From 8e0818be4aca7a84159e93b8144f6321aefdbd61 Mon Sep 17 00:00:00 2001 From: EnderProyects Date: Mon, 6 Mar 2023 23:23:19 +0100 Subject: [PATCH] spotless --- src/main/java/ab/AdvancedBotany.java | 53 +- src/main/java/ab/AdvancedBotanyTab.java | 31 +- src/main/java/ab/api/AchievementAB.java | 17 +- src/main/java/ab/api/AdvancedBotanyAPI.java | 82 +- src/main/java/ab/api/IBoundRender.java | 5 +- src/main/java/ab/api/IRankItem.java | 9 +- src/main/java/ab/api/IRenderHud.java | 2 +- src/main/java/ab/api/TerraFarmlandList.java | 30 +- .../ab/api/recipe/RecipeAdvancedPlate.java | 115 ++- .../ab/api/recipe/RecipeAncientAlphirine.java | 62 +- .../lexicon/AdvancedPlateCraftPage.java | 200 ++-- .../recipe/lexicon/AlphirineCraftPage.java | 156 +-- .../java/ab/client/core/ClientHelper.java | 434 ++++---- .../core/handler/BoundRenderHandler.java | 216 ++-- .../ab/client/core/handler/ClientHandler.java | 215 ++-- .../core/handler/GuiABConfigHandler.java | 19 +- .../ab/client/core/handler/GuiABFactory.java | 29 +- .../client/core/handler/HudRenderHandler.java | 80 +- .../core/handler/ItemsRemainingRender.java | 106 +- .../core/handler/PlayerItemUsingSound.java | 146 +-- .../core/handler/PlayerRendererHandler.java | 149 +-- .../ab/client/core/proxy/ClientProxy.java | 76 +- .../ab/client/gui/ContainerItemChest.java | 137 +-- src/main/java/ab/client/gui/GuiItemChest.java | 48 +- .../ab/client/gui/InventoryItemChest.java | 216 ++-- .../java/ab/client/gui/SlotItemChest.java | 30 +- .../java/ab/client/model/ModelDiceFate.java | 48 +- .../ab/client/model/ModelEngineerHopper.java | 106 +- .../ab/client/model/ModelManaCharger.java | 227 +++-- .../ab/client/model/ModelManaContainer.java | 68 +- .../ab/client/model/ModelNidavellirForge.java | 74 +- .../client/model/armor/ModelArmorNebula.java | 650 ++++++------ .../model/armor/ModelArmorWildHunt.java | 686 ++++++------- src/main/java/ab/client/nei/NEIConfig.java | 30 +- .../nei/RecipeHandlerAdvancedPlate.java | 208 ++-- .../ab/client/nei/RecipeHandlerAlphirine.java | 208 ++-- .../render/block/RenderBlockABSpreader.java | 54 +- .../block/RenderBlockEngineerHopper.java | 54 +- .../render/block/RenderBlockManaCharger.java | 54 +- .../block/RenderBlockManaContainer.java | 56 +- .../block/RenderBlockManaCrystalCube.java | 54 +- .../block/RenderBlockNidavellirForge.java | 56 +- .../render/entity/EntityNullRender.java | 12 +- .../entity/RenderEntityAdvancedSpark.java | 25 +- .../entity/RenderEntityAlphirinePortal.java | 72 +- .../item/RenderItemAntigravityCharm.java | 107 +- .../item/RenderItemSphereNavigation.java | 111 ++- .../render/tile/RenderTileABSpreader.java | 37 +- .../render/tile/RenderTileBoardFate.java | 128 +-- .../render/tile/RenderTileEngineerHopper.java | 44 +- .../render/tile/RenderTileGameBoard.java | 166 ++-- .../tile/RenderTileMagicCraftingCrate.java | 223 +++-- .../render/tile/RenderTileManaCharger.java | 155 +-- .../render/tile/RenderTileManaContainer.java | 142 ++- .../tile/RenderTileManaCrystalCube.java | 90 +- .../tile/RenderTileNidavellirForge.java | 162 ++- .../ab/client/render/tile/TileRenderer.java | 181 ++-- .../java/ab/common/block/BlockABSpreader.java | 273 +++-- .../java/ab/common/block/BlockABStorage.java | 76 +- .../ab/common/block/BlockAntigravitation.java | 71 +- .../java/ab/common/block/BlockBoardFate.java | 269 +++-- .../ab/common/block/BlockEngineerHopper.java | 151 ++- .../java/ab/common/block/BlockFreyrLiana.java | 111 ++- .../ab/common/block/BlockLebethronWood.java | 216 ++-- .../common/block/BlockLuminousFreyrLiana.java | 73 +- .../ab/common/block/BlockMagicCraftCrate.java | 476 +++++---- .../ab/common/block/BlockManaCharger.java | 223 +++-- .../ab/common/block/BlockManaContainer.java | 111 +-- .../ab/common/block/BlockManaCrystalCube.java | 114 +-- .../ab/common/block/BlockNidavellirForge.java | 262 ++--- .../ab/common/block/BlockTerraFarmland.java | 170 ++-- .../block/subtile/ABSubTileSignature.java | 87 +- .../subtile/SubTileAncientAlphirine.java | 237 +++-- .../subtile/SubTileArdentAzarcissus.java | 161 ++- .../block/subtile/SubTileAspecolus.java | 157 ++- .../block/subtile/SubTileDictarius.java | 216 ++-- .../block/subtile/SubTilePureGladiolus.java | 133 +-- .../ab/common/block/tile/TileABSpreader.java | 200 ++-- .../ab/common/block/tile/TileBoardFate.java | 300 +++--- .../common/block/tile/TileEngineerHopper.java | 585 ++++++----- .../ab/common/block/tile/TileGameBoard.java | 469 +++++---- .../ab/common/block/tile/TileInventory.java | 159 ++- .../common/block/tile/TileLebethronCore.java | 379 +++---- .../block/tile/TileMagicCraftCrate.java | 512 +++++----- .../ab/common/block/tile/TileManaCharger.java | 499 +++++----- .../common/block/tile/TileManaContainer.java | 205 ++-- .../block/tile/TileManaCrystalCube.java | 77 +- .../block/tile/TileNidavellirForge.java | 497 +++++----- .../java/ab/common/core/CommonHelper.java | 99 +- .../common/core/handler/ConfigABHandler.java | 414 ++++---- .../ab/common/core/handler/GuiHandler.java | 39 +- .../common/core/handler/NetworkHandler.java | 49 +- .../ab/common/core/proxy/CommonProxy.java | 45 +- .../proxy/packet/S00PacketHornChargeHud.java | 49 +- .../proxy/packet/S01PacketFindNearBlocks.java | 64 +- .../proxy/packet/S02PacketSpaceBladeDash.java | 19 +- .../ab/common/entity/EntityAdvancedSpark.java | 560 +++++------ .../common/entity/EntityAlphirinePortal.java | 87 +- .../common/entity/EntityAnonymousSteve.java | 55 +- .../java/ab/common/entity/EntityManaVine.java | 333 ++++--- .../ab/common/entity/EntityNebulaBlaze.java | 214 ++-- .../java/ab/common/entity/EntitySeed.java | 329 +++--- .../java/ab/common/entity/EntitySword.java | 218 ++-- .../java/ab/common/item/ItemABResource.java | 156 ++- .../ab/common/item/ItemAdvancedSpark.java | 85 +- .../ab/common/item/ItemAntigravityCharm.java | 137 +-- .../ab/common/item/ItemCraftingPattern.java | 157 ++- src/main/java/ab/common/item/ItemMod.java | 13 +- .../ab/common/item/block/ItemBlockBase.java | 23 +- .../ab/common/item/block/ItemBlockBoard.java | 45 +- .../common/item/equipment/ItemAquaSword.java | 244 ++--- .../ab/common/item/equipment/ItemBauble.java | 306 +++--- .../common/item/equipment/ItemBlackHalo.java | 645 ++++++------ .../common/item/equipment/ItemManaFlower.java | 39 +- .../item/equipment/ItemMithrillMultiTool.java | 130 ++- .../item/equipment/ItemMithrillRing.java | 135 +-- .../item/equipment/ItemNebulaBlaze.java | 62 +- .../common/item/equipment/ItemNebulaRing.java | 34 +- .../common/item/equipment/ItemNebulaRod.java | 302 +++--- .../common/item/equipment/ItemSpaceBlade.java | 543 +++++----- .../common/item/equipment/ItemSprawlRod.java | 310 +++--- .../common/item/equipment/ItemTerraHoe.java | 152 +-- .../item/equipment/armor/ItemNebulaArmor.java | 276 +++--- .../item/equipment/armor/ItemNebulaBoots.java | 133 +-- .../item/equipment/armor/ItemNebulaChest.java | 99 +- .../item/equipment/armor/ItemNebulaHelm.java | 169 ++-- .../armor/ItemNebulaHelmRevealing.java | 30 +- .../item/equipment/armor/ItemNebulaLegs.java | 58 +- .../equipment/armor/ItemWildHuntArmor.java | 123 +-- .../equipment/armor/ItemWildHuntBoots.java | 6 +- .../equipment/armor/ItemWildHuntChest.java | 8 +- .../equipment/armor/ItemWildHuntHelm.java | 8 +- .../equipment/armor/ItemWildHuntLegs.java | 8 +- .../common/item/relic/ItemFreyrSlingshot.java | 108 +- .../ab/common/item/relic/ItemHornPlenty.java | 259 ++--- .../ab/common/item/relic/ItemModRelic.java | 80 +- .../common/item/relic/ItemPocketWardrobe.java | 585 ++++++----- .../item/relic/ItemSphereNavigation.java | 372 +++---- .../item/relic/ItemTalismanHiddenRiches.java | 511 +++++----- .../lib/register/AchievementRegister.java | 66 +- .../ab/common/lib/register/BlockListAB.java | 183 ++-- .../ab/common/lib/register/EntityListAB.java | 34 +- .../common/lib/register/FlowerRegister.java | 36 +- .../ab/common/lib/register/ItemListAB.java | 183 ++-- .../ab/common/lib/register/RecipeListAB.java | 937 ++++++++++++------ .../common/minetweaker/AdvancedPlateMT.java | 183 ++-- .../minetweaker/AdvancedPlatePageMT.java | 258 ++--- .../ab/common/minetweaker/AlphirineMT.java | 179 ++-- .../common/minetweaker/AlphirinePageMT.java | 259 ++--- .../common/minetweaker/MineTweakerConfig.java | 12 +- 150 files changed, 13246 insertions(+), 12429 deletions(-) diff --git a/src/main/java/ab/AdvancedBotany.java b/src/main/java/ab/AdvancedBotany.java index c16d481..69f8220 100644 --- a/src/main/java/ab/AdvancedBotany.java +++ b/src/main/java/ab/AdvancedBotany.java @@ -1,40 +1,45 @@ package ab; +import net.minecraft.creativetab.CreativeTabs; + import ab.common.core.proxy.CommonProxy; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraftforge.common.MinecraftForge; -@Mod (modid = AdvancedBotany.modid, name="Advanced Botany", version = AdvancedBotany.version, dependencies = "required-after:Botania", guiFactory = "ab.client.core.handler.GuiABFactory") +@Mod( + modid = AdvancedBotany.modid, + name = "Advanced Botany", + version = AdvancedBotany.version, + dependencies = "required-after:Botania", + guiFactory = "ab.client.core.handler.GuiABFactory") public class AdvancedBotany { - - public static final String modid = "AdvancedBotany"; - public static final String version = "1.3.1.5"; - @Mod.Instance("AdvancedBotany") + public static final String modid = "AdvancedBotany"; + public static final String version = "1.3.1.5"; + + @Mod.Instance("AdvancedBotany") public static AdvancedBotany instance; - - @SidedProxy(clientSide = "ab.client.core.proxy.ClientProxy", serverSide = "ab.common.core.proxy.CommonProxy") + + @SidedProxy(clientSide = "ab.client.core.proxy.ClientProxy", serverSide = "ab.common.core.proxy.CommonProxy") public static CommonProxy proxy; - - @Mod.EventHandler - public void preInit(FMLPreInitializationEvent event) { - proxy.preInit(event); - } - @Mod.EventHandler - public void init(FMLInitializationEvent event) { - proxy.init(event); - } + @Mod.EventHandler + public void preInit(FMLPreInitializationEvent event) { + proxy.preInit(event); + } - @Mod.EventHandler - public void postInit(FMLPostInitializationEvent event) { - proxy.postInit(event); - } - - public static final CreativeTabs tabAB = new AdvancedBotanyTab("tabAB"); + @Mod.EventHandler + public void init(FMLInitializationEvent event) { + proxy.init(event); + } + + @Mod.EventHandler + public void postInit(FMLPostInitializationEvent event) { + proxy.postInit(event); + } + + public static final CreativeTabs tabAB = new AdvancedBotanyTab("tabAB"); } diff --git a/src/main/java/ab/AdvancedBotanyTab.java b/src/main/java/ab/AdvancedBotanyTab.java index 7b50763..cfcf8bb 100644 --- a/src/main/java/ab/AdvancedBotanyTab.java +++ b/src/main/java/ab/AdvancedBotanyTab.java @@ -1,24 +1,23 @@ package ab; -import ab.common.lib.register.BlockListAB; -import ab.common.lib.register.ItemListAB; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; +import ab.common.lib.register.BlockListAB; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + public class AdvancedBotanyTab extends CreativeTabs { - public AdvancedBotanyTab(String str) { - super(str); - this.setNoTitle(); - this.setBackgroundImageName("ab.png"); - } - - @SideOnly(Side.CLIENT) - public Item getTabIconItem() { - return ItemBlock.getItemFromBlock(BlockListAB.blockABSpreader); - } -} \ No newline at end of file + public AdvancedBotanyTab(String str) { + super(str); + this.setNoTitle(); + this.setBackgroundImageName("ab.png"); + } + + @SideOnly(Side.CLIENT) + public Item getTabIconItem() { + return ItemBlock.getItemFromBlock(BlockListAB.blockABSpreader); + } +} diff --git a/src/main/java/ab/api/AchievementAB.java b/src/main/java/ab/api/AchievementAB.java index a255eea..4c4aaaf 100644 --- a/src/main/java/ab/api/AchievementAB.java +++ b/src/main/java/ab/api/AchievementAB.java @@ -1,17 +1,16 @@ package ab.api; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.stats.Achievement; + import vazkii.botania.api.item.IRelic; public class AchievementAB extends Achievement { - - public AchievementAB(String name, int x, int y, ItemStack icon, Achievement parent) { - super("achievement.ab:" + name, "ab:" + name, x, y, icon, parent); - AdvancedBotanyAPI.achievements.add(this); - registerStat(); - if(icon.getItem() instanceof IRelic) - ((IRelic)icon.getItem()).setBindAchievement(this); - } + + public AchievementAB(String name, int x, int y, ItemStack icon, Achievement parent) { + super("achievement.ab:" + name, "ab:" + name, x, y, icon, parent); + AdvancedBotanyAPI.achievements.add(this); + registerStat(); + if (icon.getItem() instanceof IRelic) ((IRelic) icon.getItem()).setBindAchievement(this); + } } diff --git a/src/main/java/ab/api/AdvancedBotanyAPI.java b/src/main/java/ab/api/AdvancedBotanyAPI.java index dbe8568..1fa307e 100644 --- a/src/main/java/ab/api/AdvancedBotanyAPI.java +++ b/src/main/java/ab/api/AdvancedBotanyAPI.java @@ -3,10 +3,6 @@ package ab.api; import java.util.ArrayList; import java.util.List; -import ab.api.recipe.RecipeAdvancedPlate; -import ab.api.recipe.RecipeAncientAlphirine; -import ab.common.core.handler.ConfigABHandler; -import ab.common.lib.register.ItemListAB; import net.minecraft.block.Block; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; @@ -15,39 +11,51 @@ import net.minecraft.item.ItemStack; import net.minecraft.stats.Achievement; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.EnumHelper; -import vazkii.botania.common.item.ModItems; + +import ab.api.recipe.RecipeAdvancedPlate; +import ab.api.recipe.RecipeAncientAlphirine; +import ab.common.core.handler.ConfigABHandler; public class AdvancedBotanyAPI { - public static List advancedPlateRecipes = new ArrayList(); - public static List alphirineRecipes = new ArrayList(); - public static List farmlandList = new ArrayList(); - public static List achievements = new ArrayList(); - public static List relicList = new ArrayList(); - public static List diceList = new ArrayList(); - - public static Item.ToolMaterial mithrilToolMaterial = EnumHelper.addToolMaterial("MITHRIL", 7, -1, 8.0F, 4.0F, 24); - public static ItemArmor.ArmorMaterial nebulaArmorMaterial = EnumHelper.addArmorMaterial("NEBULA", 0, new int[] { (int)(3 * ConfigABHandler.protectionFactorNebula), (int)(8 * ConfigABHandler.protectionFactorNebula), (int)(6 * ConfigABHandler.protectionFactorNebula), (int)(3 * ConfigABHandler.protectionFactorNebula) }, 26); - public static ItemArmor.ArmorMaterial wildHundArmor = EnumHelper.addArmorMaterial("WILD_HUNT_MATERIAL", 34, new int[] { 7, 8, 3, 2 }, 26); - - public static EnumRarity rarityNebula = EnumHelper.addRarity("NEBULA", EnumChatFormatting.LIGHT_PURPLE, "Nebula"); - public static EnumRarity rarityWildHunt = EnumHelper.addRarity("WILD_HUNT", EnumChatFormatting.AQUA, "WildHunt"); - - public static RecipeAdvancedPlate registerAdvancedPlateRecipe(ItemStack output, ItemStack input1, ItemStack input2, ItemStack input3, int mana, int color) { - RecipeAdvancedPlate recipe = new RecipeAdvancedPlate(output, mana, color, input1, input2, input3); - advancedPlateRecipes.add(recipe); - return recipe; - } - - public static RecipeAncientAlphirine registerAlphirineRecipe(ItemStack output, ItemStack input, int chance) { - RecipeAncientAlphirine recipe = new RecipeAncientAlphirine(output, input, chance); - alphirineRecipes.add(recipe); - return recipe; - } - - public static TerraFarmlandList registerFarmlandSeed(Block block, int meta) { - TerraFarmlandList seed = new TerraFarmlandList(block, meta); - farmlandList.add(seed); - return seed; - } -} \ No newline at end of file + public static List advancedPlateRecipes = new ArrayList(); + public static List alphirineRecipes = new ArrayList(); + public static List farmlandList = new ArrayList(); + public static List achievements = new ArrayList(); + public static List relicList = new ArrayList(); + public static List diceList = new ArrayList(); + + public static Item.ToolMaterial mithrilToolMaterial = EnumHelper.addToolMaterial("MITHRIL", 7, -1, 8.0F, 4.0F, 24); + public static ItemArmor.ArmorMaterial nebulaArmorMaterial = EnumHelper.addArmorMaterial( + "NEBULA", + 0, + new int[] { (int) (3 * ConfigABHandler.protectionFactorNebula), + (int) (8 * ConfigABHandler.protectionFactorNebula), + (int) (6 * ConfigABHandler.protectionFactorNebula), + (int) (3 * ConfigABHandler.protectionFactorNebula) }, + 26); + public static ItemArmor.ArmorMaterial wildHundArmor = EnumHelper + .addArmorMaterial("WILD_HUNT_MATERIAL", 34, new int[] { 7, 8, 3, 2 }, 26); + + public static EnumRarity rarityNebula = EnumHelper.addRarity("NEBULA", EnumChatFormatting.LIGHT_PURPLE, "Nebula"); + public static EnumRarity rarityWildHunt = EnumHelper.addRarity("WILD_HUNT", EnumChatFormatting.AQUA, "WildHunt"); + + public static RecipeAdvancedPlate registerAdvancedPlateRecipe(ItemStack output, ItemStack input1, ItemStack input2, + ItemStack input3, int mana, int color) { + RecipeAdvancedPlate recipe = new RecipeAdvancedPlate(output, mana, color, input1, input2, input3); + advancedPlateRecipes.add(recipe); + return recipe; + } + + public static RecipeAncientAlphirine registerAlphirineRecipe(ItemStack output, ItemStack input, int chance) { + RecipeAncientAlphirine recipe = new RecipeAncientAlphirine(output, input, chance); + alphirineRecipes.add(recipe); + return recipe; + } + + public static TerraFarmlandList registerFarmlandSeed(Block block, int meta) { + TerraFarmlandList seed = new TerraFarmlandList(block, meta); + farmlandList.add(seed); + return seed; + } +} diff --git a/src/main/java/ab/api/IBoundRender.java b/src/main/java/ab/api/IBoundRender.java index 2727d55..801d688 100644 --- a/src/main/java/ab/api/IBoundRender.java +++ b/src/main/java/ab/api/IBoundRender.java @@ -1,9 +1,10 @@ package ab.api; import net.minecraft.util.ChunkCoordinates; + import vazkii.botania.api.wand.IWandBindable; public interface IBoundRender extends IWandBindable { - - public ChunkCoordinates[] getBlocksCoord(); + + public ChunkCoordinates[] getBlocksCoord(); } diff --git a/src/main/java/ab/api/IRankItem.java b/src/main/java/ab/api/IRankItem.java index 08ee4bb..b76a28e 100644 --- a/src/main/java/ab/api/IRankItem.java +++ b/src/main/java/ab/api/IRankItem.java @@ -1,11 +1,12 @@ package ab.api; import net.minecraft.item.ItemStack; + import vazkii.botania.api.mana.IManaItem; public interface IRankItem extends IManaItem { - - public int getLevel(ItemStack stack); - - public int[] getLevels(); + + public int getLevel(ItemStack stack); + + public int[] getLevels(); } diff --git a/src/main/java/ab/api/IRenderHud.java b/src/main/java/ab/api/IRenderHud.java index 04558bc..f194a24 100644 --- a/src/main/java/ab/api/IRenderHud.java +++ b/src/main/java/ab/api/IRenderHud.java @@ -5,5 +5,5 @@ import net.minecraft.client.gui.ScaledResolution; public interface IRenderHud { - public void renderHud(Minecraft mc, ScaledResolution res); + public void renderHud(Minecraft mc, ScaledResolution res); } diff --git a/src/main/java/ab/api/TerraFarmlandList.java b/src/main/java/ab/api/TerraFarmlandList.java index 05c90da..092a27b 100644 --- a/src/main/java/ab/api/TerraFarmlandList.java +++ b/src/main/java/ab/api/TerraFarmlandList.java @@ -4,19 +4,19 @@ import net.minecraft.block.Block; public class TerraFarmlandList { - Block block; - int meta; - - public TerraFarmlandList(Block block, int meta) { - this.block = block; - this.meta = meta; - } - - public Block getBlock() { - return block; - } - - public int getMeta() { - return meta; - } + Block block; + int meta; + + public TerraFarmlandList(Block block, int meta) { + this.block = block; + this.meta = meta; + } + + public Block getBlock() { + return block; + } + + public int getMeta() { + return meta; + } } diff --git a/src/main/java/ab/api/recipe/RecipeAdvancedPlate.java b/src/main/java/ab/api/recipe/RecipeAdvancedPlate.java index 72a3895..d17cb8d 100644 --- a/src/main/java/ab/api/recipe/RecipeAdvancedPlate.java +++ b/src/main/java/ab/api/recipe/RecipeAdvancedPlate.java @@ -8,63 +8,60 @@ import net.minecraft.item.ItemStack; public class RecipeAdvancedPlate { - private ItemStack output; - private int color; - private List inputs; - private int mana; - - public RecipeAdvancedPlate(ItemStack output, int mana, int color, ItemStack... inputs) { - this.output = output; - this.mana = mana; - this.color = color; - List inputsToSet = new ArrayList(); - for (ItemStack obj : inputs) - inputsToSet.add(obj); - this.inputs = inputsToSet; - } - - public List getInputs() { - return new ArrayList(this.inputs); - } - - public ItemStack getOutput() { - return this.output; - } - - public int getManaUsage() { - return this.mana; - } - - public int getColor() { - return this.color; - } - - public boolean matches(IInventory inv) { - List inputsMissing = new ArrayList(this.inputs); - for (int i = 1; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if (stack == null) - break; - int stackIndex = -1; - for (int j = 0; j < inputsMissing.size(); j++) { - ItemStack input = inputsMissing.get(j); - if (input instanceof ItemStack && simpleAreStacksEqual(input.copy(), stack)) { - stackIndex = j; - break; - } - } - if (stackIndex != -1) { - inputsMissing.remove(stackIndex); - } else { - return false; - } - } - return inputsMissing.isEmpty(); - } - - boolean simpleAreStacksEqual(ItemStack input, ItemStack stack) { - if(input.getItemDamage() == 32767) - input.setItemDamage(stack.getItemDamage()); - return (input.getItem() == stack.getItem() && input.getItemDamage() == stack.getItemDamage()); - } + private ItemStack output; + private int color; + private List inputs; + private int mana; + + public RecipeAdvancedPlate(ItemStack output, int mana, int color, ItemStack... inputs) { + this.output = output; + this.mana = mana; + this.color = color; + List inputsToSet = new ArrayList(); + for (ItemStack obj : inputs) inputsToSet.add(obj); + this.inputs = inputsToSet; + } + + public List getInputs() { + return new ArrayList(this.inputs); + } + + public ItemStack getOutput() { + return this.output; + } + + public int getManaUsage() { + return this.mana; + } + + public int getColor() { + return this.color; + } + + public boolean matches(IInventory inv) { + List inputsMissing = new ArrayList(this.inputs); + for (int i = 1; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if (stack == null) break; + int stackIndex = -1; + for (int j = 0; j < inputsMissing.size(); j++) { + ItemStack input = inputsMissing.get(j); + if (input instanceof ItemStack && simpleAreStacksEqual(input.copy(), stack)) { + stackIndex = j; + break; + } + } + if (stackIndex != -1) { + inputsMissing.remove(stackIndex); + } else { + return false; + } + } + return inputsMissing.isEmpty(); + } + + boolean simpleAreStacksEqual(ItemStack input, ItemStack stack) { + if (input.getItemDamage() == 32767) input.setItemDamage(stack.getItemDamage()); + return (input.getItem() == stack.getItem() && input.getItemDamage() == stack.getItemDamage()); + } } diff --git a/src/main/java/ab/api/recipe/RecipeAncientAlphirine.java b/src/main/java/ab/api/recipe/RecipeAncientAlphirine.java index b690667..9210587 100644 --- a/src/main/java/ab/api/recipe/RecipeAncientAlphirine.java +++ b/src/main/java/ab/api/recipe/RecipeAncientAlphirine.java @@ -1,40 +1,36 @@ package ab.api.recipe; -import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; public class RecipeAncientAlphirine { - private ItemStack output; - private ItemStack input; - private int chance; - - public RecipeAncientAlphirine(ItemStack output, ItemStack input, int chance) { - this.output = output; - this.input = input; - if(chance > 100) - chance = 100; - else if(chance <= 0) - chance = 1; - this.chance = chance; - } - - public ItemStack getOutput() { - return output; - } - - public ItemStack getInput() { - return input; - } - - public int getChance() { - return chance; - } - - public boolean matches(ItemStack stack) { - ItemStack inputCopy = this.input.copy(); - if(inputCopy.getItemDamage() == 32767) - inputCopy.setItemDamage(stack.getItemDamage()); - return stack.getItem() == input.getItem() && stack.getItemDamage() == inputCopy.getItemDamage(); - } + private ItemStack output; + private ItemStack input; + private int chance; + + public RecipeAncientAlphirine(ItemStack output, ItemStack input, int chance) { + this.output = output; + this.input = input; + if (chance > 100) chance = 100; + else if (chance <= 0) chance = 1; + this.chance = chance; + } + + public ItemStack getOutput() { + return output; + } + + public ItemStack getInput() { + return input; + } + + public int getChance() { + return chance; + } + + public boolean matches(ItemStack stack) { + ItemStack inputCopy = this.input.copy(); + if (inputCopy.getItemDamage() == 32767) inputCopy.setItemDamage(stack.getItemDamage()); + return stack.getItem() == input.getItem() && stack.getItemDamage() == inputCopy.getItemDamage(); + } } diff --git a/src/main/java/ab/api/recipe/lexicon/AdvancedPlateCraftPage.java b/src/main/java/ab/api/recipe/lexicon/AdvancedPlateCraftPage.java index 47994fa..3fc7db7 100644 --- a/src/main/java/ab/api/recipe/lexicon/AdvancedPlateCraftPage.java +++ b/src/main/java/ab/api/recipe/lexicon/AdvancedPlateCraftPage.java @@ -3,14 +3,6 @@ package ab.api.recipe.lexicon; import java.util.ArrayList; import java.util.List; -import org.lwjgl.opengl.GL11; - -import ab.api.AdvancedBotanyAPI; -import ab.api.recipe.RecipeAdvancedPlate; -import ab.client.core.ClientHelper; -import ab.common.lib.register.BlockListAB; -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.GuiScreen; @@ -18,104 +10,114 @@ import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; + +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.handler.ClientTickHandler; -import vazkii.botania.client.core.handler.HUDHandler; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lexicon.page.PageRecipe; +import ab.api.AdvancedBotanyAPI; +import ab.api.recipe.RecipeAdvancedPlate; +import ab.client.core.ClientHelper; +import ab.common.lib.register.BlockListAB; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class AdvancedPlateCraftPage extends PageRecipe { - - private static final ResourceLocation plateOverlay = new ResourceLocation("botania:textures/gui/petalOverlay.png"); - private RecipeAdvancedPlate recipe; - private final ItemStack resultStack; - int ticksElapsed = 0; - public AdvancedPlateCraftPage(LexiconEntry entry, ItemStack stack) { - this(entry, stack, ""); - } - - public AdvancedPlateCraftPage(LexiconEntry entry, ItemStack stack, String str) { - super(str); - resultStack = stack; - refreshRecipe(entry, stack); - } - - public ItemStack getResult() { - return resultStack; - } - - public void refreshRecipe(LexiconEntry entry, ItemStack stack) { - RecipeAdvancedPlate rec = null; - for(RecipeAdvancedPlate recipe : AdvancedBotanyAPI.advancedPlateRecipes) { - if(stack != null && recipe.getOutput() != null && recipe.getOutput().isItemEqual(stack)) { - rec = recipe; - break; - } - } - if(rec == null) - entry.pages.remove(this); - recipe = rec; - } - - public void onPageAdded(LexiconEntry entry, int index) { - LexiconRecipeMappings.map(recipe.getOutput(), entry, index); - } - - @SideOnly(Side.CLIENT) - public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { - TextureManager render = (Minecraft.getMinecraft()).renderEngine; - renderItemAtGridPos(gui, 3, 0, recipe.getOutput(), false); - renderItemAtGridPos(gui, 2, 1, new ItemStack(BlockListAB.blockABPlate), false); - List inputs = recipe.getInputs(); - int degreePerInput = (int)(360.0F / inputs.size()); - float currentDegree = ConfigHandler.lexiconRotatingItems ? (GuiScreen.isShiftKeyDown() ? this.ticksElapsed : (this.ticksElapsed + ClientTickHandler.partialTicks)) : 0.0F; - for (ItemStack obj : inputs) { - ItemStack copy = obj.copy(); - if (copy.getItemDamage() == 32767) - copy.setItemDamage(0); - renderItemAtAngle(gui, currentDegree, copy); - currentDegree += degreePerInput; - } - renderManaBar(gui, mx, my); - render.bindTexture(plateOverlay); - GL11.glEnable(3042); - GL11.glBlendFunc(770, 771); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - ((GuiScreen)gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); - GL11.glDisable(3042); - } - - @SideOnly(Side.CLIENT) - public void renderManaBar(IGuiLexiconEntry gui, int mx, int my) { - FontRenderer font = (Minecraft.getMinecraft()).fontRenderer; - GL11.glEnable(3042); - GL11.glBlendFunc(770, 771); - String manaUsage = StatCollector.translateToLocal("botaniamisc.manaUsage"); - font.drawString(manaUsage, gui.getLeft() + gui.getWidth() / 2 - font.getStringWidth(manaUsage) / 2, gui.getTop() + 105, 1711276032); - int x = gui.getLeft() + gui.getWidth() / 2 - 50; - int y = gui.getTop() + 120; - String stopStr = StatCollector.translateToLocal("botaniamisc.shiftToStopSpin"); - ClientHelper.renderPoolManaBar(x, y - 5, 0x239ddc, 1.0f, this.recipe.getManaUsage()); - boolean unicode = font.getUnicodeFlag(); - font.setUnicodeFlag(true); - font.drawString(stopStr, x + 49 - font.getStringWidth(stopStr) / 2, y + 18, -1728053248); - font.setUnicodeFlag(unicode); - GL11.glDisable(3042); - } - - @SideOnly(Side.CLIENT) - public void updateScreen() { - if (GuiScreen.isShiftKeyDown()) - return; - this.ticksElapsed++; - } - - public List getDisplayedRecipes() { - ArrayList list = new ArrayList(); - list.add(recipe.getOutput()); - return list; - } + private static final ResourceLocation plateOverlay = new ResourceLocation("botania:textures/gui/petalOverlay.png"); + private RecipeAdvancedPlate recipe; + private final ItemStack resultStack; + int ticksElapsed = 0; + + public AdvancedPlateCraftPage(LexiconEntry entry, ItemStack stack) { + this(entry, stack, ""); + } + + public AdvancedPlateCraftPage(LexiconEntry entry, ItemStack stack, String str) { + super(str); + resultStack = stack; + refreshRecipe(entry, stack); + } + + public ItemStack getResult() { + return resultStack; + } + + public void refreshRecipe(LexiconEntry entry, ItemStack stack) { + RecipeAdvancedPlate rec = null; + for (RecipeAdvancedPlate recipe : AdvancedBotanyAPI.advancedPlateRecipes) { + if (stack != null && recipe.getOutput() != null && recipe.getOutput().isItemEqual(stack)) { + rec = recipe; + break; + } + } + if (rec == null) entry.pages.remove(this); + recipe = rec; + } + + public void onPageAdded(LexiconEntry entry, int index) { + LexiconRecipeMappings.map(recipe.getOutput(), entry, index); + } + + @SideOnly(Side.CLIENT) + public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { + TextureManager render = (Minecraft.getMinecraft()).renderEngine; + renderItemAtGridPos(gui, 3, 0, recipe.getOutput(), false); + renderItemAtGridPos(gui, 2, 1, new ItemStack(BlockListAB.blockABPlate), false); + List inputs = recipe.getInputs(); + int degreePerInput = (int) (360.0F / inputs.size()); + float currentDegree = ConfigHandler.lexiconRotatingItems ? (GuiScreen.isShiftKeyDown() ? this.ticksElapsed + : (this.ticksElapsed + ClientTickHandler.partialTicks)) : 0.0F; + for (ItemStack obj : inputs) { + ItemStack copy = obj.copy(); + if (copy.getItemDamage() == 32767) copy.setItemDamage(0); + renderItemAtAngle(gui, currentDegree, copy); + currentDegree += degreePerInput; + } + renderManaBar(gui, mx, my); + render.bindTexture(plateOverlay); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); + GL11.glDisable(3042); + } + + @SideOnly(Side.CLIENT) + public void renderManaBar(IGuiLexiconEntry gui, int mx, int my) { + FontRenderer font = (Minecraft.getMinecraft()).fontRenderer; + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + String manaUsage = StatCollector.translateToLocal("botaniamisc.manaUsage"); + font.drawString( + manaUsage, + gui.getLeft() + gui.getWidth() / 2 - font.getStringWidth(manaUsage) / 2, + gui.getTop() + 105, + 1711276032); + int x = gui.getLeft() + gui.getWidth() / 2 - 50; + int y = gui.getTop() + 120; + String stopStr = StatCollector.translateToLocal("botaniamisc.shiftToStopSpin"); + ClientHelper.renderPoolManaBar(x, y - 5, 0x239ddc, 1.0f, this.recipe.getManaUsage()); + boolean unicode = font.getUnicodeFlag(); + font.setUnicodeFlag(true); + font.drawString(stopStr, x + 49 - font.getStringWidth(stopStr) / 2, y + 18, -1728053248); + font.setUnicodeFlag(unicode); + GL11.glDisable(3042); + } + + @SideOnly(Side.CLIENT) + public void updateScreen() { + if (GuiScreen.isShiftKeyDown()) return; + this.ticksElapsed++; + } + + public List getDisplayedRecipes() { + ArrayList list = new ArrayList(); + list.add(recipe.getOutput()); + return list; + } } diff --git a/src/main/java/ab/api/recipe/lexicon/AlphirineCraftPage.java b/src/main/java/ab/api/recipe/lexicon/AlphirineCraftPage.java index 5e70d5b..dffa016 100644 --- a/src/main/java/ab/api/recipe/lexicon/AlphirineCraftPage.java +++ b/src/main/java/ab/api/recipe/lexicon/AlphirineCraftPage.java @@ -3,14 +3,6 @@ package ab.api.recipe.lexicon; import java.util.ArrayList; import java.util.List; -import org.lwjgl.opengl.GL11; - -import ab.api.AdvancedBotanyAPI; -import ab.api.recipe.RecipeAdvancedPlate; -import ab.api.recipe.RecipeAncientAlphirine; -import ab.client.core.ClientHelper; -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.GuiScreen; @@ -19,79 +11,91 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; + +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.common.item.block.ItemBlockSpecialFlower; import vazkii.botania.common.lexicon.page.PageRecipe; -import vazkii.botania.common.lexicon.page.PageText; +import ab.api.AdvancedBotanyAPI; +import ab.api.recipe.RecipeAncientAlphirine; +import ab.client.core.ClientHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class AlphirineCraftPage extends PageRecipe { - - private static final ResourceLocation alphirineOverlay = new ResourceLocation("botania:textures/gui/pureDaisyOverlay.png"); - private RecipeAncientAlphirine recipe; - private final ItemStack resultStack; - - public AlphirineCraftPage(LexiconEntry entry, ItemStack stack) { - this(entry, stack, ""); - } - - public AlphirineCraftPage(LexiconEntry entry, ItemStack stack, String str) { - super(str); - resultStack = stack; - refreshRecipe(entry, stack); - } - - public ItemStack getResult() { - return resultStack; - } - - public void refreshRecipe(LexiconEntry entry, ItemStack stack) { - RecipeAncientAlphirine rec = null; - for(RecipeAncientAlphirine recipe : AdvancedBotanyAPI.alphirineRecipes) { - if(stack != null && recipe.getOutput() != null && recipe.getOutput().isItemEqual(stack)) { - rec = recipe; - break; - } - } - if(rec == null) - entry.pages.remove(this); - recipe = rec; - } - - public void onPageAdded(LexiconEntry entry, int index) { - LexiconRecipeMappings.map(recipe.getOutput(), entry, index); - } - - @SideOnly(Side.CLIENT) - public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { - TextureManager render = (Minecraft.getMinecraft()).renderEngine; - FontRenderer font = (Minecraft.getMinecraft()).fontRenderer; - GL11.glEnable(3042); - GL11.glBlendFunc(770, 771); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - render.bindTexture(alphirineOverlay); - ((GuiScreen)gui).drawTexturedModalRect(gui.getLeft() + 40, gui.getTop() + 44, 0, 0, gui.getWidth(), gui.getHeight()); - ItemStack inp = recipe.getInput().copy(); - if(inp.getItemDamage() == 32767) - inp.setItemDamage(0); - this.renderItem(gui, gui.getLeft() + 34, gui.getTop() + 59, inp, false); - this.renderItem(gui, gui.getLeft() + 62, gui.getTop() + 57, ItemBlockSpecialFlower.ofType("ancientAlphirine").copy(), false); - this.renderItem(gui, gui.getLeft() + 93, gui.getTop() + 54, recipe.getOutput().copy(), false); - int x = gui.getLeft() + gui.getWidth() / 2 - 50; - int y = gui.getTop() + 85; - String name = EnumChatFormatting.BOLD + StatCollector.translateToLocal("ab.name.alpherine.craft"); - boolean unicode = font.getUnicodeFlag(); - font.setUnicodeFlag(true); - font.drawString(name, x + 50 - font.getStringWidth(name) / 2, y - 65, -1728053248); - font.setUnicodeFlag(unicode); - ClientHelper.drawChanceBar(x + 21, y + 14, recipe.getChance()); - GL11.glDisable(3042); - } - - public List getDisplayedRecipes() { - ArrayList list = new ArrayList(); - list.add(recipe.getOutput()); - return list; - } + + private static final ResourceLocation alphirineOverlay = new ResourceLocation( + "botania:textures/gui/pureDaisyOverlay.png"); + private RecipeAncientAlphirine recipe; + private final ItemStack resultStack; + + public AlphirineCraftPage(LexiconEntry entry, ItemStack stack) { + this(entry, stack, ""); + } + + public AlphirineCraftPage(LexiconEntry entry, ItemStack stack, String str) { + super(str); + resultStack = stack; + refreshRecipe(entry, stack); + } + + public ItemStack getResult() { + return resultStack; + } + + public void refreshRecipe(LexiconEntry entry, ItemStack stack) { + RecipeAncientAlphirine rec = null; + for (RecipeAncientAlphirine recipe : AdvancedBotanyAPI.alphirineRecipes) { + if (stack != null && recipe.getOutput() != null && recipe.getOutput().isItemEqual(stack)) { + rec = recipe; + break; + } + } + if (rec == null) entry.pages.remove(this); + recipe = rec; + } + + public void onPageAdded(LexiconEntry entry, int index) { + LexiconRecipeMappings.map(recipe.getOutput(), entry, index); + } + + @SideOnly(Side.CLIENT) + public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) { + TextureManager render = (Minecraft.getMinecraft()).renderEngine; + FontRenderer font = (Minecraft.getMinecraft()).fontRenderer; + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + render.bindTexture(alphirineOverlay); + ((GuiScreen) gui) + .drawTexturedModalRect(gui.getLeft() + 40, gui.getTop() + 44, 0, 0, gui.getWidth(), gui.getHeight()); + ItemStack inp = recipe.getInput().copy(); + if (inp.getItemDamage() == 32767) inp.setItemDamage(0); + this.renderItem(gui, gui.getLeft() + 34, gui.getTop() + 59, inp, false); + this.renderItem( + gui, + gui.getLeft() + 62, + gui.getTop() + 57, + ItemBlockSpecialFlower.ofType("ancientAlphirine").copy(), + false); + this.renderItem(gui, gui.getLeft() + 93, gui.getTop() + 54, recipe.getOutput().copy(), false); + int x = gui.getLeft() + gui.getWidth() / 2 - 50; + int y = gui.getTop() + 85; + String name = EnumChatFormatting.BOLD + StatCollector.translateToLocal("ab.name.alpherine.craft"); + boolean unicode = font.getUnicodeFlag(); + font.setUnicodeFlag(true); + font.drawString(name, x + 50 - font.getStringWidth(name) / 2, y - 65, -1728053248); + font.setUnicodeFlag(unicode); + ClientHelper.drawChanceBar(x + 21, y + 14, recipe.getChance()); + GL11.glDisable(3042); + } + + public List getDisplayedRecipes() { + ArrayList list = new ArrayList(); + list.add(recipe.getOutput()); + return list; + } } diff --git a/src/main/java/ab/client/core/ClientHelper.java b/src/main/java/ab/client/core/ClientHelper.java index b703be4..6f1c27a 100644 --- a/src/main/java/ab/client/core/ClientHelper.java +++ b/src/main/java/ab/client/core/ClientHelper.java @@ -4,239 +4,241 @@ import java.awt.Color; import java.nio.FloatBuffer; import java.util.Random; -import org.lwjgl.opengl.GL11; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.renderer.GLAllocation; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; + +import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.handler.HUDHandler; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.core.helper.Vector3; public class ClientHelper { - - public static final ResourceLocation miscHuds = new ResourceLocation("ab:textures/misc/miscHuds.png"); - 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); - public static Minecraft mc = Minecraft.getMinecraft(); - private static FloatBuffer field_147528_b = GLAllocation.createDirectFloatBuffer(16); - - public static void renderCosmicBackground() { - 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); - if (i == 0) { - mc.renderEngine.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) { - mc.renderEngine.bindTexture(field_147526_d); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); - f6 = 0.5F; - } - GL11.glTranslatef(0.0f, 1.5f, 0.0f); - 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, (float)(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); - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - Color color = Color.getHSBColor((float)Minecraft.getSystemTime() / 20.0F % 360.0F / 360.0F, 1.0F, 1.0F); - float f11 = color.getRed() / 255.0F; - float f12 = color.getGreen() / 255.0F; - float f13 = color.getBlue() / 255.0F; - tessellator.setBrightness(60); - tessellator.setColorRGBA_F(f11 * f7, f12 * f7, f13 * f7, 1.0F); - tessellator.addVertex(0.0D, f4, 0.0D); - tessellator.addVertex(0.0D, f4, 1.0D); - tessellator.addVertex(1.0D, f4, 1.0D); - tessellator.addVertex(1.0D, f4, 0.0D); - tessellator.draw(); - GL11.glPopMatrix(); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - } - GL11.glDisable(GL11.GL_BLEND); + + public static final ResourceLocation miscHuds = new ResourceLocation("ab:textures/misc/miscHuds.png"); + 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); + public static Minecraft mc = Minecraft.getMinecraft(); + private static FloatBuffer field_147528_b = GLAllocation.createDirectFloatBuffer(16); + + public static void renderCosmicBackground() { + 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); + if (i == 0) { + mc.renderEngine.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) { + mc.renderEngine.bindTexture(field_147526_d); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + f6 = 0.5F; + } + GL11.glTranslatef(0.0f, 1.5f, 0.0f); + 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, (float) (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); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + Color color = Color.getHSBColor((float) Minecraft.getSystemTime() / 20.0F % 360.0F / 360.0F, 1.0F, 1.0F); + float f11 = color.getRed() / 255.0F; + float f12 = color.getGreen() / 255.0F; + float f13 = color.getBlue() / 255.0F; + tessellator.setBrightness(60); + tessellator.setColorRGBA_F(f11 * f7, f12 * f7, f13 * f7, 1.0F); + tessellator.addVertex(0.0D, f4, 0.0D); + tessellator.addVertex(0.0D, f4, 1.0D); + tessellator.addVertex(1.0D, f4, 1.0D); + tessellator.addVertex(1.0D, f4, 0.0D); + 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); - } - - private static 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; - } - - public static void drawArrow(int x, int y, boolean side) { - mc.renderEngine.bindTexture(miscHuds); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0f); - vazkii.botania.client.core.helper.RenderHelper.drawTexturedModalRect(x, y, 0.0F, 0, 10, side ? 0 : 22, 38); - } - - public static void drawChanceBar(int x, int y, int chance) { - mc.renderEngine.bindTexture(miscHuds); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0f); - vazkii.botania.client.core.helper.RenderHelper.drawTexturedModalRect(x, y, 0.0F, 0, 0, 57, 6); - int chancePercentage = Math.max(0, (int)((chance / 100.f) * 55.0D)); - vazkii.botania.client.core.helper.RenderHelper.drawTexturedModalRect(x + 1, y + 1, 0.0F, 0, 6, 55, 4); - Color color = new Color(Color.HSBtoRGB((chance) / 360.0f, ((float)Math.sin((ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.2D) + 1.0F) * 0.3F + 0.4F, 1.0f)); - GL11.glColor4ub((byte)color.getRed(), (byte)color.getGreen(), (byte)color.getBlue(), (byte)255); - vazkii.botania.client.core.helper.RenderHelper.drawTexturedModalRect(x + 1, y + 1, 0.0F, 0, 6, Math.min(55, chancePercentage), 4); - } - - public static void renderPoolManaBar(int x, int y, int color, float alpha, int mana) { - Minecraft mc = Minecraft.getMinecraft(); - int poolCount = (int)Math.floor(mana / 1000000.0D); - if(poolCount < 0) - poolCount = 0; - int onePoolMana = mana - (poolCount * 1000000); - String strPool = poolCount + "x"; - int xc = x - mc.fontRenderer.getStringWidth(strPool) / 2; - int yc = y; - GL11.glPushMatrix(); - GL11.glTranslatef(xc + 42.0f, yc + 5.0f, 0.0f); - RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModBlocks.pool), 0, 0); - RenderHelper.disableStandardItemLighting(); - GL11.glTranslatef(18.0f, 5.0f, 300.0f); - mc.fontRenderer.drawString(strPool, 0, 0, color); - GL11.glPopMatrix(); - if((poolCount * 1000000) == mana) - onePoolMana = poolCount * 1000000; - HUDHandler.renderManaBar(x, y, color, alpha, onePoolMana, 1000000); - } - - public static void drawPoolManaHUD(ScaledResolution res, String name, int mana, int maxMana, int color) { - Minecraft mc = Minecraft.getMinecraft(); - int poolCount = (int)Math.floor(mana / 1000000.0D); - int maxPoolCount = (int)Math.floor(maxMana / 1000000.0D); - if(poolCount < 0) - poolCount = 0; - if(maxPoolCount < 0) - maxPoolCount = 0; - int onePoolMana = mana - (poolCount * 1000000); - String strPool = poolCount + "x / " + maxPoolCount + "x"; - int xc = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(strPool) / 2 - 3; - int yc = res.getScaledHeight() / 2; - GL11.glPushMatrix(); - GL11.glTranslatef(xc - 6.0f, yc + 30.0f, 0.0f); - RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModBlocks.pool), 0, 0); - RenderHelper.disableStandardItemLighting(); - GL11.glTranslatef(18.0f, 4.5f, 300.0f); - mc.fontRenderer.drawStringWithShadow(strPool, 0, 0, color); - GL11.glPopMatrix(); - if((poolCount * 1000000) == mana) - onePoolMana = poolCount * 1000000; - HUDHandler.drawSimpleManaHUD(color, onePoolMana, 1000000, name, res); - } - - public static void setLightmapTextureCoords() { - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - } - - public static Vector3 setRotation(float angel, float vX, float vY, float vZ, Vector3 v3) { - Vector3 rVec = new Vector3(vX, vY, vZ); - Vector3 rVec1 = v3.copy().normalize(); - double rAngel = Math.toRadians(angel) * 0.5f; - double sin = Math.sin(rAngel); - double x = rVec.x * sin; - double y = rVec.y * sin; - double z = rVec.z * sin; - rAngel = Math.cos(rAngel); - double d = -x * rVec1.x - y * rVec1.y - z * rVec1.z; - double d1 = rAngel * rVec1.x + y * rVec1.z - z * rVec1.y; - double d2 = rAngel * rVec1.y - x * rVec1.z + z * rVec1.x; - double d3 = rAngel * rVec1.z + x * rVec1.y - y * rVec1.x; - v3.x = d1 * rAngel - d * x - d2 * z + d3 * y; - v3.y = d2 * rAngel - d * y + d1 * z - d3 * x; - v3.z = d3 * rAngel - d * z - d1 * y + d2 * x; - return v3; - } - - public static Color getCorporeaRuneColor(int posX, int posY, int posZ, int meta) { - double time = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks; - time += (new Random((posX ^ posY ^ posZ))).nextInt(360); - float sin = (float)(Math.sin(time / 20.0f) * 0.15f) - 0.15f; - int color = 0; - switch(meta) { - case 0: - color = Color.HSBtoRGB(0.0f, 0.0f, 0.54f + (sin / 1.2f)); - break; - case 1: - color = Color.HSBtoRGB(0.688f, 0.93f, 0.96f + sin - 0.15f); - break; - case 2: - color = Color.HSBtoRGB(0.983f, 0.99f, 1.0f + sin - 0.15f); - break; - case 3: - color = Color.HSBtoRGB(0.319f, 0.92f, 0.95f + sin - 0.15f); - break; - case 4: - color = Color.HSBtoRGB(0.536f, 0.53f, 0.92f + sin - 0.15f); - break; - } - return new Color(color); - } - - public static void renderIcon(IIcon icon, int light) { - Tessellator tessellator = Tessellator.instance; - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - float f4 = 1.0F; - float f5 = 0.5F; - float f6 = 0.25F; - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 1.0F, 0.0F); - tessellator.addVertexWithUV((0.0F - f5), (0.0F - f6), 0.0D, f, f3); - tessellator.addVertexWithUV((f4 - f5), (0.0F - f6), 0.0D, f1, f3); - tessellator.addVertexWithUV((f4 - f5), (f4 - f6), 0.0D, f1, f2); - tessellator.addVertexWithUV((0.0F - f5), (f4 - f6), 0.0D, f, f2); - tessellator.draw(); - } -} \ No newline at end of file + } + + private static 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; + } + + public static void drawArrow(int x, int y, boolean side) { + mc.renderEngine.bindTexture(miscHuds); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0f); + vazkii.botania.client.core.helper.RenderHelper.drawTexturedModalRect(x, y, 0.0F, 0, 10, side ? 0 : 22, 38); + } + + public static void drawChanceBar(int x, int y, int chance) { + mc.renderEngine.bindTexture(miscHuds); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0f); + vazkii.botania.client.core.helper.RenderHelper.drawTexturedModalRect(x, y, 0.0F, 0, 0, 57, 6); + int chancePercentage = Math.max(0, (int) ((chance / 100.f) * 55.0D)); + vazkii.botania.client.core.helper.RenderHelper.drawTexturedModalRect(x + 1, y + 1, 0.0F, 0, 6, 55, 4); + Color color = new Color( + Color.HSBtoRGB( + (chance) / 360.0f, + ((float) Math.sin((ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.2D) + + 1.0F) * 0.3F + 0.4F, + 1.0f)); + GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) 255); + vazkii.botania.client.core.helper.RenderHelper + .drawTexturedModalRect(x + 1, y + 1, 0.0F, 0, 6, Math.min(55, chancePercentage), 4); + } + + public static void renderPoolManaBar(int x, int y, int color, float alpha, int mana) { + Minecraft mc = Minecraft.getMinecraft(); + int poolCount = (int) Math.floor(mana / 1000000.0D); + if (poolCount < 0) poolCount = 0; + int onePoolMana = mana - (poolCount * 1000000); + String strPool = poolCount + "x"; + int xc = x - mc.fontRenderer.getStringWidth(strPool) / 2; + int yc = y; + GL11.glPushMatrix(); + GL11.glTranslatef(xc + 42.0f, yc + 5.0f, 0.0f); + RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance() + .renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModBlocks.pool), 0, 0); + RenderHelper.disableStandardItemLighting(); + GL11.glTranslatef(18.0f, 5.0f, 300.0f); + mc.fontRenderer.drawString(strPool, 0, 0, color); + GL11.glPopMatrix(); + if ((poolCount * 1000000) == mana) onePoolMana = poolCount * 1000000; + HUDHandler.renderManaBar(x, y, color, alpha, onePoolMana, 1000000); + } + + public static void drawPoolManaHUD(ScaledResolution res, String name, int mana, int maxMana, int color) { + Minecraft mc = Minecraft.getMinecraft(); + int poolCount = (int) Math.floor(mana / 1000000.0D); + int maxPoolCount = (int) Math.floor(maxMana / 1000000.0D); + if (poolCount < 0) poolCount = 0; + if (maxPoolCount < 0) maxPoolCount = 0; + int onePoolMana = mana - (poolCount * 1000000); + String strPool = poolCount + "x / " + maxPoolCount + "x"; + int xc = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(strPool) / 2 - 3; + int yc = res.getScaledHeight() / 2; + GL11.glPushMatrix(); + GL11.glTranslatef(xc - 6.0f, yc + 30.0f, 0.0f); + RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance() + .renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModBlocks.pool), 0, 0); + RenderHelper.disableStandardItemLighting(); + GL11.glTranslatef(18.0f, 4.5f, 300.0f); + mc.fontRenderer.drawStringWithShadow(strPool, 0, 0, color); + GL11.glPopMatrix(); + if ((poolCount * 1000000) == mana) onePoolMana = poolCount * 1000000; + HUDHandler.drawSimpleManaHUD(color, onePoolMana, 1000000, name, res); + } + + public static void setLightmapTextureCoords() { + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + } + + public static Vector3 setRotation(float angel, float vX, float vY, float vZ, Vector3 v3) { + Vector3 rVec = new Vector3(vX, vY, vZ); + Vector3 rVec1 = v3.copy().normalize(); + double rAngel = Math.toRadians(angel) * 0.5f; + double sin = Math.sin(rAngel); + double x = rVec.x * sin; + double y = rVec.y * sin; + double z = rVec.z * sin; + rAngel = Math.cos(rAngel); + double d = -x * rVec1.x - y * rVec1.y - z * rVec1.z; + double d1 = rAngel * rVec1.x + y * rVec1.z - z * rVec1.y; + double d2 = rAngel * rVec1.y - x * rVec1.z + z * rVec1.x; + double d3 = rAngel * rVec1.z + x * rVec1.y - y * rVec1.x; + v3.x = d1 * rAngel - d * x - d2 * z + d3 * y; + v3.y = d2 * rAngel - d * y + d1 * z - d3 * x; + v3.z = d3 * rAngel - d * z - d1 * y + d2 * x; + return v3; + } + + public static Color getCorporeaRuneColor(int posX, int posY, int posZ, int meta) { + double time = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks; + time += (new Random((posX ^ posY ^ posZ))).nextInt(360); + float sin = (float) (Math.sin(time / 20.0f) * 0.15f) - 0.15f; + int color = 0; + switch (meta) { + case 0: + color = Color.HSBtoRGB(0.0f, 0.0f, 0.54f + (sin / 1.2f)); + break; + case 1: + color = Color.HSBtoRGB(0.688f, 0.93f, 0.96f + sin - 0.15f); + break; + case 2: + color = Color.HSBtoRGB(0.983f, 0.99f, 1.0f + sin - 0.15f); + break; + case 3: + color = Color.HSBtoRGB(0.319f, 0.92f, 0.95f + sin - 0.15f); + break; + case 4: + color = Color.HSBtoRGB(0.536f, 0.53f, 0.92f + sin - 0.15f); + break; + } + return new Color(color); + } + + public static void renderIcon(IIcon icon, int light) { + Tessellator tessellator = Tessellator.instance; + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + float f4 = 1.0F; + float f5 = 0.5F; + float f6 = 0.25F; + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + tessellator.addVertexWithUV((0.0F - f5), (0.0F - f6), 0.0D, f, f3); + tessellator.addVertexWithUV((f4 - f5), (0.0F - f6), 0.0D, f1, f3); + tessellator.addVertexWithUV((f4 - f5), (f4 - f6), 0.0D, f1, f2); + tessellator.addVertexWithUV((0.0F - f5), (f4 - f6), 0.0D, f, f2); + tessellator.draw(); + } +} diff --git a/src/main/java/ab/client/core/handler/BoundRenderHandler.java b/src/main/java/ab/client/core/handler/BoundRenderHandler.java index 8649878..5ec87a9 100644 --- a/src/main/java/ab/client/core/handler/BoundRenderHandler.java +++ b/src/main/java/ab/client/core/handler/BoundRenderHandler.java @@ -2,10 +2,6 @@ package ab.client.core.handler; import java.awt.Color; -import org.lwjgl.opengl.GL11; - -import ab.api.IBoundRender; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; @@ -19,111 +15,121 @@ import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderWorldLastEvent; + +import org.lwjgl.opengl.GL11; + import vazkii.botania.api.wand.ICoordBoundItem; import vazkii.botania.api.wand.IWireframeAABBProvider; import vazkii.botania.client.core.handler.ClientTickHandler; +import ab.api.IBoundRender; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class BoundRenderHandler { - @SubscribeEvent - public void onWorldRenderLast(RenderWorldLastEvent event) { - GL11.glPushMatrix(); - GL11.glPushAttrib(2896); - GL11.glDisable(2929); - GL11.glDisable(3553); - GL11.glDisable(2896); - GL11.glEnable(3042); - Tessellator.renderingWorldRenderer = false; - EntityClientPlayerMP entityClientPlayerMP = (Minecraft.getMinecraft()).thePlayer; - ItemStack stack = entityClientPlayerMP.getCurrentEquippedItem(); - int color = Color.HSBtoRGB((ClientTickHandler.ticksInGame % 200) / 200.0F, 0.6F, 1.0F); - if(stack != null && stack.getItem() instanceof ICoordBoundItem) { - ChunkCoordinates[] coords = null; - 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 IBoundRender) - coords = ((IBoundRender)tile).getBlocksCoord(); - } - if(coords != null) - for(int i = 0; i < coords.length; i++) { - if(coords[i].posY == -1) - continue; - renderBlockOutlineAt(coords[i], color, 1.0f); - } - } - GL11.glEnable(2929); - GL11.glEnable(3553); - GL11.glDisable(3042); - GL11.glPopAttrib(); - GL11.glPopMatrix(); - } - - 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.0D); - Color colorRGB = new Color(color); - GL11.glColor4ub((byte)colorRGB.getRed(), (byte)colorRGB.getGreen(), (byte)colorRGB.getBlue(), (byte)-1); - WorldClient worldClient = (Minecraft.getMinecraft()).theWorld; - Block block = worldClient.getBlock(pos.posX, pos.posY, pos.posZ); - if(block != null) { - AxisAlignedBB axis; - if(block instanceof IWireframeAABBProvider) { - axis = ((IWireframeAABBProvider)block).getWireframeAABB((World)worldClient, pos.posX, pos.posY, pos.posZ); - } else { - axis = block.getSelectedBoundingBoxFromPool((World)worldClient, pos.posX, pos.posY, pos.posZ); - } - if(axis != null) { - 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(1.0F, 1.0F, 1.0F); - GL11.glLineWidth(thickness); - renderBlockOutline(axis); - GL11.glLineWidth(thickness + 3.0F); - 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(1); - 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.draw(); - } + @SubscribeEvent + public void onWorldRenderLast(RenderWorldLastEvent event) { + GL11.glPushMatrix(); + GL11.glPushAttrib(2896); + GL11.glDisable(2929); + GL11.glDisable(3553); + GL11.glDisable(2896); + GL11.glEnable(3042); + Tessellator.renderingWorldRenderer = false; + EntityClientPlayerMP entityClientPlayerMP = (Minecraft.getMinecraft()).thePlayer; + ItemStack stack = entityClientPlayerMP.getCurrentEquippedItem(); + int color = Color.HSBtoRGB((ClientTickHandler.ticksInGame % 200) / 200.0F, 0.6F, 1.0F); + if (stack != null && stack.getItem() instanceof ICoordBoundItem) { + ChunkCoordinates[] coords = null; + 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 IBoundRender) coords = ((IBoundRender) tile).getBlocksCoord(); + } + if (coords != null) for (int i = 0; i < coords.length; i++) { + if (coords[i].posY == -1) continue; + renderBlockOutlineAt(coords[i], color, 1.0f); + } + } + GL11.glEnable(2929); + GL11.glEnable(3553); + GL11.glDisable(3042); + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } + + 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.0D); + Color colorRGB = new Color(color); + GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) -1); + WorldClient worldClient = (Minecraft.getMinecraft()).theWorld; + Block block = worldClient.getBlock(pos.posX, pos.posY, pos.posZ); + if (block != null) { + AxisAlignedBB axis; + if (block instanceof IWireframeAABBProvider) { + axis = ((IWireframeAABBProvider) block) + .getWireframeAABB((World) worldClient, pos.posX, pos.posY, pos.posZ); + } else { + axis = block.getSelectedBoundingBoxFromPool((World) worldClient, pos.posX, pos.posY, pos.posZ); + } + if (axis != null) { + 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(1.0F, 1.0F, 1.0F); + GL11.glLineWidth(thickness); + renderBlockOutline(axis); + GL11.glLineWidth(thickness + 3.0F); + 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(1); + 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.draw(); + } } diff --git a/src/main/java/ab/client/core/handler/ClientHandler.java b/src/main/java/ab/client/core/handler/ClientHandler.java index 574c794..8eb306a 100644 --- a/src/main/java/ab/client/core/handler/ClientHandler.java +++ b/src/main/java/ab/client/core/handler/ClientHandler.java @@ -4,124 +4,125 @@ import java.awt.Color; import java.util.ArrayList; import java.util.List; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -import ab.api.IBoundRender; -import ab.api.IRankItem; -import ab.client.core.handler.PlayerItemUsingSound.ClientSoundHandler; -import ab.common.block.tile.TileLebethronCore; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent; -import cpw.mods.fml.relauncher.ReflectionHelper; -import net.minecraft.block.Block; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.multiplayer.WorldClient; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import net.minecraft.profiler.Profiler; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.ChunkCoordinates; -import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.StatCollector; -import net.minecraft.world.World; -import net.minecraftforge.client.event.RenderGameOverlayEvent; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import vazkii.botania.api.wand.ICoordBoundItem; -import vazkii.botania.api.wand.IWireframeAABBProvider; + +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.common.lib.LibObfuscation; +import ab.api.IRankItem; +import ab.client.core.handler.PlayerItemUsingSound.ClientSoundHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.relauncher.ReflectionHelper; public class ClientHandler { - - @SubscribeEvent - public void renderTick(TickEvent.RenderTickEvent event) { - if(event.phase != TickEvent.Phase.START) - renderTooltip(); - } - - @SubscribeEvent - public void clientTickEnd(TickEvent.ClientTickEvent event) { - if(event.phase == TickEvent.Phase.END) { - ItemsRemainingRender.tick(); - ClientSoundHandler.tick(); - } - } - - public static void renderTooltip() { - 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 = (Slot)ReflectionHelper.getPrivateValue(GuiContainer.class, container, LibObfuscation.THE_SLOT); - if (slot != null && slot.getHasStack()) { - ItemStack stack = slot.getStack(); - if (stack != null) { - List tooltip; - 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; - try { - tooltip = stack.getTooltip((EntityPlayer)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 IRankItem) { - drawRankItemBar(stack, mouseX, mouseY, offx, offy, width, height, font); - } - } - } - } - } - - private static void drawRankItemBar(ItemStack stack, int mouseX, int mouseY, int offx, int offy, int width, int height, FontRenderer font) { - IRankItem item = (IRankItem)stack.getItem(); - int level = item.getLevel(stack); - int max = item.getLevels()[Math.min(item.getLevels().length - 1, level + 1)]; - boolean ss = (level >= item.getLevels().length - 1); - int curr = item.getMana(stack); - float percent = (level == 0) ? 0.0F : ((float)curr / (float)max); - int rainbowWidth = Math.min(width - (ss ? 0 : 1), (int)(width * percent)); - float huePer = (width == 0) ? 0.0F : (1.0F / width); - float hueOff = (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.01F; - GL11.glDisable(2929); - Gui.drawRect(mouseX + offx - 1, mouseY - offy - height - 1, mouseX + offx + width + 1, mouseY - offy, -16777216); - 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, 1.0F, 1.0F)); - Gui.drawRect(mouseX + offx + rainbowWidth, mouseY - offy - height, mouseX + offx + width, mouseY - offy, -11184811); - String rank = StatCollector.translateToLocal("botania.rank" + level).replaceAll("&", "\u00A7"); - GL11.glPushAttrib(2896); - GL11.glDisable(2896); - font.drawStringWithShadow(rank, mouseX + offx, mouseY - offy - 12, 16777215); - if(!ss) { - rank = StatCollector.translateToLocal("botania.rank" + (level + 1)).replaceAll("&", "\u00A7"); - font.drawStringWithShadow(rank, mouseX + offx + width - font.getStringWidth(rank), mouseY - offy - 12, 16777215); - } - GL11.glEnable(2929); - GL11.glPopAttrib(); - } -} \ No newline at end of file + + @SubscribeEvent + public void renderTick(TickEvent.RenderTickEvent event) { + if (event.phase != TickEvent.Phase.START) renderTooltip(); + } + + @SubscribeEvent + public void clientTickEnd(TickEvent.ClientTickEvent event) { + if (event.phase == TickEvent.Phase.END) { + ItemsRemainingRender.tick(); + ClientSoundHandler.tick(); + } + } + + public static void renderTooltip() { + 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 = (Slot) ReflectionHelper.getPrivateValue(GuiContainer.class, container, LibObfuscation.THE_SLOT); + if (slot != null && slot.getHasStack()) { + ItemStack stack = slot.getStack(); + if (stack != null) { + List tooltip; + 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; + try { + tooltip = stack.getTooltip((EntityPlayer) 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 IRankItem) { + drawRankItemBar(stack, mouseX, mouseY, offx, offy, width, height, font); + } + } + } + } + } + + private static void drawRankItemBar(ItemStack stack, int mouseX, int mouseY, int offx, int offy, int width, + int height, FontRenderer font) { + IRankItem item = (IRankItem) stack.getItem(); + int level = item.getLevel(stack); + int max = item.getLevels()[Math.min(item.getLevels().length - 1, level + 1)]; + boolean ss = (level >= item.getLevels().length - 1); + int curr = item.getMana(stack); + float percent = (level == 0) ? 0.0F : ((float) curr / (float) max); + int rainbowWidth = Math.min(width - (ss ? 0 : 1), (int) (width * percent)); + float huePer = (width == 0) ? 0.0F : (1.0F / width); + float hueOff = (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.01F; + GL11.glDisable(2929); + Gui.drawRect( + mouseX + offx - 1, + mouseY - offy - height - 1, + mouseX + offx + width + 1, + mouseY - offy, + -16777216); + 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, 1.0F, 1.0F)); + Gui.drawRect( + mouseX + offx + rainbowWidth, + mouseY - offy - height, + mouseX + offx + width, + mouseY - offy, + -11184811); + String rank = StatCollector.translateToLocal("botania.rank" + level).replaceAll("&", "\u00A7"); + GL11.glPushAttrib(2896); + GL11.glDisable(2896); + font.drawStringWithShadow(rank, mouseX + offx, mouseY - offy - 12, 16777215); + if (!ss) { + rank = StatCollector.translateToLocal("botania.rank" + (level + 1)).replaceAll("&", "\u00A7"); + font.drawStringWithShadow( + rank, + mouseX + offx + width - font.getStringWidth(rank), + mouseY - offy - 12, + 16777215); + } + GL11.glEnable(2929); + GL11.glPopAttrib(); + } +} diff --git a/src/main/java/ab/client/core/handler/GuiABConfigHandler.java b/src/main/java/ab/client/core/handler/GuiABConfigHandler.java index 663b274..eeff55e 100644 --- a/src/main/java/ab/client/core/handler/GuiABConfigHandler.java +++ b/src/main/java/ab/client/core/handler/GuiABConfigHandler.java @@ -1,18 +1,21 @@ package ab.client.core.handler; -import java.util.ArrayList; -import java.util.List; +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.common.config.ConfigElement; import ab.AdvancedBotany; import ab.common.core.handler.ConfigABHandler; import cpw.mods.fml.client.config.GuiConfig; -import cpw.mods.fml.client.config.IConfigElement; -import net.minecraft.client.gui.GuiScreen; -import net.minecraftforge.common.config.ConfigElement; public class GuiABConfigHandler extends GuiConfig { - public GuiABConfigHandler(GuiScreen parentScreen) { - super(parentScreen, (new ConfigElement(ConfigABHandler.config.getCategory("general"))).getChildElements(), AdvancedBotany.modid, false, false, GuiConfig.getAbridgedConfigPath(ConfigABHandler.config.toString())); - } + public GuiABConfigHandler(GuiScreen parentScreen) { + super( + parentScreen, + (new ConfigElement(ConfigABHandler.config.getCategory("general"))).getChildElements(), + AdvancedBotany.modid, + false, + false, + GuiConfig.getAbridgedConfigPath(ConfigABHandler.config.toString())); + } } diff --git a/src/main/java/ab/client/core/handler/GuiABFactory.java b/src/main/java/ab/client/core/handler/GuiABFactory.java index d8855d9..c951fd8 100644 --- a/src/main/java/ab/client/core/handler/GuiABFactory.java +++ b/src/main/java/ab/client/core/handler/GuiABFactory.java @@ -2,23 +2,24 @@ package ab.client.core.handler; import java.util.Set; -import cpw.mods.fml.client.IModGuiFactory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; +import cpw.mods.fml.client.IModGuiFactory; + public class GuiABFactory implements IModGuiFactory { - public void initialize(Minecraft minecraftInstance) {} - - public Class mainConfigGuiClass() { - return GuiABConfigHandler.class; - } - - public Set runtimeGuiCategories() { - return null; - } - - public IModGuiFactory.RuntimeOptionGuiHandler getHandlerFor(IModGuiFactory.RuntimeOptionCategoryElement element) { - return null; - } + public void initialize(Minecraft minecraftInstance) {} + + public Class mainConfigGuiClass() { + return GuiABConfigHandler.class; + } + + public Set runtimeGuiCategories() { + return null; + } + + public IModGuiFactory.RuntimeOptionGuiHandler getHandlerFor(IModGuiFactory.RuntimeOptionCategoryElement element) { + return null; + } } diff --git a/src/main/java/ab/client/core/handler/HudRenderHandler.java b/src/main/java/ab/client/core/handler/HudRenderHandler.java index a348f50..e0d76a7 100644 --- a/src/main/java/ab/client/core/handler/HudRenderHandler.java +++ b/src/main/java/ab/client/core/handler/HudRenderHandler.java @@ -1,62 +1,46 @@ package ab.client.core.handler; -import java.awt.Color; - -import org.lwjgl.opengl.GL11; - -import ab.api.IRenderHud; -import ab.common.block.tile.TileLebethronCore; -import ab.common.item.equipment.ItemBlackHalo; -import ab.common.item.equipment.armor.ItemNebulaArmor; -import ab.common.item.equipment.armor.ItemNebulaHelm; -import ab.common.lib.register.ItemListAB; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.profiler.Profiler; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.RenderGameOverlayEvent; -import net.minecraftforge.client.event.RenderPlayerEvent; -import vazkii.botania.api.item.IPhantomInkable; -import vazkii.botania.client.core.handler.ClientTickHandler; + import vazkii.botania.common.item.ItemLexicon; import vazkii.botania.common.item.ItemTwigWand; +import ab.api.IRenderHud; +import ab.common.item.equipment.ItemBlackHalo; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class HudRenderHandler { - - @SubscribeEvent - public void onDrawScreenPost(RenderGameOverlayEvent.Post event) { - Minecraft mc = Minecraft.getMinecraft(); - Profiler profiler = mc.mcProfiler; - ItemStack equippedStack = mc.thePlayer.getCurrentEquippedItem(); - if (event.type == RenderGameOverlayEvent.ElementType.ALL) { - profiler.startSection("advabcedBotany-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); - boolean canRender = equippedStack != null && (equippedStack.getItem() instanceof ItemTwigWand || equippedStack.getItem() instanceof ItemLexicon); - if(tile != null && tile instanceof IRenderHud && !canRender) { - ((IRenderHud)tile).renderHud(mc, event.resolution); - } - } - if(equippedStack != null && equippedStack.getItem() instanceof ItemBlackHalo) { - profiler.startSection("blackHalo"); - ItemBlackHalo.renderHUD(event.resolution, mc.thePlayer, equippedStack); - profiler.endSection(); - } - profiler.endStartSection("itemsRemainingAB"); - ItemsRemainingRender.render(event.resolution, event.partialTicks); - 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 == RenderGameOverlayEvent.ElementType.ALL) { + profiler.startSection("advabcedBotany-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); + boolean canRender = equippedStack != null && (equippedStack.getItem() instanceof ItemTwigWand + || equippedStack.getItem() instanceof ItemLexicon); + if (tile != null && tile instanceof IRenderHud && !canRender) { + ((IRenderHud) tile).renderHud(mc, event.resolution); + } + } + if (equippedStack != null && equippedStack.getItem() instanceof ItemBlackHalo) { + profiler.startSection("blackHalo"); + ItemBlackHalo.renderHUD(event.resolution, mc.thePlayer, equippedStack); + profiler.endSection(); + } + profiler.endStartSection("itemsRemainingAB"); + ItemsRemainingRender.render(event.resolution, event.partialTicks); + profiler.endSection(); + } + } } diff --git a/src/main/java/ab/client/core/handler/ItemsRemainingRender.java b/src/main/java/ab/client/core/handler/ItemsRemainingRender.java index 63774f2..a6916f0 100644 --- a/src/main/java/ab/client/core/handler/ItemsRemainingRender.java +++ b/src/main/java/ab/client/core/handler/ItemsRemainingRender.java @@ -1,63 +1,63 @@ package ab.client.core.handler; -import org.lwjgl.opengl.GL11; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.item.ItemStack; +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + public class ItemsRemainingRender { - private static int maxTicks = 30; - private static int leaveTicks = 20; - private static ItemStack stack; - private static int ticks; - private static String text; - - @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) ? 1.0F : ((ticks + partTicks) / start); - GL11.glDisable(3008); - GL11.glEnable(3042); - GL11.glEnable(32826); - GL11.glBlendFunc(770, 771); - GL11.glColor4f(1.0F, 1.0F, 1.0F, alpha); - RenderHelper.enableGUIStandardItemLighting(); - int xp = x + (int)(16.0F * (1.0F - alpha)); - GL11.glTranslatef(xp, y, 0.0F); - GL11.glScalef(alpha, 1.0F, 1.0F); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, 0, 0); - GL11.glScalef(1.0F / alpha, 1.0F, 1.0F); - GL11.glTranslatef(-xp, -y, 0.0F); - RenderHelper.disableStandardItemLighting(); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glEnable(3042); - int color = 0xFFFFFF | (int)(alpha * 255.0F) << 24; - mc.fontRenderer.drawStringWithShadow(text, x + 20, y + 6, color); - GL11.glDisable(3042); - GL11.glEnable(3008); - } - } - - @SideOnly(Side.CLIENT) - public static void tick() { - if(ticks > 0) - ticks--; - } - - public static void set(ItemStack stack, String text) { - ItemsRemainingRender.stack = stack; - ItemsRemainingRender.text = text; - ticks = (stack == null) ? 0 : maxTicks; - } -} \ No newline at end of file + private static int maxTicks = 30; + private static int leaveTicks = 20; + private static ItemStack stack; + private static int ticks; + private static String text; + + @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) ? 1.0F : ((ticks + partTicks) / start); + GL11.glDisable(3008); + GL11.glEnable(3042); + GL11.glEnable(32826); + GL11.glBlendFunc(770, 771); + GL11.glColor4f(1.0F, 1.0F, 1.0F, alpha); + RenderHelper.enableGUIStandardItemLighting(); + int xp = x + (int) (16.0F * (1.0F - alpha)); + GL11.glTranslatef(xp, y, 0.0F); + GL11.glScalef(alpha, 1.0F, 1.0F); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, 0, 0); + GL11.glScalef(1.0F / alpha, 1.0F, 1.0F); + GL11.glTranslatef(-xp, -y, 0.0F); + RenderHelper.disableStandardItemLighting(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnable(3042); + int color = 0xFFFFFF | (int) (alpha * 255.0F) << 24; + mc.fontRenderer.drawStringWithShadow(text, x + 20, y + 6, color); + GL11.glDisable(3042); + GL11.glEnable(3008); + } + } + + @SideOnly(Side.CLIENT) + public static void tick() { + if (ticks > 0) ticks--; + } + + public static void set(ItemStack stack, String text) { + ItemsRemainingRender.stack = stack; + ItemsRemainingRender.text = text; + ticks = (stack == null) ? 0 : maxTicks; + } +} diff --git a/src/main/java/ab/client/core/handler/PlayerItemUsingSound.java b/src/main/java/ab/client/core/handler/PlayerItemUsingSound.java index 522283a..ad30176 100644 --- a/src/main/java/ab/client/core/handler/PlayerItemUsingSound.java +++ b/src/main/java/ab/client/core/handler/PlayerItemUsingSound.java @@ -11,73 +11,79 @@ import net.minecraft.util.ResourceLocation; public class PlayerItemUsingSound { - public EntityPlayer player; - public ISound sound; - public int maxTick = 0; - public int tick = 0; - public boolean isDeadingSound = false; - public boolean hasCheckUse; - - public PlayerItemUsingSound(EntityPlayer player, ISound sound, int maxTick, boolean hasCheckUse) { - this.player = player; - this.sound = sound; - this.maxTick = maxTick; - this.hasCheckUse = hasCheckUse; - } - - public static class ClientSoundHandler { - - public static Minecraft mc = Minecraft.getMinecraft(); - public static List soundsList = new ArrayList(); - - public static void playSound(EntityPlayer player, String name, float volume, float pitch, int maxTick, boolean hasCheckUse) { - if(!soundsList.isEmpty()) - for(int i = 0; i < soundsList.size(); i++) { - PlayerItemUsingSound playerSound = soundsList.get(i); - if(playerSound.player.getCommandSenderName().equals(player.getCommandSenderName())) { - if(playerSound.maxTick != 0 && playerSound.maxTick <= playerSound.tick && !playerSound.isDeadingSound) { - playerSound.isDeadingSound = true; - setSound(player, name, volume, pitch, maxTick, hasCheckUse); - return; - } - return; - } else - setSound(player, name, volume, pitch, maxTick, hasCheckUse); - } - else - setSound(player, name, volume, pitch, maxTick, hasCheckUse); - } - - public static void playSound(EntityPlayer player, String name, float volume, float pitch, int maxTick) { - playSound(player, name, volume, pitch, maxTick, true); - } - - public static void playSound(EntityPlayer player, String name, float volume, float pitch) { - playSound(player, name, volume, pitch, 0); - } - - protected static void setSound(EntityPlayer player, String name, float volume, float pitch, int maxTick, boolean hasCheckUse) { - PositionedSoundRecord posSound = new PositionedSoundRecord(new ResourceLocation(name), volume, pitch, (float)player.posX, (float)player.posY, (float)player.posZ); - soundsList.add(new PlayerItemUsingSound(player, posSound, maxTick, hasCheckUse)); - mc.getSoundHandler().playSound(posSound); - } - - public static void tick() { - if(!soundsList.isEmpty()) { - for(int i = 0; i < soundsList.size(); i++) { - PlayerItemUsingSound playerSound = soundsList.get(i); - playerSound.tick++; - if(!mc.getSoundHandler().isSoundPlaying(playerSound.sound)) { - soundsList.remove(playerSound); - continue; - } else if(playerSound.hasCheckUse && !playerSound.player.isUsingItem()) { - if(mc.getSoundHandler().isSoundPlaying(playerSound.sound)) - mc.getSoundHandler().stopSound(playerSound.sound); - soundsList.remove(playerSound); - continue; - } - } - } - } - } -} \ No newline at end of file + public EntityPlayer player; + public ISound sound; + public int maxTick = 0; + public int tick = 0; + public boolean isDeadingSound = false; + public boolean hasCheckUse; + + public PlayerItemUsingSound(EntityPlayer player, ISound sound, int maxTick, boolean hasCheckUse) { + this.player = player; + this.sound = sound; + this.maxTick = maxTick; + this.hasCheckUse = hasCheckUse; + } + + public static class ClientSoundHandler { + + public static Minecraft mc = Minecraft.getMinecraft(); + public static List soundsList = new ArrayList(); + + public static void playSound(EntityPlayer player, String name, float volume, float pitch, int maxTick, + boolean hasCheckUse) { + if (!soundsList.isEmpty()) for (int i = 0; i < soundsList.size(); i++) { + PlayerItemUsingSound playerSound = soundsList.get(i); + if (playerSound.player.getCommandSenderName().equals(player.getCommandSenderName())) { + if (playerSound.maxTick != 0 && playerSound.maxTick <= playerSound.tick + && !playerSound.isDeadingSound) { + playerSound.isDeadingSound = true; + setSound(player, name, volume, pitch, maxTick, hasCheckUse); + return; + } + return; + } else setSound(player, name, volume, pitch, maxTick, hasCheckUse); + } + else setSound(player, name, volume, pitch, maxTick, hasCheckUse); + } + + public static void playSound(EntityPlayer player, String name, float volume, float pitch, int maxTick) { + playSound(player, name, volume, pitch, maxTick, true); + } + + public static void playSound(EntityPlayer player, String name, float volume, float pitch) { + playSound(player, name, volume, pitch, 0); + } + + protected static void setSound(EntityPlayer player, String name, float volume, float pitch, int maxTick, + boolean hasCheckUse) { + PositionedSoundRecord posSound = new PositionedSoundRecord( + new ResourceLocation(name), + volume, + pitch, + (float) player.posX, + (float) player.posY, + (float) player.posZ); + soundsList.add(new PlayerItemUsingSound(player, posSound, maxTick, hasCheckUse)); + mc.getSoundHandler().playSound(posSound); + } + + public static void tick() { + if (!soundsList.isEmpty()) { + for (int i = 0; i < soundsList.size(); i++) { + PlayerItemUsingSound playerSound = soundsList.get(i); + playerSound.tick++; + if (!mc.getSoundHandler().isSoundPlaying(playerSound.sound)) { + soundsList.remove(playerSound); + continue; + } else if (playerSound.hasCheckUse && !playerSound.player.isUsingItem()) { + if (mc.getSoundHandler().isSoundPlaying(playerSound.sound)) + mc.getSoundHandler().stopSound(playerSound.sound); + soundsList.remove(playerSound); + continue; + } + } + } + } + } +} diff --git a/src/main/java/ab/client/core/handler/PlayerRendererHandler.java b/src/main/java/ab/client/core/handler/PlayerRendererHandler.java index a818a4a..832d679 100644 --- a/src/main/java/ab/client/core/handler/PlayerRendererHandler.java +++ b/src/main/java/ab/client/core/handler/PlayerRendererHandler.java @@ -2,12 +2,6 @@ package ab.client.core.handler; import java.awt.Color; -import org.lwjgl.opengl.GL11; - -import ab.client.core.ClientHelper; -import ab.common.item.equipment.armor.ItemNebulaArmor; -import ab.common.item.equipment.armor.ItemNebulaHelm; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.OpenGlHelper; @@ -17,72 +11,87 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.client.event.RenderPlayerEvent; + +import org.lwjgl.opengl.GL11; + import vazkii.botania.api.item.IPhantomInkable; import vazkii.botania.client.core.handler.ClientTickHandler; +import ab.client.core.ClientHelper; +import ab.common.item.equipment.armor.ItemNebulaArmor; +import ab.common.item.equipment.armor.ItemNebulaHelm; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class PlayerRendererHandler { - @SubscribeEvent - public void onPlayerRender(RenderPlayerEvent.Specials.Post event) { - EntityPlayer player = event.entityPlayer; - ItemStack item = player.getCurrentArmor(3); - if(item != null && item.getItem() instanceof ItemNebulaHelm) { - Item helm = player.getCurrentArmor(3).getItem(); - boolean hasPhantomInk = helm instanceof IPhantomInkable && ((IPhantomInkable)helm).hasPhantomInk(item); - if(!hasPhantomInk && ((ItemNebulaHelm)helm).enableCosmicFace(item)) { - float angelX = event.renderer.modelBipedMain.bipedHead.rotateAngleX * 180.0F / (float)Math.PI; - float angelY = event.renderer.modelBipedMain.bipedHead.rotateAngleY * 180.0F / (float)Math.PI; - GL11.glPushMatrix(); - if(player.isSneaking()) - GL11.glTranslatef(event.renderer.modelBipedMain.bipedHead.rotationPointX * 0.0625f, event.renderer.modelBipedMain.bipedHead.rotationPointY * 0.0625f, 0.0f); - GL11.glRotatef(angelY, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(angelX, 1.0F, 0.0F, 0.0F); - renderCosmicFace(); - GL11.glPopMatrix(); - } - } - } - - private void renderCosmicFace() { - double worldTime = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks; - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDisable(2884); - - GL11.glPushMatrix(); - GL11.glScalef(0.5f, 0.4f, 0.4f); - GL11.glRotatef(90.0f, 1.0f, 0.0f, 0.0f); - GL11.glTranslatef(-0.5f, -0.8675f, 0.0f); - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - boolean hasFog = GL11.glGetBoolean(2912); - if(hasFog) - GL11.glDisable(2912); - ClientHelper.renderCosmicBackground(); - if(hasFog) - GL11.glEnable(2912); - GL11.glPopMatrix(); - - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - GL11.glEnable(3042); - GL11.glBlendFunc(770, 771); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - (Minecraft.getMinecraft()).renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glTranslatef(-0.2F, -0.35F, -0.25F); - GL11.glScalef(0.4f, 0.4f, 0.4f); - float f = ItemNebulaArmor.nebulaEyes.getMinU(); - float f1 = ItemNebulaArmor.nebulaEyes.getMaxU(); - float f2 = ItemNebulaArmor.nebulaEyes.getMinV(); - float f3 = ItemNebulaArmor.nebulaEyes.getMaxV(); - Color color = Color.getHSBColor((float)Minecraft.getSystemTime() / 20.0F % 360.0F / 360.0F, 1.0F, 1.0F); - float r = color.getRed() / 510.0F; - float g = color.getGreen() / 510.0F; - float b = color.getBlue() / 510.0F; - GL11.glColor4f(0.5f + r, 0.5f + g, 0.5f + b, 0.685f + (float)Math.sin(worldTime / 50.0D) * 0.175F); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, ItemNebulaArmor.nebulaEyes.getIconWidth(), ItemNebulaArmor.nebulaEyes.getIconHeight(), 0.03125F); - GL11.glDisable(3042); - GL11.glEnable(32826); - GL11.glPopMatrix(); - } -} \ No newline at end of file + @SubscribeEvent + public void onPlayerRender(RenderPlayerEvent.Specials.Post event) { + EntityPlayer player = event.entityPlayer; + ItemStack item = player.getCurrentArmor(3); + if (item != null && item.getItem() instanceof ItemNebulaHelm) { + Item helm = player.getCurrentArmor(3).getItem(); + boolean hasPhantomInk = helm instanceof IPhantomInkable && ((IPhantomInkable) helm).hasPhantomInk(item); + if (!hasPhantomInk && ((ItemNebulaHelm) helm).enableCosmicFace(item)) { + float angelX = event.renderer.modelBipedMain.bipedHead.rotateAngleX * 180.0F / (float) Math.PI; + float angelY = event.renderer.modelBipedMain.bipedHead.rotateAngleY * 180.0F / (float) Math.PI; + GL11.glPushMatrix(); + if (player.isSneaking()) GL11.glTranslatef( + event.renderer.modelBipedMain.bipedHead.rotationPointX * 0.0625f, + event.renderer.modelBipedMain.bipedHead.rotationPointY * 0.0625f, + 0.0f); + GL11.glRotatef(angelY, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(angelX, 1.0F, 0.0F, 0.0F); + renderCosmicFace(); + GL11.glPopMatrix(); + } + } + } + + private void renderCosmicFace() { + double worldTime = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks; + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(2884); + + GL11.glPushMatrix(); + GL11.glScalef(0.5f, 0.4f, 0.4f); + GL11.glRotatef(90.0f, 1.0f, 0.0f, 0.0f); + GL11.glTranslatef(-0.5f, -0.8675f, 0.0f); + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + boolean hasFog = GL11.glGetBoolean(2912); + if (hasFog) GL11.glDisable(2912); + ClientHelper.renderCosmicBackground(); + if (hasFog) GL11.glEnable(2912); + GL11.glPopMatrix(); + + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + (Minecraft.getMinecraft()).renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glTranslatef(-0.2F, -0.35F, -0.25F); + GL11.glScalef(0.4f, 0.4f, 0.4f); + float f = ItemNebulaArmor.nebulaEyes.getMinU(); + float f1 = ItemNebulaArmor.nebulaEyes.getMaxU(); + float f2 = ItemNebulaArmor.nebulaEyes.getMinV(); + float f3 = ItemNebulaArmor.nebulaEyes.getMaxV(); + Color color = Color.getHSBColor((float) Minecraft.getSystemTime() / 20.0F % 360.0F / 360.0F, 1.0F, 1.0F); + float r = color.getRed() / 510.0F; + float g = color.getGreen() / 510.0F; + float b = color.getBlue() / 510.0F; + GL11.glColor4f(0.5f + r, 0.5f + g, 0.5f + b, 0.685f + (float) Math.sin(worldTime / 50.0D) * 0.175F); + ItemRenderer.renderItemIn2D( + Tessellator.instance, + f1, + f2, + f, + f3, + ItemNebulaArmor.nebulaEyes.getIconWidth(), + ItemNebulaArmor.nebulaEyes.getIconHeight(), + 0.03125F); + GL11.glDisable(3042); + GL11.glEnable(32826); + GL11.glPopMatrix(); + } +} diff --git a/src/main/java/ab/client/core/proxy/ClientProxy.java b/src/main/java/ab/client/core/proxy/ClientProxy.java index 703bf7f..54ec5c6 100644 --- a/src/main/java/ab/client/core/proxy/ClientProxy.java +++ b/src/main/java/ab/client/core/proxy/ClientProxy.java @@ -1,5 +1,9 @@ package ab.client.core.proxy; +import net.minecraftforge.client.MinecraftForgeClient; +import net.minecraftforge.common.MinecraftForge; + +import vazkii.botania.common.Botania; import ab.client.core.handler.BoundRenderHandler; import ab.client.core.handler.ClientHandler; import ab.client.core.handler.HudRenderHandler; @@ -21,13 +25,6 @@ import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderSnowball; -import net.minecraft.item.ItemStack; -import net.minecraftforge.client.MinecraftForgeClient; -import net.minecraftforge.common.MinecraftForge; -import vazkii.botania.common.Botania; -import vazkii.botania.common.item.ModItems; public class ClientProxy extends CommonProxy { @@ -36,53 +33,54 @@ public class ClientProxy extends CommonProxy { } public void init(FMLInitializationEvent event) { - super.init(event); - - FMLCommonHandler.instance().bus().register(new ClientHandler()); - MinecraftForge.EVENT_BUS.register(new HudRenderHandler()); - MinecraftForge.EVENT_BUS.register(new PlayerRendererHandler()); - MinecraftForge.EVENT_BUS.register(new BoundRenderHandler()); - - ClientRegistry.bindTileEntitySpecialRenderer(TileNidavellirForge.class, new RenderTileNidavellirForge()); - ClientRegistry.bindTileEntitySpecialRenderer(TileABSpreader.class, new RenderTileABSpreader()); - ClientRegistry.bindTileEntitySpecialRenderer(TileManaContainer.class, new RenderTileManaContainer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileManaCrystalCube.class, new RenderTileManaCrystalCube()); - if(ConfigABHandler.hasManaCharger) - ClientRegistry.bindTileEntitySpecialRenderer(TileManaCharger.class, new RenderTileManaCharger()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEngineerHopper.class, new RenderTileEngineerHopper()); - ClientRegistry.bindTileEntitySpecialRenderer(TileBoardFate.class, new RenderTileBoardFate()); - ClientRegistry.bindTileEntitySpecialRenderer(TileGameBoard.class, new RenderTileGameBoard()); - if(Botania.thaumcraftLoaded && ConfigABHandler.hasAutoThaum) - ClientRegistry.bindTileEntitySpecialRenderer(TileMagicCraftCrate.class, new RenderTileMagicCraftingCrate()); - - BlockListAB.blockABSpreaderRI = RenderingRegistry.getNextAvailableRenderId(); - BlockListAB.blockManaContainerRI = RenderingRegistry.getNextAvailableRenderId(); - BlockListAB.blockManaCrystalCubeRI = RenderingRegistry.getNextAvailableRenderId(); - BlockListAB.blockManaChargerRI = RenderingRegistry.getNextAvailableRenderId(); - BlockListAB.blockEngineerHopperRI = RenderingRegistry.getNextAvailableRenderId(); - BlockListAB.blockABPlateRI = RenderingRegistry.getNextAvailableRenderId(); - + super.init(event); + + FMLCommonHandler.instance().bus().register(new ClientHandler()); + MinecraftForge.EVENT_BUS.register(new HudRenderHandler()); + MinecraftForge.EVENT_BUS.register(new PlayerRendererHandler()); + MinecraftForge.EVENT_BUS.register(new BoundRenderHandler()); + + ClientRegistry.bindTileEntitySpecialRenderer(TileNidavellirForge.class, new RenderTileNidavellirForge()); + ClientRegistry.bindTileEntitySpecialRenderer(TileABSpreader.class, new RenderTileABSpreader()); + ClientRegistry.bindTileEntitySpecialRenderer(TileManaContainer.class, new RenderTileManaContainer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileManaCrystalCube.class, new RenderTileManaCrystalCube()); + if (ConfigABHandler.hasManaCharger) + ClientRegistry.bindTileEntitySpecialRenderer(TileManaCharger.class, new RenderTileManaCharger()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEngineerHopper.class, new RenderTileEngineerHopper()); + ClientRegistry.bindTileEntitySpecialRenderer(TileBoardFate.class, new RenderTileBoardFate()); + ClientRegistry.bindTileEntitySpecialRenderer(TileGameBoard.class, new RenderTileGameBoard()); + if (Botania.thaumcraftLoaded && ConfigABHandler.hasAutoThaum) + ClientRegistry.bindTileEntitySpecialRenderer(TileMagicCraftCrate.class, new RenderTileMagicCraftingCrate()); + + BlockListAB.blockABSpreaderRI = RenderingRegistry.getNextAvailableRenderId(); + BlockListAB.blockManaContainerRI = RenderingRegistry.getNextAvailableRenderId(); + BlockListAB.blockManaCrystalCubeRI = RenderingRegistry.getNextAvailableRenderId(); + BlockListAB.blockManaChargerRI = RenderingRegistry.getNextAvailableRenderId(); + BlockListAB.blockEngineerHopperRI = RenderingRegistry.getNextAvailableRenderId(); + BlockListAB.blockABPlateRI = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(new RenderBlockABSpreader()); RenderingRegistry.registerBlockHandler(new RenderBlockManaContainer()); RenderingRegistry.registerBlockHandler(new RenderBlockManaCrystalCube()); RenderingRegistry.registerBlockHandler(new RenderBlockManaCharger()); RenderingRegistry.registerBlockHandler(new RenderBlockEngineerHopper()); RenderingRegistry.registerBlockHandler(new RenderBlockNidavellirForge()); - + RenderingRegistry.registerEntityRenderingHandler(EntityAdvancedSpark.class, new RenderEntityAdvancedSpark()); RenderingRegistry.registerEntityRenderingHandler(EntityNebulaBlaze.class, new EntityNullRender()); RenderingRegistry.registerEntityRenderingHandler(EntityManaVine.class, new EntityNullRender()); - RenderingRegistry.registerEntityRenderingHandler(EntityAlphirinePortal.class, new RenderEntityAlphirinePortal()); + RenderingRegistry + .registerEntityRenderingHandler(EntityAlphirinePortal.class, new RenderEntityAlphirinePortal()); RenderingRegistry.registerEntityRenderingHandler(EntitySword.class, new EntityNullRender()); RenderingRegistry.registerEntityRenderingHandler(EntitySeed.class, new EntityNullRender()); - + MinecraftForgeClient.registerItemRenderer(ItemListAB.itemAntigravityCharm, new RenderItemAntigravityCharm()); MinecraftForgeClient.registerItemRenderer(ItemListAB.itemSphereNavigation, new RenderItemSphereNavigation()); } public void postInit(FMLPostInitializationEvent event) { super.postInit(event); -// ItemStack crashGameForRender = null; -// System.out.println(crashGameForRender.stackSize); + // ItemStack crashGameForRender = null; + // System.out.println(crashGameForRender.stackSize); } -} \ No newline at end of file +} diff --git a/src/main/java/ab/client/gui/ContainerItemChest.java b/src/main/java/ab/client/gui/ContainerItemChest.java index 6504e51..1dd827b 100644 --- a/src/main/java/ab/client/gui/ContainerItemChest.java +++ b/src/main/java/ab/client/gui/ContainerItemChest.java @@ -1,79 +1,80 @@ package ab.client.gui; -import ab.common.item.relic.ItemTalismanHiddenRiches; -import ab.common.lib.register.ItemListAB; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; + import vazkii.botania.client.gui.SlotLocked; +import ab.common.item.relic.ItemTalismanHiddenRiches; public class ContainerItemChest extends Container { - public InventoryItemChest itemChestInv; - private int numRows; - - public ContainerItemChest(EntityPlayer player) { - int slot = player.inventory.currentItem; - InventoryPlayer inventoryPlayer = player.inventory; - this.itemChestInv = new InventoryItemChest(player, slot, ItemTalismanHiddenRiches.getOpenChest(player.getHeldItem())); - this.numRows = itemChestInv.getSizeInventory() / 9; - int i, j, k; - for(j = 0; j < this.numRows; ++j) { - for(k = 0; k < 9; ++k) { - this.addSlotToContainer(new SlotItemChest(itemChestInv, k + j * 9, 8 + k * 18, 18 + j * 18, k)); - } - } - for(i = 0; i < 3; i++) { - for (j = 0; j < 9; j++) - addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 85 + i * 18)); - } - for(i = 0; i < 9; i++) { - if(player.inventory.currentItem == i) { - addSlotToContainer(new SlotLocked(inventoryPlayer, i, 8 + i * 18, 143)); - } else { - addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 143)); - } - } - } - - public boolean canInteractWith(EntityPlayer player) { - boolean can = this.itemChestInv.isUseableByPlayer(player); - if(!can) - onContainerClosed(player); - return can; - } - - public void onContainerClosed(EntityPlayer player) { - super.onContainerClosed(player); - this.itemChestInv.pushInventory(); - } - - public ItemStack transferStackInSlot(EntityPlayer player, int i) { - ItemStack itemstack = null; - Slot slot = (Slot)this.inventorySlots.get(i); - if(slot != null && slot.getHasStack()) { - ItemStack stack = slot.getStack(); - itemstack = stack.copy(); - if(!itemChestInv.isRelicTalisman(stack)) { - if(i < itemChestInv.getSizeInventory()) { - if(!this.mergeItemStack(stack, itemChestInv.getSizeInventory(), inventorySlots.size(), true)) { - return null; - } - } - else if(!this.mergeItemStack(stack, 0, itemChestInv.getSizeInventory(), false)) { - return null; - } - } else { - return null; - } - if(stack.stackSize == 0) { - slot.putStack((ItemStack)null); - } else { - slot.onSlotChanged(); - } - } - return itemstack; - } -} \ No newline at end of file + public InventoryItemChest itemChestInv; + private int numRows; + + public ContainerItemChest(EntityPlayer player) { + int slot = player.inventory.currentItem; + InventoryPlayer inventoryPlayer = player.inventory; + this.itemChestInv = new InventoryItemChest( + player, + slot, + ItemTalismanHiddenRiches.getOpenChest(player.getHeldItem())); + this.numRows = itemChestInv.getSizeInventory() / 9; + int i, j, k; + for (j = 0; j < this.numRows; ++j) { + for (k = 0; k < 9; ++k) { + this.addSlotToContainer(new SlotItemChest(itemChestInv, k + j * 9, 8 + k * 18, 18 + j * 18, k)); + } + } + for (i = 0; i < 3; i++) { + for (j = 0; j < 9; j++) + addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 85 + i * 18)); + } + for (i = 0; i < 9; i++) { + if (player.inventory.currentItem == i) { + addSlotToContainer(new SlotLocked(inventoryPlayer, i, 8 + i * 18, 143)); + } else { + addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 143)); + } + } + } + + public boolean canInteractWith(EntityPlayer player) { + boolean can = this.itemChestInv.isUseableByPlayer(player); + if (!can) onContainerClosed(player); + return can; + } + + public void onContainerClosed(EntityPlayer player) { + super.onContainerClosed(player); + this.itemChestInv.pushInventory(); + } + + public ItemStack transferStackInSlot(EntityPlayer player, int i) { + ItemStack itemstack = null; + Slot slot = (Slot) this.inventorySlots.get(i); + if (slot != null && slot.getHasStack()) { + ItemStack stack = slot.getStack(); + itemstack = stack.copy(); + if (!itemChestInv.isRelicTalisman(stack)) { + if (i < itemChestInv.getSizeInventory()) { + if (!this.mergeItemStack(stack, itemChestInv.getSizeInventory(), inventorySlots.size(), true)) { + return null; + } + } else if (!this.mergeItemStack(stack, 0, itemChestInv.getSizeInventory(), false)) { + return null; + } + } else { + return null; + } + if (stack.stackSize == 0) { + slot.putStack((ItemStack) null); + } else { + slot.onSlotChanged(); + } + } + return itemstack; + } +} diff --git a/src/main/java/ab/client/gui/GuiItemChest.java b/src/main/java/ab/client/gui/GuiItemChest.java index f9645a4..0fcd8ca 100644 --- a/src/main/java/ab/client/gui/GuiItemChest.java +++ b/src/main/java/ab/client/gui/GuiItemChest.java @@ -1,35 +1,37 @@ package ab.client.gui; -import org.lwjgl.opengl.GL11; - import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; -public class GuiItemChest extends GuiContainer { - - private static final ResourceLocation field_147017_u = new ResourceLocation("textures/gui/container/generic_54.png"); - private int inventoryRows; +import org.lwjgl.opengl.GL11; - public GuiItemChest(EntityPlayer player) { - super(new ContainerItemChest(player)); - short short1 = 222; +public class GuiItemChest extends GuiContainer { + + private static final ResourceLocation field_147017_u = new ResourceLocation( + "textures/gui/container/generic_54.png"); + private int inventoryRows; + + public GuiItemChest(EntityPlayer player) { + super(new ContainerItemChest(player)); + short short1 = 222; int i = short1 - 108; - this.inventoryRows = ((ContainerItemChest)this.inventorySlots).itemChestInv.getSizeInventory() / 9; - this.ySize = i + this.inventoryRows * 18; - } - - protected boolean checkHotbarKeys(int p_146983_1_) { - return false; - } - - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - this.fontRendererObj.drawString(I18n.format("container.chest", new Object[0]), 8, 6, 4210752); - this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); - } - - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { + this.inventoryRows = ((ContainerItemChest) this.inventorySlots).itemChestInv.getSizeInventory() / 9; + this.ySize = i + this.inventoryRows * 18; + } + + protected boolean checkHotbarKeys(int p_146983_1_) { + return false; + } + + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { + this.fontRendererObj.drawString(I18n.format("container.chest", new Object[0]), 8, 6, 4210752); + this.fontRendererObj + .drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); + } + + 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); this.mc.getTextureManager().bindTexture(field_147017_u); int k = (this.width - this.xSize) / 2; diff --git a/src/main/java/ab/client/gui/InventoryItemChest.java b/src/main/java/ab/client/gui/InventoryItemChest.java index 4d15762..36d0964 100644 --- a/src/main/java/ab/client/gui/InventoryItemChest.java +++ b/src/main/java/ab/client/gui/InventoryItemChest.java @@ -1,118 +1,114 @@ package ab.client.gui; -import ab.common.item.relic.ItemTalismanHiddenRiches; -import ab.common.lib.register.ItemListAB; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +import ab.common.item.relic.ItemTalismanHiddenRiches; +import ab.common.lib.register.ItemListAB; + public class InventoryItemChest implements IInventory { - EntityPlayer player; - int slot; - ItemStack[] stacks = null; - boolean invPushed = false; - ItemStack storedInv = null; - int openChest; - - public InventoryItemChest(EntityPlayer player, int slot, int openChest) { - this.player = player; - this.slot = slot; - this.openChest = openChest; - } - - public static boolean isRelicTalisman(ItemStack stack) { - return (stack != null && stack.getItem() == ItemListAB.itemTalismanHiddenRiches); - } - - protected ItemStack getStack() { - ItemStack stack = this.player.inventory.getStackInSlot(this.slot); - if(stack != null) - this.storedInv = stack; - return stack; - } - - protected ItemStack[] getInventory() { - if(this.stacks != null) - return this.stacks; - ItemStack stack = getStack(); - if(isRelicTalisman(getStack())) { - this.stacks = ItemTalismanHiddenRiches.getChestLoot(stack, openChest); - return this.stacks; - } - return new ItemStack[getSizeInventory()]; - } - - public void pushInventory() { - if(this.invPushed) - return; - ItemStack stack = getStack(); - if(stack == null) - stack = this.storedInv; - if(stack != null) { - ItemStack[] inv = getInventory(); - ItemTalismanHiddenRiches.setChestLoot(stack, inv, openChest); - ItemTalismanHiddenRiches.setOpenChest(stack, -1); - } - this.invPushed = true; - } - - public int getSizeInventory() { - return 27; - } - - public ItemStack getStackInSlot(int i) { - return getInventory()[i]; - } - - public ItemStack decrStackSize(int i, int j) { - ItemStack[] inventorySlots = getInventory(); - if(inventorySlots[i] != null) { - if((inventorySlots[i]).stackSize <= j) { - ItemStack itemStack = inventorySlots[i]; - inventorySlots[i] = null; - return itemStack; - } - ItemStack stackAt = inventorySlots[i].splitStack(j); - if((inventorySlots[i]).stackSize == 0) - inventorySlots[i] = null; - return stackAt; - } - return null; - } - - public ItemStack getStackInSlotOnClosing(int i) { - return getStackInSlot(i); - } - - public void setInventorySlotContents(int i, ItemStack itemstack) { - ItemStack[] inventorySlots = getInventory(); - inventorySlots[i] = itemstack; - } - - public int getInventoryStackLimit() { - return isRelicTalisman(getStack()) ? 64 : 0; - } - - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return isRelicTalisman(getStack()); - } - - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return isRelicTalisman(getStack()); - } - - public boolean hasCustomInventoryName() { - return false; - } - - public void openInventory() {} - - public void closeInventory() {} - - public String getInventoryName() { - return "itemChestTalisman"; - } - - public void markDirty() {} -} \ No newline at end of file + EntityPlayer player; + int slot; + ItemStack[] stacks = null; + boolean invPushed = false; + ItemStack storedInv = null; + int openChest; + + public InventoryItemChest(EntityPlayer player, int slot, int openChest) { + this.player = player; + this.slot = slot; + this.openChest = openChest; + } + + public static boolean isRelicTalisman(ItemStack stack) { + return (stack != null && stack.getItem() == ItemListAB.itemTalismanHiddenRiches); + } + + protected ItemStack getStack() { + ItemStack stack = this.player.inventory.getStackInSlot(this.slot); + if (stack != null) this.storedInv = stack; + return stack; + } + + protected ItemStack[] getInventory() { + if (this.stacks != null) return this.stacks; + ItemStack stack = getStack(); + if (isRelicTalisman(getStack())) { + this.stacks = ItemTalismanHiddenRiches.getChestLoot(stack, openChest); + return this.stacks; + } + return new ItemStack[getSizeInventory()]; + } + + public void pushInventory() { + if (this.invPushed) return; + ItemStack stack = getStack(); + if (stack == null) stack = this.storedInv; + if (stack != null) { + ItemStack[] inv = getInventory(); + ItemTalismanHiddenRiches.setChestLoot(stack, inv, openChest); + ItemTalismanHiddenRiches.setOpenChest(stack, -1); + } + this.invPushed = true; + } + + public int getSizeInventory() { + return 27; + } + + public ItemStack getStackInSlot(int i) { + return getInventory()[i]; + } + + public ItemStack decrStackSize(int i, int j) { + ItemStack[] inventorySlots = getInventory(); + if (inventorySlots[i] != null) { + if ((inventorySlots[i]).stackSize <= j) { + ItemStack itemStack = inventorySlots[i]; + inventorySlots[i] = null; + return itemStack; + } + ItemStack stackAt = inventorySlots[i].splitStack(j); + if ((inventorySlots[i]).stackSize == 0) inventorySlots[i] = null; + return stackAt; + } + return null; + } + + public ItemStack getStackInSlotOnClosing(int i) { + return getStackInSlot(i); + } + + public void setInventorySlotContents(int i, ItemStack itemstack) { + ItemStack[] inventorySlots = getInventory(); + inventorySlots[i] = itemstack; + } + + public int getInventoryStackLimit() { + return isRelicTalisman(getStack()) ? 64 : 0; + } + + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + return isRelicTalisman(getStack()); + } + + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return isRelicTalisman(getStack()); + } + + public boolean hasCustomInventoryName() { + return false; + } + + public void openInventory() {} + + public void closeInventory() {} + + public String getInventoryName() { + return "itemChestTalisman"; + } + + public void markDirty() {} +} diff --git a/src/main/java/ab/client/gui/SlotItemChest.java b/src/main/java/ab/client/gui/SlotItemChest.java index 20cd3cb..347309e 100644 --- a/src/main/java/ab/client/gui/SlotItemChest.java +++ b/src/main/java/ab/client/gui/SlotItemChest.java @@ -5,20 +5,20 @@ import net.minecraft.item.ItemStack; public class SlotItemChest extends Slot { - InventoryItemChest itemChestInv; - int slot; - - public SlotItemChest(InventoryItemChest inv, int index, int x, int y, int slot) { - super(inv, index, x, y); - this.itemChestInv = inv; - this.slot = slot; - } + InventoryItemChest itemChestInv; + int slot; - public void onSlotChange(ItemStack oldStack, ItemStack newStack) { - itemChestInv.setInventorySlotContents(slot, newStack); - } - - public boolean isItemValid(ItemStack stack) { - return !itemChestInv.isRelicTalisman(stack); - } + public SlotItemChest(InventoryItemChest inv, int index, int x, int y, int slot) { + super(inv, index, x, y); + this.itemChestInv = inv; + this.slot = slot; + } + + public void onSlotChange(ItemStack oldStack, ItemStack newStack) { + itemChestInv.setInventorySlotContents(slot, newStack); + } + + public boolean isItemValid(ItemStack stack) { + return !itemChestInv.isRelicTalisman(stack); + } } diff --git a/src/main/java/ab/client/model/ModelDiceFate.java b/src/main/java/ab/client/model/ModelDiceFate.java index 47dd312..4523135 100644 --- a/src/main/java/ab/client/model/ModelDiceFate.java +++ b/src/main/java/ab/client/model/ModelDiceFate.java @@ -6,31 +6,31 @@ import net.minecraft.client.model.ModelRenderer; public class ModelDiceFate extends ModelBase { - private final ModelRenderer bb_main; + private final ModelRenderer bb_main; - public ModelDiceFate() { - - textureWidth = 48; - textureHeight = 48; + public ModelDiceFate() { - bb_main = new ModelRenderer(this); - bb_main.setRotationPoint(0.0F, 18.0F, 0.0F); - bb_main.cubeList.add(new ModelBox(bb_main, 0, 24, -6.0F, -6.0F, -6.0F, 12, 12, 12, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 0, 0, -6.0F, -6.0F, -6.0F, 12, 12, 12, 0.0F)); - } + textureWidth = 48; + textureHeight = 48; - public void render(float rotX, float rotY, float rotZ) { - setRotationAngle(bb_main, getAngel(rotX), getAngel(rotY), getAngel(rotZ)); - bb_main.render(0.0625f); - } - - private float getAngel(float rot) { - return rot / 180.0F * (float)Math.PI; - } + bb_main = new ModelRenderer(this); + bb_main.setRotationPoint(0.0F, 18.0F, 0.0F); + bb_main.cubeList.add(new ModelBox(bb_main, 0, 24, -6.0F, -6.0F, -6.0F, 12, 12, 12, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 0, 0, -6.0F, -6.0F, -6.0F, 12, 12, 12, 0.0F)); + } - public void setRotationAngle(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 render(float rotX, float rotY, float rotZ) { + setRotationAngle(bb_main, getAngel(rotX), getAngel(rotY), getAngel(rotZ)); + bb_main.render(0.0625f); + } + + private float getAngel(float rot) { + return rot / 180.0F * (float) Math.PI; + } + + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } +} diff --git a/src/main/java/ab/client/model/ModelEngineerHopper.java b/src/main/java/ab/client/model/ModelEngineerHopper.java index 3bd4707..bf3c7ea 100644 --- a/src/main/java/ab/client/model/ModelEngineerHopper.java +++ b/src/main/java/ab/client/model/ModelEngineerHopper.java @@ -1,64 +1,64 @@ package ab.client.model; -import org.lwjgl.opengl.GL11; - import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBox; import net.minecraft.client.model.ModelRenderer; +import org.lwjgl.opengl.GL11; + public class ModelEngineerHopper extends ModelBase { - - private final ModelRenderer hopperBase; - private final ModelRenderer hopperTop; - private final ModelRenderer hopperBottom; - public ModelEngineerHopper() { - textureWidth = 64; - textureHeight = 64; + private final ModelRenderer hopperBase; + private final ModelRenderer hopperTop; + private final ModelRenderer hopperBottom; - hopperBase = new ModelRenderer(this); - hopperBase.setRotationPoint(0.0F, 24.0F, 0.0F); - hopperBase.cubeList.add(new ModelBox(hopperBase, 0, 45, -7.0F, -16.0F, -7.0F, 2, 5, 14, 0.0F)); - hopperBase.cubeList.add(new ModelBox(hopperBase, 12, 27, -5.0F, -11.2F, -5.0F, 10, 3, 10, 0.0F)); - hopperBase.cubeList.add(new ModelBox(hopperBase, 0, 38, -6.0F, -11.0F, -2.0F, 2, 5, 4, 0.0F)); - hopperBase.cubeList.add(new ModelBox(hopperBase, 52, 38, 4.0F, -11.0F, -2.0F, 2, 5, 4, 0.0F)); - hopperBase.cubeList.add(new ModelBox(hopperBase, 0, 49, -2.0F, -11.0F, -6.0F, 4, 5, 2, 0.0F)); - hopperBase.cubeList.add(new ModelBox(hopperBase, 52, 49, -2.0F, -11.0F, 4.0F, 4, 5, 2, 0.0F)); - hopperBase.cubeList.add(new ModelBox(hopperBase, 32, 45, 5.0F, -16.0F, -7.0F, 2, 5, 14, 0.0F)); - hopperBase.cubeList.add(new ModelBox(hopperBase, 20, 50, -5.0F, -16.0F, 5.0F, 10, 5, 2, 0.0F)); - hopperBase.cubeList.add(new ModelBox(hopperBase, 20, 42, -5.0F, -16.0F, -7.0F, 10, 5, 2, 0.0F)); - - hopperTop = new ModelRenderer(this); - hopperTop.setRotationPoint(0.0F, 24.0F, 0.0F); - hopperTop.cubeList.add(new ModelBox(hopperTop, 20, 13, -3.0F, -20.0F, -3.0F, 6, 6, 6, 0.0F)); - - hopperBottom = new ModelRenderer(this); - hopperBottom.setRotationPoint(0.0F, 24.0F, 0.0F); - hopperBottom.cubeList.add(new ModelBox(hopperBottom, 24, 3, -2.0F, -5.0F, -2.0F, 4, 4, 4, 0.0F)); - } - - public void renderHoper(double time) { - float offset = (float)Math.sin(time / 10.0D) * 0.05F + 0.01F; - hopperBase.render(0.0625f); - - GL11.glEnable(3042); - GL11.glBlendFunc(770, 771); - GL11.glPushMatrix(); - GL11.glTranslatef(0.0f, offset, 0.0f); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.6F); - hopperTop.render(0.0625f); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glTranslatef(0.0f, -offset, 0.0f); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.6F); - hopperBottom.render(0.0625f); - GL11.glPopMatrix(); - } + public ModelEngineerHopper() { + textureWidth = 64; + textureHeight = 64; - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + hopperBase = new ModelRenderer(this); + hopperBase.setRotationPoint(0.0F, 24.0F, 0.0F); + hopperBase.cubeList.add(new ModelBox(hopperBase, 0, 45, -7.0F, -16.0F, -7.0F, 2, 5, 14, 0.0F)); + hopperBase.cubeList.add(new ModelBox(hopperBase, 12, 27, -5.0F, -11.2F, -5.0F, 10, 3, 10, 0.0F)); + hopperBase.cubeList.add(new ModelBox(hopperBase, 0, 38, -6.0F, -11.0F, -2.0F, 2, 5, 4, 0.0F)); + hopperBase.cubeList.add(new ModelBox(hopperBase, 52, 38, 4.0F, -11.0F, -2.0F, 2, 5, 4, 0.0F)); + hopperBase.cubeList.add(new ModelBox(hopperBase, 0, 49, -2.0F, -11.0F, -6.0F, 4, 5, 2, 0.0F)); + hopperBase.cubeList.add(new ModelBox(hopperBase, 52, 49, -2.0F, -11.0F, 4.0F, 4, 5, 2, 0.0F)); + hopperBase.cubeList.add(new ModelBox(hopperBase, 32, 45, 5.0F, -16.0F, -7.0F, 2, 5, 14, 0.0F)); + hopperBase.cubeList.add(new ModelBox(hopperBase, 20, 50, -5.0F, -16.0F, 5.0F, 10, 5, 2, 0.0F)); + hopperBase.cubeList.add(new ModelBox(hopperBase, 20, 42, -5.0F, -16.0F, -7.0F, 10, 5, 2, 0.0F)); + + hopperTop = new ModelRenderer(this); + hopperTop.setRotationPoint(0.0F, 24.0F, 0.0F); + hopperTop.cubeList.add(new ModelBox(hopperTop, 20, 13, -3.0F, -20.0F, -3.0F, 6, 6, 6, 0.0F)); + + hopperBottom = new ModelRenderer(this); + hopperBottom.setRotationPoint(0.0F, 24.0F, 0.0F); + hopperBottom.cubeList.add(new ModelBox(hopperBottom, 24, 3, -2.0F, -5.0F, -2.0F, 4, 4, 4, 0.0F)); + } + + public void renderHoper(double time) { + float offset = (float) Math.sin(time / 10.0D) * 0.05F + 0.01F; + hopperBase.render(0.0625f); + + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glPushMatrix(); + GL11.glTranslatef(0.0f, offset, 0.0f); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.6F); + hopperTop.render(0.0625f); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glTranslatef(0.0f, -offset, 0.0f); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.6F); + hopperBottom.render(0.0625f); + GL11.glPopMatrix(); + } + + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/ab/client/model/ModelManaCharger.java b/src/main/java/ab/client/model/ModelManaCharger.java index 1e6d85a..0865afa 100644 --- a/src/main/java/ab/client/model/ModelManaCharger.java +++ b/src/main/java/ab/client/model/ModelManaCharger.java @@ -1,120 +1,137 @@ package ab.client.model; -import java.util.Random; - -import org.lwjgl.opengl.GL11; - -import ab.client.render.tile.RenderTileManaCharger; -import ab.common.block.tile.TileManaCharger; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBox; import net.minecraft.client.model.ModelRenderer; import net.minecraft.item.ItemStack; -import vazkii.botania.api.mana.IManaItem; + +import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.LightningHandler; -import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.Vector3; +import ab.client.render.tile.RenderTileManaCharger; +import ab.common.block.tile.TileManaCharger; public class ModelManaCharger extends ModelBase { - - private final ModelRenderer chargerBase; - private final ModelRenderer chargerPlate; - - public ModelManaCharger() { - textureWidth = 32; - textureHeight = 32; + private final ModelRenderer chargerBase; + private final ModelRenderer chargerPlate; - chargerBase = new ModelRenderer(this); - chargerBase.setRotationPoint(0.0F, 24.0F, 0.0F); - chargerBase.cubeList.add(new ModelBox(chargerBase, 0, 9, -2.5F, -9.0F, -2.5F, 5, 4, 5, 0.0F)); - chargerBase.cubeList.add(new ModelBox(chargerBase, 0, 0, -3.5F, -11.0F, -3.5F, 7, 2, 7, 0.0F)); - chargerBase.cubeList.add(new ModelBox(chargerBase, 20, 9, -1.5F, -5.0F, -1.5F, 3, 3, 3, 0.0F)); + public ModelManaCharger() { + textureWidth = 32; + textureHeight = 32; - chargerPlate = new ModelRenderer(this); - chargerPlate.setRotationPoint(0.0F, 17.0F, 0.0F); - chargerPlate.cubeList.add(new ModelBox(chargerPlate, 0, 18, 5.0F, 0.0F, -2.0F, 4, 1, 4, 0.0F)); - } + chargerBase = new ModelRenderer(this); + chargerBase.setRotationPoint(0.0F, 24.0F, 0.0F); + chargerBase.cubeList.add(new ModelBox(chargerBase, 0, 9, -2.5F, -9.0F, -2.5F, 5, 4, 5, 0.0F)); + chargerBase.cubeList.add(new ModelBox(chargerBase, 0, 0, -3.5F, -11.0F, -3.5F, 7, 2, 7, 0.0F)); + chargerBase.cubeList.add(new ModelBox(chargerBase, 20, 9, -1.5F, -5.0F, -1.5F, 3, 3, 3, 0.0F)); - public void render(RenderTileManaCharger render, double time) { - TileManaCharger tile = render.charger; - float offset = (float)Math.sin(time / 40.0D) * 0.1F + 0.05F; - float polerot = -((float)time / 16.0F) * 25.0F; - GL11.glPushMatrix(); - GL11.glTranslatef(0.0F, offset, 0.0F); - GL11.glRotatef(polerot, 0.0F, 1.0F, 0.0F); - chargerBase.render(0.0625f); - if (tile.getStackInSlot(0) != null) { - float rot = this.chargerPlate.rotateAngleY * 180.0F / (float)Math.PI; - GL11.glRotatef(rot, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(-0.125F, 0.8125F, 0.125F); - GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); - render.renderItemStack(tile.getStackInSlot(0)); - } - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glTranslatef(0.0F, offset / 1.3f + 0.185f, 0.0F); - GL11.glScalef(0.85f, 0.85f, 0.85f); - for (int i = 1; i < 5; i++) { - switch(i) { - case 1: chargerPlate.rotateAngleY = 3.1416F; - break; - case 2: chargerPlate.rotateAngleY = 0; - break; - case 3: chargerPlate.rotateAngleY = 1.5708F; - break; - case 4: chargerPlate.rotateAngleY = -1.5708F; - break; - } - if(tile.getWorldObj() != null) - time += i * 36.0f; - float offset1 = (float)Math.sin(time / 15.0D) * 0.1F - 0.1F; - if(time == -1.0D) - offset1 = 0.0F; - ItemStack stack = tile.getStackInSlot(i); - GL11.glTranslatef(0.0F, -offset1, 0.0F); - if(stack != null) { - GL11.glPushMatrix(); - float manaPercent = TileManaCharger.getManaPercent(stack); - float rot = this.chargerPlate.rotateAngleY * 180.0F / (float)Math.PI; - if(manaPercent < 100.0f) { - float chargeY = (offset1 + (offset1 / 2.4f)) * ((100.0f - manaPercent) / 150.0f); - GL11.glTranslatef(0.0F, chargeY, 0.0F); - if(tile.clientTick[i] > 12) { - float posX = 0; - float posZ = 0; - switch(i) { - case 1: posX = 0.0f; posZ = -0.375f; - break; - case 2: posX = 0.0f; posZ = 0.375f; - break; - case 3: posX = -0.375f; posZ = 0.0f; - break; - case 4: posX = 0.375f; posZ = 0.0f; - break; - } - Vector3 itemVec = Vector3.fromTileEntity(render.charger).add(0.5D + posX + ((Math.random() / 8) - 0.0625f), 0.67D + offset1, 0.5D + posZ + ((Math.random() / 8) - 0.0625f)); - Vector3 tileVec = Vector3.fromTileEntity(render.charger).add(0.5D + posX, 0.7425D + offset1 - (chargeY / 2), 0.5D + posZ); - LightningHandler.spawnLightningBolt(render.charger.getWorldObj(), itemVec, tileVec, 10.0F, render.charger.getWorldObj().rand.nextLong(), 1140881820, 1140901631); - render.charger.clientTick[i] = 0; - } - } - GL11.glRotatef(rot, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(0.3125F, 1.06F, 0.1245F); - GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); - render.renderItemStack(stack); - GL11.glPopMatrix(); - } - chargerPlate.render(0.0625f); - GL11.glTranslatef(0.0F, offset1, 0.0F); - } - GL11.glPopMatrix(); - } + chargerPlate = new ModelRenderer(this); + chargerPlate.setRotationPoint(0.0F, 17.0F, 0.0F); + chargerPlate.cubeList.add(new ModelBox(chargerPlate, 0, 18, 5.0F, 0.0F, -2.0F, 4, 1, 4, 0.0F)); + } - public void setRotationAngle(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 render(RenderTileManaCharger render, double time) { + TileManaCharger tile = render.charger; + float offset = (float) Math.sin(time / 40.0D) * 0.1F + 0.05F; + float polerot = -((float) time / 16.0F) * 25.0F; + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, offset, 0.0F); + GL11.glRotatef(polerot, 0.0F, 1.0F, 0.0F); + chargerBase.render(0.0625f); + if (tile.getStackInSlot(0) != null) { + float rot = this.chargerPlate.rotateAngleY * 180.0F / (float) Math.PI; + GL11.glRotatef(rot, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.125F, 0.8125F, 0.125F); + GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); + render.renderItemStack(tile.getStackInSlot(0)); + } + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, offset / 1.3f + 0.185f, 0.0F); + GL11.glScalef(0.85f, 0.85f, 0.85f); + for (int i = 1; i < 5; i++) { + switch (i) { + case 1: + chargerPlate.rotateAngleY = 3.1416F; + break; + case 2: + chargerPlate.rotateAngleY = 0; + break; + case 3: + chargerPlate.rotateAngleY = 1.5708F; + break; + case 4: + chargerPlate.rotateAngleY = -1.5708F; + break; + } + if (tile.getWorldObj() != null) time += i * 36.0f; + float offset1 = (float) Math.sin(time / 15.0D) * 0.1F - 0.1F; + if (time == -1.0D) offset1 = 0.0F; + ItemStack stack = tile.getStackInSlot(i); + GL11.glTranslatef(0.0F, -offset1, 0.0F); + if (stack != null) { + GL11.glPushMatrix(); + float manaPercent = TileManaCharger.getManaPercent(stack); + float rot = this.chargerPlate.rotateAngleY * 180.0F / (float) Math.PI; + if (manaPercent < 100.0f) { + float chargeY = (offset1 + (offset1 / 2.4f)) * ((100.0f - manaPercent) / 150.0f); + GL11.glTranslatef(0.0F, chargeY, 0.0F); + if (tile.clientTick[i] > 12) { + float posX = 0; + float posZ = 0; + switch (i) { + case 1: + posX = 0.0f; + posZ = -0.375f; + break; + case 2: + posX = 0.0f; + posZ = 0.375f; + break; + case 3: + posX = -0.375f; + posZ = 0.0f; + break; + case 4: + posX = 0.375f; + posZ = 0.0f; + break; + } + Vector3 itemVec = Vector3.fromTileEntity(render.charger).add( + 0.5D + posX + ((Math.random() / 8) - 0.0625f), + 0.67D + offset1, + 0.5D + posZ + ((Math.random() / 8) - 0.0625f)); + Vector3 tileVec = Vector3.fromTileEntity(render.charger) + .add(0.5D + posX, 0.7425D + offset1 - (chargeY / 2), 0.5D + posZ); + LightningHandler.spawnLightningBolt( + render.charger.getWorldObj(), + itemVec, + tileVec, + 10.0F, + render.charger.getWorldObj().rand.nextLong(), + 1140881820, + 1140901631); + render.charger.clientTick[i] = 0; + } + } + GL11.glRotatef(rot, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.3125F, 1.06F, 0.1245F); + GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); + render.renderItemStack(stack); + GL11.glPopMatrix(); + } + chargerPlate.render(0.0625f); + GL11.glTranslatef(0.0F, offset1, 0.0F); + } + GL11.glPopMatrix(); + } + + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } +} diff --git a/src/main/java/ab/client/model/ModelManaContainer.java b/src/main/java/ab/client/model/ModelManaContainer.java index 6ab6fb0..5d730d3 100644 --- a/src/main/java/ab/client/model/ModelManaContainer.java +++ b/src/main/java/ab/client/model/ModelManaContainer.java @@ -5,42 +5,42 @@ import net.minecraft.client.model.ModelBox; import net.minecraft.client.model.ModelRenderer; public class ModelManaContainer extends ModelBase { - - private final ModelRenderer bb_main; - public ModelManaContainer() { - textureWidth = 64; - textureHeight = 64; + private final ModelRenderer bb_main; - bb_main = new ModelRenderer(this); - bb_main.setRotationPoint(0.0F, 24.0F, 0.0F); - bb_main.cubeList.add(new ModelBox(bb_main, 6, 14, -7.0F, -15.0F, -7.0F, 14, 5, 3, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 24, 0, -5.0F, -10.2F, -5.0F, 10, 4, 10, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 49, 37, -6.0F, -10.0F, -2.0F, 2, 6, 4, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 50, 26, 4.0F, -10.0F, -2.0F, 2, 6, 4, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 13, 23, -2.0F, -10.0F, -6.0F, 4, 6, 2, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 0, 23, -2.0F, -10.0F, 4.0F, 4, 6, 2, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 27, 23, -5.0F, -18.0F, -5.0F, 1, 3, 10, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 40, 14, -3.0F, -6.2F, -3.0F, 6, 5, 6, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 55, 0, -6.0F, -17.0F, -6.0F, 2, 2, 2, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 28, 28, 4.0F, -17.0F, -6.0F, 2, 2, 2, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 55, 5, 4.0F, -17.0F, 4.0F, 2, 2, 2, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 28, 23, -6.0F, -17.0F, 4.0F, 2, 2, 2, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 1, 0, 4.0F, -18.0F, -5.0F, 1, 3, 10, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 16, 5, -4.0F, -18.0F, 4.0F, 8, 3, 1, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 16, 0, -4.0F, -18.0F, -5.0F, 8, 3, 1, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 14, 38, -7.0F, -15.0F, 4.0F, 14, 5, 3, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 41, 48, 4.0F, -15.0F, -4.0F, 3, 5, 8, 0.0F)); - bb_main.cubeList.add(new ModelBox(bb_main, 18, 48, -7.0F, -15.0F, -4.0F, 3, 5, 8, 0.0F)); - } + public ModelManaContainer() { + textureWidth = 64; + textureHeight = 64; - public void render() { - bb_main.render(0.0625f); - } + bb_main = new ModelRenderer(this); + bb_main.setRotationPoint(0.0F, 24.0F, 0.0F); + bb_main.cubeList.add(new ModelBox(bb_main, 6, 14, -7.0F, -15.0F, -7.0F, 14, 5, 3, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 24, 0, -5.0F, -10.2F, -5.0F, 10, 4, 10, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 49, 37, -6.0F, -10.0F, -2.0F, 2, 6, 4, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 50, 26, 4.0F, -10.0F, -2.0F, 2, 6, 4, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 13, 23, -2.0F, -10.0F, -6.0F, 4, 6, 2, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 0, 23, -2.0F, -10.0F, 4.0F, 4, 6, 2, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 27, 23, -5.0F, -18.0F, -5.0F, 1, 3, 10, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 40, 14, -3.0F, -6.2F, -3.0F, 6, 5, 6, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 55, 0, -6.0F, -17.0F, -6.0F, 2, 2, 2, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 28, 28, 4.0F, -17.0F, -6.0F, 2, 2, 2, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 55, 5, 4.0F, -17.0F, 4.0F, 2, 2, 2, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 28, 23, -6.0F, -17.0F, 4.0F, 2, 2, 2, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 1, 0, 4.0F, -18.0F, -5.0F, 1, 3, 10, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 16, 5, -4.0F, -18.0F, 4.0F, 8, 3, 1, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 16, 0, -4.0F, -18.0F, -5.0F, 8, 3, 1, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 14, 38, -7.0F, -15.0F, 4.0F, 14, 5, 3, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 41, 48, 4.0F, -15.0F, -4.0F, 3, 5, 8, 0.0F)); + bb_main.cubeList.add(new ModelBox(bb_main, 18, 48, -7.0F, -15.0F, -4.0F, 3, 5, 8, 0.0F)); + } - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + public void render() { + bb_main.render(0.0625f); + } + + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/ab/client/model/ModelNidavellirForge.java b/src/main/java/ab/client/model/ModelNidavellirForge.java index 8788939..bcd8528 100644 --- a/src/main/java/ab/client/model/ModelNidavellirForge.java +++ b/src/main/java/ab/client/model/ModelNidavellirForge.java @@ -6,42 +6,42 @@ import net.minecraft.client.model.ModelRenderer; public class ModelNidavellirForge extends ModelBase { - private final ModelRenderer bottomAnvil; - private final ModelRenderer topAnvil; - - public ModelNidavellirForge() { - textureWidth = 48; - textureHeight = 48; + private final ModelRenderer bottomAnvil; + private final ModelRenderer topAnvil; - bottomAnvil = new ModelRenderer(this); - bottomAnvil.setRotationPoint(0.0F, 24.0F, 0.0F); - bottomAnvil.cubeList.add(new ModelBox(bottomAnvil, 32, 26, -3.0F, -1.0F, -4.0F, 6, 1, 1, 0.0F)); - bottomAnvil.cubeList.add(new ModelBox(bottomAnvil, 0, 31, -5.0F, -1.0F, -3.0F, 12, 1, 6, 0.0F)); - bottomAnvil.cubeList.add(new ModelBox(bottomAnvil, 32, 17, -2.0F, -3.0F, -2.0F, 4, 1, 4, 0.0F)); - bottomAnvil.cubeList.add(new ModelBox(bottomAnvil, 0, 8, -4.0F, -2.0F, -3.0F, 8, 1, 6, 0.0F)); - bottomAnvil.cubeList.add(new ModelBox(bottomAnvil, 32, 23, -3.0F, -1.0F, 3.0F, 6, 1, 1, 0.0F)); + public ModelNidavellirForge() { + textureWidth = 48; + textureHeight = 48; - topAnvil = new ModelRenderer(this); - topAnvil.setRotationPoint(0.0F, 26.0F, 0.0F); - topAnvil.cubeList.add(new ModelBox(topAnvil, 0, 23, -6.5F, -11.0F, -3.0F, 12, 2, 6, 0.0F)); - topAnvil.cubeList.add(new ModelBox(topAnvil, 0, 38, -5.5F, -12.0F, -4.0F, 13, 2, 8, 0.0F)); - topAnvil.cubeList.add(new ModelBox(topAnvil, 0, 15, -5.5F, -9.0F, -3.0F, 9, 2, 6, 0.0F)); - topAnvil.cubeList.add(new ModelBox(topAnvil, 17, 0, -4.5F, -11.0F, 2.5F, 7, 3, 1, 0.0F)); - topAnvil.cubeList.add(new ModelBox(topAnvil, 0, 0, -4.5F, -11.0F, -3.5F, 7, 3, 1, 0.0F)); - topAnvil.cubeList.add(new ModelBox(topAnvil, 30, 12, -2.5F, -7.0F, -2.0F, 5, 1, 4, 0.0F)); - } - - public void renderBottom() { - bottomAnvil.render(0.0625f); - } - - public void renderTop() { - topAnvil.render(0.0625f); - } - - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } -} \ No newline at end of file + bottomAnvil = new ModelRenderer(this); + bottomAnvil.setRotationPoint(0.0F, 24.0F, 0.0F); + bottomAnvil.cubeList.add(new ModelBox(bottomAnvil, 32, 26, -3.0F, -1.0F, -4.0F, 6, 1, 1, 0.0F)); + bottomAnvil.cubeList.add(new ModelBox(bottomAnvil, 0, 31, -5.0F, -1.0F, -3.0F, 12, 1, 6, 0.0F)); + bottomAnvil.cubeList.add(new ModelBox(bottomAnvil, 32, 17, -2.0F, -3.0F, -2.0F, 4, 1, 4, 0.0F)); + bottomAnvil.cubeList.add(new ModelBox(bottomAnvil, 0, 8, -4.0F, -2.0F, -3.0F, 8, 1, 6, 0.0F)); + bottomAnvil.cubeList.add(new ModelBox(bottomAnvil, 32, 23, -3.0F, -1.0F, 3.0F, 6, 1, 1, 0.0F)); + + topAnvil = new ModelRenderer(this); + topAnvil.setRotationPoint(0.0F, 26.0F, 0.0F); + topAnvil.cubeList.add(new ModelBox(topAnvil, 0, 23, -6.5F, -11.0F, -3.0F, 12, 2, 6, 0.0F)); + topAnvil.cubeList.add(new ModelBox(topAnvil, 0, 38, -5.5F, -12.0F, -4.0F, 13, 2, 8, 0.0F)); + topAnvil.cubeList.add(new ModelBox(topAnvil, 0, 15, -5.5F, -9.0F, -3.0F, 9, 2, 6, 0.0F)); + topAnvil.cubeList.add(new ModelBox(topAnvil, 17, 0, -4.5F, -11.0F, 2.5F, 7, 3, 1, 0.0F)); + topAnvil.cubeList.add(new ModelBox(topAnvil, 0, 0, -4.5F, -11.0F, -3.5F, 7, 3, 1, 0.0F)); + topAnvil.cubeList.add(new ModelBox(topAnvil, 30, 12, -2.5F, -7.0F, -2.0F, 5, 1, 4, 0.0F)); + } + + public void renderBottom() { + bottomAnvil.render(0.0625f); + } + + public void renderTop() { + topAnvil.render(0.0625f); + } + + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } +} diff --git a/src/main/java/ab/client/model/armor/ModelArmorNebula.java b/src/main/java/ab/client/model/armor/ModelArmorNebula.java index ba1fede..ca6b3d6 100644 --- a/src/main/java/ab/client/model/armor/ModelArmorNebula.java +++ b/src/main/java/ab/client/model/armor/ModelArmorNebula.java @@ -1,341 +1,330 @@ package ab.client.model.armor; -import java.awt.Color; -import org.lwjgl.opengl.GL11; - -import ab.client.core.ClientHelper; -import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelBox; import net.minecraft.client.model.ModelRenderer; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; -import vazkii.botania.client.core.handler.ClientTickHandler; + +import org.lwjgl.opengl.GL11; public class ModelArmorNebula extends ModelBiped { - - private final ModelRenderer head; - private final ModelRenderer cube_r1; - private final ModelRenderer cube_r2; - private final ModelRenderer cube_r3; - private final ModelRenderer cube_r12; - private final ModelRenderer cube_r13; - private final ModelRenderer cube_r14; - private final ModelRenderer cube_r15; - private final ModelRenderer chestplate; - private final ModelRenderer cube_r16; - private final ModelRenderer cube_r4; - private final ModelRenderer cube_r4_r1; - private final ModelRenderer cube_r5; - private final ModelRenderer cube_r5_r1; - private final ModelRenderer cube_r6; - private final ModelRenderer cube_r7; - private final ModelRenderer cube_r7_r1; - private final ModelRenderer cube_r7_r2; - private final ModelRenderer lArm; - private final ModelRenderer cube_r17; - private final ModelRenderer cube_r8; - private final ModelRenderer cube_r9; - private final ModelRenderer rArm; - private final ModelRenderer cube_r18; - private final ModelRenderer cube_r10; - private final ModelRenderer cube_r11; - private final ModelRenderer lLeg; - private final ModelRenderer cube_r19; - private final ModelRenderer cube_r20; - private final ModelRenderer cube_r21; - private final ModelRenderer rLeg; - private final ModelRenderer cube_r22; - private final ModelRenderer cube_r23; - private final ModelRenderer cube_r24; - private final ModelRenderer lBoot; - private final ModelRenderer cube_r25; - private final ModelRenderer cube_r26; - private final ModelRenderer rBoot; - private final ModelRenderer cube_r27; - private final ModelRenderer cube_r28; - - int slot; - public ModelArmorNebula(int slot) { - this.slot = slot; - - textureWidth = 64; - textureHeight = 128; - - head = new ModelRenderer(this); - head.setRotationPoint(0.0F, 0.0F, 0.0F); - head.cubeList.add(new ModelBox(head, 0, 66, -4.0F, -8.0F, -4.0F, 8, 2, 8, 0.21F)); - head.cubeList.add(new ModelBox(head, 36, 90, -3.0F, -8.75F, -3.0F, 6, 1, 4, 0.21F)); - - head.cubeList.add(new ModelBox(head, 0, 90, -4.0F, -6.0F, -4.0F, 1, 3, 7, 0.2085F)); - head.cubeList.add(new ModelBox(head, 19, 86, 3.0F, -6.0F, -4.0F, 1, 3, 7, 0.2085F)); - head.cubeList.add(new ModelBox(head, 28, 80, -3.0F, -6.0F, -4.0F, 6, 1, 1, 0.2075F)); - head.cubeList.add(new ModelBox(head, 23, 81, -4.0F, -6.0F, 3.0F, 1, 1, 1, 0.2075F)); - head.cubeList.add(new ModelBox(head, 23, 78, 3.0F, -6.0F, 3.0F, 1, 1, 1, 0.2075F)); + private final ModelRenderer head; + private final ModelRenderer cube_r1; + private final ModelRenderer cube_r2; + private final ModelRenderer cube_r3; + private final ModelRenderer cube_r12; + private final ModelRenderer cube_r13; + private final ModelRenderer cube_r14; + private final ModelRenderer cube_r15; + private final ModelRenderer chestplate; + private final ModelRenderer cube_r16; + private final ModelRenderer cube_r4; + private final ModelRenderer cube_r4_r1; + private final ModelRenderer cube_r5; + private final ModelRenderer cube_r5_r1; + private final ModelRenderer cube_r6; + private final ModelRenderer cube_r7; + private final ModelRenderer cube_r7_r1; + private final ModelRenderer cube_r7_r2; + private final ModelRenderer lArm; + private final ModelRenderer cube_r17; + private final ModelRenderer cube_r8; + private final ModelRenderer cube_r9; + private final ModelRenderer rArm; + private final ModelRenderer cube_r18; + private final ModelRenderer cube_r10; + private final ModelRenderer cube_r11; + private final ModelRenderer lLeg; + private final ModelRenderer cube_r19; + private final ModelRenderer cube_r20; + private final ModelRenderer cube_r21; + private final ModelRenderer rLeg; + private final ModelRenderer cube_r22; + private final ModelRenderer cube_r23; + private final ModelRenderer cube_r24; + private final ModelRenderer lBoot; + private final ModelRenderer cube_r25; + private final ModelRenderer cube_r26; + private final ModelRenderer rBoot; + private final ModelRenderer cube_r27; + private final ModelRenderer cube_r28; - cube_r1 = new ModelRenderer(this); - cube_r1.setRotationPoint(0.0F, 0.0F, 0.3F); - head.addChild(cube_r1); - setRotationAngle(cube_r1, -0.1745F, -0.3491F, 0.0F); - cube_r1.cubeList.add(new ModelBox(cube_r1, 16, 78, 0.6F, -8.4F, -6.8F, 2, 3, 1, 0.21F)); + int slot; - cube_r2 = new ModelRenderer(this); - cube_r2.setRotationPoint(0.0F, 0.0F, 0.3F); - head.addChild(cube_r2); - setRotationAngle(cube_r2, -0.1745F, 0.3491F, 0.0F); - cube_r2.cubeList.add(new ModelBox(cube_r2, 9, 78, -2.6F, -8.4F, -6.8F, 2, 3, 1, 0.21F)); + public ModelArmorNebula(int slot) { + this.slot = slot; - cube_r3 = new ModelRenderer(this); - cube_r3.setRotationPoint(0.0F, 0.0F, 0.0F); - head.addChild(cube_r3); - setRotationAngle(cube_r3, -0.2618F, 0.0F, 0.0F); - cube_r3.cubeList.add(new ModelBox(cube_r3, 5, 83, -1.0F, -9.0F, -2.5F, 2, 1, 5, 0.21F)); + textureWidth = 64; + textureHeight = 128; - cube_r12 = new ModelRenderer(this); - cube_r12.setRotationPoint(0.0F, 0.0F, 0.0F); - head.addChild(cube_r12); - setRotationAngle(cube_r12, 0.7418F, 0.0F, -0.0873F); - cube_r12.cubeList.add(new ModelBox(cube_r12, 47, 83, -4.6F, -7.0F, 3.0F, 2, 2, 4, 0.21F)); + head = new ModelRenderer(this); + head.setRotationPoint(0.0F, 0.0F, 0.0F); + head.cubeList.add(new ModelBox(head, 0, 66, -4.0F, -8.0F, -4.0F, 8, 2, 8, 0.21F)); + head.cubeList.add(new ModelBox(head, 36, 90, -3.0F, -8.75F, -3.0F, 6, 1, 4, 0.21F)); - cube_r13 = new ModelRenderer(this); - cube_r13.setRotationPoint(0.0F, 0.0F, 0.0F); - head.addChild(cube_r13); - setRotationAngle(cube_r13, 0.7418F, 0.0F, 0.0873F); - cube_r13.cubeList.add(new ModelBox(cube_r13, 45, 76, 2.6F, -7.0F, 3.0F, 2, 2, 4, 0.21F)); + head.cubeList.add(new ModelBox(head, 0, 90, -4.0F, -6.0F, -4.0F, 1, 3, 7, 0.2085F)); + head.cubeList.add(new ModelBox(head, 19, 86, 3.0F, -6.0F, -4.0F, 1, 3, 7, 0.2085F)); + head.cubeList.add(new ModelBox(head, 28, 80, -3.0F, -6.0F, -4.0F, 6, 1, 1, 0.2075F)); + head.cubeList.add(new ModelBox(head, 23, 81, -4.0F, -6.0F, 3.0F, 1, 1, 1, 0.2075F)); + head.cubeList.add(new ModelBox(head, 23, 78, 3.0F, -6.0F, 3.0F, 1, 1, 1, 0.2075F)); - cube_r14 = new ModelRenderer(this); - cube_r14.setRotationPoint(0.0F, 0.0F, 0.0F); - head.addChild(cube_r14); - setRotationAngle(cube_r14, -0.0873F, 0.0F, 0.0F); - cube_r14.cubeList.add(new ModelBox(cube_r14, 31, 84, -1.0F, -5.0F, -4.6F, 2, 1, 1, 0.21F)); + cube_r1 = new ModelRenderer(this); + cube_r1.setRotationPoint(0.0F, 0.0F, 0.3F); + head.addChild(cube_r1); + setRotationAngle(cube_r1, -0.1745F, -0.3491F, 0.0F); + cube_r1.cubeList.add(new ModelBox(cube_r1, 16, 78, 0.6F, -8.4F, -6.8F, 2, 3, 1, 0.21F)); - cube_r15 = new ModelRenderer(this); - cube_r15.setRotationPoint(0.0F, 0.0F, 0.0F); - head.addChild(cube_r15); - setRotationAngle(cube_r15, -0.48F, 0.0F, 0.0F); - cube_r15.cubeList.add(new ModelBox(cube_r15, 0, 78, -1.0F, -7.9F, -8.0F, 2, 4, 2, 0.21F)); + cube_r2 = new ModelRenderer(this); + cube_r2.setRotationPoint(0.0F, 0.0F, 0.3F); + head.addChild(cube_r2); + setRotationAngle(cube_r2, -0.1745F, 0.3491F, 0.0F); + cube_r2.cubeList.add(new ModelBox(cube_r2, 9, 78, -2.6F, -8.4F, -6.8F, 2, 3, 1, 0.21F)); - chestplate = new ModelRenderer(this); - chestplate.setRotationPoint(0.0F, 0.0F, 0.0F); - chestplate.cubeList.add(new ModelBox(chestplate, 0, 0, -4.5F, -0.2F, -3.0F, 9, 11, 6, 0.0F)); - chestplate.cubeList.add(new ModelBox(chestplate, 31, 10, -2.5F, 5.7F, 1.9F, 5, 4, 2, 0.0F)); - chestplate.cubeList.add(new ModelBox(chestplate, 31, 0, -3.5F, -0.6F, 2.6F, 7, 7, 2, 0.0F)); + cube_r3 = new ModelRenderer(this); + cube_r3.setRotationPoint(0.0F, 0.0F, 0.0F); + head.addChild(cube_r3); + setRotationAngle(cube_r3, -0.2618F, 0.0F, 0.0F); + cube_r3.cubeList.add(new ModelBox(cube_r3, 5, 83, -1.0F, -9.0F, -2.5F, 2, 1, 5, 0.21F)); - cube_r16 = new ModelRenderer(this); - cube_r16.setRotationPoint(0.0F, 24.0F, -1.0F); - chestplate.addChild(cube_r16); - setRotationAngle(cube_r16, 0.1309F, 0.0F, 0.0F); - cube_r16.cubeList.add(new ModelBox(cube_r16, 57, 16, -1.0F, -20.7F, 7.7F, 2, 6, 1, 0.0F)); + cube_r12 = new ModelRenderer(this); + cube_r12.setRotationPoint(0.0F, 0.0F, 0.0F); + head.addChild(cube_r12); + setRotationAngle(cube_r12, 0.7418F, 0.0F, -0.0873F); + cube_r12.cubeList.add(new ModelBox(cube_r12, 47, 83, -4.6F, -7.0F, 3.0F, 2, 2, 4, 0.21F)); - cube_r4 = new ModelRenderer(this); - cube_r4.setRotationPoint(-0.1F, 25.2F, 3.35F); - chestplate.addChild(cube_r4); - setRotationAngle(cube_r4, 0.2618F, 0.0F, 0.1745F); - + cube_r13 = new ModelRenderer(this); + cube_r13.setRotationPoint(0.0F, 0.0F, 0.0F); + head.addChild(cube_r13); + setRotationAngle(cube_r13, 0.7418F, 0.0F, 0.0873F); + cube_r13.cubeList.add(new ModelBox(cube_r13, 45, 76, 2.6F, -7.0F, 3.0F, 2, 2, 4, 0.21F)); - cube_r4_r1 = new ModelRenderer(this); - cube_r4_r1.setRotationPoint(0.1F, -1.2F, -3.35F); - cube_r4.addChild(cube_r4_r1); - setRotationAngle(cube_r4_r1, -0.5236F, 0.0F, 0.0F); - cube_r4_r1.cubeList.add(new ModelBox(cube_r4_r1, 50, 8, -2.0F, -25.0F, -3.0F, 2, 5, 2, 0.0F)); + cube_r14 = new ModelRenderer(this); + cube_r14.setRotationPoint(0.0F, 0.0F, 0.0F); + head.addChild(cube_r14); + setRotationAngle(cube_r14, -0.0873F, 0.0F, 0.0F); + cube_r14.cubeList.add(new ModelBox(cube_r14, 31, 84, -1.0F, -5.0F, -4.6F, 2, 1, 1, 0.21F)); - cube_r5 = new ModelRenderer(this); - cube_r5.setRotationPoint(-0.1F, 25.2F, 3.35F); - chestplate.addChild(cube_r5); - setRotationAngle(cube_r5, 0.2618F, 0.0F, -0.1745F); - + cube_r15 = new ModelRenderer(this); + cube_r15.setRotationPoint(0.0F, 0.0F, 0.0F); + head.addChild(cube_r15); + setRotationAngle(cube_r15, -0.48F, 0.0F, 0.0F); + cube_r15.cubeList.add(new ModelBox(cube_r15, 0, 78, -1.0F, -7.9F, -8.0F, 2, 4, 2, 0.21F)); - cube_r5_r1 = new ModelRenderer(this); - cube_r5_r1.setRotationPoint(0.1F, -1.2F, -3.35F); - cube_r5.addChild(cube_r5_r1); - setRotationAngle(cube_r5_r1, -0.5236F, 0.0F, 0.0F); - cube_r5_r1.cubeList.add(new ModelBox(cube_r5_r1, 50, 0, 0.0F, -25.0F, -3.0F, 2, 5, 2, 0.0F)); + chestplate = new ModelRenderer(this); + chestplate.setRotationPoint(0.0F, 0.0F, 0.0F); + chestplate.cubeList.add(new ModelBox(chestplate, 0, 0, -4.5F, -0.2F, -3.0F, 9, 11, 6, 0.0F)); + chestplate.cubeList.add(new ModelBox(chestplate, 31, 10, -2.5F, 5.7F, 1.9F, 5, 4, 2, 0.0F)); + chestplate.cubeList.add(new ModelBox(chestplate, 31, 0, -3.5F, -0.6F, 2.6F, 7, 7, 2, 0.0F)); - cube_r6 = new ModelRenderer(this); - cube_r6.setRotationPoint(0.0F, 24.0F, 0.0F); - chestplate.addChild(cube_r6); - setRotationAngle(cube_r6, -0.1745F, 0.0F, 0.0F); - + cube_r16 = new ModelRenderer(this); + cube_r16.setRotationPoint(0.0F, 24.0F, -1.0F); + chestplate.addChild(cube_r16); + setRotationAngle(cube_r16, 0.1309F, 0.0F, 0.0F); + cube_r16.cubeList.add(new ModelBox(cube_r16, 57, 16, -1.0F, -20.7F, 7.7F, 2, 6, 1, 0.0F)); - cube_r7 = new ModelRenderer(this); - cube_r7.setRotationPoint(0.0F, 23.75F, 0.0F); - chestplate.addChild(cube_r7); - setRotationAngle(cube_r7, -0.0873F, 0.0F, 0.0F); - + cube_r4 = new ModelRenderer(this); + cube_r4.setRotationPoint(-0.1F, 25.2F, 3.35F); + chestplate.addChild(cube_r4); + setRotationAngle(cube_r4, 0.2618F, 0.0F, 0.1745F); - cube_r7_r1 = new ModelRenderer(this); - cube_r7_r1.setRotationPoint(0.0F, -0.3F, 0.0F); - cube_r7.addChild(cube_r7_r1); - setRotationAngle(cube_r7_r1, 0.2182F, 0.0F, 0.0F); - cube_r7_r1.cubeList.add(new ModelBox(cube_r7_r1, 34, 68, -1.5F, -23.1842F, -1.1615F, 3, 8, 2, 0.0F)); + cube_r4_r1 = new ModelRenderer(this); + cube_r4_r1.setRotationPoint(0.1F, -1.2F, -3.35F); + cube_r4.addChild(cube_r4_r1); + setRotationAngle(cube_r4_r1, -0.5236F, 0.0F, 0.0F); + cube_r4_r1.cubeList.add(new ModelBox(cube_r4_r1, 50, 8, -2.0F, -25.0F, -3.0F, 2, 5, 2, 0.0F)); - cube_r7_r2 = new ModelRenderer(this); - cube_r7_r2.setRotationPoint(0.0F, -0.3F, 0.0F); - cube_r7.addChild(cube_r7_r2); - setRotationAngle(cube_r7_r2, 0.2618F, 0.0F, 0.0F); - cube_r7_r2.cubeList.add(new ModelBox(cube_r7_r2, 34, 17, 1.5F, -21.1842F, -0.8615F, 2, 7, 2, 0.0F)); - cube_r7_r2.cubeList.add(new ModelBox(cube_r7_r2, 54, 69, -3.5F, -21.1842F, -0.8615F, 2, 7, 2, 0.0F)); + cube_r5 = new ModelRenderer(this); + cube_r5.setRotationPoint(-0.1F, 25.2F, 3.35F); + chestplate.addChild(cube_r5); + setRotationAngle(cube_r5, 0.2618F, 0.0F, -0.1745F); - lArm = new ModelRenderer(this); - lArm.setRotationPoint(-5.0F, 2.0F, 0.0F); - lArm.cubeList.add(new ModelBox(lArm, 0, 27, -4.0F, -2.4F, -2.5F, 5, 5, 5, 0.05F)); - lArm.cubeList.add(new ModelBox(lArm, 21, 27, -3.0F, 6.0F, -2.0F, 4, 4, 4, 0.2F)); + cube_r5_r1 = new ModelRenderer(this); + cube_r5_r1.setRotationPoint(0.1F, -1.2F, -3.35F); + cube_r5.addChild(cube_r5_r1); + setRotationAngle(cube_r5_r1, -0.5236F, 0.0F, 0.0F); + cube_r5_r1.cubeList.add(new ModelBox(cube_r5_r1, 50, 0, 0.0F, -25.0F, -3.0F, 2, 5, 2, 0.0F)); - cube_r17 = new ModelRenderer(this); - cube_r17.setRotationPoint(0.0F, -3.5F, 0.0F); - lArm.addChild(cube_r17); - setRotationAngle(cube_r17, 0.8727F, 0.0F, 0.0F); - cube_r17.cubeList.add(new ModelBox(cube_r17, 45, 63, -1.7F, 1.3F, -2.3F, 2, 1, 4, 0.0F)); + cube_r6 = new ModelRenderer(this); + cube_r6.setRotationPoint(0.0F, 24.0F, 0.0F); + chestplate.addChild(cube_r6); + setRotationAngle(cube_r6, -0.1745F, 0.0F, 0.0F); - cube_r8 = new ModelRenderer(this); - cube_r8.setRotationPoint(5.2F, 22.3F, 0.0F); - lArm.addChild(cube_r8); - setRotationAngle(cube_r8, 0.0F, 0.0F, 0.2182F); - cube_r8.cubeList.add(new ModelBox(cube_r8, 54, 25, -14.0918F, -24.4119F, -1.0F, 2, 3, 2, 0.0F)); + cube_r7 = new ModelRenderer(this); + cube_r7.setRotationPoint(0.0F, 23.75F, 0.0F); + chestplate.addChild(cube_r7); + setRotationAngle(cube_r7, -0.0873F, 0.0F, 0.0F); - cube_r9 = new ModelRenderer(this); - cube_r9.setRotationPoint(5.2F, 22.3F, 0.0F); - lArm.addChild(cube_r9); - setRotationAngle(cube_r9, 0.0F, 0.0F, 0.0873F); - cube_r9.cubeList.add(new ModelBox(cube_r9, 16, 19, -11.8564F, -24.7019F, -2.0F, 4, 3, 4, 0.0F)); + cube_r7_r1 = new ModelRenderer(this); + cube_r7_r1.setRotationPoint(0.0F, -0.3F, 0.0F); + cube_r7.addChild(cube_r7_r1); + setRotationAngle(cube_r7_r1, 0.2182F, 0.0F, 0.0F); + cube_r7_r1.cubeList.add(new ModelBox(cube_r7_r1, 34, 68, -1.5F, -23.1842F, -1.1615F, 3, 8, 2, 0.0F)); - rArm = new ModelRenderer(this); - rArm.setRotationPoint(5.0F, 2.0F, 0.0F); - rArm.cubeList.add(new ModelBox(rArm, 38, 26, -1.0F, -2.4F, -2.5F, 5, 5, 5, 0.05F)); - rArm.cubeList.add(new ModelBox(rArm, 0, 38, -1.0F, 6.0F, -2.0F, 4, 4, 4, 0.2F)); + cube_r7_r2 = new ModelRenderer(this); + cube_r7_r2.setRotationPoint(0.0F, -0.3F, 0.0F); + cube_r7.addChild(cube_r7_r2); + setRotationAngle(cube_r7_r2, 0.2618F, 0.0F, 0.0F); + cube_r7_r2.cubeList.add(new ModelBox(cube_r7_r2, 34, 17, 1.5F, -21.1842F, -0.8615F, 2, 7, 2, 0.0F)); + cube_r7_r2.cubeList.add(new ModelBox(cube_r7_r2, 54, 69, -3.5F, -21.1842F, -0.8615F, 2, 7, 2, 0.0F)); - cube_r18 = new ModelRenderer(this); - cube_r18.setRotationPoint(-10.0F, -3.5F, 0.0F); - rArm.addChild(cube_r18); - setRotationAngle(cube_r18, 0.8727F, 0.0F, 0.0F); - cube_r18.cubeList.add(new ModelBox(cube_r18, 45, 63, 9.7F, 1.3F, -2.3F, 2, 1, 4, 0.0F)); + lArm = new ModelRenderer(this); + lArm.setRotationPoint(-5.0F, 2.0F, 0.0F); + lArm.cubeList.add(new ModelBox(lArm, 0, 27, -4.0F, -2.4F, -2.5F, 5, 5, 5, 0.05F)); + lArm.cubeList.add(new ModelBox(lArm, 21, 27, -3.0F, 6.0F, -2.0F, 4, 4, 4, 0.2F)); - cube_r10 = new ModelRenderer(this); - cube_r10.setRotationPoint(-4.8F, 22.3F, 0.0F); - rArm.addChild(cube_r10); - setRotationAngle(cube_r10, 0.0F, 0.0F, -0.2182F); - cube_r10.cubeList.add(new ModelBox(cube_r10, 19, 36, 11.6918F, -24.4119F, -1.0F, 2, 3, 2, 0.0F)); + cube_r17 = new ModelRenderer(this); + cube_r17.setRotationPoint(0.0F, -3.5F, 0.0F); + lArm.addChild(cube_r17); + setRotationAngle(cube_r17, 0.8727F, 0.0F, 0.0F); + cube_r17.cubeList.add(new ModelBox(cube_r17, 45, 63, -1.7F, 1.3F, -2.3F, 2, 1, 4, 0.0F)); - cube_r11 = new ModelRenderer(this); - cube_r11.setRotationPoint(-4.8F, 22.3F, 0.0F); - rArm.addChild(cube_r11); - setRotationAngle(cube_r11, 0.0F, 0.0F, -0.0873F); - cube_r11.cubeList.add(new ModelBox(cube_r11, 24, 38, 7.4564F, -24.7019F, -2.0F, 4, 3, 4, 0.0F)); + cube_r8 = new ModelRenderer(this); + cube_r8.setRotationPoint(5.2F, 22.3F, 0.0F); + lArm.addChild(cube_r8); + setRotationAngle(cube_r8, 0.0F, 0.0F, 0.2182F); + cube_r8.cubeList.add(new ModelBox(cube_r8, 54, 25, -14.0918F, -24.4119F, -1.0F, 2, 3, 2, 0.0F)); - lLeg = new ModelRenderer(this); - lLeg.setRotationPoint(0.0F, 12.0F, 0.0F); - lLeg.cubeList.add(new ModelBox(lLeg, 0, 50, -4.0F, 0.0F, -2.0F, 4, 8, 4, 0.2F)); + cube_r9 = new ModelRenderer(this); + cube_r9.setRotationPoint(5.2F, 22.3F, 0.0F); + lArm.addChild(cube_r9); + setRotationAngle(cube_r9, 0.0F, 0.0F, 0.0873F); + cube_r9.cubeList.add(new ModelBox(cube_r9, 16, 19, -11.8564F, -24.7019F, -2.0F, 4, 3, 4, 0.0F)); - cube_r19 = new ModelRenderer(this); - cube_r19.setRotationPoint(0.0F, 0.0F, 0.0F); - lLeg.addChild(cube_r19); - setRotationAngle(cube_r19, 0.2618F, 0.0F, 0.0F); - cube_r19.cubeList.add(new ModelBox(cube_r19, 46, 17, -3.0F, 0.6F, -3.8F, 2, 4, 1, 0.2F)); + rArm = new ModelRenderer(this); + rArm.setRotationPoint(5.0F, 2.0F, 0.0F); + rArm.cubeList.add(new ModelBox(rArm, 38, 26, -1.0F, -2.4F, -2.5F, 5, 5, 5, 0.05F)); + rArm.cubeList.add(new ModelBox(rArm, 0, 38, -1.0F, 6.0F, -2.0F, 4, 4, 4, 0.2F)); - cube_r20 = new ModelRenderer(this); - cube_r20.setRotationPoint(0.0F, 0.0F, 0.0F); - lLeg.addChild(cube_r20); - setRotationAngle(cube_r20, 0.3054F, 0.0F, 0.0F); - cube_r20.cubeList.add(new ModelBox(cube_r20, 7, 20, -3.0F, 2.0F, 0.7F, 2, 4, 1, 0.2F)); + cube_r18 = new ModelRenderer(this); + cube_r18.setRotationPoint(-10.0F, -3.5F, 0.0F); + rArm.addChild(cube_r18); + setRotationAngle(cube_r18, 0.8727F, 0.0F, 0.0F); + cube_r18.cubeList.add(new ModelBox(cube_r18, 45, 63, 9.7F, 1.3F, -2.3F, 2, 1, 4, 0.0F)); - cube_r21 = new ModelRenderer(this); - cube_r21.setRotationPoint(0.0F, 12.0F, 1.0F); - lLeg.addChild(cube_r21); - setRotationAngle(cube_r21, 0.1745F, 0.0F, -0.1745F); - cube_r21.cubeList.add(new ModelBox(cube_r21, 17, 48, -3.0F, -10.7F, -1.9F, 2, 4, 2, 0.2F)); + cube_r10 = new ModelRenderer(this); + cube_r10.setRotationPoint(-4.8F, 22.3F, 0.0F); + rArm.addChild(cube_r10); + setRotationAngle(cube_r10, 0.0F, 0.0F, -0.2182F); + cube_r10.cubeList.add(new ModelBox(cube_r10, 19, 36, 11.6918F, -24.4119F, -1.0F, 2, 3, 2, 0.0F)); - rLeg = new ModelRenderer(this); - rLeg.setRotationPoint(0.0F, 12.0F, 0.0F); - rLeg.cubeList.add(new ModelBox(rLeg, 42, 38, 0.0F, 0.0F, -2.0F, 4, 8, 4, 0.2F)); + cube_r11 = new ModelRenderer(this); + cube_r11.setRotationPoint(-4.8F, 22.3F, 0.0F); + rArm.addChild(cube_r11); + setRotationAngle(cube_r11, 0.0F, 0.0F, -0.0873F); + cube_r11.cubeList.add(new ModelBox(cube_r11, 24, 38, 7.4564F, -24.7019F, -2.0F, 4, 3, 4, 0.0F)); - cube_r22 = new ModelRenderer(this); - cube_r22.setRotationPoint(0.0F, 0.0F, 0.0F); - rLeg.addChild(cube_r22); - setRotationAngle(cube_r22, 0.2618F, 0.0F, 0.0F); - cube_r22.cubeList.add(new ModelBox(cube_r22, 35, 46, 1.0F, 0.6F, -3.8F, 2, 4, 1, 0.2F)); + lLeg = new ModelRenderer(this); + lLeg.setRotationPoint(0.0F, 12.0F, 0.0F); + lLeg.cubeList.add(new ModelBox(lLeg, 0, 50, -4.0F, 0.0F, -2.0F, 4, 8, 4, 0.2F)); - cube_r23 = new ModelRenderer(this); - cube_r23.setRotationPoint(0.0F, 0.0F, 0.0F); - rLeg.addChild(cube_r23); - setRotationAngle(cube_r23, 0.3054F, 0.0F, 0.0F); - cube_r23.cubeList.add(new ModelBox(cube_r23, 0, 20, 1.0F, 2.0F, 0.7F, 2, 4, 1, 0.2F)); + cube_r19 = new ModelRenderer(this); + cube_r19.setRotationPoint(0.0F, 0.0F, 0.0F); + lLeg.addChild(cube_r19); + setRotationAngle(cube_r19, 0.2618F, 0.0F, 0.0F); + cube_r19.cubeList.add(new ModelBox(cube_r19, 46, 17, -3.0F, 0.6F, -3.8F, 2, 4, 1, 0.2F)); - cube_r24 = new ModelRenderer(this); - cube_r24.setRotationPoint(0.0F, 12.0F, 1.0F); - rLeg.addChild(cube_r24); - setRotationAngle(cube_r24, 0.1745F, 0.0F, 0.1745F); - cube_r24.cubeList.add(new ModelBox(cube_r24, 26, 48, 1.0F, -10.7F, -1.9F, 2, 4, 2, 0.2F)); + cube_r20 = new ModelRenderer(this); + cube_r20.setRotationPoint(0.0F, 0.0F, 0.0F); + lLeg.addChild(cube_r20); + setRotationAngle(cube_r20, 0.3054F, 0.0F, 0.0F); + cube_r20.cubeList.add(new ModelBox(cube_r20, 7, 20, -3.0F, 2.0F, 0.7F, 2, 4, 1, 0.2F)); - lBoot = new ModelRenderer(this); - lBoot.setRotationPoint(0.0F, 12.0F, 0.0F); - lBoot.cubeList.add(new ModelBox(lBoot, 18, 56, 0.0F, 9.0F, -2.8F, 4, 3, 5, 0.2F)); + cube_r21 = new ModelRenderer(this); + cube_r21.setRotationPoint(0.0F, 12.0F, 1.0F); + lLeg.addChild(cube_r21); + setRotationAngle(cube_r21, 0.1745F, 0.0F, -0.1745F); + cube_r21.cubeList.add(new ModelBox(cube_r21, 17, 48, -3.0F, -10.7F, -1.9F, 2, 4, 2, 0.2F)); - cube_r25 = new ModelRenderer(this); - cube_r25.setRotationPoint(0.0F, 12.0F, -1.0F); - lBoot.addChild(cube_r25); - setRotationAngle(cube_r25, -0.3054F, 0.0F, 0.0F); - cube_r25.cubeList.add(new ModelBox(cube_r25, 40, 52, 1.0F, -5.7F, 1.9F, 2, 3, 1, 0.2F)); + rLeg = new ModelRenderer(this); + rLeg.setRotationPoint(0.0F, 12.0F, 0.0F); + rLeg.cubeList.add(new ModelBox(rLeg, 42, 38, 0.0F, 0.0F, -2.0F, 4, 8, 4, 0.2F)); - cube_r26 = new ModelRenderer(this); - cube_r26.setRotationPoint(0.0F, 12.0F, -1.0F); - lBoot.addChild(cube_r26); - setRotationAngle(cube_r26, 0.7418F, 0.0F, 0.1745F); - cube_r26.cubeList.add(new ModelBox(cube_r26, 33, 54, 3.2F, -1.8F, 2.2F, 1, 2, 3, 0.2F)); + cube_r22 = new ModelRenderer(this); + cube_r22.setRotationPoint(0.0F, 0.0F, 0.0F); + rLeg.addChild(cube_r22); + setRotationAngle(cube_r22, 0.2618F, 0.0F, 0.0F); + cube_r22.cubeList.add(new ModelBox(cube_r22, 35, 46, 1.0F, 0.6F, -3.8F, 2, 4, 1, 0.2F)); - rBoot = new ModelRenderer(this); - rBoot.setRotationPoint(0.0F, 12.0F, 0.0F); - rBoot.cubeList.add(new ModelBox(rBoot, 44, 53, -4.0F, 9.0F, -2.8F, 4, 3, 5, 0.2F)); + cube_r23 = new ModelRenderer(this); + cube_r23.setRotationPoint(0.0F, 0.0F, 0.0F); + rLeg.addChild(cube_r23); + setRotationAngle(cube_r23, 0.3054F, 0.0F, 0.0F); + cube_r23.cubeList.add(new ModelBox(cube_r23, 0, 20, 1.0F, 2.0F, 0.7F, 2, 4, 1, 0.2F)); - cube_r27 = new ModelRenderer(this); - cube_r27.setRotationPoint(0.0F, 12.0F, -1.0F); - rBoot.addChild(cube_r27); - setRotationAngle(cube_r27, -0.3054F, 0.0F, 0.0F); - cube_r27.cubeList.add(new ModelBox(cube_r27, 27, 65, -3.0F, -5.7F, 1.9F, 2, 3, 1, 0.2F)); + cube_r24 = new ModelRenderer(this); + cube_r24.setRotationPoint(0.0F, 12.0F, 1.0F); + rLeg.addChild(cube_r24); + setRotationAngle(cube_r24, 0.1745F, 0.0F, 0.1745F); + cube_r24.cubeList.add(new ModelBox(cube_r24, 26, 48, 1.0F, -10.7F, -1.9F, 2, 4, 2, 0.2F)); - cube_r28 = new ModelRenderer(this); - cube_r28.setRotationPoint(0.0F, 12.0F, -1.0F); - rBoot.addChild(cube_r28); - setRotationAngle(cube_r28, 0.7418F, 0.0F, -0.1745F); - cube_r28.cubeList.add(new ModelBox(cube_r28, 37, 61, -4.2F, -1.8F, 2.2F, 1, 2, 3, 0.2F)); - } - - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - if(entity instanceof net.minecraft.entity.monster.EntitySkeleton || entity instanceof net.minecraft.entity.monster.EntityZombie) - setRotationAnglesMonster(f, f1, f2, f3, f4, f5, entity); - else { - prepareForRender(entity); - setRotationAngles(f, f1, f2, f3, f4, f5, entity); - } - this.head.showModel = (this.slot == 0); - this.chestplate.showModel = (this.slot == 1); - this.lArm.showModel = (this.slot == 1); - this.rArm.showModel = (this.slot == 1); - this.rLeg.showModel = (this.slot == 2); - this.lLeg.showModel = (this.slot == 2); - this.lBoot.showModel = (this.slot == 3); - this.rBoot.showModel = (this.slot == 3); - this.bipedHeadwear.showModel = false; - this.bipedHead = this.head; - this.bipedBody = this.chestplate; - this.bipedRightArm = this.lArm; - this.bipedLeftArm = this.rArm; - if(this.slot == 2) { - this.bipedRightLeg = this.lLeg; - this.bipedLeftLeg = this.rLeg; - } else { - this.bipedRightLeg = this.rBoot; - this.bipedLeftLeg = this.lBoot; - } - if(this.isChild) { + lBoot = new ModelRenderer(this); + lBoot.setRotationPoint(0.0F, 12.0F, 0.0F); + lBoot.cubeList.add(new ModelBox(lBoot, 18, 56, 0.0F, 9.0F, -2.8F, 4, 3, 5, 0.2F)); + + cube_r25 = new ModelRenderer(this); + cube_r25.setRotationPoint(0.0F, 12.0F, -1.0F); + lBoot.addChild(cube_r25); + setRotationAngle(cube_r25, -0.3054F, 0.0F, 0.0F); + cube_r25.cubeList.add(new ModelBox(cube_r25, 40, 52, 1.0F, -5.7F, 1.9F, 2, 3, 1, 0.2F)); + + cube_r26 = new ModelRenderer(this); + cube_r26.setRotationPoint(0.0F, 12.0F, -1.0F); + lBoot.addChild(cube_r26); + setRotationAngle(cube_r26, 0.7418F, 0.0F, 0.1745F); + cube_r26.cubeList.add(new ModelBox(cube_r26, 33, 54, 3.2F, -1.8F, 2.2F, 1, 2, 3, 0.2F)); + + rBoot = new ModelRenderer(this); + rBoot.setRotationPoint(0.0F, 12.0F, 0.0F); + rBoot.cubeList.add(new ModelBox(rBoot, 44, 53, -4.0F, 9.0F, -2.8F, 4, 3, 5, 0.2F)); + + cube_r27 = new ModelRenderer(this); + cube_r27.setRotationPoint(0.0F, 12.0F, -1.0F); + rBoot.addChild(cube_r27); + setRotationAngle(cube_r27, -0.3054F, 0.0F, 0.0F); + cube_r27.cubeList.add(new ModelBox(cube_r27, 27, 65, -3.0F, -5.7F, 1.9F, 2, 3, 1, 0.2F)); + + cube_r28 = new ModelRenderer(this); + cube_r28.setRotationPoint(0.0F, 12.0F, -1.0F); + rBoot.addChild(cube_r28); + setRotationAngle(cube_r28, 0.7418F, 0.0F, -0.1745F); + cube_r28.cubeList.add(new ModelBox(cube_r28, 37, 61, -4.2F, -1.8F, 2.2F, 1, 2, 3, 0.2F)); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + if (entity instanceof net.minecraft.entity.monster.EntitySkeleton + || entity instanceof net.minecraft.entity.monster.EntityZombie) + setRotationAnglesMonster(f, f1, f2, f3, f4, f5, entity); + else { + prepareForRender(entity); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + } + this.head.showModel = (this.slot == 0); + this.chestplate.showModel = (this.slot == 1); + this.lArm.showModel = (this.slot == 1); + this.rArm.showModel = (this.slot == 1); + this.rLeg.showModel = (this.slot == 2); + this.lLeg.showModel = (this.slot == 2); + this.lBoot.showModel = (this.slot == 3); + this.rBoot.showModel = (this.slot == 3); + this.bipedHeadwear.showModel = false; + this.bipedHead = this.head; + this.bipedBody = this.chestplate; + this.bipedRightArm = this.lArm; + this.bipedLeftArm = this.rArm; + if (this.slot == 2) { + this.bipedRightLeg = this.lLeg; + this.bipedLeftLeg = this.rLeg; + } else { + this.bipedRightLeg = this.rBoot; + this.bipedLeftLeg = this.lBoot; + } + if (this.isChild) { float f6 = 2.0F; GL11.glPushMatrix(); GL11.glScalef(1.5F / f6, 1.5F / f6, 1.5F / f6); @@ -361,48 +350,49 @@ public class ModelArmorNebula extends ModelBiped { this.bipedLeftLeg.render(f5); this.bipedHeadwear.render(f5); } - } - - public void prepareForRender(Entity entity) { - EntityLivingBase living = (EntityLivingBase)entity; - this.isSneak = (living != null) ? living.isSneaking() : false; - if (living != null && living instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer)living; - ItemStack itemstack = player.inventory.getCurrentItem(); - this.heldItemRight = (itemstack != null) ? 1 : 0; - this.aimedBow = false; - if (itemstack != null && player.getItemInUseCount() > 0) { - EnumAction enumaction = itemstack.getItemUseAction(); - if (enumaction == EnumAction.block) { - this.heldItemRight = 3; - } else if (enumaction == EnumAction.bow) { - this.aimedBow = true; - } - } - } - } - - public void setRotationAnglesMonster(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity p_78087_7_) { - setRotationAngles(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, p_78087_7_); - float f6 = MathHelper.sin(this.onGround * 3.1415927F); - float f7 = MathHelper.sin((1.0F - (1.0F - this.onGround) * (1.0F - this.onGround)) * 3.1415927F); - this.bipedRightArm.rotateAngleZ = 0.0F; - this.bipedLeftArm.rotateAngleZ = 0.0F; - this.bipedRightArm.rotateAngleY = -(0.1F - f6 * 0.6F); - this.bipedLeftArm.rotateAngleY = 0.1F - f6 * 0.6F; - this.bipedRightArm.rotateAngleX = -1.5707964F; - this.bipedLeftArm.rotateAngleX = -1.5707964F; - this.bipedRightArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; - this.bipedLeftArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; - this.bipedRightArm.rotateAngleZ += MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F; - this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F; - this.bipedRightArm.rotateAngleX += MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F; - this.bipedLeftArm.rotateAngleX -= MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F; - } - - public void setRotationAngle(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 prepareForRender(Entity entity) { + EntityLivingBase living = (EntityLivingBase) entity; + this.isSneak = (living != null) ? living.isSneaking() : false; + if (living != null && living instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) living; + ItemStack itemstack = player.inventory.getCurrentItem(); + this.heldItemRight = (itemstack != null) ? 1 : 0; + this.aimedBow = false; + if (itemstack != null && player.getItemInUseCount() > 0) { + EnumAction enumaction = itemstack.getItemUseAction(); + if (enumaction == EnumAction.block) { + this.heldItemRight = 3; + } else if (enumaction == EnumAction.bow) { + this.aimedBow = true; + } + } + } + } + + public void setRotationAnglesMonster(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, + float p_78087_5_, float p_78087_6_, Entity p_78087_7_) { + setRotationAngles(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, p_78087_7_); + float f6 = MathHelper.sin(this.onGround * 3.1415927F); + float f7 = MathHelper.sin((1.0F - (1.0F - this.onGround) * (1.0F - this.onGround)) * 3.1415927F); + this.bipedRightArm.rotateAngleZ = 0.0F; + this.bipedLeftArm.rotateAngleZ = 0.0F; + this.bipedRightArm.rotateAngleY = -(0.1F - f6 * 0.6F); + this.bipedLeftArm.rotateAngleY = 0.1F - f6 * 0.6F; + this.bipedRightArm.rotateAngleX = -1.5707964F; + this.bipedLeftArm.rotateAngleX = -1.5707964F; + this.bipedRightArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; + this.bipedLeftArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; + this.bipedRightArm.rotateAngleZ += MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F; + this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F; + this.bipedRightArm.rotateAngleX += MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F; + this.bipedLeftArm.rotateAngleX -= MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F; + } + + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } +} diff --git a/src/main/java/ab/client/model/armor/ModelArmorWildHunt.java b/src/main/java/ab/client/model/armor/ModelArmorWildHunt.java index 50c3290..8640707 100644 --- a/src/main/java/ab/client/model/armor/ModelArmorWildHunt.java +++ b/src/main/java/ab/client/model/armor/ModelArmorWildHunt.java @@ -1,7 +1,5 @@ package ab.client.model.armor; -import org.lwjgl.opengl.GL11; - import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelBox; import net.minecraft.client.model.ModelRenderer; @@ -12,345 +10,348 @@ import net.minecraft.item.EnumAction; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; +import org.lwjgl.opengl.GL11; + public class ModelArmorWildHunt extends ModelBiped { - - private final ModelRenderer head; - private final ModelRenderer cube_r1; - private final ModelRenderer cube_r2; - private final ModelRenderer cube_r3; - private final ModelRenderer cube_r4; - private final ModelRenderer cube_r5; - private final ModelRenderer cube_r6; - private final ModelRenderer cube_r7; - private final ModelRenderer cube_r8; - private final ModelRenderer cube_r9; - private final ModelRenderer cube_r10; - private final ModelRenderer cube_r11; - private final ModelRenderer cube_r12; - private final ModelRenderer cube_r13; - private final ModelRenderer cube_r14; - private final ModelRenderer cube_r15; - private final ModelRenderer cube_r16; - private final ModelRenderer chest; - private final ModelRenderer cube_r17; - private final ModelRenderer cube_r18; - private final ModelRenderer cube_r19; - private final ModelRenderer cloak; - private final ModelRenderer cube_r20; - private final ModelRenderer lArm; - private final ModelRenderer cube_r21; - private final ModelRenderer cube_r22; - private final ModelRenderer cube_r23; - private final ModelRenderer cube_r24; - private final ModelRenderer cube_r25; - private final ModelRenderer cube_r26; - private final ModelRenderer rArm; - private final ModelRenderer cube_r27; - private final ModelRenderer cube_r28; - private final ModelRenderer cube_r29; - private final ModelRenderer cube_r30; - private final ModelRenderer cube_r31; - private final ModelRenderer cube_r32; - private final ModelRenderer lLeg; - private final ModelRenderer cube_r33; - private final ModelRenderer rLeg; - private final ModelRenderer cube_r34; - private final ModelRenderer rBoot; - private final ModelRenderer lBoot; - - int slot; - - public ModelArmorWildHunt(int slot) { - this.slot = slot; - - textureWidth = 64; - textureHeight = 128; - head = new ModelRenderer(this); - head.setRotationPoint(0.0F, 0.0F, 0.0F); - head.cubeList.add(new ModelBox(head, 32, 7, -4.0F, -8.0F, -4.0F, 8, 2, 8, 0.25F)); - head.cubeList.add(new ModelBox(head, 38, 18, -4.0F, -8.6F, -4.0F, 8, 1, 5, 0.0F)); - head.cubeList.add(new ModelBox(head, 21, 20, -3.0F, -8.6F, 1.0F, 6, 1, 2, 0.0F)); - head.cubeList.add(new ModelBox(head, 46, 86, -3.5F, -6.0F, 3.0F, 7, 1, 1, 0.1F)); - head.cubeList.add(new ModelBox(head, 40, 25, 3.0F, -6.2F, -1.8F, 1, 4, 5, 0.1F)); - head.cubeList.add(new ModelBox(head, 52, 25, -4.0F, -6.2F, -1.8F, 1, 4, 5, 0.1F)); - head.cubeList.add(new ModelBox(head, 28, 0, -4.0F, -6.3F, -4.0F, 1, 5, 2, 0.1F)); - head.cubeList.add(new ModelBox(head, 33, 7, 3.0F, -6.3F, -4.0F, 1, 5, 2, 0.1F)); + private final ModelRenderer head; + private final ModelRenderer cube_r1; + private final ModelRenderer cube_r2; + private final ModelRenderer cube_r3; + private final ModelRenderer cube_r4; + private final ModelRenderer cube_r5; + private final ModelRenderer cube_r6; + private final ModelRenderer cube_r7; + private final ModelRenderer cube_r8; + private final ModelRenderer cube_r9; + private final ModelRenderer cube_r10; + private final ModelRenderer cube_r11; + private final ModelRenderer cube_r12; + private final ModelRenderer cube_r13; + private final ModelRenderer cube_r14; + private final ModelRenderer cube_r15; + private final ModelRenderer cube_r16; + private final ModelRenderer chest; + private final ModelRenderer cube_r17; + private final ModelRenderer cube_r18; + private final ModelRenderer cube_r19; + private final ModelRenderer cloak; + private final ModelRenderer cube_r20; + private final ModelRenderer lArm; + private final ModelRenderer cube_r21; + private final ModelRenderer cube_r22; + private final ModelRenderer cube_r23; + private final ModelRenderer cube_r24; + private final ModelRenderer cube_r25; + private final ModelRenderer cube_r26; + private final ModelRenderer rArm; + private final ModelRenderer cube_r27; + private final ModelRenderer cube_r28; + private final ModelRenderer cube_r29; + private final ModelRenderer cube_r30; + private final ModelRenderer cube_r31; + private final ModelRenderer cube_r32; + private final ModelRenderer lLeg; + private final ModelRenderer cube_r33; + private final ModelRenderer rLeg; + private final ModelRenderer cube_r34; + private final ModelRenderer rBoot; + private final ModelRenderer lBoot; - cube_r1 = new ModelRenderer(this); - cube_r1.setRotationPoint(0.0F, 3.8F, -2.7F); - head.addChild(cube_r1); - setRotationAngle(cube_r1, -0.1745F, 0.0F, 0.1309F); - cube_r1.cubeList.add(new ModelBox(cube_r1, 31, 25, 1.7F, -6.7F, -3.0F, 2, 3, 2, -0.2F)); + int slot; - cube_r2 = new ModelRenderer(this); - cube_r2.setRotationPoint(0.0F, 3.8F, -2.7F); - head.addChild(cube_r2); - setRotationAngle(cube_r2, -0.1745F, 0.0F, -0.1309F); - cube_r2.cubeList.add(new ModelBox(cube_r2, 22, 25, -3.7F, -6.7F, -3.0F, 2, 3, 2, -0.2F)); + public ModelArmorWildHunt(int slot) { + this.slot = slot; - cube_r3 = new ModelRenderer(this); - cube_r3.setRotationPoint(0.0F, 4.0F, -1.0F); - head.addChild(cube_r3); - setRotationAngle(cube_r3, -0.1309F, 0.0F, 0.0F); - cube_r3.cubeList.add(new ModelBox(cube_r3, 21, 12, -1.0F, -13.1F, -2.8F, 2, 1, 6, 0.0F)); + textureWidth = 64; + textureHeight = 128; - cube_r4 = new ModelRenderer(this); - cube_r4.setRotationPoint(0.3F, 4.0F, -1.2F); - head.addChild(cube_r4); - setRotationAngle(cube_r4, -0.1309F, 0.0F, 0.0F); - cube_r4.cubeList.add(new ModelBox(cube_r4, 47, 61, 1.0F, -15.2F, -3.4F, 2, 3, 2, -0.3F)); - cube_r4.cubeList.add(new ModelBox(cube_r4, 47, 55, -3.6F, -15.2F, -3.4F, 2, 3, 2, -0.3F)); + head = new ModelRenderer(this); + head.setRotationPoint(0.0F, 0.0F, 0.0F); + head.cubeList.add(new ModelBox(head, 32, 7, -4.0F, -8.0F, -4.0F, 8, 2, 8, 0.25F)); + head.cubeList.add(new ModelBox(head, 38, 18, -4.0F, -8.6F, -4.0F, 8, 1, 5, 0.0F)); + head.cubeList.add(new ModelBox(head, 21, 20, -3.0F, -8.6F, 1.0F, 6, 1, 2, 0.0F)); + head.cubeList.add(new ModelBox(head, 46, 86, -3.5F, -6.0F, 3.0F, 7, 1, 1, 0.1F)); + head.cubeList.add(new ModelBox(head, 40, 25, 3.0F, -6.2F, -1.8F, 1, 4, 5, 0.1F)); + head.cubeList.add(new ModelBox(head, 52, 25, -4.0F, -6.2F, -1.8F, 1, 4, 5, 0.1F)); + head.cubeList.add(new ModelBox(head, 28, 0, -4.0F, -6.3F, -4.0F, 1, 5, 2, 0.1F)); + head.cubeList.add(new ModelBox(head, 33, 7, 3.0F, -6.3F, -4.0F, 1, 5, 2, 0.1F)); - cube_r5 = new ModelRenderer(this); - cube_r5.setRotationPoint(-0.3F, 4.0F, -1.2F); - head.addChild(cube_r5); - setRotationAngle(cube_r5, 0.2182F, 0.0F, 0.0F); - cube_r5.cubeList.add(new ModelBox(cube_r5, 47, 71, -3.0F, -13.0F, 1.2F, 2, 1, 2, -0.1F)); - cube_r5.cubeList.add(new ModelBox(cube_r5, 47, 67, 1.6F, -13.0F, 1.2F, 2, 1, 2, -0.1F)); + cube_r1 = new ModelRenderer(this); + cube_r1.setRotationPoint(0.0F, 3.8F, -2.7F); + head.addChild(cube_r1); + setRotationAngle(cube_r1, -0.1745F, 0.0F, 0.1309F); + cube_r1.cubeList.add(new ModelBox(cube_r1, 31, 25, 1.7F, -6.7F, -3.0F, 2, 3, 2, -0.2F)); - cube_r6 = new ModelRenderer(this); - cube_r6.setRotationPoint(0.0F, 4.0F, -1.0F); - head.addChild(cube_r6); - setRotationAngle(cube_r6, 0.1309F, 0.0F, 0.0F); - cube_r6.cubeList.add(new ModelBox(cube_r6, 24, 8, -1.0F, -11.2F, -2.0F, 2, 2, 1, 0.1F)); + cube_r2 = new ModelRenderer(this); + cube_r2.setRotationPoint(0.0F, 3.8F, -2.7F); + head.addChild(cube_r2); + setRotationAngle(cube_r2, -0.1745F, 0.0F, -0.1309F); + cube_r2.cubeList.add(new ModelBox(cube_r2, 22, 25, -3.7F, -6.7F, -3.0F, 2, 3, 2, -0.2F)); - cube_r7 = new ModelRenderer(this); - cube_r7.setRotationPoint(-0.8F, 5.5F, -0.1F); - head.addChild(cube_r7); - setRotationAngle(cube_r7, -0.1309F, 1.5708F, 0.0F); - cube_r7.cubeList.add(new ModelBox(cube_r7, 56, 43, -1.0F, -15.7F, -6.4F, 2, 3, 2, -0.35F)); + cube_r3 = new ModelRenderer(this); + cube_r3.setRotationPoint(0.0F, 4.0F, -1.0F); + head.addChild(cube_r3); + setRotationAngle(cube_r3, -0.1309F, 0.0F, 0.0F); + cube_r3.cubeList.add(new ModelBox(cube_r3, 21, 12, -1.0F, -13.1F, -2.8F, 2, 1, 6, 0.0F)); - cube_r8 = new ModelRenderer(this); - cube_r8.setRotationPoint(0.8F, 4.5F, -0.1F); - head.addChild(cube_r8); - setRotationAngle(cube_r8, 0.2182F, -1.5708F, 0.0F); - cube_r8.cubeList.add(new ModelBox(cube_r8, 56, 68, -1.0F, -13.7F, -1.7F, 2, 3, 2, -0.2F)); + cube_r4 = new ModelRenderer(this); + cube_r4.setRotationPoint(0.3F, 4.0F, -1.2F); + head.addChild(cube_r4); + setRotationAngle(cube_r4, -0.1309F, 0.0F, 0.0F); + cube_r4.cubeList.add(new ModelBox(cube_r4, 47, 61, 1.0F, -15.2F, -3.4F, 2, 3, 2, -0.3F)); + cube_r4.cubeList.add(new ModelBox(cube_r4, 47, 55, -3.6F, -15.2F, -3.4F, 2, 3, 2, -0.3F)); - cube_r9 = new ModelRenderer(this); - cube_r9.setRotationPoint(0.8F, 5.5F, -0.1F); - head.addChild(cube_r9); - setRotationAngle(cube_r9, -0.1309F, -1.5708F, 0.0F); - cube_r9.cubeList.add(new ModelBox(cube_r9, 56, 49, -1.0F, -15.7F, -6.4F, 2, 3, 2, -0.35F)); + cube_r5 = new ModelRenderer(this); + cube_r5.setRotationPoint(-0.3F, 4.0F, -1.2F); + head.addChild(cube_r5); + setRotationAngle(cube_r5, 0.2182F, 0.0F, 0.0F); + cube_r5.cubeList.add(new ModelBox(cube_r5, 47, 71, -3.0F, -13.0F, 1.2F, 2, 1, 2, -0.1F)); + cube_r5.cubeList.add(new ModelBox(cube_r5, 47, 67, 1.6F, -13.0F, 1.2F, 2, 1, 2, -0.1F)); - cube_r10 = new ModelRenderer(this); - cube_r10.setRotationPoint(-0.8F, 4.5F, -0.1F); - head.addChild(cube_r10); - setRotationAngle(cube_r10, 0.2182F, 1.5708F, 0.0F); - cube_r10.cubeList.add(new ModelBox(cube_r10, 56, 74, -1.0F, -13.7F, -1.7F, 2, 3, 2, -0.2F)); + cube_r6 = new ModelRenderer(this); + cube_r6.setRotationPoint(0.0F, 4.0F, -1.0F); + head.addChild(cube_r6); + setRotationAngle(cube_r6, 0.1309F, 0.0F, 0.0F); + cube_r6.cubeList.add(new ModelBox(cube_r6, 24, 8, -1.0F, -11.2F, -2.0F, 2, 2, 1, 0.1F)); - cube_r11 = new ModelRenderer(this); - cube_r11.setRotationPoint(0.0F, 3.9F, -0.7F); - head.addChild(cube_r11); - setRotationAngle(cube_r11, -0.1309F, 0.0F, 0.0F); - cube_r11.cubeList.add(new ModelBox(cube_r11, 56, 62, -1.0F, -15.7F, -6.6F, 2, 3, 2, -0.35F)); + cube_r7 = new ModelRenderer(this); + cube_r7.setRotationPoint(-0.8F, 5.5F, -0.1F); + head.addChild(cube_r7); + setRotationAngle(cube_r7, -0.1309F, 1.5708F, 0.0F); + cube_r7.cubeList.add(new ModelBox(cube_r7, 56, 43, -1.0F, -15.7F, -6.4F, 2, 3, 2, -0.35F)); - cube_r12 = new ModelRenderer(this); - cube_r12.setRotationPoint(0.0F, 3.9F, -0.7F); - head.addChild(cube_r12); - setRotationAngle(cube_r12, 0.2182F, 0.0F, 0.0F); - cube_r12.cubeList.add(new ModelBox(cube_r12, 56, 55, -1.0F, -14.7F, -1.7F, 2, 4, 2, -0.2F)); + cube_r8 = new ModelRenderer(this); + cube_r8.setRotationPoint(0.8F, 4.5F, -0.1F); + head.addChild(cube_r8); + setRotationAngle(cube_r8, 0.2182F, -1.5708F, 0.0F); + cube_r8.cubeList.add(new ModelBox(cube_r8, 56, 68, -1.0F, -13.7F, -1.7F, 2, 3, 2, -0.2F)); - cube_r13 = new ModelRenderer(this); - cube_r13.setRotationPoint(-1.6F, 3.8F, -1.6F); - head.addChild(cube_r13); - setRotationAngle(cube_r13, 0.2182F, 0.7854F, 0.0F); - cube_r13.cubeList.add(new ModelBox(cube_r13, 47, 43, -1.0F, -13.7F, -1.7F, 2, 3, 2, -0.2F)); + cube_r9 = new ModelRenderer(this); + cube_r9.setRotationPoint(0.8F, 5.5F, -0.1F); + head.addChild(cube_r9); + setRotationAngle(cube_r9, -0.1309F, -1.5708F, 0.0F); + cube_r9.cubeList.add(new ModelBox(cube_r9, 56, 49, -1.0F, -15.7F, -6.4F, 2, 3, 2, -0.35F)); - cube_r14 = new ModelRenderer(this); - cube_r14.setRotationPoint(1.6F, 3.8F, -1.6F); - head.addChild(cube_r14); - setRotationAngle(cube_r14, -0.1309F, -0.7854F, 0.0F); - cube_r14.cubeList.add(new ModelBox(cube_r14, 0, 0, -1.0F, -14.7F, -6.3F, 2, 3, 2, -0.35F)); + cube_r10 = new ModelRenderer(this); + cube_r10.setRotationPoint(-0.8F, 4.5F, -0.1F); + head.addChild(cube_r10); + setRotationAngle(cube_r10, 0.2182F, 1.5708F, 0.0F); + cube_r10.cubeList.add(new ModelBox(cube_r10, 56, 74, -1.0F, -13.7F, -1.7F, 2, 3, 2, -0.2F)); - cube_r15 = new ModelRenderer(this); - cube_r15.setRotationPoint(1.6F, 3.8F, -1.6F); - head.addChild(cube_r15); - setRotationAngle(cube_r15, 0.2182F, -0.7854F, 0.0F); - cube_r15.cubeList.add(new ModelBox(cube_r15, 47, 49, -1.0F, -13.7F, -1.7F, 2, 3, 2, -0.2F)); + cube_r11 = new ModelRenderer(this); + cube_r11.setRotationPoint(0.0F, 3.9F, -0.7F); + head.addChild(cube_r11); + setRotationAngle(cube_r11, -0.1309F, 0.0F, 0.0F); + cube_r11.cubeList.add(new ModelBox(cube_r11, 56, 62, -1.0F, -15.7F, -6.6F, 2, 3, 2, -0.35F)); - cube_r16 = new ModelRenderer(this); - cube_r16.setRotationPoint(-1.6F, 3.8F, -1.6F); - head.addChild(cube_r16); - setRotationAngle(cube_r16, -0.1309F, 0.7854F, 0.0F); - cube_r16.cubeList.add(new ModelBox(cube_r16, 0, 6, -1.0F, -14.7F, -6.3F, 2, 3, 2, -0.35F)); + cube_r12 = new ModelRenderer(this); + cube_r12.setRotationPoint(0.0F, 3.9F, -0.7F); + head.addChild(cube_r12); + setRotationAngle(cube_r12, 0.2182F, 0.0F, 0.0F); + cube_r12.cubeList.add(new ModelBox(cube_r12, 56, 55, -1.0F, -14.7F, -1.7F, 2, 4, 2, -0.2F)); - chest = new ModelRenderer(this); - chest.setRotationPoint(0.0F, 0.0F, 0.0F); - chest.cubeList.add(new ModelBox(chest, 49, 25, -1.0F, 7.85F, -2.9F, 2, 2, 1, 0.0F)); - chest.cubeList.add(new ModelBox(chest, 0, 84, -4.0F, 0.9F, -3.1F, 8, 7, 1, 0.0F)); - chest.cubeList.add(new ModelBox(chest, 19, 85, -2.5F, 4.7F, 1.9F, 5, 6, 1, 0.0F)); - chest.cubeList.add(new ModelBox(chest, 44, 89, -3.5F, 0.0F, 1.1F, 7, 7, 2, 0.0F)); - chest.cubeList.add(new ModelBox(chest, 0, 93, -4.0F, 0.0F, -2.0F, 8, 12, 4, 0.2F)); + cube_r13 = new ModelRenderer(this); + cube_r13.setRotationPoint(-1.6F, 3.8F, -1.6F); + head.addChild(cube_r13); + setRotationAngle(cube_r13, 0.2182F, 0.7854F, 0.0F); + cube_r13.cubeList.add(new ModelBox(cube_r13, 47, 43, -1.0F, -13.7F, -1.7F, 2, 3, 2, -0.2F)); - cube_r17 = new ModelRenderer(this); - cube_r17.setRotationPoint(0.0F, -3.0F, 1.2F); - chest.addChild(cube_r17); - setRotationAngle(cube_r17, 0.0873F, 0.0F, 0.0F); - cube_r17.cubeList.add(new ModelBox(cube_r17, 36, 1, -4.0F, 10.1F, -5.1F, 8, 4, 1, -0.1F)); + cube_r14 = new ModelRenderer(this); + cube_r14.setRotationPoint(1.6F, 3.8F, -1.6F); + head.addChild(cube_r14); + setRotationAngle(cube_r14, -0.1309F, -0.7854F, 0.0F); + cube_r14.cubeList.add(new ModelBox(cube_r14, 0, 0, -1.0F, -14.7F, -6.3F, 2, 3, 2, -0.35F)); - cube_r18 = new ModelRenderer(this); - cube_r18.setRotationPoint(0.0F, 20.5F, 0.8F); - chest.addChild(cube_r18); - setRotationAngle(cube_r18, 0.0F, 0.0F, 0.0436F); - cube_r18.cubeList.add(new ModelBox(cube_r18, 51, 35, 0.9F, -14.0F, -3.9F, 2, 6, 1, -0.1F)); + cube_r15 = new ModelRenderer(this); + cube_r15.setRotationPoint(1.6F, 3.8F, -1.6F); + head.addChild(cube_r15); + setRotationAngle(cube_r15, 0.2182F, -0.7854F, 0.0F); + cube_r15.cubeList.add(new ModelBox(cube_r15, 47, 49, -1.0F, -13.7F, -1.7F, 2, 3, 2, -0.2F)); - cube_r19 = new ModelRenderer(this); - cube_r19.setRotationPoint(0.0F, 20.5F, 0.8F); - chest.addChild(cube_r19); - setRotationAngle(cube_r19, 0.0F, 0.0F, -0.0436F); - cube_r19.cubeList.add(new ModelBox(cube_r19, 58, 35, -2.9F, -14.0F, -3.9F, 2, 6, 1, -0.1F)); + cube_r16 = new ModelRenderer(this); + cube_r16.setRotationPoint(-1.6F, 3.8F, -1.6F); + head.addChild(cube_r16); + setRotationAngle(cube_r16, -0.1309F, 0.7854F, 0.0F); + cube_r16.cubeList.add(new ModelBox(cube_r16, 0, 6, -1.0F, -14.7F, -6.3F, 2, 3, 2, -0.35F)); - cloak = new ModelRenderer(this); - cloak.setRotationPoint(0.0F, 2.0F, 0.0F); + chest = new ModelRenderer(this); + chest.setRotationPoint(0.0F, 0.0F, 0.0F); + chest.cubeList.add(new ModelBox(chest, 49, 25, -1.0F, 7.85F, -2.9F, 2, 2, 1, 0.0F)); + chest.cubeList.add(new ModelBox(chest, 0, 84, -4.0F, 0.9F, -3.1F, 8, 7, 1, 0.0F)); + chest.cubeList.add(new ModelBox(chest, 19, 85, -2.5F, 4.7F, 1.9F, 5, 6, 1, 0.0F)); + chest.cubeList.add(new ModelBox(chest, 44, 89, -3.5F, 0.0F, 1.1F, 7, 7, 2, 0.0F)); + chest.cubeList.add(new ModelBox(chest, 0, 93, -4.0F, 0.0F, -2.0F, 8, 12, 4, 0.2F)); - cube_r20 = new ModelRenderer(this); - cube_r20.setRotationPoint(0.0F, -6.0F, 1.0F); - cloak.addChild(cube_r20); - setRotationAngle(cube_r20, 0.2182F, 0.0F, 0.0F); - cube_r20.cubeList.add(new ModelBox(cube_r20, 0, 71, -3.0F, 4.6F, 1.4F, 6, 10, 0, 0.0F)); + cube_r17 = new ModelRenderer(this); + cube_r17.setRotationPoint(0.0F, -3.0F, 1.2F); + chest.addChild(cube_r17); + setRotationAngle(cube_r17, 0.0873F, 0.0F, 0.0F); + cube_r17.cubeList.add(new ModelBox(cube_r17, 36, 1, -4.0F, 10.1F, -5.1F, 8, 4, 1, -0.1F)); - lArm = new ModelRenderer(this); - lArm.setRotationPoint(-5.0F, 2.0F, 0.0F); - lArm.cubeList.add(new ModelBox(lArm, 31, 95, -3.0F, -2.0F, -2.0F, 4, 4, 4, 0.3F)); - lArm.cubeList.add(new ModelBox(lArm, 19, 59, -3.0F, 2.0F, -2.0F, 4, 8, 4, 0.1F)); - lArm.cubeList.add(new ModelBox(lArm, 19, 51, -3.9F, -2.7F, -2.0F, 4, 3, 4, 0.0F)); + cube_r18 = new ModelRenderer(this); + cube_r18.setRotationPoint(0.0F, 20.5F, 0.8F); + chest.addChild(cube_r18); + setRotationAngle(cube_r18, 0.0F, 0.0F, 0.0436F); + cube_r18.cubeList.add(new ModelBox(cube_r18, 51, 35, 0.9F, -14.0F, -3.9F, 2, 6, 1, -0.1F)); - cube_r21 = new ModelRenderer(this); - cube_r21.setRotationPoint(-1.1F, 10.3F, 0.5F); - lArm.addChild(cube_r21); - setRotationAngle(cube_r21, -0.1309F, 0.7854F, 0.0F); - cube_r21.cubeList.add(new ModelBox(cube_r21, 0, 29, -1.0F, -13.7F, -6.3F, 2, 2, 2, -0.45F)); + cube_r19 = new ModelRenderer(this); + cube_r19.setRotationPoint(0.0F, 20.5F, 0.8F); + chest.addChild(cube_r19); + setRotationAngle(cube_r19, 0.0F, 0.0F, -0.0436F); + cube_r19.cubeList.add(new ModelBox(cube_r19, 58, 35, -2.9F, -14.0F, -3.9F, 2, 6, 1, -0.1F)); - cube_r22 = new ModelRenderer(this); - cube_r22.setRotationPoint(0.8F, 9.9F, 1.0F); - lArm.addChild(cube_r22); - setRotationAngle(cube_r22, -0.1309F, 0.0F, 0.0F); - cube_r22.cubeList.add(new ModelBox(cube_r22, 9, 51, -3.0F, -14.7F, -3.4F, 2, 3, 2, -0.35F)); + cloak = new ModelRenderer(this); + cloak.setRotationPoint(0.0F, 2.0F, 0.0F); - cube_r23 = new ModelRenderer(this); - cube_r23.setRotationPoint(0.8F, 9.9F, 1.0F); - lArm.addChild(cube_r23); - setRotationAngle(cube_r23, 0.2182F, 0.0F, 0.0F); - cube_r23.cubeList.add(new ModelBox(cube_r23, 9, 63, -3.0F, -13.0F, 1.2F, 2, 1, 2, -0.1F)); + cube_r20 = new ModelRenderer(this); + cube_r20.setRotationPoint(0.0F, -6.0F, 1.0F); + cloak.addChild(cube_r20); + setRotationAngle(cube_r20, 0.2182F, 0.0F, 0.0F); + cube_r20.cubeList.add(new ModelBox(cube_r20, 0, 71, -3.0F, 4.6F, 1.4F, 6, 10, 0, 0.0F)); - cube_r24 = new ModelRenderer(this); - cube_r24.setRotationPoint(-1.1F, 9.7F, -0.8F); - lArm.addChild(cube_r24); - setRotationAngle(cube_r24, 0.2182F, 2.3562F, 0.0F); - cube_r24.cubeList.add(new ModelBox(cube_r24, 0, 47, -1.0F, -13.7F, -1.7F, 2, 2, 2, -0.3F)); + lArm = new ModelRenderer(this); + lArm.setRotationPoint(-5.0F, 2.0F, 0.0F); + lArm.cubeList.add(new ModelBox(lArm, 31, 95, -3.0F, -2.0F, -2.0F, 4, 4, 4, 0.3F)); + lArm.cubeList.add(new ModelBox(lArm, 19, 59, -3.0F, 2.0F, -2.0F, 4, 8, 4, 0.1F)); + lArm.cubeList.add(new ModelBox(lArm, 19, 51, -3.9F, -2.7F, -2.0F, 4, 3, 4, 0.0F)); - cube_r25 = new ModelRenderer(this); - cube_r25.setRotationPoint(-1.1F, 9.9F, -0.8F); - lArm.addChild(cube_r25); - setRotationAngle(cube_r25, -0.1309F, 2.3562F, 0.0F); - cube_r25.cubeList.add(new ModelBox(cube_r25, 0, 23, -1.0F, -13.7F, -6.3F, 2, 2, 2, -0.45F)); + cube_r21 = new ModelRenderer(this); + cube_r21.setRotationPoint(-1.1F, 10.3F, 0.5F); + lArm.addChild(cube_r21); + setRotationAngle(cube_r21, -0.1309F, 0.7854F, 0.0F); + cube_r21.cubeList.add(new ModelBox(cube_r21, 0, 29, -1.0F, -13.7F, -6.3F, 2, 2, 2, -0.45F)); - cube_r26 = new ModelRenderer(this); - cube_r26.setRotationPoint(-1.1F, 10.1F, 0.5F); - lArm.addChild(cube_r26); - setRotationAngle(cube_r26, 0.2182F, 0.7854F, 0.0F); - cube_r26.cubeList.add(new ModelBox(cube_r26, 0, 53, -1.0F, -13.7F, -1.7F, 2, 2, 2, -0.3F)); + cube_r22 = new ModelRenderer(this); + cube_r22.setRotationPoint(0.8F, 9.9F, 1.0F); + lArm.addChild(cube_r22); + setRotationAngle(cube_r22, -0.1309F, 0.0F, 0.0F); + cube_r22.cubeList.add(new ModelBox(cube_r22, 9, 51, -3.0F, -14.7F, -3.4F, 2, 3, 2, -0.35F)); - rArm = new ModelRenderer(this); - rArm.setRotationPoint(5.0F, 2.0F, 0.0F); - rArm.cubeList.add(new ModelBox(rArm, 19, 72, -1.0F, 2.0F, -2.0F, 4, 8, 4, 0.1F)); - rArm.cubeList.add(new ModelBox(rArm, 31, 105, -1.0F, -2.0F, -2.0F, 4, 4, 4, 0.3F)); - rArm.cubeList.add(new ModelBox(rArm, 19, 43, -0.1F, -2.7F, -2.0F, 4, 3, 4, 0.0F)); + cube_r23 = new ModelRenderer(this); + cube_r23.setRotationPoint(0.8F, 9.9F, 1.0F); + lArm.addChild(cube_r23); + setRotationAngle(cube_r23, 0.2182F, 0.0F, 0.0F); + cube_r23.cubeList.add(new ModelBox(cube_r23, 9, 63, -3.0F, -13.0F, 1.2F, 2, 1, 2, -0.1F)); - cube_r27 = new ModelRenderer(this); - cube_r27.setRotationPoint(1.1F, 10.1F, 0.5F); - rArm.addChild(cube_r27); - setRotationAngle(cube_r27, 0.2182F, -0.7854F, 0.0F); - cube_r27.cubeList.add(new ModelBox(cube_r27, 0, 59, -1.0F, -13.7F, -1.7F, 2, 2, 2, -0.3F)); + cube_r24 = new ModelRenderer(this); + cube_r24.setRotationPoint(-1.1F, 9.7F, -0.8F); + lArm.addChild(cube_r24); + setRotationAngle(cube_r24, 0.2182F, 2.3562F, 0.0F); + cube_r24.cubeList.add(new ModelBox(cube_r24, 0, 47, -1.0F, -13.7F, -1.7F, 2, 2, 2, -0.3F)); - cube_r28 = new ModelRenderer(this); - cube_r28.setRotationPoint(1.1F, 10.3F, 0.5F); - rArm.addChild(cube_r28); - setRotationAngle(cube_r28, -0.1309F, -0.7854F, 0.0F); - cube_r28.cubeList.add(new ModelBox(cube_r28, 0, 35, -1.0F, -13.7F, -6.3F, 2, 2, 2, -0.45F)); + cube_r25 = new ModelRenderer(this); + cube_r25.setRotationPoint(-1.1F, 9.9F, -0.8F); + lArm.addChild(cube_r25); + setRotationAngle(cube_r25, -0.1309F, 2.3562F, 0.0F); + cube_r25.cubeList.add(new ModelBox(cube_r25, 0, 23, -1.0F, -13.7F, -6.3F, 2, 2, 2, -0.45F)); - cube_r29 = new ModelRenderer(this); - cube_r29.setRotationPoint(1.2F, 10.0F, -0.8F); - rArm.addChild(cube_r29); - setRotationAngle(cube_r29, -0.1309F, -2.3562F, 0.0F); - cube_r29.cubeList.add(new ModelBox(cube_r29, 0, 41, -1.0F, -13.7F, -6.3F, 2, 2, 2, -0.45F)); + cube_r26 = new ModelRenderer(this); + cube_r26.setRotationPoint(-1.1F, 10.1F, 0.5F); + lArm.addChild(cube_r26); + setRotationAngle(cube_r26, 0.2182F, 0.7854F, 0.0F); + cube_r26.cubeList.add(new ModelBox(cube_r26, 0, 53, -1.0F, -13.7F, -1.7F, 2, 2, 2, -0.3F)); - cube_r30 = new ModelRenderer(this); - cube_r30.setRotationPoint(1.2F, 9.8F, -0.8F); - rArm.addChild(cube_r30); - setRotationAngle(cube_r30, 0.2182F, -2.3562F, 0.0F); - cube_r30.cubeList.add(new ModelBox(cube_r30, 0, 65, -1.0F, -13.7F, -1.7F, 2, 2, 2, -0.3F)); + rArm = new ModelRenderer(this); + rArm.setRotationPoint(5.0F, 2.0F, 0.0F); + rArm.cubeList.add(new ModelBox(rArm, 19, 72, -1.0F, 2.0F, -2.0F, 4, 8, 4, 0.1F)); + rArm.cubeList.add(new ModelBox(rArm, 31, 105, -1.0F, -2.0F, -2.0F, 4, 4, 4, 0.3F)); + rArm.cubeList.add(new ModelBox(rArm, 19, 43, -0.1F, -2.7F, -2.0F, 4, 3, 4, 0.0F)); - cube_r31 = new ModelRenderer(this); - cube_r31.setRotationPoint(3.3F, 10.0F, 1.0F); - rArm.addChild(cube_r31); - setRotationAngle(cube_r31, -0.1309F, 0.0F, 0.0F); - cube_r31.cubeList.add(new ModelBox(cube_r31, 9, 57, -3.0F, -14.7F, -3.4F, 2, 3, 2, -0.35F)); + cube_r27 = new ModelRenderer(this); + cube_r27.setRotationPoint(1.1F, 10.1F, 0.5F); + rArm.addChild(cube_r27); + setRotationAngle(cube_r27, 0.2182F, -0.7854F, 0.0F); + cube_r27.cubeList.add(new ModelBox(cube_r27, 0, 59, -1.0F, -13.7F, -1.7F, 2, 2, 2, -0.3F)); - cube_r32 = new ModelRenderer(this); - cube_r32.setRotationPoint(3.3F, 10.0F, 1.0F); - rArm.addChild(cube_r32); - setRotationAngle(cube_r32, 0.2182F, 0.0F, 0.0F); - cube_r32.cubeList.add(new ModelBox(cube_r32, 9, 67, -3.0F, -13.0F, 1.2F, 2, 1, 2, -0.1F)); + cube_r28 = new ModelRenderer(this); + cube_r28.setRotationPoint(1.1F, 10.3F, 0.5F); + rArm.addChild(cube_r28); + setRotationAngle(cube_r28, -0.1309F, -0.7854F, 0.0F); + cube_r28.cubeList.add(new ModelBox(cube_r28, 0, 35, -1.0F, -13.7F, -6.3F, 2, 2, 2, -0.45F)); - lLeg = new ModelRenderer(this); - lLeg.setRotationPoint(0.0F, 12.0F, 0.0F); - lLeg.cubeList.add(new ModelBox(lLeg, 48, 103, -4.0F, 0.4F, -2.0F, 4, 8, 4, 0.15F)); + cube_r29 = new ModelRenderer(this); + cube_r29.setRotationPoint(1.2F, 10.0F, -0.8F); + rArm.addChild(cube_r29); + setRotationAngle(cube_r29, -0.1309F, -2.3562F, 0.0F); + cube_r29.cubeList.add(new ModelBox(cube_r29, 0, 41, -1.0F, -13.7F, -6.3F, 2, 2, 2, -0.45F)); - cube_r33 = new ModelRenderer(this); - cube_r33.setRotationPoint(0.0F, 11.9F, 1.0F); - lLeg.addChild(cube_r33); - setRotationAngle(cube_r33, 0.0873F, 0.0F, 0.0F); - cube_r33.cubeList.add(new ModelBox(cube_r33, 37, 122, -3.5F, -10.1F, -3.1F, 3, 4, 2, -0.3F)); + cube_r30 = new ModelRenderer(this); + cube_r30.setRotationPoint(1.2F, 9.8F, -0.8F); + rArm.addChild(cube_r30); + setRotationAngle(cube_r30, 0.2182F, -2.3562F, 0.0F); + cube_r30.cubeList.add(new ModelBox(cube_r30, 0, 65, -1.0F, -13.7F, -1.7F, 2, 2, 2, -0.3F)); - rLeg = new ModelRenderer(this); - rLeg.setRotationPoint(0.0F, 12.0F, 0.0F); - rLeg.cubeList.add(new ModelBox(rLeg, 48, 116, 0.0F, 0.4F, -2.0F, 4, 8, 4, 0.15F)); + cube_r31 = new ModelRenderer(this); + cube_r31.setRotationPoint(3.3F, 10.0F, 1.0F); + rArm.addChild(cube_r31); + setRotationAngle(cube_r31, -0.1309F, 0.0F, 0.0F); + cube_r31.cubeList.add(new ModelBox(cube_r31, 9, 57, -3.0F, -14.7F, -3.4F, 2, 3, 2, -0.35F)); - cube_r34 = new ModelRenderer(this); - cube_r34.setRotationPoint(0.0F, 11.9F, 1.0F); - rLeg.addChild(cube_r34); - setRotationAngle(cube_r34, 0.0873F, 0.0F, 0.0F); - cube_r34.cubeList.add(new ModelBox(cube_r34, 37, 115, 0.5F, -10.1F, -3.1F, 3, 4, 2, -0.3F)); + cube_r32 = new ModelRenderer(this); + cube_r32.setRotationPoint(3.3F, 10.0F, 1.0F); + rArm.addChild(cube_r32); + setRotationAngle(cube_r32, 0.2182F, 0.0F, 0.0F); + cube_r32.cubeList.add(new ModelBox(cube_r32, 9, 67, -3.0F, -13.0F, 1.2F, 2, 1, 2, -0.1F)); - rBoot = new ModelRenderer(this); - rBoot.setRotationPoint(0.0F, 12.0F, 0.0F); - rBoot.cubeList.add(new ModelBox(rBoot, 0, 120, -4.0F, 9.0F, -2.8F, 4, 3, 5, 0.25F)); + lLeg = new ModelRenderer(this); + lLeg.setRotationPoint(0.0F, 12.0F, 0.0F); + lLeg.cubeList.add(new ModelBox(lLeg, 48, 103, -4.0F, 0.4F, -2.0F, 4, 8, 4, 0.15F)); - lBoot = new ModelRenderer(this); - lBoot.setRotationPoint(0.0F, 12.0F, 0.0F); - lBoot.cubeList.add(new ModelBox(lBoot, 0, 111, 0.0F, 9.0F, -2.8F, 4, 3, 5, 0.25F)); - } - - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - if(entity instanceof net.minecraft.entity.monster.EntitySkeleton || entity instanceof net.minecraft.entity.monster.EntityZombie) - setRotationAnglesMonster(f, f1, f2, f3, f4, f5, entity); - else { - prepareForRender(entity); - setRotationAngles(f, f1, f2, f3, f4, f5, entity); - } - this.head.showModel = (this.slot == 0); - this.chest.showModel = (this.slot == 1); - this.lArm.showModel = (this.slot == 1); - this.rArm.showModel = (this.slot == 1); - this.rLeg.showModel = (this.slot == 2); - this.lLeg.showModel = (this.slot == 2); - this.lBoot.showModel = (this.slot == 3); - this.rBoot.showModel = (this.slot == 3); - this.bipedHeadwear.showModel = false; - this.bipedHead = this.head; - this.bipedBody = this.chest; - this.bipedRightArm = this.lArm; - this.bipedLeftArm = this.rArm; - if(this.slot == 2) { - this.bipedRightLeg = this.lLeg; - this.bipedLeftLeg = this.rLeg; - } else { - this.bipedRightLeg = this.rBoot; - this.bipedLeftLeg = this.lBoot; - } - if(this.isChild) { + cube_r33 = new ModelRenderer(this); + cube_r33.setRotationPoint(0.0F, 11.9F, 1.0F); + lLeg.addChild(cube_r33); + setRotationAngle(cube_r33, 0.0873F, 0.0F, 0.0F); + cube_r33.cubeList.add(new ModelBox(cube_r33, 37, 122, -3.5F, -10.1F, -3.1F, 3, 4, 2, -0.3F)); + + rLeg = new ModelRenderer(this); + rLeg.setRotationPoint(0.0F, 12.0F, 0.0F); + rLeg.cubeList.add(new ModelBox(rLeg, 48, 116, 0.0F, 0.4F, -2.0F, 4, 8, 4, 0.15F)); + + cube_r34 = new ModelRenderer(this); + cube_r34.setRotationPoint(0.0F, 11.9F, 1.0F); + rLeg.addChild(cube_r34); + setRotationAngle(cube_r34, 0.0873F, 0.0F, 0.0F); + cube_r34.cubeList.add(new ModelBox(cube_r34, 37, 115, 0.5F, -10.1F, -3.1F, 3, 4, 2, -0.3F)); + + rBoot = new ModelRenderer(this); + rBoot.setRotationPoint(0.0F, 12.0F, 0.0F); + rBoot.cubeList.add(new ModelBox(rBoot, 0, 120, -4.0F, 9.0F, -2.8F, 4, 3, 5, 0.25F)); + + lBoot = new ModelRenderer(this); + lBoot.setRotationPoint(0.0F, 12.0F, 0.0F); + lBoot.cubeList.add(new ModelBox(lBoot, 0, 111, 0.0F, 9.0F, -2.8F, 4, 3, 5, 0.25F)); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + if (entity instanceof net.minecraft.entity.monster.EntitySkeleton + || entity instanceof net.minecraft.entity.monster.EntityZombie) + setRotationAnglesMonster(f, f1, f2, f3, f4, f5, entity); + else { + prepareForRender(entity); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + } + this.head.showModel = (this.slot == 0); + this.chest.showModel = (this.slot == 1); + this.lArm.showModel = (this.slot == 1); + this.rArm.showModel = (this.slot == 1); + this.rLeg.showModel = (this.slot == 2); + this.lLeg.showModel = (this.slot == 2); + this.lBoot.showModel = (this.slot == 3); + this.rBoot.showModel = (this.slot == 3); + this.bipedHeadwear.showModel = false; + this.bipedHead = this.head; + this.bipedBody = this.chest; + this.bipedRightArm = this.lArm; + this.bipedLeftArm = this.rArm; + if (this.slot == 2) { + this.bipedRightLeg = this.lLeg; + this.bipedLeftLeg = this.rLeg; + } else { + this.bipedRightLeg = this.rBoot; + this.bipedLeftLeg = this.lBoot; + } + if (this.isChild) { float f6 = 2.0F; GL11.glPushMatrix(); GL11.glScalef(1.5F / f6, 1.5F / f6, 1.5F / f6); @@ -376,48 +377,49 @@ public class ModelArmorWildHunt extends ModelBiped { this.bipedLeftLeg.render(f5); this.bipedHeadwear.render(f5); } - } - - public void prepareForRender(Entity entity) { - EntityLivingBase living = (EntityLivingBase)entity; - this.isSneak = (living != null) ? living.isSneaking() : false; - if(living != null && living instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer)living; - ItemStack itemstack = player.inventory.getCurrentItem(); - this.heldItemRight = (itemstack != null) ? 1 : 0; - this.aimedBow = false; - if(itemstack != null && player.getItemInUseCount() > 0) { - EnumAction enumaction = itemstack.getItemUseAction(); - if(enumaction == EnumAction.block) { - this.heldItemRight = 3; - } else if(enumaction == EnumAction.bow) { - this.aimedBow = true; - } - } - } - } - - public void setRotationAnglesMonster(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity p_78087_7_) { - setRotationAngles(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, p_78087_7_); - float f6 = MathHelper.sin(this.onGround * 3.1415927F); - float f7 = MathHelper.sin((1.0F - (1.0F - this.onGround) * (1.0F - this.onGround)) * 3.1415927F); - this.bipedRightArm.rotateAngleZ = 0.0F; - this.bipedLeftArm.rotateAngleZ = 0.0F; - this.bipedRightArm.rotateAngleY = -(0.1F - f6 * 0.6F); - this.bipedLeftArm.rotateAngleY = 0.1F - f6 * 0.6F; - this.bipedRightArm.rotateAngleX = -1.5707964F; - this.bipedLeftArm.rotateAngleX = -1.5707964F; - this.bipedRightArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; - this.bipedLeftArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; - this.bipedRightArm.rotateAngleZ += MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F; - this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F; - this.bipedRightArm.rotateAngleX += MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F; - this.bipedLeftArm.rotateAngleX -= MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F; - } - - public void setRotationAngle(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 prepareForRender(Entity entity) { + EntityLivingBase living = (EntityLivingBase) entity; + this.isSneak = (living != null) ? living.isSneaking() : false; + if (living != null && living instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) living; + ItemStack itemstack = player.inventory.getCurrentItem(); + this.heldItemRight = (itemstack != null) ? 1 : 0; + this.aimedBow = false; + if (itemstack != null && player.getItemInUseCount() > 0) { + EnumAction enumaction = itemstack.getItemUseAction(); + if (enumaction == EnumAction.block) { + this.heldItemRight = 3; + } else if (enumaction == EnumAction.bow) { + this.aimedBow = true; + } + } + } + } + + public void setRotationAnglesMonster(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, + float p_78087_5_, float p_78087_6_, Entity p_78087_7_) { + setRotationAngles(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, p_78087_7_); + float f6 = MathHelper.sin(this.onGround * 3.1415927F); + float f7 = MathHelper.sin((1.0F - (1.0F - this.onGround) * (1.0F - this.onGround)) * 3.1415927F); + this.bipedRightArm.rotateAngleZ = 0.0F; + this.bipedLeftArm.rotateAngleZ = 0.0F; + this.bipedRightArm.rotateAngleY = -(0.1F - f6 * 0.6F); + this.bipedLeftArm.rotateAngleY = 0.1F - f6 * 0.6F; + this.bipedRightArm.rotateAngleX = -1.5707964F; + this.bipedLeftArm.rotateAngleX = -1.5707964F; + this.bipedRightArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; + this.bipedLeftArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; + this.bipedRightArm.rotateAngleZ += MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F; + this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F; + this.bipedRightArm.rotateAngleX += MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F; + this.bipedLeftArm.rotateAngleX -= MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F; + } + + public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } +} diff --git a/src/main/java/ab/client/nei/NEIConfig.java b/src/main/java/ab/client/nei/NEIConfig.java index e42cdc5..90063ce 100644 --- a/src/main/java/ab/client/nei/NEIConfig.java +++ b/src/main/java/ab/client/nei/NEIConfig.java @@ -1,29 +1,29 @@ package ab.client.nei; +import net.minecraft.item.ItemStack; + import ab.AdvancedBotany; -import ab.common.core.handler.ConfigABHandler; import ab.common.lib.register.BlockListAB; import codechicken.nei.api.API; import codechicken.nei.api.IConfigureNEI; import codechicken.nei.recipe.ICraftingHandler; import codechicken.nei.recipe.IUsageHandler; -import net.minecraft.item.ItemStack; public class NEIConfig implements IConfigureNEI { - public String getName() { - return AdvancedBotany.modid; - } + public String getName() { + return AdvancedBotany.modid; + } - public String getVersion() { - return AdvancedBotany.version; - } + public String getVersion() { + return AdvancedBotany.version; + } - public void loadConfig() { - API.registerRecipeHandler((ICraftingHandler)new RecipeHandlerAlphirine()); - API.registerUsageHandler((IUsageHandler)new RecipeHandlerAlphirine()); - API.registerRecipeHandler((ICraftingHandler)new RecipeHandlerAdvancedPlate()); - API.registerUsageHandler((IUsageHandler)new RecipeHandlerAdvancedPlate()); - API.hideItem(new ItemStack(BlockListAB.blockAntigravitation)); - } + public void loadConfig() { + API.registerRecipeHandler((ICraftingHandler) new RecipeHandlerAlphirine()); + API.registerUsageHandler((IUsageHandler) new RecipeHandlerAlphirine()); + API.registerRecipeHandler((ICraftingHandler) new RecipeHandlerAdvancedPlate()); + API.registerUsageHandler((IUsageHandler) new RecipeHandlerAdvancedPlate()); + API.hideItem(new ItemStack(BlockListAB.blockAntigravitation)); + } } diff --git a/src/main/java/ab/client/nei/RecipeHandlerAdvancedPlate.java b/src/main/java/ab/client/nei/RecipeHandlerAdvancedPlate.java index 3937bb5..b0f9294 100644 --- a/src/main/java/ab/client/nei/RecipeHandlerAdvancedPlate.java +++ b/src/main/java/ab/client/nei/RecipeHandlerAdvancedPlate.java @@ -3,116 +3,122 @@ package ab.client.nei; import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; + import org.lwjgl.opengl.GL11; + import ab.api.AdvancedBotanyAPI; import ab.api.recipe.RecipeAdvancedPlate; import ab.client.core.ClientHelper; -import ab.client.nei.RecipeHandlerAlphirine.CachedHandlerAlphirine; import ab.common.lib.register.BlockListAB; import codechicken.lib.gui.GuiDraw; import codechicken.nei.NEIServerUtils; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.TemplateRecipeHandler; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; public class RecipeHandlerAdvancedPlate extends TemplateRecipeHandler { - - public class CachedAdvancedPlateRecipe extends TemplateRecipeHandler.CachedRecipe { - - public List inputs = new ArrayList(); - public PositionedStack output; - public int manaUsage; - - public CachedAdvancedPlateRecipe(RecipeAdvancedPlate recipe) { - setIngredients(recipe.getInputs()); - this.output = new PositionedStack(recipe.getOutput(), 111, 21); - this.inputs.add(new PositionedStack(new ItemStack(BlockListAB.blockABPlate), 73, 55)); - this.manaUsage = recipe.getManaUsage(); - } - - public void setIngredients(List inputs) { - float degreePerInput = 360.0F / inputs.size(); - float currentDegree = -90.0F; - for (Object o : inputs) { - int posX = (int)Math.round(73.0D + Math.cos(currentDegree * Math.PI / 180.0D) * 32.0D); - int posY = (int)Math.round(55.0D + Math.sin(currentDegree * Math.PI / 180.0D) * 32.0D); - this.inputs.add(new PositionedStack(o, posX, posY)); - currentDegree += degreePerInput; - } - } - - public List getIngredients() { - return getCycledIngredients(RecipeHandlerAdvancedPlate.this.cycleticks / 20, this.inputs); - } - - public PositionedStack getResult() { - return this.output; - } - } - - public String getRecipeName() { - return StatCollector.translateToLocal("ab.nei.advancedPlate"); - } - - public String getRecipeID() { - return "ab.advancedPlate"; - } - - public String getGuiTexture() { - return "botania:textures/gui/neiBlank.png"; - } - - public void loadTransferRects() { - this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(72, 54, 18, 18), getRecipeID(), new Object[0])); - } - - public int recipiesPerPage() { - return 1; - } - - public void drawBackground(int recipe) { - super.drawBackground(recipe); - GL11.glEnable(3042); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); - GuiDraw.changeTexture("botania:textures/gui/petalOverlay.png"); - GuiDraw.drawTexturedModalRect(45, 10, 38, 7, 92, 92); - int mana = ((CachedAdvancedPlateRecipe)this.arecipes.get(recipe)).manaUsage; - ClientHelper.renderPoolManaBar(32, 112, 0x239ddc, 1.0f, mana); - } - - public CachedAdvancedPlateRecipe getCachedRecipe(RecipeAdvancedPlate recipe) { - return new CachedAdvancedPlateRecipe(recipe); - } - - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals(getRecipeID())) { - for (RecipeAdvancedPlate recipe : AdvancedBotanyAPI.advancedPlateRecipes) { - this.arecipes.add(getCachedRecipe(recipe)); - } - } else { - super.loadCraftingRecipes(outputId, results); - } - } - - public void loadCraftingRecipes(ItemStack result) { - for (RecipeAdvancedPlate recipe : AdvancedBotanyAPI.advancedPlateRecipes) { - if (recipe == null) - continue; - if (((recipe.getOutput()).stackTagCompound != null && NEIServerUtils.areStacksSameType(recipe.getOutput(), result)) || ((recipe.getOutput()).stackTagCompound == null && NEIServerUtils.areStacksSameTypeCrafting(recipe.getOutput(), result))) - this.arecipes.add(getCachedRecipe(recipe)); - } - } - - public void loadUsageRecipes(ItemStack ingredient) { - for (RecipeAdvancedPlate recipe : AdvancedBotanyAPI.advancedPlateRecipes) { - if (recipe == null) - continue; - CachedAdvancedPlateRecipe crecipe = getCachedRecipe(recipe); - if(crecipe.contains(crecipe.getIngredients(), ingredient) || crecipe.contains(crecipe.getOtherStacks(), ingredient)) - this.arecipes.add(crecipe); - } - } + + public class CachedAdvancedPlateRecipe extends TemplateRecipeHandler.CachedRecipe { + + public List inputs = new ArrayList(); + public PositionedStack output; + public int manaUsage; + + public CachedAdvancedPlateRecipe(RecipeAdvancedPlate recipe) { + setIngredients(recipe.getInputs()); + this.output = new PositionedStack(recipe.getOutput(), 111, 21); + this.inputs.add(new PositionedStack(new ItemStack(BlockListAB.blockABPlate), 73, 55)); + this.manaUsage = recipe.getManaUsage(); + } + + public void setIngredients(List inputs) { + float degreePerInput = 360.0F / inputs.size(); + float currentDegree = -90.0F; + for (Object o : inputs) { + int posX = (int) Math.round(73.0D + Math.cos(currentDegree * Math.PI / 180.0D) * 32.0D); + int posY = (int) Math.round(55.0D + Math.sin(currentDegree * Math.PI / 180.0D) * 32.0D); + this.inputs.add(new PositionedStack(o, posX, posY)); + currentDegree += degreePerInput; + } + } + + public List getIngredients() { + return getCycledIngredients(RecipeHandlerAdvancedPlate.this.cycleticks / 20, this.inputs); + } + + public PositionedStack getResult() { + return this.output; + } + } + + public String getRecipeName() { + return StatCollector.translateToLocal("ab.nei.advancedPlate"); + } + + public String getRecipeID() { + return "ab.advancedPlate"; + } + + public String getGuiTexture() { + return "botania:textures/gui/neiBlank.png"; + } + + public void loadTransferRects() { + this.transferRects.add( + new TemplateRecipeHandler.RecipeTransferRect( + new Rectangle(72, 54, 18, 18), + getRecipeID(), + new Object[0])); + } + + public int recipiesPerPage() { + return 1; + } + + public void drawBackground(int recipe) { + super.drawBackground(recipe); + GL11.glEnable(3042); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); + GuiDraw.changeTexture("botania:textures/gui/petalOverlay.png"); + GuiDraw.drawTexturedModalRect(45, 10, 38, 7, 92, 92); + int mana = ((CachedAdvancedPlateRecipe) this.arecipes.get(recipe)).manaUsage; + ClientHelper.renderPoolManaBar(32, 112, 0x239ddc, 1.0f, mana); + } + + public CachedAdvancedPlateRecipe getCachedRecipe(RecipeAdvancedPlate recipe) { + return new CachedAdvancedPlateRecipe(recipe); + } + + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getRecipeID())) { + for (RecipeAdvancedPlate recipe : AdvancedBotanyAPI.advancedPlateRecipes) { + this.arecipes.add(getCachedRecipe(recipe)); + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } + + public void loadCraftingRecipes(ItemStack result) { + for (RecipeAdvancedPlate recipe : AdvancedBotanyAPI.advancedPlateRecipes) { + if (recipe == null) continue; + if (((recipe.getOutput()).stackTagCompound != null + && NEIServerUtils.areStacksSameType(recipe.getOutput(), result)) + || ((recipe.getOutput()).stackTagCompound == null + && NEIServerUtils.areStacksSameTypeCrafting(recipe.getOutput(), result))) + this.arecipes.add(getCachedRecipe(recipe)); + } + } + + public void loadUsageRecipes(ItemStack ingredient) { + for (RecipeAdvancedPlate recipe : AdvancedBotanyAPI.advancedPlateRecipes) { + if (recipe == null) continue; + CachedAdvancedPlateRecipe crecipe = getCachedRecipe(recipe); + if (crecipe.contains(crecipe.getIngredients(), ingredient) + || crecipe.contains(crecipe.getOtherStacks(), ingredient)) + this.arecipes.add(crecipe); + } + } } diff --git a/src/main/java/ab/client/nei/RecipeHandlerAlphirine.java b/src/main/java/ab/client/nei/RecipeHandlerAlphirine.java index d667526..f0c24cf 100644 --- a/src/main/java/ab/client/nei/RecipeHandlerAlphirine.java +++ b/src/main/java/ab/client/nei/RecipeHandlerAlphirine.java @@ -4,7 +4,13 @@ import java.awt.Rectangle; import java.util.ArrayList; import java.util.Collection; import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; + import org.lwjgl.opengl.GL11; + +import vazkii.botania.common.item.block.ItemBlockSpecialFlower; import ab.api.AdvancedBotanyAPI; import ab.api.recipe.RecipeAncientAlphirine; import ab.client.core.ClientHelper; @@ -12,110 +18,104 @@ import codechicken.lib.gui.GuiDraw; import codechicken.nei.NEIServerUtils; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.TemplateRecipeHandler; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; -import vazkii.botania.common.item.block.ItemBlockSpecialFlower; public class RecipeHandlerAlphirine extends TemplateRecipeHandler { - - public class CachedHandlerAlphirine extends TemplateRecipeHandler.CachedRecipe { - - public List inputs = new ArrayList(); - public PositionedStack output; - public List otherStacks = new ArrayList(); - public int chance; - - public CachedHandlerAlphirine(RecipeAncientAlphirine recipe) { - if (recipe == null) - return; - this.inputs.add(new PositionedStack(ItemBlockSpecialFlower.ofType("ancientAlphirine"), 71, 23)); - this.inputs.add(new PositionedStack(recipe.getInput(), 42, 23)); - this.output = new PositionedStack(recipe.getOutput(), 101, 23); - this.chance = recipe.getChance(); - } - - public List getIngredients() { - return getCycledIngredients(RecipeHandlerAlphirine.this.cycleticks / 20, this.inputs); - } - - public PositionedStack getResult() { - return this.output; - } - - public List getOtherStacks() { - return this.otherStacks; - } - - public boolean contains(Collection ingredients, ItemStack ingredient) { - if (ingredients == this.inputs) - for (PositionedStack stack : ingredients) { - if (stack.contains(ingredient)) - return true; - } - return super.contains(ingredients, ingredient); - } - } - - public String getRecipeName() { - return StatCollector.translateToLocal("ab.nei.alphirine"); - } - - public String getRecipeID() { - return "ab.alphirine"; - } - - public String getGuiTexture() { - return "botania:textures/gui/neiBlank.png"; - } - - public int recipiesPerPage() { - return 2; - } - - public void loadTransferRects() { - this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(70, 22, 18, 18), getRecipeID(), new Object[0])); - } - - public void drawBackground(int recipe) { - super.drawBackground(recipe); - GL11.glEnable(3042); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); - GuiDraw.changeTexture("botania:textures/gui/pureDaisyOverlay.png"); - GuiDraw.drawTexturedModalRect(45, 10, 0, 0, 65, 44); - int chance = ((CachedHandlerAlphirine)this.arecipes.get(recipe)).chance; - ClientHelper.drawChanceBar(52, 58, chance); - } - - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals(getRecipeID())) { - for (RecipeAncientAlphirine recipe : AdvancedBotanyAPI.alphirineRecipes) { - if (recipe == null) - continue; - this.arecipes.add(new CachedHandlerAlphirine(recipe)); - } - } else { - super.loadCraftingRecipes(outputId, results); - } - } - - public void loadCraftingRecipes(ItemStack result) { - for (RecipeAncientAlphirine recipe : AdvancedBotanyAPI.alphirineRecipes) { - if (recipe == null) - continue; - if (NEIServerUtils.areStacksSameTypeCrafting(recipe.getOutput(), result)) - this.arecipes.add(new CachedHandlerAlphirine(recipe)); - } - } - - public void loadUsageRecipes(ItemStack ingredient) { - for (RecipeAncientAlphirine recipe : AdvancedBotanyAPI.alphirineRecipes) { - if (recipe == null) - continue; - CachedHandlerAlphirine crecipe = new CachedHandlerAlphirine(recipe); - if (crecipe.contains(crecipe.getIngredients(), ingredient) || crecipe.contains(crecipe.getOtherStacks(), ingredient)) - this.arecipes.add(crecipe); - } - } + + public class CachedHandlerAlphirine extends TemplateRecipeHandler.CachedRecipe { + + public List inputs = new ArrayList(); + public PositionedStack output; + public List otherStacks = new ArrayList(); + public int chance; + + public CachedHandlerAlphirine(RecipeAncientAlphirine recipe) { + if (recipe == null) return; + this.inputs.add(new PositionedStack(ItemBlockSpecialFlower.ofType("ancientAlphirine"), 71, 23)); + this.inputs.add(new PositionedStack(recipe.getInput(), 42, 23)); + this.output = new PositionedStack(recipe.getOutput(), 101, 23); + this.chance = recipe.getChance(); + } + + public List getIngredients() { + return getCycledIngredients(RecipeHandlerAlphirine.this.cycleticks / 20, this.inputs); + } + + public PositionedStack getResult() { + return this.output; + } + + public List getOtherStacks() { + return this.otherStacks; + } + + public boolean contains(Collection ingredients, ItemStack ingredient) { + if (ingredients == this.inputs) for (PositionedStack stack : ingredients) { + if (stack.contains(ingredient)) return true; + } + return super.contains(ingredients, ingredient); + } + } + + public String getRecipeName() { + return StatCollector.translateToLocal("ab.nei.alphirine"); + } + + public String getRecipeID() { + return "ab.alphirine"; + } + + public String getGuiTexture() { + return "botania:textures/gui/neiBlank.png"; + } + + public int recipiesPerPage() { + return 2; + } + + public void loadTransferRects() { + this.transferRects.add( + new TemplateRecipeHandler.RecipeTransferRect( + new Rectangle(70, 22, 18, 18), + getRecipeID(), + new Object[0])); + } + + public void drawBackground(int recipe) { + super.drawBackground(recipe); + GL11.glEnable(3042); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); + GuiDraw.changeTexture("botania:textures/gui/pureDaisyOverlay.png"); + GuiDraw.drawTexturedModalRect(45, 10, 0, 0, 65, 44); + int chance = ((CachedHandlerAlphirine) this.arecipes.get(recipe)).chance; + ClientHelper.drawChanceBar(52, 58, chance); + } + + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getRecipeID())) { + for (RecipeAncientAlphirine recipe : AdvancedBotanyAPI.alphirineRecipes) { + if (recipe == null) continue; + this.arecipes.add(new CachedHandlerAlphirine(recipe)); + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } + + public void loadCraftingRecipes(ItemStack result) { + for (RecipeAncientAlphirine recipe : AdvancedBotanyAPI.alphirineRecipes) { + if (recipe == null) continue; + if (NEIServerUtils.areStacksSameTypeCrafting(recipe.getOutput(), result)) + this.arecipes.add(new CachedHandlerAlphirine(recipe)); + } + } + + public void loadUsageRecipes(ItemStack ingredient) { + for (RecipeAncientAlphirine recipe : AdvancedBotanyAPI.alphirineRecipes) { + if (recipe == null) continue; + CachedHandlerAlphirine crecipe = new CachedHandlerAlphirine(recipe); + if (crecipe.contains(crecipe.getIngredients(), ingredient) + || crecipe.contains(crecipe.getOtherStacks(), ingredient)) + this.arecipes.add(crecipe); + } + } } diff --git a/src/main/java/ab/client/render/block/RenderBlockABSpreader.java b/src/main/java/ab/client/render/block/RenderBlockABSpreader.java index f47c6a2..8ff07e8 100644 --- a/src/main/java/ab/client/render/block/RenderBlockABSpreader.java +++ b/src/main/java/ab/client/render/block/RenderBlockABSpreader.java @@ -1,36 +1,38 @@ package ab.client.render.block; -import org.lwjgl.opengl.GL11; - -import ab.common.block.tile.TileABSpreader; -import ab.common.lib.register.BlockListAB; -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.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; +import org.lwjgl.opengl.GL11; + +import ab.common.block.tile.TileABSpreader; +import ab.common.lib.register.BlockListAB; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + public class RenderBlockABSpreader implements ISimpleBlockRenderingHandler { - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - TileABSpreader spreader = new TileABSpreader(); - spreader.rotationX = -180.0F; - TileEntityRendererDispatcher.instance.renderTileEntityAt((TileEntity)spreader, 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - public int getRenderId() { - return BlockListAB.blockABSpreaderRI; - } - - public boolean shouldRender3DInInventory(int modelId) { - return true; - } -} \ No newline at end of file + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + TileABSpreader spreader = new TileABSpreader(); + spreader.rotationX = -180.0F; + TileEntityRendererDispatcher.instance.renderTileEntityAt((TileEntity) spreader, 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + return false; + } + + public int getRenderId() { + return BlockListAB.blockABSpreaderRI; + } + + public boolean shouldRender3DInInventory(int modelId) { + return true; + } +} diff --git a/src/main/java/ab/client/render/block/RenderBlockEngineerHopper.java b/src/main/java/ab/client/render/block/RenderBlockEngineerHopper.java index daf0560..1bb93e3 100644 --- a/src/main/java/ab/client/render/block/RenderBlockEngineerHopper.java +++ b/src/main/java/ab/client/render/block/RenderBlockEngineerHopper.java @@ -1,36 +1,38 @@ package ab.client.render.block; -import org.lwjgl.opengl.GL11; - -import ab.common.block.tile.TileEngineerHopper; -import ab.common.lib.register.BlockListAB; -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.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; +import org.lwjgl.opengl.GL11; + +import ab.common.block.tile.TileEngineerHopper; +import ab.common.lib.register.BlockListAB; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + public class RenderBlockEngineerHopper implements ISimpleBlockRenderingHandler { - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - GL11.glScalef(1.4f, 1.4f, 1.4f); - TileEngineerHopper hopper = new TileEngineerHopper(); - TileEntityRendererDispatcher.instance.renderTileEntityAt((TileEntity)hopper, 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - public int getRenderId() { - return BlockListAB.blockEngineerHopperRI; - } - - public boolean shouldRender3DInInventory(int modelId) { - return true; - } -} \ No newline at end of file + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + GL11.glScalef(1.4f, 1.4f, 1.4f); + TileEngineerHopper hopper = new TileEngineerHopper(); + TileEntityRendererDispatcher.instance.renderTileEntityAt((TileEntity) hopper, 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + return false; + } + + public int getRenderId() { + return BlockListAB.blockEngineerHopperRI; + } + + public boolean shouldRender3DInInventory(int modelId) { + return true; + } +} diff --git a/src/main/java/ab/client/render/block/RenderBlockManaCharger.java b/src/main/java/ab/client/render/block/RenderBlockManaCharger.java index b118d7e..f8c2654 100644 --- a/src/main/java/ab/client/render/block/RenderBlockManaCharger.java +++ b/src/main/java/ab/client/render/block/RenderBlockManaCharger.java @@ -1,36 +1,38 @@ package ab.client.render.block; -import org.lwjgl.opengl.GL11; - -import ab.common.block.tile.TileManaCharger; -import ab.common.lib.register.BlockListAB; -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.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; +import org.lwjgl.opengl.GL11; + +import ab.common.block.tile.TileManaCharger; +import ab.common.lib.register.BlockListAB; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + public class RenderBlockManaCharger implements ISimpleBlockRenderingHandler { - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.625F, -0.5F); - GL11.glScalef(1.35f, 1.35f, 1.35f); - TileManaCharger charger = new TileManaCharger(); - TileEntityRendererDispatcher.instance.renderTileEntityAt((TileEntity)charger, 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - public int getRenderId() { - return BlockListAB.blockManaChargerRI; - } - - public boolean shouldRender3DInInventory(int modelId) { - return true; - } -} \ No newline at end of file + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.625F, -0.5F); + GL11.glScalef(1.35f, 1.35f, 1.35f); + TileManaCharger charger = new TileManaCharger(); + TileEntityRendererDispatcher.instance.renderTileEntityAt((TileEntity) charger, 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + return false; + } + + public int getRenderId() { + return BlockListAB.blockManaChargerRI; + } + + public boolean shouldRender3DInInventory(int modelId) { + return true; + } +} diff --git a/src/main/java/ab/client/render/block/RenderBlockManaContainer.java b/src/main/java/ab/client/render/block/RenderBlockManaContainer.java index 7392138..4832c45 100644 --- a/src/main/java/ab/client/render/block/RenderBlockManaContainer.java +++ b/src/main/java/ab/client/render/block/RenderBlockManaContainer.java @@ -1,38 +1,40 @@ package ab.client.render.block; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; + import org.lwjgl.opengl.GL11; import ab.client.render.tile.RenderTileManaContainer; import ab.common.block.tile.TileManaContainer; import ab.common.lib.register.BlockListAB; 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.tileentity.TileEntity; -import net.minecraft.world.IBlockAccess; public class RenderBlockManaContainer implements ISimpleBlockRenderingHandler { - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - GL11.glScalef(1.4f, 1.4f, 1.4f); - TileManaContainer container = new TileManaContainer(); - RenderTileManaContainer.metadata = metadata; - TileEntityRendererDispatcher.instance.renderTileEntityAt((TileEntity)container, 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - public int getRenderId() { - return BlockListAB.blockManaContainerRI; - } - - public boolean shouldRender3DInInventory(int modelId) { - return true; - } -} \ No newline at end of file + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + GL11.glScalef(1.4f, 1.4f, 1.4f); + TileManaContainer container = new TileManaContainer(); + RenderTileManaContainer.metadata = metadata; + TileEntityRendererDispatcher.instance.renderTileEntityAt((TileEntity) container, 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + return false; + } + + public int getRenderId() { + return BlockListAB.blockManaContainerRI; + } + + public boolean shouldRender3DInInventory(int modelId) { + return true; + } +} diff --git a/src/main/java/ab/client/render/block/RenderBlockManaCrystalCube.java b/src/main/java/ab/client/render/block/RenderBlockManaCrystalCube.java index 2340836..d84e47f 100644 --- a/src/main/java/ab/client/render/block/RenderBlockManaCrystalCube.java +++ b/src/main/java/ab/client/render/block/RenderBlockManaCrystalCube.java @@ -1,37 +1,39 @@ package ab.client.render.block; -import org.lwjgl.opengl.GL11; - -import ab.common.block.tile.TileManaCrystalCube; -import ab.common.lib.register.BlockListAB; -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.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; +import org.lwjgl.opengl.GL11; + +import ab.common.block.tile.TileManaCrystalCube; +import ab.common.lib.register.BlockListAB; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + public class RenderBlockManaCrystalCube implements ISimpleBlockRenderingHandler { - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - GL11.glDisable(3008); - TileManaCrystalCube cube = new TileManaCrystalCube(); - TileEntityRendererDispatcher.instance.renderTileEntityAt((TileEntity)cube, 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glEnable(3008); - GL11.glPopMatrix(); - } - - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - public int getRenderId() { - return BlockListAB.blockManaCrystalCubeRI; - } - - public boolean shouldRender3DInInventory(int modelId) { - return true; - } + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + GL11.glDisable(3008); + TileManaCrystalCube cube = new TileManaCrystalCube(); + TileEntityRendererDispatcher.instance.renderTileEntityAt((TileEntity) cube, 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glEnable(3008); + GL11.glPopMatrix(); + } + + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + return false; + } + + public int getRenderId() { + return BlockListAB.blockManaCrystalCubeRI; + } + + public boolean shouldRender3DInInventory(int modelId) { + return true; + } } diff --git a/src/main/java/ab/client/render/block/RenderBlockNidavellirForge.java b/src/main/java/ab/client/render/block/RenderBlockNidavellirForge.java index afc65ac..4a7c863 100644 --- a/src/main/java/ab/client/render/block/RenderBlockNidavellirForge.java +++ b/src/main/java/ab/client/render/block/RenderBlockNidavellirForge.java @@ -1,38 +1,40 @@ package ab.client.render.block; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; + import org.lwjgl.opengl.GL11; import ab.client.render.tile.RenderTileManaContainer; import ab.common.block.tile.TileNidavellirForge; import ab.common.lib.register.BlockListAB; 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.tileentity.TileEntity; -import net.minecraft.world.IBlockAccess; public class RenderBlockNidavellirForge implements ISimpleBlockRenderingHandler { - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.375F, -0.5F); - GL11.glScalef(1.25f, 1.25f, 1.25f); - TileNidavellirForge forge = new TileNidavellirForge(); - RenderTileManaContainer.metadata = metadata; - TileEntityRendererDispatcher.instance.renderTileEntityAt((TileEntity)forge, 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } - - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } - - public int getRenderId() { - return BlockListAB.blockABPlateRI; - } - - public boolean shouldRender3DInInventory(int modelId) { - return true; - } -} \ No newline at end of file + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.375F, -0.5F); + GL11.glScalef(1.25f, 1.25f, 1.25f); + TileNidavellirForge forge = new TileNidavellirForge(); + RenderTileManaContainer.metadata = metadata; + TileEntityRendererDispatcher.instance.renderTileEntityAt((TileEntity) forge, 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } + + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + return false; + } + + public int getRenderId() { + return BlockListAB.blockABPlateRI; + } + + public boolean shouldRender3DInInventory(int modelId) { + return true; + } +} diff --git a/src/main/java/ab/client/render/entity/EntityNullRender.java b/src/main/java/ab/client/render/entity/EntityNullRender.java index 06ab517..7fed810 100644 --- a/src/main/java/ab/client/render/entity/EntityNullRender.java +++ b/src/main/java/ab/client/render/entity/EntityNullRender.java @@ -6,10 +6,10 @@ import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; public class EntityNullRender extends Render { - - public void doRender(Entity entity, double d, double d1, double d2, float f, float f1) {} - - protected ResourceLocation getEntityTexture(Entity entity) { - return AbstractClientPlayer.locationStevePng; - } + + public void doRender(Entity entity, double d, double d1, double d2, float f, float f1) {} + + protected ResourceLocation getEntityTexture(Entity entity) { + return AbstractClientPlayer.locationStevePng; + } } diff --git a/src/main/java/ab/client/render/entity/RenderEntityAdvancedSpark.java b/src/main/java/ab/client/render/entity/RenderEntityAdvancedSpark.java index 3ad2e99..158bb55 100644 --- a/src/main/java/ab/client/render/entity/RenderEntityAdvancedSpark.java +++ b/src/main/java/ab/client/render/entity/RenderEntityAdvancedSpark.java @@ -1,20 +1,21 @@ package ab.client.render.entity; -import ab.common.entity.EntityAdvancedSpark; -import ab.common.item.ItemAdvancedSpark; -import ab.common.lib.register.ItemListAB; import net.minecraft.util.IIcon; + import vazkii.botania.client.render.entity.RenderSparkBase; import vazkii.botania.common.item.ItemSparkUpgrade; +import ab.common.entity.EntityAdvancedSpark; +import ab.common.item.ItemAdvancedSpark; public class RenderEntityAdvancedSpark extends RenderSparkBase { - - public IIcon getSpinningIcon(EntityAdvancedSpark entity) { - int upgrade = entity.getUpgrade() - 1; - return (upgrade >= 0 && upgrade < ItemSparkUpgrade.worldIcons.length) ? ItemSparkUpgrade.worldIcons[upgrade] : null; - } - - public IIcon getBaseIcon(EntityAdvancedSpark entity) { - return ItemAdvancedSpark.worldIcon; - } + + public IIcon getSpinningIcon(EntityAdvancedSpark entity) { + int upgrade = entity.getUpgrade() - 1; + return (upgrade >= 0 && upgrade < ItemSparkUpgrade.worldIcons.length) ? ItemSparkUpgrade.worldIcons[upgrade] + : null; + } + + public IIcon getBaseIcon(EntityAdvancedSpark entity) { + return ItemAdvancedSpark.worldIcon; + } } diff --git a/src/main/java/ab/client/render/entity/RenderEntityAlphirinePortal.java b/src/main/java/ab/client/render/entity/RenderEntityAlphirinePortal.java index 6e5269c..2a81fd9 100644 --- a/src/main/java/ab/client/render/entity/RenderEntityAlphirinePortal.java +++ b/src/main/java/ab/client/render/entity/RenderEntityAlphirinePortal.java @@ -1,58 +1,46 @@ package ab.client.render.entity; -import java.awt.Color; import java.util.Random; -import org.lwjgl.opengl.GL11; - -import ab.client.core.ClientHelper; -import ab.common.block.BlockLebethronWood; -import ab.common.lib.register.BlockListAB; -import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; -import net.minecraftforge.client.ForgeHooksClient; -import net.minecraftforge.client.IItemRenderer.ItemRendererHelper; + +import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; +import ab.client.core.ClientHelper; +import ab.common.block.BlockLebethronWood; public class RenderEntityAlphirinePortal extends Render { - public void doRender(Entity entity, double x, double y, double z, float fl, float fl1) { - double worldTime = (entity.worldObj == null) ? 0.0D : (ClientTickHandler.ticksInGame + fl1); - if(entity != null) - worldTime += (new Random(((int)entity.posX ^ (int)entity.posY ^ (int)entity.posZ))).nextInt(360); - Minecraft mc = Minecraft.getMinecraft(); - float burn = Math.min(1.0f, entity.ticksExisted * 0.0561f); - GL11.glPushMatrix(); - GL11.glTranslated(x, y, z); - GL11.glEnable(3042); - GL11.glBlendFunc(770, 771); - burn = Math.max(0.0f, (float)(burn + (Math.sin(worldTime / 3.2f) / 9.0f))); - GL11.glScalef(burn / 3.15f, burn / 3.15f, burn / 3.15f); - GL11.glRotatef(180.0f - this.renderManager.playerViewY, 0.0f, 1.0f, 0.0f); - GL11.glRotatef(-this.renderManager.playerViewX, 1.0f, 0.0f, 0.0f); - GL11.glDisable(GL11.GL_CULL_FACE); - mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); - ClientHelper.setLightmapTextureCoords(); - ClientHelper.renderIcon(BlockLebethronWood.iconPortal, 220); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glDisable(3042); - GL11.glPopMatrix(); - } + public void doRender(Entity entity, double x, double y, double z, float fl, float fl1) { + double worldTime = (entity.worldObj == null) ? 0.0D : (ClientTickHandler.ticksInGame + fl1); + if (entity != null) + worldTime += (new Random(((int) entity.posX ^ (int) entity.posY ^ (int) entity.posZ))).nextInt(360); + Minecraft mc = Minecraft.getMinecraft(); + float burn = Math.min(1.0f, entity.ticksExisted * 0.0561f); + GL11.glPushMatrix(); + GL11.glTranslated(x, y, z); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + burn = Math.max(0.0f, (float) (burn + (Math.sin(worldTime / 3.2f) / 9.0f))); + GL11.glScalef(burn / 3.15f, burn / 3.15f, burn / 3.15f); + GL11.glRotatef(180.0f - this.renderManager.playerViewY, 0.0f, 1.0f, 0.0f); + GL11.glRotatef(-this.renderManager.playerViewX, 1.0f, 0.0f, 0.0f); + GL11.glDisable(GL11.GL_CULL_FACE); + mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + ClientHelper.setLightmapTextureCoords(); + ClientHelper.renderIcon(BlockLebethronWood.iconPortal, 220); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDisable(3042); + GL11.glPopMatrix(); + } - protected ResourceLocation getEntityTexture(Entity entity) { - return AbstractClientPlayer.locationStevePng; - } + protected ResourceLocation getEntityTexture(Entity entity) { + return AbstractClientPlayer.locationStevePng; + } } diff --git a/src/main/java/ab/client/render/item/RenderItemAntigravityCharm.java b/src/main/java/ab/client/render/item/RenderItemAntigravityCharm.java index 10f0921..e22ff67 100644 --- a/src/main/java/ab/client/render/item/RenderItemAntigravityCharm.java +++ b/src/main/java/ab/client/render/item/RenderItemAntigravityCharm.java @@ -1,58 +1,75 @@ package ab.client.render.item; -import org.lwjgl.opengl.GL11; - -import ab.common.item.ItemAntigravityCharm; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.OpenGlHelper; 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.core.helper.ItemNBTHelper; +import ab.common.item.ItemAntigravityCharm; public class RenderItemAntigravityCharm implements IItemRenderer { - - public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) { - return true; - } - - public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) { - return (helper == IItemRenderer.ItemRendererHelper.ENTITY_ROTATION || helper == IItemRenderer.ItemRendererHelper.ENTITY_BOBBING); - } - - public void renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) { - int dmg = item.getItemDamage(); - IIcon icon = ItemAntigravityCharm.icons[0]; - IIcon iconIsland = ItemAntigravityCharm.icons[1]; - GL11.glPushMatrix(); - if(type == type.INVENTORY) { - GL11.glScalef(16, 16, 16); - GL11.glRotatef(180, 0, 0, 1); - GL11.glTranslatef(-1.0f, -1.0f, 0); - } else if(type == type.ENTITY) { - GL11.glTranslatef(-0.5F, 0.0F, 0.0F); - if (item.isOnItemFrame()) - GL11.glTranslatef(0.0F, -0.3F, 0.01F); - } - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F); - double time = (double) Minecraft.getSystemTime(); - if(type != type.INVENTORY) { - GL11.glScalef(1.0f, 1.0f, 1.05f); - GL11.glTranslated(0.0f, 0.0f, 0.0015625f); - } - if(ItemNBTHelper.getBoolean(item, "isActive", true)) { - GL11.glTranslated(0, Math.cos(time / 650.0) * 0.0075 -0.05f, 0.0f); - } else { - GL11.glTranslated(0.0f, -0.125f, 0.0f); - } - ItemRenderer.renderItemIn2D(Tessellator.instance, iconIsland.getMaxU(), iconIsland.getMinV(), iconIsland.getMinU(), iconIsland.getMaxV(), iconIsland.getIconWidth(), iconIsland.getIconHeight(), 0.0625F); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } + + public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) { + return true; + } + + public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType type, ItemStack item, + IItemRenderer.ItemRendererHelper helper) { + return (helper == IItemRenderer.ItemRendererHelper.ENTITY_ROTATION + || helper == IItemRenderer.ItemRendererHelper.ENTITY_BOBBING); + } + + public void renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) { + int dmg = item.getItemDamage(); + IIcon icon = ItemAntigravityCharm.icons[0]; + IIcon iconIsland = ItemAntigravityCharm.icons[1]; + GL11.glPushMatrix(); + if (type == type.INVENTORY) { + GL11.glScalef(16, 16, 16); + GL11.glRotatef(180, 0, 0, 1); + GL11.glTranslatef(-1.0f, -1.0f, 0); + } else if (type == type.ENTITY) { + GL11.glTranslatef(-0.5F, 0.0F, 0.0F); + if (item.isOnItemFrame()) GL11.glTranslatef(0.0F, -0.3F, 0.01F); + } + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + ItemRenderer.renderItemIn2D( + Tessellator.instance, + icon.getMaxU(), + icon.getMinV(), + icon.getMinU(), + icon.getMaxV(), + icon.getIconWidth(), + icon.getIconHeight(), + 0.0625F); + double time = (double) Minecraft.getSystemTime(); + if (type != type.INVENTORY) { + GL11.glScalef(1.0f, 1.0f, 1.05f); + GL11.glTranslated(0.0f, 0.0f, 0.0015625f); + } + if (ItemNBTHelper.getBoolean(item, "isActive", true)) { + GL11.glTranslated(0, Math.cos(time / 650.0) * 0.0075 - 0.05f, 0.0f); + } else { + GL11.glTranslated(0.0f, -0.125f, 0.0f); + } + ItemRenderer.renderItemIn2D( + Tessellator.instance, + iconIsland.getMaxU(), + iconIsland.getMinV(), + iconIsland.getMinU(), + iconIsland.getMaxV(), + iconIsland.getIconWidth(), + iconIsland.getIconHeight(), + 0.0625F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/ab/client/render/item/RenderItemSphereNavigation.java b/src/main/java/ab/client/render/item/RenderItemSphereNavigation.java index 5e33c77..1febe26 100644 --- a/src/main/java/ab/client/render/item/RenderItemSphereNavigation.java +++ b/src/main/java/ab/client/render/item/RenderItemSphereNavigation.java @@ -1,8 +1,5 @@ package ab.client.render.item; -import org.lwjgl.opengl.GL11; - -import ab.common.item.relic.ItemSphereNavigation; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.OpenGlHelper; @@ -10,47 +7,75 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraftforge.client.IItemRenderer; -import vazkii.botania.common.core.helper.ItemNBTHelper; + +import org.lwjgl.opengl.GL11; + +import ab.common.item.relic.ItemSphereNavigation; public class RenderItemSphereNavigation implements IItemRenderer { - public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) { - return true; - } - - public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) { - return (helper == IItemRenderer.ItemRendererHelper.ENTITY_ROTATION || helper == IItemRenderer.ItemRendererHelper.ENTITY_BOBBING); - } - - public void renderItem(IItemRenderer.ItemRenderType type, ItemStack stack, Object... data) { - GL11.glPushMatrix(); - if(type == type.INVENTORY) { - GL11.glScalef(16, 16, 16); - GL11.glRotatef(180, 0, 0, 1); - GL11.glTranslatef(-1.0f, -1.0f, 0); - } else if(type == type.ENTITY) { - GL11.glTranslatef(-0.5F, 0.0F, 0.0F); - if(stack.isOnItemFrame()) - GL11.glTranslatef(0.0F, -0.3F, 0.01F); - } - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - IIcon icon = ItemSphereNavigation.icons[0]; - ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F); - IIcon iconEnable = ItemSphereNavigation.icons[stack.getItemDamage() == 0 ? 4 : 3]; - ItemRenderer.renderItemIn2D(Tessellator.instance, iconEnable.getMaxU(), iconEnable.getMinV(), iconEnable.getMinU(), iconEnable.getMaxV(), iconEnable.getIconWidth(), iconEnable.getIconHeight(), 0.0625F); - double time = (double) Minecraft.getSystemTime(); - if(type != type.INVENTORY) { - GL11.glScalef(1.0f, 1.0f, 1.05f); - GL11.glTranslated(0.0f, 0.0f, 0.0015625f); - } - IIcon iconBlock = ItemSphereNavigation.icons[ItemSphereNavigation.getFindBlock(stack) != null ? 1 : 2]; - if(ItemSphereNavigation.getFindBlock(stack) != null) { - GL11.glTranslated(0, Math.cos(time / 650.0) * 0.0075 - 0.015f, 0.0f); - } - ItemRenderer.renderItemIn2D(Tessellator.instance, iconBlock.getMaxU(), iconBlock.getMinV(), iconBlock.getMinU(), iconBlock.getMaxV(), iconBlock.getIconWidth(), iconBlock.getIconHeight(), 0.0625F); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } + public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) { + return true; + } + + public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType type, ItemStack item, + IItemRenderer.ItemRendererHelper helper) { + return (helper == IItemRenderer.ItemRendererHelper.ENTITY_ROTATION + || helper == IItemRenderer.ItemRendererHelper.ENTITY_BOBBING); + } + + public void renderItem(IItemRenderer.ItemRenderType type, ItemStack stack, Object... data) { + GL11.glPushMatrix(); + if (type == type.INVENTORY) { + GL11.glScalef(16, 16, 16); + GL11.glRotatef(180, 0, 0, 1); + GL11.glTranslatef(-1.0f, -1.0f, 0); + } else if (type == type.ENTITY) { + GL11.glTranslatef(-0.5F, 0.0F, 0.0F); + if (stack.isOnItemFrame()) GL11.glTranslatef(0.0F, -0.3F, 0.01F); + } + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + IIcon icon = ItemSphereNavigation.icons[0]; + ItemRenderer.renderItemIn2D( + Tessellator.instance, + icon.getMaxU(), + icon.getMinV(), + icon.getMinU(), + icon.getMaxV(), + icon.getIconWidth(), + icon.getIconHeight(), + 0.0625F); + IIcon iconEnable = ItemSphereNavigation.icons[stack.getItemDamage() == 0 ? 4 : 3]; + ItemRenderer.renderItemIn2D( + Tessellator.instance, + iconEnable.getMaxU(), + iconEnable.getMinV(), + iconEnable.getMinU(), + iconEnable.getMaxV(), + iconEnable.getIconWidth(), + iconEnable.getIconHeight(), + 0.0625F); + double time = (double) Minecraft.getSystemTime(); + if (type != type.INVENTORY) { + GL11.glScalef(1.0f, 1.0f, 1.05f); + GL11.glTranslated(0.0f, 0.0f, 0.0015625f); + } + IIcon iconBlock = ItemSphereNavigation.icons[ItemSphereNavigation.getFindBlock(stack) != null ? 1 : 2]; + if (ItemSphereNavigation.getFindBlock(stack) != null) { + GL11.glTranslated(0, Math.cos(time / 650.0) * 0.0075 - 0.015f, 0.0f); + } + ItemRenderer.renderItemIn2D( + Tessellator.instance, + iconBlock.getMaxU(), + iconBlock.getMinV(), + iconBlock.getMinU(), + iconBlock.getMaxV(), + iconBlock.getIconWidth(), + iconBlock.getIconHeight(), + 0.0625F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/ab/client/render/tile/RenderTileABSpreader.java b/src/main/java/ab/client/render/tile/RenderTileABSpreader.java index 3818c34..ec35ba6 100644 --- a/src/main/java/ab/client/render/tile/RenderTileABSpreader.java +++ b/src/main/java/ab/client/render/tile/RenderTileABSpreader.java @@ -1,8 +1,5 @@ package ab.client.render.tile; -import org.lwjgl.opengl.GL11; - -import ab.common.block.tile.TileABSpreader; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderBlocks; @@ -12,20 +9,26 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + import vazkii.botania.api.mana.ILens; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.proxy.ClientProxy; import vazkii.botania.client.model.ModelSpreader; import vazkii.botania.client.render.item.RenderLens; +import ab.common.block.tile.TileABSpreader; public class RenderTileABSpreader extends TileEntitySpecialRenderer { - - private static final ResourceLocation texture_0 = new ResourceLocation("ab:textures/model/lebethronSpreader.png"); - private static final ResourceLocation texture_1 = new ResourceLocation("ab:textures/model/lebethronSpreader_halloween.png"); + + private static final ResourceLocation texture_0 = new ResourceLocation("ab:textures/model/lebethronSpreader.png"); + private static final ResourceLocation texture_1 = new ResourceLocation( + "ab:textures/model/lebethronSpreader_halloween.png"); private static final ModelSpreader model = new ModelSpreader(); - public void renderTileEntityAt(final TileEntity tileentity, final double x, final double y, final double z, final float ticks) { - TileABSpreader spreader = (TileABSpreader)tileentity; + public void renderTileEntityAt(final TileEntity tileentity, final double x, final double y, final double z, + final float ticks) { + TileABSpreader spreader = (TileABSpreader) tileentity; GL11.glPushMatrix(); GL11.glEnable(32826); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); @@ -35,26 +38,24 @@ public class RenderTileABSpreader extends TileEntitySpecialRenderer { GL11.glTranslatef(0.0f, -1.0f, 0.0f); GL11.glRotatef(spreader.rotationY, 1.0f, 0.0f, 0.0f); GL11.glTranslatef(0.0f, 1.0f, 0.0f); - if (!ClientProxy.dootDoot) - Minecraft.getMinecraft().renderEngine.bindTexture(texture_0); - else - Minecraft.getMinecraft().renderEngine.bindTexture(texture_1); + if (!ClientProxy.dootDoot) Minecraft.getMinecraft().renderEngine.bindTexture(texture_0); + else Minecraft.getMinecraft().renderEngine.bindTexture(texture_1); GL11.glScalef(1.0f, -1.0f, -1.0f); - double time = ClientTickHandler.ticksInGame + ticks; - + double time = ClientTickHandler.ticksInGame + ticks; + model.render(); GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glPushMatrix(); final double worldTicks = (tileentity.getWorldObj() == null) ? 0.0 : time; - GL11.glRotatef((float)worldTicks % 360.0f, 0.0f, 1.0f, 0.0f); - GL11.glTranslatef(0.0f, (float)Math.sin(worldTicks / 20.0) * 0.05f, 0.0f); + GL11.glRotatef((float) worldTicks % 360.0f, 0.0f, 1.0f, 0.0f); + GL11.glTranslatef(0.0f, (float) Math.sin(worldTicks / 20.0) * 0.05f, 0.0f); model.renderCube(); GL11.glPopMatrix(); GL11.glScalef(1.0f, -1.0f, -1.0f); final ItemStack stack = spreader.getStackInSlot(0); if (stack != null) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - final ILens lens = (ILens)stack.getItem(); + final ILens lens = (ILens) stack.getItem(); GL11.glPushMatrix(); GL11.glTranslatef(-0.4f, -1.4f, -0.4375f); GL11.glScalef(0.8f, 0.8f, 0.8f); @@ -86,5 +87,5 @@ public class RenderTileABSpreader extends TileEntitySpecialRenderer { } GL11.glEnable(32826); GL11.glPopMatrix(); - } + } } diff --git a/src/main/java/ab/client/render/tile/RenderTileBoardFate.java b/src/main/java/ab/client/render/tile/RenderTileBoardFate.java index 7f236c8..4d2f2f4 100644 --- a/src/main/java/ab/client/render/tile/RenderTileBoardFate.java +++ b/src/main/java/ab/client/render/tile/RenderTileBoardFate.java @@ -2,76 +2,76 @@ package ab.client.render.tile; import java.util.Random; -import org.lwjgl.opengl.GL11; - -import ab.client.model.ModelDiceFate; -import ab.common.block.tile.TileBoardFate; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.RenderManager; 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.handler.ClientTickHandler; +import ab.client.model.ModelDiceFate; +import ab.common.block.tile.TileBoardFate; public class RenderTileBoardFate extends TileEntitySpecialRenderer { - - private static final ModelDiceFate model = new ModelDiceFate(); - private static final ResourceLocation texture = new ResourceLocation("ab:textures/model/diceFate.png"); - public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float ticks) { - double time = (tile.getWorldObj() == null) ? 0.0D : (ClientTickHandler.ticksInGame + ticks); - if(tile != null) - time += (new Random((tile.xCoord ^ tile.yCoord ^ tile.zCoord))).nextInt(360); - TileBoardFate board = (TileBoardFate)tile; - GL11.glEnable(3042); - GL11.glEnable(32826); - GL11.glBlendFunc(770, 771); - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5f, y, z + 0.5f); - GL11.glRotatef(90.0f - RenderManager.instance.playerViewY, 0.0f, 1.0f, 0.0f); - for(int i = 0; i < board.getSizeInventory(); i++) { - if(board.getStackInSlot(i) == null) - continue; - time += i * 83.256f; - GL11.glPushMatrix(); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - float dropAnim = (1.0f - (Math.min(150.0f, (board.clientTick[i] * board.clientTick[i] * 1.42f) + ticks) / 150.0f)); - dropAnim = Math.min(1.0f, Math.max(dropAnim, 0.0f)); - float alpha = (float)Math.cos(dropAnim); - float indet = i == 0 ? 0.16f + (0.08f * dropAnim) : -0.16f - (0.08f * dropAnim); - GL11.glTranslated(indet, 0.02f + Math.sin(time / 12.0D) / 48.0D + (0.28f * dropAnim), indet); - GL11.glScalef(0.25f, 0.25f, 0.25f); - GL11.glColor4f(1.0F, 1.0F, 1.0F, alpha); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - float dropAngel = 70.0f * dropAnim; - switch(board.slotChance[i]) { - case 1: - model.render(180.0f + dropAngel, 0.0f + dropAngel, 0.0f); - break; - case 2: - model.render(0.0f + dropAngel, 0.0f + dropAngel, 0.0f); - break; - case 3: - model.render(90.0f + dropAngel, 0.0f + dropAngel, 0.0f); - break; - case 4: - model.render(270.0f + dropAngel, 0.0f + dropAngel, 0.0f); - break; - case 5: - model.render(0.0f + dropAngel, 0.0f + dropAngel, 270.0f); - break; - case 6: - model.render(0.0f + dropAngel, 0.0f + dropAngel, 90.0f); - break; - default: - model.render(0.0f + dropAngel, 0.0f + dropAngel, 0.0f); - break; - } - GL11.glEnable(32826); - GL11.glPopMatrix(); - } - GL11.glPopMatrix(); - GL11.glEnable(32826); - GL11.glDisable(3042); - } -} \ No newline at end of file + private static final ModelDiceFate model = new ModelDiceFate(); + private static final ResourceLocation texture = new ResourceLocation("ab:textures/model/diceFate.png"); + + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float ticks) { + double time = (tile.getWorldObj() == null) ? 0.0D : (ClientTickHandler.ticksInGame + ticks); + if (tile != null) time += (new Random((tile.xCoord ^ tile.yCoord ^ tile.zCoord))).nextInt(360); + TileBoardFate board = (TileBoardFate) tile; + GL11.glEnable(3042); + GL11.glEnable(32826); + GL11.glBlendFunc(770, 771); + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5f, y, z + 0.5f); + GL11.glRotatef(90.0f - RenderManager.instance.playerViewY, 0.0f, 1.0f, 0.0f); + for (int i = 0; i < board.getSizeInventory(); i++) { + if (board.getStackInSlot(i) == null) continue; + time += i * 83.256f; + GL11.glPushMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + float dropAnim = (1.0f + - (Math.min(150.0f, (board.clientTick[i] * board.clientTick[i] * 1.42f) + ticks) / 150.0f)); + dropAnim = Math.min(1.0f, Math.max(dropAnim, 0.0f)); + float alpha = (float) Math.cos(dropAnim); + float indet = i == 0 ? 0.16f + (0.08f * dropAnim) : -0.16f - (0.08f * dropAnim); + GL11.glTranslated(indet, 0.02f + Math.sin(time / 12.0D) / 48.0D + (0.28f * dropAnim), indet); + GL11.glScalef(0.25f, 0.25f, 0.25f); + GL11.glColor4f(1.0F, 1.0F, 1.0F, alpha); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + float dropAngel = 70.0f * dropAnim; + switch (board.slotChance[i]) { + case 1: + model.render(180.0f + dropAngel, 0.0f + dropAngel, 0.0f); + break; + case 2: + model.render(0.0f + dropAngel, 0.0f + dropAngel, 0.0f); + break; + case 3: + model.render(90.0f + dropAngel, 0.0f + dropAngel, 0.0f); + break; + case 4: + model.render(270.0f + dropAngel, 0.0f + dropAngel, 0.0f); + break; + case 5: + model.render(0.0f + dropAngel, 0.0f + dropAngel, 270.0f); + break; + case 6: + model.render(0.0f + dropAngel, 0.0f + dropAngel, 90.0f); + break; + default: + model.render(0.0f + dropAngel, 0.0f + dropAngel, 0.0f); + break; + } + GL11.glEnable(32826); + GL11.glPopMatrix(); + } + GL11.glPopMatrix(); + GL11.glEnable(32826); + GL11.glDisable(3042); + } +} diff --git a/src/main/java/ab/client/render/tile/RenderTileEngineerHopper.java b/src/main/java/ab/client/render/tile/RenderTileEngineerHopper.java index e635505..d8202ec 100644 --- a/src/main/java/ab/client/render/tile/RenderTileEngineerHopper.java +++ b/src/main/java/ab/client/render/tile/RenderTileEngineerHopper.java @@ -2,34 +2,34 @@ package ab.client.render.tile; import java.util.Random; -import org.lwjgl.opengl.GL11; - -import ab.client.model.ModelEngineerHopper; 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 vazkii.botania.client.core.handler.ClientTickHandler; +import ab.client.model.ModelEngineerHopper; public class RenderTileEngineerHopper extends TileEntitySpecialRenderer { - - private static final ModelEngineerHopper model = new ModelEngineerHopper(); - private static final ResourceLocation texture = new ResourceLocation("ab:textures/model/engineerHopper.png"); - public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float ticks) { - double time = (tile.getWorldObj() == null) ? 0.0D : (ClientTickHandler.ticksInGame + ticks); - if(tile != null) - time += (new Random((tile.xCoord ^ tile.yCoord ^ tile.zCoord))).nextInt(360); - GL11.glPushMatrix(); - GL11.glEnable(32826); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glTranslated(x, y, z); - GL11.glTranslatef(0.5f, 1.0625f, 0.5f); - GL11.glRotatef(180, 1.0f, 0.0f, 1.0f); - GL11.glScalef(0.7f, 0.7f, 0.7f); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - model.renderHoper(time); - GL11.glEnable(32826); - GL11.glPopMatrix(); - } + private static final ModelEngineerHopper model = new ModelEngineerHopper(); + private static final ResourceLocation texture = new ResourceLocation("ab:textures/model/engineerHopper.png"); + + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float ticks) { + double time = (tile.getWorldObj() == null) ? 0.0D : (ClientTickHandler.ticksInGame + ticks); + if (tile != null) time += (new Random((tile.xCoord ^ tile.yCoord ^ tile.zCoord))).nextInt(360); + GL11.glPushMatrix(); + GL11.glEnable(32826); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glTranslated(x, y, z); + GL11.glTranslatef(0.5f, 1.0625f, 0.5f); + GL11.glRotatef(180, 1.0f, 0.0f, 1.0f); + GL11.glScalef(0.7f, 0.7f, 0.7f); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + model.renderHoper(time); + GL11.glEnable(32826); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/ab/client/render/tile/RenderTileGameBoard.java b/src/main/java/ab/client/render/tile/RenderTileGameBoard.java index f769d94..22b2a35 100644 --- a/src/main/java/ab/client/render/tile/RenderTileGameBoard.java +++ b/src/main/java/ab/client/render/tile/RenderTileGameBoard.java @@ -2,95 +2,95 @@ package ab.client.render.tile; import java.util.Random; -import org.lwjgl.opengl.GL11; - -import ab.client.model.ModelDiceFate; -import ab.common.block.tile.TileGameBoard; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.RenderManager; 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.handler.ClientTickHandler; +import ab.client.model.ModelDiceFate; +import ab.common.block.tile.TileGameBoard; public class RenderTileGameBoard extends TileEntitySpecialRenderer { - - private static final ModelDiceFate model = new ModelDiceFate(); - private static final ResourceLocation texture = new ResourceLocation("ab:textures/model/gameDice.png"); - private static final ResourceLocation textureEnemy = new ResourceLocation("ab:textures/model/gameDice_enemy.png"); - - public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float ticks) { - double time = (tile.getWorldObj() == null) ? 0.0D : (ClientTickHandler.ticksInGame + ticks); - if(tile != null) - time += (new Random((tile.xCoord ^ tile.yCoord ^ tile.zCoord))).nextInt(360); - TileGameBoard board = (TileGameBoard)tile; - GL11.glEnable(3042); - GL11.glEnable(32826); - GL11.glBlendFunc(770, 771); - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5f, y, z + 0.5f); - GL11.glRotatef(90.0f - RenderManager.instance.playerViewY, 0.0f, 1.0f, 0.0f); - for(int i = 0; i < board.slotChance.length; i++) { - if(board.slotChance[i] == 0) - continue; - time += i * 83.256f; - GL11.glPushMatrix(); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - float posX = 0.0f; - float posZ = 0.0f; - float dropAnim = (1.0f - (Math.min(150.0f, (board.clientTick[i] * board.clientTick[i] * 1.42f) + ticks) / 150.0f)); - dropAnim = Math.min(1.0f, Math.max(dropAnim, 0.0f)); - float alpha = (float)Math.cos(dropAnim); - GL11.glColor4f(1.0F, 1.0F, 1.0F, alpha); - switch(i) { - case 0: - posX = 0.16f + 0.08f * dropAnim; - posZ = 0.16f + 0.08f * dropAnim; - break; - case 1: - posX = -0.16f - 0.08f * dropAnim; - posZ = 0.16f + 0.08f * dropAnim; - break; - case 2: - posX = 0.16f + 0.08f * dropAnim; - posZ = -0.16f - 0.08f * dropAnim; - break; - case 3: - posX = -0.16f - 0.08f * dropAnim; - posZ = -0.16f - 0.08f * dropAnim; - break; - } - GL11.glTranslated(posX, 0.02f + Math.sin(time / 12.0D) / 48.0D + (0.28f * dropAnim), posZ); - GL11.glScalef(0.25f, 0.25f, 0.25f); - Minecraft.getMinecraft().renderEngine.bindTexture(i > 1 ? textureEnemy : texture); - float dropAngel = 70.0f * dropAnim; - switch(board.slotChance[i]) { - case 1: - model.render(180.0f + dropAngel, 0.0f + dropAngel, 0.0f); - break; - case 2: - model.render(0.0f + dropAngel, 0.0f + dropAngel, 0.0f); - break; - case 3: - model.render(90.0f + dropAngel, 0.0f + dropAngel, 0.0f); - break; - case 4: - model.render(270.0f + dropAngel, 0.0f + dropAngel, 0.0f); - break; - case 5: - model.render(0.0f + dropAngel, 0.0f + dropAngel, 270.0f); - break; - case 6: - model.render(0.0f + dropAngel, 0.0f + dropAngel, 90.0f); - break; - default: - model.render(0.0f + dropAngel, 0.0f + dropAngel, 0.0f); - break; - } - GL11.glPopMatrix(); - } - GL11.glPopMatrix(); - GL11.glEnable(32826); - GL11.glDisable(3042); - } + + private static final ModelDiceFate model = new ModelDiceFate(); + private static final ResourceLocation texture = new ResourceLocation("ab:textures/model/gameDice.png"); + private static final ResourceLocation textureEnemy = new ResourceLocation("ab:textures/model/gameDice_enemy.png"); + + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float ticks) { + double time = (tile.getWorldObj() == null) ? 0.0D : (ClientTickHandler.ticksInGame + ticks); + if (tile != null) time += (new Random((tile.xCoord ^ tile.yCoord ^ tile.zCoord))).nextInt(360); + TileGameBoard board = (TileGameBoard) tile; + GL11.glEnable(3042); + GL11.glEnable(32826); + GL11.glBlendFunc(770, 771); + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5f, y, z + 0.5f); + GL11.glRotatef(90.0f - RenderManager.instance.playerViewY, 0.0f, 1.0f, 0.0f); + for (int i = 0; i < board.slotChance.length; i++) { + if (board.slotChance[i] == 0) continue; + time += i * 83.256f; + GL11.glPushMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + float posX = 0.0f; + float posZ = 0.0f; + float dropAnim = (1.0f + - (Math.min(150.0f, (board.clientTick[i] * board.clientTick[i] * 1.42f) + ticks) / 150.0f)); + dropAnim = Math.min(1.0f, Math.max(dropAnim, 0.0f)); + float alpha = (float) Math.cos(dropAnim); + GL11.glColor4f(1.0F, 1.0F, 1.0F, alpha); + switch (i) { + case 0: + posX = 0.16f + 0.08f * dropAnim; + posZ = 0.16f + 0.08f * dropAnim; + break; + case 1: + posX = -0.16f - 0.08f * dropAnim; + posZ = 0.16f + 0.08f * dropAnim; + break; + case 2: + posX = 0.16f + 0.08f * dropAnim; + posZ = -0.16f - 0.08f * dropAnim; + break; + case 3: + posX = -0.16f - 0.08f * dropAnim; + posZ = -0.16f - 0.08f * dropAnim; + break; + } + GL11.glTranslated(posX, 0.02f + Math.sin(time / 12.0D) / 48.0D + (0.28f * dropAnim), posZ); + GL11.glScalef(0.25f, 0.25f, 0.25f); + Minecraft.getMinecraft().renderEngine.bindTexture(i > 1 ? textureEnemy : texture); + float dropAngel = 70.0f * dropAnim; + switch (board.slotChance[i]) { + case 1: + model.render(180.0f + dropAngel, 0.0f + dropAngel, 0.0f); + break; + case 2: + model.render(0.0f + dropAngel, 0.0f + dropAngel, 0.0f); + break; + case 3: + model.render(90.0f + dropAngel, 0.0f + dropAngel, 0.0f); + break; + case 4: + model.render(270.0f + dropAngel, 0.0f + dropAngel, 0.0f); + break; + case 5: + model.render(0.0f + dropAngel, 0.0f + dropAngel, 270.0f); + break; + case 6: + model.render(0.0f + dropAngel, 0.0f + dropAngel, 90.0f); + break; + default: + model.render(0.0f + dropAngel, 0.0f + dropAngel, 0.0f); + break; + } + GL11.glPopMatrix(); + } + GL11.glPopMatrix(); + GL11.glEnable(32826); + GL11.glDisable(3042); + } } diff --git a/src/main/java/ab/client/render/tile/RenderTileMagicCraftingCrate.java b/src/main/java/ab/client/render/tile/RenderTileMagicCraftingCrate.java index a073680..4c8636a 100644 --- a/src/main/java/ab/client/render/tile/RenderTileMagicCraftingCrate.java +++ b/src/main/java/ab/client/render/tile/RenderTileMagicCraftingCrate.java @@ -2,11 +2,6 @@ package ab.client.render.tile; import java.util.Random; -import org.lwjgl.opengl.GL11; - -import ab.common.block.BlockMagicCraftCrate; -import ab.common.block.tile.TileMagicCraftCrate; -import ab.common.lib.register.BlockListAB; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; @@ -20,115 +15,119 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; +import ab.common.block.BlockMagicCraftCrate; +import ab.common.block.tile.TileMagicCraftCrate; +import ab.common.lib.register.BlockListAB; public class RenderTileMagicCraftingCrate extends TileEntitySpecialRenderer { - - private ModelCrateBook model = new ModelCrateBook(); - public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float fq) { - double time = (tile.getWorldObj() == null) ? 0.0D : (ClientTickHandler.ticksInGame + fq); - if(tile != null) - time += (new Random((tile.xCoord ^ tile.yCoord ^ tile.zCoord))).nextInt(360); - float f1 = 0.002f; - float f2 = 0.125f; - float f3 = 0.1875f; - float f4 = 0.25f; - TileMagicCraftCrate crate = (TileMagicCraftCrate) tile; - boolean[][] pattern = crate.getPattern(); - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - Tessellator t = new Tessellator(); - t.startDrawingQuads(); - t.setColorRGBA_I(0xfc0195, 50); - IIcon icon = ((BlockMagicCraftCrate)BlockListAB.blockMagicCraftCrate).nothing; - float maxU = icon.getMaxU(); - float maxV = icon.getMaxV(); - float minU = icon.getMinU(); - float minV = icon.getMinV(); - boolean hasPattern = false; - for(int i = 0; i < 3; i++) - for(int j = 0; j < 3; j++) { - if(!pattern[i][j]) { - int i1 = 2 - i; - int j1 = 2 - j; - hasPattern = true; - t.addVertexWithUV(x + f4 + f3 * j1 + f2, y + 1 + f1, z + f4 + f3 * i1+ f2, maxU, maxV); - t.addVertexWithUV(x + f4 + f3 * j1 + f2, y + 1 + f1, z + f4 + f3 * i1, maxU, minV); - t.addVertexWithUV(x + f4 + f3 * j1, y + 1 + f1, z + f4 + f3 * i1, minU, minV); - t.addVertexWithUV(x + f4 + f3 * j1, y + 1 + f1, z + f4 + f3 * i1+ f2, minU, maxV); - float f0 = f2; - if(i == 0 && j == 1) - f0 = 0.0625f; - float minY = (float) (y + f4 + f3 * i1); - float maxY = minY + f0; - t.addVertexWithUV(x + f4 + f3 * j1, minY, z - f1, maxU, maxV); - t.addVertexWithUV(x + f4 + f3 * j1, maxY, z - f1, maxU, minV); - t.addVertexWithUV(x + f4 + f3 * j1 + f2, maxY, z - f1, minU, minV); - t.addVertexWithUV(x + f4 + f3 * j1 + f2, minY, z - f1, minU, maxV); - t.addVertexWithUV(x + 1 + f1, minY, z + f4 + f3 * j1, maxU, maxV); - t.addVertexWithUV(x + 1 + f1, maxY, z + f4 + f3 * j1, maxU, minV); - t.addVertexWithUV(x + 1 + f1, maxY, z + f4 + f3 * j1 + f2, minU, minV); - t.addVertexWithUV(x + 1 + f1, minY, z + f4 + f3 * j1 + f2, minU, maxV); - j1 = j; - t.addVertexWithUV(x - f1, minY, z + f4 + f3 * j1 + f2, maxU, maxV); - t.addVertexWithUV(x - f1, maxY, z + f4 + f3 * j1 + f2, maxU, minV); - t.addVertexWithUV(x - f1, maxY, z + f4 + f3 * j1, minU, minV); - t.addVertexWithUV(x - f1, minY, z + f4 + f3 * j1, minU, maxV); - t.addVertexWithUV(x + f4 + f3 * j1 + f2, minY, z + 1 + f1, maxU, maxV); - t.addVertexWithUV(x + f4 + f3 * j1 + f2, maxY, z + 1 + f1, maxU, minV); - t.addVertexWithUV(x + f4 + f3 * j1, maxY, z + 1 + f1, minU, minV); - t.addVertexWithUV(x + f4 + f3 * j1, minY, z + 1 + f1, minU, maxV); - } - } - t.draw(); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - ItemStack wand = crate.getStackInSlot(10); - if(wand != null) { - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5f, y + 1.12f + (Math.sin(time / 24.0D) / 40.0D - 0.05D), z + 0.275f); - GL11.glRotated(Math.sin(time / 24.0D) * 5.0f, 0.0f, 1.0f, 0.0f); - GL11.glRotatef(90.0f, 0.0f, 0.0f, 1.0f); - EntityItem entity = new EntityItem(tile.getWorldObj(), 0, -0.125, 0, wand.copy()); - entity.hoverStart = 0.0f; - RenderItem.renderInFrame = true; - RenderManager.instance.renderEntityWithPosYaw(entity, 0, -0.285, 0, 0.0f, 0.0f); - RenderItem.renderInFrame = false; - GL11.glPopMatrix(); - } - ItemStack book = crate.getStackInSlot(11); - if(book != null) { - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.7f, y + 0.825f + (Math.sin(-time / 24.0D) / 40.0D - 0.05D), z + 0.825f); - GL11.glRotatef(90.0f, 0.0f, 0.0f, 1.0f); - GL11.glRotatef(90.0f, 0.0f, 1.0f, 0.0f); - GL11.glRotated(Math.sin(-time / 24.0D) * 5.0f, 0.0f, 0.0f, 1.0f); - Minecraft.getMinecraft().renderEngine.bindTexture(model.texture); - model.render(); - GL11.glPopMatrix(); - } - } - - public class ModelCrateBook extends ModelBase { - public final ResourceLocation texture = new ResourceLocation("thaumcraft:textures/models/fortress_armor.png"); - private ModelRenderer Book; - - public ModelCrateBook() { - textureWidth = 128; - textureHeight = 64; - Book = new ModelRenderer(this, 100, 8); - Book.addBox(1.0F, -0.3F, 4.0F, 5, 7, 2); - Book.setRotationPoint(0.0F, 0.0F, 0.0F); - Book.setTextureSize(128, 64); - } - - public void render() { - Book.render(0.0625f); - } - } + private ModelCrateBook model = new ModelCrateBook(); + + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float fq) { + double time = (tile.getWorldObj() == null) ? 0.0D : (ClientTickHandler.ticksInGame + fq); + if (tile != null) time += (new Random((tile.xCoord ^ tile.yCoord ^ tile.zCoord))).nextInt(360); + float f1 = 0.002f; + float f2 = 0.125f; + float f3 = 0.1875f; + float f4 = 0.25f; + TileMagicCraftCrate crate = (TileMagicCraftCrate) tile; + boolean[][] pattern = crate.getPattern(); + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + Tessellator t = new Tessellator(); + t.startDrawingQuads(); + t.setColorRGBA_I(0xfc0195, 50); + IIcon icon = ((BlockMagicCraftCrate) BlockListAB.blockMagicCraftCrate).nothing; + float maxU = icon.getMaxU(); + float maxV = icon.getMaxV(); + float minU = icon.getMinU(); + float minV = icon.getMinV(); + boolean hasPattern = false; + for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) { + if (!pattern[i][j]) { + int i1 = 2 - i; + int j1 = 2 - j; + hasPattern = true; + t.addVertexWithUV(x + f4 + f3 * j1 + f2, y + 1 + f1, z + f4 + f3 * i1 + f2, maxU, maxV); + t.addVertexWithUV(x + f4 + f3 * j1 + f2, y + 1 + f1, z + f4 + f3 * i1, maxU, minV); + t.addVertexWithUV(x + f4 + f3 * j1, y + 1 + f1, z + f4 + f3 * i1, minU, minV); + t.addVertexWithUV(x + f4 + f3 * j1, y + 1 + f1, z + f4 + f3 * i1 + f2, minU, maxV); + float f0 = f2; + if (i == 0 && j == 1) f0 = 0.0625f; + float minY = (float) (y + f4 + f3 * i1); + float maxY = minY + f0; + t.addVertexWithUV(x + f4 + f3 * j1, minY, z - f1, maxU, maxV); + t.addVertexWithUV(x + f4 + f3 * j1, maxY, z - f1, maxU, minV); + t.addVertexWithUV(x + f4 + f3 * j1 + f2, maxY, z - f1, minU, minV); + t.addVertexWithUV(x + f4 + f3 * j1 + f2, minY, z - f1, minU, maxV); + t.addVertexWithUV(x + 1 + f1, minY, z + f4 + f3 * j1, maxU, maxV); + t.addVertexWithUV(x + 1 + f1, maxY, z + f4 + f3 * j1, maxU, minV); + t.addVertexWithUV(x + 1 + f1, maxY, z + f4 + f3 * j1 + f2, minU, minV); + t.addVertexWithUV(x + 1 + f1, minY, z + f4 + f3 * j1 + f2, minU, maxV); + j1 = j; + t.addVertexWithUV(x - f1, minY, z + f4 + f3 * j1 + f2, maxU, maxV); + t.addVertexWithUV(x - f1, maxY, z + f4 + f3 * j1 + f2, maxU, minV); + t.addVertexWithUV(x - f1, maxY, z + f4 + f3 * j1, minU, minV); + t.addVertexWithUV(x - f1, minY, z + f4 + f3 * j1, minU, maxV); + t.addVertexWithUV(x + f4 + f3 * j1 + f2, minY, z + 1 + f1, maxU, maxV); + t.addVertexWithUV(x + f4 + f3 * j1 + f2, maxY, z + 1 + f1, maxU, minV); + t.addVertexWithUV(x + f4 + f3 * j1, maxY, z + 1 + f1, minU, minV); + t.addVertexWithUV(x + f4 + f3 * j1, minY, z + 1 + f1, minU, maxV); + } + } + t.draw(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + ItemStack wand = crate.getStackInSlot(10); + if (wand != null) { + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5f, y + 1.12f + (Math.sin(time / 24.0D) / 40.0D - 0.05D), z + 0.275f); + GL11.glRotated(Math.sin(time / 24.0D) * 5.0f, 0.0f, 1.0f, 0.0f); + GL11.glRotatef(90.0f, 0.0f, 0.0f, 1.0f); + EntityItem entity = new EntityItem(tile.getWorldObj(), 0, -0.125, 0, wand.copy()); + entity.hoverStart = 0.0f; + RenderItem.renderInFrame = true; + RenderManager.instance.renderEntityWithPosYaw(entity, 0, -0.285, 0, 0.0f, 0.0f); + RenderItem.renderInFrame = false; + GL11.glPopMatrix(); + } + ItemStack book = crate.getStackInSlot(11); + if (book != null) { + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.7f, y + 0.825f + (Math.sin(-time / 24.0D) / 40.0D - 0.05D), z + 0.825f); + GL11.glRotatef(90.0f, 0.0f, 0.0f, 1.0f); + GL11.glRotatef(90.0f, 0.0f, 1.0f, 0.0f); + GL11.glRotated(Math.sin(-time / 24.0D) * 5.0f, 0.0f, 0.0f, 1.0f); + Minecraft.getMinecraft().renderEngine.bindTexture(model.texture); + model.render(); + GL11.glPopMatrix(); + } + } + + public class ModelCrateBook extends ModelBase { + + public final ResourceLocation texture = new ResourceLocation("thaumcraft:textures/models/fortress_armor.png"); + private ModelRenderer Book; + + public ModelCrateBook() { + textureWidth = 128; + textureHeight = 64; + Book = new ModelRenderer(this, 100, 8); + Book.addBox(1.0F, -0.3F, 4.0F, 5, 7, 2); + Book.setRotationPoint(0.0F, 0.0F, 0.0F); + Book.setTextureSize(128, 64); + } + + public void render() { + Book.render(0.0625f); + } + } } diff --git a/src/main/java/ab/client/render/tile/RenderTileManaCharger.java b/src/main/java/ab/client/render/tile/RenderTileManaCharger.java index 1df9592..c7d08bc 100644 --- a/src/main/java/ab/client/render/tile/RenderTileManaCharger.java +++ b/src/main/java/ab/client/render/tile/RenderTileManaCharger.java @@ -1,14 +1,8 @@ package ab.client.render.tile; import java.awt.Color; -import java.util.ArrayList; -import java.util.List; import java.util.Random; -import org.lwjgl.opengl.GL11; - -import ab.client.model.ModelManaCharger; -import ab.common.block.tile.TileManaCharger; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; @@ -22,68 +16,97 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.ForgeHooksClient; + +import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; +import ab.client.model.ModelManaCharger; +import ab.common.block.tile.TileManaCharger; public class RenderTileManaCharger extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation("ab:textures/model/manaCharger.png"); - private static final ModelManaCharger model = new ModelManaCharger(); - public TileManaCharger charger; - - public void renderTileEntityAt(final TileEntity tile, final double x, final double y, final double z, final float ticks) { - this.charger = (TileManaCharger)tile; - double time = (tile.getWorldObj() == null) ? 0.0D : (ClientTickHandler.ticksInGame + ticks); - if (tile != null) - time += (new Random((tile.xCoord ^ tile.yCoord ^ tile.zCoord))).nextInt(360); - GL11.glPushMatrix(); - GL11.glEnable(32826); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glTranslated(x, y, z); - GL11.glTranslatef(0.5f, 1.65f, 0.5f); - GL11.glRotatef(180, 1.0f, 0.0f, 1.0f); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - model.render(this, time); - GL11.glEnable(32826); - GL11.glPopMatrix(); - } - - public void renderItemStack(ItemStack stack) { - if (stack != null) { - Minecraft mc = Minecraft.getMinecraft(); - mc.renderEngine.bindTexture((stack.getItem() instanceof net.minecraft.item.ItemBlock) ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture); - float s = 0.25F; - GL11.glScalef(s, s, s); - GL11.glScalef(2.0F, 2.0F, 2.0F); - if (!ForgeHooksClient.renderEntityItem(new EntityItem(this.charger.getWorldObj(), this.charger.xCoord, this.charger.yCoord, this.charger.zCoord, stack), stack, 0.0F, 0.0F, (this.charger.getWorldObj()).rand, mc.renderEngine, RenderBlocks.getInstance(), 1)) { - GL11.glScalef(0.5F, 0.5F, 0.5F); - if (stack.getItem() instanceof net.minecraft.item.ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(stack.getItem()).getRenderType())) { - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(1.0F, 1.1F, 0.0F); - GL11.glPushMatrix(); - RenderBlocks.getInstance().renderBlockAsItem(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1.0F); - GL11.glPopMatrix(); - GL11.glTranslatef(-1.0F, -1.1F, 0.0F); - GL11.glScalef(2.0F, 2.0F, 2.0F); - } else { - int renderPass = 0; - do { - IIcon icon = stack.getItem().getIcon(stack, renderPass); - if (icon == null) - continue; - 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(), 0.0625F); - GL11.glColor3f(1.0F, 1.0F, 1.0F); - ++renderPass; - } while (renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); - } - } - GL11.glScalef(1.0F / s, 1.0F / s, 1.0F / s); - (Minecraft.getMinecraft()).renderEngine.bindTexture(texture); - } - } + private static final ResourceLocation texture = new ResourceLocation("ab:textures/model/manaCharger.png"); + private static final ModelManaCharger model = new ModelManaCharger(); + public TileManaCharger charger; + + public void renderTileEntityAt(final TileEntity tile, final double x, final double y, final double z, + final float ticks) { + this.charger = (TileManaCharger) tile; + double time = (tile.getWorldObj() == null) ? 0.0D : (ClientTickHandler.ticksInGame + ticks); + if (tile != null) time += (new Random((tile.xCoord ^ tile.yCoord ^ tile.zCoord))).nextInt(360); + GL11.glPushMatrix(); + GL11.glEnable(32826); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glTranslated(x, y, z); + GL11.glTranslatef(0.5f, 1.65f, 0.5f); + GL11.glRotatef(180, 1.0f, 0.0f, 1.0f); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + model.render(this, time); + GL11.glEnable(32826); + GL11.glPopMatrix(); + } + + public void renderItemStack(ItemStack stack) { + if (stack != null) { + Minecraft mc = Minecraft.getMinecraft(); + mc.renderEngine.bindTexture( + (stack.getItem() instanceof net.minecraft.item.ItemBlock) ? TextureMap.locationBlocksTexture + : TextureMap.locationItemsTexture); + float s = 0.25F; + GL11.glScalef(s, s, s); + GL11.glScalef(2.0F, 2.0F, 2.0F); + if (!ForgeHooksClient.renderEntityItem( + new EntityItem( + this.charger.getWorldObj(), + this.charger.xCoord, + this.charger.yCoord, + this.charger.zCoord, + stack), + stack, + 0.0F, + 0.0F, + (this.charger.getWorldObj()).rand, + mc.renderEngine, + RenderBlocks.getInstance(), + 1)) { + GL11.glScalef(0.5F, 0.5F, 0.5F); + if (stack.getItem() instanceof net.minecraft.item.ItemBlock + && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(stack.getItem()).getRenderType())) { + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(1.0F, 1.1F, 0.0F); + GL11.glPushMatrix(); + RenderBlocks.getInstance() + .renderBlockAsItem(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1.0F); + GL11.glPopMatrix(); + GL11.glTranslatef(-1.0F, -1.1F, 0.0F); + GL11.glScalef(2.0F, 2.0F, 2.0F); + } else { + int renderPass = 0; + do { + IIcon icon = stack.getItem().getIcon(stack, renderPass); + if (icon == null) continue; + 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(), + 0.0625F); + GL11.glColor3f(1.0F, 1.0F, 1.0F); + ++renderPass; + } while (renderPass < stack.getItem().getRenderPasses(stack.getItemDamage())); + } + } + GL11.glScalef(1.0F / s, 1.0F / s, 1.0F / s); + (Minecraft.getMinecraft()).renderEngine.bindTexture(texture); + } + } } diff --git a/src/main/java/ab/client/render/tile/RenderTileManaContainer.java b/src/main/java/ab/client/render/tile/RenderTileManaContainer.java index 8376464..34d0803 100644 --- a/src/main/java/ab/client/render/tile/RenderTileManaContainer.java +++ b/src/main/java/ab/client/render/tile/RenderTileManaContainer.java @@ -3,88 +3,86 @@ package ab.client.render.tile; import java.awt.Color; import java.util.Random; -import org.lwjgl.opengl.GL11; - -import ab.client.core.ClientHelper; -import ab.client.model.ModelManaContainer; -import ab.common.block.tile.TileManaContainer; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.entity.passive.EntitySheep; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + +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.BlockPool; +import ab.client.core.ClientHelper; +import ab.client.model.ModelManaContainer; +import ab.common.block.tile.TileManaContainer; public class RenderTileManaContainer extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation("ab:textures/model/mana_container.png"); - private static final ResourceLocation texture1 = new ResourceLocation("ab:textures/model/mana_container1.png"); - private static final ModelManaContainer model = new ModelManaContainer(); - - public static int metadata; - - public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float ticks) { - TileManaContainer container = (TileManaContainer)tileentity; - double worldTime = (tileentity.getWorldObj() == null) ? 0.0D : (ClientTickHandler.ticksInGame + ticks); - if(tileentity != null) - worldTime += (new Random((tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord))).nextInt(360); - boolean dil = (tileentity.getWorldObj() == null) ? ((metadata == 1)) : ((tileentity.getBlockMetadata() == 1)); - boolean fab = (tileentity.getWorldObj() == null) ? ((metadata == 2)) : ((tileentity.getBlockMetadata() == 2)); - GL11.glPushMatrix(); - GL11.glEnable(32826); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glTranslated(x, y, z); - GL11.glTranslatef(0.5f, 1.075f, 0.5f); - GL11.glScalef(0.7f, 0.7f, 0.7f); - GL11.glRotatef((float)worldTime * 0.375F, 0.0F, 1.0F, 0.0F); - GL11.glTranslated(0.0D, Math.sin(worldTime / 80.0D) / 20.0D - 0.025D, 0.0D); - GL11.glRotatef(180, 1.0f, 0.0f, 1.0f); - 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((float)(time * 0.005F), 0.6F, 1.0F); - GL11.glColor4ub((byte)color.getRed(), (byte)color.getGreen(), (byte)color.getBlue(), (byte)-1); - } - Minecraft.getMinecraft().renderEngine.bindTexture(dil ? texture1 : texture); - model.render(); - renderMana(tileentity.getWorldObj(), container); - GL11.glEnable(32826); - GL11.glPopMatrix(); - metadata = 0; - } - - public void renderMana(World world, TileManaContainer container) { - if(world != null) { - (Minecraft.getMinecraft()).renderEngine.bindTexture(TextureMap.locationBlocksTexture); - int mana = container.getCurrentMana(); - int cap = container.getMaxMana(); - float waterLevel = ((float)mana / (float)cap) * 0.8F; - float v = 0.125F; - float w = -v * 3.5F; - if(waterLevel > 0.0F) { - float s = 0.5f; - GL11.glPushMatrix(); - GL11.glEnable(3042); - GL11.glBlendFunc(770, 771); - GL11.glDisable(3008); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0f); - GL11.glScalef(s, s, s); - GL11.glTranslatef(0.0f, 1.71F - waterLevel, -0.25f); - GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); - ShaderHelper.useShader(ShaderHelper.manaPool); - ClientHelper.renderIcon(BlockPool.manaIcon, 240); - ShaderHelper.releaseShader(); - GL11.glEnable(3008); - GL11.glDisable(3042); - GL11.glPopMatrix(); - } - } - } + private static final ResourceLocation texture = new ResourceLocation("ab:textures/model/mana_container.png"); + private static final ResourceLocation texture1 = new ResourceLocation("ab:textures/model/mana_container1.png"); + private static final ModelManaContainer model = new ModelManaContainer(); + + public static int metadata; + + public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float ticks) { + TileManaContainer container = (TileManaContainer) tileentity; + double worldTime = (tileentity.getWorldObj() == null) ? 0.0D : (ClientTickHandler.ticksInGame + ticks); + if (tileentity != null) + worldTime += (new Random((tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord))).nextInt(360); + boolean dil = (tileentity.getWorldObj() == null) ? ((metadata == 1)) : ((tileentity.getBlockMetadata() == 1)); + boolean fab = (tileentity.getWorldObj() == null) ? ((metadata == 2)) : ((tileentity.getBlockMetadata() == 2)); + GL11.glPushMatrix(); + GL11.glEnable(32826); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glTranslated(x, y, z); + GL11.glTranslatef(0.5f, 1.075f, 0.5f); + GL11.glScalef(0.7f, 0.7f, 0.7f); + GL11.glRotatef((float) worldTime * 0.375F, 0.0F, 1.0F, 0.0F); + GL11.glTranslated(0.0D, Math.sin(worldTime / 80.0D) / 20.0D - 0.025D, 0.0D); + GL11.glRotatef(180, 1.0f, 0.0f, 1.0f); + 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((float) (time * 0.005F), 0.6F, 1.0F); + GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) -1); + } + Minecraft.getMinecraft().renderEngine.bindTexture(dil ? texture1 : texture); + model.render(); + renderMana(tileentity.getWorldObj(), container); + GL11.glEnable(32826); + GL11.glPopMatrix(); + metadata = 0; + } + + public void renderMana(World world, TileManaContainer container) { + if (world != null) { + (Minecraft.getMinecraft()).renderEngine.bindTexture(TextureMap.locationBlocksTexture); + int mana = container.getCurrentMana(); + int cap = container.getMaxMana(); + float waterLevel = ((float) mana / (float) cap) * 0.8F; + float v = 0.125F; + float w = -v * 3.5F; + if (waterLevel > 0.0F) { + float s = 0.5f; + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glDisable(3008); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0f); + GL11.glScalef(s, s, s); + GL11.glTranslatef(0.0f, 1.71F - waterLevel, -0.25f); + GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); + ShaderHelper.useShader(ShaderHelper.manaPool); + ClientHelper.renderIcon(BlockPool.manaIcon, 240); + ShaderHelper.releaseShader(); + GL11.glEnable(3008); + GL11.glDisable(3042); + GL11.glPopMatrix(); + } + } + } } diff --git a/src/main/java/ab/client/render/tile/RenderTileManaCrystalCube.java b/src/main/java/ab/client/render/tile/RenderTileManaCrystalCube.java index 90e5ff5..de92525 100644 --- a/src/main/java/ab/client/render/tile/RenderTileManaCrystalCube.java +++ b/src/main/java/ab/client/render/tile/RenderTileManaCrystalCube.java @@ -1,7 +1,5 @@ package ab.client.render.tile; -import org.lwjgl.opengl.GL11; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; @@ -11,49 +9,57 @@ import net.minecraft.entity.item.EntityItem; 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.model.ModelCrystalCube; import vazkii.botania.common.item.ModItems; public class RenderTileManaCrystalCube extends TileEntitySpecialRenderer { - - private static final ResourceLocation texture = new ResourceLocation("ab:textures/model/crystalCube.png"); - private static final ModelCrystalCube model = new ModelCrystalCube(); - private EntityItem entity = null; - - public void renderTileEntityAt(TileEntity tile, double d0, double d1, double d2, float f) { - if(this.entity == null) - this.entity = new EntityItem(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, new ItemStack(ModItems.twigWand)); - this.entity.age = ClientTickHandler.ticksInGame; - double time = (ClientTickHandler.ticksInGame + f); - double worldTicks = (tile.getWorldObj() == null) ? 0.0D : time; - Minecraft mc = Minecraft.getMinecraft(); - GL11.glPushMatrix(); - GL11.glEnable(32826); - GL11.glEnable(3042); - GL11.glBlendFunc(770, 771); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glTranslated(d0, d1, d2); - mc.renderEngine.bindTexture(texture); - GL11.glTranslatef(0.5F, 1.5F, 0.5F); - GL11.glScalef(1.0F, -1.0F, -1.0F); - this.model.renderBase(); - GL11.glTranslatef(0.0F, (float)Math.sin(worldTicks / 20.0D) * 0.05F, 0.0F); - if(tile.getWorldObj() != null) { - GL11.glPushMatrix(); - float s = 0.5F; - GL11.glTranslatef(0.0F, 0.8F, 0.0F); - GL11.glScalef(s, s, s); - GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); - ((Render)RenderManager.instance.entityRenderMap.get(EntityItem.class)).doRender((Entity)this.entity, 0.0D, 0.0D, 0.0D, 1.0F, f); - GL11.glPopMatrix(); - mc.renderEngine.bindTexture(texture); - } - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.4F); - this.model.renderCube(); - GL11.glColor3f(1.0F, 1.0F, 1.0F); - GL11.glScalef(1.0F, -1.0F, -1.0F); - GL11.glEnable(32826); - GL11.glPopMatrix(); - } + + private static final ResourceLocation texture = new ResourceLocation("ab:textures/model/crystalCube.png"); + private static final ModelCrystalCube model = new ModelCrystalCube(); + private EntityItem entity = null; + + public void renderTileEntityAt(TileEntity tile, double d0, double d1, double d2, float f) { + if (this.entity == null) this.entity = new EntityItem( + tile.getWorldObj(), + tile.xCoord, + tile.yCoord, + tile.zCoord, + new ItemStack(ModItems.twigWand)); + this.entity.age = ClientTickHandler.ticksInGame; + double time = (ClientTickHandler.ticksInGame + f); + double worldTicks = (tile.getWorldObj() == null) ? 0.0D : time; + Minecraft mc = Minecraft.getMinecraft(); + GL11.glPushMatrix(); + GL11.glEnable(32826); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glTranslated(d0, d1, d2); + mc.renderEngine.bindTexture(texture); + GL11.glTranslatef(0.5F, 1.5F, 0.5F); + GL11.glScalef(1.0F, -1.0F, -1.0F); + this.model.renderBase(); + GL11.glTranslatef(0.0F, (float) Math.sin(worldTicks / 20.0D) * 0.05F, 0.0F); + if (tile.getWorldObj() != null) { + GL11.glPushMatrix(); + float s = 0.5F; + GL11.glTranslatef(0.0F, 0.8F, 0.0F); + GL11.glScalef(s, s, s); + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + ((Render) RenderManager.instance.entityRenderMap.get(EntityItem.class)) + .doRender((Entity) this.entity, 0.0D, 0.0D, 0.0D, 1.0F, f); + GL11.glPopMatrix(); + mc.renderEngine.bindTexture(texture); + } + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.4F); + this.model.renderCube(); + GL11.glColor3f(1.0F, 1.0F, 1.0F); + GL11.glScalef(1.0F, -1.0F, -1.0F); + GL11.glEnable(32826); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/ab/client/render/tile/RenderTileNidavellirForge.java b/src/main/java/ab/client/render/tile/RenderTileNidavellirForge.java index eca35bb..df8aef3 100644 --- a/src/main/java/ab/client/render/tile/RenderTileNidavellirForge.java +++ b/src/main/java/ab/client/render/tile/RenderTileNidavellirForge.java @@ -4,98 +4,94 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; -import org.lwjgl.opengl.GL11; - -import ab.client.model.ModelNidavellirForge; -import ab.common.block.tile.TileNidavellirForge; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; + +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; +import ab.client.model.ModelNidavellirForge; +import ab.common.block.tile.TileNidavellirForge; public class RenderTileNidavellirForge extends TileEntitySpecialRenderer { - - private List entityList = null; - private static final ResourceLocation texture = new ResourceLocation("ab:textures/model/nidavellirForge.png"); - private static final ModelNidavellirForge model = new ModelNidavellirForge(); - - public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { - TileNidavellirForge tile = (TileNidavellirForge)tileentity; - double worldTime = 0.0D; - int meta = 2; - float invRender = 0.0f; - if(tileentity != null && tileentity.getWorldObj() != null) { - worldTime = ClientTickHandler.ticksInGame + f + (new Random((tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord))).nextInt(360); - meta = tileentity.getWorldObj().getBlockMetadata(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord); - } else - invRender = 0.0875f; - float indetY = (float)(Math.sin(worldTime / 18.0D) / 24.0D); - GL11.glPushMatrix(); - GL11.glEnable(32826); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glTranslated(x - invRender, y, z); - GL11.glTranslatef(0.5f, 1.5f, 0.5f); - GL11.glRotatef(180.0f, 1.0f, 0.0f, 1.0f); - GL11.glRotatef(90.0f * meta, 0.0f, 1.0f, 0.0f); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - model.renderBottom(); - GL11.glTranslatef(0.0f, indetY, 0.0f); - model.renderTop(); - GL11.glEnable(32826); - GL11.glPopMatrix(); - if(entityList == null) { - List list = new ArrayList(); - for(int i = 0; i < tile.getSizeInventory(); i++) { - list.add(new EntityItem(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord)); - } - entityList = list; - } - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5f, y + 0.675f - indetY, z + 0.5f); - GL11.glScalef(0.2F, 0.225F, 0.225F); - for(int i = 1; i < entityList.size(); i++) { - GL11.glPushMatrix(); - ItemStack stack = tile.getStackInSlot(i); - if(stack != null) { - switch(i) { - case 1: - GL11.glTranslated(0.15f, 0.0f, 0.0f); - break; - case 2: - GL11.glTranslated(-0.15f, 0.0f, -0.15f); - break; - case 3: - GL11.glTranslated(-0.15f, 0.0f, 0.15f); - break; - } - entityList.get(i).setEntityItemStack(stack); - entityList.get(i).age = ClientTickHandler.ticksInGame; - ((Render)RenderManager.instance.entityRenderMap.get(EntityItem.class)).doRender((Entity)entityList.get(i), 0.0D, 0.0D, 0.0D, 1.0F, f); - } - GL11.glPopMatrix(); - } - GL11.glPopMatrix(); - if(tile.getStackInSlot(0) != null) { - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5, y + 0.915f - indetY, z + 0.5); - GL11.glScalef(0.45f, 0.45f, 0.45f); - entityList.get(0).setEntityItemStack(tile.getStackInSlot(0)); - entityList.get(0).age = ClientTickHandler.ticksInGame; - ((Render)RenderManager.instance.entityRenderMap.get(EntityItem.class)).doRender((Entity)entityList.get(0), 0.0D, 0.0D, 0.0D, 1.0F, f); - GL11.glPopMatrix(); - } - } -} \ No newline at end of file + + private List entityList = null; + private static final ResourceLocation texture = new ResourceLocation("ab:textures/model/nidavellirForge.png"); + private static final ModelNidavellirForge model = new ModelNidavellirForge(); + + public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { + TileNidavellirForge tile = (TileNidavellirForge) tileentity; + double worldTime = 0.0D; + int meta = 2; + float invRender = 0.0f; + if (tileentity != null && tileentity.getWorldObj() != null) { + worldTime = ClientTickHandler.ticksInGame + f + + (new Random((tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord))).nextInt(360); + meta = tileentity.getWorldObj().getBlockMetadata(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord); + } else invRender = 0.0875f; + float indetY = (float) (Math.sin(worldTime / 18.0D) / 24.0D); + GL11.glPushMatrix(); + GL11.glEnable(32826); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glTranslated(x - invRender, y, z); + GL11.glTranslatef(0.5f, 1.5f, 0.5f); + GL11.glRotatef(180.0f, 1.0f, 0.0f, 1.0f); + GL11.glRotatef(90.0f * meta, 0.0f, 1.0f, 0.0f); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + model.renderBottom(); + GL11.glTranslatef(0.0f, indetY, 0.0f); + model.renderTop(); + GL11.glEnable(32826); + GL11.glPopMatrix(); + if (entityList == null) { + List list = new ArrayList(); + for (int i = 0; i < tile.getSizeInventory(); i++) { + list.add(new EntityItem(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord)); + } + entityList = list; + } + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5f, y + 0.675f - indetY, z + 0.5f); + GL11.glScalef(0.2F, 0.225F, 0.225F); + for (int i = 1; i < entityList.size(); i++) { + GL11.glPushMatrix(); + ItemStack stack = tile.getStackInSlot(i); + if (stack != null) { + switch (i) { + case 1: + GL11.glTranslated(0.15f, 0.0f, 0.0f); + break; + case 2: + GL11.glTranslated(-0.15f, 0.0f, -0.15f); + break; + case 3: + GL11.glTranslated(-0.15f, 0.0f, 0.15f); + break; + } + entityList.get(i).setEntityItemStack(stack); + entityList.get(i).age = ClientTickHandler.ticksInGame; + ((Render) RenderManager.instance.entityRenderMap.get(EntityItem.class)) + .doRender((Entity) entityList.get(i), 0.0D, 0.0D, 0.0D, 1.0F, f); + } + GL11.glPopMatrix(); + } + GL11.glPopMatrix(); + if (tile.getStackInSlot(0) != null) { + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y + 0.915f - indetY, z + 0.5); + GL11.glScalef(0.45f, 0.45f, 0.45f); + entityList.get(0).setEntityItemStack(tile.getStackInSlot(0)); + entityList.get(0).age = ClientTickHandler.ticksInGame; + ((Render) RenderManager.instance.entityRenderMap.get(EntityItem.class)) + .doRender((Entity) entityList.get(0), 0.0D, 0.0D, 0.0D, 1.0F, f); + GL11.glPopMatrix(); + } + } +} diff --git a/src/main/java/ab/client/render/tile/TileRenderer.java b/src/main/java/ab/client/render/tile/TileRenderer.java index 7d15b21..8e88169 100644 --- a/src/main/java/ab/client/render/tile/TileRenderer.java +++ b/src/main/java/ab/client/render/tile/TileRenderer.java @@ -4,108 +4,115 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.IIcon; public class TileRenderer { - - public static void renderCube(double xCenter, double yCenter, double zCenter, double r, IIcon icon, Tessellator t) { - renderCube(xCenter, yCenter, zCenter, r, icon, t, 0.0f); - } - - public static void renderLateralSides(double xCenter, double yCenter, double zCenter, double r, IIcon icon, Tessellator t) { - renderLateralSides(xCenter, yCenter, zCenter, r, icon, t, 0.0f); - } - - public static void renderUpperlSide(double xCenter, double yCenter, double zCenter, double r, IIcon icon, Tessellator t) { - renderUpperlSide(xCenter, yCenter, zCenter, r, icon, t, 0.0f); - } - - public static void renderDownside(double xCenter, double yCenter, double zCenter, double r, IIcon icon, Tessellator t) { - renderUpperlSide(xCenter, yCenter, zCenter, r, icon, t, 0.0f); - } - - public static void renderCube(double xCenter, double yCenter, double zCenter, double r, IIcon icon, Tessellator t, float sideOffset) { - renderLateralSides(xCenter, yCenter, zCenter, r, icon, t, sideOffset); - - renderUpperlSide(xCenter, yCenter, zCenter, r, icon, t, sideOffset); - - renderDownside(xCenter, yCenter, zCenter, r, icon, t, sideOffset); - - } + public static void renderCube(double xCenter, double yCenter, double zCenter, double r, IIcon icon, Tessellator t) { + renderCube(xCenter, yCenter, zCenter, r, icon, t, 0.0f); + } - public static void renderLateralSides(double xCenter, double yCenter, double zCenter, double r, IIcon icon, Tessellator t, float sideOffset) { - - float maxU = icon.getMaxU(); - float maxV = icon.getMaxV(); - float minU = icon.getMinU(); - float minV = icon.getMinV(); + public static void renderLateralSides(double xCenter, double yCenter, double zCenter, double r, IIcon icon, + Tessellator t) { + renderLateralSides(xCenter, yCenter, zCenter, r, icon, t, 0.0f); + } - double minX = xCenter - r; - double minY = yCenter - r; - double minZ = zCenter - r; - double maxX = xCenter + r; - double maxY = yCenter + r; - double maxZ = zCenter + r; + public static void renderUpperlSide(double xCenter, double yCenter, double zCenter, double r, IIcon icon, + Tessellator t) { + renderUpperlSide(xCenter, yCenter, zCenter, r, icon, t, 0.0f); + } - t.addVertexWithUV(maxX, minY, maxZ + sideOffset, maxU, maxV); - t.addVertexWithUV(maxX, maxY, maxZ + sideOffset, maxU, minV); - t.addVertexWithUV(minX, maxY, maxZ + sideOffset, minU, minV); - t.addVertexWithUV(minX, minY, maxZ + sideOffset, minU, maxV); + public static void renderDownside(double xCenter, double yCenter, double zCenter, double r, IIcon icon, + Tessellator t) { + renderUpperlSide(xCenter, yCenter, zCenter, r, icon, t, 0.0f); + } - t.addVertexWithUV(minX, minY, minZ - sideOffset, maxU, maxV); - t.addVertexWithUV(minX, maxY, minZ - sideOffset, maxU, minV); - t.addVertexWithUV(maxX, maxY, minZ - sideOffset, minU, minV); - t.addVertexWithUV(maxX, minY, minZ - sideOffset, minU, maxV); + public static void renderCube(double xCenter, double yCenter, double zCenter, double r, IIcon icon, Tessellator t, + float sideOffset) { - t.addVertexWithUV(minX - sideOffset, minY, maxZ, maxU, maxV); - t.addVertexWithUV(minX - sideOffset, maxY, maxZ, maxU, minV); - t.addVertexWithUV(minX - sideOffset, maxY, minZ, minU, minV); - t.addVertexWithUV(minX - sideOffset, minY, minZ, minU, maxV); + renderLateralSides(xCenter, yCenter, zCenter, r, icon, t, sideOffset); - t.addVertexWithUV(maxX + sideOffset, minY, minZ, maxU, maxV); - t.addVertexWithUV(maxX + sideOffset, maxY, minZ, maxU, minV); - t.addVertexWithUV(maxX + sideOffset, maxY, maxZ, minU, minV); - t.addVertexWithUV(maxX + sideOffset, minY, maxZ, minU, maxV); + renderUpperlSide(xCenter, yCenter, zCenter, r, icon, t, sideOffset); - } + renderDownside(xCenter, yCenter, zCenter, r, icon, t, sideOffset); - public static void renderUpperlSide(double xCenter, double yCenter, double zCenter, double r, IIcon icon, Tessellator t, float sideOffset) { + } - float maxU = icon.getMaxU(); - float maxV = icon.getMaxV(); - float minU = icon.getMinU(); - float minV = icon.getMinV(); + public static void renderLateralSides(double xCenter, double yCenter, double zCenter, double r, IIcon icon, + Tessellator t, float sideOffset) { - double minX = xCenter - r; - double minY = yCenter - r; - double minZ = zCenter - r; - double maxX = xCenter + r; - double maxY = yCenter + r; - double maxZ = zCenter + r; + float maxU = icon.getMaxU(); + float maxV = icon.getMaxV(); + float minU = icon.getMinU(); + float minV = icon.getMinV(); - t.addVertexWithUV(maxX, maxY + sideOffset, maxZ, maxU, maxV); - t.addVertexWithUV(maxX, maxY + sideOffset, minZ, maxU, minV); - t.addVertexWithUV(minX, maxY + sideOffset, minZ, minU, minV); - t.addVertexWithUV(minX, maxY + sideOffset, maxZ, minU, maxV); + double minX = xCenter - r; + double minY = yCenter - r; + double minZ = zCenter - r; + double maxX = xCenter + r; + double maxY = yCenter + r; + double maxZ = zCenter + r; - } + t.addVertexWithUV(maxX, minY, maxZ + sideOffset, maxU, maxV); + t.addVertexWithUV(maxX, maxY, maxZ + sideOffset, maxU, minV); + t.addVertexWithUV(minX, maxY, maxZ + sideOffset, minU, minV); + t.addVertexWithUV(minX, minY, maxZ + sideOffset, minU, maxV); - public static void renderDownside(double xCenter, double yCenter, double zCenter, double r, IIcon icon, Tessellator t, float sideOffset) { + t.addVertexWithUV(minX, minY, minZ - sideOffset, maxU, maxV); + t.addVertexWithUV(minX, maxY, minZ - sideOffset, maxU, minV); + t.addVertexWithUV(maxX, maxY, minZ - sideOffset, minU, minV); + t.addVertexWithUV(maxX, minY, minZ - sideOffset, minU, maxV); - float maxU = icon.getMaxU(); - float maxV = icon.getMaxV(); - float minU = icon.getMinU(); - float minV = icon.getMinV(); + t.addVertexWithUV(minX - sideOffset, minY, maxZ, maxU, maxV); + t.addVertexWithUV(minX - sideOffset, maxY, maxZ, maxU, minV); + t.addVertexWithUV(minX - sideOffset, maxY, minZ, minU, minV); + t.addVertexWithUV(minX - sideOffset, minY, minZ, minU, maxV); - double minX = xCenter - r; - double minY = yCenter - r; - double minZ = zCenter - r; - double maxX = xCenter + r; - double maxY = yCenter + r; - double maxZ = zCenter + r; + t.addVertexWithUV(maxX + sideOffset, minY, minZ, maxU, maxV); + t.addVertexWithUV(maxX + sideOffset, maxY, minZ, maxU, minV); + t.addVertexWithUV(maxX + sideOffset, maxY, maxZ, minU, minV); + t.addVertexWithUV(maxX + sideOffset, minY, maxZ, minU, maxV); - t.addVertexWithUV(minX, minY - sideOffset, minZ, maxU, maxV); - t.addVertexWithUV(maxX, minY - sideOffset, minZ, maxU, minV); - t.addVertexWithUV(maxX, minY - sideOffset, maxZ, minU, minV); - t.addVertexWithUV(minX, minY - sideOffset, maxZ, minU, maxV); + } - } -} \ No newline at end of file + public static void renderUpperlSide(double xCenter, double yCenter, double zCenter, double r, IIcon icon, + Tessellator t, float sideOffset) { + + float maxU = icon.getMaxU(); + float maxV = icon.getMaxV(); + float minU = icon.getMinU(); + float minV = icon.getMinV(); + + double minX = xCenter - r; + double minY = yCenter - r; + double minZ = zCenter - r; + double maxX = xCenter + r; + double maxY = yCenter + r; + double maxZ = zCenter + r; + + t.addVertexWithUV(maxX, maxY + sideOffset, maxZ, maxU, maxV); + t.addVertexWithUV(maxX, maxY + sideOffset, minZ, maxU, minV); + t.addVertexWithUV(minX, maxY + sideOffset, minZ, minU, minV); + t.addVertexWithUV(minX, maxY + sideOffset, maxZ, minU, maxV); + + } + + public static void renderDownside(double xCenter, double yCenter, double zCenter, double r, IIcon icon, + Tessellator t, float sideOffset) { + + float maxU = icon.getMaxU(); + float maxV = icon.getMaxV(); + float minU = icon.getMinU(); + float minV = icon.getMinV(); + + double minX = xCenter - r; + double minY = yCenter - r; + double minZ = zCenter - r; + double maxX = xCenter + r; + double maxY = yCenter + r; + double maxZ = zCenter + r; + + t.addVertexWithUV(minX, minY - sideOffset, minZ, maxU, maxV); + t.addVertexWithUV(maxX, minY - sideOffset, minZ, maxU, minV); + t.addVertexWithUV(maxX, minY - sideOffset, maxZ, minU, minV); + t.addVertexWithUV(minX, minY - sideOffset, maxZ, minU, maxV); + + } +} diff --git a/src/main/java/ab/common/block/BlockABSpreader.java b/src/main/java/ab/common/block/BlockABSpreader.java index 51b646f..864c21a 100644 --- a/src/main/java/ab/common/block/BlockABSpreader.java +++ b/src/main/java/ab/common/block/BlockABSpreader.java @@ -1,19 +1,11 @@ package ab.common.block; -import java.util.List; - -import ab.AdvancedBotany; -import ab.common.block.tile.TileABSpreader; -import ab.common.lib.register.BlockListAB; -import ab.common.lib.register.RecipeListAB; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockPistonBase; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; @@ -27,146 +19,149 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.wand.IWandHUD; import vazkii.botania.api.wand.IWandable; import vazkii.botania.api.wand.IWireframeAABBProvider; import vazkii.botania.common.item.ModItems; +import ab.AdvancedBotany; +import ab.common.block.tile.TileABSpreader; +import ab.common.lib.register.BlockListAB; +import ab.common.lib.register.RecipeListAB; -public class BlockABSpreader extends BlockContainer implements IWandable, IWandHUD, IWireframeAABBProvider, ILexiconable { - - public BlockABSpreader() { - super(Material.wood); - this.setCreativeTab(AdvancedBotany.tabAB); - this.setHardness(7.0F); - this.setStepSound(soundTypeWood); - this.setBlockName("advancedSpreader"); - } - - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase liv, ItemStack stack) { - int orientation = BlockPistonBase.determineOrientation(world, x, y, z, liv); - TileABSpreader spreader = (TileABSpreader)world.getTileEntity(x, y, z); - world.setBlockMetadataWithNotify(x, y, z, stack.getItemDamage(), 3); - switch (orientation) { - case 0: - spreader.rotationY = -90.0F; - case 1: - spreader.rotationY = 90.0F; - case 2: - spreader.rotationX = 270.0F; - case 3: - spreader.rotationX = 90.0F; - case 4: - return; - } - spreader.rotationX = 180.0F; - } - - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { - TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof TileABSpreader)) - return false; - TileABSpreader spreader = (TileABSpreader)tile; - ItemStack lens = spreader.getStackInSlot(0); - ItemStack heldItem = player.getCurrentEquippedItem(); - boolean isHeldItemLens = (heldItem != null && heldItem.getItem() instanceof vazkii.botania.api.mana.ILens); - boolean wool = (heldItem != null && heldItem.getItem() == Item.getItemFromBlock(Blocks.wool)); - if (heldItem != null && heldItem.getItem() == ModItems.twigWand) - return false; - if (lens == null && isHeldItemLens) { - if (!player.capabilities.isCreativeMode) - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - spreader.setInventorySlotContents(0, heldItem.copy()); - spreader.markDirty(); - } else if (lens != null && !wool) { - ItemStack add = lens.copy(); - if (!player.inventory.addItemStackToInventory(add)) - player.dropPlayerItemWithRandomChoice(add, false); - spreader.setInventorySlotContents(0, null); - spreader.markDirty(); - } - if (wool && spreader.paddingColor == -1) { - spreader.paddingColor = heldItem.getItemDamage(); - heldItem.stackSize--; - if (heldItem.stackSize == 0) - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - } else if (heldItem == null && spreader.paddingColor != -1 && lens == null) { - ItemStack pad = new ItemStack(Blocks.wool, 1, spreader.paddingColor); - if (!player.inventory.addItemStackToInventory(pad)) - player.dropPlayerItemWithRandomChoice(pad, false); - spreader.paddingColor = -1; - spreader.markDirty(); - } - return true; - } - - public void breakBlock(World world, int x, int y, int z, Block par5, int par6) { - TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof TileABSpreader)) - return; - TileABSpreader inv = (TileABSpreader)tile; - if (inv != null) { - for (int i = 0; i < inv.getSizeInventory() + 1; i++) { - ItemStack stack = (i >= inv.getSizeInventory()) ? ((inv.paddingColor == -1) ? null : new ItemStack(Blocks.wool, 1, inv.paddingColor)) : inv.getStackInSlot(i); - if(stack != null) { - float spawnX = x + world.rand.nextFloat(); - float spawnY = y + world.rand.nextFloat(); - float spawnZ = z + world.rand.nextFloat(); - EntityItem droppedItem = new EntityItem(world, spawnX, spawnY, spawnZ, stack); - float mult = 0.05F; - droppedItem.motionX = ((-0.5F + world.rand.nextFloat()) * mult); - droppedItem.motionY = ((4.0F + world.rand.nextFloat()) * mult); - droppedItem.motionZ = ((-0.5F + world.rand.nextFloat()) * mult); - if (stack.hasTagCompound()) - droppedItem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy()); - world.spawnEntityInWorld((Entity)droppedItem); - } - } - world.func_147453_f(x, y, z, par5); - } - super.breakBlock(world, x, y, z, par5, par6); - } - - public IIcon getIcon(int par1, int par2) { - return BlockListAB.blockLebethron.getIcon(par1, 0); - } - - public boolean isOpaqueCube() { - return false; - } - - public boolean renderAsNormalBlock() { - return false; - } - - public int getRenderType() { +public class BlockABSpreader extends BlockContainer + implements IWandable, IWandHUD, IWireframeAABBProvider, ILexiconable { + + public BlockABSpreader() { + super(Material.wood); + this.setCreativeTab(AdvancedBotany.tabAB); + this.setHardness(7.0F); + this.setStepSound(soundTypeWood); + this.setBlockName("advancedSpreader"); + } + + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase liv, ItemStack stack) { + int orientation = BlockPistonBase.determineOrientation(world, x, y, z, liv); + TileABSpreader spreader = (TileABSpreader) world.getTileEntity(x, y, z); + world.setBlockMetadataWithNotify(x, y, z, stack.getItemDamage(), 3); + switch (orientation) { + case 0: + spreader.rotationY = -90.0F; + case 1: + spreader.rotationY = 90.0F; + case 2: + spreader.rotationX = 270.0F; + case 3: + spreader.rotationX = 90.0F; + case 4: + return; + } + spreader.rotationX = 180.0F; + } + + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, + float par8, float par9) { + TileEntity tile = world.getTileEntity(x, y, z); + if (!(tile instanceof TileABSpreader)) return false; + TileABSpreader spreader = (TileABSpreader) tile; + ItemStack lens = spreader.getStackInSlot(0); + ItemStack heldItem = player.getCurrentEquippedItem(); + boolean isHeldItemLens = (heldItem != null && heldItem.getItem() instanceof vazkii.botania.api.mana.ILens); + boolean wool = (heldItem != null && heldItem.getItem() == Item.getItemFromBlock(Blocks.wool)); + if (heldItem != null && heldItem.getItem() == ModItems.twigWand) return false; + if (lens == null && isHeldItemLens) { + if (!player.capabilities.isCreativeMode) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + spreader.setInventorySlotContents(0, heldItem.copy()); + spreader.markDirty(); + } else if (lens != null && !wool) { + ItemStack add = lens.copy(); + if (!player.inventory.addItemStackToInventory(add)) player.dropPlayerItemWithRandomChoice(add, false); + spreader.setInventorySlotContents(0, null); + spreader.markDirty(); + } + if (wool && spreader.paddingColor == -1) { + spreader.paddingColor = heldItem.getItemDamage(); + heldItem.stackSize--; + if (heldItem.stackSize == 0) player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + } else if (heldItem == null && spreader.paddingColor != -1 && lens == null) { + ItemStack pad = new ItemStack(Blocks.wool, 1, spreader.paddingColor); + if (!player.inventory.addItemStackToInventory(pad)) player.dropPlayerItemWithRandomChoice(pad, false); + spreader.paddingColor = -1; + spreader.markDirty(); + } + return true; + } + + public void breakBlock(World world, int x, int y, int z, Block par5, int par6) { + TileEntity tile = world.getTileEntity(x, y, z); + if (!(tile instanceof TileABSpreader)) return; + TileABSpreader inv = (TileABSpreader) tile; + if (inv != null) { + for (int i = 0; i < inv.getSizeInventory() + 1; i++) { + ItemStack stack = (i >= inv.getSizeInventory()) + ? ((inv.paddingColor == -1) ? null : new ItemStack(Blocks.wool, 1, inv.paddingColor)) + : inv.getStackInSlot(i); + if (stack != null) { + float spawnX = x + world.rand.nextFloat(); + float spawnY = y + world.rand.nextFloat(); + float spawnZ = z + world.rand.nextFloat(); + EntityItem droppedItem = new EntityItem(world, spawnX, spawnY, spawnZ, stack); + float mult = 0.05F; + droppedItem.motionX = ((-0.5F + world.rand.nextFloat()) * mult); + droppedItem.motionY = ((4.0F + world.rand.nextFloat()) * mult); + droppedItem.motionZ = ((-0.5F + world.rand.nextFloat()) * mult); + if (stack.hasTagCompound()) + droppedItem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy()); + world.spawnEntityInWorld((Entity) droppedItem); + } + } + world.func_147453_f(x, y, z, par5); + } + super.breakBlock(world, x, y, z, par5, par6); + } + + public IIcon getIcon(int par1, int par2) { + return BlockListAB.blockLebethron.getIcon(par1, 0); + } + + public boolean isOpaqueCube() { + return false; + } + + public boolean renderAsNormalBlock() { + return false; + } + + public int getRenderType() { return BlockListAB.blockABSpreaderRI; } - - public int getLightValue(IBlockAccess world, int x, int y, int z) { - return 12; - } - public TileEntity createNewTileEntity(World world, int meta) { - return new TileABSpreader(); - } - - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - ((TileABSpreader)world.getTileEntity(x, y, z)).onWanded(player, stack); - return true; - } - - public AxisAlignedBB getWireframeAABB(World world, int x, int y, int z) { - float f = 0.0625F; - return AxisAlignedBB.getBoundingBox((x + f), (y + f), (z + f), ((x + 1) - f), ((y + 1) - f), ((z + 1) - f)); - } + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return 12; + } - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - ((TileABSpreader)world.getTileEntity(x, y, z)).renderHUD(mc, res); - } + public TileEntity createNewTileEntity(World world, int meta) { + return new TileABSpreader(); + } - public LexiconEntry getEntry(World arg0, int arg1, int arg2, int arg3, EntityPlayer arg4, ItemStack arg5) { - return RecipeListAB.lebethronSpreader; - } -} \ No newline at end of file + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + ((TileABSpreader) world.getTileEntity(x, y, z)).onWanded(player, stack); + return true; + } + + public AxisAlignedBB getWireframeAABB(World world, int x, int y, int z) { + float f = 0.0625F; + return AxisAlignedBB.getBoundingBox((x + f), (y + f), (z + f), ((x + 1) - f), ((y + 1) - f), ((z + 1) - f)); + } + + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + ((TileABSpreader) world.getTileEntity(x, y, z)).renderHUD(mc, res); + } + + public LexiconEntry getEntry(World arg0, int arg1, int arg2, int arg3, EntityPlayer arg4, ItemStack arg5) { + return RecipeListAB.lebethronSpreader; + } +} diff --git a/src/main/java/ab/common/block/BlockABStorage.java b/src/main/java/ab/common/block/BlockABStorage.java index f9caacf..a401c64 100644 --- a/src/main/java/ab/common/block/BlockABStorage.java +++ b/src/main/java/ab/common/block/BlockABStorage.java @@ -2,9 +2,6 @@ package ab.common.block; import java.util.List; -import ab.AdvancedBotany; -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; @@ -14,41 +11,44 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; +import ab.AdvancedBotany; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + public class BlockABStorage extends Block { -private static IIcon[] icon = new IIcon[1]; - - public BlockABStorage() { - super(Material.iron); - this.setCreativeTab(AdvancedBotany.tabAB); - this.setHardness(3.0F); - this.setResistance(10.0F); - this.setStepSound(soundTypeMetal); - this.setBlockName("abStorage"); - } - - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List list) { - for(int i = 0; i < icon.length; i++) { - list.add(new ItemStack(par1, 1, i)); - } - } - - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister ir) { - for (int i = 0; i < icon.length; i++) - icon[i] = ir.registerIcon("ab:abStorage_" + i); - } - - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) { - return this.icon[meta]; - } - - public int damageDropped(int par1) { - return par1; - } - - public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { - return true; - } + private static IIcon[] icon = new IIcon[1]; + + public BlockABStorage() { + super(Material.iron); + this.setCreativeTab(AdvancedBotany.tabAB); + this.setHardness(3.0F); + this.setResistance(10.0F); + this.setStepSound(soundTypeMetal); + this.setBlockName("abStorage"); + } + + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List list) { + for (int i = 0; i < icon.length; i++) { + list.add(new ItemStack(par1, 1, i)); + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister ir) { + for (int i = 0; i < icon.length; i++) icon[i] = ir.registerIcon("ab:abStorage_" + i); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return this.icon[meta]; + } + + public int damageDropped(int par1) { + return par1; + } + + public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { + return true; + } } diff --git a/src/main/java/ab/common/block/BlockAntigravitation.java b/src/main/java/ab/common/block/BlockAntigravitation.java index ae33bab..3b6650f 100644 --- a/src/main/java/ab/common/block/BlockAntigravitation.java +++ b/src/main/java/ab/common/block/BlockAntigravitation.java @@ -2,61 +2,74 @@ package ab.common.block; import java.util.Random; -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.util.AxisAlignedBB; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import vazkii.botania.common.Botania; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockAntigravitation extends Block { - public BlockAntigravitation() { - super(Material.ground); - this.setHardness(-1.0f); - this.setTickRandomly(true); - this.useNeighborBrightness = false; - } - public boolean isReplaceable(IBlockAccess world, int x, int y, int z) { + public BlockAntigravitation() { + super(Material.ground); + this.setHardness(-1.0f); + this.setTickRandomly(true); + this.useNeighborBrightness = false; + } + + public boolean isReplaceable(IBlockAccess world, int x, int y, int z) { return true; } - + public int getRenderType() { return -1; } - + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { return null; } - + public boolean renderAsNormalBlock() { return false; } - + public boolean isOpaqueCube() { return false; } - + public boolean canCollideCheck(int p_149678_1_, boolean p_149678_2_) { return false; } - - public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) {} + + public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, + int p_149690_5_, float p_149690_6_, int p_149690_7_) {} public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - if(world.isAirBlock(x, y + 1, z)) - world.setBlockToAir(x, y, z); + if (world.isAirBlock(x, y + 1, z)) world.setBlockToAir(x, y, z); } - - @SideOnly(Side.CLIENT) - public void randomDisplayTick(World world, int x, int y, int z, Random random) { - if(random.nextBoolean()) { - float r = random.nextInt(128) / 255.0f; - float g = (random.nextInt(128) + 70) / 255.0f; - float b = 200.0f / 255.0f; - Botania.proxy.wispFX(world, x + 0.1f + Math.random() * 0.8f, y - 0.18f + 1.0f, z + 0.1 + Math.random() * 0.8, r, g, b, 0.24F * (float)(Math.random() - 0.5D), 0.0f, (float)(0.001f + Math.random() * 0.01f), 0.0f); - } - } -} \ No newline at end of file + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World world, int x, int y, int z, Random random) { + if (random.nextBoolean()) { + float r = random.nextInt(128) / 255.0f; + float g = (random.nextInt(128) + 70) / 255.0f; + float b = 200.0f / 255.0f; + Botania.proxy.wispFX( + world, + x + 0.1f + Math.random() * 0.8f, + y - 0.18f + 1.0f, + z + 0.1 + Math.random() * 0.8, + r, + g, + b, + 0.24F * (float) (Math.random() - 0.5D), + 0.0f, + (float) (0.001f + Math.random() * 0.01f), + 0.0f); + } + } +} diff --git a/src/main/java/ab/common/block/BlockBoardFate.java b/src/main/java/ab/common/block/BlockBoardFate.java index 1ecc1cf..f3f1645 100644 --- a/src/main/java/ab/common/block/BlockBoardFate.java +++ b/src/main/java/ab/common/block/BlockBoardFate.java @@ -2,12 +2,6 @@ package ab.common.block; import java.util.List; -import ab.AdvancedBotany; -import ab.common.block.tile.TileBoardFate; -import ab.common.block.tile.TileGameBoard; -import ab.common.block.tile.TileInventory; -import ab.common.lib.register.AchievementRegister; -import ab.common.lib.register.RecipeListAB; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -23,143 +17,142 @@ import net.minecraft.stats.Achievement; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; + import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; -import vazkii.botania.api.wand.IWandable; import vazkii.botania.common.achievement.IPickupAchievement; -import vazkii.botania.common.core.handler.ConfigHandler; +import ab.AdvancedBotany; +import ab.common.block.tile.TileBoardFate; +import ab.common.block.tile.TileGameBoard; +import ab.common.block.tile.TileInventory; +import ab.common.lib.register.AchievementRegister; +import ab.common.lib.register.RecipeListAB; public class BlockBoardFate extends BlockContainer implements IPickupAchievement, ILexiconable { - - protected IIcon[] iconsFate; - protected IIcon[] iconsBoard; - public BlockBoardFate() { - super(Material.iron); - this.setCreativeTab(AdvancedBotany.tabAB); - this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.1875F, 1.0F); - this.setHardness(3.0F); - this.setResistance(10.0F); - this.setStepSound(soundTypeMetal); - this.setBlockName("boardFate"); - } - - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List list) { - for(int i = 0; i < 2; i++) - list.add(new ItemStack(par1, 1, i)); - } - - public void registerBlockIcons(IIconRegister ir) { - this.iconsFate = new IIcon[3]; - this.iconsBoard = new IIcon[3]; - for(int i = 0; i < iconsFate.length; i++) - this.iconsFate[i] = ir.registerIcon("ab:boardFate_" + i); - for(int i = 0; i < iconsBoard.length; i++) - this.iconsBoard[i] = ir.registerIcon("ab:gameBoard_" + i); - } - - public IIcon getIcon(int side, int meta) { - if(meta == 0) - return this.iconsBoard[Math.min(2, side)]; - else - return this.iconsFate[Math.min(2, side)]; - } - - public boolean isOpaqueCube() { - return false; - } - - public boolean renderAsNormalBlock() { - return false; - } - - public int damageDropped(int par1) { - return par1; - } - - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7, float par8, float par9) { - int meta = world.getBlockMetadata(x, y, z); - if(meta == 0) { - TileGameBoard tile = (TileGameBoard)world.getTileEntity(x, y, z); - if(player.isSneaking() && !tile.hasGame()) { - tile.isSingleGame = !tile.isSingleGame; - if(!world.isRemote) - world.playSoundAtEntity((Entity)player, "botania:ding", 0.11F, 0.8F); - return true; - } - if(!tile.hasGame()) - tile.setPlayer(player); - else if(!tile.isSingleGame && tile.playersName[1].isEmpty() && !tile.playersName[0].equals(player.getCommandSenderName())) - tile.setPlayer(player); - else { - return tile.dropDice(player); - } - return false; - } else { - if(!player.isSneaking()) { - ItemStack heldItem = player.getCurrentEquippedItem(); - TileBoardFate tile = (TileBoardFate)world.getTileEntity(x, y, z); - if(heldItem != null && tile != null && tile.isDice(heldItem)) { - for(int i = 0; i < tile.getSizeInventory(); i++) { - ItemStack slotStack = tile.getStackInSlot(i); - if(slotStack != null) - continue; - heldItem.stackSize--; - if(heldItem.stackSize == 0) - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - if(!world.isRemote) { - ItemStack copy = heldItem.copy(); - copy.stackSize = 1; - tile.setInventorySlotContents(i, copy); - tile.slotChance[i] = (byte)(world.rand.nextInt(6) + 1); - tile.requestUpdate = true; - world.playSoundEffect(x, y, z, "ab:boardCube", 0.6F, 1.0F); - } - return true; - } - } - return false; - } else { - TileBoardFate tile = (TileBoardFate)world.getTileEntity(x, y, z); - return tile.spawnRelic(player); - } - } - } - - public TileEntity createNewTileEntity(World world, int meta) { - return meta == 0 ? new TileGameBoard() : new TileBoardFate(); - } - - public void breakBlock(World world, int x, int y, int z, Block block, int meta) { - if(!world.isRemote && meta == 1) { - TileInventory inv = (TileInventory)world.getTileEntity(x, y, z); - if (inv != null) { - for (int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if (stack != null) { - float f = world.rand.nextFloat() * 0.8F + 0.1F; - float f1 = world.rand.nextFloat() * 0.8F + 0.1F; - float f2 = world.rand.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem = new EntityItem(world, (x + f), (y + f1), (z + f2), stack.copy()); - float f3 = 0.05F; - entityitem.motionX = ((float)world.rand.nextGaussian() * f3); - entityitem.motionY = ((float)world.rand.nextGaussian() * f3 + 0.2F); - entityitem.motionZ = ((float)world.rand.nextGaussian() * f3); - if (stack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy()); - world.spawnEntityInWorld(entityitem); - } - } - } - } - super.breakBlock(world, x, y, z, block, meta); - } + protected IIcon[] iconsFate; + protected IIcon[] iconsBoard; - public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { - return stack.getItemDamage() == 1 ? AchievementRegister.fateBoard : null; - } + public BlockBoardFate() { + super(Material.iron); + this.setCreativeTab(AdvancedBotany.tabAB); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.1875F, 1.0F); + this.setHardness(3.0F); + this.setResistance(10.0F); + this.setStepSound(soundTypeMetal); + this.setBlockName("boardFate"); + } - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack stack) { - return world.getBlockMetadata(x, y, z) == 0 ? RecipeListAB.gameBoard : RecipeListAB.fateBoard; - } -} \ No newline at end of file + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List list) { + for (int i = 0; i < 2; i++) list.add(new ItemStack(par1, 1, i)); + } + + public void registerBlockIcons(IIconRegister ir) { + this.iconsFate = new IIcon[3]; + this.iconsBoard = new IIcon[3]; + for (int i = 0; i < iconsFate.length; i++) this.iconsFate[i] = ir.registerIcon("ab:boardFate_" + i); + for (int i = 0; i < iconsBoard.length; i++) this.iconsBoard[i] = ir.registerIcon("ab:gameBoard_" + i); + } + + public IIcon getIcon(int side, int meta) { + if (meta == 0) return this.iconsBoard[Math.min(2, side)]; + else return this.iconsFate[Math.min(2, side)]; + } + + public boolean isOpaqueCube() { + return false; + } + + public boolean renderAsNormalBlock() { + return false; + } + + public int damageDropped(int par1) { + return par1; + } + + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7, + float par8, float par9) { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 0) { + TileGameBoard tile = (TileGameBoard) world.getTileEntity(x, y, z); + if (player.isSneaking() && !tile.hasGame()) { + tile.isSingleGame = !tile.isSingleGame; + if (!world.isRemote) world.playSoundAtEntity((Entity) player, "botania:ding", 0.11F, 0.8F); + return true; + } + if (!tile.hasGame()) tile.setPlayer(player); + else if (!tile.isSingleGame && tile.playersName[1].isEmpty() + && !tile.playersName[0].equals(player.getCommandSenderName())) + tile.setPlayer(player); + else { + return tile.dropDice(player); + } + return false; + } else { + if (!player.isSneaking()) { + ItemStack heldItem = player.getCurrentEquippedItem(); + TileBoardFate tile = (TileBoardFate) world.getTileEntity(x, y, z); + if (heldItem != null && tile != null && tile.isDice(heldItem)) { + for (int i = 0; i < tile.getSizeInventory(); i++) { + ItemStack slotStack = tile.getStackInSlot(i); + if (slotStack != null) continue; + heldItem.stackSize--; + if (heldItem.stackSize == 0) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + if (!world.isRemote) { + ItemStack copy = heldItem.copy(); + copy.stackSize = 1; + tile.setInventorySlotContents(i, copy); + tile.slotChance[i] = (byte) (world.rand.nextInt(6) + 1); + tile.requestUpdate = true; + world.playSoundEffect(x, y, z, "ab:boardCube", 0.6F, 1.0F); + } + return true; + } + } + return false; + } else { + TileBoardFate tile = (TileBoardFate) world.getTileEntity(x, y, z); + return tile.spawnRelic(player); + } + } + } + + public TileEntity createNewTileEntity(World world, int meta) { + return meta == 0 ? new TileGameBoard() : new TileBoardFate(); + } + + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + if (!world.isRemote && meta == 1) { + TileInventory inv = (TileInventory) world.getTileEntity(x, y, z); + if (inv != null) { + for (int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if (stack != null) { + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem = new EntityItem(world, (x + f), (y + f1), (z + f2), stack.copy()); + float f3 = 0.05F; + entityitem.motionX = ((float) world.rand.nextGaussian() * f3); + entityitem.motionY = ((float) world.rand.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = ((float) world.rand.nextGaussian() * f3); + if (stack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy()); + world.spawnEntityInWorld(entityitem); + } + } + } + } + super.breakBlock(world, x, y, z, block, meta); + } + + public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { + return stack.getItemDamage() == 1 ? AchievementRegister.fateBoard : null; + } + + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack stack) { + return world.getBlockMetadata(x, y, z) == 0 ? RecipeListAB.gameBoard : RecipeListAB.fateBoard; + } +} diff --git a/src/main/java/ab/common/block/BlockEngineerHopper.java b/src/main/java/ab/common/block/BlockEngineerHopper.java index f633e91..c943e93 100644 --- a/src/main/java/ab/common/block/BlockEngineerHopper.java +++ b/src/main/java/ab/common/block/BlockEngineerHopper.java @@ -1,110 +1,101 @@ package ab.common.block; -import java.util.List; - -import ab.AdvancedBotany; -import ab.common.block.tile.TileEngineerHopper; -import ab.common.block.tile.TileInventory; -import ab.common.lib.register.BlockListAB; -import ab.common.lib.register.RecipeListAB; -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.BlockHopper; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.Facing; import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.wand.IWandHUD; import vazkii.botania.api.wand.IWandable; import vazkii.botania.common.block.ModBlocks; +import ab.AdvancedBotany; +import ab.common.block.tile.TileEngineerHopper; +import ab.common.block.tile.TileInventory; +import ab.common.lib.register.BlockListAB; +import ab.common.lib.register.RecipeListAB; public class BlockEngineerHopper extends BlockContainer implements IWandable, IWandHUD, ILexiconable { - - private static IIcon[] icons = new IIcon[3]; - public BlockEngineerHopper() { - super(Material.iron); - this.setCreativeTab(AdvancedBotany.tabAB); - this.setBlockName("engineerHopper"); - float offset = 0.125F; - this.setBlockBounds(offset, offset / 2.0f, offset, 1.0F - offset, 1.0F - (offset / 2.0f), 1.0F - offset); - } - - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return RecipeListAB.engineerHopper; - } - - public IIcon getIcon(int par1, int par2) { - return ModBlocks.blazeBlock.getIcon(0, 0); - } + private static IIcon[] icons = new IIcon[3]; - public void breakBlock(World world, int x, int y, int z, Block block, int meta) { - if(!world.isRemote) { - TileInventory inv = (TileInventory)world.getTileEntity(x, y, z); - if (inv != null) { - for (int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if (stack != null) { - float f = world.rand.nextFloat() * 0.8F + 0.1F; - float f1 = world.rand.nextFloat() * 0.8F + 0.1F; - float f2 = world.rand.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem = new EntityItem(world, (x + f), (y + f1), (z + f2), stack.copy()); - float f3 = 0.05F; - entityitem.motionX = ((float)world.rand.nextGaussian() * f3); - entityitem.motionY = ((float)world.rand.nextGaussian() * f3 + 0.2F); - entityitem.motionZ = ((float)world.rand.nextGaussian() * f3); - if (stack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy()); - world.spawnEntityInWorld(entityitem); - } - } - } - } - super.breakBlock(world, x, y, z, block, meta); - } - - public TileEntity createNewTileEntity(World world, int meta) { + public BlockEngineerHopper() { + super(Material.iron); + this.setCreativeTab(AdvancedBotany.tabAB); + this.setBlockName("engineerHopper"); + float offset = 0.125F; + this.setBlockBounds(offset, offset / 2.0f, offset, 1.0F - offset, 1.0F - (offset / 2.0f), 1.0F - offset); + } + + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return RecipeListAB.engineerHopper; + } + + public IIcon getIcon(int par1, int par2) { + return ModBlocks.blazeBlock.getIcon(0, 0); + } + + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + if (!world.isRemote) { + TileInventory inv = (TileInventory) world.getTileEntity(x, y, z); + if (inv != null) { + for (int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if (stack != null) { + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem = new EntityItem(world, (x + f), (y + f1), (z + f2), stack.copy()); + float f3 = 0.05F; + entityitem.motionX = ((float) world.rand.nextGaussian() * f3); + entityitem.motionY = ((float) world.rand.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = ((float) world.rand.nextGaussian() * f3); + if (stack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy()); + world.spawnEntityInWorld(entityitem); + } + } + } + } + super.breakBlock(world, x, y, z, block, meta); + } + + public TileEntity createNewTileEntity(World world, int meta) { return new TileEngineerHopper(); } - - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - ((TileEngineerHopper)world.getTileEntity(x, y, z)).renderHUD(mc, res); - } - - public int getRenderType() { - return BlockListAB.blockEngineerHopperRI; - } - - public boolean isOpaqueCube() { + + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + ((TileEngineerHopper) world.getTileEntity(x, y, z)).renderHUD(mc, res); + } + + public int getRenderType() { + return BlockListAB.blockEngineerHopperRI; + } + + public boolean isOpaqueCube() { return false; } - - public boolean renderAsNormalBlock() { + + public boolean renderAsNormalBlock() { return false; } - - public boolean onUsedByWand(EntityPlayer player, ItemStack wand, World world, int x, int y, int z, int meta) { - if(!player.isSneaking()) { - TileEngineerHopper tile = (TileEngineerHopper)world.getTileEntity(x, y, z); - tile.changeBindType(); - if(!world.isRemote) - world.playSoundAtEntity((Entity)player, "botania:ding", 0.11F, 1.0F); - } - return true; - } -} \ No newline at end of file + + public boolean onUsedByWand(EntityPlayer player, ItemStack wand, World world, int x, int y, int z, int meta) { + if (!player.isSneaking()) { + TileEngineerHopper tile = (TileEngineerHopper) world.getTileEntity(x, y, z); + tile.changeBindType(); + if (!world.isRemote) world.playSoundAtEntity((Entity) player, "botania:ding", 0.11F, 1.0F); + } + return true; + } +} diff --git a/src/main/java/ab/common/block/BlockFreyrLiana.java b/src/main/java/ab/common/block/BlockFreyrLiana.java index fac4cfa..e349907 100644 --- a/src/main/java/ab/common/block/BlockFreyrLiana.java +++ b/src/main/java/ab/common/block/BlockFreyrLiana.java @@ -2,9 +2,6 @@ package ab.common.block; import java.util.Random; -import ab.common.core.CommonHelper; -import ab.common.lib.register.BlockListAB; -import ab.common.lib.register.RecipeListAB; import net.minecraft.block.Block; import net.minecraft.block.BlockBush; import net.minecraft.block.IGrowable; @@ -15,66 +12,72 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; + import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; +import ab.common.core.CommonHelper; +import ab.common.lib.register.BlockListAB; +import ab.common.lib.register.RecipeListAB; public class BlockFreyrLiana extends BlockBush implements ILexiconable { - public BlockFreyrLiana() { - super(Material.plants); - this.setBlockName("BlockFreyrLiana"); - this.setStepSound(soundTypeGrass); - this.setBlockTextureName("ab:freyrLiana"); - } - - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return RecipeListAB.freyrSlingshot; - } + public BlockFreyrLiana() { + super(Material.plants); + this.setBlockName("BlockFreyrLiana"); + this.setStepSound(soundTypeGrass); + this.setBlockTextureName("ab:freyrLiana"); + } - public boolean canPlaceBlockAt(World world, int x, int y, int z) { - return world.getBlock(x, y + 1, z).getMaterial() == Material.leaves - || world.getBlock(x, y + 1, z).getMaterial() == Material.wood - || world.getBlock(x, y + 1, z).getMaterial() == Material.ground - || world.getBlock(x, y + 1, z).getMaterial() == Material.rock - || world.getBlock(x, y + 1, z).getMaterial() == Material.sand - || world.getBlock(x, y + 1, z).getMaterial() == Material.grass - || world.getBlock(x, y + 1, z) instanceof BlockFreyrLiana; - } + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return RecipeListAB.freyrSlingshot; + } - public void updateTick(World world, int x, int y, int z, Random rand) { - this.checkAndDropBlock(world, x, y, z); - world.markBlockForUpdate(x, y, z); - for(int i1 = 1; i1 < 5; i1++) { - Block block = world.getBlock(x, y - i1, z); - if(block instanceof IGrowable) { - CommonHelper.fertilizer(world, block, x, y - i1, z, 18, null); - if(world.getBlock(x, y - i1 - 1, z) == BlockListAB.blockTerraFarmland) - world.getBlock(x, y - i1 - 1, z).updateTick(world, x, y - i1 - 1, z, rand); - break; - } - } - } + public boolean canPlaceBlockAt(World world, int x, int y, int z) { + return world.getBlock(x, y + 1, z).getMaterial() == Material.leaves + || world.getBlock(x, y + 1, z).getMaterial() == Material.wood + || world.getBlock(x, y + 1, z).getMaterial() == Material.ground + || world.getBlock(x, y + 1, z).getMaterial() == Material.rock + || world.getBlock(x, y + 1, z).getMaterial() == Material.sand + || world.getBlock(x, y + 1, z).getMaterial() == Material.grass + || world.getBlock(x, y + 1, z) instanceof BlockFreyrLiana; + } - protected void checkAndDropBlock(World world, int x, int y, int z) { - if (!this.canBlockStay(world, x, y, z)) { - this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); - world.setBlock(x, y, z, getBlockById(0), 0, 3); - } - } + public void updateTick(World world, int x, int y, int z, Random rand) { + this.checkAndDropBlock(world, x, y, z); + world.markBlockForUpdate(x, y, z); + for (int i1 = 1; i1 < 5; i1++) { + Block block = world.getBlock(x, y - i1, z); + if (block instanceof IGrowable) { + CommonHelper.fertilizer(world, block, x, y - i1, z, 18, null); + if (world.getBlock(x, y - i1 - 1, z) == BlockListAB.blockTerraFarmland) + world.getBlock(x, y - i1 - 1, z).updateTick(world, x, y - i1 - 1, z, rand); + break; + } + } + } - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return null; - } + protected void checkAndDropBlock(World world, int x, int y, int z) { + if (!this.canBlockStay(world, x, y, z)) { + this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); + world.setBlock(x, y, z, getBlockById(0), 0, 3); + } + } - public boolean canBlockStay(World world, int x, int y, int z) { - return this.canPlaceBlockAt(world, x, y, z); - } + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return null; + } - public int getFlammability(final IBlockAccess world, final int x, final int y, final int z, final ForgeDirection face) { - return 100; - } + public boolean canBlockStay(World world, int x, int y, int z) { + return this.canPlaceBlockAt(world, x, y, z); + } - public int getFireSpreadSpeed(final IBlockAccess world, final int x, final int y, final int z, final ForgeDirection face) { - return 60; - } -} \ No newline at end of file + public int getFlammability(final IBlockAccess world, final int x, final int y, final int z, + final ForgeDirection face) { + return 100; + } + + public int getFireSpreadSpeed(final IBlockAccess world, final int x, final int y, final int z, + final ForgeDirection face) { + return 60; + } +} diff --git a/src/main/java/ab/common/block/BlockLebethronWood.java b/src/main/java/ab/common/block/BlockLebethronWood.java index 30946ba..1566eb3 100644 --- a/src/main/java/ab/common/block/BlockLebethronWood.java +++ b/src/main/java/ab/common/block/BlockLebethronWood.java @@ -2,11 +2,6 @@ package ab.common.block; import java.util.List; -import ab.AdvancedBotany; -import ab.common.block.tile.TileLebethronCore; -import ab.common.lib.register.RecipeListAB; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; @@ -14,7 +9,6 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -23,113 +17,117 @@ import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; -import vazkii.botania.common.item.ModItems; +import ab.AdvancedBotany; +import ab.common.block.tile.TileLebethronCore; +import ab.common.lib.register.RecipeListAB; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockLebethronWood extends Block implements ILexiconable, ITileEntityProvider { - - private static IIcon[] icon = new IIcon[5]; - public static IIcon iconPortal; - - public BlockLebethronWood() { - super(Material.wood); - this.setCreativeTab(AdvancedBotany.tabAB); - this.setHardness(6.0F); - this.setStepSound(soundTypeWood); - this.setBlockName("lebethronWood"); - } - - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { - int meta = world.getBlockMetadata(x, y, z); - if(meta == 4) { - TileLebethronCore core = (TileLebethronCore)world.getTileEntity(x, y, z); - ItemStack heldItem = player.getCurrentEquippedItem(); - if(heldItem == null) - return false; - Block block = Block.getBlockFromItem(heldItem.getItem()); - if(block.getMaterial() == Material.leaves && !heldItem.hasTagCompound()) { - if(!world.isRemote) { - core.updateStructure(); - if(core.getValidTree()) { - if(core.setBlock(player, block, heldItem.getItemDamage())) { - heldItem.stackSize--; - if(heldItem.stackSize == 0) - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z); - } - } - } - return true; - } - } - return false; - } - - public void breakBlock(World world, int x, int y, int z, Block block, int meta) { - if(!world.isRemote && meta == 4) { - TileLebethronCore tile = (TileLebethronCore)world.getTileEntity(x, y, z); - if(tile != null) { - ItemStack stack = new ItemStack(tile.getBlock(), 1, tile.getMeta()); - if (stack != null) { - float f = world.rand.nextFloat() * 0.8F + 0.1F; - float f1 = world.rand.nextFloat() * 0.8F + 0.1F; - float f2 = world.rand.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem = new EntityItem(world, (x + f), (y + f1), (z + f2), stack.copy()); - float f3 = 0.05F; - entityitem.motionX = ((float)world.rand.nextGaussian() * f3); - entityitem.motionY = ((float)world.rand.nextGaussian() * f3 + 0.2F); - entityitem.motionZ = ((float)world.rand.nextGaussian() * f3); - if (stack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy()); - world.spawnEntityInWorld(entityitem); - } - } - } - super.breakBlock(world, x, y, z, block, meta); - } - - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List list) { - for(int i = 0; i < icon.length; i++) { - list.add(new ItemStack(par1, 1, i)); - } - } - - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister ir) { - for (int i = 0; i < icon.length; i++) - icon[i] = ir.registerIcon("ab:lebethronWood_" + i); - iconPortal = ir.registerIcon("ab:portalAlphirine"); - } - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) { - return this.icon[meta]; - } - - public int damageDropped(int par1) { - return par1; - } - - public int getLightValue(IBlockAccess world, int x, int y, int z) { - return (world.getBlockMetadata(x, y, z) == 3) ? 12 : 0; - } - - public boolean canSustainLeaves(IBlockAccess world, int x, int y, int z) { - return (world.getBlockMetadata(x, y, z) == 0); - } - - 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); - } - - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return RecipeListAB.lebethronWood; - } + private static IIcon[] icon = new IIcon[5]; + public static IIcon iconPortal; - public TileEntity createNewTileEntity(World world, int meta) { - return meta == 4 ? new TileLebethronCore() : null; - } -} \ No newline at end of file + public BlockLebethronWood() { + super(Material.wood); + this.setCreativeTab(AdvancedBotany.tabAB); + this.setHardness(6.0F); + this.setStepSound(soundTypeWood); + this.setBlockName("lebethronWood"); + } + + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, + float par8, float par9) { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 4) { + TileLebethronCore core = (TileLebethronCore) world.getTileEntity(x, y, z); + ItemStack heldItem = player.getCurrentEquippedItem(); + if (heldItem == null) return false; + Block block = Block.getBlockFromItem(heldItem.getItem()); + if (block.getMaterial() == Material.leaves && !heldItem.hasTagCompound()) { + if (!world.isRemote) { + core.updateStructure(); + if (core.getValidTree()) { + if (core.setBlock(player, block, heldItem.getItemDamage())) { + heldItem.stackSize--; + if (heldItem.stackSize == 0) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z); + } + } + } + return true; + } + } + return false; + } + + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + if (!world.isRemote && meta == 4) { + TileLebethronCore tile = (TileLebethronCore) world.getTileEntity(x, y, z); + if (tile != null) { + ItemStack stack = new ItemStack(tile.getBlock(), 1, tile.getMeta()); + if (stack != null) { + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem = new EntityItem(world, (x + f), (y + f1), (z + f2), stack.copy()); + float f3 = 0.05F; + entityitem.motionX = ((float) world.rand.nextGaussian() * f3); + entityitem.motionY = ((float) world.rand.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = ((float) world.rand.nextGaussian() * f3); + if (stack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy()); + world.spawnEntityInWorld(entityitem); + } + } + } + super.breakBlock(world, x, y, z, block, meta); + } + + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List list) { + for (int i = 0; i < icon.length; i++) { + list.add(new ItemStack(par1, 1, i)); + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister ir) { + for (int i = 0; i < icon.length; i++) icon[i] = ir.registerIcon("ab:lebethronWood_" + i); + iconPortal = ir.registerIcon("ab:portalAlphirine"); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return this.icon[meta]; + } + + public int damageDropped(int par1) { + return par1; + } + + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return (world.getBlockMetadata(x, y, z) == 3) ? 12 : 0; + } + + public boolean canSustainLeaves(IBlockAccess world, int x, int y, int z) { + return (world.getBlockMetadata(x, y, z) == 0); + } + + 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); + } + + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return RecipeListAB.lebethronWood; + } + + public TileEntity createNewTileEntity(World world, int meta) { + return meta == 4 ? new TileLebethronCore() : null; + } +} diff --git a/src/main/java/ab/common/block/BlockLuminousFreyrLiana.java b/src/main/java/ab/common/block/BlockLuminousFreyrLiana.java index 846c9e0..4f27cec 100644 --- a/src/main/java/ab/common/block/BlockLuminousFreyrLiana.java +++ b/src/main/java/ab/common/block/BlockLuminousFreyrLiana.java @@ -2,48 +2,57 @@ package ab.common.block; import java.util.Random; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.world.World; + import vazkii.botania.common.Botania; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockLuminousFreyrLiana extends BlockFreyrLiana { - public BlockLuminousFreyrLiana() { - this.setBlockName("BlockLuminousFreyrLiana"); - this.setBlockTextureName("ab:freyrLuminousLiana"); - this.setTickRandomly(true); - } + public BlockLuminousFreyrLiana() { + this.setBlockName("BlockLuminousFreyrLiana"); + this.setBlockTextureName("ab:freyrLuminousLiana"); + this.setTickRandomly(true); + } - public int getLightValue() { - return 11; - } + public int getLightValue() { + return 11; + } - public void updateTick(World world, int x, int y, int z, Random rand) { - super.updateTick(world, x, y, z, rand); - if(rand.nextInt(11) == 0) - world.setBlockMetadataWithNotify(x, y, z, 1, 3); - } + public void updateTick(World world, int x, int y, int z, Random rand) { + super.updateTick(world, x, y, z, rand); + if (rand.nextInt(11) == 0) world.setBlockMetadataWithNotify(x, y, z, 1, 3); + } - @SideOnly(Side.CLIENT) - public void randomDisplayTick(World world, int x, int y, int z, Random rand) { - if(world.getBlockMetadata(x, y, z) == 1) - if(rand.nextInt(3) == 0) - Botania.proxy.wispFX(world, x + 0.1 + Math.random() * 0.8, y + Math.random() * 0.5, z + 0.1 + Math.random() * 0.8, 249 / 255f, 230 / 255f, 3 / 255f, 0.14f, -0.04f, 2); - } + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World world, int x, int y, int z, Random rand) { + if (world.getBlockMetadata(x, y, z) == 1) if (rand.nextInt(3) == 0) Botania.proxy.wispFX( + world, + x + 0.1 + Math.random() * 0.8, + y + Math.random() * 0.5, + z + 0.1 + Math.random() * 0.8, + 249 / 255f, + 230 / 255f, + 3 / 255f, + 0.14f, + -0.04f, + 2); + } - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - Random rand = new Random(); - if(world.getBlockMetadata(x, y, z) == 1) { - if (!world.isRemote) - (new EntityItem(world, x + 0.5, y, z + 0.5)).entityDropItem(new ItemStack(Items.gold_nugget, 1 + rand.nextInt(3)), 0.75f); - world.setBlockMetadataWithNotify(x, y, z, 0, 3); - return true; - } - return false; - } -} \ No newline at end of file + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, + float hitY, float hitZ) { + Random rand = new Random(); + if (world.getBlockMetadata(x, y, z) == 1) { + if (!world.isRemote) (new EntityItem(world, x + 0.5, y, z + 0.5)) + .entityDropItem(new ItemStack(Items.gold_nugget, 1 + rand.nextInt(3)), 0.75f); + world.setBlockMetadataWithNotify(x, y, z, 0, 3); + return true; + } + return false; + } +} diff --git a/src/main/java/ab/common/block/BlockMagicCraftCrate.java b/src/main/java/ab/common/block/BlockMagicCraftCrate.java index 9e8d9dd..1ceee93 100644 --- a/src/main/java/ab/common/block/BlockMagicCraftCrate.java +++ b/src/main/java/ab/common/block/BlockMagicCraftCrate.java @@ -1,12 +1,5 @@ package ab.common.block; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; - -import ab.AdvancedBotany; -import ab.common.block.tile.TileMagicCraftCrate; -import ab.common.item.ItemCraftingPattern; -import ab.common.lib.register.RecipeListAB; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; @@ -25,6 +18,10 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; import thaumcraft.client.lib.UtilsFX; @@ -35,241 +32,280 @@ import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.wand.IWandHUD; import vazkii.botania.api.wand.IWandable; import vazkii.botania.common.block.BlockModContainer; +import ab.AdvancedBotany; +import ab.common.block.tile.TileMagicCraftCrate; +import ab.common.item.ItemCraftingPattern; +import ab.common.lib.register.RecipeListAB; public class BlockMagicCraftCrate extends BlockModContainer implements IWandable, IWandHUD, ILexiconable { - public static final Aspect[] primals = new Aspect[] { Aspect.AIR, Aspect.WATER, Aspect.EARTH, Aspect.FIRE, Aspect.ORDER, Aspect.ENTROPY }; + public static final Aspect[] primals = new Aspect[] { Aspect.AIR, Aspect.WATER, Aspect.EARTH, Aspect.FIRE, + Aspect.ORDER, Aspect.ENTROPY }; - IIcon iconSide; - IIcon iconBottom; - IIcon iconTop; - public IIcon nothing; + IIcon iconSide; + IIcon iconBottom; + IIcon iconTop; + public IIcon nothing; - public BlockMagicCraftCrate() { - super(Material.wood); - this.setHardness(2.0F); - this.setStepSound(soundTypeWood); - this.setBlockName("magicThaumCrafter"); - this.setCreativeTab(AdvancedBotany.tabAB); - } - - public LexiconEntry getEntry(World arg0, int arg1, int arg2, int arg3, EntityPlayer arg4, ItemStack arg5) { - return RecipeListAB.thaumAutoCraft; - } + public BlockMagicCraftCrate() { + super(Material.wood); + this.setHardness(2.0F); + this.setStepSound(soundTypeWood); + this.setBlockName("magicThaumCrafter"); + this.setCreativeTab(AdvancedBotany.tabAB); + } - public void registerBlockIcons(IIconRegister ir) { - iconSide = ir.registerIcon("ab:magicCrateSide"); - iconTop = ir.registerIcon("ab:magicCrateTop"); - iconBottom = ir.registerIcon("ab:magicCrateBottom"); - nothing = ir.registerIcon("ab:nothing"); - } + public LexiconEntry getEntry(World arg0, int arg1, int arg2, int arg3, EntityPlayer arg4, ItemStack arg5) { + return RecipeListAB.thaumAutoCraft; + } - public boolean hasComparatorInputOverride() { - return true; - } + public void registerBlockIcons(IIconRegister ir) { + iconSide = ir.registerIcon("ab:magicCrateSide"); + iconTop = ir.registerIcon("ab:magicCrateTop"); + iconBottom = ir.registerIcon("ab:magicCrateBottom"); + nothing = ir.registerIcon("ab:nothing"); + } - public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { - TileMagicCraftCrate crate = (TileMagicCraftCrate) par1World.getTileEntity(par2, par3, par4); - return crate.getSignal(); - } + public boolean hasComparatorInputOverride() { + return true; + } - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - TileMagicCraftCrate crate = (TileMagicCraftCrate) world.getTileEntity(x, y, z); - ItemStack stack = player.getHeldItem(); - for(int i = 10; i < 12; i++) { - ItemStack item = crate.getStackInSlot(i); - if(player.isSneaking()) { - if(item == null) - continue; - if(!world.isRemote) { - Vec3 vec3 = player.getLook(1.0F).normalize(); - EntityItem entityitem = new EntityItem(world, player.posX + vec3.xCoord, player.posY + vec3.yCoord + 0.5f, player.posZ + vec3.zCoord, item.copy()); - world.spawnEntityInWorld(entityitem); - } - crate.setInventorySlotContents(i, null); - world.playSoundEffect((double) x, (double) y, (double) z, "random.pop", 0.2f, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7f + 1.0f) * 1.5f); - crate.markDirty(); - return true; - } else if(stack != null && crate.isItemValidForSlot(i, stack)) { - if(item != null) { - if(!world.isRemote) { - Vec3 vec3 = player.getLook(1.0F).normalize(); - EntityItem entityitem = new EntityItem(world, player.posX + vec3.xCoord, player.posY + vec3.yCoord + 0.5f, player.posZ + vec3.zCoord, item.copy()); - world.spawnEntityInWorld(entityitem); - } - } - crate.setInventorySlotContents(i, stack.copy()); - if(i == 11) - crate.setPlayer(player); - stack.splitStack(1); - world.playSoundEffect((double) x, (double) y, (double) z, "random.pop", 0.2f, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7f + 1.0f) * 1.5f); - crate.markDirty(); - return true; - } - } - if(stack != null && stack.getItem() instanceof ItemCraftingPattern && stack.getItemDamage() != 0) { - boolean[][] pattern = ((ItemCraftingPattern) stack.getItem()).getPattern(stack.getItemDamage()); - crate.setPattern(pattern); - stack.splitStack(1); - return true; - } - return false; - } + public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { + TileMagicCraftCrate crate = (TileMagicCraftCrate) par1World.getTileEntity(par2, par3, par4); + return crate.getSignal(); + } - public IIcon getIcon(int side, int meta) { - switch (side) { - case 0: - return iconBottom; - case 1: - return iconTop; - default: - return iconSide; - } - } + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, + float hitY, float hitZ) { + TileMagicCraftCrate crate = (TileMagicCraftCrate) world.getTileEntity(x, y, z); + ItemStack stack = player.getHeldItem(); + for (int i = 10; i < 12; i++) { + ItemStack item = crate.getStackInSlot(i); + if (player.isSneaking()) { + if (item == null) continue; + if (!world.isRemote) { + Vec3 vec3 = player.getLook(1.0F).normalize(); + EntityItem entityitem = new EntityItem( + world, + player.posX + vec3.xCoord, + player.posY + vec3.yCoord + 0.5f, + player.posZ + vec3.zCoord, + item.copy()); + world.spawnEntityInWorld(entityitem); + } + crate.setInventorySlotContents(i, null); + world.playSoundEffect( + (double) x, + (double) y, + (double) z, + "random.pop", + 0.2f, + ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7f + 1.0f) * 1.5f); + crate.markDirty(); + return true; + } else if (stack != null && crate.isItemValidForSlot(i, stack)) { + if (item != null) { + if (!world.isRemote) { + Vec3 vec3 = player.getLook(1.0F).normalize(); + EntityItem entityitem = new EntityItem( + world, + player.posX + vec3.xCoord, + player.posY + vec3.yCoord + 0.5f, + player.posZ + vec3.zCoord, + item.copy()); + world.spawnEntityInWorld(entityitem); + } + } + crate.setInventorySlotContents(i, stack.copy()); + if (i == 11) crate.setPlayer(player); + stack.splitStack(1); + world.playSoundEffect( + (double) x, + (double) y, + (double) z, + "random.pop", + 0.2f, + ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7f + 1.0f) * 1.5f); + crate.markDirty(); + return true; + } + } + if (stack != null && stack.getItem() instanceof ItemCraftingPattern && stack.getItemDamage() != 0) { + boolean[][] pattern = ((ItemCraftingPattern) stack.getItem()).getPattern(stack.getItemDamage()); + crate.setPattern(pattern); + stack.splitStack(1); + return true; + } + return false; + } - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { - switch (side) { - case 0: - return iconBottom; - case 1: - return iconTop; - default: - return iconSide; - } - } + public IIcon getIcon(int side, int meta) { + switch (side) { + case 0: + return iconBottom; + case 1: + return iconTop; + default: + return iconSide; + } + } - public TileEntity createNewTileEntity(World world, int meta) { - return new TileMagicCraftCrate(); - } + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + switch (side) { + case 0: + return iconBottom; + case 1: + return iconTop; + default: + return iconSide; + } + } - 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 TileMagicCraftCrate) { - TileMagicCraftCrate craft = (TileMagicCraftCrate) tile; - int width = 52; - int height = 52; - int xc = res.getScaledWidth() / 2 + 20; - int yc = res.getScaledHeight() / 2 - height / 2; + public TileEntity createNewTileEntity(World world, int meta) { + return new TileMagicCraftCrate(); + } - Gui.drawRect(xc - 6 - 3, yc - 6, xc + width + 3, yc + height + 6, 0x2294178a); - Gui.drawRect(xc - 4 - 3, yc - 4, xc + width + 1, yc + height + 4, 0x2294178a); + 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 TileMagicCraftCrate) { + TileMagicCraftCrate craft = (TileMagicCraftCrate) tile; + int width = 52; + int height = 52; + int xc = res.getScaledWidth() / 2 + 20; + int yc = res.getScaledHeight() / 2 - height / 2; - Gui.drawRect(xc + 60 - 3, yc + 18 - 3, xc + 60 + 16 + 3, yc + 18 + 16 + 3, 0x2294178a); - Gui.drawRect(xc + 60 - 2, yc + 18 - 2, xc + 60 + 16 + 2, yc + 18 + 16 + 2, 0x2294178a); - Gui.drawRect(xc + 60, yc + 18, xc + 60 + 16, yc + 18 + 16, 0x22efd3f4); + Gui.drawRect(xc - 6 - 3, yc - 6, xc + width + 3, yc + height + 6, 0x2294178a); + Gui.drawRect(xc - 4 - 3, yc - 4, xc + width + 1, yc + height + 4, 0x2294178a); - AspectList waitingAspects = null; - - if(craft.getWaitingStack() != null && craft.getPlayer() != null) { - GL11.glColor4f(1.0f, 1.0f, 1.0f, 0.7f); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, craft.getWaitingStack(), xc + 60, yc + 18); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - waitingAspects = ThaumcraftCraftingManager.findMatchingArcaneRecipeAspects((IInventory) craft, craft.getPlayer()); - } - if(craft.getStackInSlot(10) != null) { - GL11.glEnable(GL11.GL_BLEND); - ItemStack wand = craft.getStackInSlot(10); - ItemWandCasting itemWand = ((ItemWandCasting) wand.getItem()); - AspectList aspects = itemWand.getAllVis(wand); - int n = 0; - for (Aspect a : primals) { - float alpha = 1.0f; - if (waitingAspects != null) { - float amt = (float) waitingAspects.getAmount(a); - if (amt > 0) { - amt *= itemWand.getConsumptionModifier(wand, craft.getPlayer(), a, true); - if (amt * 100.0f > itemWand.getVis(wand, a)) { - alpha = 0.5f + (MathHelper.sin((craft.getPlayer().ticksExisted + n * 10) / 2.0f) * 0.2f - - 0.2f); - } - } - } - int xa = (int) (xc - 45 + Math.cos(0.2f * Math.PI * n + Math.PI / 2) * 45); - int ya = (int) (yc + 16 + Math.sin(0.2f * Math.PI * n + Math.PI / 2) * 45); - float amout = aspects.getAmount(a) + 0.000001f; - UtilsFX.drawTag(xa, ya, a, amout / 100f, 0, 0, 771, alpha, false); - n++; - } - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - } + Gui.drawRect(xc + 60 - 3, yc + 18 - 3, xc + 60 + 16 + 3, yc + 18 + 16 + 3, 0x2294178a); + Gui.drawRect(xc + 60 - 2, yc + 18 - 2, xc + 60 + 16 + 2, yc + 18 + 16 + 2, 0x2294178a); + Gui.drawRect(xc + 60, yc + 18, xc + 60 + 16, yc + 18 + 16, 0x22efd3f4); - Gui.drawRect(xc - 28 - 20 - 3, yc + 7 - 3, xc - 28 - 20 + 16 + 3, yc + 7 + 16 + 3, 0x2294178a); - Gui.drawRect(xc - 28 - 20 - 2, yc + 7 - 2, xc - 28 - 20 + 16 + 2, yc + 7 + 16 + 2, 0x2294178a); - Gui.drawRect(xc - 28 - 20, yc + 7, xc - 28 - 20 + 16, yc + 7 + 16, 0x22efd3f4); - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, - craft.getStackInSlot(10), xc - 28 - 20, yc + 8); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + AspectList waitingAspects = null; - Gui.drawRect(xc - 28 - 20 - 3, yc + 29 - 3, xc - 28 - 20 + 16 - 3, yc + 29 + 16 + 3, 0x2294178a); - Gui.drawRect(xc - 28 - 20 - 2, yc + 29 - 2, xc - 28 - 20 + 16 + 2, yc + 29 + 16 + 2, 0x2294178a); - Gui.drawRect(xc - 28 - 20, yc + 29, xc - 28 - 20 + 16, yc + 29 + 16, 0x22efd3f4); - net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, - craft.getStackInSlot(11), xc - 28 - 20, yc + 29); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + if (craft.getWaitingStack() != null && craft.getPlayer() != null) { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 0.7f); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance().renderItemAndEffectIntoGUI( + mc.fontRenderer, + mc.renderEngine, + craft.getWaitingStack(), + xc + 60, + yc + 18); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + waitingAspects = ThaumcraftCraftingManager + .findMatchingArcaneRecipeAspects((IInventory) craft, craft.getPlayer()); + } + if (craft.getStackInSlot(10) != null) { + GL11.glEnable(GL11.GL_BLEND); + ItemStack wand = craft.getStackInSlot(10); + ItemWandCasting itemWand = ((ItemWandCasting) wand.getItem()); + AspectList aspects = itemWand.getAllVis(wand); + int n = 0; + for (Aspect a : primals) { + float alpha = 1.0f; + if (waitingAspects != null) { + float amt = (float) waitingAspects.getAmount(a); + if (amt > 0) { + amt *= itemWand.getConsumptionModifier(wand, craft.getPlayer(), a, true); + if (amt * 100.0f > itemWand.getVis(wand, a)) { + alpha = 0.5f + (MathHelper.sin((craft.getPlayer().ticksExisted + n * 10) / 2.0f) * 0.2f + - 0.2f); + } + } + } + int xa = (int) (xc - 45 + Math.cos(0.2f * Math.PI * n + Math.PI / 2) * 45); + int ya = (int) (yc + 16 + Math.sin(0.2f * Math.PI * n + Math.PI / 2) * 45); + float amout = aspects.getAmount(a) + 0.000001f; + UtilsFX.drawTag(xa, ya, a, amout / 100f, 0, 0, 771, alpha, false); + n++; + } + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + } - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) { - int index = i * 3 + j; - int xp = xc + j * 18 - 3; - int yp = yc + i * 18; + Gui.drawRect(xc - 28 - 20 - 3, yc + 7 - 3, xc - 28 - 20 + 16 + 3, yc + 7 + 16 + 3, 0x2294178a); + Gui.drawRect(xc - 28 - 20 - 2, yc + 7 - 2, xc - 28 - 20 + 16 + 2, yc + 7 + 16 + 2, 0x2294178a); + Gui.drawRect(xc - 28 - 20, yc + 7, xc - 28 - 20 + 16, yc + 7 + 16, 0x22efd3f4); + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance().renderItemAndEffectIntoGUI( + mc.fontRenderer, + mc.renderEngine, + craft.getStackInSlot(10), + xc - 28 - 20, + yc + 8); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - boolean enabled = craft.getPattern()[i][j]; + Gui.drawRect(xc - 28 - 20 - 3, yc + 29 - 3, xc - 28 - 20 + 16 - 3, yc + 29 + 16 + 3, 0x2294178a); + Gui.drawRect(xc - 28 - 20 - 2, yc + 29 - 2, xc - 28 - 20 + 16 + 2, yc + 29 + 16 + 2, 0x2294178a); + Gui.drawRect(xc - 28 - 20, yc + 29, xc - 28 - 20 + 16, yc + 29 + 16, 0x22efd3f4); + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderItem.getInstance().renderItemAndEffectIntoGUI( + mc.fontRenderer, + mc.renderEngine, + craft.getStackInSlot(11), + xc - 28 - 20, + yc + 29); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); - Gui.drawRect(xp, yp, xp + 16, yp + 16, enabled ? 0x22efd3f4 : 0x22fb02a6); + for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) { + int index = i * 3 + j; + int xp = xc + j * 18 - 3; + int yp = yc + i * 18; - 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(); - } - } - } - - public void breakBlock(World world, int x, int y, int z, Block block, int meta) { - if(!world.isRemote) { - TileMagicCraftCrate inv = (TileMagicCraftCrate)world.getTileEntity(x, y, z); - if(inv != null) { - for(int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if(stack != null) { - float f = world.rand.nextFloat() * 0.8F + 0.1F; - float f1 = world.rand.nextFloat() * 0.8F + 0.1F; - float f2 = world.rand.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem = new EntityItem(world, (x + f), (y + f1), (z + f2), stack.copy()); - float f3 = 0.05F; - entityitem.motionX = ((float)world.rand.nextGaussian() * f3); - entityitem.motionY = ((float)world.rand.nextGaussian() * f3 + 0.2F); - entityitem.motionZ = ((float)world.rand.nextGaussian() * f3); - if(stack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy()); - world.spawnEntityInWorld(entityitem); - } - } - } - } - super.breakBlock(world, x, y, z, block, meta); - } + boolean enabled = craft.getPattern()[i][j]; - public boolean renderAsNormalBlock() { - return false; - } + Gui.drawRect(xp, yp, xp + 16, yp + 16, enabled ? 0x22efd3f4 : 0x22fb02a6); - public boolean isOpaqueCube() { - return false; - } + 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(); + } + } + } - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - TileMagicCraftCrate crate = (TileMagicCraftCrate) world.getTileEntity(x, y, z); - crate.ejectAll(); - return true; - } -} \ No newline at end of file + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + if (!world.isRemote) { + TileMagicCraftCrate inv = (TileMagicCraftCrate) world.getTileEntity(x, y, z); + if (inv != null) { + for (int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if (stack != null) { + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem = new EntityItem(world, (x + f), (y + f1), (z + f2), stack.copy()); + float f3 = 0.05F; + entityitem.motionX = ((float) world.rand.nextGaussian() * f3); + entityitem.motionY = ((float) world.rand.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = ((float) world.rand.nextGaussian() * f3); + if (stack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy()); + world.spawnEntityInWorld(entityitem); + } + } + } + } + super.breakBlock(world, x, y, z, block, meta); + } + + public boolean renderAsNormalBlock() { + return false; + } + + public boolean isOpaqueCube() { + return false; + } + + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + TileMagicCraftCrate crate = (TileMagicCraftCrate) world.getTileEntity(x, y, z); + crate.ejectAll(); + return true; + } +} diff --git a/src/main/java/ab/common/block/BlockManaCharger.java b/src/main/java/ab/common/block/BlockManaCharger.java index 25bafe5..c999739 100644 --- a/src/main/java/ab/common/block/BlockManaCharger.java +++ b/src/main/java/ab/common/block/BlockManaCharger.java @@ -1,10 +1,5 @@ package ab.common.block; -import ab.AdvancedBotany; -import ab.common.block.tile.TileInventory; -import ab.common.block.tile.TileManaCharger; -import ab.common.lib.register.BlockListAB; -import ab.common.lib.register.RecipeListAB; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -18,120 +13,132 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.Vec3; import net.minecraft.world.World; -import vazkii.botania.api.internal.VanillaPacketDispatcher; + import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.mana.IManaItem; import vazkii.botania.api.wand.IWandHUD; import vazkii.botania.api.wand.IWandable; import vazkii.botania.common.block.ModBlocks; +import ab.AdvancedBotany; +import ab.common.block.tile.TileInventory; +import ab.common.block.tile.TileManaCharger; +import ab.common.lib.register.BlockListAB; +import ab.common.lib.register.RecipeListAB; public class BlockManaCharger extends BlockContainer implements IWandHUD, IWandable, ILexiconable { - public BlockManaCharger() { - super(Material.iron); - this.setCreativeTab(AdvancedBotany.tabAB); - this.setHardness(6.0F); - float f = 0.0625f; - this.setBlockBounds(f * 3, f * 3, f * 3, 1.0f - f * 3, 1.0f - f * 4 + f * 3, 1.0f - f * 3); - this.setBlockName("ABManaCharger"); - } - - public IIcon getIcon(int par1, int par2) { - return ModBlocks.livingrock.getIcon(0, 0); - } - - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7, float par8, float par9) { - TileManaCharger tile = (TileManaCharger)world.getTileEntity(x, y, z); - if(tile != null) { - int slotSide = side - 1; - if(slotSide < 0) - return false; - ItemStack heldItem = player.getCurrentEquippedItem(); - ItemStack stackInSlot = tile.getStackInSlot(slotSide); - if(player.isSneaking()) { - if(stackInSlot != null) { - ItemStack copy = stackInSlot.copy(); - tile.setInventorySlotContents(slotSide, null); - if(!world.isRemote) { - Vec3 vec3 = player.getLook(1.0F).normalize(); - EntityItem entityitem = new EntityItem(world, player.posX + vec3.xCoord, player.posY + 1.2f, player.posZ + vec3.zCoord, copy); - world.spawnEntityInWorld(entityitem); - tile.requestUpdate = true; - } - world.func_147453_f(x, y, z, (Block)this); - return true; - } - } else { - if(heldItem != null && heldItem.getItem() instanceof IManaItem && stackInSlot == null && heldItem.getMaxStackSize() == 1) { - ItemStack copy = heldItem.copy(); - copy.stackSize = 1; - heldItem.stackSize--; - if(heldItem.stackSize == 0) - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - player.inventory.markDirty(); - if(!world.isRemote) { - tile.setInventorySlotContents(slotSide, copy); - tile.requestUpdate = true; - } - return true; - } - } - } - return false; - } - - public void breakBlock(World world, int x, int y, int z, Block block, int meta) { - if(!world.isRemote) { - TileInventory inv = (TileInventory)world.getTileEntity(x, y, z); - if (inv != null) { - for (int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if (stack != null) { - float f = world.rand.nextFloat() * 0.8F + 0.1F; - float f1 = world.rand.nextFloat() * 0.8F + 0.1F; - float f2 = world.rand.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem = new EntityItem(world, (x + f), (y + f1), (z + f2), stack.copy()); - float f3 = 0.05F; - entityitem.motionX = ((float)world.rand.nextGaussian() * f3); - entityitem.motionY = ((float)world.rand.nextGaussian() * f3 + 0.2F); - entityitem.motionZ = ((float)world.rand.nextGaussian() * f3); - if (stack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy()); - world.spawnEntityInWorld(entityitem); - } - } - } - } - super.breakBlock(world, x, y, z, block, meta); - } - - public boolean isOpaqueCube() { - return false; - } - - public boolean renderAsNormalBlock() { - return false; - } - - public int getRenderType() { + public BlockManaCharger() { + super(Material.iron); + this.setCreativeTab(AdvancedBotany.tabAB); + this.setHardness(6.0F); + float f = 0.0625f; + this.setBlockBounds(f * 3, f * 3, f * 3, 1.0f - f * 3, 1.0f - f * 4 + f * 3, 1.0f - f * 3); + this.setBlockName("ABManaCharger"); + } + + public IIcon getIcon(int par1, int par2) { + return ModBlocks.livingrock.getIcon(0, 0); + } + + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7, + float par8, float par9) { + TileManaCharger tile = (TileManaCharger) world.getTileEntity(x, y, z); + if (tile != null) { + int slotSide = side - 1; + if (slotSide < 0) return false; + ItemStack heldItem = player.getCurrentEquippedItem(); + ItemStack stackInSlot = tile.getStackInSlot(slotSide); + if (player.isSneaking()) { + if (stackInSlot != null) { + ItemStack copy = stackInSlot.copy(); + tile.setInventorySlotContents(slotSide, null); + if (!world.isRemote) { + Vec3 vec3 = player.getLook(1.0F).normalize(); + EntityItem entityitem = new EntityItem( + world, + player.posX + vec3.xCoord, + player.posY + 1.2f, + player.posZ + vec3.zCoord, + copy); + world.spawnEntityInWorld(entityitem); + tile.requestUpdate = true; + } + world.func_147453_f(x, y, z, (Block) this); + return true; + } + } else { + if (heldItem != null && heldItem.getItem() instanceof IManaItem + && stackInSlot == null + && heldItem.getMaxStackSize() == 1) { + ItemStack copy = heldItem.copy(); + copy.stackSize = 1; + heldItem.stackSize--; + if (heldItem.stackSize == 0) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + player.inventory.markDirty(); + if (!world.isRemote) { + tile.setInventorySlotContents(slotSide, copy); + tile.requestUpdate = true; + } + return true; + } + } + } + return false; + } + + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + if (!world.isRemote) { + TileInventory inv = (TileInventory) world.getTileEntity(x, y, z); + if (inv != null) { + for (int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if (stack != null) { + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem = new EntityItem(world, (x + f), (y + f1), (z + f2), stack.copy()); + float f3 = 0.05F; + entityitem.motionX = ((float) world.rand.nextGaussian() * f3); + entityitem.motionY = ((float) world.rand.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = ((float) world.rand.nextGaussian() * f3); + if (stack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy()); + world.spawnEntityInWorld(entityitem); + } + } + } + } + super.breakBlock(world, x, y, z, block, meta); + } + + public boolean isOpaqueCube() { + return false; + } + + public boolean renderAsNormalBlock() { + return false; + } + + public int getRenderType() { return BlockListAB.blockManaChargerRI; } - public TileEntity createNewTileEntity(World world, int meta) { - return new TileManaCharger(); - } - - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - ((TileManaCharger)world.getTileEntity(x, y, z)).renderHUD(mc, res); - } - - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - ((TileManaCharger)world.getTileEntity(x, y, z)).onWanded(player, stack); - return true; - } + public TileEntity createNewTileEntity(World world, int meta) { + return new TileManaCharger(); + } - public LexiconEntry getEntry(World arg0, int arg1, int arg2, int arg3, EntityPlayer arg4, ItemStack arg5) { - return RecipeListAB.manaCharger; - } + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + ((TileManaCharger) world.getTileEntity(x, y, z)).renderHUD(mc, res); + } + + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + ((TileManaCharger) world.getTileEntity(x, y, z)).onWanded(player, stack); + return true; + } + + public LexiconEntry getEntry(World arg0, int arg1, int arg2, int arg3, EntityPlayer arg4, ItemStack arg5) { + return RecipeListAB.manaCharger; + } } diff --git a/src/main/java/ab/common/block/BlockManaContainer.java b/src/main/java/ab/common/block/BlockManaContainer.java index 52ffc41..248b2bd 100644 --- a/src/main/java/ab/common/block/BlockManaContainer.java +++ b/src/main/java/ab/common/block/BlockManaContainer.java @@ -1,13 +1,7 @@ package ab.common.block; import java.util.List; -import java.util.Random; -import ab.AdvancedBotany; -import ab.common.block.tile.TileABSpreader; -import ab.common.block.tile.TileManaContainer; -import ab.common.lib.register.BlockListAB; -import ab.common.lib.register.RecipeListAB; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; @@ -18,66 +12,69 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; -import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; + import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.wand.IWandHUD; import vazkii.botania.api.wand.IWandable; -import vazkii.botania.common.block.BlockLivingrock; import vazkii.botania.common.block.ModBlocks; +import ab.AdvancedBotany; +import ab.common.block.tile.TileManaContainer; +import ab.common.lib.register.BlockListAB; +import ab.common.lib.register.RecipeListAB; public class BlockManaContainer extends BlockContainer implements IWandHUD, IWandable, ILexiconable { - public BlockManaContainer() { - super(Material.iron); - this.setCreativeTab(AdvancedBotany.tabAB); - this.setHardness(9.0F); - this.setBlockName("ABManaContainer"); - float offset = 0.08F; - this.setBlockBounds(offset, offset / 2.0f, offset, 1.0F - offset, 1.0F - (offset / 2.0f), 1.0F - offset); - } - - public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { - par3.add(new ItemStack(par1, 1, 0)); - par3.add(new ItemStack(par1, 1, 1)); - par3.add(new ItemStack(par1, 1, 2)); - } - - public int damageDropped(int meta) { - return meta; - } - - public TileEntity createNewTileEntity(World world, int meta) { - return new TileManaContainer(); - } - - public boolean isOpaqueCube() { - return false; - } - - public boolean renderAsNormalBlock() { - return false; - } - - public int getRenderType() { + public BlockManaContainer() { + super(Material.iron); + this.setCreativeTab(AdvancedBotany.tabAB); + this.setHardness(9.0F); + this.setBlockName("ABManaContainer"); + float offset = 0.08F; + this.setBlockBounds(offset, offset / 2.0f, offset, 1.0F - offset, 1.0F - (offset / 2.0f), 1.0F - offset); + } + + public void getSubBlocks(Item par1, CreativeTabs par2, List par3) { + par3.add(new ItemStack(par1, 1, 0)); + par3.add(new ItemStack(par1, 1, 1)); + par3.add(new ItemStack(par1, 1, 2)); + } + + public int damageDropped(int meta) { + return meta; + } + + public TileEntity createNewTileEntity(World world, int meta) { + return new TileManaContainer(); + } + + public boolean isOpaqueCube() { + return false; + } + + public boolean renderAsNormalBlock() { + return false; + } + + public int getRenderType() { return BlockListAB.blockManaContainerRI; } - - public IIcon getIcon(int par1, int par2) { - return ModBlocks.livingrock.getIcon(0, 0); - } - - public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { - ((TileManaContainer)world.getTileEntity(x, y, z)).renderHUD(mc, res); - } - - public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { - ((TileManaContainer)world.getTileEntity(x, y, z)).onWanded(player, stack); - return true; - } - - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return RecipeListAB.manaContainer; - } + + public IIcon getIcon(int par1, int par2) { + return ModBlocks.livingrock.getIcon(0, 0); + } + + public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) { + ((TileManaContainer) world.getTileEntity(x, y, z)).renderHUD(mc, res); + } + + public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) { + ((TileManaContainer) world.getTileEntity(x, y, z)).onWanded(player, stack); + return true; + } + + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return RecipeListAB.manaContainer; + } } diff --git a/src/main/java/ab/common/block/BlockManaCrystalCube.java b/src/main/java/ab/common/block/BlockManaCrystalCube.java index b501953..0956fad 100644 --- a/src/main/java/ab/common/block/BlockManaCrystalCube.java +++ b/src/main/java/ab/common/block/BlockManaCrystalCube.java @@ -1,81 +1,77 @@ package ab.common.block; -import ab.AdvancedBotany; -import ab.common.block.tile.TileManaCrystalCube; -import ab.common.lib.register.BlockListAB; -import ab.common.lib.register.RecipeListAB; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; -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.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; + import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; -import vazkii.botania.api.wand.IWandHUD; -import vazkii.botania.api.wand.IWandable; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.item.ItemTwigWand; +import ab.AdvancedBotany; +import ab.common.block.tile.TileManaCrystalCube; +import ab.common.lib.register.BlockListAB; +import ab.common.lib.register.RecipeListAB; public class BlockManaCrystalCube extends BlockContainer implements ILexiconable { - public BlockManaCrystalCube() { - super(Material.iron); - this.setCreativeTab(AdvancedBotany.tabAB); - float f = 0.1875F; - this.setBlockBounds(f, 0.0F, f, 1.0F - f, 1.0F, 1.0F - f); - this.setHardness(5.5F); - this.setStepSound(soundTypeMetal); - this.setBlockName("ABManaCrystalCube"); - } - - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7, float par8, float par9) { - boolean isWand = player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemTwigWand; - if(isWand) - return false; - TileManaCrystalCube tile = (TileManaCrystalCube)world.getTileEntity(x, y, z); - if(tile != null && !world.isRemote) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - tile.writeCustomNBT(nbttagcompound); - int[] mana = tile.getManaAround(); - nbttagcompound.setInteger("knownMana", mana[0]); - nbttagcompound.setInteger("knownMaxMana", mana[1]); - if(player instanceof EntityPlayerMP) - ((EntityPlayerMP)player).playerNetServerHandler.sendPacket(new S35PacketUpdateTileEntity(tile.xCoord, tile.yCoord, tile.zCoord, -999, nbttagcompound)); - } - world.playSoundAtEntity((Entity)player, "botania:ding", 0.11F, 1.0F); - return true; - } - - public TileEntity createNewTileEntity(World world, int meta) { - return new TileManaCrystalCube(); - } - - public IIcon getIcon(int par1, int par2) { - return ModBlocks.dreamwood.getIcon(0, 0); - } - - public int getRenderType() { + public BlockManaCrystalCube() { + super(Material.iron); + this.setCreativeTab(AdvancedBotany.tabAB); + float f = 0.1875F; + this.setBlockBounds(f, 0.0F, f, 1.0F - f, 1.0F, 1.0F - f); + this.setHardness(5.5F); + this.setStepSound(soundTypeMetal); + this.setBlockName("ABManaCrystalCube"); + } + + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7, + float par8, float par9) { + boolean isWand = player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemTwigWand; + if (isWand) return false; + TileManaCrystalCube tile = (TileManaCrystalCube) world.getTileEntity(x, y, z); + if (tile != null && !world.isRemote) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + tile.writeCustomNBT(nbttagcompound); + int[] mana = tile.getManaAround(); + nbttagcompound.setInteger("knownMana", mana[0]); + nbttagcompound.setInteger("knownMaxMana", mana[1]); + if (player instanceof EntityPlayerMP) ((EntityPlayerMP) player).playerNetServerHandler.sendPacket( + new S35PacketUpdateTileEntity(tile.xCoord, tile.yCoord, tile.zCoord, -999, nbttagcompound)); + } + world.playSoundAtEntity((Entity) player, "botania:ding", 0.11F, 1.0F); + return true; + } + + public TileEntity createNewTileEntity(World world, int meta) { + return new TileManaCrystalCube(); + } + + public IIcon getIcon(int par1, int par2) { + return ModBlocks.dreamwood.getIcon(0, 0); + } + + public int getRenderType() { return BlockListAB.blockManaCrystalCubeRI; } - - public boolean isOpaqueCube() { - return false; - } - - public boolean renderAsNormalBlock() { - return false; - } - - public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return RecipeListAB.manaCrystalCube; - } -} \ No newline at end of file + + public boolean isOpaqueCube() { + return false; + } + + public boolean renderAsNormalBlock() { + return false; + } + + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { + return RecipeListAB.manaCrystalCube; + } +} diff --git a/src/main/java/ab/common/block/BlockNidavellirForge.java b/src/main/java/ab/common/block/BlockNidavellirForge.java index 25409be..34e06f3 100644 --- a/src/main/java/ab/common/block/BlockNidavellirForge.java +++ b/src/main/java/ab/common/block/BlockNidavellirForge.java @@ -1,15 +1,8 @@ package ab.common.block; -import ab.AdvancedBotany; -import ab.common.block.tile.TileNidavellirForge; -import ab.common.block.tile.TileInventory; -import ab.common.lib.register.BlockListAB; -import ab.common.lib.register.RecipeListAB; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -21,127 +14,148 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import vazkii.botania.api.BotaniaAPI; + import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.common.block.ModBlocks; +import ab.AdvancedBotany; +import ab.common.block.tile.TileInventory; +import ab.common.block.tile.TileNidavellirForge; +import ab.common.lib.register.BlockListAB; +import ab.common.lib.register.RecipeListAB; public class BlockNidavellirForge extends BlockContainer implements ILexiconable { - - public BlockNidavellirForge() { - super(Material.iron); - this.setCreativeTab(AdvancedBotany.tabAB); - this.setHardness(3.0F); - this.setResistance(10.0F); - this.setStepSound(soundTypeMetal); - this.setBlockName("ABPlate"); - } - - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { - float f = 0.1875F; - float f1 = 0.0625F; - switch(world.getBlockMetadata(x, y, z)) { - case 0: this.setBlockBounds(f, 0.0F, f1, 1.0F - f, 0.75F, 1.0F); - break; - case 1: this.setBlockBounds(0.0F, 0.0F, f, 1.0F - f1, 0.75F, 1.0F - f); - break; - case 2: this.setBlockBounds(f, 0.0F, 0.0F, 1.0F - f, 0.75F, 1.0F - f1); - break; - case 3: this.setBlockBounds(f1, 0.0F, f, 1.0F, 0.75F, 1.0F - f); - break; - default: this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - } - - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase liv, ItemStack stack) { - int meta = MathHelper.floor_double((double)(liv.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - world.setBlockMetadataWithNotify(x, y, z, meta, 3); - } - - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { - TileNidavellirForge tile = (TileNidavellirForge)world.getTileEntity(x, y, z); - if(player.isSneaking()) { - if(tile.getStackInSlot(0) != null) { - ItemStack copy = tile.getStackInSlot(0).copy(); - if(!world.isRemote) { - Vec3 vec3 = player.getLook(1.0F).normalize(); - EntityItem entityitem = new EntityItem(world, player.posX + vec3.xCoord, player.posY + 1.2f, player.posZ + vec3.zCoord, copy); - world.spawnEntityInWorld(entityitem); - tile.requestUpdate = true; - } - tile.setInventorySlotContents(0, null); - world.func_147453_f(x, y, z, (Block)this); - return true; - } - for(int i = tile.getSizeInventory() - 1; i > 0; i--) { - ItemStack stack = tile.getStackInSlot(i); - if(stack != null) { - ItemStack copy = stack.copy(); - if(!world.isRemote) { - Vec3 vec3 = player.getLook(1.0F).normalize(); - EntityItem entityitem = new EntityItem(world, player.posX + vec3.xCoord, player.posY + 1.2f, player.posZ + vec3.zCoord, copy); - world.spawnEntityInWorld(entityitem); - tile.requestUpdate = true; - } - tile.setInventorySlotContents(i, null); - world.func_147453_f(x, y, z, (Block)this); - return true; - } - } - } - return false; - } - - public void breakBlock(World world, int x, int y, int z, Block block, int meta) { - if(!world.isRemote) { - TileInventory inv = (TileInventory)world.getTileEntity(x, y, z); - if (inv != null) { - for (int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if (stack != null) { - float f = world.rand.nextFloat() * 0.8F + 0.1F; - float f1 = world.rand.nextFloat() * 0.8F + 0.1F; - float f2 = world.rand.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem = new EntityItem(world, (x + f), (y + f1), (z + f2), stack.copy()); - float f3 = 0.05F; - entityitem.motionX = ((float)world.rand.nextGaussian() * f3); - entityitem.motionY = ((float)world.rand.nextGaussian() * f3 + 0.2F); - entityitem.motionZ = ((float)world.rand.nextGaussian() * f3); - if (stack.hasTagCompound()) - entityitem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy()); - world.spawnEntityInWorld(entityitem); - } - } - } - } - super.breakBlock(world, x, y, z, block, meta); - } - - public int getRenderType() { - return BlockListAB.blockABPlateRI; - } - - public IIcon getIcon(int par1, int par2) { - return ModBlocks.storage.getIcon(0, 0); - } - - public boolean renderAsNormalBlock() { - return false; - } - - public boolean isOpaqueCube() { - return false; - } - - public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { - return false; - } - public TileEntity createNewTileEntity(World world, int meta) { - return new TileNidavellirForge(); - } + public BlockNidavellirForge() { + super(Material.iron); + this.setCreativeTab(AdvancedBotany.tabAB); + this.setHardness(3.0F); + this.setResistance(10.0F); + this.setStepSound(soundTypeMetal); + this.setBlockName("ABPlate"); + } - public LexiconEntry getEntry(World arg0, int arg1, int arg2, int arg3, EntityPlayer arg4, ItemStack arg5) { - return RecipeListAB.advandedAgglomerationPlate; - } -} \ No newline at end of file + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { + float f = 0.1875F; + float f1 = 0.0625F; + switch (world.getBlockMetadata(x, y, z)) { + case 0: + this.setBlockBounds(f, 0.0F, f1, 1.0F - f, 0.75F, 1.0F); + break; + case 1: + this.setBlockBounds(0.0F, 0.0F, f, 1.0F - f1, 0.75F, 1.0F - f); + break; + case 2: + this.setBlockBounds(f, 0.0F, 0.0F, 1.0F - f, 0.75F, 1.0F - f1); + break; + case 3: + this.setBlockBounds(f1, 0.0F, f, 1.0F, 0.75F, 1.0F - f); + break; + default: + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + } + + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase liv, ItemStack stack) { + int meta = MathHelper.floor_double((double) (liv.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + world.setBlockMetadataWithNotify(x, y, z, meta, 3); + } + + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, + float par8, float par9) { + TileNidavellirForge tile = (TileNidavellirForge) world.getTileEntity(x, y, z); + if (player.isSneaking()) { + if (tile.getStackInSlot(0) != null) { + ItemStack copy = tile.getStackInSlot(0).copy(); + if (!world.isRemote) { + Vec3 vec3 = player.getLook(1.0F).normalize(); + EntityItem entityitem = new EntityItem( + world, + player.posX + vec3.xCoord, + player.posY + 1.2f, + player.posZ + vec3.zCoord, + copy); + world.spawnEntityInWorld(entityitem); + tile.requestUpdate = true; + } + tile.setInventorySlotContents(0, null); + world.func_147453_f(x, y, z, (Block) this); + return true; + } + for (int i = tile.getSizeInventory() - 1; i > 0; i--) { + ItemStack stack = tile.getStackInSlot(i); + if (stack != null) { + ItemStack copy = stack.copy(); + if (!world.isRemote) { + Vec3 vec3 = player.getLook(1.0F).normalize(); + EntityItem entityitem = new EntityItem( + world, + player.posX + vec3.xCoord, + player.posY + 1.2f, + player.posZ + vec3.zCoord, + copy); + world.spawnEntityInWorld(entityitem); + tile.requestUpdate = true; + } + tile.setInventorySlotContents(i, null); + world.func_147453_f(x, y, z, (Block) this); + return true; + } + } + } + return false; + } + + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + if (!world.isRemote) { + TileInventory inv = (TileInventory) world.getTileEntity(x, y, z); + if (inv != null) { + for (int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if (stack != null) { + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem = new EntityItem(world, (x + f), (y + f1), (z + f2), stack.copy()); + float f3 = 0.05F; + entityitem.motionX = ((float) world.rand.nextGaussian() * f3); + entityitem.motionY = ((float) world.rand.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = ((float) world.rand.nextGaussian() * f3); + if (stack.hasTagCompound()) + entityitem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy()); + world.spawnEntityInWorld(entityitem); + } + } + } + } + super.breakBlock(world, x, y, z, block, meta); + } + + public int getRenderType() { + return BlockListAB.blockABPlateRI; + } + + public IIcon getIcon(int par1, int par2) { + return ModBlocks.storage.getIcon(0, 0); + } + + public boolean renderAsNormalBlock() { + return false; + } + + public boolean isOpaqueCube() { + return false; + } + + public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) { + return false; + } + + public TileEntity createNewTileEntity(World world, int meta) { + return new TileNidavellirForge(); + } + + public LexiconEntry getEntry(World arg0, int arg1, int arg2, int arg3, EntityPlayer arg4, ItemStack arg5) { + return RecipeListAB.advandedAgglomerationPlate; + } +} diff --git a/src/main/java/ab/common/block/BlockTerraFarmland.java b/src/main/java/ab/common/block/BlockTerraFarmland.java index 996486a..ffe1e25 100644 --- a/src/main/java/ab/common/block/BlockTerraFarmland.java +++ b/src/main/java/ab/common/block/BlockTerraFarmland.java @@ -1,22 +1,12 @@ package ab.common.block; -import static net.minecraftforge.common.util.ForgeDirection.UP; - import java.util.List; import java.util.Random; -import ab.api.AdvancedBotanyAPI; -import ab.api.TerraFarmlandList; -import ab.common.lib.register.RecipeListAB; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; + import net.minecraft.block.Block; -import net.minecraft.block.BlockBush; import net.minecraft.block.BlockCrops; -import net.minecraft.block.BlockFarmland; -import net.minecraft.block.IGrowable; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -26,16 +16,21 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.common.EnumPlantType; import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.util.ForgeDirection; + import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; +import ab.api.AdvancedBotanyAPI; +import ab.api.TerraFarmlandList; +import ab.common.lib.register.RecipeListAB; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockTerraFarmland extends Block implements ILexiconable { - - private IIcon icon; - + + private IIcon icon; + public BlockTerraFarmland() { super(Material.ground); this.setTickRandomly(true); @@ -44,94 +39,97 @@ public class BlockTerraFarmland extends Block implements ILexiconable { this.setLightOpacity(255); this.setStepSound(soundTypeGravel); } - - public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) { - Block plant = plantable.getPlant(world, x, y + 1, z); - return plant != Blocks.cactus && plant != Blocks.reeds; - } - - public void updateTick(World world, int x, int y, int z, Random rand) { - if(world.isRemote) - return; - Block block = world.getBlock(x, y + 1, z); - int meta = world.getBlockMetadata(x, y + 1, z); - if(block instanceof BlockCrops) { - if(meta == 7) { - refreshSeed(world, x, y, z, block, meta); - return; - } - } else if(block instanceof IPlantable) { - for(TerraFarmlandList fSeed : AdvancedBotanyAPI.farmlandList) { - int meta1 = fSeed.getMeta(); - Block block1 = fSeed.getBlock(); - if(block != block1) - continue; - if(meta == meta1) { - refreshSeed(world, x, y, z, block1, meta1); - return; - } - } - } else { - world.setBlock(x, y, z, Blocks.dirt); - } - } - - private void refreshSeed(World world, int x, int y, int z, Block block, int meta) { - List items = world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - 4, y - 4, z - 4, x + 4, y + 4, z + 4)); - if(!items.isEmpty() && items.size() > 7) - return; - IPlantable seed = (IPlantable)block; - List list = block.getDrops(world, x, y + 1, z, meta, 0); - for(ItemStack stack : list) { - if(stack == null) - continue; - else if(stack.getItem() == seed) { - if(stack.stackSize > 1) - stack.stackSize -= 1; - } else - stack.stackSize = Math.min(64, (int)(stack.stackSize * 2.5f)); - } - for(ItemStack stack : list) { - if(stack == null) - continue; - EntityItem itemEnt = new EntityItem(world, x + 0.5f, y + 1, z + 0.5f, stack); - world.spawnEntityInWorld(itemEnt); - } - world.setBlock(x, y + 1, z, block, 0, 3); - } - - public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) { - return AxisAlignedBB.getBoundingBox((double)(p_149668_2_ + 0), (double)(p_149668_3_ + 0), (double)(p_149668_4_ + 0), (double)(p_149668_2_ + 1), (double)(p_149668_3_ + 1), (double)(p_149668_4_ + 1)); + + public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, + IPlantable plantable) { + Block plant = plantable.getPlant(world, x, y + 1, z); + return plant != Blocks.cactus && plant != Blocks.reeds; } - + + public void updateTick(World world, int x, int y, int z, Random rand) { + if (world.isRemote) return; + Block block = world.getBlock(x, y + 1, z); + int meta = world.getBlockMetadata(x, y + 1, z); + if (block instanceof BlockCrops) { + if (meta == 7) { + refreshSeed(world, x, y, z, block, meta); + return; + } + } else if (block instanceof IPlantable) { + for (TerraFarmlandList fSeed : AdvancedBotanyAPI.farmlandList) { + int meta1 = fSeed.getMeta(); + Block block1 = fSeed.getBlock(); + if (block != block1) continue; + if (meta == meta1) { + refreshSeed(world, x, y, z, block1, meta1); + return; + } + } + } else { + world.setBlock(x, y, z, Blocks.dirt); + } + } + + private void refreshSeed(World world, int x, int y, int z, Block block, int meta) { + List items = world.getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox(x - 4, y - 4, z - 4, x + 4, y + 4, z + 4)); + if (!items.isEmpty() && items.size() > 7) return; + IPlantable seed = (IPlantable) block; + List list = block.getDrops(world, x, y + 1, z, meta, 0); + for (ItemStack stack : list) { + if (stack == null) continue; + else if (stack.getItem() == seed) { + if (stack.stackSize > 1) stack.stackSize -= 1; + } else stack.stackSize = Math.min(64, (int) (stack.stackSize * 2.5f)); + } + for (ItemStack stack : list) { + if (stack == null) continue; + EntityItem itemEnt = new EntityItem(world, x + 0.5f, y + 1, z + 0.5f, stack); + world.spawnEntityInWorld(itemEnt); + } + world.setBlock(x, y + 1, z, block, 0, 3); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, + int p_149668_4_) { + return AxisAlignedBB.getBoundingBox( + (double) (p_149668_2_ + 0), + (double) (p_149668_3_ + 0), + (double) (p_149668_4_ + 0), + (double) (p_149668_2_ + 1), + (double) (p_149668_3_ + 1), + (double) (p_149668_4_ + 1)); + } + public boolean isOpaqueCube() { return false; } - + public boolean renderAsNormalBlock() { return false; } - + 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_); + return Blocks.dirt.getItemDropped(0, p_149650_2_, p_149650_3_); } - + @SideOnly(Side.CLIENT) public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { - return Item.getItemFromBlock(Blocks.dirt); + return Item.getItemFromBlock(Blocks.dirt); } - + @SideOnly(Side.CLIENT) public IIcon getIcon(int p_149691_1_, int p_149691_2_) { return p_149691_1_ == 1 ? icon : Blocks.dirt.getIcon(0, 0); } - + @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister reg) { - icon = reg.registerIcon("ab:terraFarmland"); + icon = reg.registerIcon("ab:terraFarmland"); } - + public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) { - return RecipeListAB.terraHoe; - } -} \ No newline at end of file + return RecipeListAB.terraHoe; + } +} diff --git a/src/main/java/ab/common/block/subtile/ABSubTileSignature.java b/src/main/java/ab/common/block/subtile/ABSubTileSignature.java index b266601..3b7e04a 100644 --- a/src/main/java/ab/common/block/subtile/ABSubTileSignature.java +++ b/src/main/java/ab/common/block/subtile/ABSubTileSignature.java @@ -8,6 +8,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.subtile.SubTileEntity; import vazkii.botania.api.subtile.SubTileFunctional; @@ -18,48 +19,44 @@ import vazkii.botania.common.block.BlockSpecialFlower; public class ABSubTileSignature extends SubTileSignature { - String name; - IIcon icon; - - public ABSubTileSignature(String name) { - this.name = name; - } - - public void registerIcons(IIconRegister reg) { - this.icon = reg.registerIcon("ab:flower_" + this.name); - BlockSpecialFlower.icons.put(name, icon); - } - - public IIcon getIconForStack(ItemStack item) { - return this.icon; - } - - public String getUnlocalizedNameForStack(ItemStack item) { - return unlocalizedName(""); - } - - private String unlocalizedName(String end) { - return "ab.flower." + this.name + end; - } - - public String getUnlocalizedLoreTextForStack(ItemStack stack) { - return unlocalizedName(".reference"); - } - - public String getType() { - Class clazz = BotaniaAPI.getSubTileMapping(this.name); - if(clazz == null) - return "uwotm8"; - if(clazz.getAnnotation(PassiveFlower.class) != null) - return "botania.flowerType.passiveGenerating"; - if(SubTileGenerating.class.isAssignableFrom(clazz)) - return "botania.flowerType.generating"; - if(SubTileFunctional.class.isAssignableFrom(clazz)) - return "botania.flowerType.functional"; - return "botania.flowerType.misc"; - } - - public void addTooltip(ItemStack stack, EntityPlayer player, List tooltip) { - tooltip.add(EnumChatFormatting.BLUE + StatCollector.translateToLocal(getType())); - } -} \ No newline at end of file + String name; + IIcon icon; + + public ABSubTileSignature(String name) { + this.name = name; + } + + public void registerIcons(IIconRegister reg) { + this.icon = reg.registerIcon("ab:flower_" + this.name); + BlockSpecialFlower.icons.put(name, icon); + } + + public IIcon getIconForStack(ItemStack item) { + return this.icon; + } + + public String getUnlocalizedNameForStack(ItemStack item) { + return unlocalizedName(""); + } + + private String unlocalizedName(String end) { + return "ab.flower." + this.name + end; + } + + public String getUnlocalizedLoreTextForStack(ItemStack stack) { + return unlocalizedName(".reference"); + } + + public String getType() { + Class clazz = BotaniaAPI.getSubTileMapping(this.name); + if (clazz == null) return "uwotm8"; + if (clazz.getAnnotation(PassiveFlower.class) != null) return "botania.flowerType.passiveGenerating"; + if (SubTileGenerating.class.isAssignableFrom(clazz)) return "botania.flowerType.generating"; + if (SubTileFunctional.class.isAssignableFrom(clazz)) return "botania.flowerType.functional"; + return "botania.flowerType.misc"; + } + + public void addTooltip(ItemStack stack, EntityPlayer player, List tooltip) { + tooltip.add(EnumChatFormatting.BLUE + StatCollector.translateToLocal(getType())); + } +} diff --git a/src/main/java/ab/common/block/subtile/SubTileAncientAlphirine.java b/src/main/java/ab/common/block/subtile/SubTileAncientAlphirine.java index bf5e2b8..46f50e9 100644 --- a/src/main/java/ab/common/block/subtile/SubTileAncientAlphirine.java +++ b/src/main/java/ab/common/block/subtile/SubTileAncientAlphirine.java @@ -2,130 +2,127 @@ package ab.common.block.subtile; import java.util.List; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + +import vazkii.botania.api.lexicon.LexiconEntry; +import vazkii.botania.api.subtile.RadiusDescriptor; +import vazkii.botania.api.subtile.SubTileFunctional; +import vazkii.botania.common.item.ItemLexicon; import ab.api.AdvancedBotanyAPI; import ab.api.recipe.RecipeAncientAlphirine; import ab.common.entity.EntityAlphirinePortal; -import ab.common.lib.register.BlockListAB; import ab.common.lib.register.RecipeListAB; -import net.minecraft.block.Block; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.World; -import vazkii.botania.api.lexicon.LexiconEntry; -import vazkii.botania.api.lexicon.multiblock.Multiblock; -import vazkii.botania.api.lexicon.multiblock.MultiblockSet; -import vazkii.botania.api.subtile.RadiusDescriptor; -import vazkii.botania.api.subtile.SubTileEntity; -import vazkii.botania.api.subtile.SubTileFunctional; -import vazkii.botania.common.Botania; -import vazkii.botania.common.block.ModBlocks; -import vazkii.botania.common.block.ModFluffBlocks; -import vazkii.botania.common.item.ItemLexicon; public class SubTileAncientAlphirine extends SubTileFunctional { - - protected static int manaRequare = 4500; - public void onUpdate() { - super.onUpdate(); - float posX = this.supertile.xCoord + 0.5f; - float posY = this.supertile.yCoord; - float posZ = this.supertile.zCoord + 0.5f; - World world = this.supertile.getWorldObj(); - List items = world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, (posX + 1), (posY + 1), (posZ + 1)).expand(1, 0, 1)); - if(this.ticksExisted % 10 == 0 && this.mana >= manaRequare) { - label666: for(EntityItem item : items) { - if(item.isDead || !(item.getEntityItem().stackSize >= 1)) - continue; - for(RecipeAncientAlphirine recipe : AdvancedBotanyAPI.alphirineRecipes) { - if(recipe.matches(item.getEntityItem())) { - if(world.isRemote) { - spawnParticle(world, item); - } else { - if(item.getEntityItem().stackSize > 1) - item.getEntityItem().stackSize -= 1; - else - item.setDead(); - if(world.rand.nextInt(111) <= recipe.getChance()) { - spawnPortal(world, recipe.getOutput().copy(), posX, posY, posZ); - this.mana -= manaRequare; - } else { - this.mana -= manaRequare / 10; - } - this.sync(); - } - break label666; - } - } - if(item.getEntityItem().getItem() instanceof ItemLexicon) { - if(!((ItemLexicon)item.getEntityItem().getItem()).isKnowledgeUnlocked(item.getEntityItem(), RecipeListAB.forgotten)) { - if(world.isRemote) - spawnParticle(world, item); - else { - if(item.getEntityItem().stackSize > 1) - item.getEntityItem().stackSize -= 1; - else - item.setDead(); - ItemStack lexicon = item.getEntityItem().copy(); - ((ItemLexicon)lexicon.getItem()).unlockKnowledge(lexicon, RecipeListAB.forgotten); - this.mana -= manaRequare; - spawnPortal(world, lexicon, posX, posY, posZ); - this.sync(); - } - break label666; - } - } - } - } - } - - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), 1); - } - - private void spawnPortal(World world, ItemStack stack, float posX, float posY, float posZ) { - EntityAlphirinePortal portal = new EntityAlphirinePortal(world); - float itemX = (float)(posX + (Math.random() * 2.0f - 1.0f)); - float itemY = (float)(posY + 1.2f + (Math.random() - 0.5f)); - float itemZ = (float)(posZ + (Math.random() * 2.0f - 1.0f)); - portal.setPosition(itemX, itemY, itemZ); - portal.setStack(stack); - world.spawnEntityInWorld(portal); - } - - private void spawnParticle(World world, EntityItem item) { - ItemStack stack = item.getEntityItem(); - if(world.isRemote) - for (int i = 0; i < 10; i++) { - float m = 0.2F; - float mx = (float)(Math.random() - 0.5D) * m; - float my = (float)(Math.random() - 0.5D) * m; - float mz = (float)(Math.random() - 0.5D) * m; - if(stack.getItem() instanceof net.minecraft.item.ItemBlock) { - world.spawnParticle("blockcrack_" + Item.getIdFromItem(stack.getItem()) + "_" + stack.getItemDamage(), item.posX, item.posY, item.posZ, mx, my, mz); - } else { - world.spawnParticle("iconcrack_" + Item.getIdFromItem(stack.getItem()) + "_" + stack.getItemDamage(), item.posX, item.posY, item.posZ, mx, my, mz); - } - } - } - - public int getMaxMana() { - return 180000; - } - - public int getColor() { - return 0xd0bf58; - } - - public LexiconEntry getEntry() { - return RecipeListAB.ancientAlphirine; - } -} \ No newline at end of file + protected static int manaRequare = 4500; + + public void onUpdate() { + super.onUpdate(); + float posX = this.supertile.xCoord + 0.5f; + float posY = this.supertile.yCoord; + float posZ = this.supertile.zCoord + 0.5f; + World world = this.supertile.getWorldObj(); + List items = world.getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox(posX, posY, posZ, (posX + 1), (posY + 1), (posZ + 1)).expand(1, 0, 1)); + if (this.ticksExisted % 10 == 0 && this.mana >= manaRequare) { + label666: for (EntityItem item : items) { + if (item.isDead || !(item.getEntityItem().stackSize >= 1)) continue; + for (RecipeAncientAlphirine recipe : AdvancedBotanyAPI.alphirineRecipes) { + if (recipe.matches(item.getEntityItem())) { + if (world.isRemote) { + spawnParticle(world, item); + } else { + if (item.getEntityItem().stackSize > 1) item.getEntityItem().stackSize -= 1; + else item.setDead(); + if (world.rand.nextInt(111) <= recipe.getChance()) { + spawnPortal(world, recipe.getOutput().copy(), posX, posY, posZ); + this.mana -= manaRequare; + } else { + this.mana -= manaRequare / 10; + } + this.sync(); + } + break label666; + } + } + if (item.getEntityItem().getItem() instanceof ItemLexicon) { + if (!((ItemLexicon) item.getEntityItem().getItem()) + .isKnowledgeUnlocked(item.getEntityItem(), RecipeListAB.forgotten)) { + if (world.isRemote) spawnParticle(world, item); + else { + if (item.getEntityItem().stackSize > 1) item.getEntityItem().stackSize -= 1; + else item.setDead(); + ItemStack lexicon = item.getEntityItem().copy(); + ((ItemLexicon) lexicon.getItem()).unlockKnowledge(lexicon, RecipeListAB.forgotten); + this.mana -= manaRequare; + spawnPortal(world, lexicon, posX, posY, posZ); + this.sync(); + } + break label666; + } + } + } + } + } + + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), 1); + } + + private void spawnPortal(World world, ItemStack stack, float posX, float posY, float posZ) { + EntityAlphirinePortal portal = new EntityAlphirinePortal(world); + float itemX = (float) (posX + (Math.random() * 2.0f - 1.0f)); + float itemY = (float) (posY + 1.2f + (Math.random() - 0.5f)); + float itemZ = (float) (posZ + (Math.random() * 2.0f - 1.0f)); + portal.setPosition(itemX, itemY, itemZ); + portal.setStack(stack); + world.spawnEntityInWorld(portal); + } + + private void spawnParticle(World world, EntityItem item) { + ItemStack stack = item.getEntityItem(); + if (world.isRemote) for (int i = 0; i < 10; i++) { + float m = 0.2F; + float mx = (float) (Math.random() - 0.5D) * m; + float my = (float) (Math.random() - 0.5D) * m; + float mz = (float) (Math.random() - 0.5D) * m; + if (stack.getItem() instanceof net.minecraft.item.ItemBlock) { + world.spawnParticle( + "blockcrack_" + Item.getIdFromItem(stack.getItem()) + "_" + stack.getItemDamage(), + item.posX, + item.posY, + item.posZ, + mx, + my, + mz); + } else { + world.spawnParticle( + "iconcrack_" + Item.getIdFromItem(stack.getItem()) + "_" + stack.getItemDamage(), + item.posX, + item.posY, + item.posZ, + mx, + my, + mz); + } + } + } + + public int getMaxMana() { + return 180000; + } + + public int getColor() { + return 0xd0bf58; + } + + public LexiconEntry getEntry() { + return RecipeListAB.ancientAlphirine; + } +} diff --git a/src/main/java/ab/common/block/subtile/SubTileArdentAzarcissus.java b/src/main/java/ab/common/block/subtile/SubTileArdentAzarcissus.java index 7a1d48e..d28b895 100644 --- a/src/main/java/ab/common/block/subtile/SubTileArdentAzarcissus.java +++ b/src/main/java/ab/common/block/subtile/SubTileArdentAzarcissus.java @@ -1,96 +1,91 @@ package ab.common.block.subtile; -import ab.common.block.tile.TileGameBoard; -import ab.common.lib.register.RecipeListAB; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.SubTileGenerating; import vazkii.botania.common.item.block.ItemBlockSpecialFlower; +import ab.common.block.tile.TileGameBoard; +import ab.common.lib.register.RecipeListAB; public class SubTileArdentAzarcissus extends SubTileGenerating { - - public static final String playerName = "ArdentAzarcissus#21sda2gaj91*21df#111sfq3jrns@#"; - public static final ItemStack flowerStack = ItemBlockSpecialFlower.ofType("ardentAzarcissus"); - - int cooldown; - int workMana = 320; - public void onUpdate() { - super.onUpdate(); - World world = this.supertile.getWorldObj(); - int posX = this.supertile.xCoord; - int posY = this.supertile.yCoord; - int posZ = this.supertile.zCoord; - if(world.isRemote) - return; - if(cooldown > 0) { - cooldown--; - return; - } else if(this.mana == this.getMaxMana()) - return; - boolean needSync = false; - for(int i = -1; i <= 1; i++) - for(int j = -1; j <= 1; j++) { - int x = posX + i; - int z = posZ + j; - TileEntity tile = world.getTileEntity(x, posY, z); - if(tile != null && tile instanceof TileGameBoard) { - TileGameBoard board = (TileGameBoard)tile; - if(board.isSingleGame) { - if(!board.hasGame()) { - board.setPlayer(playerName, true); - cooldown = 120; - } else { - if(!board.playersName[0].equals(playerName)) - board.playersName[0] = playerName; - if(!board.isCustomGame) - board.isCustomGame = true; - if(board.endGameTick == 0) { - int winCount = (board.slotChance[0] + board.slotChance[1]) - (board.slotChance[2] + board.slotChance[3]); - if(winCount > 0) { - mana = Math.min(this.getMaxMana(), this.mana + (workMana * winCount)); - needSync = true; - } - board.finishGame(false); - } else - board.dropDice(playerName); - cooldown = 120; - } - board.changeCustomStack(flowerStack); - } - } - } - if(needSync) - sync(); - } - - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), 1); - } - - public int getMaxMana() { - return 16000; - } - - public int getColor() { - return 0xdf3596; - } - - public LexiconEntry getEntry() { - return RecipeListAB.azartFlower; - } - - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - cmp.setInteger("cooldown", this.cooldown); - } - - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - this.cooldown = cmp.getInteger("cooldown"); - } -} \ No newline at end of file + public static final String playerName = "ArdentAzarcissus#21sda2gaj91*21df#111sfq3jrns@#"; + public static final ItemStack flowerStack = ItemBlockSpecialFlower.ofType("ardentAzarcissus"); + + int cooldown; + int workMana = 320; + + public void onUpdate() { + super.onUpdate(); + World world = this.supertile.getWorldObj(); + int posX = this.supertile.xCoord; + int posY = this.supertile.yCoord; + int posZ = this.supertile.zCoord; + if (world.isRemote) return; + if (cooldown > 0) { + cooldown--; + return; + } else if (this.mana == this.getMaxMana()) return; + boolean needSync = false; + for (int i = -1; i <= 1; i++) for (int j = -1; j <= 1; j++) { + int x = posX + i; + int z = posZ + j; + TileEntity tile = world.getTileEntity(x, posY, z); + if (tile != null && tile instanceof TileGameBoard) { + TileGameBoard board = (TileGameBoard) tile; + if (board.isSingleGame) { + if (!board.hasGame()) { + board.setPlayer(playerName, true); + cooldown = 120; + } else { + if (!board.playersName[0].equals(playerName)) board.playersName[0] = playerName; + if (!board.isCustomGame) board.isCustomGame = true; + if (board.endGameTick == 0) { + int winCount = (board.slotChance[0] + board.slotChance[1]) + - (board.slotChance[2] + board.slotChance[3]); + if (winCount > 0) { + mana = Math.min(this.getMaxMana(), this.mana + (workMana * winCount)); + needSync = true; + } + board.finishGame(false); + } else board.dropDice(playerName); + cooldown = 120; + } + board.changeCustomStack(flowerStack); + } + } + } + if (needSync) sync(); + } + + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), 1); + } + + public int getMaxMana() { + return 16000; + } + + public int getColor() { + return 0xdf3596; + } + + public LexiconEntry getEntry() { + return RecipeListAB.azartFlower; + } + + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + cmp.setInteger("cooldown", this.cooldown); + } + + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + this.cooldown = cmp.getInteger("cooldown"); + } +} diff --git a/src/main/java/ab/common/block/subtile/SubTileAspecolus.java b/src/main/java/ab/common/block/subtile/SubTileAspecolus.java index a6148d8..4762c60 100644 --- a/src/main/java/ab/common/block/subtile/SubTileAspecolus.java +++ b/src/main/java/ab/common/block/subtile/SubTileAspecolus.java @@ -2,99 +2,98 @@ package ab.common.block.subtile; import java.util.ArrayList; import java.util.List; -import java.util.Random; -import ab.common.lib.register.RecipeListAB; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; + import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; import thaumcraft.common.Thaumcraft; import thaumcraft.common.lib.network.PacketHandler; import thaumcraft.common.lib.network.playerdata.PacketAspectPool; -import thaumcraft.common.lib.network.playerdata.PacketSyncAspects; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.SubTileFunctional; +import ab.common.lib.register.RecipeListAB; public class SubTileAspecolus extends SubTileFunctional { - protected static int manaRequare = 1250; - int cooldown = 0; - - public void onUpdate() { - super.onUpdate(); - World world = this.supertile.getWorldObj(); - if(world.isRemote) - return; - if(this.cooldown > 0) - this.cooldown -= 1; - int posX = this.supertile.xCoord; - int posY = this.supertile.yCoord; - int posZ = this.supertile.zCoord; - List players = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, (posX + 1), (posY + 1), (posZ + 1))); - int countPlayer = 0; - for(EntityPlayer p : players) { - if(!(this.mana >= this.manaRequare)) - break; - else if(this.cooldown > 0) - break; - AspectList aspList = Thaumcraft.proxy.playerKnowledge.getAspectsDiscovered(p.getDisplayName()); - ArrayList aspects = new ArrayList(); - for(Aspect a : aspList.getAspects()) { - if(!Aspect.getPrimalAspects().contains(a) && Thaumcraft.proxy.playerKnowledge.getAspectPoolFor(p.getCommandSenderName(), a) > 0) - aspects.add(a); - } - if(aspects.isEmpty()) - continue; - for(int i = 0; i < 8; i++) { - Aspect a = aspects.get(world.rand.nextInt(aspects.size())); - if(!(Thaumcraft.proxy.playerKnowledge.getAspectPoolFor(p.getCommandSenderName(), a) > 0)) - continue; - Aspect[] components = a.getComponents(); - aspList.reduce(a, 1); - for(int r = 0; r < components.length; r++) { - if(world.rand.nextInt(100) < 70) - continue; - Thaumcraft.proxy.playerKnowledge.addAspectPool(p.getDisplayName(), components[r], (short) 1); - PacketHandler.INSTANCE.sendTo(new PacketAspectPool(components[r].getTag(), (short) 1, Thaumcraft.proxy.playerKnowledge.getAspectPoolFor(p.getCommandSenderName(), components[r])), - (EntityPlayerMP) p); - } - } - this.mana -= this.manaRequare; - this.sync(); - ++countPlayer; - } - if(countPlayer > 0) - this.cooldown = 75 * countPlayer; - } - - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), 1); - } - - public int getMaxMana() { - return 15000; - } - - public int getColor() { - return 0x8a20dc; - } - - public LexiconEntry getEntry() { - return RecipeListAB.aspecolus; - } - - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - cmp.setInteger("cooldown", this.cooldown); - } - - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - this.cooldown = cmp.getInteger("cooldown"); - } -} \ No newline at end of file + protected static int manaRequare = 1250; + int cooldown = 0; + + public void onUpdate() { + super.onUpdate(); + World world = this.supertile.getWorldObj(); + if (world.isRemote) return; + if (this.cooldown > 0) this.cooldown -= 1; + int posX = this.supertile.xCoord; + int posY = this.supertile.yCoord; + int posZ = this.supertile.zCoord; + List players = world.getEntitiesWithinAABB( + EntityPlayer.class, + AxisAlignedBB.getBoundingBox(posX, posY, posZ, (posX + 1), (posY + 1), (posZ + 1))); + int countPlayer = 0; + for (EntityPlayer p : players) { + if (!(this.mana >= this.manaRequare)) break; + else if (this.cooldown > 0) break; + AspectList aspList = Thaumcraft.proxy.playerKnowledge.getAspectsDiscovered(p.getDisplayName()); + ArrayList aspects = new ArrayList(); + for (Aspect a : aspList.getAspects()) { + if (!Aspect.getPrimalAspects().contains(a) + && Thaumcraft.proxy.playerKnowledge.getAspectPoolFor(p.getCommandSenderName(), a) > 0) + aspects.add(a); + } + if (aspects.isEmpty()) continue; + for (int i = 0; i < 8; i++) { + Aspect a = aspects.get(world.rand.nextInt(aspects.size())); + if (!(Thaumcraft.proxy.playerKnowledge.getAspectPoolFor(p.getCommandSenderName(), a) > 0)) continue; + Aspect[] components = a.getComponents(); + aspList.reduce(a, 1); + for (int r = 0; r < components.length; r++) { + if (world.rand.nextInt(100) < 70) continue; + Thaumcraft.proxy.playerKnowledge.addAspectPool(p.getDisplayName(), components[r], (short) 1); + PacketHandler.INSTANCE.sendTo( + new PacketAspectPool( + components[r].getTag(), + (short) 1, + Thaumcraft.proxy.playerKnowledge + .getAspectPoolFor(p.getCommandSenderName(), components[r])), + (EntityPlayerMP) p); + } + } + this.mana -= this.manaRequare; + this.sync(); + ++countPlayer; + } + if (countPlayer > 0) this.cooldown = 75 * countPlayer; + } + + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), 1); + } + + public int getMaxMana() { + return 15000; + } + + public int getColor() { + return 0x8a20dc; + } + + public LexiconEntry getEntry() { + return RecipeListAB.aspecolus; + } + + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + cmp.setInteger("cooldown", this.cooldown); + } + + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + this.cooldown = cmp.getInteger("cooldown"); + } +} diff --git a/src/main/java/ab/common/block/subtile/SubTileDictarius.java b/src/main/java/ab/common/block/subtile/SubTileDictarius.java index 764ac26..604c048 100644 --- a/src/main/java/ab/common/block/subtile/SubTileDictarius.java +++ b/src/main/java/ab/common/block/subtile/SubTileDictarius.java @@ -2,10 +2,7 @@ package ab.common.block.subtile; import java.util.List; -import ab.common.core.handler.ConfigABHandler; -import ab.common.lib.register.RecipeListAB; import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.player.EntityPlayer; @@ -16,105 +13,126 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; + import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.SubTileGenerating; import vazkii.botania.common.block.tile.TileSpecialFlower; +import ab.common.core.handler.ConfigABHandler; +import ab.common.lib.register.RecipeListAB; public class SubTileDictarius extends SubTileGenerating { - - private static final int workMana = 480; - int cooldown; - - public void onUpdate() { - super.onUpdate(); - if(this.supertile.getWorldObj().isRemote) - return; - int posX = this.supertile.xCoord; - int posY = this.supertile.yCoord; - int posZ = this.supertile.zCoord; - World world = this.supertile.getWorldObj(); - if(world.getTotalWorldTime() % 1200 == 0) - checkNearDictarius(); - if(this.mana != this.getMaxMana() && cooldown == 0) { - List livs = world.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, (posX + 1), (posY + 1), (posZ + 1)).expand(2, 1, 2)); - int workMana = 0; - int villagers = 0; - if(!livs.isEmpty()) { - for(int i = 0; i < Math.min(livs.size(), 16); i++) { - EntityLivingBase liv = livs.get(i); - if(liv instanceof EntityPlayer) - workMana += SubTileDictarius.workMana; - else if(!world.isRemote && liv instanceof EntityVillager) { - workMana += (int)(SubTileDictarius.workMana / 6); - if(villagers > 15 && world.rand.nextInt(100) <= 4) - liv.setDead(); - villagers++; - } - } - } - if(workMana > 0) { - this.cooldown = 200; - workMana *= Math.random(); - this.mana = Math.min(this.getMaxMana(), this.mana + workMana); - sync(); - } - } - if(cooldown > 0) - cooldown -= 1; - } - - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), 2); - } - - public void checkNearDictarius() { - int findedFlower = 0; - for(int z = -4; z < 4; z++) { - for(int x = -4; x < 4; x++) { - for(int y = -4; y < 4; y++) { - int posX = this.supertile.xCoord + x; - int posY = this.supertile.yCoord + y; - int posZ = this.supertile.zCoord + z; - TileEntity tile = this.supertile.getWorldObj().getTileEntity(posX, posY, posZ); - if(tile != null && tile instanceof TileSpecialFlower) { - TileSpecialFlower tileFlower = (TileSpecialFlower)tile; - if(tileFlower.subTileName.equals("dictarius")) { - if(findedFlower >= ConfigABHandler.maxDictariusCount) { - this.supertile.getWorldObj().playAuxSFX(2001, this.supertile.xCoord, this.supertile.yCoord, this.supertile.zCoord, Block.getIdFromBlock(this.supertile.getBlockType())); - if(this.supertile.getWorldObj().getBlock(this.supertile.xCoord, this.supertile.yCoord - 1, this.supertile.zCoord).isSideSolid((IBlockAccess)this.supertile.getWorldObj(), this.supertile.xCoord, this.supertile.yCoord - 1, this.supertile.zCoord, ForgeDirection.UP)) - this.supertile.getWorldObj().setBlock(this.supertile.xCoord, this.supertile.yCoord, this.supertile.zCoord, (Block)Blocks.deadbush); - else - this.supertile.getWorldObj().setBlockToAir(this.supertile.xCoord, this.supertile.yCoord, this.supertile.zCoord); - return; - } - findedFlower++; - } - } - } - } - } - } - - public int getMaxMana() { - return 8000; - } - - public int getColor() { - return 0xd2cdb2; - } - - public LexiconEntry getEntry() { - return RecipeListAB.dictarius; - } - - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - cmp.setInteger("cooldown", this.cooldown); - } - - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - this.cooldown = cmp.getInteger("cooldown"); - } -} \ No newline at end of file + + private static final int workMana = 480; + int cooldown; + + public void onUpdate() { + super.onUpdate(); + if (this.supertile.getWorldObj().isRemote) return; + int posX = this.supertile.xCoord; + int posY = this.supertile.yCoord; + int posZ = this.supertile.zCoord; + World world = this.supertile.getWorldObj(); + if (world.getTotalWorldTime() % 1200 == 0) checkNearDictarius(); + if (this.mana != this.getMaxMana() && cooldown == 0) { + List livs = world.getEntitiesWithinAABB( + EntityLivingBase.class, + AxisAlignedBB.getBoundingBox(posX, posY, posZ, (posX + 1), (posY + 1), (posZ + 1)).expand(2, 1, 2)); + int workMana = 0; + int villagers = 0; + if (!livs.isEmpty()) { + for (int i = 0; i < Math.min(livs.size(), 16); i++) { + EntityLivingBase liv = livs.get(i); + if (liv instanceof EntityPlayer) workMana += SubTileDictarius.workMana; + else if (!world.isRemote && liv instanceof EntityVillager) { + workMana += (int) (SubTileDictarius.workMana / 6); + if (villagers > 15 && world.rand.nextInt(100) <= 4) liv.setDead(); + villagers++; + } + } + } + if (workMana > 0) { + this.cooldown = 200; + workMana *= Math.random(); + this.mana = Math.min(this.getMaxMana(), this.mana + workMana); + sync(); + } + } + if (cooldown > 0) cooldown -= 1; + } + + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), 2); + } + + public void checkNearDictarius() { + int findedFlower = 0; + for (int z = -4; z < 4; z++) { + for (int x = -4; x < 4; x++) { + for (int y = -4; y < 4; y++) { + int posX = this.supertile.xCoord + x; + int posY = this.supertile.yCoord + y; + int posZ = this.supertile.zCoord + z; + TileEntity tile = this.supertile.getWorldObj().getTileEntity(posX, posY, posZ); + if (tile != null && tile instanceof TileSpecialFlower) { + TileSpecialFlower tileFlower = (TileSpecialFlower) tile; + if (tileFlower.subTileName.equals("dictarius")) { + if (findedFlower >= ConfigABHandler.maxDictariusCount) { + this.supertile.getWorldObj().playAuxSFX( + 2001, + this.supertile.xCoord, + this.supertile.yCoord, + this.supertile.zCoord, + Block.getIdFromBlock(this.supertile.getBlockType())); + if (this.supertile.getWorldObj() + .getBlock( + this.supertile.xCoord, + this.supertile.yCoord - 1, + this.supertile.zCoord) + .isSideSolid( + (IBlockAccess) this.supertile.getWorldObj(), + this.supertile.xCoord, + this.supertile.yCoord - 1, + this.supertile.zCoord, + ForgeDirection.UP)) + this.supertile.getWorldObj().setBlock( + this.supertile.xCoord, + this.supertile.yCoord, + this.supertile.zCoord, + (Block) Blocks.deadbush); + else this.supertile.getWorldObj().setBlockToAir( + this.supertile.xCoord, + this.supertile.yCoord, + this.supertile.zCoord); + return; + } + findedFlower++; + } + } + } + } + } + } + + public int getMaxMana() { + return 8000; + } + + public int getColor() { + return 0xd2cdb2; + } + + public LexiconEntry getEntry() { + return RecipeListAB.dictarius; + } + + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + cmp.setInteger("cooldown", this.cooldown); + } + + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + this.cooldown = cmp.getInteger("cooldown"); + } +} diff --git a/src/main/java/ab/common/block/subtile/SubTilePureGladiolus.java b/src/main/java/ab/common/block/subtile/SubTilePureGladiolus.java index cfee5ae..43691bd 100644 --- a/src/main/java/ab/common/block/subtile/SubTilePureGladiolus.java +++ b/src/main/java/ab/common/block/subtile/SubTilePureGladiolus.java @@ -2,88 +2,93 @@ package ab.common.block.subtile; import java.util.List; -import ab.common.lib.register.RecipeListAB; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; + import thaumcraft.api.aspects.Aspect; import thaumcraft.common.entities.EntityAspectOrb; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.SubTileFunctional; -import vazkii.botania.common.Botania; import vazkii.botania.common.block.ModBlocks; +import ab.common.lib.register.RecipeListAB; public class SubTilePureGladiolus extends SubTileFunctional { - private static final int MAX_MANA = 10000; - private static final String COOLDOWN_TAG = "Cooldown"; - private static final Aspect[] PRIMALS = new Aspect[] { Aspect.AIR, Aspect.WATER, Aspect.EARTH, Aspect.ENTROPY, Aspect.ORDER, Aspect.FIRE }; + private static final int MAX_MANA = 10000; + private static final String COOLDOWN_TAG = "Cooldown"; + private static final Aspect[] PRIMALS = new Aspect[] { Aspect.AIR, Aspect.WATER, Aspect.EARTH, Aspect.ENTROPY, + Aspect.ORDER, Aspect.FIRE }; - private int cooldown = 180; - protected static int manaRequare = 1000; + private int cooldown = 180; + protected static int manaRequare = 1000; - public void onUpdate() { - super.onUpdate(); - int tick = 1; - World world = this.supertile.getWorldObj(); - int x = this.supertile.xCoord; - int y = this.supertile.yCoord; - int z = this.supertile.zCoord; - List players = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, (x + 1), (y + 1), (z + 1)).expand(1.9f, 1.2f, 1.9f)); - if(world.getBlock(x, y + 1, z).getMaterial() != Material.air) - return; - else if(world.getBlock(x, y - 1, z) == ModBlocks.enchantedSoil) - tick = 2; - if(players.isEmpty()) - return; - if(cooldown > 0) - cooldown -= tick; - else if(mana >= manaRequare && cooldown <= 0) { - mana -= manaRequare; - cooldown = 180; - spawnAspectOrbs(world, x + 0.5, y + 1.0, z + 0.5); - } - } - - public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(toChunkCoordinates(), 1); - } - - public LexiconEntry getEntry() { - return RecipeListAB.gladious; - } + public void onUpdate() { + super.onUpdate(); + int tick = 1; + World world = this.supertile.getWorldObj(); + int x = this.supertile.xCoord; + int y = this.supertile.yCoord; + int z = this.supertile.zCoord; + List players = world.getEntitiesWithinAABB( + EntityPlayer.class, + AxisAlignedBB.getBoundingBox(x, y, z, (x + 1), (y + 1), (z + 1)).expand(1.9f, 1.2f, 1.9f)); + if (world.getBlock(x, y + 1, z).getMaterial() != Material.air) return; + else if (world.getBlock(x, y - 1, z) == ModBlocks.enchantedSoil) tick = 2; + if (players.isEmpty()) return; + if (cooldown > 0) cooldown -= tick; + else if (mana >= manaRequare && cooldown <= 0) { + mana -= manaRequare; + cooldown = 180; + spawnAspectOrbs(world, x + 0.5, y + 1.0, z + 0.5); + } + } - public void spawnAspectOrbs(World world, double x, double y, double z) { - if(!world.isRemote) { - for (int i = 0; i < 3 + world.rand.nextInt(3); i++) { - EntityAspectOrb orb = new EntityAspectOrb(world, x, y, z, PRIMALS[world.rand.nextInt(6)], 2 + world.rand.nextInt(3)); - orb.motionX = 0.05 - Math.random() * 0.1; - orb.motionY = 0.07; - orb.motionZ = 0.05 - Math.random() * 0.1; - world.spawnEntityInWorld(orb); - } - this.sync(); - } - } + public RadiusDescriptor getRadius() { + return new RadiusDescriptor.Square(toChunkCoordinates(), 1); + } - public int getColor() { - return 0xFF00FF; - } + public LexiconEntry getEntry() { + return RecipeListAB.gladious; + } - public int getMaxMana() { - return MAX_MANA; - } + public void spawnAspectOrbs(World world, double x, double y, double z) { + if (!world.isRemote) { + for (int i = 0; i < 3 + world.rand.nextInt(3); i++) { + EntityAspectOrb orb = new EntityAspectOrb( + world, + x, + y, + z, + PRIMALS[world.rand.nextInt(6)], + 2 + world.rand.nextInt(3)); + orb.motionX = 0.05 - Math.random() * 0.1; + orb.motionY = 0.07; + orb.motionZ = 0.05 - Math.random() * 0.1; + world.spawnEntityInWorld(orb); + } + this.sync(); + } + } - public void writeToPacketNBT(NBTTagCompound cmp) { - super.writeToPacketNBT(cmp); - cmp.setInteger(COOLDOWN_TAG, this.cooldown); - } + public int getColor() { + return 0xFF00FF; + } - public void readFromPacketNBT(NBTTagCompound cmp) { - super.readFromPacketNBT(cmp); - this.cooldown = cmp.getInteger(COOLDOWN_TAG); - } -} \ No newline at end of file + public int getMaxMana() { + return MAX_MANA; + } + + public void writeToPacketNBT(NBTTagCompound cmp) { + super.writeToPacketNBT(cmp); + cmp.setInteger(COOLDOWN_TAG, this.cooldown); + } + + public void readFromPacketNBT(NBTTagCompound cmp) { + super.readFromPacketNBT(cmp); + this.cooldown = cmp.getInteger(COOLDOWN_TAG); + } +} diff --git a/src/main/java/ab/common/block/tile/TileABSpreader.java b/src/main/java/ab/common/block/tile/TileABSpreader.java index 103a888..b98d16e 100644 --- a/src/main/java/ab/common/block/tile/TileABSpreader.java +++ b/src/main/java/ab/common/block/tile/TileABSpreader.java @@ -1,122 +1,130 @@ package ab.common.block.tile; -import java.util.UUID; - -import org.lwjgl.opengl.GL11; - -import ab.common.core.handler.ConfigABHandler; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.StatCollector; -import vazkii.botania.api.internal.IManaBurst; + +import org.lwjgl.opengl.GL11; + import vazkii.botania.api.mana.BurstProperties; import vazkii.botania.api.mana.ILensEffect; import vazkii.botania.api.mana.IManaReceiver; import vazkii.botania.client.core.handler.HUDHandler; import vazkii.botania.common.block.tile.mana.TileSpreader; import vazkii.botania.common.entity.EntityManaBurst; +import ab.common.core.handler.ConfigABHandler; public class TileABSpreader extends TileSpreader { - - protected boolean requestsClientUpdate = false; - protected int knownMana = -1; - protected IManaReceiver receiver = null; - - public void readCustomNBT(NBTTagCompound cmp) { - super.readCustomNBT(cmp); - this.requestsClientUpdate = cmp.getBoolean("requestUpdate"); - if(cmp.hasKey("knownMana")) - this.knownMana = cmp.getInteger("knownMana"); - if(this.requestsClientUpdate && this.worldObj != null) { - int x = cmp.getInteger("forceClientBindingX"); - int y = cmp.getInteger("forceClientBindingY"); - int z = cmp.getInteger("forceClientBindingZ"); - if(y != -1) { - TileEntity tile = this.worldObj.getTileEntity(x, y, z); - if(tile instanceof IManaReceiver) { - this.receiver = (IManaReceiver)tile; - } else { - this.receiver = null; - } - } else { - this.receiver = null; - } - } - } - - public EntityManaBurst getBurst(boolean fake) { - EntityManaBurst burst = new EntityManaBurst(this, fake); - int maxMana = ConfigABHandler.spreaderBurstMana; - int color = 0xcdd419; - int ticksBeforeManaLoss = 35; - float manaLossPerTick = ConfigABHandler.spreaderBurstMana / 4.5f; - float motionModifier = 2.5f; - float gravity = 0.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) { - 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; - } - + + protected boolean requestsClientUpdate = false; + protected int knownMana = -1; + protected IManaReceiver receiver = null; + + public void readCustomNBT(NBTTagCompound cmp) { + super.readCustomNBT(cmp); + this.requestsClientUpdate = cmp.getBoolean("requestUpdate"); + if (cmp.hasKey("knownMana")) this.knownMana = cmp.getInteger("knownMana"); + if (this.requestsClientUpdate && this.worldObj != null) { + int x = cmp.getInteger("forceClientBindingX"); + int y = cmp.getInteger("forceClientBindingY"); + int z = cmp.getInteger("forceClientBindingZ"); + if (y != -1) { + TileEntity tile = this.worldObj.getTileEntity(x, y, z); + if (tile instanceof IManaReceiver) { + this.receiver = (IManaReceiver) tile; + } else { + this.receiver = null; + } + } else { + this.receiver = null; + } + } + } + + public EntityManaBurst getBurst(boolean fake) { + EntityManaBurst burst = new EntityManaBurst(this, fake); + int maxMana = ConfigABHandler.spreaderBurstMana; + int color = 0xcdd419; + int ticksBeforeManaLoss = 35; + float manaLossPerTick = ConfigABHandler.spreaderBurstMana / 4.5f; + float motionModifier = 2.5f; + float gravity = 0.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) { + 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 void renderHUD(Minecraft mc, ScaledResolution res) { - String name = StatCollector.translateToLocal("tile.advancedSpreader.name"); + String name = StatCollector.translateToLocal("tile.advancedSpreader.name"); int color = 0xcdd419; HUDHandler.drawSimpleManaHUD(color, this.knownMana, getMaxMana(), name, res); ItemStack lens = getStackInSlot(0); - if(lens != null) { - GL11.glEnable(3042); - GL11.glBlendFunc(770, 771); - 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(2896); - GL11.glDisable(3042); - } - if(this.receiver != null) { - TileEntity receiverTile = (TileEntity)this.receiver; - ItemStack recieverStack = new ItemStack(this.worldObj.getBlock(receiverTile.xCoord, receiverTile.yCoord, receiverTile.zCoord), 1, receiverTile.getBlockMetadata()); - GL11.glEnable(3042); - GL11.glBlendFunc(770, 771); - 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(2896); - GL11.glDisable(3042); - } + if (lens != null) { + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + 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(2896); + GL11.glDisable(3042); + } + if (this.receiver != null) { + TileEntity receiverTile = (TileEntity) this.receiver; + ItemStack recieverStack = new ItemStack( + this.worldObj.getBlock(receiverTile.xCoord, receiverTile.yCoord, receiverTile.zCoord), + 1, + receiverTile.getBlockMetadata()); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + 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(2896); + GL11.glDisable(3042); + } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } - - public int getMaxMana() { + + public int getMaxMana() { return ConfigABHandler.spreaderMaxMana; } -} \ No newline at end of file +} diff --git a/src/main/java/ab/common/block/tile/TileBoardFate.java b/src/main/java/ab/common/block/tile/TileBoardFate.java index 48fcc04..09d7439 100644 --- a/src/main/java/ab/common/block/tile/TileBoardFate.java +++ b/src/main/java/ab/common/block/tile/TileBoardFate.java @@ -2,8 +2,6 @@ package ab.common.block.tile; import java.util.List; -import ab.api.AdvancedBotanyAPI; -import ab.common.core.handler.ConfigABHandler; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -14,156 +12,164 @@ import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.ChatStyle; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.Vec3; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.item.IRelic; -import vazkii.botania.common.item.relic.ItemDice; import vazkii.botania.common.item.relic.ItemRelic; +import ab.api.AdvancedBotanyAPI; +import ab.common.core.handler.ConfigABHandler; public class TileBoardFate extends TileInventory { - - public byte[] slotChance = new byte[getSizeInventory()]; - public int clientTick[] = new int[] { 0, 0, 0, 0 }; - public boolean requestUpdate; - - public void updateEntity() { - if(!worldObj.isRemote) - updateServer(); - else - updateAnimationTicks(); - } - - public void updateAnimationTicks() { - for(int i = 0; i < getSizeInventory(); i++) - if(getStackInSlot(i) != null) - clientTick[i]++; - else - clientTick[i] = 0; - } - - protected void updateServer() { - if(requestUpdate) - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord); - boolean hasUpdate = false; - if(hasFreeSlot()) - hasUpdate = setDiceFate(); - requestUpdate = hasUpdate; - } - - public boolean spawnRelic(EntityPlayer player) { - int relicCount = 0; - for(int i = 0; i < getSizeInventory(); i++) { - if(getStackInSlot(i) == null) - slotChance[i] = 0; - else if(!ItemRelic.isRightPlayer(player, getStackInSlot(i))) { - if(!worldObj.isRemote) - dropRelic(player, i); - return true; - } - else - setInventorySlotContents(i, null); - relicCount += slotChance[i]; - } - if(relicCount < 1) - return false; - else if(!worldObj.isRemote) { - ItemStack relic = AdvancedBotanyAPI.relicList.get(Math.min(relicCount - 1, AdvancedBotanyAPI.relicList.size() - 1)).copy(); - worldObj.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (worldObj.rand.nextFloat() * 0.4F + 0.8F)); - if(hasRelicAchievement(player, relic) || !ConfigABHandler.fateBoardRelicEnables[relicCount - 1]) { - player.addChatMessage((new ChatComponentTranslation("botaniamisc.dudDiceRoll", new Object[] { Integer.valueOf(relicCount) })).setChatStyle((new ChatStyle()).setColor(EnumChatFormatting.DARK_GREEN))); - } else { - ItemRelic.updateRelic(relic, player); - EntityItem entityItem = new EntityItem(worldObj, xCoord + 0.5f, yCoord + 0.5f, zCoord + 0.5f, relic); - player.addChatMessage((new ChatComponentTranslation("botaniamisc.diceRoll", new Object[] { Integer.valueOf(relicCount) })).setChatStyle((new ChatStyle()).setColor(EnumChatFormatting.DARK_GREEN))); - worldObj.spawnEntityInWorld(entityItem); - } - requestUpdate = true; - } - return true; - } - - private void dropRelic(EntityPlayer player, int slot) { - EntityItem entityItem = new EntityItem(worldObj, xCoord + 0.5f, yCoord + 0.8f, zCoord + 0.5f, getStackInSlot(slot).copy()); - float f3 = 0.15F; - Vec3 vec = player.getLookVec(); - entityItem.motionX = vec.xCoord * f3; - entityItem.motionY = 0.25F; - entityItem.motionZ = vec.zCoord * f3; - setInventorySlotContents(slot, null); - worldObj.spawnEntityInWorld(entityItem); - } - - public static boolean hasRelicAchievement(EntityPlayer player, ItemStack rStack) { - EntityPlayerMP mpPlayer = (EntityPlayerMP)player; - IRelic irelic = (IRelic)rStack.getItem(); - if(irelic.getBindAchievement() == null) - return false; - return mpPlayer.func_147099_x().hasAchievementUnlocked(irelic.getBindAchievement()); - } - - protected boolean hasFreeSlot() { - for(int i = 0; i < getSizeInventory(); i++) - if(getStackInSlot(i) == null) - return true; - return false; - } - - protected boolean setDiceFate() { - boolean hasUpdate = false; - List items = this.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord, this.zCoord, (this.xCoord + 1), (this.yCoord + 0.7f), (this.zCoord + 1))); - label666: for(EntityItem item : items) { - if(!item.isDead && item.getEntityItem() != null) { - ItemStack stack = item.getEntityItem(); - if(!isDice(stack)) - continue; - for(int s = 0; s < getSizeInventory(); s++) { - ItemStack slotStack = getStackInSlot(s); - if(slotStack != null) - continue; - ItemStack copy = stack.copy(); - copy.stackSize = 1; - setInventorySlotContents(s, copy); - slotChance[s] = (byte)(worldObj.rand.nextInt(6) + 1); - stack.stackSize--; - if(stack.stackSize == 0) - item.setDead(); - hasUpdate = true; - worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "ab:boardCube", 0.6F, 1.0F); - break label666; - } - } - } - return hasUpdate; - } - - public static boolean isDice(ItemStack stack) { - for(ItemStack dice : AdvancedBotanyAPI.diceList) { - if(dice.getItem() == stack.getItem() && (dice.getItemDamage() == stack.getItemDamage() || dice.getItemDamage() == 32767)) - return true; - } - return false; - } - - public void writeCustomNBT(NBTTagCompound cmp) { - super.writeCustomNBT(cmp); - cmp.setByteArray("slotChance", slotChance); - cmp.setBoolean("requestUpdate", requestUpdate); - } - - public void readCustomNBT(NBTTagCompound cmp) { - super.readCustomNBT(cmp); - slotChance = cmp.getByteArray("slotChance"); - requestUpdate = cmp.getBoolean("requestUpdate"); - } - public int getInventoryStackLimit() { - return 1; - } + public byte[] slotChance = new byte[getSizeInventory()]; + public int clientTick[] = new int[] { 0, 0, 0, 0 }; + public boolean requestUpdate; - public String getInventoryName() { - return "inv.boardFate"; - } + public void updateEntity() { + if (!worldObj.isRemote) updateServer(); + else updateAnimationTicks(); + } - public int getSizeInventory() { - return 2; - } -} \ No newline at end of file + public void updateAnimationTicks() { + for (int i = 0; i < getSizeInventory(); i++) if (getStackInSlot(i) != null) clientTick[i]++; + else clientTick[i] = 0; + } + + protected void updateServer() { + if (requestUpdate) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord); + boolean hasUpdate = false; + if (hasFreeSlot()) hasUpdate = setDiceFate(); + requestUpdate = hasUpdate; + } + + public boolean spawnRelic(EntityPlayer player) { + int relicCount = 0; + for (int i = 0; i < getSizeInventory(); i++) { + if (getStackInSlot(i) == null) slotChance[i] = 0; + else if (!ItemRelic.isRightPlayer(player, getStackInSlot(i))) { + if (!worldObj.isRemote) dropRelic(player, i); + return true; + } else setInventorySlotContents(i, null); + relicCount += slotChance[i]; + } + if (relicCount < 1) return false; + else if (!worldObj.isRemote) { + ItemStack relic = AdvancedBotanyAPI.relicList + .get(Math.min(relicCount - 1, AdvancedBotanyAPI.relicList.size() - 1)).copy(); + worldObj.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (worldObj.rand.nextFloat() * 0.4F + 0.8F)); + if (hasRelicAchievement(player, relic) || !ConfigABHandler.fateBoardRelicEnables[relicCount - 1]) { + player.addChatMessage( + (new ChatComponentTranslation( + "botaniamisc.dudDiceRoll", + new Object[] { Integer.valueOf(relicCount) })) + .setChatStyle((new ChatStyle()).setColor(EnumChatFormatting.DARK_GREEN))); + } else { + ItemRelic.updateRelic(relic, player); + EntityItem entityItem = new EntityItem(worldObj, xCoord + 0.5f, yCoord + 0.5f, zCoord + 0.5f, relic); + player.addChatMessage( + (new ChatComponentTranslation( + "botaniamisc.diceRoll", + new Object[] { Integer.valueOf(relicCount) })) + .setChatStyle((new ChatStyle()).setColor(EnumChatFormatting.DARK_GREEN))); + worldObj.spawnEntityInWorld(entityItem); + } + requestUpdate = true; + } + return true; + } + + private void dropRelic(EntityPlayer player, int slot) { + EntityItem entityItem = new EntityItem( + worldObj, + xCoord + 0.5f, + yCoord + 0.8f, + zCoord + 0.5f, + getStackInSlot(slot).copy()); + float f3 = 0.15F; + Vec3 vec = player.getLookVec(); + entityItem.motionX = vec.xCoord * f3; + entityItem.motionY = 0.25F; + entityItem.motionZ = vec.zCoord * f3; + setInventorySlotContents(slot, null); + worldObj.spawnEntityInWorld(entityItem); + } + + public static boolean hasRelicAchievement(EntityPlayer player, ItemStack rStack) { + EntityPlayerMP mpPlayer = (EntityPlayerMP) player; + IRelic irelic = (IRelic) rStack.getItem(); + if (irelic.getBindAchievement() == null) return false; + return mpPlayer.func_147099_x().hasAchievementUnlocked(irelic.getBindAchievement()); + } + + protected boolean hasFreeSlot() { + for (int i = 0; i < getSizeInventory(); i++) if (getStackInSlot(i) == null) return true; + return false; + } + + protected boolean setDiceFate() { + boolean hasUpdate = false; + List items = this.worldObj.getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox( + this.xCoord, + this.yCoord, + this.zCoord, + (this.xCoord + 1), + (this.yCoord + 0.7f), + (this.zCoord + 1))); + label666: for (EntityItem item : items) { + if (!item.isDead && item.getEntityItem() != null) { + ItemStack stack = item.getEntityItem(); + if (!isDice(stack)) continue; + for (int s = 0; s < getSizeInventory(); s++) { + ItemStack slotStack = getStackInSlot(s); + if (slotStack != null) continue; + ItemStack copy = stack.copy(); + copy.stackSize = 1; + setInventorySlotContents(s, copy); + slotChance[s] = (byte) (worldObj.rand.nextInt(6) + 1); + stack.stackSize--; + if (stack.stackSize == 0) item.setDead(); + hasUpdate = true; + worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "ab:boardCube", 0.6F, 1.0F); + break label666; + } + } + } + return hasUpdate; + } + + public static boolean isDice(ItemStack stack) { + for (ItemStack dice : AdvancedBotanyAPI.diceList) { + if (dice.getItem() == stack.getItem() + && (dice.getItemDamage() == stack.getItemDamage() || dice.getItemDamage() == 32767)) + return true; + } + return false; + } + + public void writeCustomNBT(NBTTagCompound cmp) { + super.writeCustomNBT(cmp); + cmp.setByteArray("slotChance", slotChance); + cmp.setBoolean("requestUpdate", requestUpdate); + } + + public void readCustomNBT(NBTTagCompound cmp) { + super.readCustomNBT(cmp); + slotChance = cmp.getByteArray("slotChance"); + requestUpdate = cmp.getBoolean("requestUpdate"); + } + + public int getInventoryStackLimit() { + return 1; + } + + public String getInventoryName() { + return "inv.boardFate"; + } + + public int getSizeInventory() { + return 2; + } +} diff --git a/src/main/java/ab/common/block/tile/TileEngineerHopper.java b/src/main/java/ab/common/block/tile/TileEngineerHopper.java index dcc18b5..8079b6b 100644 --- a/src/main/java/ab/common/block/tile/TileEngineerHopper.java +++ b/src/main/java/ab/common/block/tile/TileEngineerHopper.java @@ -1,333 +1,320 @@ package ab.common.block.tile; -import java.util.List; - -import org.lwjgl.opengl.GL11; - -import ab.api.IBoundRender; -import ab.client.core.ClientHelper; import net.minecraft.block.Block; -import net.minecraft.block.BlockChest; -import net.minecraft.block.BlockHopper; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.command.IEntitySelector; -import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.IHopper; import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityChest; import net.minecraft.tileentity.TileEntityHopper; -import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChunkCoordinates; -import net.minecraft.util.Facing; -import net.minecraft.util.MathHelper; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import vazkii.botania.api.wand.IWandBindable; -import vazkii.botania.client.core.handler.HUDHandler; -import vazkii.botania.common.core.helper.Vector3; + +import org.lwjgl.opengl.GL11; + import vazkii.botania.common.item.ModItems; +import ab.api.IBoundRender; +import ab.client.core.ClientHelper; public class TileEngineerHopper extends TileInventory implements IHopper, IBoundRender { - private int cooldown; - private int[] invPosX = new int[] {0, 0}; - private int[] invPosY = new int[] {-1, -1}; - private int[] invPosZ = new int[] {0, 0}; - private int[] invSide = new int[] {-1, -1}; - private boolean bindType; - public int redstoneSignal = 0; - - public void updateEntity() { + private int cooldown; + private int[] invPosX = new int[] { 0, 0 }; + private int[] invPosY = new int[] { -1, -1 }; + private int[] invPosZ = new int[] { 0, 0 }; + private int[] invSide = new int[] { -1, -1 }; + private boolean bindType; + public int redstoneSignal = 0; + + public void updateEntity() { this.redstoneSignal = 0; - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - int redstoneSide = getWorldObj().getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal()); - this.redstoneSignal = Math.max(this.redstoneSignal, redstoneSide); - } - if(redstoneSignal > 0) - return; - else if(this.worldObj != null) { - if(!this.worldObj.isRemote) { - if(cooldown > 0) - --cooldown; - else if(cooldown == 0) { - if(worldObj != null && !worldObj.isRemote) { - boolean hasUpdate = false; - ItemStack stack = getStackInSlot(0); - if(stack != null) - hasUpdate = canExtractStack(); - if(stack == null || stack.stackSize != stack.getMaxStackSize()) - hasUpdate = canInsertStack() || hasUpdate; - if(hasUpdate) - this.cooldown = 8; - this.markDirty(); + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int redstoneSide = getWorldObj().getIndirectPowerLevelTo( + xCoord + dir.offsetX, + yCoord + dir.offsetY, + zCoord + dir.offsetZ, + dir.ordinal()); + this.redstoneSignal = Math.max(this.redstoneSignal, redstoneSide); + } + if (redstoneSignal > 0) return; + else if (this.worldObj != null) { + if (!this.worldObj.isRemote) { + if (cooldown > 0) --cooldown; + else if (cooldown == 0) { + if (worldObj != null && !worldObj.isRemote) { + boolean hasUpdate = false; + ItemStack stack = getStackInSlot(0); + if (stack != null) hasUpdate = canExtractStack(); + if (stack == null || stack.stackSize != stack.getMaxStackSize()) + hasUpdate = canInsertStack() || hasUpdate; + if (hasUpdate) this.cooldown = 8; + this.markDirty(); } } - } + } } - } - - public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - TileEntity tile = player.getEntityWorld().getTileEntity(x, y, z); - boolean isFar = Math.abs(this.xCoord - x) >= 10 || Math.abs(this.yCoord - y) >= 10 || Math.abs(this.zCoord - z) >= 10; - if(isFar) - return false; - int invCount = bindType ? 0 : 1; - if(tile instanceof TileEngineerHopper) - return false; - else if(tile != null && tile instanceof IInventory) { - setDistantInventory(invCount, x, y, z); - invSide[invCount] = side; - return true; - } else { - setDistantInventory(invCount, 0, -1, 0); - invSide[invCount] = -1; - return false; - } - } - - public void changeBindType() { - bindType = !bindType; - } - - public void setDistantInventory(int count, int posX, int posY, int posZ) { - invPosX[count] = posX; - invPosY[count] = posY; - invPosZ[count] = posZ; - } - - public IInventory getDistantInventory(int count) { - IInventory inv = TileEntityHopper.func_145893_b(this.getWorldObj(), invPosX[count], invPosY[count], invPosZ[count]); - if(inv == null) - setDistantInventory(count, 0, -1, 0); - return inv; - } - - public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - return true; - } - - public ChunkCoordinates[] getBlocksCoord() { - return new ChunkCoordinates[] { new ChunkCoordinates(invPosX[0], invPosY[0], invPosZ[0]), new ChunkCoordinates(invPosX[1], invPosY[1], invPosZ[1]) }; - } - - public ChunkCoordinates getBinding() { - return null; - } - - public void renderHUD(Minecraft mc, ScaledResolution res) { - int x = res.getScaledWidth() / 2 - 7; - int y = res.getScaledHeight() / 2 + 16; - GL11.glEnable(3042); - GL11.glBlendFunc(770, 771); - ClientHelper.drawArrow(x - 2, y, false); - for(int i = 0; i < 2; i++) { - ItemStack stack = null; - boolean hasInv = false; - int posX = x + (i == 0 ? 32 : -32); - if(getDistantInventory(i) != null && (TileEntity)getDistantInventory(i) != null) { - TileEntity tile = (TileEntity)getDistantInventory(i); - Block block = tile.getWorldObj().getBlock(tile.xCoord, tile.yCoord, tile.zCoord); - int meta = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord); - stack = new ItemStack(block, 1, meta); - hasInv = true; - } - Gui.drawRect(posX - 4, y - 4, posX + 20, y + 20, 1140850688); - Gui.drawRect(posX - 2, y - 2, posX + 18, y + 18, 1140850688); - if(stack != null) { - RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(32826); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, posX, y); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(2929); - } - int invCount = bindType ? 0 : 1; - if(invCount == i) { - GL11.glTranslatef(0.0f, 0.0f, 300.0f); - RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(32826); - RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModItems.twigWand), posX + 10, y + 7); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(2929); - GL11.glTranslatef(0.0f, 0.0f, -300.0f); - } - boolean unicode = mc.fontRenderer.getUnicodeFlag(); - mc.fontRenderer.setUnicodeFlag(true); - if(!hasInv) { - mc.fontRenderer.drawStringWithShadow("\u2717", posX + 5, y + 6, 4980736); - mc.fontRenderer.drawStringWithShadow("\u2717", posX + 5, y + 5, 13764621); - } - mc.fontRenderer.setUnicodeFlag(unicode); - GL11.glEnable(2929); - } - GL11.glDisable(3042); - } - - public void writeCustomNBT(NBTTagCompound nbtt) { - super.writeCustomNBT(nbtt); - nbtt.setInteger("cooldown", this.cooldown); - nbtt.setBoolean("bindType", this.bindType); - nbtt.setIntArray("bindingX", this.invPosX); - nbtt.setIntArray("bindingY", this.invPosY); - nbtt.setIntArray("bindingZ", this.invPosZ); - nbtt.setIntArray("bindingSide", this.invSide); - } - - public void readCustomNBT(NBTTagCompound nbtt) { - super.readCustomNBT(nbtt); - this.cooldown = nbtt.getInteger("cooldown"); - this.bindType = nbtt.getBoolean("bindType"); - this.invPosX = nbtt.getIntArray("bindingX"); - this.invPosY = nbtt.getIntArray("bindingY"); - this.invPosZ = nbtt.getIntArray("bindingZ"); - this.invSide = nbtt.getIntArray("bindingSide"); - } - - private boolean canExtractStack() { - IInventory inv = getDistantInventory(0); - if(inv == null) - return false; - else { - int side = invSide[0]; - int pullCount = getPullCount(inv, side); - System.out.println("canExtractStack " + pullCount); - if(pullCount <= 0) - return false; - else { - if(getStackInSlot(0) != null) { - ItemStack itemstack = getStackInSlot(0).copy(); - ItemStack itemstack1 = TileEntityHopper.func_145889_a(inv, decrStackSize(0, pullCount), side); - if(itemstack1 == null || itemstack1.stackSize == 0) { - inv.markDirty(); - return true; - } - setInventorySlotContents(0, itemstack); - } - return false; - } - } - } + } - private int getPullCount(IInventory inv, int side) { - if(inv instanceof ISidedInventory && side > -1) { - ISidedInventory sideInv = (ISidedInventory)inv; - int[] slots = sideInv.getAccessibleSlotsFromSide(side); - for(int i = 0; i < slots.length; ++i) { - ItemStack stack = sideInv.getStackInSlot(slots[i]); - if(stack == null) - return inv.getInventoryStackLimit(); - else if(inv.getInventoryStackLimit() != stack.stackSize && stack.stackSize != stack.getMaxStackSize() && TileNidavellirForge.isItemEqual(stack, getStackInSlot(0))) - return inv.getInventoryStackLimit() - stack.stackSize; - } - } else { - int size = inv.getSizeInventory(); - for(int i = 0; i < size; ++i) { - ItemStack stack = inv.getStackInSlot(i); - if(stack == null) - return inv.getInventoryStackLimit(); - else if(inv.getInventoryStackLimit() != stack.stackSize && stack.stackSize != stack.getMaxStackSize() && TileNidavellirForge.isItemEqual(stack, getStackInSlot(0))) - return inv.getInventoryStackLimit() - stack.stackSize; - } - } - return 0; - } + public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + TileEntity tile = player.getEntityWorld().getTileEntity(x, y, z); + boolean isFar = Math.abs(this.xCoord - x) >= 10 || Math.abs(this.yCoord - y) >= 10 + || Math.abs(this.zCoord - z) >= 10; + if (isFar) return false; + int invCount = bindType ? 0 : 1; + if (tile instanceof TileEngineerHopper) return false; + else if (tile != null && tile instanceof IInventory) { + setDistantInventory(invCount, x, y, z); + invSide[invCount] = side; + return true; + } else { + setDistantInventory(invCount, 0, -1, 0); + invSide[invCount] = -1; + return false; + } + } - private boolean canInsertStack() { - IInventory inv = getDistantInventory(1); - if(inv != null) { - int side = invSide[1]; - int takeCount = getTakeCount(inv, side); - System.out.println("canInsertStack " + takeCount); - if(takeCount <= 0) - return false; - if(inv instanceof ISidedInventory && side > -1) { - ISidedInventory sidedInv = (ISidedInventory)inv; - int[] slots = sidedInv.getAccessibleSlotsFromSide(side); - for(int k = 0; k < slots.length; ++k) { - if(func_145892_a(inv, slots[k], side, takeCount)) - return true; - } - } else { - int i = inv.getSizeInventory(); - for(int j = 0; j < i; ++j) { - if(func_145892_a(inv, j, side, takeCount)) - return true; - } - } - } - return false; - } + public void changeBindType() { + bindType = !bindType; + } - private int getTakeCount(IInventory inv, int side) { - if(inv instanceof ISidedInventory && side > -1) { - ISidedInventory sideInv = (ISidedInventory)inv; - int[] slots = sideInv.getAccessibleSlotsFromSide(side); - for(int i = 0; i < slots.length; ++i) { - ItemStack stack = sideInv.getStackInSlot(slots[i]); - if(stack != null) - if(getStackInSlot(0) == null) - return Math.min(stack.getMaxStackSize(), getInventoryStackLimit()); - else if(getInventoryStackLimit() != getStackInSlot(0).stackSize && getStackInSlot(0).stackSize != getStackInSlot(0).getMaxStackSize() && TileNidavellirForge.isItemEqual(stack, getStackInSlot(0))) - return getInventoryStackLimit() - getStackInSlot(0).stackSize; - } - } else { - for(int i = 0; i < inv.getSizeInventory(); ++i) { - ItemStack stack = inv.getStackInSlot(i); - if(stack != null) - if(getStackInSlot(0) == null) - return Math.min(stack.getMaxStackSize(), getInventoryStackLimit()); - else if(getInventoryStackLimit() != getStackInSlot(0).stackSize && getStackInSlot(0).stackSize != getStackInSlot(0).getMaxStackSize() && TileNidavellirForge.isItemEqual(stack, getStackInSlot(0))) - return getInventoryStackLimit() - getStackInSlot(0).stackSize; - } - } - return 0; - } + public void setDistantInventory(int count, int posX, int posY, int posZ) { + invPosX[count] = posX; + invPosY[count] = posY; + invPosZ[count] = posZ; + } - private boolean func_145892_a(IInventory inv, int slot, int side, int takeCount) { - ItemStack itemstack = inv.getStackInSlot(slot); - if(itemstack != null && func_145890_b(inv, itemstack, slot, side)) { - ItemStack itemstack1 = itemstack.copy(); - ItemStack itemstack2 = TileEntityHopper.func_145889_a(this, inv.decrStackSize(slot, takeCount), side); - if(itemstack2 == null || itemstack2.stackSize == 0) { - inv.markDirty(); - return true; - } - inv.setInventorySlotContents(slot, itemstack1); - } - return false; - } - - private static boolean func_145890_b(IInventory inv, ItemStack stack, int slot, int side) { - return !(inv instanceof ISidedInventory) || ((ISidedInventory)inv).canExtractItem(slot, stack, side); - } - - public int getSizeInventory() { - return 1; - } + public IInventory getDistantInventory(int count) { + IInventory inv = TileEntityHopper + .func_145893_b(this.getWorldObj(), invPosX[count], invPosY[count], invPosZ[count]); + if (inv == null) setDistantInventory(count, 0, -1, 0); + return inv; + } - public String getInventoryName() { - return "engineerHopper"; - } + public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + return true; + } - public double getXPos() { - return this.xCoord; - } + public ChunkCoordinates[] getBlocksCoord() { + return new ChunkCoordinates[] { new ChunkCoordinates(invPosX[0], invPosY[0], invPosZ[0]), + new ChunkCoordinates(invPosX[1], invPosY[1], invPosZ[1]) }; + } - public double getYPos() { - return this.yCoord; - } + public ChunkCoordinates getBinding() { + return null; + } - public double getZPos() { - return this.zCoord; - } -} \ No newline at end of file + public void renderHUD(Minecraft mc, ScaledResolution res) { + int x = res.getScaledWidth() / 2 - 7; + int y = res.getScaledHeight() / 2 + 16; + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + ClientHelper.drawArrow(x - 2, y, false); + for (int i = 0; i < 2; i++) { + ItemStack stack = null; + boolean hasInv = false; + int posX = x + (i == 0 ? 32 : -32); + if (getDistantInventory(i) != null && (TileEntity) getDistantInventory(i) != null) { + TileEntity tile = (TileEntity) getDistantInventory(i); + Block block = tile.getWorldObj().getBlock(tile.xCoord, tile.yCoord, tile.zCoord); + int meta = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord); + stack = new ItemStack(block, 1, meta); + hasInv = true; + } + Gui.drawRect(posX - 4, y - 4, posX + 20, y + 20, 1140850688); + Gui.drawRect(posX - 2, y - 2, posX + 18, y + 18, 1140850688); + if (stack != null) { + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(32826); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, posX, y); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(2929); + } + int invCount = bindType ? 0 : 1; + if (invCount == i) { + GL11.glTranslatef(0.0f, 0.0f, 300.0f); + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(32826); + RenderItem.getInstance().renderItemIntoGUI( + mc.fontRenderer, + mc.renderEngine, + new ItemStack(ModItems.twigWand), + posX + 10, + y + 7); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(2929); + GL11.glTranslatef(0.0f, 0.0f, -300.0f); + } + boolean unicode = mc.fontRenderer.getUnicodeFlag(); + mc.fontRenderer.setUnicodeFlag(true); + if (!hasInv) { + mc.fontRenderer.drawStringWithShadow("\u2717", posX + 5, y + 6, 4980736); + mc.fontRenderer.drawStringWithShadow("\u2717", posX + 5, y + 5, 13764621); + } + mc.fontRenderer.setUnicodeFlag(unicode); + GL11.glEnable(2929); + } + GL11.glDisable(3042); + } + + public void writeCustomNBT(NBTTagCompound nbtt) { + super.writeCustomNBT(nbtt); + nbtt.setInteger("cooldown", this.cooldown); + nbtt.setBoolean("bindType", this.bindType); + nbtt.setIntArray("bindingX", this.invPosX); + nbtt.setIntArray("bindingY", this.invPosY); + nbtt.setIntArray("bindingZ", this.invPosZ); + nbtt.setIntArray("bindingSide", this.invSide); + } + + public void readCustomNBT(NBTTagCompound nbtt) { + super.readCustomNBT(nbtt); + this.cooldown = nbtt.getInteger("cooldown"); + this.bindType = nbtt.getBoolean("bindType"); + this.invPosX = nbtt.getIntArray("bindingX"); + this.invPosY = nbtt.getIntArray("bindingY"); + this.invPosZ = nbtt.getIntArray("bindingZ"); + this.invSide = nbtt.getIntArray("bindingSide"); + } + + private boolean canExtractStack() { + IInventory inv = getDistantInventory(0); + if (inv == null) return false; + else { + int side = invSide[0]; + int pullCount = getPullCount(inv, side); + System.out.println("canExtractStack " + pullCount); + if (pullCount <= 0) return false; + else { + if (getStackInSlot(0) != null) { + ItemStack itemstack = getStackInSlot(0).copy(); + ItemStack itemstack1 = TileEntityHopper.func_145889_a(inv, decrStackSize(0, pullCount), side); + if (itemstack1 == null || itemstack1.stackSize == 0) { + inv.markDirty(); + return true; + } + setInventorySlotContents(0, itemstack); + } + return false; + } + } + } + + private int getPullCount(IInventory inv, int side) { + if (inv instanceof ISidedInventory && side > -1) { + ISidedInventory sideInv = (ISidedInventory) inv; + int[] slots = sideInv.getAccessibleSlotsFromSide(side); + for (int i = 0; i < slots.length; ++i) { + ItemStack stack = sideInv.getStackInSlot(slots[i]); + if (stack == null) return inv.getInventoryStackLimit(); + else if (inv.getInventoryStackLimit() != stack.stackSize && stack.stackSize != stack.getMaxStackSize() + && TileNidavellirForge.isItemEqual(stack, getStackInSlot(0))) + return inv.getInventoryStackLimit() - stack.stackSize; + } + } else { + int size = inv.getSizeInventory(); + for (int i = 0; i < size; ++i) { + ItemStack stack = inv.getStackInSlot(i); + if (stack == null) return inv.getInventoryStackLimit(); + else if (inv.getInventoryStackLimit() != stack.stackSize && stack.stackSize != stack.getMaxStackSize() + && TileNidavellirForge.isItemEqual(stack, getStackInSlot(0))) + return inv.getInventoryStackLimit() - stack.stackSize; + } + } + return 0; + } + + private boolean canInsertStack() { + IInventory inv = getDistantInventory(1); + if (inv != null) { + int side = invSide[1]; + int takeCount = getTakeCount(inv, side); + System.out.println("canInsertStack " + takeCount); + if (takeCount <= 0) return false; + if (inv instanceof ISidedInventory && side > -1) { + ISidedInventory sidedInv = (ISidedInventory) inv; + int[] slots = sidedInv.getAccessibleSlotsFromSide(side); + for (int k = 0; k < slots.length; ++k) { + if (func_145892_a(inv, slots[k], side, takeCount)) return true; + } + } else { + int i = inv.getSizeInventory(); + for (int j = 0; j < i; ++j) { + if (func_145892_a(inv, j, side, takeCount)) return true; + } + } + } + return false; + } + + private int getTakeCount(IInventory inv, int side) { + if (inv instanceof ISidedInventory && side > -1) { + ISidedInventory sideInv = (ISidedInventory) inv; + int[] slots = sideInv.getAccessibleSlotsFromSide(side); + for (int i = 0; i < slots.length; ++i) { + ItemStack stack = sideInv.getStackInSlot(slots[i]); + if (stack != null) + if (getStackInSlot(0) == null) return Math.min(stack.getMaxStackSize(), getInventoryStackLimit()); + else if (getInventoryStackLimit() != getStackInSlot(0).stackSize + && getStackInSlot(0).stackSize != getStackInSlot(0).getMaxStackSize() + && TileNidavellirForge.isItemEqual(stack, getStackInSlot(0))) + return getInventoryStackLimit() - getStackInSlot(0).stackSize; + } + } else { + for (int i = 0; i < inv.getSizeInventory(); ++i) { + ItemStack stack = inv.getStackInSlot(i); + if (stack != null) + if (getStackInSlot(0) == null) return Math.min(stack.getMaxStackSize(), getInventoryStackLimit()); + else if (getInventoryStackLimit() != getStackInSlot(0).stackSize + && getStackInSlot(0).stackSize != getStackInSlot(0).getMaxStackSize() + && TileNidavellirForge.isItemEqual(stack, getStackInSlot(0))) + return getInventoryStackLimit() - getStackInSlot(0).stackSize; + } + } + return 0; + } + + private boolean func_145892_a(IInventory inv, int slot, int side, int takeCount) { + ItemStack itemstack = inv.getStackInSlot(slot); + if (itemstack != null && func_145890_b(inv, itemstack, slot, side)) { + ItemStack itemstack1 = itemstack.copy(); + ItemStack itemstack2 = TileEntityHopper.func_145889_a(this, inv.decrStackSize(slot, takeCount), side); + if (itemstack2 == null || itemstack2.stackSize == 0) { + inv.markDirty(); + return true; + } + inv.setInventorySlotContents(slot, itemstack1); + } + return false; + } + + private static boolean func_145890_b(IInventory inv, ItemStack stack, int slot, int side) { + return !(inv instanceof ISidedInventory) || ((ISidedInventory) inv).canExtractItem(slot, stack, side); + } + + public int getSizeInventory() { + return 1; + } + + public String getInventoryName() { + return "engineerHopper"; + } + + public double getXPos() { + return this.xCoord; + } + + public double getYPos() { + return this.yCoord; + } + + public double getZPos() { + return this.zCoord; + } +} diff --git a/src/main/java/ab/common/block/tile/TileGameBoard.java b/src/main/java/ab/common/block/tile/TileGameBoard.java index 9df1715..65976c5 100644 --- a/src/main/java/ab/common/block/tile/TileGameBoard.java +++ b/src/main/java/ab/common/block/tile/TileGameBoard.java @@ -2,258 +2,251 @@ package ab.common.block.tile; import java.util.List; -import ab.api.IRenderHud; -import ab.common.block.subtile.SubTileArdentAzarcissus; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.ChatStyle; import net.minecraft.util.EnumChatFormatting; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.common.block.tile.TileMod; +import ab.api.IRenderHud; public class TileGameBoard extends TileMod implements IRenderHud { - - public String[] playersName = new String[] { "", "" }; - public byte[] slotChance = new byte[] { 0, 0, 0, 0 }; - protected int botTick = -1; - public int endGameTick = -1; - protected boolean requestUpdate; - public boolean isSingleGame = true; - public boolean isCustomGame = false; - public int clientTick[] = new int[] { 0, 0, 0, 0 }; - public static final ItemStack headRender = new ItemStack(Items.skull, 1, 3); - private ItemStack customStack; - public void updateEntity() { - if(botTick > 0) - botTick--; - if(endGameTick > 0) - endGameTick--; - if(!worldObj.isRemote) - updateServer(); - else - updateAnimationTicks(); - } - - public void updateAnimationTicks() { - for(int i = 0; i < slotChance.length; i++) - if(slotChance[i] > 0) - clientTick[i]++; - else - clientTick[i] = 0; - } - - protected void updateServer() { - if(hasGame() && endGameTick == 0 && !isCustomGame) - finishGame(); - if(requestUpdate) - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord); - if(worldObj.getTotalWorldTime() % 20 == 0 && hasFullDice() && endGameTick == -1) - endGameTick = 28; - boolean hasUpdate = false; - if(isSingleGame) { - if(botTick == 0 && hasGame()) { - for(int i = 2; i < 4; i++) { - if(slotChance[i] == 0) { - slotChance[i] = (byte)(worldObj.rand.nextInt(6) + 1); - botTick = -1; - hasUpdate = true; - worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "ab:boardCube", 0.6F, 1.0F); - break; - } - } - } - } else { - if(botTick == 0 && hasGame()) - endGameTick = 0; - } - requestUpdate = hasUpdate; - } - - public void setPlayer(String name, boolean isCustomGame) { - this.isCustomGame = isCustomGame; - if(isSingleGame) { - playersName[0] = name; - playersName[1] = ""; - requestUpdate = true; - botTick = 8; - } else { - if(playersName[0].isEmpty()) - playersName[0] = name; - else if(!playersName[0].equals(name)) - playersName[1] = name; - requestUpdate = true; - } - } - - public void setPlayer(EntityPlayer player) { - setPlayer(player.getCommandSenderName(), false); - } - - public boolean dropDice(String name) { - if(isSingleGame) { - if(name.equals(playersName[0]) && botTick == -1) { - boolean hasDrop = false; - for(int i = 0; i < 2; i++) { - if(slotChance[i] == 0) { - hasDrop = true; - if(!worldObj.isRemote) { - slotChance[i] = (byte)(worldObj.rand.nextInt(6) + 1); - botTick = 18; - worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "ab:boardCube", 0.6F, 1.0F); - requestUpdate = true; - } - break; - } - } - return hasDrop; - } - } else { - for(int i = 0; i < playersName.length; i++) { - if(name.equals(playersName[i])) { - boolean hasDrop = false; - for(int j = i * 2; j < (i + 1) * 2; j++) { - if(slotChance[j] == 0) { - hasDrop = true; - if(!worldObj.isRemote) { - slotChance[j] = (byte)(worldObj.rand.nextInt(6) + 1); - botTick = playersName[1].isEmpty() ? 240 : 1200; - worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "ab:boardCube", 0.6F, 1.0F); - requestUpdate = true; - } - break; - } - } - return hasDrop; - } - } - } - return false; - } - - public boolean dropDice(EntityPlayer player) { - return dropDice(player.getCommandSenderName()); - } - - public boolean hasFullDice() { - boolean hasFull = false; - for(int i = 0; i < slotChance.length; i++) { - if(!(slotChance[i] > 0)) - return false; - hasFull = slotChance[i] > 0; - } - return hasFull; - } - - public boolean hasGame() { - if(isSingleGame) - return !playersName[0].isEmpty(); - else - for(int i = 0; i < playersName.length; i++) - if(!playersName[i].isEmpty()) - return true; - return false; - } - - public void finishGame(boolean hasChatMessage) { - if(worldObj.isRemote) - return; - else if(!hasChatMessage) { - resetGame(); - return; - } else if(!hasFullDice()) { - sendNearMessage("ab.gameBoard.misc.notPlayer", new Object[] {}); - resetGame(); - return; - } - String str = isSingleGame ? "" : ".mult"; - if((slotChance[0] + slotChance[1]) > (slotChance[2] + slotChance[3])) - sendNearMessage("ab.gameBoard.misc.0" + str, new Object[] { playersName[0] }); - else if((slotChance[0] + slotChance[1]) == (slotChance[2] + slotChance[3])) - sendNearMessage("ab.gameBoard.misc.1" + str, new Object[] {}); - else - sendNearMessage("ab.gameBoard.misc.2" + str, new Object[] { playersName[isSingleGame ? 0 : 1] }); - resetGame(); - } - - public void finishGame() { - finishGame(true); - } - - public void sendNearMessage(String text, Object[] obj) { - List players = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord, this.zCoord, (this.xCoord + 1), (this.yCoord + 1), (this.zCoord + 1)).expand(3.5f, 3.5f, 3.5f)); - for(EntityPlayer player : players) { - if(player != null) - player.addChatMessage((new ChatComponentTranslation(text, obj)).setChatStyle((new ChatStyle()).setColor(EnumChatFormatting.DARK_GREEN))); - } - } - - public boolean changeCustomStack(ItemStack stack) { - if(!isCustomGame) - return false; - else if(customStack == null || !ItemStack.areItemStacksEqual(customStack, stack)) { - customStack = stack; - requestUpdate = true; - return true; - } else - return false; - } - - public void resetGame() { - playersName[0] = ""; - playersName[1] = ""; - for(int i = 0; i < slotChance.length; i++) - slotChance[i] = 0; - botTick = -1; - endGameTick = -1; - isCustomGame = false; - requestUpdate = true; - } - - public void renderHud(Minecraft mc, ScaledResolution res) { - int x = res.getScaledWidth() / 2 - 7; - int y = res.getScaledHeight() / 2 + 12; - RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, isCustomGame ? (customStack == null ? headRender : customStack) : headRender, x - (!isSingleGame ? 1 : 0), y - (!isSingleGame ? 1 : 0)); - if(!isSingleGame) - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, headRender, x + 3, y + 3); - RenderHelper.disableStandardItemLighting(); - } - - public void writeCustomNBT(NBTTagCompound cmp) { - super.writeCustomNBT(cmp); - for(int i = 0; i < playersName.length; i++) - cmp.setString("playerName" + i, playersName[i]); - cmp.setByteArray("slotChance", slotChance); - cmp.setInteger("botTick", botTick); - cmp.setInteger("endGameTick", endGameTick); - cmp.setBoolean("requestUpdate", requestUpdate); - cmp.setBoolean("isSingleGame", isSingleGame); - cmp.setBoolean("isAnonimGame", isCustomGame); - if(customStack != null) - customStack.writeToNBT(cmp); - } - - public void readCustomNBT(NBTTagCompound cmp) { - super.readCustomNBT(cmp); - for(int i = 0; i < playersName.length; i++) - playersName[i] = cmp.getString("playerName" + i); - botTick = cmp.getInteger("botTick"); - endGameTick = cmp.getInteger("endGameTick"); - slotChance = cmp.getByteArray("slotChance"); - requestUpdate = cmp.getBoolean("requestUpdate"); - isSingleGame = cmp.getBoolean("isSingleGame"); - isCustomGame = cmp.getBoolean("isAnonimGame"); - customStack = ItemStack.loadItemStackFromNBT(cmp); - } -} \ No newline at end of file + public String[] playersName = new String[] { "", "" }; + public byte[] slotChance = new byte[] { 0, 0, 0, 0 }; + protected int botTick = -1; + public int endGameTick = -1; + protected boolean requestUpdate; + public boolean isSingleGame = true; + public boolean isCustomGame = false; + public int clientTick[] = new int[] { 0, 0, 0, 0 }; + public static final ItemStack headRender = new ItemStack(Items.skull, 1, 3); + private ItemStack customStack; + + public void updateEntity() { + if (botTick > 0) botTick--; + if (endGameTick > 0) endGameTick--; + if (!worldObj.isRemote) updateServer(); + else updateAnimationTicks(); + } + + public void updateAnimationTicks() { + for (int i = 0; i < slotChance.length; i++) if (slotChance[i] > 0) clientTick[i]++; + else clientTick[i] = 0; + } + + protected void updateServer() { + if (hasGame() && endGameTick == 0 && !isCustomGame) finishGame(); + if (requestUpdate) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord); + if (worldObj.getTotalWorldTime() % 20 == 0 && hasFullDice() && endGameTick == -1) endGameTick = 28; + boolean hasUpdate = false; + if (isSingleGame) { + if (botTick == 0 && hasGame()) { + for (int i = 2; i < 4; i++) { + if (slotChance[i] == 0) { + slotChance[i] = (byte) (worldObj.rand.nextInt(6) + 1); + botTick = -1; + hasUpdate = true; + worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "ab:boardCube", 0.6F, 1.0F); + break; + } + } + } + } else { + if (botTick == 0 && hasGame()) endGameTick = 0; + } + requestUpdate = hasUpdate; + } + + public void setPlayer(String name, boolean isCustomGame) { + this.isCustomGame = isCustomGame; + if (isSingleGame) { + playersName[0] = name; + playersName[1] = ""; + requestUpdate = true; + botTick = 8; + } else { + if (playersName[0].isEmpty()) playersName[0] = name; + else if (!playersName[0].equals(name)) playersName[1] = name; + requestUpdate = true; + } + } + + public void setPlayer(EntityPlayer player) { + setPlayer(player.getCommandSenderName(), false); + } + + public boolean dropDice(String name) { + if (isSingleGame) { + if (name.equals(playersName[0]) && botTick == -1) { + boolean hasDrop = false; + for (int i = 0; i < 2; i++) { + if (slotChance[i] == 0) { + hasDrop = true; + if (!worldObj.isRemote) { + slotChance[i] = (byte) (worldObj.rand.nextInt(6) + 1); + botTick = 18; + worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "ab:boardCube", 0.6F, 1.0F); + requestUpdate = true; + } + break; + } + } + return hasDrop; + } + } else { + for (int i = 0; i < playersName.length; i++) { + if (name.equals(playersName[i])) { + boolean hasDrop = false; + for (int j = i * 2; j < (i + 1) * 2; j++) { + if (slotChance[j] == 0) { + hasDrop = true; + if (!worldObj.isRemote) { + slotChance[j] = (byte) (worldObj.rand.nextInt(6) + 1); + botTick = playersName[1].isEmpty() ? 240 : 1200; + worldObj.playSoundEffect( + this.xCoord, + this.yCoord, + this.zCoord, + "ab:boardCube", + 0.6F, + 1.0F); + requestUpdate = true; + } + break; + } + } + return hasDrop; + } + } + } + return false; + } + + public boolean dropDice(EntityPlayer player) { + return dropDice(player.getCommandSenderName()); + } + + public boolean hasFullDice() { + boolean hasFull = false; + for (int i = 0; i < slotChance.length; i++) { + if (!(slotChance[i] > 0)) return false; + hasFull = slotChance[i] > 0; + } + return hasFull; + } + + public boolean hasGame() { + if (isSingleGame) return !playersName[0].isEmpty(); + else for (int i = 0; i < playersName.length; i++) if (!playersName[i].isEmpty()) return true; + return false; + } + + public void finishGame(boolean hasChatMessage) { + if (worldObj.isRemote) return; + else if (!hasChatMessage) { + resetGame(); + return; + } else if (!hasFullDice()) { + sendNearMessage("ab.gameBoard.misc.notPlayer", new Object[] {}); + resetGame(); + return; + } + String str = isSingleGame ? "" : ".mult"; + if ((slotChance[0] + slotChance[1]) > (slotChance[2] + slotChance[3])) + sendNearMessage("ab.gameBoard.misc.0" + str, new Object[] { playersName[0] }); + else if ((slotChance[0] + slotChance[1]) == (slotChance[2] + slotChance[3])) + sendNearMessage("ab.gameBoard.misc.1" + str, new Object[] {}); + else sendNearMessage("ab.gameBoard.misc.2" + str, new Object[] { playersName[isSingleGame ? 0 : 1] }); + resetGame(); + } + + public void finishGame() { + finishGame(true); + } + + public void sendNearMessage(String text, Object[] obj) { + List players = this.worldObj.getEntitiesWithinAABB( + EntityPlayer.class, + AxisAlignedBB.getBoundingBox( + this.xCoord, + this.yCoord, + this.zCoord, + (this.xCoord + 1), + (this.yCoord + 1), + (this.zCoord + 1)).expand(3.5f, 3.5f, 3.5f)); + for (EntityPlayer player : players) { + if (player != null) player.addChatMessage( + (new ChatComponentTranslation(text, obj)) + .setChatStyle((new ChatStyle()).setColor(EnumChatFormatting.DARK_GREEN))); + } + } + + public boolean changeCustomStack(ItemStack stack) { + if (!isCustomGame) return false; + else if (customStack == null || !ItemStack.areItemStacksEqual(customStack, stack)) { + customStack = stack; + requestUpdate = true; + return true; + } else return false; + } + + public void resetGame() { + playersName[0] = ""; + playersName[1] = ""; + for (int i = 0; i < slotChance.length; i++) slotChance[i] = 0; + botTick = -1; + endGameTick = -1; + isCustomGame = false; + requestUpdate = true; + } + + public void renderHud(Minecraft mc, ScaledResolution res) { + int x = res.getScaledWidth() / 2 - 7; + int y = res.getScaledHeight() / 2 + 12; + RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance().renderItemAndEffectIntoGUI( + mc.fontRenderer, + mc.renderEngine, + isCustomGame ? (customStack == null ? headRender : customStack) : headRender, + x - (!isSingleGame ? 1 : 0), + y - (!isSingleGame ? 1 : 0)); + if (!isSingleGame) RenderItem.getInstance() + .renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, headRender, x + 3, y + 3); + RenderHelper.disableStandardItemLighting(); + } + + public void writeCustomNBT(NBTTagCompound cmp) { + super.writeCustomNBT(cmp); + for (int i = 0; i < playersName.length; i++) cmp.setString("playerName" + i, playersName[i]); + cmp.setByteArray("slotChance", slotChance); + cmp.setInteger("botTick", botTick); + cmp.setInteger("endGameTick", endGameTick); + cmp.setBoolean("requestUpdate", requestUpdate); + cmp.setBoolean("isSingleGame", isSingleGame); + cmp.setBoolean("isAnonimGame", isCustomGame); + if (customStack != null) customStack.writeToNBT(cmp); + } + + public void readCustomNBT(NBTTagCompound cmp) { + super.readCustomNBT(cmp); + for (int i = 0; i < playersName.length; i++) playersName[i] = cmp.getString("playerName" + i); + botTick = cmp.getInteger("botTick"); + endGameTick = cmp.getInteger("endGameTick"); + slotChance = cmp.getByteArray("slotChance"); + requestUpdate = cmp.getBoolean("requestUpdate"); + isSingleGame = cmp.getBoolean("isSingleGame"); + isCustomGame = cmp.getBoolean("isAnonimGame"); + customStack = ItemStack.loadItemStackFromNBT(cmp); + } +} diff --git a/src/main/java/ab/common/block/tile/TileInventory.java b/src/main/java/ab/common/block/tile/TileInventory.java index 8e8cb82..c0d2702 100644 --- a/src/main/java/ab/common/block/tile/TileInventory.java +++ b/src/main/java/ab/common/block/tile/TileInventory.java @@ -6,87 +6,86 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; + import vazkii.botania.common.block.tile.TileMod; public abstract class TileInventory extends TileMod implements IInventory { - ItemStack[] inventorySlots = new ItemStack[getSizeInventory()]; - - public void readCustomNBT(NBTTagCompound par1NBTTagCompound) { - NBTTagList var2 = par1NBTTagCompound.getTagList("Items", 10); - this.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 < this.inventorySlots.length) - this.inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4); - } - } - - public void writeCustomNBT(NBTTagCompound par1NBTTagCompound) { - NBTTagList var2 = new NBTTagList(); - for(int var3 = 0; var3 < this.inventorySlots.length; var3++) { - if (this.inventorySlots[var3] != null) { - NBTTagCompound var4 = new NBTTagCompound(); - var4.setByte("Slot", (byte)var3); - this.inventorySlots[var3].writeToNBT(var4); - var2.appendTag((NBTBase)var4); - } - } - par1NBTTagCompound.setTag("Items", (NBTBase)var2); - } - - public ItemStack getStackInSlot(int i) { - return this.inventorySlots[i]; - } - - public ItemStack decrStackSize(int i, int j) { - if(this.inventorySlots[i] != null) { - if(!this.worldObj.isRemote) - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); - if((this.inventorySlots[i]).stackSize <= j) { - ItemStack itemStack = this.inventorySlots[i]; - this.inventorySlots[i] = null; - markDirty(); - return itemStack; - } - ItemStack stackAt = this.inventorySlots[i].splitStack(j); - if((this.inventorySlots[i]).stackSize == 0) - this.inventorySlots[i] = null; - markDirty(); - return stackAt; - } - return null; - } - - public ItemStack getStackInSlotOnClosing(int i) { - return getStackInSlot(i); - } - - public void setInventorySlotContents(int i, ItemStack itemstack) { - this.inventorySlots[i] = itemstack; - markDirty(); - if (!this.worldObj.isRemote) - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); - } - - public int getInventoryStackLimit() { - return 64; - } - - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return (this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this) ? false : ((entityplayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D)); - } - - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; - } - - public boolean hasCustomInventoryName() { - return false; - } - - public void openInventory() {} - - public void closeInventory() {} -} \ No newline at end of file + ItemStack[] inventorySlots = new ItemStack[getSizeInventory()]; + + public void readCustomNBT(NBTTagCompound par1NBTTagCompound) { + NBTTagList var2 = par1NBTTagCompound.getTagList("Items", 10); + this.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 < this.inventorySlots.length) + this.inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4); + } + } + + public void writeCustomNBT(NBTTagCompound par1NBTTagCompound) { + NBTTagList var2 = new NBTTagList(); + for (int var3 = 0; var3 < this.inventorySlots.length; var3++) { + if (this.inventorySlots[var3] != null) { + NBTTagCompound var4 = new NBTTagCompound(); + var4.setByte("Slot", (byte) var3); + this.inventorySlots[var3].writeToNBT(var4); + var2.appendTag((NBTBase) var4); + } + } + par1NBTTagCompound.setTag("Items", (NBTBase) var2); + } + + public ItemStack getStackInSlot(int i) { + return this.inventorySlots[i]; + } + + public ItemStack decrStackSize(int i, int j) { + if (this.inventorySlots[i] != null) { + if (!this.worldObj.isRemote) this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + if ((this.inventorySlots[i]).stackSize <= j) { + ItemStack itemStack = this.inventorySlots[i]; + this.inventorySlots[i] = null; + markDirty(); + return itemStack; + } + ItemStack stackAt = this.inventorySlots[i].splitStack(j); + if ((this.inventorySlots[i]).stackSize == 0) this.inventorySlots[i] = null; + markDirty(); + return stackAt; + } + return null; + } + + public ItemStack getStackInSlotOnClosing(int i) { + return getStackInSlot(i); + } + + public void setInventorySlotContents(int i, ItemStack itemstack) { + this.inventorySlots[i] = itemstack; + markDirty(); + if (!this.worldObj.isRemote) this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + } + + public int getInventoryStackLimit() { + return 64; + } + + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + return (this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this) ? false + : ((entityplayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D)); + } + + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return true; + } + + public boolean hasCustomInventoryName() { + return false; + } + + public void openInventory() {} + + public void closeInventory() {} +} diff --git a/src/main/java/ab/common/block/tile/TileLebethronCore.java b/src/main/java/ab/common/block/tile/TileLebethronCore.java index 2f9d88a..c91e37a 100644 --- a/src/main/java/ab/common/block/tile/TileLebethronCore.java +++ b/src/main/java/ab/common/block/tile/TileLebethronCore.java @@ -1,9 +1,5 @@ package ab.common.block.tile; -import org.lwjgl.opengl.GL11; - -import ab.api.IRenderHud; -import ab.common.lib.register.BlockListAB; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; @@ -14,201 +10,212 @@ import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; -import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Vec3; import net.minecraft.world.World; + +import org.lwjgl.opengl.GL11; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.lexicon.multiblock.Multiblock; import vazkii.botania.api.lexicon.multiblock.MultiblockSet; import vazkii.botania.common.Botania; -import vazkii.botania.common.block.ModBlocks; -import vazkii.botania.common.block.ModFluffBlocks; import vazkii.botania.common.block.tile.TileMod; -import vazkii.botania.common.core.handler.ConfigHandler; +import ab.api.IRenderHud; +import ab.common.lib.register.BlockListAB; public class TileLebethronCore extends TileMod implements IRenderHud { - - protected int tick; - protected Block block; - protected int meta; - protected boolean validTree; - public static MultiblockSet makeMultiblockSet() { - Multiblock mb = new Multiblock(); - mb.addComponent(0, 1, 0, BlockListAB.blockLebethron, 4); - mb.addComponent(0, 0, 0, BlockListAB.blockLebethron, 0); - mb.addComponent(0, 2, 0, BlockListAB.blockLebethron, 0); - mb.addComponent(0, 3, 0, BlockListAB.blockLebethron, 0); - mb.addComponent(0, 4, 0, BlockListAB.blockLebethron, 0); - mb.addComponent(0, 5, 0, BlockListAB.blockLebethron, 0); - mb.setRenderOffset(0, 1, 0); - return mb.makeSet(); - } - - public void updateEntity() { - if(!worldObj.isRemote) { - if(tick <= 0) { - updateStructure(); - if(validTree && getBlock() != null) { - spawnLeaves(); - tick = 40; - } - } else - tick--; - } else if(worldObj.rand.nextBoolean()) - Botania.proxy.sparkleFX(this.worldObj, this.xCoord + Math.random(), this.yCoord + Math.random(), this.zCoord + Math.random(), 0.5F, 1.0F, 0.5F, (float)Math.random() * 2, 2); - } - - public boolean getValidTree() { - return this.validTree; - } - - public void updateStructure() { - boolean oldValidTree = validTree; - validTree = hasValidTree(); - if(oldValidTree != validTree) - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord); - } - - public void writeCustomNBT(NBTTagCompound nbtt) { - nbtt.setInteger("blockID", Block.getIdFromBlock(block)); - nbtt.setInteger("blockMeta", this.meta); - nbtt.setInteger("tick", this.tick); - nbtt.setBoolean("validTree", validTree); - } - - public void readCustomNBT(NBTTagCompound nbtt) { - this.block = Block.getBlockById(nbtt.getInteger("blockID")); - this.meta = nbtt.getInteger("blockMeta"); - this.tick = nbtt.getInteger("tick"); - this.validTree = nbtt.getBoolean("validTree"); - } - - public boolean setBlock(EntityPlayer player, Block block, int meta) { - if(this.block == null) { - this.block = block; - this.meta = meta; - return true; - } else { - if(Block.isEqualTo(this.block, block) && this.meta == meta) - return false; - else if(!worldObj.isRemote) { - Vec3 vec3 = player.getLook(1.0F).normalize(); - EntityItem entityitem = new EntityItem(worldObj, player.posX + vec3.xCoord, player.posY + 1.2f, player.posZ + vec3.zCoord, new ItemStack(this.block, 1, this.meta)); - worldObj.spawnEntityInWorld(entityitem); - } - this.block = block; - this.meta = meta; - return true; - } - } - - public Block getBlock() { - if(!Block.isEqualTo(block, Blocks.air) && block != null) - return this.block; - return null; - } - - public int getMeta() { - return this.meta; - } - - public boolean hasValidTree() { - if(!checkBlock(this.worldObj.getBlock(this.xCoord, this.yCoord - 1, this.zCoord), this.worldObj.getBlockMetadata(this.xCoord, this.yCoord - 1, this.zCoord))) { - return false; - } - for(int i = 1; i <= 4; i++) { - if(!checkBlock(this.worldObj.getBlock(this.xCoord, this.yCoord + i, this.zCoord), this.worldObj.getBlockMetadata(this.xCoord, this.yCoord + i, this.zCoord))) { - return false; - } - } - return true; - } - - boolean checkBlock(Block block, int meta) { - return block == BlockListAB.blockLebethron && meta == 0; - } - - private void spawnLeaves() { - for(int x = -1; x <= 1; x++) { - for(int z = -1; z <= 1; z++) { - for(int y = 0; y < 5; y++) { - this.setBlock(worldObj, this.xCoord + x, this.yCoord + y + 2, this.zCoord + z); - } - } - } - this.setBlock(worldObj, this.xCoord + 1, this.yCoord + 1, this.zCoord); - this.setBlock(worldObj, this.xCoord - 1, this.yCoord + 1, this.zCoord); - this.setBlock(worldObj, this.xCoord, this.yCoord + 1, this.zCoord + 1); - this.setBlock(worldObj, this.xCoord, this.yCoord + 1, this.zCoord - 1); - this.setBlock(worldObj, this.xCoord + 1, this.yCoord + 7, this.zCoord); - this.setBlock(worldObj, this.xCoord - 1, this.yCoord + 7, this.zCoord); - this.setBlock(worldObj, this.xCoord, this.yCoord + 7, this.zCoord + 1); - this.setBlock(worldObj, this.xCoord, this.yCoord + 7, this.zCoord - 1); - for(int i = 0; i <= 3; i++) - this.setBlock(worldObj, this.xCoord, this.yCoord + 6 + i, this.zCoord); - this.setBlock(worldObj, this.xCoord, this.yCoord + 2, this.zCoord - 2); - for(int i = -1; i <= 1; i++) { - this.setBlock(worldObj, this.xCoord + i, this.yCoord + 3, this.zCoord - 2); - this.setBlock(worldObj, this.xCoord + i, this.yCoord + 4, this.zCoord - 2); - } - this.setBlock(worldObj, this.xCoord, this.yCoord + 5, this.zCoord - 2); - this.setBlock(worldObj, this.xCoord, this.yCoord + 2, this.zCoord + 2); - for(int i = -1; i <= 1; i++) { - this.setBlock(worldObj, this.xCoord + i, this.yCoord + 3, this.zCoord + 2); - this.setBlock(worldObj, this.xCoord + i, this.yCoord + 4, this.zCoord + 2); - } - this.setBlock(worldObj, this.xCoord, this.yCoord + 5, this.zCoord + 2); - this.setBlock(worldObj, this.xCoord + 2, this.yCoord + 2, this.zCoord); - for(int i = -1; i <= 1; i++) { - this.setBlock(worldObj, this.xCoord + 2, this.yCoord + 3, this.zCoord + i); - this.setBlock(worldObj, this.xCoord + 2, this.yCoord + 4, this.zCoord + i); - } - this.setBlock(worldObj, this.xCoord + 2, this.yCoord + 5, this.zCoord); - this.setBlock(worldObj, this.xCoord - 2, this.yCoord + 2, this.zCoord); - for(int i = -1; i <= 1; i++) { - this.setBlock(worldObj, this.xCoord - 2, this.yCoord + 3, this.zCoord + i); - this.setBlock(worldObj, this.xCoord - 2, this.yCoord + 4, this.zCoord + i); - } - this.setBlock(worldObj, this.xCoord - 2, this.yCoord + 5, this.zCoord); - } - - private void setBlock(World world, int x, int y, int z) { - if(world.rand.nextInt(10) <= 8) - return; - else if(world.getBlock(x, y, z).getMaterial() == Material.air && y < 256) - world.setBlock(x, y, z, this.block, this.meta, 3); - } + protected int tick; + protected Block block; + protected int meta; + protected boolean validTree; - public void renderHud(Minecraft mc, ScaledResolution res) { - if(!validTree) - return; - GL11.glEnable(3042); - GL11.glBlendFunc(770, 771); - ItemStack stack = getBlock() != null ? new ItemStack(block, 1, meta) : new ItemStack(Blocks.leaves); - int x = res.getScaledWidth() / 2 - 7; - int y = res.getScaledHeight() / 2 + 12; - Gui.drawRect(x - 2, y - 2, x + 18, y + 18, 1140850688); - Gui.drawRect(x, y, x + 16, y + 16, 1140850688); - RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(32826); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); - RenderHelper.disableStandardItemLighting(); + public static MultiblockSet makeMultiblockSet() { + Multiblock mb = new Multiblock(); + mb.addComponent(0, 1, 0, BlockListAB.blockLebethron, 4); + mb.addComponent(0, 0, 0, BlockListAB.blockLebethron, 0); + mb.addComponent(0, 2, 0, BlockListAB.blockLebethron, 0); + mb.addComponent(0, 3, 0, BlockListAB.blockLebethron, 0); + mb.addComponent(0, 4, 0, BlockListAB.blockLebethron, 0); + mb.addComponent(0, 5, 0, BlockListAB.blockLebethron, 0); + mb.setRenderOffset(0, 1, 0); + return mb.makeSet(); + } + + public void updateEntity() { + if (!worldObj.isRemote) { + if (tick <= 0) { + updateStructure(); + if (validTree && getBlock() != null) { + spawnLeaves(); + tick = 40; + } + } else tick--; + } else if (worldObj.rand.nextBoolean()) Botania.proxy.sparkleFX( + this.worldObj, + this.xCoord + Math.random(), + this.yCoord + Math.random(), + this.zCoord + Math.random(), + 0.5F, + 1.0F, + 0.5F, + (float) Math.random() * 2, + 2); + } + + public boolean getValidTree() { + return this.validTree; + } + + public void updateStructure() { + boolean oldValidTree = validTree; + validTree = hasValidTree(); + if (oldValidTree != validTree) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord); + } + + public void writeCustomNBT(NBTTagCompound nbtt) { + nbtt.setInteger("blockID", Block.getIdFromBlock(block)); + nbtt.setInteger("blockMeta", this.meta); + nbtt.setInteger("tick", this.tick); + nbtt.setBoolean("validTree", validTree); + } + + public void readCustomNBT(NBTTagCompound nbtt) { + this.block = Block.getBlockById(nbtt.getInteger("blockID")); + this.meta = nbtt.getInteger("blockMeta"); + this.tick = nbtt.getInteger("tick"); + this.validTree = nbtt.getBoolean("validTree"); + } + + public boolean setBlock(EntityPlayer player, Block block, int meta) { + if (this.block == null) { + this.block = block; + this.meta = meta; + return true; + } else { + if (Block.isEqualTo(this.block, block) && this.meta == meta) return false; + else if (!worldObj.isRemote) { + Vec3 vec3 = player.getLook(1.0F).normalize(); + EntityItem entityitem = new EntityItem( + worldObj, + player.posX + vec3.xCoord, + player.posY + 1.2f, + player.posZ + vec3.zCoord, + new ItemStack(this.block, 1, this.meta)); + worldObj.spawnEntityInWorld(entityitem); + } + this.block = block; + this.meta = meta; + return true; + } + } + + public Block getBlock() { + if (!Block.isEqualTo(block, Blocks.air) && block != null) return this.block; + return null; + } + + public int getMeta() { + return this.meta; + } + + public boolean hasValidTree() { + if (!checkBlock( + this.worldObj.getBlock(this.xCoord, this.yCoord - 1, this.zCoord), + this.worldObj.getBlockMetadata(this.xCoord, this.yCoord - 1, this.zCoord))) { + return false; + } + for (int i = 1; i <= 4; i++) { + if (!checkBlock( + this.worldObj.getBlock(this.xCoord, this.yCoord + i, this.zCoord), + this.worldObj.getBlockMetadata(this.xCoord, this.yCoord + i, this.zCoord))) { + return false; + } + } + return true; + } + + boolean checkBlock(Block block, int meta) { + return block == BlockListAB.blockLebethron && meta == 0; + } + + private void spawnLeaves() { + for (int x = -1; x <= 1; x++) { + for (int z = -1; z <= 1; z++) { + for (int y = 0; y < 5; y++) { + this.setBlock(worldObj, this.xCoord + x, this.yCoord + y + 2, this.zCoord + z); + } + } + } + this.setBlock(worldObj, this.xCoord + 1, this.yCoord + 1, this.zCoord); + this.setBlock(worldObj, this.xCoord - 1, this.yCoord + 1, this.zCoord); + this.setBlock(worldObj, this.xCoord, this.yCoord + 1, this.zCoord + 1); + this.setBlock(worldObj, this.xCoord, this.yCoord + 1, this.zCoord - 1); + this.setBlock(worldObj, this.xCoord + 1, this.yCoord + 7, this.zCoord); + this.setBlock(worldObj, this.xCoord - 1, this.yCoord + 7, this.zCoord); + this.setBlock(worldObj, this.xCoord, this.yCoord + 7, this.zCoord + 1); + this.setBlock(worldObj, this.xCoord, this.yCoord + 7, this.zCoord - 1); + for (int i = 0; i <= 3; i++) this.setBlock(worldObj, this.xCoord, this.yCoord + 6 + i, this.zCoord); + this.setBlock(worldObj, this.xCoord, this.yCoord + 2, this.zCoord - 2); + for (int i = -1; i <= 1; i++) { + this.setBlock(worldObj, this.xCoord + i, this.yCoord + 3, this.zCoord - 2); + this.setBlock(worldObj, this.xCoord + i, this.yCoord + 4, this.zCoord - 2); + } + this.setBlock(worldObj, this.xCoord, this.yCoord + 5, this.zCoord - 2); + this.setBlock(worldObj, this.xCoord, this.yCoord + 2, this.zCoord + 2); + for (int i = -1; i <= 1; i++) { + this.setBlock(worldObj, this.xCoord + i, this.yCoord + 3, this.zCoord + 2); + this.setBlock(worldObj, this.xCoord + i, this.yCoord + 4, this.zCoord + 2); + } + this.setBlock(worldObj, this.xCoord, this.yCoord + 5, this.zCoord + 2); + this.setBlock(worldObj, this.xCoord + 2, this.yCoord + 2, this.zCoord); + for (int i = -1; i <= 1; i++) { + this.setBlock(worldObj, this.xCoord + 2, this.yCoord + 3, this.zCoord + i); + this.setBlock(worldObj, this.xCoord + 2, this.yCoord + 4, this.zCoord + i); + } + this.setBlock(worldObj, this.xCoord + 2, this.yCoord + 5, this.zCoord); + this.setBlock(worldObj, this.xCoord - 2, this.yCoord + 2, this.zCoord); + for (int i = -1; i <= 1; i++) { + this.setBlock(worldObj, this.xCoord - 2, this.yCoord + 3, this.zCoord + i); + this.setBlock(worldObj, this.xCoord - 2, this.yCoord + 4, this.zCoord + i); + } + this.setBlock(worldObj, this.xCoord - 2, this.yCoord + 5, this.zCoord); + } + + private void setBlock(World world, int x, int y, int z) { + if (world.rand.nextInt(10) <= 8) return; + else if (world.getBlock(x, y, z).getMaterial() == Material.air && y < 256) + world.setBlock(x, y, z, this.block, this.meta, 3); + } + + public void renderHud(Minecraft mc, ScaledResolution res) { + if (!validTree) return; + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + ItemStack stack = getBlock() != null ? new ItemStack(block, 1, meta) : new ItemStack(Blocks.leaves); + int x = res.getScaledWidth() / 2 - 7; + int y = res.getScaledHeight() / 2 + 12; + Gui.drawRect(x - 2, y - 2, x + 18, y + 18, 1140850688); + Gui.drawRect(x, y, x + 16, y + 16, 1140850688); + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(32826); + RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y); + RenderHelper.disableStandardItemLighting(); GL11.glDisable(2929); boolean unicode = mc.fontRenderer.getUnicodeFlag(); mc.fontRenderer.setUnicodeFlag(true); - if(getBlock() != null) { - mc.fontRenderer.drawStringWithShadow("\u2713", x + 10, y + 9, 19456); - mc.fontRenderer.drawStringWithShadow("\u2713", x + 10, y + 8, 774669); - } else { - mc.fontRenderer.drawStringWithShadow("\u2717", x + 10, y + 9, 4980736); - mc.fontRenderer.drawStringWithShadow("\u2717", x + 10, y + 8, 13764621); - } - mc.fontRenderer.setUnicodeFlag(unicode); - GL11.glEnable(2929); - GL11.glDisable(3042); - } -} \ No newline at end of file + if (getBlock() != null) { + mc.fontRenderer.drawStringWithShadow("\u2713", x + 10, y + 9, 19456); + mc.fontRenderer.drawStringWithShadow("\u2713", x + 10, y + 8, 774669); + } else { + mc.fontRenderer.drawStringWithShadow("\u2717", x + 10, y + 9, 4980736); + mc.fontRenderer.drawStringWithShadow("\u2717", x + 10, y + 8, 13764621); + } + mc.fontRenderer.setUnicodeFlag(unicode); + GL11.glEnable(2929); + GL11.glDisable(3042); + } +} diff --git a/src/main/java/ab/common/block/tile/TileMagicCraftCrate.java b/src/main/java/ab/common/block/tile/TileMagicCraftCrate.java index d6e998b..2b5fc48 100644 --- a/src/main/java/ab/common/block/tile/TileMagicCraftCrate.java +++ b/src/main/java/ab/common/block/tile/TileMagicCraftCrate.java @@ -1,6 +1,5 @@ package ab.common.block.tile; -import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -14,7 +13,7 @@ import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; -import thaumcraft.api.aspects.Aspect; + import thaumcraft.api.aspects.AspectList; import thaumcraft.common.items.relics.ItemThaumonomicon; import thaumcraft.common.items.wands.ItemWandCasting; @@ -22,312 +21,295 @@ import thaumcraft.common.lib.crafting.ThaumcraftCraftingManager; import thaumcraft.common.tiles.TileMagicWorkbench; import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.common.item.ModItems; +import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; public class TileMagicCraftCrate extends TileMagicWorkbench implements ISidedInventory, IInventory { - private static final String WAITING_TAG = "waitingStack"; - private static final String PATTERN_TAG = "pattern"; - private static final int[] ACCESSIBLE_SLOTS = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + private static final String WAITING_TAG = "waitingStack"; + private static final String PATTERN_TAG = "pattern"; + private static final int[] ACCESSIBLE_SLOTS = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; - private boolean[][] pattern; - private EntityPlayer player; - int signal = 0; - private ItemStack waitingStack; + private boolean[][] pattern; + private EntityPlayer player; + int signal = 0; + private ItemStack waitingStack; - public TileMagicCraftCrate() { - pattern = new boolean[][] { new boolean[] { true, true, true }, new boolean[] { true, true, true }, new boolean[] { true, true, true } }; - } + public TileMagicCraftCrate() { + pattern = new boolean[][] { new boolean[] { true, true, true }, new boolean[] { true, true, true }, + new boolean[] { true, true, true } }; + } - public void updateEntity() { - if(!worldObj.isRemote && (craft(true) && canEject() || isFull() && !isWaiting())) - ejectAll(); - int newSignal = 0; - for(; newSignal < 9; newSignal++) - if(!isLocked(newSignal) && getStackInSlot(newSignal) == null) - break; - if(isWaiting()) - newSignal = 14; - if(newSignal != signal) { - signal = newSignal; - worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - } + public void updateEntity() { + if (!worldObj.isRemote && (craft(true) && canEject() || isFull() && !isWaiting())) ejectAll(); + int newSignal = 0; + for (; newSignal < 9; newSignal++) if (!isLocked(newSignal) && getStackInSlot(newSignal) == null) break; + if (isWaiting()) newSignal = 14; + 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; - if(player == null) - return false; - TileMagicWorkbench craft = new TileMagicWorkbench() { - - public void setInventorySlotContents(int par1, ItemStack par2ItemStack) { - this.stackList[par1] = par2ItemStack; - } + boolean craft(boolean fullCheck) { + if (fullCheck && !isFull()) return false; + if (player == null) return false; + TileMagicWorkbench craft = new TileMagicWorkbench() { - public ItemStack decrStackSize(int par1, int par2) { - if(this.stackList[par1] == null) { - return null; - } - if(this.stackList[par1].stackSize <= par2) { - final ItemStack var3 = this.stackList[par1]; - this.stackList[par1] = null; - return var3; - } - final ItemStack var3 = this.stackList[par1].splitStack(par2); - if(this.stackList[par1].stackSize == 0) { - this.stackList[par1] = null; - } - return var3; - } - }; - for(int i = 0; i < 10; i++) { - ItemStack stack = getStackInSlot(i); - if(stack == null || isLocked(i) || stack.getItem() == ModItems.manaResource && stack.getItemDamage() == 11) - continue; - craft.setInventorySlotContents(i, stack.copy()); - } - ItemStack result = ThaumcraftCraftingManager.findMatchingArcaneRecipe(craft, player); - if(result != null) { - final AspectList aspects = ThaumcraftCraftingManager.findMatchingArcaneRecipeAspects(craft, player); - if(aspects.size() > 0 && this.getStackInSlot(10) != null) { - final ItemWandCasting wand = (ItemWandCasting) this.getStackInSlot(10).getItem(); - if (wand.consumeAllVisCrafting(this.getStackInSlot(10), player, aspects, true)) { - for(int var2 = 0; var2 < 9; ++var2) { - final ItemStack var3 = craft.getStackInSlot(var2); - if(var3 != null) - craft.decrStackSize(var2, 1); - } - for(int i = 0; i < 9; i++) - setInventorySlotContents(i, craft.getStackInSlot(i)); - setInventorySlotContents(9, result); - MinecraftForge.EVENT_BUS.post(new ItemCraftedEvent(player, result, craft)); - waitingStack = null; - return true; - } else { - waitingStack = result; - markDirty(); - } - } - } else - waitingStack = null; - return false; - } + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) { + this.stackList[par1] = par2ItemStack; + } - boolean isFull() { - for (int i = 0; i < 9; i++) - if (!isLocked(i) && getStackInSlot(i) == null) - return false; + public ItemStack decrStackSize(int par1, int par2) { + if (this.stackList[par1] == null) { + return null; + } + if (this.stackList[par1].stackSize <= par2) { + final ItemStack var3 = this.stackList[par1]; + this.stackList[par1] = null; + return var3; + } + final ItemStack var3 = this.stackList[par1].splitStack(par2); + if (this.stackList[par1].stackSize == 0) { + this.stackList[par1] = null; + } + return var3; + } + }; + for (int i = 0; i < 10; i++) { + ItemStack stack = getStackInSlot(i); + if (stack == null || isLocked(i) || stack.getItem() == ModItems.manaResource && stack.getItemDamage() == 11) + continue; + craft.setInventorySlotContents(i, stack.copy()); + } + ItemStack result = ThaumcraftCraftingManager.findMatchingArcaneRecipe(craft, player); + if (result != null) { + final AspectList aspects = ThaumcraftCraftingManager.findMatchingArcaneRecipeAspects(craft, player); + if (aspects.size() > 0 && this.getStackInSlot(10) != null) { + final ItemWandCasting wand = (ItemWandCasting) this.getStackInSlot(10).getItem(); + if (wand.consumeAllVisCrafting(this.getStackInSlot(10), player, aspects, true)) { + for (int var2 = 0; var2 < 9; ++var2) { + final ItemStack var3 = craft.getStackInSlot(var2); + if (var3 != null) craft.decrStackSize(var2, 1); + } + for (int i = 0; i < 9; i++) setInventorySlotContents(i, craft.getStackInSlot(i)); + setInventorySlotContents(9, result); + MinecraftForge.EVENT_BUS.post(new ItemCraftedEvent(player, result, craft)); + waitingStack = null; + return true; + } else { + waitingStack = result; + markDirty(); + } + } + } else waitingStack = null; + return false; + } - return true; - } + boolean isFull() { + for (int i = 0; i < 9; i++) if (!isLocked(i) && getStackInSlot(i) == null) return false; - public boolean[][] getPattern() { - return pattern; - } + return true; + } - public void setPattern(boolean[][] pattern) { - this.pattern = pattern; - } + public boolean[][] getPattern() { + return pattern; + } - public int getSizeInventory() { - return 12; - } + public void setPattern(boolean[][] pattern) { + this.pattern = pattern; + } - public EntityPlayer getPlayer() { - return player; - } + public int getSizeInventory() { + return 12; + } - public void setPlayer(EntityPlayer player) { - this.player = player; - } + public EntityPlayer getPlayer() { + return player; + } - public int getSignal() { - return signal; - } + public void setPlayer(EntityPlayer player) { + this.player = player; + } - public ItemStack getWaitingStack() { - return waitingStack; - } + public int getSignal() { + return signal; + } - private boolean isWaiting() { - return waitingStack != null; - } + public ItemStack getWaitingStack() { + return waitingStack; + } - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - if (i < 9 && !isLocked(i)) - return true; - if (i == 9) - return false; - if (i == 10) { - if (!(itemstack.getItem() instanceof ItemWandCasting)) { - return false; - } - final ItemWandCasting wand = (ItemWandCasting) itemstack.getItem(); - return !wand.isStaff(itemstack); - } - return itemstack.getItem() instanceof ItemThaumonomicon; - } + private boolean isWaiting() { + return waitingStack != null; + } - private boolean isLocked(int slot) { - return pattern != null && !pattern[slot / 3][slot % 3]; - } + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + if (i < 9 && !isLocked(i)) return true; + if (i == 9) return false; + if (i == 10) { + if (!(itemstack.getItem() instanceof ItemWandCasting)) { + return false; + } + final ItemWandCasting wand = (ItemWandCasting) itemstack.getItem(); + return !wand.isStaff(itemstack); + } + return itemstack.getItem() instanceof ItemThaumonomicon; + } - public void readCustomNBT(NBTTagCompound nbtt) { - super.readCustomNBT(nbtt); - NBTTagList var2 = nbtt.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); - } - for(int i = 0; i < 3; i++) - for(int j = 0; j < 3; j++) - pattern[i][j] = nbtt.getBoolean(PATTERN_TAG + i * 3 + j); - NBTTagCompound nbtt1 = nbtt.getCompoundTag(WAITING_TAG); - if(nbtt1 != null) - waitingStack = ItemStack.loadItemStackFromNBT(nbtt1); - } + private boolean isLocked(int slot) { + return pattern != null && !pattern[slot / 3][slot % 3]; + } - public void writeCustomNBT(NBTTagCompound nbtt) { - super.writeCustomNBT(nbtt); - 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); - } - } - nbtt.setTag("Items", var2); - for(int i = 0; i < 3; i++) - for(int j = 0; j < 3; j++) - nbtt.setBoolean(PATTERN_TAG + i * 3 + j, pattern[i][j]); - NBTTagCompound nbtt1 = new NBTTagCompound(); - if(waitingStack != null) { - waitingStack.writeToNBT(nbtt1); - nbtt.setTag(WAITING_TAG, nbtt1); - } - } + public void readCustomNBT(NBTTagCompound nbtt) { + super.readCustomNBT(nbtt); + NBTTagList var2 = nbtt.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); + } + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) pattern[i][j] = nbtt.getBoolean(PATTERN_TAG + i * 3 + j); + NBTTagCompound nbtt1 = nbtt.getCompoundTag(WAITING_TAG); + if (nbtt1 != null) waitingStack = ItemStack.loadItemStackFromNBT(nbtt1); + } - public void markDirty() { - super.markDirty(); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - } + public void writeCustomNBT(NBTTagCompound nbtt) { + super.writeCustomNBT(nbtt); + 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); + } + } + nbtt.setTag("Items", var2); + for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) nbtt.setBoolean(PATTERN_TAG + i * 3 + j, pattern[i][j]); + NBTTagCompound nbtt1 = new NBTTagCompound(); + if (waitingStack != null) { + waitingStack.writeToNBT(nbtt1); + nbtt.setTag(WAITING_TAG, nbtt1); + } + } - public void onDataPacket(NetworkManager manager, S35PacketUpdateTileEntity packet) { - super.onDataPacket(manager, packet); - worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); - } + public void markDirty() { + super.markDirty(); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + } - public Packet getDescriptionPacket() { - final NBTTagCompound compound = new NBTTagCompound(); - this.writeToNBT(compound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 10, compound); - } + public void onDataPacket(NetworkManager manager, S35PacketUpdateTileEntity packet) { + super.onDataPacket(manager, packet); + worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); + } - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return i == 9; - } + public Packet getDescriptionPacket() { + final NBTTagCompound compound = new NBTTagCompound(); + this.writeToNBT(compound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 10, compound); + } - public int[] getAccessibleSlotsFromSide(int side) { - return ACCESSIBLE_SLOTS; - } + public boolean canExtractItem(int i, ItemStack itemstack, int j) { + return i == 9; + } - public boolean canInsertItem(int i, ItemStack stack, int j) { - return i < 9; - } + public int[] getAccessibleSlotsFromSide(int side) { + return ACCESSIBLE_SLOTS; + } - public int getInventoryStackLimit() { - return 1; - } + public boolean canInsertItem(int i, ItemStack stack, int j) { + return i < 9; + } - public int onWandRightClick(World world, ItemStack wandstack, EntityPlayer player, int x, int y, int z, int side, int md) { - return 0; - } + public int getInventoryStackLimit() { + return 1; + } - public ItemStack onWandRightClick(final World world, final ItemStack wandstack, final EntityPlayer player) { - this.player = player; - return wandstack; - } + public int onWandRightClick(World world, ItemStack wandstack, EntityPlayer player, int x, int y, int z, int side, + int md) { + return 0; + } - public void onUsingWandTick(ItemStack wandstack, EntityPlayer player, int count) {} + public ItemStack onWandRightClick(final World world, final ItemStack wandstack, final EntityPlayer player) { + this.player = player; + return wandstack; + } - public void onWandStoppedUsing(ItemStack wandstack, World world, EntityPlayer player, int count) {} + public void onUsingWandTick(ItemStack wandstack, EntityPlayer player, int count) {} - public void ejectAll() { - for(int i = 0; i < 10; ++i) { - ItemStack stack = getStackInSlot(i); - if(stack != null) - eject(stack, false); - setInventorySlotContents(i, null); - } - this.waitingStack = null; - markDirty(); - } + public void onWandStoppedUsing(ItemStack wandstack, World world, EntityPlayer player, int count) {} - 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; - setInventorySlotContents(0, null); - if(!worldObj.isRemote) - worldObj.spawnEntityInWorld(item); - } + public void ejectAll() { + for (int i = 0; i < 10; ++i) { + ItemStack stack = getStackInSlot(i); + if (stack != null) eject(stack, false); + setInventorySlotContents(i, null); + } + this.waitingStack = null; + markDirty(); + } - 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; + if (redstone) item.age = -200; + setInventorySlotContents(0, null); + if (!worldObj.isRemote) worldObj.spawnEntityInWorld(item); + } - ItemStack[] inventorySlots = new ItemStack[getSizeInventory()]; + 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; + } - @Override - public ItemStack getStackInSlot(int i) { - return inventorySlots[i]; - } + ItemStack[] inventorySlots = new ItemStack[getSizeInventory()]; - 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 getStackInSlot(int i) { + return inventorySlots[i]; + } - // Copied from vazkii.botania.common.block.tile.TileSimpleInventory + 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; + } - public ItemStack getStackInSlotOnClosing(int i) { - return getStackInSlot(i); - } + // Copied from vazkii.botania.common.block.tile.TileSimpleInventory - public void setInventorySlotContents(int i, ItemStack itemstack) { - inventorySlots[i] = itemstack; - } + public ItemStack getStackInSlotOnClosing(int i) { + return getStackInSlot(i); + } - 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; - } + public void setInventorySlotContents(int i, ItemStack itemstack) { + inventorySlots[i] = itemstack; + } - public boolean hasCustomInventoryName() { - return false; - } + 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; + } - public void openInventory() {} + public boolean hasCustomInventoryName() { + return false; + } - public void closeInventory() {} -} \ No newline at end of file + public void openInventory() {} + + public void closeInventory() {} +} diff --git a/src/main/java/ab/common/block/tile/TileManaCharger.java b/src/main/java/ab/common/block/tile/TileManaCharger.java index 680a4f8..2399485 100644 --- a/src/main/java/ab/common/block/tile/TileManaCharger.java +++ b/src/main/java/ab/common/block/tile/TileManaCharger.java @@ -1,279 +1,274 @@ package ab.common.block.tile; -import java.awt.Color; -import java.util.List; -import java.util.Random; - -import org.lwjgl.opengl.GL11; - -import ab.api.IRenderHud; -import ab.client.core.ClientHelper; -import ab.common.core.handler.ConfigABHandler; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.Packet; -import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.StatCollector; + +import org.lwjgl.opengl.GL11; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.mana.IManaItem; import vazkii.botania.api.mana.IManaReceiver; import vazkii.botania.api.mana.spark.ISparkAttachable; -import vazkii.botania.api.mana.spark.ISparkEntity; import vazkii.botania.api.wand.IWandBindable; -import vazkii.botania.client.core.handler.ClientTickHandler; -import vazkii.botania.client.core.handler.HUDHandler; import vazkii.botania.common.block.ModBlocks; -import vazkii.botania.common.block.tile.TileSimpleInventory; -import vazkii.botania.common.core.helper.Vector3; +import ab.api.IRenderHud; +import ab.client.core.ClientHelper; +import ab.common.core.handler.ConfigABHandler; public class TileManaCharger extends TileInventory implements ISidedInventory, IRenderHud, IWandBindable { - private static final int MANA_SPEED = 11240; - - public boolean requestUpdate; - int clientMana = -1; - int receiverPosX = -1; - int receiverPosY = -1; - int receiverPosZ = -1; - public int clientTick[] = new int[] {0, 0, 3, 12, 6}; - - public void updateEntity() { - boolean hasUpdate = false; - if(!this.worldObj.isRemote && requestUpdate) - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord); - ISparkAttachable receiver = this.getReceiver(); - if(receiver == null) - return; - for(int i = 0; i < this.getSizeInventory(); i++) { - ItemStack stack = this.getStackInSlot(i); - if(stack == null) - continue; - else if(stack.getItem() instanceof IManaItem) { - IManaItem mana = (IManaItem)stack.getItem(); - if(i == 0) { - if(mana.getMana(stack) > 0 && !receiver.isFull() && mana.canExportManaToPool(stack, (TileEntity)receiver)) { - int availableMana = ((ISparkAttachable)receiver).getAvailableSpaceForMana(); - int manaVal = Math.min(Math.min(mana.getMaxMana(stack) / 256, MANA_SPEED) * 3, Math.min(availableMana, mana.getMana(stack))); - if(!this.worldObj.isRemote) { - mana.addMana(stack, -manaVal); - if(this.worldObj.getTotalWorldTime() % 15 == 0) - hasUpdate = true; - } else { - clientTick[i]++; - } - receiver.recieveMana(manaVal); - } - continue; - } else if(receiver.getCurrentMana() > 0 && mana.getMana(stack) < mana.getMaxMana(stack) && mana.canReceiveManaFromPool(stack, (TileEntity)receiver)) { - int manaVal = Math.min(Math.min(mana.getMaxMana(stack) / 256, MANA_SPEED), Math.min(receiver.getCurrentMana(), mana.getMaxMana(stack) - mana.getMana(stack))); - if(!this.worldObj.isRemote) { - mana.addMana(stack, manaVal); - if(this.worldObj.getTotalWorldTime() % 15 == 0) - hasUpdate = true; - } else { - if(ConfigABHandler.useManaChargerAnimation) - clientTick[i]++; - } - receiver.recieveMana(-manaVal); - } - } - } - requestUpdate = hasUpdate; - } - - public ISparkAttachable getReceiver() { - ISparkAttachable receiver = null; - if(this.worldObj != null && this.receiverPosY != -1) { - TileEntity tile = this.worldObj.getTileEntity(receiverPosX, receiverPosY, receiverPosZ); - if(tile != null && tile instanceof ISparkAttachable) { - receiver = (ISparkAttachable)tile; - } - } - if(receiver == null) { - receiverPosX = -1; - receiverPosY = -1; - receiverPosZ = -1; - } - return receiver; - } - - public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - return true; - } - - public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { - TileEntity tile = this.worldObj.getTileEntity(x, y, z); - boolean isFar = Math.abs(this.xCoord - x) >= 10 || Math.abs(this.yCoord - y) >= 10 || Math.abs(this.zCoord - z) >= 10; - if(isFar) - return false; - else if(tile instanceof ISparkAttachable && ((ISparkAttachable)tile).canRecieveManaFromBursts()) { - if(!this.worldObj.isRemote) { - this.receiverPosX = tile.xCoord; - this.receiverPosY = tile.yCoord; - this.receiverPosZ = tile.zCoord; - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord); - } - return true; - } - return false; - } - - public ChunkCoordinates getBinding() { - IManaReceiver receiver = this.getReceiver(); - if(receiver == null) - return null; - TileEntity tile = (TileEntity)receiver; - return new ChunkCoordinates(tile.xCoord, tile.yCoord, tile.zCoord); - } - - public static float getManaPercent(ItemStack stack) { - if(!(stack.getItem() instanceof IManaItem)) - return 0.0f; - IManaItem mana = (IManaItem)stack.getItem(); - return (float)mana.getMana(stack) / (mana.getMaxMana(stack) / 100.0f); - } - - public void renderHud(Minecraft mc, ScaledResolution res) { - int xc = res.getScaledWidth() / 2; - int yc = res.getScaledHeight() / 2; - int radius = 42; - int amt = 0; - for(int i = 0; i < getSizeInventory(); i++) - if(getStackInSlot(i) != null) - amt++; - float angle = -90.0f; - if(amt >= 0) { - for (int i = 0; i < getSizeInventory(); i++) { - ItemStack stack = getStackInSlot(i); - if(stack == null) - continue; - float anglePer = 360.0F / amt; - double xPos = xc + Math.cos(angle * Math.PI / 180.0D) * radius - 8.0D; - double yPos = yc + Math.sin(angle * Math.PI / 180.0D) * radius - 8.0D; - RenderHelper.enableGUIStandardItemLighting(); - GL11.glPushMatrix(); - GL11.glEnable(3042); - GL11.glBlendFunc(770, 771); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glTranslated(xPos, yPos, 0.0D); - vazkii.botania.client.core.helper.RenderHelper.renderProgressPie(0, 0, getManaPercent(stack) / 100.0f, stack); - if(i == 0) { - GL11.glScalef(0.75f, 0.75f, 0.75f); - GL11.glTranslated(11.0D, 10.0D, 0.0D); - RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModBlocks.pool), 0, 0); - } - GL11.glDisable(2896); - GL11.glDisable(3042); - GL11.glPopMatrix(); - RenderHelper.disableStandardItemLighting(); - angle += anglePer; - } - } - } - - public void onWanded(EntityPlayer player, ItemStack wand) { - ISparkAttachable reciever = getReceiver(); - if(player == null) - return; - if(this.worldObj.isRemote && reciever != null) - clientMana = reciever.getCurrentMana(); - this.worldObj.playSoundAtEntity((Entity)player, "botania:ding", 0.11F, 1.0F); - } - - public void renderHUD(Minecraft mc, ScaledResolution res) { - ISparkAttachable reciever = getReceiver(); - if(reciever != null) { - String name = StatCollector.translateToLocal("ab.manaCharger.wandHud"); - TileEntity receiverTile = (TileEntity)reciever; - ItemStack recieverStack = new ItemStack(this.worldObj.getBlock(receiverTile.xCoord, receiverTile.yCoord, receiverTile.zCoord), 1, receiverTile.getBlockMetadata()); - GL11.glEnable(3042); - GL11.glBlendFunc(770, 771); - 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 + 48; - mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, 0xf4f4f4); - RenderHelper.enableGUIStandardItemLighting(); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recieverStack, x, y); - RenderHelper.disableStandardItemLighting(); - } - GL11.glDisable(2896); - GL11.glDisable(3042); - ClientHelper.drawPoolManaHUD(res, name, clientMana, reciever.getAvailableSpaceForMana() + reciever.getCurrentMana(), 0xb9bbae); - } - } - - public int getSizeInventory() { - return 5; - } - - public int getInventoryStackLimit() { - return 1; - } + private static final int MANA_SPEED = 11240; - public String getInventoryName() { - return "ab.manaCharger"; - } - - public void writeCustomNBT(NBTTagCompound nbtt) { - super.writeCustomNBT(nbtt); - nbtt.setInteger("bindingX", this.receiverPosX); - nbtt.setInteger("bindingY", this.receiverPosY); - nbtt.setInteger("bindingZ", this.receiverPosZ); - nbtt.setBoolean("requestUpdate", this.requestUpdate); - } - - public void readFromNBT(NBTTagCompound nbtt) { - super.readFromNBT(nbtt); - this.requestUpdate = nbtt.getBoolean("requestUpdate"); - } - - public void readCustomNBT(NBTTagCompound nbtt) { - super.readCustomNBT(nbtt); - this.receiverPosX = nbtt.getInteger("bindingX"); - this.receiverPosY = nbtt.getInteger("bindingY"); - this.receiverPosZ = nbtt.getInteger("bindingZ"); - } + public boolean requestUpdate; + int clientMana = -1; + int receiverPosX = -1; + int receiverPosY = -1; + int receiverPosZ = -1; + public int clientTick[] = new int[] { 0, 0, 3, 12, 6 }; - public int[] getAccessibleSlotsFromSide(int side) { - return new int[] {1, 2, 3, 4}; - } + public void updateEntity() { + boolean hasUpdate = false; + if (!this.worldObj.isRemote && requestUpdate) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord); + ISparkAttachable receiver = this.getReceiver(); + if (receiver == null) return; + for (int i = 0; i < this.getSizeInventory(); i++) { + ItemStack stack = this.getStackInSlot(i); + if (stack == null) continue; + else if (stack.getItem() instanceof IManaItem) { + IManaItem mana = (IManaItem) stack.getItem(); + if (i == 0) { + if (mana.getMana(stack) > 0 && !receiver.isFull() + && mana.canExportManaToPool(stack, (TileEntity) receiver)) { + int availableMana = ((ISparkAttachable) receiver).getAvailableSpaceForMana(); + int manaVal = Math.min( + Math.min(mana.getMaxMana(stack) / 256, MANA_SPEED) * 3, + Math.min(availableMana, mana.getMana(stack))); + if (!this.worldObj.isRemote) { + mana.addMana(stack, -manaVal); + if (this.worldObj.getTotalWorldTime() % 15 == 0) hasUpdate = true; + } else { + clientTick[i]++; + } + receiver.recieveMana(manaVal); + } + continue; + } else if (receiver.getCurrentMana() > 0 && mana.getMana(stack) < mana.getMaxMana(stack) + && mana.canReceiveManaFromPool(stack, (TileEntity) receiver)) { + int manaVal = Math.min( + Math.min(mana.getMaxMana(stack) / 256, MANA_SPEED), + Math.min(receiver.getCurrentMana(), mana.getMaxMana(stack) - mana.getMana(stack))); + if (!this.worldObj.isRemote) { + mana.addMana(stack, manaVal); + if (this.worldObj.getTotalWorldTime() % 15 == 0) hasUpdate = true; + } else { + if (ConfigABHandler.useManaChargerAnimation) clientTick[i]++; + } + receiver.recieveMana(-manaVal); + } + } + } + requestUpdate = hasUpdate; + } - public boolean canInsertItem(int slot, ItemStack stack, int side) { - boolean isManaItem = false; - if(stack != null && stack.getItem() instanceof IManaItem) { - IManaItem mana = (IManaItem)stack.getItem(); - ISparkAttachable receiver = this.getReceiver(); - if(receiver == null) - return false; - isManaItem = mana.getMana(stack) < mana.getMaxMana(stack) && mana.canReceiveManaFromPool(stack, (TileEntity)receiver); - } - return side == 1 && slot != 0 && isManaItem; - } + public ISparkAttachable getReceiver() { + ISparkAttachable receiver = null; + if (this.worldObj != null && this.receiverPosY != -1) { + TileEntity tile = this.worldObj.getTileEntity(receiverPosX, receiverPosY, receiverPosZ); + if (tile != null && tile instanceof ISparkAttachable) { + receiver = (ISparkAttachable) tile; + } + } + if (receiver == null) { + receiverPosX = -1; + receiverPosY = -1; + receiverPosZ = -1; + } + return receiver; + } - public boolean canExtractItem(int slot, ItemStack stack, int side) { - boolean isManaItem = false; - if(stack != null && stack.getItem() instanceof IManaItem) { - IManaItem mana = (IManaItem)stack.getItem(); - ISparkAttachable receiver = this.getReceiver(); - if(receiver == null) - return false; - isManaItem = mana.getMana(stack) == mana.getMaxMana(stack); - } - return side == 0 && slot != 0 && isManaItem; - } -} \ No newline at end of file + public boolean canSelect(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + return true; + } + + public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) { + TileEntity tile = this.worldObj.getTileEntity(x, y, z); + boolean isFar = Math.abs(this.xCoord - x) >= 10 || Math.abs(this.yCoord - y) >= 10 + || Math.abs(this.zCoord - z) >= 10; + if (isFar) return false; + else if (tile instanceof ISparkAttachable && ((ISparkAttachable) tile).canRecieveManaFromBursts()) { + if (!this.worldObj.isRemote) { + this.receiverPosX = tile.xCoord; + this.receiverPosY = tile.yCoord; + this.receiverPosZ = tile.zCoord; + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord); + } + return true; + } + return false; + } + + public ChunkCoordinates getBinding() { + IManaReceiver receiver = this.getReceiver(); + if (receiver == null) return null; + TileEntity tile = (TileEntity) receiver; + return new ChunkCoordinates(tile.xCoord, tile.yCoord, tile.zCoord); + } + + public static float getManaPercent(ItemStack stack) { + if (!(stack.getItem() instanceof IManaItem)) return 0.0f; + IManaItem mana = (IManaItem) stack.getItem(); + return (float) mana.getMana(stack) / (mana.getMaxMana(stack) / 100.0f); + } + + public void renderHud(Minecraft mc, ScaledResolution res) { + int xc = res.getScaledWidth() / 2; + int yc = res.getScaledHeight() / 2; + int radius = 42; + int amt = 0; + for (int i = 0; i < getSizeInventory(); i++) if (getStackInSlot(i) != null) amt++; + float angle = -90.0f; + if (amt >= 0) { + for (int i = 0; i < getSizeInventory(); i++) { + ItemStack stack = getStackInSlot(i); + if (stack == null) continue; + float anglePer = 360.0F / amt; + double xPos = xc + Math.cos(angle * Math.PI / 180.0D) * radius - 8.0D; + double yPos = yc + Math.sin(angle * Math.PI / 180.0D) * radius - 8.0D; + RenderHelper.enableGUIStandardItemLighting(); + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glTranslated(xPos, yPos, 0.0D); + vazkii.botania.client.core.helper.RenderHelper + .renderProgressPie(0, 0, getManaPercent(stack) / 100.0f, stack); + if (i == 0) { + GL11.glScalef(0.75f, 0.75f, 0.75f); + GL11.glTranslated(11.0D, 10.0D, 0.0D); + RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance().renderItemAndEffectIntoGUI( + mc.fontRenderer, + mc.renderEngine, + new ItemStack(ModBlocks.pool), + 0, + 0); + } + GL11.glDisable(2896); + GL11.glDisable(3042); + GL11.glPopMatrix(); + RenderHelper.disableStandardItemLighting(); + angle += anglePer; + } + } + } + + public void onWanded(EntityPlayer player, ItemStack wand) { + ISparkAttachable reciever = getReceiver(); + if (player == null) return; + if (this.worldObj.isRemote && reciever != null) clientMana = reciever.getCurrentMana(); + this.worldObj.playSoundAtEntity((Entity) player, "botania:ding", 0.11F, 1.0F); + } + + public void renderHUD(Minecraft mc, ScaledResolution res) { + ISparkAttachable reciever = getReceiver(); + if (reciever != null) { + String name = StatCollector.translateToLocal("ab.manaCharger.wandHud"); + TileEntity receiverTile = (TileEntity) reciever; + ItemStack recieverStack = new ItemStack( + this.worldObj.getBlock(receiverTile.xCoord, receiverTile.yCoord, receiverTile.zCoord), + 1, + receiverTile.getBlockMetadata()); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + 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 + 48; + mc.fontRenderer.drawStringWithShadow(stackName, x + 20, y + 5, 0xf4f4f4); + RenderHelper.enableGUIStandardItemLighting(); + RenderItem.getInstance() + .renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recieverStack, x, y); + RenderHelper.disableStandardItemLighting(); + } + GL11.glDisable(2896); + GL11.glDisable(3042); + ClientHelper.drawPoolManaHUD( + res, + name, + clientMana, + reciever.getAvailableSpaceForMana() + reciever.getCurrentMana(), + 0xb9bbae); + } + } + + public int getSizeInventory() { + return 5; + } + + public int getInventoryStackLimit() { + return 1; + } + + public String getInventoryName() { + return "ab.manaCharger"; + } + + public void writeCustomNBT(NBTTagCompound nbtt) { + super.writeCustomNBT(nbtt); + nbtt.setInteger("bindingX", this.receiverPosX); + nbtt.setInteger("bindingY", this.receiverPosY); + nbtt.setInteger("bindingZ", this.receiverPosZ); + nbtt.setBoolean("requestUpdate", this.requestUpdate); + } + + public void readFromNBT(NBTTagCompound nbtt) { + super.readFromNBT(nbtt); + this.requestUpdate = nbtt.getBoolean("requestUpdate"); + } + + public void readCustomNBT(NBTTagCompound nbtt) { + super.readCustomNBT(nbtt); + this.receiverPosX = nbtt.getInteger("bindingX"); + this.receiverPosY = nbtt.getInteger("bindingY"); + this.receiverPosZ = nbtt.getInteger("bindingZ"); + } + + public int[] getAccessibleSlotsFromSide(int side) { + return new int[] { 1, 2, 3, 4 }; + } + + public boolean canInsertItem(int slot, ItemStack stack, int side) { + boolean isManaItem = false; + if (stack != null && stack.getItem() instanceof IManaItem) { + IManaItem mana = (IManaItem) stack.getItem(); + ISparkAttachable receiver = this.getReceiver(); + if (receiver == null) return false; + isManaItem = mana.getMana(stack) < mana.getMaxMana(stack) + && mana.canReceiveManaFromPool(stack, (TileEntity) receiver); + } + return side == 1 && slot != 0 && isManaItem; + } + + public boolean canExtractItem(int slot, ItemStack stack, int side) { + boolean isManaItem = false; + if (stack != null && stack.getItem() instanceof IManaItem) { + IManaItem mana = (IManaItem) stack.getItem(); + ISparkAttachable receiver = this.getReceiver(); + if (receiver == null) return false; + isManaItem = mana.getMana(stack) == mana.getMaxMana(stack); + } + return side == 0 && slot != 0 && isManaItem; + } +} diff --git a/src/main/java/ab/common/block/tile/TileManaContainer.java b/src/main/java/ab/common/block/tile/TileManaContainer.java index 58aca85..2e056df 100644 --- a/src/main/java/ab/common/block/tile/TileManaContainer.java +++ b/src/main/java/ab/common/block/tile/TileManaContainer.java @@ -3,128 +3,139 @@ package ab.common.block.tile; import java.awt.Color; import java.util.List; -import org.lwjgl.opengl.GL11; - -import ab.client.core.ClientHelper; -import ab.common.core.handler.ConfigABHandler; -import ab.common.lib.register.BlockListAB; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.StatCollector; -import vazkii.botania.api.internal.VanillaPacketDispatcher; + import vazkii.botania.api.mana.IManaPool; -import vazkii.botania.api.mana.IManaReceiver; -import vazkii.botania.api.mana.IThrottledPacket; import vazkii.botania.api.mana.spark.ISparkAttachable; import vazkii.botania.api.mana.spark.ISparkEntity; -import vazkii.botania.client.core.handler.HUDHandler; import vazkii.botania.common.Botania; import vazkii.botania.common.block.tile.TileMod; +import ab.client.core.ClientHelper; +import ab.common.core.handler.ConfigABHandler; public class TileManaContainer extends TileMod implements IManaPool, ISparkAttachable { - - protected int mana = 0; - int knownMana = -1; - + + protected int mana = 0; + int knownMana = -1; + public boolean canUpdate() { return true; } - - public void updateEntity() { - if(this.worldObj.isRemote) { - double particleChance = 1.0D - getCurrentMana() / getMaxMana() * 0.1D; - Color color = new Color(50943); - if(Math.random() > particleChance) - Botania.proxy.wispFX(this.worldObj, this.xCoord + 0.5f + (Math.random() - 0.5) * 0.4f, this.yCoord + 0.81D + (Math.random() * 0.05D), this.zCoord + 0.5f + (Math.random() - 0.5) * 0.4f, color.getRed() / 255.0F, color.getGreen() / 255.0F, color.getBlue() / 255.0F, (float)Math.random() / 4.2F, (float)-Math.random() / 50.0F, 2.0F); - } - } - - public void onWanded(EntityPlayer player, ItemStack wand) { - if(player == null) - return; - if(!this.worldObj.isRemote) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - writeCustomNBT(nbttagcompound); - nbttagcompound.setInteger("knownMana", getCurrentMana()); - if (player instanceof EntityPlayerMP) - ((EntityPlayerMP)player).playerNetServerHandler.sendPacket((Packet)new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, -999, nbttagcompound)); - } - this.worldObj.playSoundAtEntity((Entity)player, "botania:ding", 0.11F, 1.0F); - } - - public void renderHUD(Minecraft mc, ScaledResolution res) { - String name = StatCollector.translateToLocal("ab.manaContainer." + worldObj.getBlockMetadata(xCoord, yCoord, zCoord) + ".hud"); - int color = 0x30ead1; - ClientHelper.drawPoolManaHUD(res, name, this.knownMana, getMaxMana(), color); - } - - public int getCurrentMana() { - return this.mana; - } - - public boolean canRecieveManaFromBursts() { - return true; - } - - public int getMaxMana() { - int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); - return ConfigABHandler.maxContainerMana[Math.min(Math.max(meta, 0), ConfigABHandler.maxContainerMana.length)]; - } - public boolean isFull() { - return this.mana == getMaxMana(); - } + public void updateEntity() { + if (this.worldObj.isRemote) { + double particleChance = 1.0D - getCurrentMana() / getMaxMana() * 0.1D; + Color color = new Color(50943); + if (Math.random() > particleChance) Botania.proxy.wispFX( + this.worldObj, + this.xCoord + 0.5f + (Math.random() - 0.5) * 0.4f, + this.yCoord + 0.81D + (Math.random() * 0.05D), + this.zCoord + 0.5f + (Math.random() - 0.5) * 0.4f, + color.getRed() / 255.0F, + color.getGreen() / 255.0F, + color.getBlue() / 255.0F, + (float) Math.random() / 4.2F, + (float) -Math.random() / 50.0F, + 2.0F); + } + } - public void recieveMana(int mana) { - this.mana = Math.max(0, Math.min(getCurrentMana() + mana, getMaxMana())); - } - - public void writeCustomNBT(NBTTagCompound nbtt) { - nbtt.setInteger("mana", this.mana); - } - - public void readCustomNBT(NBTTagCompound nbtt) { - this.mana = nbtt.getInteger("mana"); - if (nbtt.hasKey("knownMana")) - this.knownMana = nbtt.getInteger("knownMana"); - } + public void onWanded(EntityPlayer player, ItemStack wand) { + if (player == null) return; + if (!this.worldObj.isRemote) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeCustomNBT(nbttagcompound); + nbttagcompound.setInteger("knownMana", getCurrentMana()); + if (player instanceof EntityPlayerMP) ((EntityPlayerMP) player).playerNetServerHandler.sendPacket( + (Packet) new S35PacketUpdateTileEntity( + this.xCoord, + this.yCoord, + this.zCoord, + -999, + nbttagcompound)); + } + this.worldObj.playSoundAtEntity((Entity) player, "botania:ding", 0.11F, 1.0F); + } - public boolean areIncomingTranfersDone() { - return false; - } + public void renderHUD(Minecraft mc, ScaledResolution res) { + String name = StatCollector + .translateToLocal("ab.manaContainer." + worldObj.getBlockMetadata(xCoord, yCoord, zCoord) + ".hud"); + int color = 0x30ead1; + ClientHelper.drawPoolManaHUD(res, name, this.knownMana, getMaxMana(), color); + } - public void attachSpark(ISparkEntity entity) {} + public int getCurrentMana() { + return this.mana; + } - public boolean canAttachSpark(ItemStack arg0) { - return true; - } + public boolean canRecieveManaFromBursts() { + return true; + } - public ISparkEntity getAttachedSpark() { - List sparks = this.worldObj.getEntitiesWithinAABB(ISparkEntity.class, AxisAlignedBB.getBoundingBox(this.xCoord, (this.yCoord + 1), this.zCoord, (this.xCoord + 1), (this.yCoord + 2), (this.zCoord + 1))); - if (sparks.size() == 1) { - Entity e = (Entity)sparks.get(0); - return (ISparkEntity)e; - } - return null; - } + public int getMaxMana() { + int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); + return ConfigABHandler.maxContainerMana[Math.min(Math.max(meta, 0), ConfigABHandler.maxContainerMana.length)]; + } - public int getAvailableSpaceForMana() { - return Math.max(0, getMaxMana() - getCurrentMana()); - } - - public boolean isOutputtingPower() { - return false; - } -} \ No newline at end of file + public boolean isFull() { + return this.mana == getMaxMana(); + } + + public void recieveMana(int mana) { + this.mana = Math.max(0, Math.min(getCurrentMana() + mana, getMaxMana())); + } + + public void writeCustomNBT(NBTTagCompound nbtt) { + nbtt.setInteger("mana", this.mana); + } + + public void readCustomNBT(NBTTagCompound nbtt) { + this.mana = nbtt.getInteger("mana"); + if (nbtt.hasKey("knownMana")) this.knownMana = nbtt.getInteger("knownMana"); + } + + public boolean areIncomingTranfersDone() { + return false; + } + + public void attachSpark(ISparkEntity entity) {} + + public boolean canAttachSpark(ItemStack arg0) { + return true; + } + + public ISparkEntity getAttachedSpark() { + List sparks = this.worldObj.getEntitiesWithinAABB( + ISparkEntity.class, + AxisAlignedBB.getBoundingBox( + this.xCoord, + (this.yCoord + 1), + this.zCoord, + (this.xCoord + 1), + (this.yCoord + 2), + (this.zCoord + 1))); + if (sparks.size() == 1) { + Entity e = (Entity) sparks.get(0); + return (ISparkEntity) e; + } + return null; + } + + public int getAvailableSpaceForMana() { + return Math.max(0, getMaxMana() - getCurrentMana()); + } + + public boolean isOutputtingPower() { + return false; + } +} diff --git a/src/main/java/ab/common/block/tile/TileManaCrystalCube.java b/src/main/java/ab/common/block/tile/TileManaCrystalCube.java index bb215e2..5330950 100644 --- a/src/main/java/ab/common/block/tile/TileManaCrystalCube.java +++ b/src/main/java/ab/common/block/tile/TileManaCrystalCube.java @@ -1,64 +1,49 @@ package ab.common.block.tile; -import java.util.ArrayList; import java.util.List; -import org.lwjgl.opengl.GL11; - -import ab.api.IRenderHud; -import ab.client.core.ClientHelper; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.Packet; -import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.util.StatCollector; + import vazkii.botania.api.mana.spark.ISparkAttachable; import vazkii.botania.api.mana.spark.ISparkEntity; import vazkii.botania.api.mana.spark.SparkHelper; -import vazkii.botania.client.core.handler.HUDHandler; -import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.TileMod; +import ab.api.IRenderHud; +import ab.client.core.ClientHelper; public class TileManaCrystalCube extends TileMod implements IRenderHud { - int knownMana = -1; - int knownMaxMana = -1; - - public boolean canUpdate() { + int knownMana = -1; + int knownMaxMana = -1; + + public boolean canUpdate() { return false; } - - public void updateEntity() {} - - public void renderHud(Minecraft mc, ScaledResolution res) { - String name = StatCollector.translateToLocal("ab.manaCrystalCube.hud"); - int color = 0x30ead1; - ClientHelper.drawPoolManaHUD(res, name, this.knownMana, this.knownMaxMana, color); - } - - public int[] getManaAround() { - int[] mana = new int[] { 0, 0 }; - List allSparks = SparkHelper.getSparksAround(worldObj, xCoord, yCoord, zCoord); - for(ISparkEntity spark : allSparks) { - ISparkAttachable tileMana = spark.getAttachedTile(); - mana[1] += tileMana.getCurrentMana() + tileMana.getAvailableSpaceForMana(); - mana[0] += tileMana.getCurrentMana(); - } - return mana; - } - - public void readCustomNBT(NBTTagCompound nbtt) { - if (nbtt.hasKey("knownMana")) - this.knownMana = nbtt.getInteger("knownMana"); - if (nbtt.hasKey("knownMaxMana")) - this.knownMaxMana = nbtt.getInteger("knownMaxMana"); - } + + public void updateEntity() {} + + public void renderHud(Minecraft mc, ScaledResolution res) { + String name = StatCollector.translateToLocal("ab.manaCrystalCube.hud"); + int color = 0x30ead1; + ClientHelper.drawPoolManaHUD(res, name, this.knownMana, this.knownMaxMana, color); + } + + public int[] getManaAround() { + int[] mana = new int[] { 0, 0 }; + List allSparks = SparkHelper.getSparksAround(worldObj, xCoord, yCoord, zCoord); + for (ISparkEntity spark : allSparks) { + ISparkAttachable tileMana = spark.getAttachedTile(); + mana[1] += tileMana.getCurrentMana() + tileMana.getAvailableSpaceForMana(); + mana[0] += tileMana.getCurrentMana(); + } + return mana; + } + + public void readCustomNBT(NBTTagCompound nbtt) { + if (nbtt.hasKey("knownMana")) this.knownMana = nbtt.getInteger("knownMana"); + if (nbtt.hasKey("knownMaxMana")) this.knownMaxMana = nbtt.getInteger("knownMaxMana"); + } } diff --git a/src/main/java/ab/common/block/tile/TileNidavellirForge.java b/src/main/java/ab/common/block/tile/TileNidavellirForge.java index efad430..41ae6e5 100644 --- a/src/main/java/ab/common/block/tile/TileNidavellirForge.java +++ b/src/main/java/ab/common/block/tile/TileNidavellirForge.java @@ -4,261 +4,288 @@ import java.awt.Color; import java.util.List; import java.util.Random; -import ab.api.AdvancedBotanyAPI; -import ab.api.recipe.RecipeAdvancedPlate; -import ab.common.lib.register.BlockListAB; -import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; -import net.minecraft.init.Blocks; -import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; -import scala.reflect.internal.Trees.This; + import vazkii.botania.api.internal.VanillaPacketDispatcher; -import vazkii.botania.api.lexicon.multiblock.Multiblock; -import vazkii.botania.api.lexicon.multiblock.MultiblockSet; import vazkii.botania.api.mana.IManaPool; -import vazkii.botania.api.mana.IManaReceiver; import vazkii.botania.api.mana.spark.ISparkAttachable; import vazkii.botania.api.mana.spark.ISparkEntity; import vazkii.botania.api.mana.spark.SparkHelper; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.common.Botania; -import vazkii.botania.common.block.ModBlocks; -import vazkii.botania.common.block.ModFluffBlocks; -import vazkii.botania.common.block.tile.TileMod; -import vazkii.botania.common.block.tile.TileSimpleInventory; -import vazkii.botania.common.item.ModItems; +import ab.api.AdvancedBotanyAPI; +import ab.api.recipe.RecipeAdvancedPlate; public class TileNidavellirForge extends TileInventory implements ISparkAttachable, ISidedInventory { - private int mana; - public int manaToGet; - private RecipeAdvancedPlate currentRecipe; - private int recipeID; - public boolean requestUpdate; - - public void updateEntity() { - if(!this.worldObj.isRemote) - updateServer(); - else - updateClient(); - ISparkEntity spark = getAttachedSpark(); - if (spark != null) { - List sparkEntities = SparkHelper.getSparksAround(this.worldObj, this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D); - for (ISparkEntity otherSpark : sparkEntities) { - if(spark == otherSpark) - continue; - else if(otherSpark.getAttachedTile() != null && otherSpark.getAttachedTile() instanceof IManaPool) - otherSpark.registerTransfer(spark); - } - } - } - - private void updateServer() { - if(requestUpdate) - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord); - boolean hasUpdate = false; - List items = this.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord, this.zCoord, (this.xCoord + 1), (this.yCoord + 1), (this.zCoord + 1))); - for(EntityItem item : items) { - if(item.getEntityItem() != null && !item.isDead) { - ItemStack stack = item.getEntityItem(); - int splitCount = addItemStack(stack); - stack.stackSize -= splitCount; - if(stack.stackSize <= 0) - item.setDead(); - if(splitCount > 0) - hasUpdate = true; - break; - } - } - int wasManaToGet = this.manaToGet; - boolean hasCraft = false; - int recipeID = 0; - for(RecipeAdvancedPlate recipe : AdvancedBotanyAPI.advancedPlateRecipes) { - if(recipe.matches(this)) { - this.recipeID = recipeID; - if(this.mana > 0 && this.isFull()) { - ItemStack output = recipe.getOutput().copy(); - this.recieveMana(-recipe.getManaUsage()); - this.manaToGet = 0; - for(int i = 1; i < this.getSizeInventory(); i++) { - if(this.getStackInSlot(i).stackSize > 1) - --this.getStackInSlot(i).stackSize; - else - this.setInventorySlotContents(i, null); - } - if(this.getStackInSlot(0) != null) - ++this.getStackInSlot(0).stackSize; - else - this.setInventorySlotContents(0, output); - hasUpdate = true; - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:terrasteelCraft", 1.0F, 2.0F); - break; - } else { - if(this.getStackInSlot(0) == null) { - this.manaToGet = recipe.getManaUsage(); - currentRecipe = recipe; - hasCraft = true; - break; - } else if(isItemEqual(recipe.getOutput(), getStackInSlot(0)) && getStackInSlot(0).stackSize < recipe.getOutput().getMaxStackSize()) { - this.manaToGet = recipe.getManaUsage(); - currentRecipe = recipe; - hasCraft = true; - break; - } - } - } - recipeID++; - } - if(!hasCraft) { - currentRecipe = null; - this.mana = 0; - this.manaToGet = 0; - } - if(this.manaToGet != wasManaToGet) - hasUpdate = true; - requestUpdate = hasUpdate; - } - - private void updateClient() { - if(this.mana > 0) { - double worldTime = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks; - worldTime += (new Random((this.xCoord ^ this.yCoord ^ this.zCoord))).nextInt(360); - float indetY = (float)(Math.sin(worldTime / 18.0D) / 24.0D); - float ticks = 100.0F * getCurrentMana() / this.manaToGet; - int totalSpiritCount = 3; - double tickIncrement = 360.0D / totalSpiritCount; - int speed = 5; - double wticks = (ticks * speed) - tickIncrement; - double r = Math.sin((ticks - 100) / 10.0D) * 0.5D; - double g = Math.sin(wticks * Math.PI / 180.0D * 0.55D); - float size = 0.4f; - for(int i = 0; i < totalSpiritCount; i++) { - double x = this.xCoord + Math.sin(wticks * Math.PI / 180.0D) * r + 0.5D; - double y = this.yCoord - indetY + 0.85D + Math.abs(r) * 0.7D; - double z = this.zCoord + Math.cos(wticks * Math.PI / 180.0D) * r + 0.5D; - wticks += tickIncrement; - int color = 0x24cce0; - if(currentRecipe != null) - color = currentRecipe.getColor(); - float hsb[] = Color.RGBtoHSB(color & 255, color >> 8 & 255, color >> 16 & 255, null); - int color1 = Color.HSBtoRGB(hsb[0], hsb[1], ticks / 100.0F); - float[] colorsfx = { (color1 & 255) / 255.0f, (color1 >> 8 & 255) / 255.0f, (color1 >> 16 & 255) / 255.0f }; - Botania.proxy.wispFX(this.worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], 0.85F * size, (float)g * 0.05F, 0.25F); - Botania.proxy.wispFX(this.worldObj, x, y, z, colorsfx[0], colorsfx[1], colorsfx[2], (float)Math.random() * 0.1F + 0.1F * size, (float)(Math.random() - 0.5D) * 0.05F, (float)(Math.random() - 0.5D) * 0.05F, (float)(Math.random() - 0.5D) * 0.05F, 0.9F); - if(ticks == 100) - for(int j = 0; j < 12; j++) - Botania.proxy.wispFX(this.worldObj, this.xCoord + 0.5D, this.yCoord + 1.1D - indetY, this.zCoord + 0.5D, colorsfx[0], colorsfx[1], colorsfx[2], (float)Math.random() * 0.15F + 0.15F * size, (float)(Math.random() - 0.5D) * 0.125F * size, (float)(Math.random() - 0.5D) * 0.125F * size, (float)(Math.random() - 0.5D) * 0.125F * size, 0.8f); - } - } - } - - public static boolean isItemEqual(ItemStack stack, ItemStack stack1) { - return stack.isItemEqual(stack1) && ItemStack.areItemStackTagsEqual(stack, stack1); - } - - private int addItemStack(ItemStack stack) { - for (int i = 1; i < getSizeInventory(); i++) { - if(getStackInSlot(i) == null) { - ItemStack stackToAdd = stack.copy(); - setInventorySlotContents(i, stackToAdd); - return stack.stackSize; - } else if(isItemEqual(stack, getStackInSlot(i))) { - if(getStackInSlot(i).stackSize < stack.getMaxStackSize()) { - int count = Math.min(stack.stackSize, stack.getMaxStackSize() - getStackInSlot(i).stackSize); - getStackInSlot(i).stackSize += count; - return count; - } - } - } - return 0; - } - - public void writeCustomNBT(NBTTagCompound cmp) { - super.writeCustomNBT(cmp); - cmp.setInteger("mana", mana); - cmp.setInteger("manaToGet", manaToGet); - cmp.setBoolean("requestUpdate", requestUpdate); - cmp.setInteger("recipeID", currentRecipe == null ? -1 : recipeID); - } - - public void readCustomNBT(NBTTagCompound cmp) { - super.readCustomNBT(cmp); - this.mana = cmp.getInteger("mana"); - this.manaToGet = cmp.getInteger("manaToGet"); - this.requestUpdate = cmp.getBoolean("requestUpdate"); - int recipeID = cmp.getInteger("recipeID"); - if(recipeID == -1) - this.currentRecipe = null; - else - this.currentRecipe = AdvancedBotanyAPI.advancedPlateRecipes.get(recipeID); - } + private int mana; + public int manaToGet; + private RecipeAdvancedPlate currentRecipe; + private int recipeID; + public boolean requestUpdate; - public int getSizeInventory() { - return 4; - } + public void updateEntity() { + if (!this.worldObj.isRemote) updateServer(); + else updateClient(); + ISparkEntity spark = getAttachedSpark(); + if (spark != null) { + List sparkEntities = SparkHelper + .getSparksAround(this.worldObj, this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D); + for (ISparkEntity otherSpark : sparkEntities) { + if (spark == otherSpark) continue; + else if (otherSpark.getAttachedTile() != null && otherSpark.getAttachedTile() instanceof IManaPool) + otherSpark.registerTransfer(spark); + } + } + } - public String getInventoryName() { - return "tileAdvancedPlate"; - } + private void updateServer() { + if (requestUpdate) + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this.worldObj, this.xCoord, this.yCoord, this.zCoord); + boolean hasUpdate = false; + List items = this.worldObj.getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox( + this.xCoord, + this.yCoord, + this.zCoord, + (this.xCoord + 1), + (this.yCoord + 1), + (this.zCoord + 1))); + for (EntityItem item : items) { + if (item.getEntityItem() != null && !item.isDead) { + ItemStack stack = item.getEntityItem(); + int splitCount = addItemStack(stack); + stack.stackSize -= splitCount; + if (stack.stackSize <= 0) item.setDead(); + if (splitCount > 0) hasUpdate = true; + break; + } + } + int wasManaToGet = this.manaToGet; + boolean hasCraft = false; + int recipeID = 0; + for (RecipeAdvancedPlate recipe : AdvancedBotanyAPI.advancedPlateRecipes) { + if (recipe.matches(this)) { + this.recipeID = recipeID; + if (this.mana > 0 && this.isFull()) { + ItemStack output = recipe.getOutput().copy(); + this.recieveMana(-recipe.getManaUsage()); + this.manaToGet = 0; + for (int i = 1; i < this.getSizeInventory(); i++) { + if (this.getStackInSlot(i).stackSize > 1) --this.getStackInSlot(i).stackSize; + else this.setInventorySlotContents(i, null); + } + if (this.getStackInSlot(0) != null) ++this.getStackInSlot(0).stackSize; + else this.setInventorySlotContents(0, output); + hasUpdate = true; + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:terrasteelCraft", 1.0F, 2.0F); + break; + } else { + if (this.getStackInSlot(0) == null) { + this.manaToGet = recipe.getManaUsage(); + currentRecipe = recipe; + hasCraft = true; + break; + } else if (isItemEqual(recipe.getOutput(), getStackInSlot(0)) + && getStackInSlot(0).stackSize < recipe.getOutput().getMaxStackSize()) { + this.manaToGet = recipe.getManaUsage(); + currentRecipe = recipe; + hasCraft = true; + break; + } + } + } + recipeID++; + } + if (!hasCraft) { + currentRecipe = null; + this.mana = 0; + this.manaToGet = 0; + } + if (this.manaToGet != wasManaToGet) hasUpdate = true; + requestUpdate = hasUpdate; + } - public int getCurrentMana() { - return this.mana; - } + private void updateClient() { + if (this.mana > 0) { + double worldTime = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks; + worldTime += (new Random((this.xCoord ^ this.yCoord ^ this.zCoord))).nextInt(360); + float indetY = (float) (Math.sin(worldTime / 18.0D) / 24.0D); + float ticks = 100.0F * getCurrentMana() / this.manaToGet; + int totalSpiritCount = 3; + double tickIncrement = 360.0D / totalSpiritCount; + int speed = 5; + double wticks = (ticks * speed) - tickIncrement; + double r = Math.sin((ticks - 100) / 10.0D) * 0.5D; + double g = Math.sin(wticks * Math.PI / 180.0D * 0.55D); + float size = 0.4f; + for (int i = 0; i < totalSpiritCount; i++) { + double x = this.xCoord + Math.sin(wticks * Math.PI / 180.0D) * r + 0.5D; + double y = this.yCoord - indetY + 0.85D + Math.abs(r) * 0.7D; + double z = this.zCoord + Math.cos(wticks * Math.PI / 180.0D) * r + 0.5D; + wticks += tickIncrement; + int color = 0x24cce0; + if (currentRecipe != null) color = currentRecipe.getColor(); + float hsb[] = Color.RGBtoHSB(color & 255, color >> 8 & 255, color >> 16 & 255, null); + int color1 = Color.HSBtoRGB(hsb[0], hsb[1], ticks / 100.0F); + float[] colorsfx = { (color1 & 255) / 255.0f, (color1 >> 8 & 255) / 255.0f, + (color1 >> 16 & 255) / 255.0f }; + Botania.proxy.wispFX( + this.worldObj, + x, + y, + z, + colorsfx[0], + colorsfx[1], + colorsfx[2], + 0.85F * size, + (float) g * 0.05F, + 0.25F); + Botania.proxy.wispFX( + this.worldObj, + x, + y, + z, + colorsfx[0], + colorsfx[1], + colorsfx[2], + (float) Math.random() * 0.1F + 0.1F * size, + (float) (Math.random() - 0.5D) * 0.05F, + (float) (Math.random() - 0.5D) * 0.05F, + (float) (Math.random() - 0.5D) * 0.05F, + 0.9F); + if (ticks == 100) for (int j = 0; j < 12; j++) Botania.proxy.wispFX( + this.worldObj, + this.xCoord + 0.5D, + this.yCoord + 1.1D - indetY, + this.zCoord + 0.5D, + colorsfx[0], + colorsfx[1], + colorsfx[2], + (float) Math.random() * 0.15F + 0.15F * size, + (float) (Math.random() - 0.5D) * 0.125F * size, + (float) (Math.random() - 0.5D) * 0.125F * size, + (float) (Math.random() - 0.5D) * 0.125F * size, + 0.8f); + } + } + } - public boolean isFull() { - return this.mana >= this.manaToGet; - } + public static boolean isItemEqual(ItemStack stack, ItemStack stack1) { + return stack.isItemEqual(stack1) && ItemStack.areItemStackTagsEqual(stack, stack1); + } - public void recieveMana(final int mana) { - this.mana = Math.min(this.mana + mana, this.manaToGet); - } - - public boolean canRecieveManaFromBursts() { - return !this.isFull(); - } - - public boolean canAttachSpark(ItemStack stack) { - return true; - } - - public void attachSpark(ISparkEntity entity) {} - - public ISparkEntity getAttachedSpark() { - List sparks = this.worldObj.getEntitiesWithinAABB(ISparkEntity.class, AxisAlignedBB.getBoundingBox(this.xCoord, (this.yCoord + 1), this.zCoord, (this.xCoord + 1), (this.yCoord + 2), (this.zCoord + 1))); - if (sparks.size() == 1) { - Entity e = (Entity)sparks.get(0); - return (ISparkEntity)e; - } - return null; - } - - public boolean areIncomingTranfersDone() { - return this.isFull(); - } - - public int getAvailableSpaceForMana() { - return Math.max(0, this.manaToGet - getCurrentMana()); - } - - public int[] getAccessibleSlotsFromSide(int side) { - return new int[]{0, 1, 2, 3}; - } + private int addItemStack(ItemStack stack) { + for (int i = 1; i < getSizeInventory(); i++) { + if (getStackInSlot(i) == null) { + ItemStack stackToAdd = stack.copy(); + setInventorySlotContents(i, stackToAdd); + return stack.stackSize; + } else if (isItemEqual(stack, getStackInSlot(i))) { + if (getStackInSlot(i).stackSize < stack.getMaxStackSize()) { + int count = Math.min(stack.stackSize, stack.getMaxStackSize() - getStackInSlot(i).stackSize); + getStackInSlot(i).stackSize += count; + return count; + } + } + } + return 0; + } - public boolean canInsertItem(int slot, ItemStack stack, int side) { - for(int i = 1; i < getSizeInventory(); i++) { - ItemStack slotStack = getStackInSlot(i); - if(slotStack != null && slotStack.stackSize == slotStack.getMaxStackSize() && isItemEqual(stack, slotStack)) - return false; - } - return side == 1 && slot != 0; - } + public void writeCustomNBT(NBTTagCompound cmp) { + super.writeCustomNBT(cmp); + cmp.setInteger("mana", mana); + cmp.setInteger("manaToGet", manaToGet); + cmp.setBoolean("requestUpdate", requestUpdate); + cmp.setInteger("recipeID", currentRecipe == null ? -1 : recipeID); + } - public boolean canExtractItem(int slot, ItemStack stack, int side) { - return (side == 0 && slot == 0) || (side != 0 && side != 1 && slot != 0); - } -} \ No newline at end of file + public void readCustomNBT(NBTTagCompound cmp) { + super.readCustomNBT(cmp); + this.mana = cmp.getInteger("mana"); + this.manaToGet = cmp.getInteger("manaToGet"); + this.requestUpdate = cmp.getBoolean("requestUpdate"); + int recipeID = cmp.getInteger("recipeID"); + if (recipeID == -1) this.currentRecipe = null; + else this.currentRecipe = AdvancedBotanyAPI.advancedPlateRecipes.get(recipeID); + } + + public int getSizeInventory() { + return 4; + } + + public String getInventoryName() { + return "tileAdvancedPlate"; + } + + public int getCurrentMana() { + return this.mana; + } + + public boolean isFull() { + return this.mana >= this.manaToGet; + } + + public void recieveMana(final int mana) { + this.mana = Math.min(this.mana + mana, this.manaToGet); + } + + public boolean canRecieveManaFromBursts() { + return !this.isFull(); + } + + public boolean canAttachSpark(ItemStack stack) { + return true; + } + + public void attachSpark(ISparkEntity entity) {} + + public ISparkEntity getAttachedSpark() { + List sparks = this.worldObj.getEntitiesWithinAABB( + ISparkEntity.class, + AxisAlignedBB.getBoundingBox( + this.xCoord, + (this.yCoord + 1), + this.zCoord, + (this.xCoord + 1), + (this.yCoord + 2), + (this.zCoord + 1))); + if (sparks.size() == 1) { + Entity e = (Entity) sparks.get(0); + return (ISparkEntity) e; + } + return null; + } + + public boolean areIncomingTranfersDone() { + return this.isFull(); + } + + public int getAvailableSpaceForMana() { + return Math.max(0, this.manaToGet - getCurrentMana()); + } + + public int[] getAccessibleSlotsFromSide(int side) { + return new int[] { 0, 1, 2, 3 }; + } + + public boolean canInsertItem(int slot, ItemStack stack, int side) { + for (int i = 1; i < getSizeInventory(); i++) { + ItemStack slotStack = getStackInSlot(i); + if (slotStack != null && slotStack.stackSize == slotStack.getMaxStackSize() + && isItemEqual(stack, slotStack)) + return false; + } + return side == 1 && slot != 0; + } + + public boolean canExtractItem(int slot, ItemStack stack, int side) { + return (side == 0 && slot == 0) || (side != 0 && side != 1 && slot != 0); + } +} diff --git a/src/main/java/ab/common/core/CommonHelper.java b/src/main/java/ab/common/core/CommonHelper.java index 597af42..233f199 100644 --- a/src/main/java/ab/common/core/CommonHelper.java +++ b/src/main/java/ab/common/core/CommonHelper.java @@ -6,53 +6,64 @@ import net.minecraft.block.IGrowable; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.world.BlockEvent; public class CommonHelper { - public static void fertilizer(World world, Block block, int xCoord, int yCoord, int zCoord, int count, EntityPlayer player) { - if(world.isRemote || !(block instanceof IGrowable) || block instanceof BlockSapling || world.getTileEntity(xCoord, yCoord, zCoord) != null) - return; - - if(player != null) { - BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(xCoord, yCoord, zCoord, world, world.getBlock(xCoord, yCoord, zCoord), world.getBlockMetadata(xCoord, yCoord, zCoord), player); - MinecraftForge.EVENT_BUS.post(event); - if(event.isCanceled()) - return; - } - - IGrowable igrowable = (IGrowable)block; - if(igrowable.func_149851_a(world, xCoord, yCoord, zCoord, world.isRemote)) - if(igrowable.func_149852_a(world, world.rand, xCoord, yCoord, zCoord)) { - int meta = world.getBlockMetadata(xCoord, yCoord, zCoord); - for(int i = 0; i < count; i++) { - if(meta != world.getBlockMetadata(xCoord, yCoord, zCoord)) - return; - igrowable.func_149853_b(world, world.rand, xCoord, yCoord, zCoord); - } - } - } - - public static boolean setBlock(World world, Block block, int meta, int x, int y, int z, EntityPlayer player, boolean checkAir) { - if(!world.isRemote) { - if(checkAir && !(world.getBlock(x, y, z).getMaterial() == Material.air)) - return false; - BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(x, y, z, world, world.getBlock(x, y, z), world.getBlockMetadata(x, y, z), player); - MinecraftForge.EVENT_BUS.post(event); - if(event.isCanceled()) - return false; - return setBlockWithY(world, block, meta, x, y, z); - } - return false; - } - - private static boolean setBlockWithY(World world, Block block, int meta, int x, int y, int z) { - if(y < 256) - world.setBlock(x, y, z, block, meta, 3); - else - return false; - return true; - } + public static void fertilizer(World world, Block block, int xCoord, int yCoord, int zCoord, int count, + EntityPlayer player) { + if (world.isRemote || !(block instanceof IGrowable) + || block instanceof BlockSapling + || world.getTileEntity(xCoord, yCoord, zCoord) != null) + return; + + if (player != null) { + BlockEvent.BreakEvent event = new BlockEvent.BreakEvent( + xCoord, + yCoord, + zCoord, + world, + world.getBlock(xCoord, yCoord, zCoord), + world.getBlockMetadata(xCoord, yCoord, zCoord), + player); + MinecraftForge.EVENT_BUS.post(event); + if (event.isCanceled()) return; + } + + IGrowable igrowable = (IGrowable) block; + if (igrowable.func_149851_a(world, xCoord, yCoord, zCoord, world.isRemote)) + if (igrowable.func_149852_a(world, world.rand, xCoord, yCoord, zCoord)) { + int meta = world.getBlockMetadata(xCoord, yCoord, zCoord); + for (int i = 0; i < count; i++) { + if (meta != world.getBlockMetadata(xCoord, yCoord, zCoord)) return; + igrowable.func_149853_b(world, world.rand, xCoord, yCoord, zCoord); + } + } + } + + public static boolean setBlock(World world, Block block, int meta, int x, int y, int z, EntityPlayer player, + boolean checkAir) { + if (!world.isRemote) { + if (checkAir && !(world.getBlock(x, y, z).getMaterial() == Material.air)) return false; + BlockEvent.BreakEvent event = new BlockEvent.BreakEvent( + x, + y, + z, + world, + world.getBlock(x, y, z), + world.getBlockMetadata(x, y, z), + player); + MinecraftForge.EVENT_BUS.post(event); + if (event.isCanceled()) return false; + return setBlockWithY(world, block, meta, x, y, z); + } + return false; + } + + private static boolean setBlockWithY(World world, Block block, int meta, int x, int y, int z) { + if (y < 256) world.setBlock(x, y, z, block, meta, 3); + else return false; + return true; + } } diff --git a/src/main/java/ab/common/core/handler/ConfigABHandler.java b/src/main/java/ab/common/core/handler/ConfigABHandler.java index 6eaf555..c8b27f5 100644 --- a/src/main/java/ab/common/core/handler/ConfigABHandler.java +++ b/src/main/java/ab/common/core/handler/ConfigABHandler.java @@ -2,184 +2,246 @@ package ab.common.core.handler; import java.io.File; -import ab.AdvancedBotany; -import ab.api.AdvancedBotanyAPI; -import cpw.mods.fml.client.event.ConfigChangedEvent; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import net.minecraft.entity.passive.EntitySheep; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; +import ab.AdvancedBotany; +import cpw.mods.fml.client.event.ConfigChangedEvent; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + public class ConfigABHandler { - public static Configuration config; - - public static final String CATEGORY_BALANCE = "general." + "balance"; - public static final String CATEGORY_BALANCE_MANA_COST = "general." + "balance.manacost"; - public static final String CATEGORY_RELICS = "general." + "relics"; - public static final String CATEGORY_INTEGRATION = "general." + "integration"; - - //Balance - - public static int[] maxContainerMana = new int[] { 64000000, 8000000, 64000000 }; - public static double protectionFactorNebula = 1.0f; - public static double damageFactorSpaceSword = 1.0f; - public static int nebulaWandCooldownTick = 18; - public static int spreaderMaxMana = 128000; - public static int spreaderBurstMana = 32000; - public static String[] lockWorldNameNebulaRod = new String[] {}; - public static int limitXZCoords = 30000000; - public static int maxDictariusCount = 64; - public static int sprawlRodMaxArea = 64; - - //Balance - mana cost - - public static int nebulaRodManaCost = 180; - public static int sphereNavigationManaCost = 2500; - - //Relics - - public static String[] lockEntityListToHorn = new String[] {}; - public static String[] relicNames = new String[] { "infiniteFruit", "kingKey", "flugelEye", "thorRing", "odinRing", "lokiRing", - "freyrSlingshot", "keyHiddenRiches", "pocketWardrobe", "sphereNavigation", "hornPlenty" }; - public static boolean[] fateBoardRelicEnables = new boolean[relicNames.length]; - - - //Integration - - public static boolean hasAutoThaum = true; - - //Misc - - public static boolean useManaChargerAnimation = true; - public static boolean hasManaCharger = true; - - static { - for(int i = 0; i < fateBoardRelicEnables.length; i++) - fateBoardRelicEnables[i] = true; - } - - public static void loadConfig(File configFile) { - config = new Configuration(configFile); - config.load(); - loadCategories(); - load(); - FMLCommonHandler.instance().bus().register(new ChangeListener()); - } - - public static void load() { - - //Balance Settings - - String desc = "Maximum mana capacity for Mana Container"; - maxContainerMana[0] = loadPropInt(CATEGORY_BALANCE, "Mana Container Capacity", desc, false, maxContainerMana[0]); - desc = "Maximum mana capacity for Diluted Mana Container"; - maxContainerMana[1] = loadPropInt(CATEGORY_BALANCE, "Mana Container Capacity (Diluted)", desc, false, maxContainerMana[1]); - desc = "Maximum mana capacity for Fabulous Mana Container"; - maxContainerMana[2] = loadPropInt(CATEGORY_BALANCE, "Mana Container Capacity (Fabulous)", desc, false, maxContainerMana[2]); - desc = "Protection factor for nebula armour"; - protectionFactorNebula = loadPropDouble(CATEGORY_BALANCE, "Nebula Armor Protection Factor", desc, false, protectionFactorNebula); - desc = "Damage factor for Space Blade"; - damageFactorSpaceSword = loadPropDouble(CATEGORY_BALANCE, "Space Sword Damage Factor", desc, false, damageFactorSpaceSword); - desc = "The number of ticks needed to restore 1 unit of the Rod of Nebula strength."; - nebulaWandCooldownTick = loadPropInt(CATEGORY_BALANCE, "Rod of Nebula Cooldown", desc, false, nebulaWandCooldownTick); - desc = "Maximum amount of mana held in a mana spreader"; - spreaderMaxMana = loadPropInt(CATEGORY_BALANCE, "Spreader Max Mana", desc, false, spreaderMaxMana); - desc = "Amount of Mana in a Mana Burst"; - spreaderBurstMana = loadPropInt(CATEGORY_BALANCE, "Spreader Burst Mana", desc, false, spreaderBurstMana); - desc = "To block a creature, type it's class name"; - lockWorldNameNebulaRod = loadPropString(CATEGORY_BALANCE, "Locking Worlds for Teleportation with Nebula Rod", desc, false, lockWorldNameNebulaRod); - desc = "Limitation on X Z coordinates for teleportation, do not increase the default value"; - limitXZCoords = loadPropInt(CATEGORY_BALANCE, "Restriction on X Z coordinates for Rod of Nebula", desc, false, limitXZCoords); - desc = "Limit the number of flowers next to each other"; - maxDictariusCount = loadPropInt(CATEGORY_BALANCE, "Max Dictarius Count", desc, false, maxDictariusCount); - desc = "Changes the area of effect of a projectile created with Rod of Sprawl"; - sprawlRodMaxArea = loadPropInt(CATEGORY_BALANCE, "Rod of Sprawl Max Area", desc, false, sprawlRodMaxArea); - - //Balance Settings - mana cost - - desc = "Mana cost to restore one unit of strength"; - nebulaRodManaCost = loadPropInt(CATEGORY_BALANCE_MANA_COST, "Rod of Nebula repair Mana cost", desc, false, nebulaRodManaCost); - - desc = "Mana cost to try to find the specified block"; - sphereNavigationManaCost = loadPropInt(CATEGORY_BALANCE_MANA_COST, "Sphere of Navigation Mana cost", desc, false, sphereNavigationManaCost); - - //Relics Settings - - lockEntityListToHorn = loadPropString(CATEGORY_RELICS, "Blocked creatures for double drop", desc, false, lockEntityListToHorn); - desc = "Enter the name of the World you want to add to the blacklist"; - - desc = "Enable or disable relic drop on the Fate Playing Board"; - for(int i = 0; i < fateBoardRelicEnables.length; i++) - fateBoardRelicEnables[i] = loadPropBool(CATEGORY_RELICS, "Enable relic: " + relicNames[i], desc, false, fateBoardRelicEnables[i]); - - //Misc Settings - - desc = "Activating the charging animation for the Mana Charger"; - useManaChargerAnimation = loadPropBool("general", "Mana Charger lighting", desc, false, useManaChargerAnimation); - desc = "Switching the Mana Charger on or off in the game"; - hasManaCharger = loadPropBool("general", "Enable Mana Charger", desc, true, hasManaCharger); - - // Integration Settings - - desc = "Switching the Thaumim Crafty Crate on or off in the game"; - hasAutoThaum = loadPropBool(CATEGORY_INTEGRATION, "Enable Thaumim Crafty Crate", desc, true, hasAutoThaum); - - if(config.hasChanged()) - config.save(); - } - - public static void loadCategories() { - addCategory(CATEGORY_BALANCE, "Advanced Botany: balance settings"); - addCategory(CATEGORY_BALANCE_MANA_COST, "Advanced Botany: balance settings (mana cost)"); - addCategory(CATEGORY_RELICS, "Advanced Botany: relics settings"); - addCategory(CATEGORY_INTEGRATION, "Advanced Botany: integration settings"); - } - - public static void addCategory(String name, String comment) { - config.addCustomCategoryComment(name, comment); - config.getCategory(name).setLanguageKey(name); - } - - public static void loadPostInit() { - if(config.hasChanged()) - config.save(); - } - - public static String[] loadPropString(String category, String propName, String desc, boolean hasRestart, String[] default_) { - Property prop = config.get(category, propName, default_); - prop.comment = desc; - prop.setRequiresMcRestart(hasRestart); - return prop.getStringList(); - } - - public static boolean loadPropBool(String category, String propName, String desc, boolean hasRestart, boolean default_) { - Property prop = config.get(category, propName, default_); - prop.comment = desc; - prop.setRequiresMcRestart(hasRestart); - return prop.getBoolean(default_); - } - - public static int loadPropInt(String category, String propName, String desc, boolean hasRestart, int default_) { - Property prop = config.get(category, propName, default_); - prop.comment = desc; - prop.setRequiresMcRestart(hasRestart); - return prop.getInt(default_); - } - - public static double loadPropDouble(String category, String propName, String desc, boolean hasRestart, double default_) { - Property prop = config.get(category, propName, default_); - prop.comment = desc; - prop.setRequiresMcRestart(hasRestart); - return prop.getDouble(default_); - } - - public static class ChangeListener { - @SubscribeEvent - public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) { - if(eventArgs.modID.equals(AdvancedBotany.modid)) - ConfigABHandler.load(); - } - } -} \ No newline at end of file + public static Configuration config; + + public static final String CATEGORY_BALANCE = "general." + "balance"; + public static final String CATEGORY_BALANCE_MANA_COST = "general." + "balance.manacost"; + public static final String CATEGORY_RELICS = "general." + "relics"; + public static final String CATEGORY_INTEGRATION = "general." + "integration"; + + // Balance + + public static int[] maxContainerMana = new int[] { 64000000, 8000000, 64000000 }; + public static double protectionFactorNebula = 1.0f; + public static double damageFactorSpaceSword = 1.0f; + public static int nebulaWandCooldownTick = 18; + public static int spreaderMaxMana = 128000; + public static int spreaderBurstMana = 32000; + public static String[] lockWorldNameNebulaRod = new String[] {}; + public static int limitXZCoords = 30000000; + public static int maxDictariusCount = 64; + public static int sprawlRodMaxArea = 64; + + // Balance - mana cost + + public static int nebulaRodManaCost = 180; + public static int sphereNavigationManaCost = 2500; + + // Relics + + public static String[] lockEntityListToHorn = new String[] {}; + public static String[] relicNames = new String[] { "infiniteFruit", "kingKey", "flugelEye", "thorRing", "odinRing", + "lokiRing", "freyrSlingshot", "keyHiddenRiches", "pocketWardrobe", "sphereNavigation", "hornPlenty" }; + public static boolean[] fateBoardRelicEnables = new boolean[relicNames.length]; + + // Integration + + public static boolean hasAutoThaum = true; + + // Misc + + public static boolean useManaChargerAnimation = true; + public static boolean hasManaCharger = true; + + static { + for (int i = 0; i < fateBoardRelicEnables.length; i++) fateBoardRelicEnables[i] = true; + } + + public static void loadConfig(File configFile) { + config = new Configuration(configFile); + config.load(); + loadCategories(); + load(); + FMLCommonHandler.instance().bus().register(new ChangeListener()); + } + + public static void load() { + + // Balance Settings + + String desc = "Maximum mana capacity for Mana Container"; + maxContainerMana[0] = loadPropInt( + CATEGORY_BALANCE, + "Mana Container Capacity", + desc, + false, + maxContainerMana[0]); + desc = "Maximum mana capacity for Diluted Mana Container"; + maxContainerMana[1] = loadPropInt( + CATEGORY_BALANCE, + "Mana Container Capacity (Diluted)", + desc, + false, + maxContainerMana[1]); + desc = "Maximum mana capacity for Fabulous Mana Container"; + maxContainerMana[2] = loadPropInt( + CATEGORY_BALANCE, + "Mana Container Capacity (Fabulous)", + desc, + false, + maxContainerMana[2]); + desc = "Protection factor for nebula armour"; + protectionFactorNebula = loadPropDouble( + CATEGORY_BALANCE, + "Nebula Armor Protection Factor", + desc, + false, + protectionFactorNebula); + desc = "Damage factor for Space Blade"; + damageFactorSpaceSword = loadPropDouble( + CATEGORY_BALANCE, + "Space Sword Damage Factor", + desc, + false, + damageFactorSpaceSword); + desc = "The number of ticks needed to restore 1 unit of the Rod of Nebula strength."; + nebulaWandCooldownTick = loadPropInt( + CATEGORY_BALANCE, + "Rod of Nebula Cooldown", + desc, + false, + nebulaWandCooldownTick); + desc = "Maximum amount of mana held in a mana spreader"; + spreaderMaxMana = loadPropInt(CATEGORY_BALANCE, "Spreader Max Mana", desc, false, spreaderMaxMana); + desc = "Amount of Mana in a Mana Burst"; + spreaderBurstMana = loadPropInt(CATEGORY_BALANCE, "Spreader Burst Mana", desc, false, spreaderBurstMana); + desc = "To block a creature, type it's class name"; + lockWorldNameNebulaRod = loadPropString( + CATEGORY_BALANCE, + "Locking Worlds for Teleportation with Nebula Rod", + desc, + false, + lockWorldNameNebulaRod); + desc = "Limitation on X Z coordinates for teleportation, do not increase the default value"; + limitXZCoords = loadPropInt( + CATEGORY_BALANCE, + "Restriction on X Z coordinates for Rod of Nebula", + desc, + false, + limitXZCoords); + desc = "Limit the number of flowers next to each other"; + maxDictariusCount = loadPropInt(CATEGORY_BALANCE, "Max Dictarius Count", desc, false, maxDictariusCount); + desc = "Changes the area of effect of a projectile created with Rod of Sprawl"; + sprawlRodMaxArea = loadPropInt(CATEGORY_BALANCE, "Rod of Sprawl Max Area", desc, false, sprawlRodMaxArea); + + // Balance Settings - mana cost + + desc = "Mana cost to restore one unit of strength"; + nebulaRodManaCost = loadPropInt( + CATEGORY_BALANCE_MANA_COST, + "Rod of Nebula repair Mana cost", + desc, + false, + nebulaRodManaCost); + + desc = "Mana cost to try to find the specified block"; + sphereNavigationManaCost = loadPropInt( + CATEGORY_BALANCE_MANA_COST, + "Sphere of Navigation Mana cost", + desc, + false, + sphereNavigationManaCost); + + // Relics Settings + + lockEntityListToHorn = loadPropString( + CATEGORY_RELICS, + "Blocked creatures for double drop", + desc, + false, + lockEntityListToHorn); + desc = "Enter the name of the World you want to add to the blacklist"; + + desc = "Enable or disable relic drop on the Fate Playing Board"; + for (int i = 0; i < fateBoardRelicEnables.length; i++) fateBoardRelicEnables[i] = loadPropBool( + CATEGORY_RELICS, + "Enable relic: " + relicNames[i], + desc, + false, + fateBoardRelicEnables[i]); + + // Misc Settings + + desc = "Activating the charging animation for the Mana Charger"; + useManaChargerAnimation = loadPropBool( + "general", + "Mana Charger lighting", + desc, + false, + useManaChargerAnimation); + desc = "Switching the Mana Charger on or off in the game"; + hasManaCharger = loadPropBool("general", "Enable Mana Charger", desc, true, hasManaCharger); + + // Integration Settings + + desc = "Switching the Thaumim Crafty Crate on or off in the game"; + hasAutoThaum = loadPropBool(CATEGORY_INTEGRATION, "Enable Thaumim Crafty Crate", desc, true, hasAutoThaum); + + if (config.hasChanged()) config.save(); + } + + public static void loadCategories() { + addCategory(CATEGORY_BALANCE, "Advanced Botany: balance settings"); + addCategory(CATEGORY_BALANCE_MANA_COST, "Advanced Botany: balance settings (mana cost)"); + addCategory(CATEGORY_RELICS, "Advanced Botany: relics settings"); + addCategory(CATEGORY_INTEGRATION, "Advanced Botany: integration settings"); + } + + public static void addCategory(String name, String comment) { + config.addCustomCategoryComment(name, comment); + config.getCategory(name).setLanguageKey(name); + } + + public static void loadPostInit() { + if (config.hasChanged()) config.save(); + } + + public static String[] loadPropString(String category, String propName, String desc, boolean hasRestart, + String[] default_) { + Property prop = config.get(category, propName, default_); + prop.comment = desc; + prop.setRequiresMcRestart(hasRestart); + return prop.getStringList(); + } + + public static boolean loadPropBool(String category, String propName, String desc, boolean hasRestart, + boolean default_) { + Property prop = config.get(category, propName, default_); + prop.comment = desc; + prop.setRequiresMcRestart(hasRestart); + return prop.getBoolean(default_); + } + + public static int loadPropInt(String category, String propName, String desc, boolean hasRestart, int default_) { + Property prop = config.get(category, propName, default_); + prop.comment = desc; + prop.setRequiresMcRestart(hasRestart); + return prop.getInt(default_); + } + + public static double loadPropDouble(String category, String propName, String desc, boolean hasRestart, + double default_) { + Property prop = config.get(category, propName, default_); + prop.comment = desc; + prop.setRequiresMcRestart(hasRestart); + return prop.getDouble(default_); + } + + public static class ChangeListener { + + @SubscribeEvent + public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) { + if (eventArgs.modID.equals(AdvancedBotany.modid)) ConfigABHandler.load(); + } + } +} diff --git a/src/main/java/ab/common/core/handler/GuiHandler.java b/src/main/java/ab/common/core/handler/GuiHandler.java index c1c0dec..5ab70ed 100644 --- a/src/main/java/ab/common/core/handler/GuiHandler.java +++ b/src/main/java/ab/common/core/handler/GuiHandler.java @@ -1,26 +1,27 @@ package ab.common.core.handler; -import ab.client.gui.GuiItemChest; -import ab.client.gui.ContainerItemChest; -import cpw.mods.fml.common.network.IGuiHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; +import ab.client.gui.ContainerItemChest; +import ab.client.gui.GuiItemChest; +import cpw.mods.fml.common.network.IGuiHandler; + public class GuiHandler implements IGuiHandler { - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - switch (ID) { - case 0: - return new ContainerItemChest(player); - } - return null; - } - - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - switch (ID) { - case 0: - return new GuiItemChest(player); - } - return null; - } -} \ No newline at end of file + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + switch (ID) { + case 0: + return new ContainerItemChest(player); + } + return null; + } + + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + switch (ID) { + case 0: + return new GuiItemChest(player); + } + return null; + } +} diff --git a/src/main/java/ab/common/core/handler/NetworkHandler.java b/src/main/java/ab/common/core/handler/NetworkHandler.java index 49207b5..9cac4e8 100644 --- a/src/main/java/ab/common/core/handler/NetworkHandler.java +++ b/src/main/java/ab/common/core/handler/NetworkHandler.java @@ -1,35 +1,36 @@ package ab.common.core.handler; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayerMP; + import ab.common.core.proxy.packet.S00PacketHornChargeHud; import ab.common.core.proxy.packet.S01PacketFindNearBlocks; import ab.common.core.proxy.packet.S02PacketSpaceBladeDash; import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.relauncher.Side; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayerMP; public class NetworkHandler { - - public static final SimpleNetworkWrapper NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel("advancedBotanyChanel"); - public static void registerPackets() { - int id = 0; - NETWORK.registerMessage(S00PacketHornChargeHud.class, S00PacketHornChargeHud.class, id++, Side.CLIENT); - NETWORK.registerMessage(S01PacketFindNearBlocks.class, S01PacketFindNearBlocks.class, id++, Side.CLIENT); - NETWORK.registerMessage(S02PacketSpaceBladeDash.class, S02PacketSpaceBladeDash.class, id++, Side.CLIENT); - } - - public static void sendPacketToSpaceDash(EntityPlayerMP playerMP) { - NETWORK.sendTo(new S02PacketSpaceBladeDash(), playerMP); - } - - public static void sendPacketToFindBlocks(EntityPlayerMP playerMP, Block block, int meta) { - NETWORK.sendTo(new S01PacketFindNearBlocks(block, meta), playerMP); - } - - public static void sendPacketToHornHud(EntityPlayerMP playerMP, short chargeLoot) { - NETWORK.sendTo(new S00PacketHornChargeHud(chargeLoot), playerMP); - } -} \ No newline at end of file + public static final SimpleNetworkWrapper NETWORK = NetworkRegistry.INSTANCE + .newSimpleChannel("advancedBotanyChanel"); + + public static void registerPackets() { + int id = 0; + NETWORK.registerMessage(S00PacketHornChargeHud.class, S00PacketHornChargeHud.class, id++, Side.CLIENT); + NETWORK.registerMessage(S01PacketFindNearBlocks.class, S01PacketFindNearBlocks.class, id++, Side.CLIENT); + NETWORK.registerMessage(S02PacketSpaceBladeDash.class, S02PacketSpaceBladeDash.class, id++, Side.CLIENT); + } + + public static void sendPacketToSpaceDash(EntityPlayerMP playerMP) { + NETWORK.sendTo(new S02PacketSpaceBladeDash(), playerMP); + } + + public static void sendPacketToFindBlocks(EntityPlayerMP playerMP, Block block, int meta) { + NETWORK.sendTo(new S01PacketFindNearBlocks(block, meta), playerMP); + } + + public static void sendPacketToHornHud(EntityPlayerMP playerMP, short chargeLoot) { + NETWORK.sendTo(new S00PacketHornChargeHud(chargeLoot), playerMP); + } +} diff --git a/src/main/java/ab/common/core/proxy/CommonProxy.java b/src/main/java/ab/common/core/proxy/CommonProxy.java index c462680..dbabc11 100644 --- a/src/main/java/ab/common/core/proxy/CommonProxy.java +++ b/src/main/java/ab/common/core/proxy/CommonProxy.java @@ -1,7 +1,6 @@ package ab.common.core.proxy; import ab.AdvancedBotany; -import ab.api.AdvancedBotanyAPI; import ab.common.core.handler.ConfigABHandler; import ab.common.core.handler.GuiHandler; import ab.common.core.handler.NetworkHandler; @@ -17,30 +16,26 @@ 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.common.network.NetworkRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.MinecraftForge; -import vazkii.botania.common.item.ModItems; public class CommonProxy { - public void preInit(FMLPreInitializationEvent event) { - BlockListAB.init(); - ItemListAB.init(); - AchievementRegister.init(); - EntityListAB.init(); - FlowerRegister.init(); - ConfigABHandler.loadConfig(event.getSuggestedConfigurationFile()); - } - - public void init(FMLInitializationEvent event) { - NetworkRegistry.INSTANCE.registerGuiHandler(AdvancedBotany.instance, new GuiHandler()); - RecipeListAB.init(); - NetworkHandler.registerPackets(); - } - - public void postInit(FMLPostInitializationEvent event) { - ConfigABHandler.loadPostInit(); - if(Loader.isModLoaded("MineTweaker3")) - MineTweakerConfig.registerMT(); - } -} \ No newline at end of file + public void preInit(FMLPreInitializationEvent event) { + BlockListAB.init(); + ItemListAB.init(); + AchievementRegister.init(); + EntityListAB.init(); + FlowerRegister.init(); + ConfigABHandler.loadConfig(event.getSuggestedConfigurationFile()); + } + + public void init(FMLInitializationEvent event) { + NetworkRegistry.INSTANCE.registerGuiHandler(AdvancedBotany.instance, new GuiHandler()); + RecipeListAB.init(); + NetworkHandler.registerPackets(); + } + + public void postInit(FMLPostInitializationEvent event) { + ConfigABHandler.loadPostInit(); + if (Loader.isModLoaded("MineTweaker3")) MineTweakerConfig.registerMT(); + } +} diff --git a/src/main/java/ab/common/core/proxy/packet/S00PacketHornChargeHud.java b/src/main/java/ab/common/core/proxy/packet/S00PacketHornChargeHud.java index 9293f76..0d86bae 100644 --- a/src/main/java/ab/common/core/proxy/packet/S00PacketHornChargeHud.java +++ b/src/main/java/ab/common/core/proxy/packet/S00PacketHornChargeHud.java @@ -1,5 +1,7 @@ package ab.common.core.proxy.packet; +import net.minecraft.item.ItemStack; + import ab.client.core.handler.ItemsRemainingRender; import ab.common.lib.register.ItemListAB; import cpw.mods.fml.common.network.simpleimpl.IMessage; @@ -8,30 +10,29 @@ import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; -import net.minecraft.item.ItemStack; public class S00PacketHornChargeHud implements IMessage, IMessageHandler { - - private static final ItemStack horn = new ItemStack(ItemListAB.itemHornPlenty); - private short chargeLoot; - - public S00PacketHornChargeHud() {}; - - public S00PacketHornChargeHud(short chargeLoot) { - this.chargeLoot = chargeLoot; - } - public void toBytes(ByteBuf buf) { - buf.writeShort(chargeLoot); - } - - public void fromBytes(ByteBuf buf) { - this.chargeLoot = buf.readShort(); - } - - @SideOnly(Side.CLIENT) - public IMessage onMessage(S00PacketHornChargeHud message, MessageContext ctx) { - ItemsRemainingRender.set(horn, "" + message.chargeLoot); - return null; - } -} \ No newline at end of file + private static final ItemStack horn = new ItemStack(ItemListAB.itemHornPlenty); + private short chargeLoot; + + public S00PacketHornChargeHud() {}; + + public S00PacketHornChargeHud(short chargeLoot) { + this.chargeLoot = chargeLoot; + } + + public void toBytes(ByteBuf buf) { + buf.writeShort(chargeLoot); + } + + public void fromBytes(ByteBuf buf) { + this.chargeLoot = buf.readShort(); + } + + @SideOnly(Side.CLIENT) + public IMessage onMessage(S00PacketHornChargeHud message, MessageContext ctx) { + ItemsRemainingRender.set(horn, "" + message.chargeLoot); + return null; + } +} diff --git a/src/main/java/ab/common/core/proxy/packet/S01PacketFindNearBlocks.java b/src/main/java/ab/common/core/proxy/packet/S01PacketFindNearBlocks.java index 7f62a83..345ef2d 100644 --- a/src/main/java/ab/common/core/proxy/packet/S01PacketFindNearBlocks.java +++ b/src/main/java/ab/common/core/proxy/packet/S01PacketFindNearBlocks.java @@ -1,45 +1,45 @@ package ab.common.core.proxy.packet; -import ab.client.core.handler.ItemsRemainingRender; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; + import ab.common.item.relic.ItemSphereNavigation; -import cpw.mods.fml.common.network.ByteBufUtils; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.WorldServer; -import net.minecraftforge.common.DimensionManager; public class S01PacketFindNearBlocks implements IMessage, IMessageHandler { - - private int blockID; - private int meta; - - public S01PacketFindNearBlocks() {}; - - public S01PacketFindNearBlocks(Block block, int meta) { - this.blockID = Block.getIdFromBlock(block); - this.meta = meta; - } - public void toBytes(ByteBuf buf) { - buf.writeInt(this.blockID); - buf.writeInt(this.meta); - } - - public void fromBytes(ByteBuf buf) { - this.blockID = buf.readInt(); - this.meta = buf.readInt(); - } - - @SideOnly(Side.CLIENT) - public IMessage onMessage(S01PacketFindNearBlocks message, MessageContext ctx) { - ItemSphereNavigation.findBlocks(Minecraft.getMinecraft().theWorld, Block.getBlockById(message.blockID), message.meta, Minecraft.getMinecraft().thePlayer); - return null; - } + private int blockID; + private int meta; + + public S01PacketFindNearBlocks() {}; + + public S01PacketFindNearBlocks(Block block, int meta) { + this.blockID = Block.getIdFromBlock(block); + this.meta = meta; + } + + public void toBytes(ByteBuf buf) { + buf.writeInt(this.blockID); + buf.writeInt(this.meta); + } + + public void fromBytes(ByteBuf buf) { + this.blockID = buf.readInt(); + this.meta = buf.readInt(); + } + + @SideOnly(Side.CLIENT) + public IMessage onMessage(S01PacketFindNearBlocks message, MessageContext ctx) { + ItemSphereNavigation.findBlocks( + Minecraft.getMinecraft().theWorld, + Block.getBlockById(message.blockID), + message.meta, + Minecraft.getMinecraft().thePlayer); + return null; + } } diff --git a/src/main/java/ab/common/core/proxy/packet/S02PacketSpaceBladeDash.java b/src/main/java/ab/common/core/proxy/packet/S02PacketSpaceBladeDash.java index 79023e5..b4452bf 100644 --- a/src/main/java/ab/common/core/proxy/packet/S02PacketSpaceBladeDash.java +++ b/src/main/java/ab/common/core/proxy/packet/S02PacketSpaceBladeDash.java @@ -1,5 +1,7 @@ package ab.common.core.proxy.packet; +import net.minecraft.client.Minecraft; + import ab.common.item.equipment.ItemSpaceBlade; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; @@ -7,17 +9,16 @@ import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; -import net.minecraft.client.Minecraft; public class S02PacketSpaceBladeDash implements IMessage, IMessageHandler { - public void fromBytes(ByteBuf buf) {} + public void fromBytes(ByteBuf buf) {} - public void toBytes(ByteBuf buf) {} + public void toBytes(ByteBuf buf) {} - @SideOnly(Side.CLIENT) - public IMessage onMessage(S02PacketSpaceBladeDash message, MessageContext ctx) { - ItemSpaceBlade.onPlayerSpaceDash(Minecraft.getMinecraft().thePlayer); - return null; - } -} \ No newline at end of file + @SideOnly(Side.CLIENT) + public IMessage onMessage(S02PacketSpaceBladeDash message, MessageContext ctx) { + ItemSpaceBlade.onPlayerSpaceDash(Minecraft.getMinecraft().thePlayer); + return null; + } +} diff --git a/src/main/java/ab/common/entity/EntityAdvancedSpark.java b/src/main/java/ab/common/entity/EntityAdvancedSpark.java index f8f638a..243151d 100644 --- a/src/main/java/ab/common/entity/EntityAdvancedSpark.java +++ b/src/main/java/ab/common/entity/EntityAdvancedSpark.java @@ -10,8 +10,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.WeakHashMap; -import ab.common.lib.register.ItemListAB; -import baubles.common.lib.PlayerHandler; + import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -19,306 +18,309 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraft.world.World; + import vazkii.botania.api.mana.IManaItem; import vazkii.botania.api.mana.spark.ISparkAttachable; import vazkii.botania.api.mana.spark.ISparkEntity; import vazkii.botania.api.mana.spark.SparkHelper; import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.Vector3; -import vazkii.botania.common.entity.EntitySpark; import vazkii.botania.common.item.ModItems; +import ab.common.lib.register.ItemListAB; +import baubles.common.lib.PlayerHandler; public class EntityAdvancedSpark extends Entity implements ISparkEntity { - - Set transfers = Collections.newSetFromMap(new WeakHashMap()); - public int transferSpeed = 48000; - public int removeTransferants = 2; - public boolean firstTick = false; - - public EntityAdvancedSpark(World world) { - super(world); - this.isImmuneToFire = true; - } - protected void entityInit() { - setSize(0.1F, 0.5F); - this.dataWatcher.addObject(27, Integer.valueOf(0)); - this.dataWatcher.addObject(28, Integer.valueOf(0)); - this.dataWatcher.setObjectWatched(27); - this.dataWatcher.setObjectWatched(28); - } + Set transfers = Collections.newSetFromMap(new WeakHashMap()); + public int transferSpeed = 48000; + public int removeTransferants = 2; + public boolean firstTick = false; - public void onUpdate() { - super.onUpdate(); - ISparkAttachable tile = getAttachedTile(); - if (tile == null) { - if (!this.worldObj.isRemote) - setDead(); - return; - } - boolean first = (this.worldObj.isRemote && !this.firstTick); - int upgrade = getUpgrade(); - List allSparks = null; - if (first || upgrade == 2 || upgrade == 3) - allSparks = SparkHelper.getSparksAround(this.worldObj, this.posX, this.posY, this.posZ); - if (first) - first = true; - Collection transfers = getTransfers(); - if (upgrade != 0) { - List players; - List validSparks; - Map> receivingPlayers; - ItemStack input; - switch (upgrade) { - case 1: - players = SparkHelper.getEntitiesAround(EntityPlayer.class, this.worldObj, this.posX, this.posY, this.posZ); - receivingPlayers = new HashMap>(); - 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 = (Map) new HashMap(); - } else { - receivingStacks = receivingPlayers.get(player); - } - int recv = Math.min(getAttachedTile().getCurrentMana(), Math.min(transferSpeed, manaItem.getMaxMana(stack) - manaItem.getMana(stack))); - if (recv > 0) { - receivingStacks.put(stack, Integer.valueOf(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 = ((Integer) items.get(stack)).intValue(); - int manaToPut = Math.min(getAttachedTile().getCurrentMana(), cost); - ((IManaItem) stack.getItem()).addMana(stack, manaToPut); - getAttachedTile().recieveMana(-manaToPut); - particlesTowards((Entity) player); - } - break; - case 2: - validSparks = new ArrayList(); - for (ISparkEntity spark : allSparks) { - if (spark == this) - continue; - int upgrade_ = spark.getUpgrade(); - if (upgrade_ == 0 && spark.getAttachedTile() instanceof vazkii.botania.api.mana.IManaPool) - validSparks.add(spark); - } - if (validSparks.size() > 0) - ((ISparkEntity) validSparks.get(this.worldObj.rand.nextInt(validSparks.size()))).registerTransfer(this); - break; - case 3: - 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(transferSpeed * 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 (this.removeTransferants > 0) - this.removeTransferants--; - getTransfers(); - } + public EntityAdvancedSpark(World world) { + super(world); + this.isImmuneToFire = true; + } - public void particlesTowards(Entity e) { - Vector3 thisVec = Vector3.fromEntityCenter(this).add(0.0D, 0.0D, 0.0D); - Vector3 receiverVec = Vector3.fromEntityCenter(e).add(0.0D, 0.0D, 0.0D); - double rc = 0.45D; - thisVec.add((Math.random() - 0.5D) * rc, (Math.random() - 0.5D) * rc, (Math.random() - 0.5D) * rc); - receiverVec.add((Math.random() - 0.5D) * rc, (Math.random() - 0.5D) * rc, (Math.random() - 0.5D) * rc); - Vector3 motion = receiverVec.copy().sub(thisVec); - motion.multiply(0.03999999910593033D); - 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(this.worldObj, thisVec.x, thisVec.y, thisVec.z, r, g, b, size, (float) motion.x, - (float) motion.y, (float) motion.z); - } + protected void entityInit() { + setSize(0.1F, 0.5F); + this.dataWatcher.addObject(27, Integer.valueOf(0)); + this.dataWatcher.addObject(28, Integer.valueOf(0)); + this.dataWatcher.setObjectWatched(27); + this.dataWatcher.setObjectWatched(28); + } - public static void particleBeam(Entity e1, Entity e2) { - if (e1 == null || e2 == null) - return; - Vector3 orig = new Vector3(e1.posX, e1.posY + 0.25D, e1.posZ); - Vector3 end = new Vector3(e2.posX, e2.posY + 0.25D, e2.posZ); - Vector3 diff = end.copy().sub(orig); - Vector3 movement = diff.copy().normalize().multiply(0.1D); - int iters = (int) (diff.mag() / movement.mag()); - float huePer = 1.0F / 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, 1.0F, 1.0F); - float r = Math.min(1.0F, color.getRed() / 255.0F + 0.4F); - float g = Math.min(1.0F, color.getGreen() / 255.0F + 0.4F); - float b = Math.min(1.0F, color.getBlue() / 255.0F + 0.4F); - Botania.proxy.setSparkleFXNoClip(true); - Botania.proxy.sparkleFX(e1.worldObj, currentPos.x, currentPos.y, currentPos.z, r, g, b, 1.0F, 12); - Botania.proxy.setSparkleFXNoClip(false); - currentPos.add(movement); - } - } + public void onUpdate() { + super.onUpdate(); + ISparkAttachable tile = getAttachedTile(); + if (tile == null) { + if (!this.worldObj.isRemote) setDead(); + return; + } + boolean first = (this.worldObj.isRemote && !this.firstTick); + int upgrade = getUpgrade(); + List allSparks = null; + if (first || upgrade == 2 || upgrade == 3) + allSparks = SparkHelper.getSparksAround(this.worldObj, this.posX, this.posY, this.posZ); + if (first) first = true; + Collection transfers = getTransfers(); + if (upgrade != 0) { + List players; + List validSparks; + Map> receivingPlayers; + ItemStack input; + switch (upgrade) { + case 1: + players = SparkHelper + .getEntitiesAround(EntityPlayer.class, this.worldObj, this.posX, this.posY, this.posZ); + receivingPlayers = new HashMap>(); + 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 = (Map) new HashMap(); + } else { + receivingStacks = receivingPlayers.get(player); + } + int recv = Math.min( + getAttachedTile().getCurrentMana(), + Math.min(transferSpeed, manaItem.getMaxMana(stack) - manaItem.getMana(stack))); + if (recv > 0) { + receivingStacks.put(stack, Integer.valueOf(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 = ((Integer) items.get(stack)).intValue(); + int manaToPut = Math.min(getAttachedTile().getCurrentMana(), cost); + ((IManaItem) stack.getItem()).addMana(stack, manaToPut); + getAttachedTile().recieveMana(-manaToPut); + particlesTowards((Entity) player); + } + break; + case 2: + validSparks = new ArrayList(); + for (ISparkEntity spark : allSparks) { + if (spark == this) continue; + int upgrade_ = spark.getUpgrade(); + if (upgrade_ == 0 && spark.getAttachedTile() instanceof vazkii.botania.api.mana.IManaPool) + validSparks.add(spark); + } + if (validSparks.size() > 0) + ((ISparkEntity) validSparks.get(this.worldObj.rand.nextInt(validSparks.size()))) + .registerTransfer(this); + break; + case 3: + 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(transferSpeed * 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 (this.removeTransferants > 0) this.removeTransferants--; + getTransfers(); + } - public boolean canBeCollidedWith() { - return true; - } + public void particlesTowards(Entity e) { + Vector3 thisVec = Vector3.fromEntityCenter(this).add(0.0D, 0.0D, 0.0D); + Vector3 receiverVec = Vector3.fromEntityCenter(e).add(0.0D, 0.0D, 0.0D); + double rc = 0.45D; + thisVec.add((Math.random() - 0.5D) * rc, (Math.random() - 0.5D) * rc, (Math.random() - 0.5D) * rc); + receiverVec.add((Math.random() - 0.5D) * rc, (Math.random() - 0.5D) * rc, (Math.random() - 0.5D) * rc); + Vector3 motion = receiverVec.copy().sub(thisVec); + motion.multiply(0.03999999910593033D); + 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( + this.worldObj, + thisVec.x, + thisVec.y, + thisVec.z, + r, + g, + b, + size, + (float) motion.x, + (float) motion.y, + (float) motion.z); + } - 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 (!this.worldObj.isRemote) - entityDropItem(new ItemStack(ModItems.sparkUpgrade, 1, upgrade - 1), 0.0F); - setUpgrade(0); - this.transfers.clear(); - this.removeTransferants = 2; - } else { - setDead(); - } - if (player.worldObj.isRemote) - player.swingItem(); - return true; - } - List allSparks = SparkHelper.getSparksAround(this.worldObj, this.posX, this.posY, this.posZ); - for (ISparkEntity spark : allSparks) - particleBeam(this, (Entity) spark); - return true; - } - 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 static void particleBeam(Entity e1, Entity e2) { + if (e1 == null || e2 == null) return; + Vector3 orig = new Vector3(e1.posX, e1.posY + 0.25D, e1.posZ); + Vector3 end = new Vector3(e2.posX, e2.posY + 0.25D, e2.posZ); + Vector3 diff = end.copy().sub(orig); + Vector3 movement = diff.copy().normalize().multiply(0.1D); + int iters = (int) (diff.mag() / movement.mag()); + float huePer = 1.0F / 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, 1.0F, 1.0F); + float r = Math.min(1.0F, color.getRed() / 255.0F + 0.4F); + float g = Math.min(1.0F, color.getGreen() / 255.0F + 0.4F); + float b = Math.min(1.0F, color.getBlue() / 255.0F + 0.4F); + Botania.proxy.setSparkleFXNoClip(true); + Botania.proxy.sparkleFX(e1.worldObj, currentPos.x, currentPos.y, currentPos.z, r, g, b, 1.0F, 12); + Botania.proxy.setSparkleFXNoClip(false); + currentPos.add(movement); + } + } - public boolean doPhantomInk(ItemStack stack) { - if (stack != null && stack.getItem() == ModItems.phantomInk && !this.worldObj.isRemote) { - int invis = this.dataWatcher.getWatchableObjectInt(27); - this.dataWatcher.updateObject(27, Integer.valueOf((invis ^ 0xFFFFFFFF) & 0x1)); - return true; - } - return false; - } + public boolean canBeCollidedWith() { + return true; + } - protected void readEntityFromNBT(NBTTagCompound cmp) { - setUpgrade(cmp.getInteger("upgrade")); - this.dataWatcher.updateObject(27, Integer.valueOf(cmp.getInteger("invis"))); - } + 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 (!this.worldObj.isRemote) + entityDropItem(new ItemStack(ModItems.sparkUpgrade, 1, upgrade - 1), 0.0F); + setUpgrade(0); + this.transfers.clear(); + this.removeTransferants = 2; + } else { + setDead(); + } + if (player.worldObj.isRemote) player.swingItem(); + return true; + } + List allSparks = SparkHelper + .getSparksAround(this.worldObj, this.posX, this.posY, this.posZ); + for (ISparkEntity spark : allSparks) particleBeam(this, (Entity) spark); + return true; + } + 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); + } - protected void writeEntityToNBT(NBTTagCompound cmp) { - cmp.setInteger("upgrade", getUpgrade()); - cmp.setInteger("invis", this.dataWatcher.getWatchableObjectInt(27)); - } + public boolean doPhantomInk(ItemStack stack) { + if (stack != null && stack.getItem() == ModItems.phantomInk && !this.worldObj.isRemote) { + int invis = this.dataWatcher.getWatchableObjectInt(27); + this.dataWatcher.updateObject(27, Integer.valueOf((invis ^ 0xFFFFFFFF) & 0x1)); + return true; + } + return false; + } - public void setDead() { - super.setDead(); - if (!this.worldObj.isRemote) { - int upgrade = getUpgrade(); - entityDropItem(new ItemStack(ItemListAB.itemAdvancedSpark), 0.0F); - if (upgrade > 0) - entityDropItem(new ItemStack(ModItems.sparkUpgrade, 1, upgrade - 1), 0.0F); - } - } + protected void readEntityFromNBT(NBTTagCompound cmp) { + setUpgrade(cmp.getInteger("upgrade")); + this.dataWatcher.updateObject(27, Integer.valueOf(cmp.getInteger("invis"))); + } - public ISparkAttachable getAttachedTile() { - int x = MathHelper.floor_double(this.posX); - int y = MathHelper.floor_double(this.posY) - 1; - int z = MathHelper.floor_double(this.posZ); - TileEntity tile = this.worldObj.getTileEntity(x, y, z); - if (tile != null && tile instanceof ISparkAttachable) - return (ISparkAttachable) tile; - return null; - } + protected void writeEntityToNBT(NBTTagCompound cmp) { + cmp.setInteger("upgrade", getUpgrade()); + cmp.setInteger("invis", this.dataWatcher.getWatchableObjectInt(27)); + } - public Collection getTransfers() { - Collection removals = new ArrayList(); - for (ISparkEntity e : this.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 vazkii.botania.api.mana.IManaPool)) - removals.add(e); - } - if (!removals.isEmpty()) - this.transfers.removeAll(removals); - return this.transfers; - } + public void setDead() { + super.setDead(); + if (!this.worldObj.isRemote) { + int upgrade = getUpgrade(); + entityDropItem(new ItemStack(ItemListAB.itemAdvancedSpark), 0.0F); + if (upgrade > 0) entityDropItem(new ItemStack(ModItems.sparkUpgrade, 1, upgrade - 1), 0.0F); + } + } - private boolean hasTransfer(ISparkEntity entity) { - return this.transfers.contains(entity); - } + public ISparkAttachable getAttachedTile() { + int x = MathHelper.floor_double(this.posX); + int y = MathHelper.floor_double(this.posY) - 1; + int z = MathHelper.floor_double(this.posZ); + TileEntity tile = this.worldObj.getTileEntity(x, y, z); + if (tile != null && tile instanceof ISparkAttachable) return (ISparkAttachable) tile; + return null; + } - public void registerTransfer(ISparkEntity entity) { - if (hasTransfer(entity)) - return; - this.transfers.add(entity); - } + public Collection getTransfers() { + Collection removals = new ArrayList(); + for (ISparkEntity e : this.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 vazkii.botania.api.mana.IManaPool)) + removals.add(e); + } + if (!removals.isEmpty()) this.transfers.removeAll(removals); + return this.transfers; + } - public int getUpgrade() { - return this.dataWatcher.getWatchableObjectInt(28); - } + private boolean hasTransfer(ISparkEntity entity) { + return this.transfers.contains(entity); + } - public void setUpgrade(int upgrade) { - this.dataWatcher.updateObject(28, Integer.valueOf(upgrade)); - } + public void registerTransfer(ISparkEntity entity) { + if (hasTransfer(entity)) return; + this.transfers.add(entity); + } - public boolean areIncomingTransfersDone() { - ISparkAttachable tile = getAttachedTile(); - if (tile instanceof vazkii.botania.api.mana.IManaPool) - return (this.removeTransferants > 0); - return (tile != null && tile.areIncomingTranfersDone()); - } -} \ No newline at end of file + public int getUpgrade() { + return this.dataWatcher.getWatchableObjectInt(28); + } + + public void setUpgrade(int upgrade) { + this.dataWatcher.updateObject(28, Integer.valueOf(upgrade)); + } + + public boolean areIncomingTransfersDone() { + ISparkAttachable tile = getAttachedTile(); + if (tile instanceof vazkii.botania.api.mana.IManaPool) return (this.removeTransferants > 0); + return (tile != null && tile.areIncomingTranfersDone()); + } +} diff --git a/src/main/java/ab/common/entity/EntityAlphirinePortal.java b/src/main/java/ab/common/entity/EntityAlphirinePortal.java index ccbe650..21dd3a6 100644 --- a/src/main/java/ab/common/entity/EntityAlphirinePortal.java +++ b/src/main/java/ab/common/entity/EntityAlphirinePortal.java @@ -6,54 +6,51 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import vazkii.botania.common.Botania; public class EntityAlphirinePortal extends Entity { - - private static final ItemStack itemStack = new ItemStack(Blocks.air); - public EntityAlphirinePortal(World world) { - super(world); - this.dataWatcher.addObject(27, itemStack.copy()); - this.dataWatcher.setObjectWatched(27); - } + private static final ItemStack itemStack = new ItemStack(Blocks.air); - protected void entityInit() {} - - public void onUpdate() { - super.onUpdate(); - if(this.ticksExisted >= 40) { - if(this.getStack() == itemStack) - this.setDead(); - if(!this.worldObj.isRemote) { - EntityItem itemResult = new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, this.getStack()); - this.worldObj.spawnEntityInWorld(itemResult); - this.setDead(); - } - } - } + public EntityAlphirinePortal(World world) { + super(world); + this.dataWatcher.addObject(27, itemStack.copy()); + this.dataWatcher.setObjectWatched(27); + } - protected void readEntityFromNBT(NBTTagCompound nbtt) { - this.ticksExisted = nbtt.getInteger("portalTick"); - NBTTagCompound stackCmp = nbtt.getCompoundTag("dropStack"); - ItemStack stack = ItemStack.loadItemStackFromNBT(stackCmp); - setStack(stack); - } + protected void entityInit() {} - protected void writeEntityToNBT(NBTTagCompound nbtt) { - nbtt.setInteger("portalTick", this.ticksExisted); - ItemStack stack = getStack(); - NBTTagCompound stackNbt = new NBTTagCompound(); - if(stack != null) - stack.writeToNBT(stackNbt); - nbtt.setTag("dropStack", stackNbt); - } - - public ItemStack getStack() { - return this.dataWatcher.getWatchableObjectItemStack(27); - } - - public void setStack(ItemStack stack) { - this.dataWatcher.updateObject(27, stack); - } -} \ No newline at end of file + public void onUpdate() { + super.onUpdate(); + if (this.ticksExisted >= 40) { + if (this.getStack() == itemStack) this.setDead(); + if (!this.worldObj.isRemote) { + EntityItem itemResult = new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, this.getStack()); + this.worldObj.spawnEntityInWorld(itemResult); + this.setDead(); + } + } + } + + protected void readEntityFromNBT(NBTTagCompound nbtt) { + this.ticksExisted = nbtt.getInteger("portalTick"); + NBTTagCompound stackCmp = nbtt.getCompoundTag("dropStack"); + ItemStack stack = ItemStack.loadItemStackFromNBT(stackCmp); + setStack(stack); + } + + protected void writeEntityToNBT(NBTTagCompound nbtt) { + nbtt.setInteger("portalTick", this.ticksExisted); + ItemStack stack = getStack(); + NBTTagCompound stackNbt = new NBTTagCompound(); + if (stack != null) stack.writeToNBT(stackNbt); + nbtt.setTag("dropStack", stackNbt); + } + + public ItemStack getStack() { + return this.dataWatcher.getWatchableObjectItemStack(27); + } + + public void setStack(ItemStack stack) { + this.dataWatcher.updateObject(27, stack); + } +} diff --git a/src/main/java/ab/common/entity/EntityAnonymousSteve.java b/src/main/java/ab/common/entity/EntityAnonymousSteve.java index b787b48..aba6a39 100644 --- a/src/main/java/ab/common/entity/EntityAnonymousSteve.java +++ b/src/main/java/ab/common/entity/EntityAnonymousSteve.java @@ -1,36 +1,37 @@ package ab.common.entity; -import com.mojang.authlib.GameProfile; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.IChatComponent; import net.minecraft.world.World; +import com.mojang.authlib.GameProfile; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + public class EntityAnonymousSteve extends AbstractClientPlayer { - public EntityAnonymousSteve(World world) { - super(world, new GameProfile(null, "abSteveForRenderer")); - } - - public boolean canCommandSenderUseCommand(int i, String s) { - return false; - } - - public ChunkCoordinates getPlayerCoordinates() { - return null; - } - - @SideOnly(Side.CLIENT) - public int getBrightnessForRender(float par1) { - return 15728880; - } - - public boolean isInvisible() { - return true; - } - - public void addChatMessage(IChatComponent var1) {} -} \ No newline at end of file + public EntityAnonymousSteve(World world) { + super(world, new GameProfile(null, "abSteveForRenderer")); + } + + public boolean canCommandSenderUseCommand(int i, String s) { + return false; + } + + public ChunkCoordinates getPlayerCoordinates() { + return null; + } + + @SideOnly(Side.CLIENT) + public int getBrightnessForRender(float par1) { + return 15728880; + } + + public boolean isInvisible() { + return true; + } + + public void addChatMessage(IChatComponent var1) {} +} diff --git a/src/main/java/ab/common/entity/EntityManaVine.java b/src/main/java/ab/common/entity/EntityManaVine.java index 37a5906..9eddd74 100644 --- a/src/main/java/ab/common/entity/EntityManaVine.java +++ b/src/main/java/ab/common/entity/EntityManaVine.java @@ -2,166 +2,207 @@ package ab.common.entity; import java.awt.Color; import java.util.List; -import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.BlockGrass; +import net.minecraft.block.IGrowable; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityAnimal; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityThrowable; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +import vazkii.botania.common.Botania; +import vazkii.botania.common.core.handler.ConfigHandler; +import vazkii.botania.common.lib.LibObfuscation; import ab.client.core.ClientHelper; import ab.common.core.CommonHelper; import ab.common.lib.register.BlockListAB; import cpw.mods.fml.relauncher.ReflectionHelper; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.block.Block; -import net.minecraft.block.BlockBush; -import net.minecraft.block.BlockCrops; -import net.minecraft.block.BlockGrass; -import net.minecraft.block.BlockSapling; -import net.minecraft.block.IGrowable; -import net.minecraft.block.material.Material; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.passive.EntityAnimal; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.entity.projectile.EntityThrowable; -import net.minecraft.init.Blocks; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; -import net.minecraft.util.MathHelper; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.Vec3; -import net.minecraft.world.World; -import vazkii.botania.common.Botania; -import vazkii.botania.common.core.handler.ConfigHandler; -import vazkii.botania.common.lib.LibObfuscation; public class EntityManaVine extends EntityThrowable { - public EntityManaVine(World world) { - super(world); - } + public EntityManaVine(World world) { + super(world); + } - public EntityManaVine(World world, EntityLivingBase entity) { - super(world, entity); - } - - protected void entityInit() { - super.entityInit(); - this.dataWatcher.addObject(28, ""); - this.dataWatcher.setObjectWatched(28); - } - - public String getAttacker() { - return this.dataWatcher.getWatchableObjectString(28); - } - - public void setAttacker(String str) { - this.dataWatcher.updateObject(28, str); - } + public EntityManaVine(World world, EntityLivingBase entity) { + super(world, entity); + } - public void onUpdate() { - super.onUpdate(); - ticksExisted++; - if(ticksExisted >= 240) - setDead(); - if(this.worldObj.isRemote) { - float m = 0.02F; - float f1 = 6.0f; - for(int i = 0; i < 4; i++) { - double posX = this.posX + (Math.random() / f1 - (0.5f / f1)); - double posY = this.posY + (Math.random() / f1 - (0.5f / f1)); - double posZ = this.posZ + (Math.random() / f1 - (0.5f / f1)); - float mx = (float)(Math.random() - 0.5D) * m; - float my = (float)(Math.random() - 0.5D) * m; - float mz = (float)(Math.random() - 0.5D) * m; - Color color = ClientHelper.getCorporeaRuneColor((int)posX, (int)posY, (int)posZ, 3); - Botania.proxy.wispFX(worldObj, posX, posY, posZ, color.getRed() / 255.0f, color.getGreen() / 255.0f, color.getBlue() / 255.0f, (float) (0.15f + (Math.random() * 0.12f)), mx, my, mz, 0.7f); - } - } - } + protected void entityInit() { + super.entityInit(); + this.dataWatcher.addObject(28, ""); + this.dataWatcher.setObjectWatched(28); + } - protected void onImpact(MovingObjectPosition pos) { - EntityPlayer player = worldObj.getPlayerEntityByName(getAttacker()); - if(pos != null && pos.entityHit == null && player != null) { - World world = this.worldObj; - int x = pos.blockX; - int y = pos.blockY; - int z = pos.blockZ; - List list = (List) (world.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(x - 10, y - 10, z - 10, x + 10, y + 10, z + 10))); - for(EntityLivingBase target : list) { - if(target instanceof EntityAnimal && target.attackEntityFrom(DamageSource.causePlayerDamage(player), 0.0f)) { - EntityAnimal animal = (EntityAnimal) target; - ReflectionHelper.setPrivateValue(EntityAnimal.class, animal, 1200, LibObfuscation.IN_LOVE); - animal.setTarget(null); - this.worldObj.setEntityState(animal, (byte) 18); - } - } - for(int k = 0; k < 7; k++) - for(int k1 = 0; k1 < 7; k1++) - for(int k2 = 0; k2 < 7; k2++) { - int xCoord = x + k - 3; - int yCoord = y + k1 - 1; - int zCoord = z + k2 - 3; - Block block = this.worldObj.getBlock(xCoord, yCoord, zCoord); - if(block instanceof IGrowable && !(block instanceof BlockGrass)) { - CommonHelper.fertilizer(world, block, xCoord, yCoord, zCoord, 12, player); - if(ConfigHandler.blockBreakParticles) { - worldObj.playAuxSFX(2005, xCoord, yCoord, zCoord, 6 + this.worldObj.rand.nextInt(4)); - worldObj.playSoundEffect(x, y, z, "botania:agricarnation", 0.01F, 0.5F + (float) Math.random() * 0.5F); - } - } else if(!world.isRemote && BlockListAB.blockFreyrLiana.canBlockStay(world, xCoord, yCoord - 1, zCoord)) { - Vec3 vec = Vec3.createVectorHelper(xCoord, yCoord, zCoord); - int distant = (int)vec.squareDistanceTo(Vec3.createVectorHelper(x, y, z)); - yCoord--; - if(this.worldObj.rand.nextInt(distant + 1) == 0) - while(yCoord > 0) { - block = worldObj.getBlock(xCoord, yCoord, zCoord); - if(block.isAir(worldObj, xCoord, yCoord, zCoord)) { - if(world.rand.nextInt(4) < 3) - CommonHelper.setBlock(world, BlockListAB.blockFreyrLiana, 0, xCoord, yCoord, zCoord, player, false); - else - CommonHelper.setBlock(world, BlockListAB.blockLuminousFreyrLiana, 0, xCoord, yCoord, zCoord, player, false); - worldObj.playAuxSFX(2001, xCoord, yCoord, zCoord, Block.getIdFromBlock(BlockListAB.blockFreyrLiana)); - yCoord--; - } else - break; - } - } - } - this.setDead(); - } - } + public String getAttacker() { + return this.dataWatcher.getWatchableObjectString(28); + } - @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_) {} + public void setAttacker(String str) { + this.dataWatcher.updateObject(28, str); + } - protected float getGravityVelocity() { - return 0.0f; - } + public void onUpdate() { + super.onUpdate(); + ticksExisted++; + if (ticksExisted >= 240) setDead(); + if (this.worldObj.isRemote) { + float m = 0.02F; + float f1 = 6.0f; + for (int i = 0; i < 4; i++) { + double posX = this.posX + (Math.random() / f1 - (0.5f / f1)); + double posY = this.posY + (Math.random() / f1 - (0.5f / f1)); + double posZ = this.posZ + (Math.random() / f1 - (0.5f / f1)); + float mx = (float) (Math.random() - 0.5D) * m; + float my = (float) (Math.random() - 0.5D) * m; + float mz = (float) (Math.random() - 0.5D) * m; + Color color = ClientHelper.getCorporeaRuneColor((int) posX, (int) posY, (int) posZ, 3); + Botania.proxy.wispFX( + worldObj, + posX, + posY, + posZ, + color.getRed() / 255.0f, + color.getGreen() / 255.0f, + color.getBlue() / 255.0f, + (float) (0.15f + (Math.random() * 0.12f)), + mx, + my, + mz, + 0.7f); + } + } + } - public void setDead() { - if(this.worldObj.isRemote) { - float m = 0.175F; - for(int i = 0; i < 32; i++) { - float mx = (float)(Math.random() - 0.5D) * m; - float my = (float)(Math.random() - 0.5D) * m; - float mz = (float)(Math.random() - 0.5D) * m; - Color color = ClientHelper.getCorporeaRuneColor((int)posX, (int)posY, (int)posZ, 3); - Botania.proxy.wispFX(worldObj, posX, posY, posZ, color.getRed() / 255.0f, color.getGreen() / 255.0f, color.getBlue() / 255.0f, (float) (0.2f + (Math.random() * 0.12f)), mx, my, mz, 2.0f); - } - } - super.setDead(); - } - - public void readEntityFromNBT(NBTTagCompound nbtt) { - super.readEntityFromNBT(nbtt); - ticksExisted = nbtt.getInteger("ticks"); - setAttacker(nbtt.getString("attacker")); - } + protected void onImpact(MovingObjectPosition pos) { + EntityPlayer player = worldObj.getPlayerEntityByName(getAttacker()); + if (pos != null && pos.entityHit == null && player != null) { + World world = this.worldObj; + int x = pos.blockX; + int y = pos.blockY; + int z = pos.blockZ; + List list = (List) (world.getEntitiesWithinAABB( + EntityLivingBase.class, + AxisAlignedBB.getBoundingBox(x - 10, y - 10, z - 10, x + 10, y + 10, z + 10))); + for (EntityLivingBase target : list) { + if (target instanceof EntityAnimal + && target.attackEntityFrom(DamageSource.causePlayerDamage(player), 0.0f)) { + EntityAnimal animal = (EntityAnimal) target; + ReflectionHelper.setPrivateValue(EntityAnimal.class, animal, 1200, LibObfuscation.IN_LOVE); + animal.setTarget(null); + this.worldObj.setEntityState(animal, (byte) 18); + } + } + for (int k = 0; k < 7; k++) for (int k1 = 0; k1 < 7; k1++) for (int k2 = 0; k2 < 7; k2++) { + int xCoord = x + k - 3; + int yCoord = y + k1 - 1; + int zCoord = z + k2 - 3; + Block block = this.worldObj.getBlock(xCoord, yCoord, zCoord); + if (block instanceof IGrowable && !(block instanceof BlockGrass)) { + CommonHelper.fertilizer(world, block, xCoord, yCoord, zCoord, 12, player); + if (ConfigHandler.blockBreakParticles) { + worldObj.playAuxSFX(2005, xCoord, yCoord, zCoord, 6 + this.worldObj.rand.nextInt(4)); + worldObj.playSoundEffect( + x, + y, + z, + "botania:agricarnation", + 0.01F, + 0.5F + (float) Math.random() * 0.5F); + } + } else if (!world.isRemote + && BlockListAB.blockFreyrLiana.canBlockStay(world, xCoord, yCoord - 1, zCoord)) { + Vec3 vec = Vec3.createVectorHelper(xCoord, yCoord, zCoord); + int distant = (int) vec.squareDistanceTo(Vec3.createVectorHelper(x, y, z)); + yCoord--; + if (this.worldObj.rand.nextInt(distant + 1) == 0) while (yCoord > 0) { + block = worldObj.getBlock(xCoord, yCoord, zCoord); + if (block.isAir(worldObj, xCoord, yCoord, zCoord)) { + if (world.rand.nextInt(4) < 3) CommonHelper.setBlock( + world, + BlockListAB.blockFreyrLiana, + 0, + xCoord, + yCoord, + zCoord, + player, + false); + else CommonHelper.setBlock( + world, + BlockListAB.blockLuminousFreyrLiana, + 0, + xCoord, + yCoord, + zCoord, + player, + false); + worldObj.playAuxSFX( + 2001, + xCoord, + yCoord, + zCoord, + Block.getIdFromBlock(BlockListAB.blockFreyrLiana)); + yCoord--; + } else break; + } + } + } + this.setDead(); + } + } - public void writeEntityToNBT(NBTTagCompound nbtt) { - super.writeEntityToNBT(nbtt); - nbtt.setInteger("ticks", ticksExisted); - nbtt.setString("attacker", getAttacker()); - } -} \ No newline at end of file + @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_) {} + + protected float getGravityVelocity() { + return 0.0f; + } + + public void setDead() { + if (this.worldObj.isRemote) { + float m = 0.175F; + for (int i = 0; i < 32; i++) { + float mx = (float) (Math.random() - 0.5D) * m; + float my = (float) (Math.random() - 0.5D) * m; + float mz = (float) (Math.random() - 0.5D) * m; + Color color = ClientHelper.getCorporeaRuneColor((int) posX, (int) posY, (int) posZ, 3); + Botania.proxy.wispFX( + worldObj, + posX, + posY, + posZ, + color.getRed() / 255.0f, + color.getGreen() / 255.0f, + color.getBlue() / 255.0f, + (float) (0.2f + (Math.random() * 0.12f)), + mx, + my, + mz, + 2.0f); + } + } + super.setDead(); + } + + public void readEntityFromNBT(NBTTagCompound nbtt) { + super.readEntityFromNBT(nbtt); + ticksExisted = nbtt.getInteger("ticks"); + setAttacker(nbtt.getString("attacker")); + } + + public void writeEntityToNBT(NBTTagCompound nbtt) { + super.writeEntityToNBT(nbtt); + nbtt.setInteger("ticks", ticksExisted); + nbtt.setString("attacker", getAttacker()); + } +} diff --git a/src/main/java/ab/common/entity/EntityNebulaBlaze.java b/src/main/java/ab/common/entity/EntityNebulaBlaze.java index 1c2661f..ae3bb6b 100644 --- a/src/main/java/ab/common/entity/EntityNebulaBlaze.java +++ b/src/main/java/ab/common/entity/EntityNebulaBlaze.java @@ -2,8 +2,6 @@ package ab.common.entity; import java.util.List; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -14,110 +12,122 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; + import vazkii.botania.common.Botania; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class EntityNebulaBlaze extends EntityThrowable { - - public EntityNebulaBlaze(World world) { - super(world); - } - - public EntityNebulaBlaze(World world, EntityPlayer e) { - super(world, e); - } - - protected void entityInit() { - super.entityInit(); - this.dataWatcher.addObject(28, ""); - this.dataWatcher.setObjectWatched(28); - } - - public void onUpdate() { - if(this.ticksExisted >= 240) - setDead(); - double posX = this.posX; - double posY = this.posY; - double posZ = this.posZ; - update(); - super.onUpdate(); - AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(this.posX, this.posY, this.posZ, this.posX + 1, this.posY + 1, this.posZ + 1).expand(3.75f, 3.75f, 3.75f); - List livs = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); - for(EntityLivingBase liv : livs) { - if(liv instanceof EntityPlayer) - continue; - else if(liv.getHealth() <= 0.0f) - continue; - double d1 = (this.posX - liv.posX); - double d2 = (this.posY - liv.posY - liv.getEyeHeight()); - double d3 = (this.posZ - liv.posZ); - double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3); - if(d4 < 3.1D) - d4 = 3.1D; - double d5 = 1.0D - d4; - this.setPosition(posX, posY, posZ); - this.motionX = d1 / d4 * d5 * 0.325D + (liv.motionX * 0.85f); + + public EntityNebulaBlaze(World world) { + super(world); + } + + public EntityNebulaBlaze(World world, EntityPlayer e) { + super(world, e); + } + + protected void entityInit() { + super.entityInit(); + this.dataWatcher.addObject(28, ""); + this.dataWatcher.setObjectWatched(28); + } + + public void onUpdate() { + if (this.ticksExisted >= 240) setDead(); + double posX = this.posX; + double posY = this.posY; + double posZ = this.posZ; + update(); + super.onUpdate(); + AxisAlignedBB axis = AxisAlignedBB + .getBoundingBox(this.posX, this.posY, this.posZ, this.posX + 1, this.posY + 1, this.posZ + 1) + .expand(3.75f, 3.75f, 3.75f); + List livs = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); + for (EntityLivingBase liv : livs) { + if (liv instanceof EntityPlayer) continue; + else if (liv.getHealth() <= 0.0f) continue; + double d1 = (this.posX - liv.posX); + double d2 = (this.posY - liv.posY - liv.getEyeHeight()); + double d3 = (this.posZ - liv.posZ); + double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3); + if (d4 < 3.1D) d4 = 3.1D; + double d5 = 1.0D - d4; + this.setPosition(posX, posY, posZ); + this.motionX = d1 / d4 * d5 * 0.325D + (liv.motionX * 0.85f); this.motionY = d2 / d4 * d5 * 0.325D + (liv.motionY * 0.85f); this.motionZ = d3 / d4 * d5 * 0.325D + (liv.motionZ * 0.85f); - this.moveEntity(this.motionX, this.motionY, this.motionZ); - break; - } - if(this.worldObj.isRemote) - for(int i = 0; i < 12; i++) - Botania.proxy.sparkleFX(worldObj, posX + ((Math.random() - 0.5D)) * 0.15f, posY + ((Math.random() - 0.5D) * 0.15f), (posZ + (Math.random() - 0.5D) * 0.15f), 1.0f - (float)(Math.random() / 5.0f), 0.0f + (float)(Math.random() / 5.0f), 1.0f - (float)(Math.random() / 5.0f), 1.2F * (float)(Math.random() - 0.5D), 3); - } - - public void update() { - String attacker = getAttacker(); - AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(posX, posY, posZ, lastTickPosX, lastTickPosY, lastTickPosZ).expand(1.0D, 1.0D, 1.0D); - List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); - for(EntityLivingBase living : entities) { - if(living instanceof EntityPlayer && (((EntityPlayer)living).getCommandSenderName().equals(attacker) || (MinecraftServer.getServer() != null && !MinecraftServer.getServer().isPVPEnabled()))) - continue; - if(living.hurtTime == 0) { - float damage = 18.0f; - if(!worldObj.isRemote) { - EntityPlayer player = living.worldObj.getPlayerEntityByName(attacker); - living.attackEntityFrom((player == null) ? DamageSource.magic : DamageSource.causePlayerDamage(player), damage); - setDead(); - break; - } - } - } - } - - public void readEntityFromNBT(NBTTagCompound nbtt) { - super.readEntityFromNBT(nbtt); - ticksExisted = nbtt.getInteger("ticks"); - setAttacker(nbtt.getString("attacker")); - } + this.moveEntity(this.motionX, this.motionY, this.motionZ); + break; + } + if (this.worldObj.isRemote) for (int i = 0; i < 12; i++) Botania.proxy.sparkleFX( + worldObj, + posX + ((Math.random() - 0.5D)) * 0.15f, + posY + ((Math.random() - 0.5D) * 0.15f), + (posZ + (Math.random() - 0.5D) * 0.15f), + 1.0f - (float) (Math.random() / 5.0f), + 0.0f + (float) (Math.random() / 5.0f), + 1.0f - (float) (Math.random() / 5.0f), + 1.2F * (float) (Math.random() - 0.5D), + 3); + } - public void writeEntityToNBT(NBTTagCompound nbtt) { - super.writeEntityToNBT(nbtt); - nbtt.setInteger("ticks", ticksExisted); - nbtt.setString("attacker", getAttacker()); - } - - public String getAttacker() { - return this.dataWatcher.getWatchableObjectString(28); - } - - public void setAttacker(String str) { - this.dataWatcher.updateObject(28, str); - } - - @SideOnly(Side.CLIENT) - public void setPositionAndRotation2(double x, double y, double z, float help, float me, int please) {} - - protected float getGravityVelocity() { - return 0.0F; - } + public void update() { + String attacker = getAttacker(); + AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(posX, posY, posZ, lastTickPosX, lastTickPosY, lastTickPosZ) + .expand(1.0D, 1.0D, 1.0D); + List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); + for (EntityLivingBase living : entities) { + if (living instanceof EntityPlayer && (((EntityPlayer) living).getCommandSenderName().equals(attacker) + || (MinecraftServer.getServer() != null && !MinecraftServer.getServer().isPVPEnabled()))) + continue; + if (living.hurtTime == 0) { + float damage = 18.0f; + if (!worldObj.isRemote) { + EntityPlayer player = living.worldObj.getPlayerEntityByName(attacker); + living.attackEntityFrom( + (player == null) ? DamageSource.magic : DamageSource.causePlayerDamage(player), + damage); + setDead(); + break; + } + } + } + } - protected void onImpact(MovingObjectPosition mov) { - Block block = this.worldObj.getBlock(mov.blockX, mov.blockY, mov.blockZ); - if(block != null && mov.entityHit == null) { - if(block instanceof net.minecraft.block.BlockBush || block instanceof net.minecraft.block.BlockLeaves) - return; - setDead(); - } - } -} \ No newline at end of file + public void readEntityFromNBT(NBTTagCompound nbtt) { + super.readEntityFromNBT(nbtt); + ticksExisted = nbtt.getInteger("ticks"); + setAttacker(nbtt.getString("attacker")); + } + + public void writeEntityToNBT(NBTTagCompound nbtt) { + super.writeEntityToNBT(nbtt); + nbtt.setInteger("ticks", ticksExisted); + nbtt.setString("attacker", getAttacker()); + } + + public String getAttacker() { + return this.dataWatcher.getWatchableObjectString(28); + } + + public void setAttacker(String str) { + this.dataWatcher.updateObject(28, str); + } + + @SideOnly(Side.CLIENT) + public void setPositionAndRotation2(double x, double y, double z, float help, float me, int please) {} + + protected float getGravityVelocity() { + return 0.0F; + } + + protected void onImpact(MovingObjectPosition mov) { + Block block = this.worldObj.getBlock(mov.blockX, mov.blockY, mov.blockZ); + if (block != null && mov.entityHit == null) { + if (block instanceof net.minecraft.block.BlockBush || block instanceof net.minecraft.block.BlockLeaves) + return; + setDead(); + } + } +} diff --git a/src/main/java/ab/common/entity/EntitySeed.java b/src/main/java/ab/common/entity/EntitySeed.java index 0367a90..834b099 100644 --- a/src/main/java/ab/common/entity/EntitySeed.java +++ b/src/main/java/ab/common/entity/EntitySeed.java @@ -2,16 +2,11 @@ package ab.common.entity; import java.awt.Color; -import ab.client.core.ClientHelper; -import ab.common.item.equipment.ItemSprawlRod; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockBush; import net.minecraft.block.BlockLeaves; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.init.Blocks; import net.minecraft.item.Item; @@ -19,160 +14,188 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.world.BlockEvent; + import vazkii.botania.common.Botania; import vazkii.botania.common.item.ItemGrassSeeds; +import ab.common.item.equipment.ItemSprawlRod; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class EntitySeed extends EntityThrowable { - public EntitySeed(World world) { - super(world); - } - - public EntitySeed(World world, EntityPlayer e) { - super(world, e); - } - - protected void entityInit() { - super.entityInit(); - this.dataWatcher.addObject(27, new ItemStack(Blocks.air)); - this.dataWatcher.addObject(28, Integer.valueOf(1)); - this.dataWatcher.addObject(29, ""); - this.dataWatcher.setObjectWatched(27); - this.dataWatcher.setObjectWatched(28); - this.dataWatcher.setObjectWatched(29); - } - - public void onUpdate() { - super.onUpdate(); - if(ticksExisted >= 240) - setDead(); - if(this.worldObj.isRemote) { - float m = 0.02F; - float f1 = 4.0f / (getRadius() / 20.0f); - float size = 1.0f + (getRadius() / 12.0f); - for(int i = 0; i < 5; i++) { - double posX = this.posX + (Math.random() - 0.5f) / f1; - double posY = this.posY + (Math.random() - 0.5f) / f1; - double posZ = this.posZ + (Math.random() - 0.5f) / f1; - float mx = (float)(Math.random() - 0.5D) * m; - float my = (float)(Math.random() - 0.5D) * m; - float mz = (float)(Math.random() - 0.5D) * m; - Color color = ItemSprawlRod.getSeedColor(getSeed()); - Botania.proxy.wispFX(worldObj, posX, posY, posZ, color.getRed() / 255.0f, color.getGreen() / 255.0f, color.getBlue() / 255.0f, (float) (0.0625f * size + (Math.random() * 0.12f)), mx, my, mz, 0.5f); - } - } - } - - public int getRadius() { - return this.dataWatcher.getWatchableObjectInt(28); - } - - public void setRadius(int rad) { - this.dataWatcher.updateObject(28, rad); - } - - public ItemStack getSeed() { - return this.dataWatcher.getWatchableObjectItemStack(27); - } - - public void setSeed(ItemStack stack) { - stack.stackSize = 1; - this.dataWatcher.updateObject(27, stack == null ? new ItemStack(Blocks.air) : stack); - } - - public String getAttacker() { - return this.dataWatcher.getWatchableObjectString(29); - } - - public void setAttacker(String str) { - this.dataWatcher.updateObject(29, str); - } - - @SideOnly(Side.CLIENT) - public void setPositionAndRotation2(double x, double y, double z, float help, float me, int please) {} - - protected float getGravityVelocity() { - return 0.025F; - } - - protected void onImpact(MovingObjectPosition mov) { - Block block = worldObj.getBlock(mov.blockX, mov.blockY, mov.blockZ); - EntityPlayer player = worldObj.getPlayerEntityByName(getAttacker()); - if(block != null && mov.entityHit == null) { - if(block instanceof BlockBush || block instanceof BlockLeaves || player == null) - return; - ItemStack seed = getSeed(); - if(seed != null && seed.getItem() instanceof ItemGrassSeeds) { - Item itemSeed = (ItemGrassSeeds)seed.getItem(); - for(int i = 0; i < getRadius(); i++) { - for(int k = 0; k < getRadius(); k++) { - int posX = mov.blockX + i - getRadius() / 2; - int posY = mov.blockY; - int posZ = mov.blockZ + k - getRadius() / 2; - int j = posY; - if(isTopBlock(posX, posY - 1, posZ)) - j = Math.max(0, j - 20); - for(; !isTopBlock(posX, j, posZ); j++) { - if(Math.abs(j - posY) > 40) - break; - } - posY = j; - if(!worldObj.isRemote && isDirt(posX, posY, posZ)) { - BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(posX, posY, posZ, worldObj, worldObj.getBlock(posX, posY, posZ), worldObj.getBlockMetadata(posX, posY, posZ), player); - MinecraftForge.EVENT_BUS.post(event); - if(event.isCanceled()) - continue; - itemSeed.onItemUse(seed.copy(), player, worldObj, posX, posY, posZ, mov.sideHit, 0, 0, 0); - } else if((Math.random() < 0.15f || getRadius() < 3) && isDirt(posX, posY, posZ)) - spawnGrowParticle(posX, posY, posZ); - } - } - } - setDead(); - } - } - - public void readEntityFromNBT(NBTTagCompound nbtt) { - super.readEntityFromNBT(nbtt); - ticksExisted = nbtt.getInteger("ticks"); - setAttacker(nbtt.getString("attacker")); - NBTTagCompound stackCmp = nbtt.getCompoundTag("seedStack"); - setSeed(ItemStack.loadItemStackFromNBT(stackCmp)); - setRadius(nbtt.getInteger("radius")); - } + public EntitySeed(World world) { + super(world); + } - public void writeEntityToNBT(NBTTagCompound nbtt) { - super.writeEntityToNBT(nbtt); - nbtt.setInteger("ticks", ticksExisted); - nbtt.setString("attacker", getAttacker()); - ItemStack stack = getSeed(); - NBTTagCompound stackNbt = new NBTTagCompound(); - if(stack != null) - stack.writeToNBT(stackNbt); - nbtt.setInteger("radius", getRadius()); - nbtt.setTag("seedStack", stackNbt); - } - - private void spawnGrowParticle(int posX, int posY, int posZ) { - for (int i = 0; i < 50; i++) { - double x = (Math.random() - 0.5D) * 3.0D; - double y = Math.random() - 0.5D + 1.0D; - double z = (Math.random() - 0.5D) * 3.0D; - float velMul = 0.025F; - Color color = ItemSprawlRod.getSeedColor(getSeed()); - Botania.proxy.wispFX(worldObj, posX + 0.5D + x, posY + 0.5D + y, posZ + 0.5D + z, color.getRed() / 255.0f, color.getGreen() / 255.0f, color.getBlue() / 255.0f, (float)Math.random() * 0.15F + 0.15F, (float)-x * velMul, (float)-y * velMul, (float)-z * velMul); - } - } - - private boolean isDirt(int posX, int posY, int posZ) { - return worldObj.getBlock(posX, posY, posZ) == Blocks.dirt || worldObj.getBlock(posX, posY, posZ) == Blocks.grass; - } + public EntitySeed(World world, EntityPlayer e) { + super(world, e); + } - private boolean isTopBlock(int posX, int posY, int posZ) { - return worldObj.getBlock(posX, posY + 1, posZ).getMaterial() == Material.air || worldObj.getBlock(posX, posY + 1, posZ) instanceof BlockBush; - } -} \ No newline at end of file + protected void entityInit() { + super.entityInit(); + this.dataWatcher.addObject(27, new ItemStack(Blocks.air)); + this.dataWatcher.addObject(28, Integer.valueOf(1)); + this.dataWatcher.addObject(29, ""); + this.dataWatcher.setObjectWatched(27); + this.dataWatcher.setObjectWatched(28); + this.dataWatcher.setObjectWatched(29); + } + + public void onUpdate() { + super.onUpdate(); + if (ticksExisted >= 240) setDead(); + if (this.worldObj.isRemote) { + float m = 0.02F; + float f1 = 4.0f / (getRadius() / 20.0f); + float size = 1.0f + (getRadius() / 12.0f); + for (int i = 0; i < 5; i++) { + double posX = this.posX + (Math.random() - 0.5f) / f1; + double posY = this.posY + (Math.random() - 0.5f) / f1; + double posZ = this.posZ + (Math.random() - 0.5f) / f1; + float mx = (float) (Math.random() - 0.5D) * m; + float my = (float) (Math.random() - 0.5D) * m; + float mz = (float) (Math.random() - 0.5D) * m; + Color color = ItemSprawlRod.getSeedColor(getSeed()); + Botania.proxy.wispFX( + worldObj, + posX, + posY, + posZ, + color.getRed() / 255.0f, + color.getGreen() / 255.0f, + color.getBlue() / 255.0f, + (float) (0.0625f * size + (Math.random() * 0.12f)), + mx, + my, + mz, + 0.5f); + } + } + } + + public int getRadius() { + return this.dataWatcher.getWatchableObjectInt(28); + } + + public void setRadius(int rad) { + this.dataWatcher.updateObject(28, rad); + } + + public ItemStack getSeed() { + return this.dataWatcher.getWatchableObjectItemStack(27); + } + + public void setSeed(ItemStack stack) { + stack.stackSize = 1; + this.dataWatcher.updateObject(27, stack == null ? new ItemStack(Blocks.air) : stack); + } + + public String getAttacker() { + return this.dataWatcher.getWatchableObjectString(29); + } + + public void setAttacker(String str) { + this.dataWatcher.updateObject(29, str); + } + + @SideOnly(Side.CLIENT) + public void setPositionAndRotation2(double x, double y, double z, float help, float me, int please) {} + + protected float getGravityVelocity() { + return 0.025F; + } + + protected void onImpact(MovingObjectPosition mov) { + Block block = worldObj.getBlock(mov.blockX, mov.blockY, mov.blockZ); + EntityPlayer player = worldObj.getPlayerEntityByName(getAttacker()); + if (block != null && mov.entityHit == null) { + if (block instanceof BlockBush || block instanceof BlockLeaves || player == null) return; + ItemStack seed = getSeed(); + if (seed != null && seed.getItem() instanceof ItemGrassSeeds) { + Item itemSeed = (ItemGrassSeeds) seed.getItem(); + for (int i = 0; i < getRadius(); i++) { + for (int k = 0; k < getRadius(); k++) { + int posX = mov.blockX + i - getRadius() / 2; + int posY = mov.blockY; + int posZ = mov.blockZ + k - getRadius() / 2; + int j = posY; + if (isTopBlock(posX, posY - 1, posZ)) j = Math.max(0, j - 20); + for (; !isTopBlock(posX, j, posZ); j++) { + if (Math.abs(j - posY) > 40) break; + } + posY = j; + if (!worldObj.isRemote && isDirt(posX, posY, posZ)) { + BlockEvent.BreakEvent event = new BlockEvent.BreakEvent( + posX, + posY, + posZ, + worldObj, + worldObj.getBlock(posX, posY, posZ), + worldObj.getBlockMetadata(posX, posY, posZ), + player); + MinecraftForge.EVENT_BUS.post(event); + if (event.isCanceled()) continue; + itemSeed.onItemUse(seed.copy(), player, worldObj, posX, posY, posZ, mov.sideHit, 0, 0, 0); + } else if ((Math.random() < 0.15f || getRadius() < 3) && isDirt(posX, posY, posZ)) + spawnGrowParticle(posX, posY, posZ); + } + } + } + setDead(); + } + } + + public void readEntityFromNBT(NBTTagCompound nbtt) { + super.readEntityFromNBT(nbtt); + ticksExisted = nbtt.getInteger("ticks"); + setAttacker(nbtt.getString("attacker")); + NBTTagCompound stackCmp = nbtt.getCompoundTag("seedStack"); + setSeed(ItemStack.loadItemStackFromNBT(stackCmp)); + setRadius(nbtt.getInteger("radius")); + } + + public void writeEntityToNBT(NBTTagCompound nbtt) { + super.writeEntityToNBT(nbtt); + nbtt.setInteger("ticks", ticksExisted); + nbtt.setString("attacker", getAttacker()); + ItemStack stack = getSeed(); + NBTTagCompound stackNbt = new NBTTagCompound(); + if (stack != null) stack.writeToNBT(stackNbt); + nbtt.setInteger("radius", getRadius()); + nbtt.setTag("seedStack", stackNbt); + } + + private void spawnGrowParticle(int posX, int posY, int posZ) { + for (int i = 0; i < 50; i++) { + double x = (Math.random() - 0.5D) * 3.0D; + double y = Math.random() - 0.5D + 1.0D; + double z = (Math.random() - 0.5D) * 3.0D; + float velMul = 0.025F; + Color color = ItemSprawlRod.getSeedColor(getSeed()); + Botania.proxy.wispFX( + worldObj, + posX + 0.5D + x, + posY + 0.5D + y, + posZ + 0.5D + z, + color.getRed() / 255.0f, + color.getGreen() / 255.0f, + color.getBlue() / 255.0f, + (float) Math.random() * 0.15F + 0.15F, + (float) -x * velMul, + (float) -y * velMul, + (float) -z * velMul); + } + } + + private boolean isDirt(int posX, int posY, int posZ) { + return worldObj.getBlock(posX, posY, posZ) == Blocks.dirt + || worldObj.getBlock(posX, posY, posZ) == Blocks.grass; + } + + private boolean isTopBlock(int posX, int posY, int posZ) { + return worldObj.getBlock(posX, posY + 1, posZ).getMaterial() == Material.air + || worldObj.getBlock(posX, posY + 1, posZ) instanceof BlockBush; + } +} diff --git a/src/main/java/ab/common/entity/EntitySword.java b/src/main/java/ab/common/entity/EntitySword.java index 51588a4..92decd5 100644 --- a/src/main/java/ab/common/entity/EntitySword.java +++ b/src/main/java/ab/common/entity/EntitySword.java @@ -2,124 +2,132 @@ package ab.common.entity; import java.util.List; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityThrowable; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.server.MinecraftServer; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; -import vazkii.botania.api.internal.IManaBurst; + import vazkii.botania.common.Botania; -import vazkii.botania.common.core.helper.ItemNBTHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class EntitySword extends EntityThrowable { - public EntitySword(World world) { - super(world); - } - - public EntitySword(World world, EntityPlayer e) { - super(world, e); - } - - protected void entityInit() { - super.entityInit(); - this.dataWatcher.addObject(27, Float.valueOf(0.0f)); - this.dataWatcher.addObject(28, ""); - this.dataWatcher.setObjectWatched(27); - this.dataWatcher.setObjectWatched(28); - } - - public void onUpdate() { - super.onUpdate(); - update(); - if(ticksExisted < 20) { - this.motionX *= 1.115f; - this.motionY *= 1.115f; - this.motionZ *= 1.115f; - } - else if(ticksExisted > 160) - setDead(); - if(worldObj.isRemote) { - for(int i = 0; i < 12; i++) { - float r = worldObj.rand.nextBoolean() ? (225.0f / 255.0f) : (101.0f / 255.0f); - float g = worldObj.rand.nextBoolean() ? (67.0f / 255.0f) : (209.0f / 255.0f); - float b = worldObj.rand.nextBoolean() ? (240.0f / 255.0f) : (225.0f / 255.0f); - Botania.proxy.sparkleFX(worldObj, posX + ((Math.random() - 0.5D)) * 0.25f, posY + ((Math.random() - 0.5D) * 0.25f), (posZ + (Math.random() - 0.5D) * 0.25f), r + (float)(Math.random() / 4 - 0.125D), g + (float)(Math.random() / 4 - 0.125D), b + (float)(Math.random() / 4 - 0.125D), 1.6F * (float)(Math.random() - 0.5D), 2); - } - } - } - - public void update() { - String attacker = getAttacker(); - AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(posX, posY, posZ, lastTickPosX, lastTickPosY, lastTickPosZ).expand(1.0D, 1.0D, 1.0D); - List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); - for(EntityLivingBase living : entities) { - if(living instanceof EntityPlayer && (((EntityPlayer)living).getCommandSenderName().equals(attacker) || (MinecraftServer.getServer() != null && !MinecraftServer.getServer().isPVPEnabled()))) - continue; - if(living.hurtTime == 0) { - float damage = getDamage(); - if(!worldObj.isRemote) { - EntityPlayer player = living.worldObj.getPlayerEntityByName(attacker); - living.attackEntityFrom((player == null) ? DamageSource.magic : DamageSource.causePlayerDamage(player), damage); - setDead(); - break; - } - } - } - } - - public String getAttacker() { - return this.dataWatcher.getWatchableObjectString(28); - } - - public void setAttacker(String str) { - this.dataWatcher.updateObject(28, str); - } - - public float getDamage() { - return this.dataWatcher.getWatchableObjectFloat(27); - } - - public void setDamage(float damage) { - this.dataWatcher.updateObject(27, damage); - } - - @SideOnly(Side.CLIENT) - public void setPositionAndRotation2(double x, double y, double z, float help, float me, int please) {} + public EntitySword(World world) { + super(world); + } - protected void onImpact(MovingObjectPosition mov) { - Block block = this.worldObj.getBlock(mov.blockX, mov.blockY, mov.blockZ); - if(block != null && mov.entityHit == null) { - if(block instanceof net.minecraft.block.BlockBush || block instanceof net.minecraft.block.BlockLeaves) - return; - setDead(); - } - } - - public void readEntityFromNBT(NBTTagCompound nbtt) { - super.readEntityFromNBT(nbtt); - ticksExisted = nbtt.getInteger("ticks"); - setDamage(nbtt.getInteger("disDamage")); - setAttacker(nbtt.getString("attacker")); - } + public EntitySword(World world, EntityPlayer e) { + super(world, e); + } - public void writeEntityToNBT(NBTTagCompound nbtt) { - super.writeEntityToNBT(nbtt); - nbtt.setInteger("ticks", ticksExisted); - nbtt.setFloat("disDamage", getDamage()); - nbtt.setString("attacker", getAttacker()); - } - - protected float getGravityVelocity() { - return 0.0F; - } -} \ No newline at end of file + protected void entityInit() { + super.entityInit(); + this.dataWatcher.addObject(27, Float.valueOf(0.0f)); + this.dataWatcher.addObject(28, ""); + this.dataWatcher.setObjectWatched(27); + this.dataWatcher.setObjectWatched(28); + } + + public void onUpdate() { + super.onUpdate(); + update(); + if (ticksExisted < 20) { + this.motionX *= 1.115f; + this.motionY *= 1.115f; + this.motionZ *= 1.115f; + } else if (ticksExisted > 160) setDead(); + if (worldObj.isRemote) { + for (int i = 0; i < 12; i++) { + float r = worldObj.rand.nextBoolean() ? (225.0f / 255.0f) : (101.0f / 255.0f); + float g = worldObj.rand.nextBoolean() ? (67.0f / 255.0f) : (209.0f / 255.0f); + float b = worldObj.rand.nextBoolean() ? (240.0f / 255.0f) : (225.0f / 255.0f); + Botania.proxy.sparkleFX( + worldObj, + posX + ((Math.random() - 0.5D)) * 0.25f, + posY + ((Math.random() - 0.5D) * 0.25f), + (posZ + (Math.random() - 0.5D) * 0.25f), + r + (float) (Math.random() / 4 - 0.125D), + g + (float) (Math.random() / 4 - 0.125D), + b + (float) (Math.random() / 4 - 0.125D), + 1.6F * (float) (Math.random() - 0.5D), + 2); + } + } + } + + public void update() { + String attacker = getAttacker(); + AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(posX, posY, posZ, lastTickPosX, lastTickPosY, lastTickPosZ) + .expand(1.0D, 1.0D, 1.0D); + List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); + for (EntityLivingBase living : entities) { + if (living instanceof EntityPlayer && (((EntityPlayer) living).getCommandSenderName().equals(attacker) + || (MinecraftServer.getServer() != null && !MinecraftServer.getServer().isPVPEnabled()))) + continue; + if (living.hurtTime == 0) { + float damage = getDamage(); + if (!worldObj.isRemote) { + EntityPlayer player = living.worldObj.getPlayerEntityByName(attacker); + living.attackEntityFrom( + (player == null) ? DamageSource.magic : DamageSource.causePlayerDamage(player), + damage); + setDead(); + break; + } + } + } + } + + public String getAttacker() { + return this.dataWatcher.getWatchableObjectString(28); + } + + public void setAttacker(String str) { + this.dataWatcher.updateObject(28, str); + } + + public float getDamage() { + return this.dataWatcher.getWatchableObjectFloat(27); + } + + public void setDamage(float damage) { + this.dataWatcher.updateObject(27, damage); + } + + @SideOnly(Side.CLIENT) + public void setPositionAndRotation2(double x, double y, double z, float help, float me, int please) {} + + protected void onImpact(MovingObjectPosition mov) { + Block block = this.worldObj.getBlock(mov.blockX, mov.blockY, mov.blockZ); + if (block != null && mov.entityHit == null) { + if (block instanceof net.minecraft.block.BlockBush || block instanceof net.minecraft.block.BlockLeaves) + return; + setDead(); + } + } + + public void readEntityFromNBT(NBTTagCompound nbtt) { + super.readEntityFromNBT(nbtt); + ticksExisted = nbtt.getInteger("ticks"); + setDamage(nbtt.getInteger("disDamage")); + setAttacker(nbtt.getString("attacker")); + } + + public void writeEntityToNBT(NBTTagCompound nbtt) { + super.writeEntityToNBT(nbtt); + nbtt.setInteger("ticks", ticksExisted); + nbtt.setFloat("disDamage", getDamage()); + nbtt.setString("attacker", getAttacker()); + } + + protected float getGravityVelocity() { + return 0.0F; + } +} diff --git a/src/main/java/ab/common/item/ItemABResource.java b/src/main/java/ab/common/item/ItemABResource.java index f63814c..c7d7502 100644 --- a/src/main/java/ab/common/item/ItemABResource.java +++ b/src/main/java/ab/common/item/ItemABResource.java @@ -2,10 +2,6 @@ package ab.common.item; import java.util.List; -import ab.AdvancedBotany; -import ab.api.AdvancedBotanyAPI; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -19,88 +15,88 @@ import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.IIcon; import net.minecraft.world.World; + import vazkii.botania.api.recipe.IFlowerComponent; +import ab.AdvancedBotany; +import ab.api.AdvancedBotanyAPI; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemABResource extends Item implements IFlowerComponent { - private IIcon[] icons = new IIcon[7]; - - public ItemABResource() { - this.setHasSubtypes(true); - this.setCreativeTab(AdvancedBotany.tabAB); - this.setUnlocalizedName("resourceAB"); - } - - public void registerIcons(IIconRegister ir) { - for(int i = 0; i < icons.length; i++) { - icons[i] = ir.registerIcon("ab:resourceAB_" + i); - } - } - - public EnumRarity getRarity(ItemStack stack) { - if(stack.getItemDamage() == 5 || stack.getItemDamage() == 6) - return AdvancedBotanyAPI.rarityNebula; - return super.getRarity(stack); - } - + private IIcon[] icons = new IIcon[7]; + + public ItemABResource() { + this.setHasSubtypes(true); + this.setCreativeTab(AdvancedBotany.tabAB); + this.setUnlocalizedName("resourceAB"); + } + + public void registerIcons(IIconRegister ir) { + for (int i = 0; i < icons.length; i++) { + icons[i] = ir.registerIcon("ab:resourceAB_" + i); + } + } + + public EnumRarity getRarity(ItemStack stack) { + if (stack.getItemDamage() == 5 || stack.getItemDamage() == 6) return AdvancedBotanyAPI.rarityNebula; + return super.getRarity(stack); + } + @SideOnly(Side.CLIENT) public boolean hasEffect(ItemStack stack) { return stack.getItemDamage() == 2; } - - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < icons.length; i++) { - list.add(new ItemStack((Item)this, 1, i)); - } - } - - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - return icons[Math.min(icons.length - 1, par1)]; - } - - public boolean canFit(ItemStack stack, IInventory apothecary) { - int meta = stack.getItemDamage(); - return (meta == 3 || meta == 2 || meta == 4); - } - - public String getUnlocalizedName(final ItemStack stack) { - return "item.resourceAB_" + stack.getItemDamage(); - } - - public int getParticleColor(ItemStack stack) { - return 10158080; - } - - public boolean isElvenItem(ItemStack stack) { - return false; - } - - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if(stack.getItemDamage() != 3) - return super.onItemRightClick(stack, world, player); - player.setItemInUse(stack, getMaxItemUseDuration(stack)); - return stack; - } - - public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) { - if(stack.getItemDamage() != 3) - return super.onEaten(stack, world, player); - else if(!world.isRemote) - player.addPotionEffect(new PotionEffect(Potion.confusion.id, 120, 3)); - ItemStack bottle = new ItemStack(Items.glass_bottle); - if(!player.inventory.addItemStackToInventory(bottle)) - player.dropPlayerItemWithRandomChoice(bottle, false); - --stack.stackSize; - return stack; - } - - public int getMaxItemUseDuration(ItemStack stack) { - return stack.getItemDamage() != 3 ? super.getMaxItemUseDuration(stack) : 24; - } - - public EnumAction getItemUseAction(ItemStack stack) { - return stack.getItemDamage() != 3 ? super.getItemUseAction(stack) : EnumAction.drink; - } + + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < icons.length; i++) { + list.add(new ItemStack((Item) this, 1, i)); + } + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return icons[Math.min(icons.length - 1, par1)]; + } + + public boolean canFit(ItemStack stack, IInventory apothecary) { + int meta = stack.getItemDamage(); + return (meta == 3 || meta == 2 || meta == 4); + } + + public String getUnlocalizedName(final ItemStack stack) { + return "item.resourceAB_" + stack.getItemDamage(); + } + + public int getParticleColor(ItemStack stack) { + return 10158080; + } + + public boolean isElvenItem(ItemStack stack) { + return false; + } + + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (stack.getItemDamage() != 3) return super.onItemRightClick(stack, world, player); + player.setItemInUse(stack, getMaxItemUseDuration(stack)); + return stack; + } + + public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) { + if (stack.getItemDamage() != 3) return super.onEaten(stack, world, player); + else if (!world.isRemote) player.addPotionEffect(new PotionEffect(Potion.confusion.id, 120, 3)); + ItemStack bottle = new ItemStack(Items.glass_bottle); + if (!player.inventory.addItemStackToInventory(bottle)) player.dropPlayerItemWithRandomChoice(bottle, false); + --stack.stackSize; + return stack; + } + + public int getMaxItemUseDuration(ItemStack stack) { + return stack.getItemDamage() != 3 ? super.getMaxItemUseDuration(stack) : 24; + } + + public EnumAction getItemUseAction(ItemStack stack) { + return stack.getItemDamage() != 3 ? super.getItemUseAction(stack) : EnumAction.drink; + } } diff --git a/src/main/java/ab/common/item/ItemAdvancedSpark.java b/src/main/java/ab/common/item/ItemAdvancedSpark.java index 23caac8..2f25c82 100644 --- a/src/main/java/ab/common/item/ItemAdvancedSpark.java +++ b/src/main/java/ab/common/item/ItemAdvancedSpark.java @@ -1,59 +1,58 @@ package ab.common.item; -import ab.AdvancedBotany; -import ab.common.entity.EntityAdvancedSpark; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.mana.IManaGivingItem; import vazkii.botania.api.mana.spark.ISparkAttachable; import vazkii.botania.api.mana.spark.ISparkEntity; -import vazkii.botania.common.entity.EntitySpark; +import ab.common.entity.EntityAdvancedSpark; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemAdvancedSpark extends ItemMod implements IManaGivingItem { - public static IIcon invIcon; - public static IIcon worldIcon; - - public ItemAdvancedSpark() { - super("advancedSpark"); - } - - 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) { - EntityAdvancedSpark spark = new EntityAdvancedSpark(world); - spark.setPosition(x + 0.5D, y + 1.5D, z + 0.5D); - world.spawnEntityInWorld((Entity)spark); - attach.attachSpark((ISparkEntity)spark); - VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z); - } - return true; - } - } - return false; - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister ir) { - invIcon = ir.registerIcon("ab:itemAB.spark_0"); - worldIcon = ir.registerIcon("ab:itemAB.spark_1"); - } - - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - return invIcon; - } -} \ No newline at end of file + public static IIcon invIcon; + public static IIcon worldIcon; + + public ItemAdvancedSpark() { + super("advancedSpark"); + } + + 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) { + EntityAdvancedSpark spark = new EntityAdvancedSpark(world); + spark.setPosition(x + 0.5D, y + 1.5D, z + 0.5D); + world.spawnEntityInWorld((Entity) spark); + attach.attachSpark((ISparkEntity) spark); + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z); + } + return true; + } + } + return false; + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister ir) { + invIcon = ir.registerIcon("ab:itemAB.spark_0"); + worldIcon = ir.registerIcon("ab:itemAB.spark_1"); + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return invIcon; + } +} diff --git a/src/main/java/ab/common/item/ItemAntigravityCharm.java b/src/main/java/ab/common/item/ItemAntigravityCharm.java index dd8b7b7..069d029 100644 --- a/src/main/java/ab/common/item/ItemAntigravityCharm.java +++ b/src/main/java/ab/common/item/ItemAntigravityCharm.java @@ -2,85 +2,86 @@ package ab.common.item; import java.util.List; -import ab.common.core.CommonHelper; -import ab.common.lib.register.BlockListAB; -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; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityFallingBlock; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; import net.minecraft.world.World; + import vazkii.botania.common.core.helper.ItemNBTHelper; +import ab.common.core.CommonHelper; +import ab.common.lib.register.BlockListAB; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemAntigravityCharm extends ItemMod { - public static IIcon[] icons; - - public ItemAntigravityCharm() { - super("antigravityCharm"); - this.setMaxStackSize(1); - this.setNoRepair(); - } - - public void registerIcons(IIconRegister ir) { - icons = new IIcon[2]; - for(int i = 0; i < icons.length; i++) - icons[i] = icons[i] = ir.registerIcon("ab:" + "itemAntigravityCharm_" + i); - } - - @SideOnly(Side.CLIENT) - public IIcon getIcon(ItemStack stack, int pass) { - int iconID = Math.min(1, pass); - return this.icons[iconID]; - } - - public boolean requiresMultipleRenderPasses() { - return true; - } - - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if(player.isSneaking()) - ItemNBTHelper.setBoolean(stack, "isActive", !ItemNBTHelper.getBoolean(stack, "isActive", true)); - return stack; - } - - public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean inHand) { - if(entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer)entity; - if(ItemNBTHelper.getBoolean(stack, "isActive", true)) { - double posX = player.posX; - double posY = player.posY; - double posZ = player.posZ; - final AxisAlignedBB asis = AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX + 1, posY + 1, posZ + 1).expand(8, 8, 8); - final List listEntity = world.getEntitiesWithinAABB(EntityFallingBlock.class, asis); - for(EntityFallingBlock fallBlock : listEntity) { - int x = (int) (fallBlock.posX >= 0 ? fallBlock.posX : fallBlock.posX - 1); - int y = (int) fallBlock.posY; - int z = (int) (fallBlock.posZ >= 0 ? fallBlock.posZ : fallBlock.posZ - 1); - Block block = fallBlock.func_145805_f(); - fallBlock.setInvisible(true); - if(!world.isRemote) { - if(CommonHelper.setBlock(world, BlockListAB.blockAntigravitation, 0, x, y - 1, z, player, true)) { - CommonHelper.setBlock(world, block, fallBlock.field_145814_a, x, y, z, player, true); - fallBlock.setDead(); - } - } - } - } - } - } - - private void setBlock(World world, int x, int y, int z, Block block, int meta) { - if(world.getBlock(x, y, z).getMaterial() == Material.air && y < 256) { - world.setBlock(x, y, z, block, meta, 3); - } - } -} \ No newline at end of file + public static IIcon[] icons; + + public ItemAntigravityCharm() { + super("antigravityCharm"); + this.setMaxStackSize(1); + this.setNoRepair(); + } + + public void registerIcons(IIconRegister ir) { + icons = new IIcon[2]; + for (int i = 0; i < icons.length; i++) + icons[i] = icons[i] = ir.registerIcon("ab:" + "itemAntigravityCharm_" + i); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int pass) { + int iconID = Math.min(1, pass); + return this.icons[iconID]; + } + + public boolean requiresMultipleRenderPasses() { + return true; + } + + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (player.isSneaking()) + ItemNBTHelper.setBoolean(stack, "isActive", !ItemNBTHelper.getBoolean(stack, "isActive", true)); + return stack; + } + + public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean inHand) { + if (entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) entity; + if (ItemNBTHelper.getBoolean(stack, "isActive", true)) { + double posX = player.posX; + double posY = player.posY; + double posZ = player.posZ; + final AxisAlignedBB asis = AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX + 1, posY + 1, posZ + 1) + .expand(8, 8, 8); + final List listEntity = world.getEntitiesWithinAABB(EntityFallingBlock.class, asis); + for (EntityFallingBlock fallBlock : listEntity) { + int x = (int) (fallBlock.posX >= 0 ? fallBlock.posX : fallBlock.posX - 1); + int y = (int) fallBlock.posY; + int z = (int) (fallBlock.posZ >= 0 ? fallBlock.posZ : fallBlock.posZ - 1); + Block block = fallBlock.func_145805_f(); + fallBlock.setInvisible(true); + if (!world.isRemote) { + if (CommonHelper + .setBlock(world, BlockListAB.blockAntigravitation, 0, x, y - 1, z, player, true)) { + CommonHelper.setBlock(world, block, fallBlock.field_145814_a, x, y, z, player, true); + fallBlock.setDead(); + } + } + } + } + } + } + + private void setBlock(World world, int x, int y, int z, Block block, int meta) { + if (world.getBlock(x, y, z).getMaterial() == Material.air && y < 256) { + world.setBlock(x, y, z, block, meta, 3); + } + } +} diff --git a/src/main/java/ab/common/item/ItemCraftingPattern.java b/src/main/java/ab/common/item/ItemCraftingPattern.java index 66c7b8f..d622d40 100644 --- a/src/main/java/ab/common/item/ItemCraftingPattern.java +++ b/src/main/java/ab/common/item/ItemCraftingPattern.java @@ -2,105 +2,84 @@ package ab.common.item; import java.util.List; -import ab.AdvancedBotany; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; +import ab.AdvancedBotany; + public class ItemCraftingPattern extends Item { - static IIcon[] icon; + static IIcon[] icon; - public ItemCraftingPattern() { - this.setCreativeTab(AdvancedBotany.tabAB); - this.setHasSubtypes(true); - icon = new IIcon[10]; - } + public ItemCraftingPattern() { + this.setCreativeTab(AdvancedBotany.tabAB); + this.setHasSubtypes(true); + icon = new IIcon[10]; + } - public void registerIcons(IIconRegister ir) { - icon[0] = ir.registerIcon("ab:blank_pattern"); - icon[1] = ir.registerIcon("ab:pattern_diagonal"); - icon[2] = ir.registerIcon("ab:pattern_T"); - icon[3] = ir.registerIcon("ab:pattern_I"); - icon[4] = ir.registerIcon("ab:pattern_U"); - icon[5] = ir.registerIcon("ab:pattern_6rect"); - icon[6] = ir.registerIcon("ab:pattern_8"); - icon[7] = ir.registerIcon("ab:pattern_2"); - icon[8] = ir.registerIcon("ab:pattern_UV"); - icon[9] = ir.registerIcon("ab:pattern_cross"); - } - - public String getUnlocalizedName(ItemStack stack) { - return "item.ab.pattern" + stack.getItemDamage(); - } - - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for(int i = 0; i < 10; i++) - par3List.add(new ItemStack(par1, 1, i)); - } - - public IIcon getIconFromDamage(int meta) { - return icon[Math.min(meta, 9)]; - } + public void registerIcons(IIconRegister ir) { + icon[0] = ir.registerIcon("ab:blank_pattern"); + icon[1] = ir.registerIcon("ab:pattern_diagonal"); + icon[2] = ir.registerIcon("ab:pattern_T"); + icon[3] = ir.registerIcon("ab:pattern_I"); + icon[4] = ir.registerIcon("ab:pattern_U"); + icon[5] = ir.registerIcon("ab:pattern_6rect"); + icon[6] = ir.registerIcon("ab:pattern_8"); + icon[7] = ir.registerIcon("ab:pattern_2"); + icon[8] = ir.registerIcon("ab:pattern_UV"); + icon[9] = ir.registerIcon("ab:pattern_cross"); + } - public static boolean[][] getPattern(int meta) { - switch (meta) { - case 0: - return new boolean[][] { - new boolean[] { true, true, true }, - new boolean[] { true, true, true }, - new boolean[] { true, true, true }}; - case 1: - return new boolean[][] { - new boolean[] { false, false, true }, - new boolean[] { false, true, false }, - new boolean[] { true, false, false }}; + public String getUnlocalizedName(ItemStack stack) { + return "item.ab.pattern" + stack.getItemDamage(); + } - case 2: - return new boolean[][] { - new boolean[] { false, false, false }, - new boolean[] { false, true, false }, - new boolean[] { true, true, true }}; + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < 10; i++) par3List.add(new ItemStack(par1, 1, i)); + } - case 3: - return new boolean[][] { - new boolean[] { true, false, false }, - new boolean[] { true, false, false }, - new boolean[] { true, false, false }}; - case 4: - return new boolean[][] { - new boolean[] { true, true, true }, - new boolean[] { true, false, true }, - new boolean[] { false, false, false }}; - case 5: - return new boolean[][] { - new boolean[] { true, true, true }, - new boolean[] { true, true, true }, - new boolean[] { false, false, false }}; - case 6: - return new boolean[][] { - new boolean[] { true, true, true }, - new boolean[] { true, false, true }, - new boolean[] { true, true, true }}; - case 7: - return new boolean[][] { - new boolean[] { true, true, false }, - new boolean[] { false, false, false }, - new boolean[] { false, false, false }}; - case 8: - return new boolean[][] { - new boolean[] { false, true, false }, - new boolean[] { true, false, true }, - new boolean[] { true, false, true }}; - case 9: - return new boolean[][] { - new boolean[] { false, true, false }, - new boolean[] { true, true, true }, - new boolean[] { false, true, false }}; - } - return null; - } -} \ No newline at end of file + public IIcon getIconFromDamage(int meta) { + return icon[Math.min(meta, 9)]; + } + + public static boolean[][] getPattern(int meta) { + switch (meta) { + case 0: + return new boolean[][] { new boolean[] { true, true, true }, new boolean[] { true, true, true }, + new boolean[] { true, true, true } }; + case 1: + return new boolean[][] { new boolean[] { false, false, true }, new boolean[] { false, true, false }, + new boolean[] { true, false, false } }; + + case 2: + return new boolean[][] { new boolean[] { false, false, false }, new boolean[] { false, true, false }, + new boolean[] { true, true, true } }; + + case 3: + return new boolean[][] { new boolean[] { true, false, false }, new boolean[] { true, false, false }, + new boolean[] { true, false, false } }; + case 4: + return new boolean[][] { new boolean[] { true, true, true }, new boolean[] { true, false, true }, + new boolean[] { false, false, false } }; + case 5: + return new boolean[][] { new boolean[] { true, true, true }, new boolean[] { true, true, true }, + new boolean[] { false, false, false } }; + case 6: + return new boolean[][] { new boolean[] { true, true, true }, new boolean[] { true, false, true }, + new boolean[] { true, true, true } }; + case 7: + return new boolean[][] { new boolean[] { true, true, false }, new boolean[] { false, false, false }, + new boolean[] { false, false, false } }; + case 8: + return new boolean[][] { new boolean[] { false, true, false }, new boolean[] { true, false, true }, + new boolean[] { true, false, true } }; + case 9: + return new boolean[][] { new boolean[] { false, true, false }, new boolean[] { true, true, true }, + new boolean[] { false, true, false } }; + } + return null; + } +} diff --git a/src/main/java/ab/common/item/ItemMod.java b/src/main/java/ab/common/item/ItemMod.java index cfea790..e257b23 100644 --- a/src/main/java/ab/common/item/ItemMod.java +++ b/src/main/java/ab/common/item/ItemMod.java @@ -1,13 +1,14 @@ package ab.common.item; -import ab.AdvancedBotany; import net.minecraft.item.Item; +import ab.AdvancedBotany; + public class ItemMod extends Item { - public ItemMod(String name) { - this.setTextureName("ab:" + name); - this.setUnlocalizedName(name); - this.setCreativeTab(AdvancedBotany.tabAB); - } + public ItemMod(String name) { + this.setTextureName("ab:" + name); + this.setUnlocalizedName(name); + this.setCreativeTab(AdvancedBotany.tabAB); + } } diff --git a/src/main/java/ab/common/item/block/ItemBlockBase.java b/src/main/java/ab/common/item/block/ItemBlockBase.java index 67feb70..707e7bc 100644 --- a/src/main/java/ab/common/item/block/ItemBlockBase.java +++ b/src/main/java/ab/common/item/block/ItemBlockBase.java @@ -6,19 +6,22 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlockWithMetadata; import net.minecraft.item.ItemStack; import net.minecraft.stats.Achievement; + import vazkii.botania.common.achievement.IPickupAchievement; public class ItemBlockBase extends ItemBlockWithMetadata implements IPickupAchievement { - public ItemBlockBase(Block block) { - super(block, block); + public ItemBlockBase(Block block) { + super(block, block); } - - public String getUnlocalizedName(ItemStack stack) { - return super.getUnlocalizedName(stack) + "." + stack.getItemDamage(); - } - public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { - return (this.field_150939_a instanceof IPickupAchievement) ? ((IPickupAchievement)this.field_150939_a).getAchievementOnPickup(stack, player, item) : null; - } -} \ No newline at end of file + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName(stack) + "." + stack.getItemDamage(); + } + + public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { + return (this.field_150939_a instanceof IPickupAchievement) + ? ((IPickupAchievement) this.field_150939_a).getAchievementOnPickup(stack, player, item) + : null; + } +} diff --git a/src/main/java/ab/common/item/block/ItemBlockBoard.java b/src/main/java/ab/common/item/block/ItemBlockBoard.java index 996c781..24cddc5 100644 --- a/src/main/java/ab/common/item/block/ItemBlockBoard.java +++ b/src/main/java/ab/common/item/block/ItemBlockBoard.java @@ -8,31 +8,30 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; + import vazkii.botania.api.BotaniaAPI; public class ItemBlockBoard extends ItemBlockBase { - public ItemBlockBoard(Block block) { - super(block); - } - - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean p_77624_4_) { - if(stack.getItemDamage() == 1) { - if(GuiScreen.isShiftKeyDown()) { - addStringToTooltip(StatCollector.translateToLocal("abmisc.fateBoard.info0"), list); - addStringToTooltip(StatCollector.translateToLocal("abmisc.fateBoard.info1"), list); - } else - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), list); - } - } - - public void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00A7")); - } + public ItemBlockBoard(Block block) { + super(block); + } - public EnumRarity getRarity(ItemStack stack) { - if(stack.getItemDamage() == 1) - return BotaniaAPI.rarityRelic; - return super.getRarity(stack); - } -} \ No newline at end of file + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean p_77624_4_) { + if (stack.getItemDamage() == 1) { + if (GuiScreen.isShiftKeyDown()) { + addStringToTooltip(StatCollector.translateToLocal("abmisc.fateBoard.info0"), list); + addStringToTooltip(StatCollector.translateToLocal("abmisc.fateBoard.info1"), list); + } else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), list); + } + } + + public void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00A7")); + } + + public EnumRarity getRarity(ItemStack stack) { + if (stack.getItemDamage() == 1) return BotaniaAPI.rarityRelic; + return super.getRarity(stack); + } +} diff --git a/src/main/java/ab/common/item/equipment/ItemAquaSword.java b/src/main/java/ab/common/item/equipment/ItemAquaSword.java index 2e572a5..5241b85 100644 --- a/src/main/java/ab/common/item/equipment/ItemAquaSword.java +++ b/src/main/java/ab/common/item/equipment/ItemAquaSword.java @@ -1,25 +1,9 @@ package ab.common.item.equipment; -import java.awt.Color; import java.util.List; -import java.util.UUID; -import com.google.common.collect.Multimap; - -import ab.AdvancedBotany; -import ab.api.AdvancedBotanyAPI; -import ab.client.core.ClientHelper; -import ab.client.core.handler.PlayerItemUsingSound.ClientSoundHandler; -import ab.common.core.handler.ConfigABHandler; -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.Minecraft; 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.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; @@ -28,104 +12,140 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; -import net.minecraft.world.World; + import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.Botania; -import vazkii.botania.common.core.helper.ItemNBTHelper; -import vazkii.botania.common.core.helper.Vector3; +import ab.AdvancedBotany; +import ab.api.AdvancedBotanyAPI; +import ab.client.core.handler.PlayerItemUsingSound.ClientSoundHandler; public class ItemAquaSword extends ItemSword { - public ItemAquaSword() { - super(AdvancedBotanyAPI.mithrilToolMaterial); - this.setCreativeTab(AdvancedBotany.tabAB); - this.setUnlocalizedName("itemAquaSword"); - this.setTextureName("ab:itemAquaSword"); - } - - public boolean isItemTool(ItemStack par1ItemStack) { - return true; - } - - public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { - AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(entity.posX, entity.posY, entity.posZ, entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ).expand(1.7f, 1.7f, 1.7f); - List entities = entity.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); - double posX = entity.posX; - double posY = entity.posY + entity.getEyeHeight(); - double posZ = entity.posZ; - if(!player.worldObj.isRemote) { - boolean hasWaterSplash = false; - for(EntityLivingBase living : entities) { - if(living instanceof EntityPlayer && (((EntityPlayer)living).getCommandSenderName().equals(player.getCommandSenderName()) || (MinecraftServer.getServer() != null && !MinecraftServer.getServer().isPVPEnabled()))) - continue; - else if(ManaItemHandler.requestManaExactForTool(stack, player, 10, false) && living.attackEntityFrom(DamageSource.causePlayerDamage(player), AdvancedBotanyAPI.mithrilToolMaterial.getDamageVsEntity() / 2.0f)) { - ManaItemHandler.requestManaExactForTool(stack, player, 10, true); - if(!hasWaterSplash) - hasWaterSplash = true; - Vec3 vec3 = player.getLook(1.0F).normalize(); - living.motionX += vec3.xCoord * 1.35f; - living.motionY += (vec3.yCoord / 1.8f); - living.motionZ += vec3.zCoord * 1.35f; - } - } - if(hasWaterSplash) - player.worldObj.playSoundAtEntity(player, "ab:aquaSword", 1.2F, 1.2F); - } else { - if(ManaItemHandler.requestManaExactForTool(stack, player, 10, false)) { - for(int i = 0; i < 24; i++) { - float mtX = (float)((Math.random() - 0.5f) * 0.12f); - float mtY = (float)((Math.random() - 0.5f) * 0.12f); - float mtZ = (float)((Math.random() - 0.5f) * 0.12f); - Botania.proxy.wispFX(player.worldObj, posX, posY, posZ, 0.0f, (float)(Math.random() * 0.35f), 1.0f - (float)(Math.random() * 0.4f), 0.17f + (float)(Math.random() * 0.3f), mtX, mtY, mtZ, 0.512f); - } - } - } - return super.onLeftClickEntity(stack, player, entity); - } - - public void onUsingTick(ItemStack stack, EntityPlayer p, int time) { - if(p.worldObj.isRemote) { - if(!ManaItemHandler.requestManaExactForTool(stack, p, 15, false)) - return; - ClientSoundHandler.playSound(p, "liquid.water", 0.8F, 1.7F, 13, false); - time = (this.getMaxItemUseDuration(stack) - time) % 120 + 1; - if(time > 50) - time = 120 - time; - float phase = time / 120.0f; - int wispCount = 8; - double tickIncrement = 360.0D / wispCount; - int speed = 10; - double wticks = (time * speed) - tickIncrement; - double r = Math.sin(1.4f); - for(int i = 0; i < wispCount; i++) { - double posX = p.posX + Math.sin(wticks * Math.PI / 180.0D) * r; - double posY = p.posY + (wticks * 0.001f) + 0.1f; - double posZ = p.posZ + Math.cos(wticks * Math.PI / 180.0D) * r; - Botania.proxy.wispFX(p.worldObj, posX, posY, posZ, 0.0f, (float)(Math.random() * 0.35f), 1.0f - (float)(Math.random() * 0.4f), 0.3F, 0.0f, -0.1f + (float)(Math.random() * 0.05f), 0.0f, 0.7F); - wticks += tickIncrement; - } - } else { - AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(p.posX, p.posY, p.posZ, p.lastTickPosX, p.lastTickPosY, p.lastTickPosZ).expand(2.75f, 2.75f, 2.75f); - List entities = p.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); - for(EntityLivingBase living : entities) { - if(living instanceof EntityPlayer && (((EntityPlayer)living).getCommandSenderName().equals(p.getCommandSenderName()) || (MinecraftServer.getServer() != null && !MinecraftServer.getServer().isPVPEnabled()))) - continue; - double dist = living.getDistance(p.posX, p.posY, p.posZ) / 2.5f; - if(ManaItemHandler.requestManaExactForTool(stack, p, 15, false) && living.attackEntityFrom(DamageSource.causePlayerDamage(p), 1.0f)) { - ManaItemHandler.requestManaExactForTool(stack, p, 15, true); - if(dist <= 1.0D) { - double d5 = living.posX - p.posX; - double d7 = living.posZ - p.posZ; - double d9 = (double)MathHelper.sqrt_double(d5 * d5 + d7 * d7); - if (d9 != 0.0D) { - d5 /= d9; - d7 /= d9; - living.motionX += d5 * 1.2f; - living.motionZ += d7 * 1.2f; - } - } - } - } - } - } -} \ No newline at end of file + public ItemAquaSword() { + super(AdvancedBotanyAPI.mithrilToolMaterial); + this.setCreativeTab(AdvancedBotany.tabAB); + this.setUnlocalizedName("itemAquaSword"); + this.setTextureName("ab:itemAquaSword"); + } + + public boolean isItemTool(ItemStack par1ItemStack) { + return true; + } + + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { + AxisAlignedBB axis = AxisAlignedBB.getBoundingBox( + entity.posX, + entity.posY, + entity.posZ, + entity.lastTickPosX, + entity.lastTickPosY, + entity.lastTickPosZ).expand(1.7f, 1.7f, 1.7f); + List entities = entity.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); + double posX = entity.posX; + double posY = entity.posY + entity.getEyeHeight(); + double posZ = entity.posZ; + if (!player.worldObj.isRemote) { + boolean hasWaterSplash = false; + for (EntityLivingBase living : entities) { + if (living instanceof EntityPlayer && (((EntityPlayer) living).getCommandSenderName() + .equals(player.getCommandSenderName()) + || (MinecraftServer.getServer() != null && !MinecraftServer.getServer().isPVPEnabled()))) + continue; + else if (ManaItemHandler.requestManaExactForTool(stack, player, 10, false) && living.attackEntityFrom( + DamageSource.causePlayerDamage(player), + AdvancedBotanyAPI.mithrilToolMaterial.getDamageVsEntity() / 2.0f)) { + ManaItemHandler.requestManaExactForTool(stack, player, 10, true); + if (!hasWaterSplash) hasWaterSplash = true; + Vec3 vec3 = player.getLook(1.0F).normalize(); + living.motionX += vec3.xCoord * 1.35f; + living.motionY += (vec3.yCoord / 1.8f); + living.motionZ += vec3.zCoord * 1.35f; + } + } + if (hasWaterSplash) player.worldObj.playSoundAtEntity(player, "ab:aquaSword", 1.2F, 1.2F); + } else { + if (ManaItemHandler.requestManaExactForTool(stack, player, 10, false)) { + for (int i = 0; i < 24; i++) { + float mtX = (float) ((Math.random() - 0.5f) * 0.12f); + float mtY = (float) ((Math.random() - 0.5f) * 0.12f); + float mtZ = (float) ((Math.random() - 0.5f) * 0.12f); + Botania.proxy.wispFX( + player.worldObj, + posX, + posY, + posZ, + 0.0f, + (float) (Math.random() * 0.35f), + 1.0f - (float) (Math.random() * 0.4f), + 0.17f + (float) (Math.random() * 0.3f), + mtX, + mtY, + mtZ, + 0.512f); + } + } + } + return super.onLeftClickEntity(stack, player, entity); + } + + public void onUsingTick(ItemStack stack, EntityPlayer p, int time) { + if (p.worldObj.isRemote) { + if (!ManaItemHandler.requestManaExactForTool(stack, p, 15, false)) return; + ClientSoundHandler.playSound(p, "liquid.water", 0.8F, 1.7F, 13, false); + time = (this.getMaxItemUseDuration(stack) - time) % 120 + 1; + if (time > 50) time = 120 - time; + float phase = time / 120.0f; + int wispCount = 8; + double tickIncrement = 360.0D / wispCount; + int speed = 10; + double wticks = (time * speed) - tickIncrement; + double r = Math.sin(1.4f); + for (int i = 0; i < wispCount; i++) { + double posX = p.posX + Math.sin(wticks * Math.PI / 180.0D) * r; + double posY = p.posY + (wticks * 0.001f) + 0.1f; + double posZ = p.posZ + Math.cos(wticks * Math.PI / 180.0D) * r; + Botania.proxy.wispFX( + p.worldObj, + posX, + posY, + posZ, + 0.0f, + (float) (Math.random() * 0.35f), + 1.0f - (float) (Math.random() * 0.4f), + 0.3F, + 0.0f, + -0.1f + (float) (Math.random() * 0.05f), + 0.0f, + 0.7F); + wticks += tickIncrement; + } + } else { + AxisAlignedBB axis = AxisAlignedBB + .getBoundingBox(p.posX, p.posY, p.posZ, p.lastTickPosX, p.lastTickPosY, p.lastTickPosZ) + .expand(2.75f, 2.75f, 2.75f); + List entities = p.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); + for (EntityLivingBase living : entities) { + if (living instanceof EntityPlayer && (((EntityPlayer) living).getCommandSenderName() + .equals(p.getCommandSenderName()) + || (MinecraftServer.getServer() != null && !MinecraftServer.getServer().isPVPEnabled()))) + continue; + double dist = living.getDistance(p.posX, p.posY, p.posZ) / 2.5f; + if (ManaItemHandler.requestManaExactForTool(stack, p, 15, false) + && living.attackEntityFrom(DamageSource.causePlayerDamage(p), 1.0f)) { + ManaItemHandler.requestManaExactForTool(stack, p, 15, true); + if (dist <= 1.0D) { + double d5 = living.posX - p.posX; + double d7 = living.posZ - p.posZ; + double d9 = (double) MathHelper.sqrt_double(d5 * d5 + d7 * d7); + if (d9 != 0.0D) { + d5 /= d9; + d7 /= d9; + living.motionX += d5 * 1.2f; + living.motionZ += d7 * 1.2f; + } + } + } + } + } + } +} diff --git a/src/main/java/ab/common/item/equipment/ItemBauble.java b/src/main/java/ab/common/item/equipment/ItemBauble.java index 8201bf3..2d32fe2 100644 --- a/src/main/java/ab/common/item/equipment/ItemBauble.java +++ b/src/main/java/ab/common/item/equipment/ItemBauble.java @@ -1,16 +1,8 @@ package ab.common.item.equipment; -import baubles.api.BaubleType; -import baubles.api.IBauble; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.Optional.Interface; -import cpw.mods.fml.common.Optional.Method; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; import java.util.UUID; -import ab.AdvancedBotany; + import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -21,154 +13,164 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.stats.StatBase; import net.minecraft.util.StatCollector; import net.minecraft.world.World; + import vazkii.botania.api.item.ICosmeticAttachable; import vazkii.botania.api.item.IPhantomInkable; import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.common.achievement.ModAchievements; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.entity.EntityDoppleganger; +import ab.AdvancedBotany; +import baubles.api.BaubleType; +import baubles.api.IBauble; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public abstract class ItemBauble extends Item implements IBauble, ICosmeticAttachable, IPhantomInkable { - - public ItemBauble(String name) { - this.setMaxStackSize(1); - this.setUnlocalizedName(name); - this.setTextureName("ab:" + name); - this.setCreativeTab(AdvancedBotany.tabAB); - } - - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if(!EntityDoppleganger.isTruePlayer((Entity)par3EntityPlayer)) - return par1ItemStack; - if(canEquip(par1ItemStack, (EntityLivingBase)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, (EntityLivingBase)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, (EntityLivingBase)par3EntityPlayer); - return stackInSlot.copy(); - } - break; - } - } - } - } - return par1ItemStack; - } - - @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 = 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"), new Object[] { cosmetic.getDisplayName() }), par3List); - if(hasPhantomInk(par1ItemStack)) - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.hasPhantomInk"), par3List); - } - - void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00A7")); - } - - public boolean canEquip(ItemStack stack, EntityLivingBase player) { - return true; - } - - public boolean canUnequip(ItemStack stack, EntityLivingBase player) { - return true; - } - - public void onWornTick(ItemStack stack, EntityLivingBase player) { - if(getLastPlayerHashcode(stack) != player.hashCode()) { - onEquippedOrLoadedIntoWorld(stack, player); - setLastPlayerHashcode(stack, player.hashCode()); - } - } - - public void onEquipped(ItemStack stack, EntityLivingBase player) { - if(player != null) { - if(!player.worldObj.isRemote) - player.worldObj.playSoundAtEntity((Entity)player, "botania:equipBauble", 0.1F, 1.3F); - if(player instanceof EntityPlayer) - ((EntityPlayer)player).addStat((StatBase)ModAchievements.baubleWear, 1); - onEquippedOrLoadedIntoWorld(stack, player); - setLastPlayerHashcode(stack, player.hashCode()); - } - } - - public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) {} - - public void onUnequipped(ItemStack stack, EntityLivingBase player) {} - - public ItemStack getCosmeticItem(ItemStack stack) { - NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, "cosmeticItem", true); - if(cmp == null) - return null; - return ItemStack.loadItemStackFromNBT(cmp); - } - - public void setCosmeticItem(ItemStack stack, ItemStack cosmetic) { - NBTTagCompound cmp = new NBTTagCompound(); - if(cosmetic != null) - cosmetic.writeToNBT(cmp); - ItemNBTHelper.setCompound(stack, "cosmeticItem", cmp); - } - - public boolean hasContainerItem(ItemStack stack) { - return (getContainerItem(stack) != null); - } - - public ItemStack getContainerItem(ItemStack itemStack) { - return getCosmeticItem(itemStack); - } - - public boolean doesContainerItemLeaveCraftingGrid(ItemStack p_77630_1_) { - return false; - } - - public static UUID getBaubleUUID(ItemStack stack) { - long most = ItemNBTHelper.getLong(stack, "baubleUUIDMost", 0L); - if(most == 0L) { - UUID uuid = UUID.randomUUID(); - ItemNBTHelper.setLong(stack, "baubleUUIDMost", uuid.getMostSignificantBits()); - ItemNBTHelper.setLong(stack, "baubleUUIDLeast", uuid.getLeastSignificantBits()); - return getBaubleUUID(stack); - } - long least = ItemNBTHelper.getLong(stack, "baubleUUIDLeast", 0L); - return new UUID(most, least); - } - - public static int getLastPlayerHashcode(ItemStack stack) { - return ItemNBTHelper.getInt(stack, "playerHashcode", 0); - } - - public static void setLastPlayerHashcode(ItemStack stack, int hash) { - ItemNBTHelper.setInt(stack, "playerHashcode", hash); - } - - public boolean hasPhantomInk(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, "phantomInk", false); - } - - public void setPhantomInk(ItemStack stack, boolean ink) { - ItemNBTHelper.setBoolean(stack, "phantomInk", ink); - } -} \ No newline at end of file + + public ItemBauble(String name) { + this.setMaxStackSize(1); + this.setUnlocalizedName(name); + this.setTextureName("ab:" + name); + this.setCreativeTab(AdvancedBotany.tabAB); + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if (!EntityDoppleganger.isTruePlayer((Entity) par3EntityPlayer)) return par1ItemStack; + if (canEquip(par1ItemStack, (EntityLivingBase) 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, (EntityLivingBase) 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, (EntityLivingBase) par3EntityPlayer); + return stackInSlot.copy(); + } + break; + } + } + } + } + return par1ItemStack; + } + + @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 = 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"), + new Object[] { cosmetic.getDisplayName() }), + par3List); + if (hasPhantomInk(par1ItemStack)) + addStringToTooltip(StatCollector.translateToLocal("botaniamisc.hasPhantomInk"), par3List); + } + + void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00A7")); + } + + public boolean canEquip(ItemStack stack, EntityLivingBase player) { + return true; + } + + public boolean canUnequip(ItemStack stack, EntityLivingBase player) { + return true; + } + + public void onWornTick(ItemStack stack, EntityLivingBase player) { + if (getLastPlayerHashcode(stack) != player.hashCode()) { + onEquippedOrLoadedIntoWorld(stack, player); + setLastPlayerHashcode(stack, player.hashCode()); + } + } + + public void onEquipped(ItemStack stack, EntityLivingBase player) { + if (player != null) { + if (!player.worldObj.isRemote) + player.worldObj.playSoundAtEntity((Entity) player, "botania:equipBauble", 0.1F, 1.3F); + if (player instanceof EntityPlayer) + ((EntityPlayer) player).addStat((StatBase) ModAchievements.baubleWear, 1); + onEquippedOrLoadedIntoWorld(stack, player); + setLastPlayerHashcode(stack, player.hashCode()); + } + } + + public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) {} + + public void onUnequipped(ItemStack stack, EntityLivingBase player) {} + + public ItemStack getCosmeticItem(ItemStack stack) { + NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, "cosmeticItem", true); + if (cmp == null) return null; + return ItemStack.loadItemStackFromNBT(cmp); + } + + public void setCosmeticItem(ItemStack stack, ItemStack cosmetic) { + NBTTagCompound cmp = new NBTTagCompound(); + if (cosmetic != null) cosmetic.writeToNBT(cmp); + ItemNBTHelper.setCompound(stack, "cosmeticItem", cmp); + } + + public boolean hasContainerItem(ItemStack stack) { + return (getContainerItem(stack) != null); + } + + public ItemStack getContainerItem(ItemStack itemStack) { + return getCosmeticItem(itemStack); + } + + public boolean doesContainerItemLeaveCraftingGrid(ItemStack p_77630_1_) { + return false; + } + + public static UUID getBaubleUUID(ItemStack stack) { + long most = ItemNBTHelper.getLong(stack, "baubleUUIDMost", 0L); + if (most == 0L) { + UUID uuid = UUID.randomUUID(); + ItemNBTHelper.setLong(stack, "baubleUUIDMost", uuid.getMostSignificantBits()); + ItemNBTHelper.setLong(stack, "baubleUUIDLeast", uuid.getLeastSignificantBits()); + return getBaubleUUID(stack); + } + long least = ItemNBTHelper.getLong(stack, "baubleUUIDLeast", 0L); + return new UUID(most, least); + } + + public static int getLastPlayerHashcode(ItemStack stack) { + return ItemNBTHelper.getInt(stack, "playerHashcode", 0); + } + + public static void setLastPlayerHashcode(ItemStack stack, int hash) { + ItemNBTHelper.setInt(stack, "playerHashcode", hash); + } + + public boolean hasPhantomInk(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, "phantomInk", false); + } + + public void setPhantomInk(ItemStack stack, boolean ink) { + ItemNBTHelper.setBoolean(stack, "phantomInk", ink); + } +} diff --git a/src/main/java/ab/common/item/equipment/ItemBlackHalo.java b/src/main/java/ab/common/item/equipment/ItemBlackHalo.java index 0be0997..cf09980 100644 --- a/src/main/java/ab/common/item/equipment/ItemBlackHalo.java +++ b/src/main/java/ab/common/item/equipment/ItemBlackHalo.java @@ -1,20 +1,10 @@ package ab.common.item.equipment; -import java.awt.Color; - -import org.lwjgl.opengl.GL11; - -import ab.AdvancedBotany; -import ab.common.item.ItemMod; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -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.entity.EntityClientPlayerMP; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; @@ -31,328 +21,339 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.common.MinecraftForge; + +import org.lwjgl.opengl.GL11; + import vazkii.botania.api.item.IBlockProvider; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.common.core.helper.InventoryHelper; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.item.ItemBlackHoleTalisman; +import ab.common.item.ItemMod; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemBlackHalo extends ItemMod implements IBlockProvider { - - public static final ResourceLocation glowTexture = new ResourceLocation("ab:textures/misc/glow.png"); - public ItemBlackHalo() { - super("blackHalo"); - this.setMaxStackSize(1); - MinecraftForge.EVENT_BUS.register(this); - } - - public ItemStack onItemRightClick(ItemStack halo, World world, EntityPlayer player) { - int segment = getSegmentLookedAt(halo, player); - if(this.getItemForSlot(halo, segment) != null) { - ItemStack stack = this.getItemForSlot(halo, segment).copy(); - if(player.isSneaking()) { - if(!player.inventory.addItemStackToInventory(stack)) - player.dropPlayerItemWithRandomChoice(stack, false); - this.setItemSlot(halo, null, segment); - return halo; - } - stack.setItemDamage(stack.getItemDamage() == 0 ? 1 : 0); - if(!world.isRemote) - world.playSoundAtEntity(player, "random.orb", 0.3F, 0.1F); - this.setItemSlot(halo, stack, segment); - return halo; - } - for(int i = 0; i < 9; i++) { - ItemStack stack = player.inventory.getStackInSlot(i); - if(stack != null && stack.getItem() instanceof ItemBlackHoleTalisman) { - boolean hasBlock = !Block.isEqualTo(((ItemBlackHoleTalisman)stack.getItem()).getBlock(stack), Blocks.air) && ((ItemBlackHoleTalisman)stack.getItem()).getBlock(stack) != null; - if(hasBlock) { - if(this.getItemForSlot(halo, segment) != null) - return halo; - this.setItemSlot(halo, stack, segment); - if(player.inventory.getStackInSlot(i).stackSize > 1) - player.inventory.getStackInSlot(i).stackSize =- 1; - else - player.inventory.setInventorySlotContents(i, null); - return halo; - } - } - } - return halo; - } - - public void onUpdate(ItemStack halo, World world, Entity entity, int pos, boolean equipped) { - boolean eqLastTick = wasEquipped(halo); - if(!equipped && eqLastTick) - setEquipped(halo, equipped); - if (!eqLastTick && equipped && entity instanceof EntityLivingBase) { - setEquipped(halo, equipped); - int angles = 360; - int segAngles = angles / 12; - float shift = (segAngles / 2); - setRotationBase(halo, getCheckingAngle((EntityLivingBase)entity) - shift); - } - if(world.isRemote) - return; - else if(!(entity.ticksExisted % 10 == 0)) - return; - for(int i = 0; i < 12; i++) { - ItemStack stack = this.getItemForSlot(halo, i); - if(stack != null) { - ((ItemBlackHoleTalisman)stack.getItem()).onUpdate(stack, world, entity, pos, equipped); - } - } - } - - public boolean onItemUse(ItemStack halo, EntityPlayer player, World world, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { - for(int i = 0; i < 12; i++) { - ItemStack tal = this.getItemForSlot(halo, i); - if(tal == null) - continue; - ItemBlackHoleTalisman talisman = (ItemBlackHoleTalisman)tal.getItem(); - Block bBlock = talisman.getBlock(tal); - int bmeta = talisman.getBlockMeta(tal); - TileEntity tile = world.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 = talisman.remove(tal, maxSize); - if (stack.stackSize != 0 && inv.isItemValidForSlot(slot, stack) && (!(inv instanceof ISidedInventory) || ((ISidedInventory)inv).canInsertItem(slot, stack, par7))) { - inv.setInventorySlotContents(slot, stack); - inv.markDirty(); - } - } 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 += talisman.remove(tal, missing); - inv.markDirty(); - } - } - } - } - } - return true; - } - - public void setItemSlot(ItemStack halo, ItemStack stack, int slot) { - NBTTagCompound cmp = new NBTTagCompound(); - if(stack != null) - stack.copy().writeToNBT(cmp); - ItemNBTHelper.setCompound(halo, "itemSlot" + slot, cmp); - } - - public static ItemStack getItemForSlot(ItemStack halo, int slot) { - if(slot >= 12) - return null; - NBTTagCompound cmp = ItemNBTHelper.getCompound(halo, "itemSlot" + slot, true); - if(cmp != null) - return ItemStack.loadItemStackFromNBT(cmp); - return null; - } - - @SideOnly(Side.CLIENT) - public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack halo) { - Minecraft mc = Minecraft.getMinecraft(); - int slot = getSegmentLookedAt(halo, (EntityLivingBase)player); - GL11.glEnable(3042); - GL11.glBlendFunc(770, 771); - ItemStack stack = getItemForSlot(halo, slot); - if(stack != null) { - String name = stack.getDisplayName(); - String count = "" + ((ItemBlackHoleTalisman)stack.getItem()).getBlockCount(stack); - 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 + 43, 570425344); - Gui.drawRect(x - 4, y - 4, x + l + 4, y + 41, 570425344); - RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(32826); - RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, resolution.getScaledWidth() / 2 - 8, resolution.getScaledHeight() / 2 - 52); - RenderHelper.disableStandardItemLighting(); - mc.fontRenderer.drawStringWithShadow(name, x, y, 16777215); - mc.fontRenderer.drawStringWithShadow(count, resolution.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(count) / 2, y + 32, 16777215); - } - } - - @SideOnly(Side.CLIENT) - @SubscribeEvent - public void onRenderWorldLast(RenderWorldLastEvent event) { - EntityClientPlayerMP entityClientPlayerMP = (Minecraft.getMinecraft()).thePlayer; - ItemStack stack = entityClientPlayerMP.getCurrentEquippedItem(); - if (stack != null && stack.getItem() instanceof ItemBlackHalo) - render(stack, (EntityPlayer)entityClientPlayerMP, 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(3042); - GL11.glBlendFunc(770, 771); - 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 / 12; - float shift = base - (segAngles / 2); - float u = 1.0F; - float v = 0.25F; - float s = 3.0F; - float m = 0.8F; - float y = v * s * 2.0F; - float y0 = 0.0F; - int segmentLookedAt = getSegmentLookedAt(stack, (EntityLivingBase)player); - for (int seg = 0; seg < 12; seg++) { - boolean inside = false; - float rotationAngle = (seg + 0.5F) * segAngles + shift; - GL11.glPushMatrix(); - GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F); - double worldTime = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks + seg * 2.75f; - GL11.glTranslated(s * m, -0.75F + Math.sin(worldTime / 12.0D) / 30.0D, 0.0F); - if (segmentLookedAt == seg) - inside = true; - ItemStack slotStack = getItemForSlot(stack, seg); - if (slotStack != null) { - ItemBlackHoleTalisman talisman = (ItemBlackHoleTalisman)slotStack.getItem(); - mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); - float scale = 0.6F; - GL11.glScalef(scale, scale, scale); - GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(0.0F, 0.6F, 0.0F); - RenderBlocks.getInstance().renderBlockAsItem(talisman.getBlock(slotStack), talisman.getBlockMeta(slotStack), 1.0F); - } - GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.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(1.0F, 1.0F, 1.0F, a); - } - GL11.glDisable(2884); - 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 / 180.0D) * s; - double zp = Math.sin(ang * Math.PI / 180.0D) * s; - tess.addVertexWithUV(xp * m, y, zp * m, u, v); - tess.addVertexWithUV(xp, y0, zp, u, 0.0D); - xp = Math.cos((ang + 1.0F) * Math.PI / 180.0D) * s; - zp = Math.sin((ang + 1.0F) * Math.PI / 180.0D) * s; - tess.addVertexWithUV(xp, y0, zp, 0.0D, 0.0D); - tess.addVertexWithUV(xp * m, y, zp * m, 0.0D, v); - } - y0 = 0.0F; - tess.draw(); - GL11.glEnable(2884); - GL11.glPopMatrix(); - } - GL11.glPopMatrix(); - } - - private static int getSegmentLookedAt(ItemStack stack, EntityLivingBase player) { - getRotationBase(stack); - float yaw = getCheckingAngle(player, getRotationBase(stack)); - int angles = 360; - int segAngles = angles / 12; - for (int seg = 0; seg < 12; seg++) { - float calcAngle = seg * segAngles; - if (yaw >= calcAngle && yaw < calcAngle + segAngles) - return seg; - } - return -1; - } - - public static void setRotationBase(ItemStack stack, float rotation) { - ItemNBTHelper.setFloat(stack, "rotationBase", rotation); - } - - public static float getRotationBase(ItemStack stack) { - return ItemNBTHelper.getFloat(stack, "rotationBase", 0.0F); - } - - private static float getCheckingAngle(EntityLivingBase player, float base) { - float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw) + 90.0F; - int angles = 360; - int segAngles = angles / 12; - float shift = (segAngles / 2); - if (yaw < 0.0F) - yaw = 180.0F + 180.0F + yaw; - yaw -= 360.0F - base; - float angle = 360.0F - yaw + shift; - if (angle < 0.0F) - angle = 360.0F + angle; - return angle; - } - - private static float getCheckingAngle(EntityLivingBase player) { - return getCheckingAngle(player, 0.0F); - } - - public static void setEquipped(ItemStack stack, boolean equipped) { - ItemNBTHelper.setBoolean(stack, "equipped", equipped); - } - - public static boolean wasEquipped(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, "equipped", false); - } - - public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack halo, Block block, int meta, boolean doit) { - for(int i = 0; i < 12; i++) { - ItemStack tal = getItemForSlot(halo, i); - if(tal == null) - continue; - ItemBlackHoleTalisman talisman = (ItemBlackHoleTalisman)tal.getItem(); - Block stored = talisman.getBlock(tal); - int storedMeta = talisman.getBlockMeta(tal); - if (stored == block && storedMeta == meta) { - int count = talisman.getBlockCount(tal); - if (count > 0) { - if (doit) - ItemNBTHelper.setInt(tal, "blockCount", count - 1); - return true; - } - } - } - return false; - } - - public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack halo, Block block, int meta) { - for(int i = 0; i < 12; i++) { - ItemStack tal = getItemForSlot(halo, i); - if(tal == null) - continue; - ItemBlackHoleTalisman talisman = (ItemBlackHoleTalisman)tal.getItem(); - Block stored = talisman.getBlock(tal); - int storedMeta = talisman.getBlockMeta(tal); - if (stored == block && storedMeta == meta) - return talisman.getBlockCount(tal); - } - return 0; - } -} \ No newline at end of file + public static final ResourceLocation glowTexture = new ResourceLocation("ab:textures/misc/glow.png"); + + public ItemBlackHalo() { + super("blackHalo"); + this.setMaxStackSize(1); + MinecraftForge.EVENT_BUS.register(this); + } + + public ItemStack onItemRightClick(ItemStack halo, World world, EntityPlayer player) { + int segment = getSegmentLookedAt(halo, player); + if (this.getItemForSlot(halo, segment) != null) { + ItemStack stack = this.getItemForSlot(halo, segment).copy(); + if (player.isSneaking()) { + if (!player.inventory.addItemStackToInventory(stack)) + player.dropPlayerItemWithRandomChoice(stack, false); + this.setItemSlot(halo, null, segment); + return halo; + } + stack.setItemDamage(stack.getItemDamage() == 0 ? 1 : 0); + if (!world.isRemote) world.playSoundAtEntity(player, "random.orb", 0.3F, 0.1F); + this.setItemSlot(halo, stack, segment); + return halo; + } + for (int i = 0; i < 9; i++) { + ItemStack stack = player.inventory.getStackInSlot(i); + if (stack != null && stack.getItem() instanceof ItemBlackHoleTalisman) { + boolean hasBlock = !Block + .isEqualTo(((ItemBlackHoleTalisman) stack.getItem()).getBlock(stack), Blocks.air) + && ((ItemBlackHoleTalisman) stack.getItem()).getBlock(stack) != null; + if (hasBlock) { + if (this.getItemForSlot(halo, segment) != null) return halo; + this.setItemSlot(halo, stack, segment); + if (player.inventory.getStackInSlot(i).stackSize > 1) + player.inventory.getStackInSlot(i).stackSize = -1; + else player.inventory.setInventorySlotContents(i, null); + return halo; + } + } + } + return halo; + } + + public void onUpdate(ItemStack halo, World world, Entity entity, int pos, boolean equipped) { + boolean eqLastTick = wasEquipped(halo); + if (!equipped && eqLastTick) setEquipped(halo, equipped); + if (!eqLastTick && equipped && entity instanceof EntityLivingBase) { + setEquipped(halo, equipped); + int angles = 360; + int segAngles = angles / 12; + float shift = (segAngles / 2); + setRotationBase(halo, getCheckingAngle((EntityLivingBase) entity) - shift); + } + if (world.isRemote) return; + else if (!(entity.ticksExisted % 10 == 0)) return; + for (int i = 0; i < 12; i++) { + ItemStack stack = this.getItemForSlot(halo, i); + if (stack != null) { + ((ItemBlackHoleTalisman) stack.getItem()).onUpdate(stack, world, entity, pos, equipped); + } + } + } + + public boolean onItemUse(ItemStack halo, EntityPlayer player, World world, int par4, int par5, int par6, int par7, + float par8, float par9, float par10) { + for (int i = 0; i < 12; i++) { + ItemStack tal = this.getItemForSlot(halo, i); + if (tal == null) continue; + ItemBlackHoleTalisman talisman = (ItemBlackHoleTalisman) tal.getItem(); + Block bBlock = talisman.getBlock(tal); + int bmeta = talisman.getBlockMeta(tal); + TileEntity tile = world.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 = talisman.remove(tal, maxSize); + if (stack.stackSize != 0 && inv.isItemValidForSlot(slot, stack) + && (!(inv instanceof ISidedInventory) + || ((ISidedInventory) inv).canInsertItem(slot, stack, par7))) { + inv.setInventorySlotContents(slot, stack); + inv.markDirty(); + } + } 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 += talisman.remove(tal, missing); + inv.markDirty(); + } + } + } + } + } + return true; + } + + public void setItemSlot(ItemStack halo, ItemStack stack, int slot) { + NBTTagCompound cmp = new NBTTagCompound(); + if (stack != null) stack.copy().writeToNBT(cmp); + ItemNBTHelper.setCompound(halo, "itemSlot" + slot, cmp); + } + + public static ItemStack getItemForSlot(ItemStack halo, int slot) { + if (slot >= 12) return null; + NBTTagCompound cmp = ItemNBTHelper.getCompound(halo, "itemSlot" + slot, true); + if (cmp != null) return ItemStack.loadItemStackFromNBT(cmp); + return null; + } + + @SideOnly(Side.CLIENT) + public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack halo) { + Minecraft mc = Minecraft.getMinecraft(); + int slot = getSegmentLookedAt(halo, (EntityLivingBase) player); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + ItemStack stack = getItemForSlot(halo, slot); + if (stack != null) { + String name = stack.getDisplayName(); + String count = "" + ((ItemBlackHoleTalisman) stack.getItem()).getBlockCount(stack); + 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 + 43, 570425344); + Gui.drawRect(x - 4, y - 4, x + l + 4, y + 41, 570425344); + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(32826); + RenderItem.getInstance().renderItemAndEffectIntoGUI( + mc.fontRenderer, + mc.renderEngine, + stack, + resolution.getScaledWidth() / 2 - 8, + resolution.getScaledHeight() / 2 - 52); + RenderHelper.disableStandardItemLighting(); + mc.fontRenderer.drawStringWithShadow(name, x, y, 16777215); + mc.fontRenderer.drawStringWithShadow( + count, + resolution.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(count) / 2, + y + 32, + 16777215); + } + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onRenderWorldLast(RenderWorldLastEvent event) { + EntityClientPlayerMP entityClientPlayerMP = (Minecraft.getMinecraft()).thePlayer; + ItemStack stack = entityClientPlayerMP.getCurrentEquippedItem(); + if (stack != null && stack.getItem() instanceof ItemBlackHalo) + render(stack, (EntityPlayer) entityClientPlayerMP, 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(3042); + GL11.glBlendFunc(770, 771); + 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 / 12; + float shift = base - (segAngles / 2); + float u = 1.0F; + float v = 0.25F; + float s = 3.0F; + float m = 0.8F; + float y = v * s * 2.0F; + float y0 = 0.0F; + int segmentLookedAt = getSegmentLookedAt(stack, (EntityLivingBase) player); + for (int seg = 0; seg < 12; seg++) { + boolean inside = false; + float rotationAngle = (seg + 0.5F) * segAngles + shift; + GL11.glPushMatrix(); + GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F); + double worldTime = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks + seg * 2.75f; + GL11.glTranslated(s * m, -0.75F + Math.sin(worldTime / 12.0D) / 30.0D, 0.0F); + if (segmentLookedAt == seg) inside = true; + ItemStack slotStack = getItemForSlot(stack, seg); + if (slotStack != null) { + ItemBlackHoleTalisman talisman = (ItemBlackHoleTalisman) slotStack.getItem(); + mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + float scale = 0.6F; + GL11.glScalef(scale, scale, scale); + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.6F, 0.0F); + RenderBlocks.getInstance() + .renderBlockAsItem(talisman.getBlock(slotStack), talisman.getBlockMeta(slotStack), 1.0F); + } + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.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(1.0F, 1.0F, 1.0F, a); + } + GL11.glDisable(2884); + 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 / 180.0D) * s; + double zp = Math.sin(ang * Math.PI / 180.0D) * s; + tess.addVertexWithUV(xp * m, y, zp * m, u, v); + tess.addVertexWithUV(xp, y0, zp, u, 0.0D); + xp = Math.cos((ang + 1.0F) * Math.PI / 180.0D) * s; + zp = Math.sin((ang + 1.0F) * Math.PI / 180.0D) * s; + tess.addVertexWithUV(xp, y0, zp, 0.0D, 0.0D); + tess.addVertexWithUV(xp * m, y, zp * m, 0.0D, v); + } + y0 = 0.0F; + tess.draw(); + GL11.glEnable(2884); + GL11.glPopMatrix(); + } + GL11.glPopMatrix(); + } + + private static int getSegmentLookedAt(ItemStack stack, EntityLivingBase player) { + getRotationBase(stack); + float yaw = getCheckingAngle(player, getRotationBase(stack)); + int angles = 360; + int segAngles = angles / 12; + for (int seg = 0; seg < 12; seg++) { + float calcAngle = seg * segAngles; + if (yaw >= calcAngle && yaw < calcAngle + segAngles) return seg; + } + return -1; + } + + public static void setRotationBase(ItemStack stack, float rotation) { + ItemNBTHelper.setFloat(stack, "rotationBase", rotation); + } + + public static float getRotationBase(ItemStack stack) { + return ItemNBTHelper.getFloat(stack, "rotationBase", 0.0F); + } + + private static float getCheckingAngle(EntityLivingBase player, float base) { + float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw) + 90.0F; + int angles = 360; + int segAngles = angles / 12; + float shift = (segAngles / 2); + if (yaw < 0.0F) yaw = 180.0F + 180.0F + yaw; + yaw -= 360.0F - base; + float angle = 360.0F - yaw + shift; + if (angle < 0.0F) angle = 360.0F + angle; + return angle; + } + + private static float getCheckingAngle(EntityLivingBase player) { + return getCheckingAngle(player, 0.0F); + } + + public static void setEquipped(ItemStack stack, boolean equipped) { + ItemNBTHelper.setBoolean(stack, "equipped", equipped); + } + + public static boolean wasEquipped(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, "equipped", false); + } + + public boolean provideBlock(EntityPlayer player, ItemStack requestor, ItemStack halo, Block block, int meta, + boolean doit) { + for (int i = 0; i < 12; i++) { + ItemStack tal = getItemForSlot(halo, i); + if (tal == null) continue; + ItemBlackHoleTalisman talisman = (ItemBlackHoleTalisman) tal.getItem(); + Block stored = talisman.getBlock(tal); + int storedMeta = talisman.getBlockMeta(tal); + if (stored == block && storedMeta == meta) { + int count = talisman.getBlockCount(tal); + if (count > 0) { + if (doit) ItemNBTHelper.setInt(tal, "blockCount", count - 1); + return true; + } + } + } + return false; + } + + public int getBlockCount(EntityPlayer player, ItemStack requestor, ItemStack halo, Block block, int meta) { + for (int i = 0; i < 12; i++) { + ItemStack tal = getItemForSlot(halo, i); + if (tal == null) continue; + ItemBlackHoleTalisman talisman = (ItemBlackHoleTalisman) tal.getItem(); + Block stored = talisman.getBlock(tal); + int storedMeta = talisman.getBlockMeta(tal); + if (stored == block && storedMeta == meta) return talisman.getBlockCount(tal); + } + return 0; + } +} diff --git a/src/main/java/ab/common/item/equipment/ItemManaFlower.java b/src/main/java/ab/common/item/equipment/ItemManaFlower.java index ccf2452..e08e309 100644 --- a/src/main/java/ab/common/item/equipment/ItemManaFlower.java +++ b/src/main/java/ab/common/item/equipment/ItemManaFlower.java @@ -1,30 +1,29 @@ package ab.common.item.equipment; -import ab.AdvancedBotany; -import ab.api.AdvancedBotanyAPI; -import baubles.api.BaubleType; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; + import vazkii.botania.api.mana.IManaGivingItem; import vazkii.botania.api.mana.ManaItemHandler; +import ab.AdvancedBotany; +import baubles.api.BaubleType; public class ItemManaFlower extends ItemBauble implements IManaGivingItem { - - public ItemManaFlower() { - super("manaFlower"); - this.setCreativeTab(AdvancedBotany.tabAB); - this.setNoRepair(); - } - - public void onWornTick(ItemStack stack, EntityLivingBase player) { - super.onWornTick(stack, player); - if (player instanceof EntityPlayer && player.ticksExisted % 5 == 0) - ManaItemHandler.dispatchManaExact(stack, (EntityPlayer)player, 54, true); - } - - public BaubleType getBaubleType(ItemStack stack) { - return BaubleType.BELT; - } + + public ItemManaFlower() { + super("manaFlower"); + this.setCreativeTab(AdvancedBotany.tabAB); + this.setNoRepair(); + } + + public void onWornTick(ItemStack stack, EntityLivingBase player) { + super.onWornTick(stack, player); + if (player instanceof EntityPlayer && player.ticksExisted % 5 == 0) + ManaItemHandler.dispatchManaExact(stack, (EntityPlayer) player, 54, true); + } + + public BaubleType getBaubleType(ItemStack stack) { + return BaubleType.BELT; + } } diff --git a/src/main/java/ab/common/item/equipment/ItemMithrillMultiTool.java b/src/main/java/ab/common/item/equipment/ItemMithrillMultiTool.java index 083f79f..ae8fb65 100644 --- a/src/main/java/ab/common/item/equipment/ItemMithrillMultiTool.java +++ b/src/main/java/ab/common/item/equipment/ItemMithrillMultiTool.java @@ -1,11 +1,5 @@ package ab.common.item.equipment; -import java.util.Set; - -import ab.AdvancedBotany; -import ab.api.AdvancedBotanyAPI; -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; @@ -15,70 +9,72 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.ItemTool; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeHooks; + import vazkii.botania.common.core.helper.ItemNBTHelper; +import ab.AdvancedBotany; +import ab.api.AdvancedBotanyAPI; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemMithrillMultiTool extends ItemTool { - - IIcon iconTool; - IIcon iconOverlay; - public ItemMithrillMultiTool() { - super(0.0f, AdvancedBotanyAPI.mithrilToolMaterial, null); - this.setCreativeTab(AdvancedBotany.tabAB); - this.setUnlocalizedName("mithrillMultiTool"); - } - - public boolean isItemTool(ItemStack par1ItemStack) { - return true; - } - - public boolean canHarvestBlock(Block block, ItemStack stack) { - return (block != Blocks.bedrock); - } - - public boolean func_150897_b(Block block) { - return true; - } - - public float getDigSpeed(ItemStack stack, Block block, int meta) { - if(this.isEnabled(stack)) - return super.getDigSpeed(stack, block, meta) + 135.0f; - else - return 0.0f; + IIcon iconTool; + IIcon iconOverlay; + + public ItemMithrillMultiTool() { + super(0.0f, AdvancedBotanyAPI.mithrilToolMaterial, null); + this.setCreativeTab(AdvancedBotany.tabAB); + this.setUnlocalizedName("mithrillMultiTool"); + } + + public boolean isItemTool(ItemStack par1ItemStack) { + return true; + } + + public boolean canHarvestBlock(Block block, ItemStack stack) { + return (block != Blocks.bedrock); + } + + public boolean func_150897_b(Block block) { + return true; + } + + public float getDigSpeed(ItemStack stack, Block block, int meta) { + if (this.isEnabled(stack)) return super.getDigSpeed(stack, block, meta) + 135.0f; + else return 0.0f; + } + + public float func_150893_a(ItemStack stack, Block block) { + return 135.0f; + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + setEnabled(par1ItemStack, !isEnabled(par1ItemStack)); + if (!par2World.isRemote) + par2World.playSoundAtEntity((Entity) par3EntityPlayer, "botania:terraPickMode", 0.5F, 0.4F); + return par1ItemStack; + } + + public boolean requiresMultipleRenderPasses() { + return true; + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister ir) { + this.iconTool = ir.registerIcon("ab:item.mithrillMultiTool"); + this.iconOverlay = ir.registerIcon("ab:item.mithrillMultiTool.overlay"); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int pass) { + return pass == 1 ? (isEnabled(stack) ? iconOverlay : iconTool) : iconTool; + } + + boolean isEnabled(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, "enabled", false); + } + + void setEnabled(ItemStack stack, boolean enabled) { + ItemNBTHelper.setBoolean(stack, "enabled", enabled); } - - public float func_150893_a(ItemStack stack, Block block) { - return 135.0f; - } - - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - setEnabled(par1ItemStack, !isEnabled(par1ItemStack)); - if (!par2World.isRemote) - par2World.playSoundAtEntity((Entity)par3EntityPlayer, "botania:terraPickMode", 0.5F, 0.4F); - return par1ItemStack; - } - - public boolean requiresMultipleRenderPasses() { - return true; - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister ir) { - this.iconTool = ir.registerIcon("ab:item.mithrillMultiTool"); - this.iconOverlay = ir.registerIcon("ab:item.mithrillMultiTool.overlay"); - } - - @SideOnly(Side.CLIENT) - public IIcon getIcon(ItemStack stack, int pass) { - return pass == 1 ? (isEnabled(stack) ? iconOverlay : iconTool) : iconTool; - } - - boolean isEnabled(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, "enabled", false); - } - - void setEnabled(ItemStack stack, boolean enabled) { - ItemNBTHelper.setBoolean(stack, "enabled", enabled); - } } diff --git a/src/main/java/ab/common/item/equipment/ItemMithrillRing.java b/src/main/java/ab/common/item/equipment/ItemMithrillRing.java index 9eb9f8d..55d8f65 100644 --- a/src/main/java/ab/common/item/equipment/ItemMithrillRing.java +++ b/src/main/java/ab/common/item/equipment/ItemMithrillRing.java @@ -2,83 +2,84 @@ package ab.common.item.equipment; import java.util.List; -import baubles.api.BaubleType; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + import vazkii.botania.api.mana.IManaItem; import vazkii.botania.api.mana.IManaTooltipDisplay; import vazkii.botania.common.core.helper.ItemNBTHelper; +import baubles.api.BaubleType; public class ItemMithrillRing extends ItemBauble implements IManaItem, IManaTooltipDisplay { - public ItemMithrillRing(String name) { - super(name); - this.setMaxDamage(1000); - this.setNoRepair(); - } - - public BaubleType getBaubleType(ItemStack stack) { - return BaubleType.RING; - } + public ItemMithrillRing(String name) { + super(name); + this.setMaxDamage(1000); + this.setNoRepair(); + } - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - par3List.add(new ItemStack(par1, 1, 10000)); - } - - public int getDamage(ItemStack stack) { - float mana = getMana(stack); - return 1000 - (int)(mana / getMaxMana(stack) * 1000.0F); - } - - public int getDisplayDamage(ItemStack stack) { - return getDamage(stack); - } - - public int getEntityLifespan(ItemStack itemStack, World world) { - return Integer.MAX_VALUE; - } - - public static void setMana(ItemStack stack, int mana) { - ItemNBTHelper.setInt(stack, "mana", mana); - } - - public int getMana(ItemStack stack) { - return ItemNBTHelper.getInt(stack, "mana", 0); - } - - public int getMaxMana(ItemStack stack) { - return 8000000; - } - - public void addMana(ItemStack stack, int mana) { - setMana(stack, Math.min(getMana(stack) + mana, getMaxMana(stack))); - stack.setItemDamage(getDamage(stack)); - } - - public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { - return true; - } - - public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { - return true; - } - - public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { - return true; - } - - public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { - return true; - } - - public boolean isNoExport(ItemStack stack) { - return false; - } - - public float getManaFractionForDisplay(ItemStack stack) { - return getMana(stack) / getMaxMana(stack); - } + public BaubleType getBaubleType(ItemStack stack) { + return BaubleType.RING; + } + + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + par3List.add(new ItemStack(par1, 1, 10000)); + } + + public int getDamage(ItemStack stack) { + float mana = getMana(stack); + return 1000 - (int) (mana / getMaxMana(stack) * 1000.0F); + } + + public int getDisplayDamage(ItemStack stack) { + return getDamage(stack); + } + + public int getEntityLifespan(ItemStack itemStack, World world) { + return Integer.MAX_VALUE; + } + + public static void setMana(ItemStack stack, int mana) { + ItemNBTHelper.setInt(stack, "mana", mana); + } + + public int getMana(ItemStack stack) { + return ItemNBTHelper.getInt(stack, "mana", 0); + } + + public int getMaxMana(ItemStack stack) { + return 8000000; + } + + public void addMana(ItemStack stack, int mana) { + setMana(stack, Math.min(getMana(stack) + mana, getMaxMana(stack))); + stack.setItemDamage(getDamage(stack)); + } + + public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool) { + return true; + } + + public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { + return true; + } + + public boolean canExportManaToPool(ItemStack stack, TileEntity pool) { + return true; + } + + public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack) { + return true; + } + + public boolean isNoExport(ItemStack stack) { + return false; + } + + public float getManaFractionForDisplay(ItemStack stack) { + return getMana(stack) / getMaxMana(stack); + } } diff --git a/src/main/java/ab/common/item/equipment/ItemNebulaBlaze.java b/src/main/java/ab/common/item/equipment/ItemNebulaBlaze.java index 90fd2e8..9937192 100644 --- a/src/main/java/ab/common/item/equipment/ItemNebulaBlaze.java +++ b/src/main/java/ab/common/item/equipment/ItemNebulaBlaze.java @@ -1,49 +1,47 @@ package ab.common.item.equipment; -import ab.api.AdvancedBotanyAPI; -import ab.common.entity.EntityNebulaBlaze; -import ab.common.item.ItemMod; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.world.World; + import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; +import ab.api.AdvancedBotanyAPI; +import ab.common.entity.EntityNebulaBlaze; +import ab.common.item.ItemMod; public class ItemNebulaBlaze extends ItemMod implements IManaUsingItem { - public ItemNebulaBlaze() { - super("nebulaBlaze"); - this.setMaxStackSize(1); - } - - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); - return stack; - } - - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { - if(player.worldObj.isRemote) - return; - else if(count % 5 == 2 && ManaItemHandler.requestManaExactForTool(stack, player, 125, true)) { - EntityNebulaBlaze blaze = new EntityNebulaBlaze(player.worldObj, player); - blaze.setAttacker(player.getCommandSenderName()); - player.worldObj.spawnEntityInWorld(blaze); - player.worldObj.playSoundAtEntity(player, "ab:nebulaBlaze", 0.4F, 1.4F); - } - } - - public EnumRarity getRarity(ItemStack stack) { - return AdvancedBotanyAPI.rarityNebula; - } - + public ItemNebulaBlaze() { + super("nebulaBlaze"); + this.setMaxStackSize(1); + } + + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); + return stack; + } + + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + if (player.worldObj.isRemote) return; + else if (count % 5 == 2 && ManaItemHandler.requestManaExactForTool(stack, player, 125, true)) { + EntityNebulaBlaze blaze = new EntityNebulaBlaze(player.worldObj, player); + blaze.setAttacker(player.getCommandSenderName()); + player.worldObj.spawnEntityInWorld(blaze); + player.worldObj.playSoundAtEntity(player, "ab:nebulaBlaze", 0.4F, 1.4F); + } + } + + public EnumRarity getRarity(ItemStack stack) { + return AdvancedBotanyAPI.rarityNebula; + } + public EnumAction getItemUseAction(ItemStack stack) { return EnumAction.block; } - + public int getMaxItemUseDuration(ItemStack stack) { return 72000; } @@ -51,4 +49,4 @@ public class ItemNebulaBlaze extends ItemMod implements IManaUsingItem { public boolean usesMana(ItemStack stack) { return true; } -} \ No newline at end of file +} diff --git a/src/main/java/ab/common/item/equipment/ItemNebulaRing.java b/src/main/java/ab/common/item/equipment/ItemNebulaRing.java index 464d40c..13e3afe 100644 --- a/src/main/java/ab/common/item/equipment/ItemNebulaRing.java +++ b/src/main/java/ab/common/item/equipment/ItemNebulaRing.java @@ -1,25 +1,23 @@ package ab.common.item.equipment; -import ab.api.AdvancedBotanyAPI; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.world.World; + +import ab.api.AdvancedBotanyAPI; public class ItemNebulaRing extends ItemMithrillRing { - public ItemNebulaRing(String name) { - super(name); - this.setMaxDamage(1000); - this.setNoRepair(); - } - - public EnumRarity getRarity(ItemStack stack) { - return AdvancedBotanyAPI.rarityNebula; - } - - public int getMaxMana(ItemStack stack) { - return 48000000; - } -} \ No newline at end of file + public ItemNebulaRing(String name) { + super(name); + this.setMaxDamage(1000); + this.setNoRepair(); + } + + public EnumRarity getRarity(ItemStack stack) { + return AdvancedBotanyAPI.rarityNebula; + } + + public int getMaxMana(ItemStack stack) { + return 48000000; + } +} diff --git a/src/main/java/ab/common/item/equipment/ItemNebulaRod.java b/src/main/java/ab/common/item/equipment/ItemNebulaRod.java index 745b81b..2d092da 100644 --- a/src/main/java/ab/common/item/equipment/ItemNebulaRod.java +++ b/src/main/java/ab/common/item/equipment/ItemNebulaRod.java @@ -2,17 +2,9 @@ package ab.common.item.equipment; import java.awt.Color; -import ab.api.AdvancedBotanyAPI; -import ab.client.core.ClientHelper; -import ab.client.core.handler.PlayerItemUsingSound.ClientSoundHandler; -import ab.common.core.handler.ConfigABHandler; -import ab.common.item.ItemMod; import net.minecraft.block.Block; -import net.minecraft.block.BlockLiquid; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.ISound; -import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -25,141 +17,187 @@ import net.minecraft.util.ChatStyle; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.EnderTeleportEvent; + import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.Vector3; +import ab.api.AdvancedBotanyAPI; +import ab.client.core.ClientHelper; +import ab.client.core.handler.PlayerItemUsingSound.ClientSoundHandler; +import ab.common.core.handler.ConfigABHandler; +import ab.common.item.ItemMod; public class ItemNebulaRod extends ItemMod implements IManaUsingItem { - - public ItemNebulaRod() { - super("nebulaRod"); - this.setMaxStackSize(1); - this.setNoRepair(); - this.setMaxDamage(100); - } - public boolean usesMana(ItemStack stack) { - return true; - } - - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if(stack.getItemDamage() == 0 && checkWorld(world.provider.getDimensionName())) - player.setItemInUse(stack, getMaxItemUseDuration(stack)); - return stack; - } - - private boolean checkWorld(String name) { - for(String str : ConfigABHandler.lockWorldNameNebulaRod) - if(str.equals(name)) - return false; - return true; - } - - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } - - public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { - if(!world.isRemote && player instanceof EntityPlayer && player.ticksExisted % ConfigABHandler.nebulaWandCooldownTick == 0 && stack.getItemDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer)player, ConfigABHandler.nebulaRodManaCost, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } - - public EnumRarity getRarity(ItemStack stack) { - return AdvancedBotanyAPI.rarityNebula; - } - - public void onUsingTick(ItemStack stack, EntityPlayer p, int time) { - time = this.getMaxItemUseDuration(stack) - time; - if(time > 110 && !p.isSneaking()) { - if(!p.worldObj.isRemote) { - ChunkCoordinates chunkcoordinates = getTopBlock(p.worldObj, p); - if(chunkcoordinates == null) { - p.stopUsingItem(); - p.addChatMessage((new ChatComponentTranslation("ab.nebulaRod.notTeleporting", new Object[0])).setChatStyle((new ChatStyle()).setColor(EnumChatFormatting.DARK_PURPLE))); - return; - } - EnderTeleportEvent event = new EnderTeleportEvent((EntityPlayerMP)p, chunkcoordinates.posX + 0.5D, chunkcoordinates.posY + 0.5D, chunkcoordinates.posZ + 0.5D, 0.0F); - MinecraftForge.EVENT_BUS.post(event); - if(event.isCanceled()) { - p.stopUsingItem(); - p.addChatMessage((new ChatComponentTranslation("ab.nebulaRod.notTeleportingEvent", new Object[0])).setChatStyle((new ChatStyle()).setColor(EnumChatFormatting.DARK_PURPLE))); - return; - } - ((EntityPlayerMP)p).playerNetServerHandler.setPlayerLocation(chunkcoordinates.posX + 0.5D, chunkcoordinates.posY + 0.5D, chunkcoordinates.posZ + 0.5D, p.rotationYaw, p.rotationPitch); - p.worldObj.playSoundAtEntity(p, "ab:nebulaRod", 1.2F, 1.2F); - } - if(!p.capabilities.isCreativeMode) - stack.setItemDamage(100); - p.stopUsingItem(); - } - spawnPortalParticle(p.worldObj, p, time, p.worldObj.rand.nextBoolean() ? 0x931fec : 0x4b1682, 1.0f); - } - - public void spawnPortalParticle(World world, EntityPlayer p, int time, int color, float particleTime) { - if(world.isRemote) { - ClientSoundHandler.playSound(p, "portal.portal", 1.2F, 1.0F, 40); - boolean isFinish = time > 80; - int ticks = Math.min(100, time); - int totalSpiritCount = (int)Math.max(3, ticks / 100.0f * 18); - double tickIncrement = 360.0D / totalSpiritCount; - int speed = 8; - double wticks = (ticks * speed) - tickIncrement; - double r = Math.sin((ticks) / 100.0D) * Math.max(0.75f, 1.4D * ticks / 100.0f); - Vec3 look = p.getLookVec(); - float yawOffset = Minecraft.getMinecraft().thePlayer.getDisplayName() == p.getDisplayName() ? 0.0f : 1.62f; - Vector3 l = new Vector3(look.xCoord, look.yCoord + yawOffset, look.zCoord); - Vector3 player = Vector3.fromEntity(p).add(0.0f, 0.0f, 0.0f); - Vector3 v3 = new Vector3(); - for(int i = 0; i < totalSpiritCount; i++) { - float size = Math.max(0.215f, ticks / 100.0f); - v3.set(Math.sin(wticks * Math.PI / 180.0D) / 1.825f * r, Math.cos(wticks * Math.PI / 180.0D) * r, 0.8f); - ClientHelper.setRotation(p.rotationPitch, 1.0f, 0.0f, 0.0f, v3); - ClientHelper.setRotation(-p.rotationYaw, 0.0f, 1.0f, 0.0f, v3); - v3.add(l.multiply(1.0f)).add(player); - wticks += tickIncrement; - float hsb[] = Color.RGBtoHSB(color & 255, color >> 8 & 255, color >> 16 & 255, null); - int color1 = Color.HSBtoRGB(hsb[0], hsb[1], ticks / 100.0f); - float[] colorsfx = { (color1 & 255) / 255.0f, (color1 >> 8 & 255) / 255.0f, (color1 >> 16 & 255) / 255.0f }; - float motionSpeed = 0.25f * Math.min(1.0f, (time - 80) / 30.0f); - Botania.proxy.wispFX(world, v3.x, v3.y, v3.z, colorsfx[0], colorsfx[1], colorsfx[2], 0.3F * size, isFinish ? (float)(look.xCoord * -1) * motionSpeed : 0.0f, isFinish ? (float)(look.yCoord * -1) * motionSpeed : 0.0f, isFinish ? (float)(look.zCoord * -1) * motionSpeed : 0.0f, 0.3F * particleTime); - Botania.proxy.wispFX(world, v3.x, v3.y, v3.z, colorsfx[0], colorsfx[1], colorsfx[2], (float)(Math.random() * 0.1F + 0.05F) * size, (float)(Math.random() - 0.5D) * 0.05F, (float)(Math.random() - 0.5D) * 0.05F, (float)(Math.random() - 0.5D) * 0.05F, 0.4F * particleTime); - } - } - } - - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 72000; - } - - public boolean isFull3D() { - return true; - } - - public ChunkCoordinates getTopBlock(World world, EntityPlayer player) { - Vec3 vec3 = player.getLook(1.0F).normalize(); - int limitXZ = ConfigABHandler.limitXZCoords; - for(int nextPos = 256; nextPos > 0 && nextPos > 8; nextPos--) { - int nPosX = MathHelper.floor_double(player.posX + vec3.xCoord * nextPos); - int nPosZ = MathHelper.floor_double(player.posZ + vec3.zCoord * nextPos); - nPosX = Math.min(Math.max(nPosX, -(limitXZ - 1)), limitXZ - 1); - nPosZ = Math.min(Math.max(nPosZ, -(limitXZ - 1)), limitXZ - 1); - Chunk chunk = world.getChunkFromBlockCoords(nPosX, nPosZ); - int x = nPosX & 15; - int z = nPosZ & 15; - for(int k = chunk.getTopFilledSegment() + 15; k > 0; --k) { - Block block = chunk.getBlock(x, k, z); - boolean hasTopAir = chunk.getBlock(x, k + 1, z).getMaterial() == Material.air && chunk.getBlock(x, k + 2, z).getMaterial() == Material.air; - if(!block.isAir(world, x, k, z) && block != Blocks.bedrock && hasTopAir) - return new ChunkCoordinates(nPosX, k + 1, nPosZ); - } - } + public ItemNebulaRod() { + super("nebulaRod"); + this.setMaxStackSize(1); + this.setNoRepair(); + this.setMaxDamage(100); + } + + public boolean usesMana(ItemStack stack) { + return true; + } + + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (stack.getItemDamage() == 0 && checkWorld(world.provider.getDimensionName())) + player.setItemInUse(stack, getMaxItemUseDuration(stack)); + return stack; + } + + private boolean checkWorld(String name) { + for (String str : ConfigABHandler.lockWorldNameNebulaRod) if (str.equals(name)) return false; + return true; + } + + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } + + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { + if (!world.isRemote && player instanceof EntityPlayer + && player.ticksExisted % ConfigABHandler.nebulaWandCooldownTick == 0 + && stack.getItemDamage() > 0 + && ManaItemHandler + .requestManaExactForTool(stack, (EntityPlayer) player, ConfigABHandler.nebulaRodManaCost, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } + + public EnumRarity getRarity(ItemStack stack) { + return AdvancedBotanyAPI.rarityNebula; + } + + public void onUsingTick(ItemStack stack, EntityPlayer p, int time) { + time = this.getMaxItemUseDuration(stack) - time; + if (time > 110 && !p.isSneaking()) { + if (!p.worldObj.isRemote) { + ChunkCoordinates chunkcoordinates = getTopBlock(p.worldObj, p); + if (chunkcoordinates == null) { + p.stopUsingItem(); + p.addChatMessage( + (new ChatComponentTranslation("ab.nebulaRod.notTeleporting", new Object[0])) + .setChatStyle((new ChatStyle()).setColor(EnumChatFormatting.DARK_PURPLE))); + return; + } + EnderTeleportEvent event = new EnderTeleportEvent( + (EntityPlayerMP) p, + chunkcoordinates.posX + 0.5D, + chunkcoordinates.posY + 0.5D, + chunkcoordinates.posZ + 0.5D, + 0.0F); + MinecraftForge.EVENT_BUS.post(event); + if (event.isCanceled()) { + p.stopUsingItem(); + p.addChatMessage( + (new ChatComponentTranslation("ab.nebulaRod.notTeleportingEvent", new Object[0])) + .setChatStyle((new ChatStyle()).setColor(EnumChatFormatting.DARK_PURPLE))); + return; + } + ((EntityPlayerMP) p).playerNetServerHandler.setPlayerLocation( + chunkcoordinates.posX + 0.5D, + chunkcoordinates.posY + 0.5D, + chunkcoordinates.posZ + 0.5D, + p.rotationYaw, + p.rotationPitch); + p.worldObj.playSoundAtEntity(p, "ab:nebulaRod", 1.2F, 1.2F); + } + if (!p.capabilities.isCreativeMode) stack.setItemDamage(100); + p.stopUsingItem(); + } + spawnPortalParticle(p.worldObj, p, time, p.worldObj.rand.nextBoolean() ? 0x931fec : 0x4b1682, 1.0f); + } + + public void spawnPortalParticle(World world, EntityPlayer p, int time, int color, float particleTime) { + if (world.isRemote) { + ClientSoundHandler.playSound(p, "portal.portal", 1.2F, 1.0F, 40); + boolean isFinish = time > 80; + int ticks = Math.min(100, time); + int totalSpiritCount = (int) Math.max(3, ticks / 100.0f * 18); + double tickIncrement = 360.0D / totalSpiritCount; + int speed = 8; + double wticks = (ticks * speed) - tickIncrement; + double r = Math.sin((ticks) / 100.0D) * Math.max(0.75f, 1.4D * ticks / 100.0f); + Vec3 look = p.getLookVec(); + float yawOffset = Minecraft.getMinecraft().thePlayer.getDisplayName() == p.getDisplayName() ? 0.0f : 1.62f; + Vector3 l = new Vector3(look.xCoord, look.yCoord + yawOffset, look.zCoord); + Vector3 player = Vector3.fromEntity(p).add(0.0f, 0.0f, 0.0f); + Vector3 v3 = new Vector3(); + for (int i = 0; i < totalSpiritCount; i++) { + float size = Math.max(0.215f, ticks / 100.0f); + v3.set(Math.sin(wticks * Math.PI / 180.0D) / 1.825f * r, Math.cos(wticks * Math.PI / 180.0D) * r, 0.8f); + ClientHelper.setRotation(p.rotationPitch, 1.0f, 0.0f, 0.0f, v3); + ClientHelper.setRotation(-p.rotationYaw, 0.0f, 1.0f, 0.0f, v3); + v3.add(l.multiply(1.0f)).add(player); + wticks += tickIncrement; + float hsb[] = Color.RGBtoHSB(color & 255, color >> 8 & 255, color >> 16 & 255, null); + int color1 = Color.HSBtoRGB(hsb[0], hsb[1], ticks / 100.0f); + float[] colorsfx = { (color1 & 255) / 255.0f, (color1 >> 8 & 255) / 255.0f, + (color1 >> 16 & 255) / 255.0f }; + float motionSpeed = 0.25f * Math.min(1.0f, (time - 80) / 30.0f); + Botania.proxy.wispFX( + world, + v3.x, + v3.y, + v3.z, + colorsfx[0], + colorsfx[1], + colorsfx[2], + 0.3F * size, + isFinish ? (float) (look.xCoord * -1) * motionSpeed : 0.0f, + isFinish ? (float) (look.yCoord * -1) * motionSpeed : 0.0f, + isFinish ? (float) (look.zCoord * -1) * motionSpeed : 0.0f, + 0.3F * particleTime); + Botania.proxy.wispFX( + world, + v3.x, + v3.y, + v3.z, + colorsfx[0], + colorsfx[1], + colorsfx[2], + (float) (Math.random() * 0.1F + 0.05F) * size, + (float) (Math.random() - 0.5D) * 0.05F, + (float) (Math.random() - 0.5D) * 0.05F, + (float) (Math.random() - 0.5D) * 0.05F, + 0.4F * particleTime); + } + } + } + + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } + + public boolean isFull3D() { + return true; + } + + public ChunkCoordinates getTopBlock(World world, EntityPlayer player) { + Vec3 vec3 = player.getLook(1.0F).normalize(); + int limitXZ = ConfigABHandler.limitXZCoords; + for (int nextPos = 256; nextPos > 0 && nextPos > 8; nextPos--) { + int nPosX = MathHelper.floor_double(player.posX + vec3.xCoord * nextPos); + int nPosZ = MathHelper.floor_double(player.posZ + vec3.zCoord * nextPos); + nPosX = Math.min(Math.max(nPosX, -(limitXZ - 1)), limitXZ - 1); + nPosZ = Math.min(Math.max(nPosZ, -(limitXZ - 1)), limitXZ - 1); + Chunk chunk = world.getChunkFromBlockCoords(nPosX, nPosZ); + int x = nPosX & 15; + int z = nPosZ & 15; + for (int k = chunk.getTopFilledSegment() + 15; k > 0; --k) { + Block block = chunk.getBlock(x, k, z); + boolean hasTopAir = chunk.getBlock(x, k + 1, z).getMaterial() == Material.air + && chunk.getBlock(x, k + 2, z).getMaterial() == Material.air; + if (!block.isAir(world, x, k, z) && block != Blocks.bedrock && hasTopAir) + return new ChunkCoordinates(nPosX, k + 1, nPosZ); + } + } return null; } -} \ No newline at end of file +} diff --git a/src/main/java/ab/common/item/equipment/ItemSpaceBlade.java b/src/main/java/ab/common/item/equipment/ItemSpaceBlade.java index 33ea8f2..3205d58 100644 --- a/src/main/java/ab/common/item/equipment/ItemSpaceBlade.java +++ b/src/main/java/ab/common/item/equipment/ItemSpaceBlade.java @@ -3,17 +3,7 @@ package ab.common.item.equipment; import java.awt.Color; import java.util.List; import java.util.UUID; -import com.google.common.collect.Multimap; -import ab.AdvancedBotany; -import ab.api.AdvancedBotanyAPI; -import ab.api.IRankItem; -import ab.common.core.handler.*; -import ab.common.entity.EntitySword; -import cpw.mods.fml.relauncher.ReflectionHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.PositionedSoundRecord; + import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -23,7 +13,6 @@ import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -36,267 +25,299 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; -import net.minecraft.util.MathHelper; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraft.util.Vec3; import net.minecraft.world.World; -import vazkii.botania.api.internal.IManaBurst; -import vazkii.botania.api.mana.BurstProperties; -import vazkii.botania.api.mana.ILensEffect; -import vazkii.botania.api.mana.IManaItem; + import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.ItemNBTHelper; -import vazkii.botania.common.entity.EntityManaBurst; -import vazkii.botania.common.lib.LibObfuscation; +import ab.AdvancedBotany; +import ab.api.AdvancedBotanyAPI; +import ab.api.IRankItem; +import ab.common.core.handler.*; +import ab.common.entity.EntitySword; + +import com.google.common.collect.Multimap; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemSpaceBlade extends ItemSword implements IRankItem, IManaUsingItem { - - private static final IIcon[] icons = new IIcon[3]; - private static final int recharge = 36; - - public static final int[] LEVELS = new int[] { 0, 10000, 1000000, 10000000, 100000000, 1000000000 }; - private static final int[] CREATIVE_MANA = new int[] { 9999, 999999, 9999999, 99999999, 999999999, 2147483646 }; - - public ItemSpaceBlade() { - super(AdvancedBotanyAPI.mithrilToolMaterial); - this.setCreativeTab(AdvancedBotany.tabAB); - this.setUnlocalizedName("spaceBlade"); - } - - public boolean isItemTool(ItemStack par1ItemStack) { - return true; - } - - 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); - } - } - - public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { - if(!player.worldObj.isRemote) { - ItemNBTHelper.setInt(stack, "postAttackTick", 3); - if(this.getLevel(stack) >= 3 && this.isEnabledMode(stack)) { - float size = this.getLevel(stack) >= 4 ? (this.getLevel(stack) >= 5 ? 3.5f : 2.5f) : 1.5f; - AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(entity.posX, entity.posY, entity.posZ, entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ).expand(size, 1.7f, size); - List entities = entity.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); - for(EntityLivingBase living : entities) { - if(living instanceof EntityPlayer && (((EntityPlayer)living).getCommandSenderName().equals(player.getCommandSenderName()) || (MinecraftServer.getServer() != null && !MinecraftServer.getServer().isPVPEnabled()))) - continue; - if(living.hurtTime == 0) { - float damage = getSwordDamage(stack); - living.attackEntityFrom(DamageSource.causePlayerDamage(player), damage); - } - } - } - } - return super.onLeftClickEntity(stack, player, entity); - } - - public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { - if(!(entity instanceof EntityPlayer)) - return; - EntityPlayer player = (EntityPlayer)entity; - int tick = ItemNBTHelper.getInt(stack, "tick", 0); - if(!world.isRemote) { - int postAttackTick = ItemNBTHelper.getInt(stack, "postAttackTick", 0); - if(postAttackTick > 0 && !player.isUsingItem()) - ItemNBTHelper.setInt(stack, "postAttackTick", postAttackTick - 1); - if(tick > 0) - ItemNBTHelper.setInt(stack, "tick", tick - 1); - 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 && this.getLevel(stack) >= 1 && postAttackTick == 0 && ManaItemHandler.requestManaExactForTool(stack, player, 120, true)) { - EntitySword sword = new EntitySword(world, player); - sword.setDamage(getSwordDamage(stack)); - sword.setAttacker(player.getCommandSenderName()); - sword.motionX *= 0.2f; - sword.motionY *= 0.2f; - sword.motionZ *= 0.2f; - world.spawnEntityInWorld(sword); - player.worldObj.playSoundAtEntity(player, "ab:bladeSpace", 0.5F, 3.6F); - } - } else { - if(tick > 26 && par5) { - for(int i = 0; i < 14; i++) { - float r = world.rand.nextBoolean() ? (225.0f / 255.0f) : (101.0f / 255.0f); - float g = world.rand.nextBoolean() ? (67.0f / 255.0f) : (209.0f / 255.0f); - float b = world.rand.nextBoolean() ? (240.0f / 255.0f) : (225.0f / 255.0f); - Botania.proxy.sparkleFX(world, entity.posX + (Math.random() - 0.5D), entity.posY + ((Math.random() - 0.5D) * 2) - 0.5f, entity.posZ + (Math.random() - 0.5D), r + (float)(Math.random() / 4 - 0.125D), g + (float)(Math.random() / 4 - 0.125D), b + (float)(Math.random() / 4 - 0.125D), 1.8F * (float)(Math.random() - 0.5D), 3); - } - } - } - } - - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if(ItemNBTHelper.getInt(stack, "tick", 0) != 0) - return stack; - return super.onItemRightClick(stack, world, player); - } - - public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int lastTime) { - int useTime = getMaxItemUseDuration(stack) - lastTime; - if(useTime < 4) { - if(!world.isRemote && !player.isSneaking() && ItemNBTHelper.getInt(stack, "tick", 0) == 0 && this.getLevel(stack) >= 2) { - NetworkHandler.sendPacketToSpaceDash((EntityPlayerMP)player); - onPlayerSpaceDash(player); - ItemNBTHelper.setInt(stack, "tick", recharge); - player.worldObj.playSoundAtEntity(player, "ab:bladeSpace", 2.3F, 1.2F); - return; - } - if(player.isSneaking() && this.getLevel(stack) >= 3) { - ItemNBTHelper.setBoolean(stack, "isEnabledMode", !this.isEnabledMode(stack)); - return; - } - } - } - - public static void onPlayerSpaceDash(EntityPlayer player) { - Vec3 vec3 = player.getLook(1.0F).normalize(); - player.motionX += vec3.xCoord * 3.25f; - player.motionY += (vec3.yCoord / 1.6f); - player.motionZ += vec3.zCoord * 3.25f; - } - - public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean par4) { - String rankFormat = StatCollector.translateToLocal("botaniamisc.toolRank"); - String rank = StatCollector.translateToLocal("botania.rank" + getLevel(stack)); - list.add(String.format(rankFormat, new Object[] { rank }).replaceAll("&", "\u00A7")); - if (getMana(stack) == Integer.MAX_VALUE) - list.add(EnumChatFormatting.DARK_AQUA + StatCollector.translateToLocal("abmisc.swordFull")); - if (GuiScreen.isShiftKeyDown()) { - int level = (getLevel(stack)); - list.add((level >= 1 ? EnumChatFormatting.GREEN : "") + StatCollector.translateToLocal("abmisc.swordInfo.1")); - list.add((level >= 2 ? EnumChatFormatting.GREEN : "") + StatCollector.translateToLocal("abmisc.swordInfo.2")); - list.add((level >= 3 ? EnumChatFormatting.GREEN : "") + StatCollector.translateToLocal(("abmisc.swordInfo.LEVEL").replaceAll("LEVEL", "" + (level >= 3 ? level : 3)))); - } else { - if(this.getLevel(stack) != 0) - list.add(StatCollector.translateToLocal("botaniamisc.shiftinfo").replaceAll("&", "\u00A7")); - } - } - - public EnumRarity getRarity(ItemStack stack) { - return AdvancedBotanyAPI.rarityNebula; - } - - public int getEntityLifespan(ItemStack itemStack, World world) { - return Integer.MAX_VALUE; - } - - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack stack, int par2) { - return (par2 == 1) ? Color.HSBtoRGB(0.836F, 1.0f - (float)getDurabilityForDisplay(stack), 1.0F) : 16777215; - } - - public boolean requiresMultipleRenderPasses() { - return true; - } - - @SideOnly(Side.CLIENT) - public boolean showDurabilityBar(ItemStack stack) { - return ItemNBTHelper.getInt(stack, "tick", 0) != 0; - } - - @SideOnly(Side.CLIENT) - public double getDurabilityForDisplay(ItemStack stack) { - int tick = ItemNBTHelper.getInt(stack, "tick", 0); - return (double)(tick) / (double)recharge; - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister ir) { - this.icons[0] = ir.registerIcon("ab:itemMithrillSword_mode_0"); - this.icons[1] = ir.registerIcon("ab:itemMithrillSword_gem"); - this.icons[2] = ir.registerIcon("ab:itemMithrillSword_mode_1"); - } - - @SideOnly(Side.CLIENT) - public IIcon getIcon(ItemStack stack, int pass) { - int iconID = Math.min(1, pass); - if(isEnabledMode(stack) && iconID == 0) { - iconID = 2; - } - return this.icons[iconID]; - } - - private boolean isEnabledMode(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, "isEnabledMode", false); - } - - public int[] getLevels() { - return LEVELS; - } - - public 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; - } - - public static int getMana_(ItemStack stack) { - return ItemNBTHelper.getInt(stack, "mana", 0); - } - - public static void setMana(ItemStack stack, int mana) { - ItemNBTHelper.setInt(stack, "mana", mana); - } - public void addMana(ItemStack stack, int mana) { - setMana(stack, Math.min(getMana(stack) + mana, 2147483647)); - } + private static final IIcon[] icons = new IIcon[3]; + private static final int recharge = 36; - public boolean canExportManaToItem(ItemStack stack, ItemStack stack1) { - return false; - } + public static final int[] LEVELS = new int[] { 0, 10000, 1000000, 10000000, 100000000, 1000000000 }; + private static final int[] CREATIVE_MANA = new int[] { 9999, 999999, 9999999, 99999999, 999999999, 2147483646 }; - public boolean canExportManaToPool(ItemStack stack, TileEntity tile) { - return false; - } + public ItemSpaceBlade() { + super(AdvancedBotanyAPI.mithrilToolMaterial); + this.setCreativeTab(AdvancedBotany.tabAB); + this.setUnlocalizedName("spaceBlade"); + } - public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { - return !(otherStack.getItem() instanceof vazkii.botania.api.mana.IManaGivingItem); - } - - public boolean canReceiveManaFromPool(ItemStack stack, TileEntity tile) { - return true; - } - - public int getMana(ItemStack stack) { - return getMana_(stack); - } - - public int getMaxMana(ItemStack stack) { - return Integer.MAX_VALUE; - } - - public boolean isNoExport(ItemStack stack) { - return true; - } - - public boolean usesMana(ItemStack stack) { + public boolean isItemTool(ItemStack par1ItemStack) { return true; } - - private float getSwordDamage(ItemStack stack) { - int level = this.getLevel(stack); - return 4.0F + (float)Math.round((AdvancedBotanyAPI.mithrilToolMaterial.getDamageVsEntity() + (level * level / 1.5f)) * ConfigABHandler.damageFactorSpaceSword); - } - - public Multimap getAttributeModifiers(ItemStack stack) { - Multimap multimap = this.getItemAttributeModifiers(); - multimap.clear(); - UUID uuid = new UUID(getUnlocalizedName().hashCode(), 0L); - multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", getSwordDamage(stack), 0)); - multimap.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(uuid, "Weapon speed", 0.25D, 1)); - return multimap; - } -} \ No newline at end of file + + 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); + } + } + + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { + if (!player.worldObj.isRemote) { + ItemNBTHelper.setInt(stack, "postAttackTick", 3); + if (this.getLevel(stack) >= 3 && this.isEnabledMode(stack)) { + float size = this.getLevel(stack) >= 4 ? (this.getLevel(stack) >= 5 ? 3.5f : 2.5f) : 1.5f; + AxisAlignedBB axis = AxisAlignedBB.getBoundingBox( + entity.posX, + entity.posY, + entity.posZ, + entity.lastTickPosX, + entity.lastTickPosY, + entity.lastTickPosZ).expand(size, 1.7f, size); + List entities = entity.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis); + for (EntityLivingBase living : entities) { + if (living instanceof EntityPlayer && (((EntityPlayer) living).getCommandSenderName() + .equals(player.getCommandSenderName()) + || (MinecraftServer.getServer() != null && !MinecraftServer.getServer().isPVPEnabled()))) + continue; + if (living.hurtTime == 0) { + float damage = getSwordDamage(stack); + living.attackEntityFrom(DamageSource.causePlayerDamage(player), damage); + } + } + } + } + return super.onLeftClickEntity(stack, player, entity); + } + + public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { + if (!(entity instanceof EntityPlayer)) return; + EntityPlayer player = (EntityPlayer) entity; + int tick = ItemNBTHelper.getInt(stack, "tick", 0); + if (!world.isRemote) { + int postAttackTick = ItemNBTHelper.getInt(stack, "postAttackTick", 0); + if (postAttackTick > 0 && !player.isUsingItem()) + ItemNBTHelper.setInt(stack, "postAttackTick", postAttackTick - 1); + if (tick > 0) ItemNBTHelper.setInt(stack, "tick", tick - 1); + 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 + && this.getLevel(stack) >= 1 + && postAttackTick == 0 + && ManaItemHandler.requestManaExactForTool(stack, player, 120, true)) { + EntitySword sword = new EntitySword(world, player); + sword.setDamage(getSwordDamage(stack)); + sword.setAttacker(player.getCommandSenderName()); + sword.motionX *= 0.2f; + sword.motionY *= 0.2f; + sword.motionZ *= 0.2f; + world.spawnEntityInWorld(sword); + player.worldObj.playSoundAtEntity(player, "ab:bladeSpace", 0.5F, 3.6F); + } + } else { + if (tick > 26 && par5) { + for (int i = 0; i < 14; i++) { + float r = world.rand.nextBoolean() ? (225.0f / 255.0f) : (101.0f / 255.0f); + float g = world.rand.nextBoolean() ? (67.0f / 255.0f) : (209.0f / 255.0f); + float b = world.rand.nextBoolean() ? (240.0f / 255.0f) : (225.0f / 255.0f); + Botania.proxy.sparkleFX( + world, + entity.posX + (Math.random() - 0.5D), + entity.posY + ((Math.random() - 0.5D) * 2) - 0.5f, + entity.posZ + (Math.random() - 0.5D), + r + (float) (Math.random() / 4 - 0.125D), + g + (float) (Math.random() / 4 - 0.125D), + b + (float) (Math.random() / 4 - 0.125D), + 1.8F * (float) (Math.random() - 0.5D), + 3); + } + } + } + } + + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (ItemNBTHelper.getInt(stack, "tick", 0) != 0) return stack; + return super.onItemRightClick(stack, world, player); + } + + public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int lastTime) { + int useTime = getMaxItemUseDuration(stack) - lastTime; + if (useTime < 4) { + if (!world.isRemote && !player.isSneaking() + && ItemNBTHelper.getInt(stack, "tick", 0) == 0 + && this.getLevel(stack) >= 2) { + NetworkHandler.sendPacketToSpaceDash((EntityPlayerMP) player); + onPlayerSpaceDash(player); + ItemNBTHelper.setInt(stack, "tick", recharge); + player.worldObj.playSoundAtEntity(player, "ab:bladeSpace", 2.3F, 1.2F); + return; + } + if (player.isSneaking() && this.getLevel(stack) >= 3) { + ItemNBTHelper.setBoolean(stack, "isEnabledMode", !this.isEnabledMode(stack)); + return; + } + } + } + + public static void onPlayerSpaceDash(EntityPlayer player) { + Vec3 vec3 = player.getLook(1.0F).normalize(); + player.motionX += vec3.xCoord * 3.25f; + player.motionY += (vec3.yCoord / 1.6f); + player.motionZ += vec3.zCoord * 3.25f; + } + + public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean par4) { + String rankFormat = StatCollector.translateToLocal("botaniamisc.toolRank"); + String rank = StatCollector.translateToLocal("botania.rank" + getLevel(stack)); + list.add(String.format(rankFormat, new Object[] { rank }).replaceAll("&", "\u00A7")); + if (getMana(stack) == Integer.MAX_VALUE) + list.add(EnumChatFormatting.DARK_AQUA + StatCollector.translateToLocal("abmisc.swordFull")); + if (GuiScreen.isShiftKeyDown()) { + int level = (getLevel(stack)); + list.add( + (level >= 1 ? EnumChatFormatting.GREEN : "") + + StatCollector.translateToLocal("abmisc.swordInfo.1")); + list.add( + (level >= 2 ? EnumChatFormatting.GREEN : "") + + StatCollector.translateToLocal("abmisc.swordInfo.2")); + list.add( + (level >= 3 ? EnumChatFormatting.GREEN : "") + StatCollector.translateToLocal( + ("abmisc.swordInfo.LEVEL").replaceAll("LEVEL", "" + (level >= 3 ? level : 3)))); + } else { + if (this.getLevel(stack) != 0) + list.add(StatCollector.translateToLocal("botaniamisc.shiftinfo").replaceAll("&", "\u00A7")); + } + } + + public EnumRarity getRarity(ItemStack stack) { + return AdvancedBotanyAPI.rarityNebula; + } + + public int getEntityLifespan(ItemStack itemStack, World world) { + return Integer.MAX_VALUE; + } + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int par2) { + return (par2 == 1) ? Color.HSBtoRGB(0.836F, 1.0f - (float) getDurabilityForDisplay(stack), 1.0F) : 16777215; + } + + public boolean requiresMultipleRenderPasses() { + return true; + } + + @SideOnly(Side.CLIENT) + public boolean showDurabilityBar(ItemStack stack) { + return ItemNBTHelper.getInt(stack, "tick", 0) != 0; + } + + @SideOnly(Side.CLIENT) + public double getDurabilityForDisplay(ItemStack stack) { + int tick = ItemNBTHelper.getInt(stack, "tick", 0); + return (double) (tick) / (double) recharge; + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister ir) { + this.icons[0] = ir.registerIcon("ab:itemMithrillSword_mode_0"); + this.icons[1] = ir.registerIcon("ab:itemMithrillSword_gem"); + this.icons[2] = ir.registerIcon("ab:itemMithrillSword_mode_1"); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int pass) { + int iconID = Math.min(1, pass); + if (isEnabledMode(stack) && iconID == 0) { + iconID = 2; + } + return this.icons[iconID]; + } + + private boolean isEnabledMode(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, "isEnabledMode", false); + } + + public int[] getLevels() { + return LEVELS; + } + + public 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; + } + + public static int getMana_(ItemStack stack) { + return ItemNBTHelper.getInt(stack, "mana", 0); + } + + public static void setMana(ItemStack stack, int mana) { + ItemNBTHelper.setInt(stack, "mana", mana); + } + + public void addMana(ItemStack stack, int mana) { + setMana(stack, Math.min(getMana(stack) + mana, 2147483647)); + } + + public boolean canExportManaToItem(ItemStack stack, ItemStack stack1) { + return false; + } + + public boolean canExportManaToPool(ItemStack stack, TileEntity tile) { + return false; + } + + public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack) { + return !(otherStack.getItem() instanceof vazkii.botania.api.mana.IManaGivingItem); + } + + public boolean canReceiveManaFromPool(ItemStack stack, TileEntity tile) { + return true; + } + + public int getMana(ItemStack stack) { + return getMana_(stack); + } + + public int getMaxMana(ItemStack stack) { + return Integer.MAX_VALUE; + } + + public boolean isNoExport(ItemStack stack) { + return true; + } + + public boolean usesMana(ItemStack stack) { + return true; + } + + private float getSwordDamage(ItemStack stack) { + int level = this.getLevel(stack); + return 4.0F + (float) Math.round( + (AdvancedBotanyAPI.mithrilToolMaterial.getDamageVsEntity() + (level * level / 1.5f)) + * ConfigABHandler.damageFactorSpaceSword); + } + + public Multimap getAttributeModifiers(ItemStack stack) { + Multimap multimap = this.getItemAttributeModifiers(); + multimap.clear(); + UUID uuid = new UUID(getUnlocalizedName().hashCode(), 0L); + multimap.put( + SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), + new AttributeModifier(field_111210_e, "Weapon modifier", getSwordDamage(stack), 0)); + multimap.put( + SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), + new AttributeModifier(uuid, "Weapon speed", 0.25D, 1)); + return multimap; + } +} diff --git a/src/main/java/ab/common/item/equipment/ItemSprawlRod.java b/src/main/java/ab/common/item/equipment/ItemSprawlRod.java index d8d9e02..9eb8437 100644 --- a/src/main/java/ab/common/item/equipment/ItemSprawlRod.java +++ b/src/main/java/ab/common/item/equipment/ItemSprawlRod.java @@ -2,170 +2,174 @@ package ab.common.item.equipment; import java.awt.Color; -import ab.common.core.handler.ConfigABHandler; -import ab.common.entity.EntitySeed; -import ab.common.item.ItemMod; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; import net.minecraft.item.ItemStack; import net.minecraft.util.Vec3; import net.minecraft.world.World; + import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.Botania; -import vazkii.botania.common.item.ItemGrassSeeds; import vazkii.botania.common.item.ModItems; +import ab.common.core.handler.ConfigABHandler; +import ab.common.entity.EntitySeed; +import ab.common.item.ItemMod; public class ItemSprawlRod extends ItemMod implements IManaUsingItem { - public ItemSprawlRod() { - super("sprawlRod"); - this.setMaxStackSize(1); - this.setNoRepair(); - this.setMaxDamage(100); - } + public ItemSprawlRod() { + super("sprawlRod"); + this.setMaxStackSize(1); + this.setNoRepair(); + this.setMaxDamage(100); + } - public boolean usesMana(ItemStack stack) { - return true; - } - - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 72000; - } - - public boolean isFull3D() { - return true; - } - - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } - - 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, 760, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } - - public ItemStack onItemRightClick(ItemStack rod, World world, EntityPlayer p) { - if(rod.getItemDamage() != 0) - return rod; - ItemStack seed = null; - for(int i = 0; i < p.inventory.getSizeInventory(); i++) { - ItemStack slot = p.inventory.getStackInSlot(i); - if(slot == null) - continue; - if(slot.getItem() == ModItems.grassSeeds) { - seed = slot; - break; - } - } - if(seed == null) - return rod; - p.setItemInUse(rod, getMaxItemUseDuration(rod)); - return rod; - } - - public void onUsingTick(ItemStack stack, EntityPlayer p, int time) { - if(p.worldObj.isRemote) { - time = this.getMaxItemUseDuration(stack) - time; - if(time % 2 == 0 && time != 0) - return; - ItemStack seed = null; - for(int i = 0; i < p.inventory.getSizeInventory(); i++) { - ItemStack slot = p.inventory.getStackInSlot(i); - if(slot == null) - continue; - if(slot.getItem() == ModItems.grassSeeds) { - seed = slot; - break; - } - } - if(seed == null) - return; - int ticks = Math.min(128, time); - float fTicks = ticks / 128.0f; - Vec3 look = p.getLookVec(); - double posX = p.posX + (look.xCoord * 1.4f) + ((Math.random() - 0.5f) * fTicks * 0.3f); - double posY = p.posY + (look.yCoord * 1.4f) + ((Math.random() - 0.5f) * fTicks * 0.3f); - double posZ = p.posZ + (look.zCoord * 1.4f) + ((Math.random() - 0.5f) * fTicks * 0.3f); - Color color = getSeedColor(seed); - Botania.proxy.wispFX(p.worldObj, posX, posY, posZ, color.getRed() / 255.0f, color.getGreen() / 255.0f, color.getBlue() / 255.0f, 0.5F * fTicks - (float)(Math.random() * 0.1f), 0.0f, 0.5F); - } - } - - public void onPlayerStoppedUsing(ItemStack rod, World world, EntityPlayer player, int lastTime) { - int useTime = getMaxItemUseDuration(rod) - lastTime; - for(int i = 0; i < player.inventory.getSizeInventory(); i++) { - ItemStack stack = player.inventory.getStackInSlot(i); - if(stack == null) - continue; - if(stack.getItem() == ModItems.grassSeeds) { - if(!world.isRemote) { - EntitySeed entitySeed = new EntitySeed(world, player); - entitySeed.setSeed(stack.copy()); - entitySeed.setRadius((int)((Math.min(useTime, 128.0f) / 128.0f) * ConfigABHandler.sprawlRodMaxArea)); - entitySeed.setAttacker(player.getCommandSenderName()); - world.spawnEntityInWorld(entitySeed); - } - if(stack.stackSize > 1) - stack.stackSize--; - else - player.inventory.setInventorySlotContents(i, null); - if(!player.capabilities.isCreativeMode) - rod.setItemDamage(Math.min(100, (int)(useTime / 128.0f * 100.0f))); - break; - } - } - } - - public static Color getSeedColor(ItemStack seed) { - int meta = seed.getItemDamage(); - float r = 0.0f; - float g = 0.4F; - float b = 0.0f; - switch (meta) { - case 1: - r = 0.5F; - g = 0.37F; - b = 0.0F; - break; - case 2: - r = 0.27F; - g = 0.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 = 0.0F; - break; - case 5: - r = 0.0F; - g = 0.5F; - b = 0.1F; - break; - case 6: - r = 0.75F; - g = 0.0F; - b = 0.0F; - break; - case 7: - r = 0.0F; - g = 0.55F; - b = 0.55F; - break; - case 8: - r = 0.4F; - g = 0.1F; - b = 0.4F; - break; - } - return new Color(r, g, b); - } -} \ No newline at end of file + public boolean usesMana(ItemStack stack) { + return true; + } + + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 72000; + } + + public boolean isFull3D() { + return true; + } + + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } + + 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, 760, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } + + public ItemStack onItemRightClick(ItemStack rod, World world, EntityPlayer p) { + if (rod.getItemDamage() != 0) return rod; + ItemStack seed = null; + for (int i = 0; i < p.inventory.getSizeInventory(); i++) { + ItemStack slot = p.inventory.getStackInSlot(i); + if (slot == null) continue; + if (slot.getItem() == ModItems.grassSeeds) { + seed = slot; + break; + } + } + if (seed == null) return rod; + p.setItemInUse(rod, getMaxItemUseDuration(rod)); + return rod; + } + + public void onUsingTick(ItemStack stack, EntityPlayer p, int time) { + if (p.worldObj.isRemote) { + time = this.getMaxItemUseDuration(stack) - time; + if (time % 2 == 0 && time != 0) return; + ItemStack seed = null; + for (int i = 0; i < p.inventory.getSizeInventory(); i++) { + ItemStack slot = p.inventory.getStackInSlot(i); + if (slot == null) continue; + if (slot.getItem() == ModItems.grassSeeds) { + seed = slot; + break; + } + } + if (seed == null) return; + int ticks = Math.min(128, time); + float fTicks = ticks / 128.0f; + Vec3 look = p.getLookVec(); + double posX = p.posX + (look.xCoord * 1.4f) + ((Math.random() - 0.5f) * fTicks * 0.3f); + double posY = p.posY + (look.yCoord * 1.4f) + ((Math.random() - 0.5f) * fTicks * 0.3f); + double posZ = p.posZ + (look.zCoord * 1.4f) + ((Math.random() - 0.5f) * fTicks * 0.3f); + Color color = getSeedColor(seed); + Botania.proxy.wispFX( + p.worldObj, + posX, + posY, + posZ, + color.getRed() / 255.0f, + color.getGreen() / 255.0f, + color.getBlue() / 255.0f, + 0.5F * fTicks - (float) (Math.random() * 0.1f), + 0.0f, + 0.5F); + } + } + + public void onPlayerStoppedUsing(ItemStack rod, World world, EntityPlayer player, int lastTime) { + int useTime = getMaxItemUseDuration(rod) - lastTime; + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { + ItemStack stack = player.inventory.getStackInSlot(i); + if (stack == null) continue; + if (stack.getItem() == ModItems.grassSeeds) { + if (!world.isRemote) { + EntitySeed entitySeed = new EntitySeed(world, player); + entitySeed.setSeed(stack.copy()); + entitySeed + .setRadius((int) ((Math.min(useTime, 128.0f) / 128.0f) * ConfigABHandler.sprawlRodMaxArea)); + entitySeed.setAttacker(player.getCommandSenderName()); + world.spawnEntityInWorld(entitySeed); + } + if (stack.stackSize > 1) stack.stackSize--; + else player.inventory.setInventorySlotContents(i, null); + if (!player.capabilities.isCreativeMode) + rod.setItemDamage(Math.min(100, (int) (useTime / 128.0f * 100.0f))); + break; + } + } + } + + public static Color getSeedColor(ItemStack seed) { + int meta = seed.getItemDamage(); + float r = 0.0f; + float g = 0.4F; + float b = 0.0f; + switch (meta) { + case 1: + r = 0.5F; + g = 0.37F; + b = 0.0F; + break; + case 2: + r = 0.27F; + g = 0.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 = 0.0F; + break; + case 5: + r = 0.0F; + g = 0.5F; + b = 0.1F; + break; + case 6: + r = 0.75F; + g = 0.0F; + b = 0.0F; + break; + case 7: + r = 0.0F; + g = 0.55F; + b = 0.55F; + break; + case 8: + r = 0.4F; + g = 0.1F; + b = 0.4F; + break; + } + return new Color(r, g, b); + } +} diff --git a/src/main/java/ab/common/item/equipment/ItemTerraHoe.java b/src/main/java/ab/common/item/equipment/ItemTerraHoe.java index 9ea8635..69f5a16 100644 --- a/src/main/java/ab/common/item/equipment/ItemTerraHoe.java +++ b/src/main/java/ab/common/item/equipment/ItemTerraHoe.java @@ -1,9 +1,5 @@ package ab.common.item.equipment; -import ab.AdvancedBotany; -import ab.api.AdvancedBotanyAPI; -import ab.common.lib.register.BlockListAB; -import cpw.mods.fml.common.eventhandler.Event.Result; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; @@ -14,73 +10,103 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.UseHoeEvent; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.Botania; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.item.ModItems; +import ab.AdvancedBotany; +import ab.common.lib.register.BlockListAB; +import cpw.mods.fml.common.eventhandler.Event.Result; public class ItemTerraHoe extends ItemHoe implements IManaUsingItem { - public ItemTerraHoe() { - super(BotaniaAPI.terrasteelToolMaterial); - this.setCreativeTab(AdvancedBotany.tabAB); - this.setUnlocalizedName("terraHoe"); - this.setTextureName("ab:terraHoe"); - } - - public boolean onItemUse(ItemStack stack, EntityPlayer p, World world, int x, int y, int z, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { - if (!p.canPlayerEdit(x, y, z, p_77648_7_, stack)) { - return false; - } else { - UseHoeEvent event = new UseHoeEvent(p, stack, world, x, y, z); - if (MinecraftForge.EVENT_BUS.post(event)) { - return false; - } - if (event.getResult() == Result.ALLOW) { - stack.damageItem(1, p); - return true; - } - Block block = world.getBlock(x, y, z); - if (p_77648_7_ != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt)) { - Block block1 = BlockListAB.blockTerraFarmland; - world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F); - if (world.isRemote) { - float velMul = 0.025F; - for (int i = 0; i < 48; i++) { - double px = (Math.random() - 0.5D) * 3.0D; - double py = Math.random() - 0.5D + 1.0D; - double pz = (Math.random() - 0.5D) * 3.0D; - Botania.proxy.wispFX(world, x + 0.5D + px, y + 0.5D + py, z + 0.5D + pz, 0.0f, 0.4f, 0.0f, (float)Math.random() * 0.15F + 0.15F, (float)-px * velMul, (float)-py * velMul, (float)-pz * velMul); - } - return true; - } else { - world.setBlock(x, y, z, block1); - stack.damageItem(1, p); - return true; - } - } - else if(p.isSneaking() && p_77648_7_ != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == ModBlocks.enchantedSoil)) { - if (world.isRemote) - return true; - world.setBlock(x, y, z, Blocks.dirt); - stack.damageItem(1, p); - EntityItem entity = new EntityItem(world, x + 0.5f, y + 1, z + 0.5f, new ItemStack(ModItems.overgrowthSeed)); - world.spawnEntityInWorld(entity); - return true; - } else { - return false; - } - } - } + public ItemTerraHoe() { + super(BotaniaAPI.terrasteelToolMaterial); + this.setCreativeTab(AdvancedBotany.tabAB); + this.setUnlocalizedName("terraHoe"); + this.setTextureName("ab:terraHoe"); + } - 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, 1760, true)) - stack.setItemDamage(stack.getItemDamage() - 1); - } - - public boolean usesMana(ItemStack stack) { - return true; - } + public boolean onItemUse(ItemStack stack, EntityPlayer p, World world, int x, int y, int z, int p_77648_7_, + float p_77648_8_, float p_77648_9_, float p_77648_10_) { + if (!p.canPlayerEdit(x, y, z, p_77648_7_, stack)) { + return false; + } else { + UseHoeEvent event = new UseHoeEvent(p, stack, world, x, y, z); + if (MinecraftForge.EVENT_BUS.post(event)) { + return false; + } + if (event.getResult() == Result.ALLOW) { + stack.damageItem(1, p); + return true; + } + Block block = world.getBlock(x, y, z); + if (p_77648_7_ != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) + && (block == Blocks.grass || block == Blocks.dirt)) { + Block block1 = BlockListAB.blockTerraFarmland; + world.playSoundEffect( + (double) ((float) x + 0.5F), + (double) ((float) y + 0.5F), + (double) ((float) z + 0.5F), + block1.stepSound.getStepResourcePath(), + (block1.stepSound.getVolume() + 1.0F) / 2.0F, + block1.stepSound.getPitch() * 0.8F); + if (world.isRemote) { + float velMul = 0.025F; + for (int i = 0; i < 48; i++) { + double px = (Math.random() - 0.5D) * 3.0D; + double py = Math.random() - 0.5D + 1.0D; + double pz = (Math.random() - 0.5D) * 3.0D; + Botania.proxy.wispFX( + world, + x + 0.5D + px, + y + 0.5D + py, + z + 0.5D + pz, + 0.0f, + 0.4f, + 0.0f, + (float) Math.random() * 0.15F + 0.15F, + (float) -px * velMul, + (float) -py * velMul, + (float) -pz * velMul); + } + return true; + } else { + world.setBlock(x, y, z, block1); + stack.damageItem(1, p); + return true; + } + } else if (p.isSneaking() && p_77648_7_ != 0 + && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) + && (block == ModBlocks.enchantedSoil)) { + if (world.isRemote) return true; + world.setBlock(x, y, z, Blocks.dirt); + stack.damageItem(1, p); + EntityItem entity = new EntityItem( + world, + x + 0.5f, + y + 1, + z + 0.5f, + new ItemStack(ModItems.overgrowthSeed)); + world.spawnEntityInWorld(entity); + return true; + } else { + return false; + } + } + } + + 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, 1760, true)) + stack.setItemDamage(stack.getItemDamage() - 1); + } + + public boolean usesMana(ItemStack stack) { + return true; + } } diff --git a/src/main/java/ab/common/item/equipment/armor/ItemNebulaArmor.java b/src/main/java/ab/common/item/equipment/armor/ItemNebulaArmor.java index 562520f..b9708fe 100644 --- a/src/main/java/ab/common/item/equipment/armor/ItemNebulaArmor.java +++ b/src/main/java/ab/common/item/equipment/armor/ItemNebulaArmor.java @@ -2,13 +2,6 @@ package ab.common.item.equipment.armor; import java.util.List; -import ab.AdvancedBotany; -import ab.api.AdvancedBotanyAPI; -import ab.client.model.armor.ModelArmorNebula; -import ab.common.core.handler.ConfigABHandler; -import ab.common.lib.register.ItemListAB; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; @@ -21,148 +14,161 @@ import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.common.ISpecialArmor; -import vazkii.botania.api.BotaniaAPI; + import vazkii.botania.api.mana.IManaItem; import vazkii.botania.api.mana.IManaTooltipDisplay; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.item.equipment.armor.manasteel.ItemManasteelArmor; +import ab.AdvancedBotany; +import ab.api.AdvancedBotanyAPI; +import ab.client.model.armor.ModelArmorNebula; +import ab.common.lib.register.ItemListAB; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemNebulaArmor extends ItemManasteelArmor implements IManaItem, IManaTooltipDisplay { - - protected static final int MAX_MANA = 250000; - private static final String TAG_MANA = "mana"; - - static ItemStack[] armorset; - public static IIcon nebulaEyes; - public ItemNebulaArmor(int type, String name) { - super(type, name, AdvancedBotanyAPI.nebulaArmorMaterial); - this.setCreativeTab(AdvancedBotany.tabAB); - this.setMaxDamage(1000); - this.setNoRepair(); - } - - public EnumRarity getRarity(ItemStack stack) { - return AdvancedBotanyAPI.rarityNebula; - } - - public ISpecialArmor.ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { - return new ISpecialArmor.ArmorProperties(0, getArmorMaterial().getDamageReductionAmount(slot) * (0.03f + (0.0725D * (1.0f - (this.getDamage(armor) / 1000.0f)))), 2147483647); - } - - @SideOnly(Side.CLIENT) - public ModelBiped provideArmorModelForSlot(ItemStack stack, int slot) { - this.models[slot] = new ModelArmorNebula(slot); - return this.models[slot]; - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister ir) { - this.itemIcon = ir.registerIcon("ab:" + this.getUnlocalizedName().replaceAll("item\\.", "")); - this.nebulaEyes = ir.registerIcon("ab:nebulaEyes"); - } - - public String getArmorTextureAfterInk(ItemStack stack, int slot) { - return "ab:textures/model/nebulaArmor.png"; - } - - public ItemStack[] getArmorSetStacks() { - if(armorset == null) - armorset = new ItemStack[] { new ItemStack(ItemListAB.itemNebulaHelm), new ItemStack(ItemListAB.itemNebulaChest), new ItemStack(ItemListAB.itemNebulaLegs), new ItemStack(ItemListAB.itemNebulaBoots) }; - return armorset; - } - - 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() == ItemListAB.itemNebulaHelm || stack.getItem() == ItemListAB.itemNebulaHelmReveal); - case 1: - return (stack.getItem() == ItemListAB.itemNebulaChest); - case 2: - return (stack.getItem() == ItemListAB.itemNebulaLegs); - case 3: - return (stack.getItem() == ItemListAB.itemNebulaBoots); - } - return false; - } + protected static final int MAX_MANA = 250000; + private static final String TAG_MANA = "mana"; - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { - int manaVal = Math.min(damage * 15, this.getMana(stack)); - if(entity instanceof EntityPlayer && !entity.worldObj.isRemote) - if(!ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer)entity, manaVal, true)) - this.addMana(stack, -manaVal); - } - - public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { - if(!world.isRemote && this.getMana(stack) != this.getMaxMana(stack) && ManaItemHandler.requestManaExactForTool(stack, player, 1000, true)) - this.addMana(stack, 1000); - } - - public void addArmorSetDescription(ItemStack stack, List list) { - addStringToTooltip(StatCollector.translateToLocal("ab.armorset.nebula.desc0"), list); - addStringToTooltip(StatCollector.translateToLocal("botania.armorset.terrasteel.desc1"), list); - addStringToTooltip(StatCollector.translateToLocal("botania.armorset.terrasteel.desc2"), list); - } - - public int getDamage(ItemStack stack) { - float mana = getMana(stack); - return 1000 - (int)(mana / getMaxMana(stack) * 1000.0F); - } - - public int getDisplayDamage(ItemStack stack) { - return getDamage(stack); - } - - public static String playerStr(EntityPlayer player) { - return player.getGameProfile().getName() + ":" + player.worldObj.isRemote; - } - - public String getArmorSetName() { - return StatCollector.translateToLocal("ab.armorset.nebula.name"); - } - - public float getManaFractionForDisplay(ItemStack stack) { - return (float) getMana(stack) / (float) getMaxMana(stack); - } - - public static void setMana(ItemStack stack, int mana) { - ItemNBTHelper.setInt(stack, TAG_MANA, mana); - } + static ItemStack[] armorset; + public static IIcon nebulaEyes; - public void addMana(ItemStack stack, int mana) { - setMana(stack, Math.min(getMana(stack) + mana, getMaxMana(stack))); - stack.setItemDamage(getDamage(stack)); - } + public ItemNebulaArmor(int type, String name) { + super(type, name, AdvancedBotanyAPI.nebulaArmorMaterial); + this.setCreativeTab(AdvancedBotany.tabAB); + this.setMaxDamage(1000); + this.setNoRepair(); + } - public boolean canExportManaToItem(ItemStack stack, ItemStack stack1) { - return false; - } + public EnumRarity getRarity(ItemStack stack) { + return AdvancedBotanyAPI.rarityNebula; + } - public boolean canExportManaToPool(ItemStack arg0, TileEntity arg1) { - return false; - } + public ISpecialArmor.ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, + double damage, int slot) { + return new ISpecialArmor.ArmorProperties( + 0, + getArmorMaterial().getDamageReductionAmount(slot) + * (0.03f + (0.0725D * (1.0f - (this.getDamage(armor) / 1000.0f)))), + 2147483647); + } - public boolean canReceiveManaFromItem(ItemStack arg0, ItemStack arg1) { - return true; - } + @SideOnly(Side.CLIENT) + public ModelBiped provideArmorModelForSlot(ItemStack stack, int slot) { + this.models[slot] = new ModelArmorNebula(slot); + return this.models[slot]; + } - public boolean canReceiveManaFromPool(ItemStack arg0, TileEntity arg1) { - return true; - } + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister ir) { + this.itemIcon = ir.registerIcon("ab:" + this.getUnlocalizedName().replaceAll("item\\.", "")); + this.nebulaEyes = ir.registerIcon("ab:nebulaEyes"); + } - public int getMana(ItemStack stack) { - return ItemNBTHelper.getInt(stack, TAG_MANA, 0); - } + public String getArmorTextureAfterInk(ItemStack stack, int slot) { + return "ab:textures/model/nebulaArmor.png"; + } - public int getMaxMana(ItemStack arg0) { - return MAX_MANA; - } + public ItemStack[] getArmorSetStacks() { + if (armorset == null) armorset = new ItemStack[] { new ItemStack(ItemListAB.itemNebulaHelm), + new ItemStack(ItemListAB.itemNebulaChest), new ItemStack(ItemListAB.itemNebulaLegs), + new ItemStack(ItemListAB.itemNebulaBoots) }; + return armorset; + } - public boolean isNoExport(ItemStack arg0) { - return true; - } -} \ No newline at end of file + 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() == ItemListAB.itemNebulaHelm + || stack.getItem() == ItemListAB.itemNebulaHelmReveal); + case 1: + return (stack.getItem() == ItemListAB.itemNebulaChest); + case 2: + return (stack.getItem() == ItemListAB.itemNebulaLegs); + case 3: + return (stack.getItem() == ItemListAB.itemNebulaBoots); + } + return false; + } + + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { + int manaVal = Math.min(damage * 15, this.getMana(stack)); + if (entity instanceof EntityPlayer && !entity.worldObj.isRemote) + if (!ManaItemHandler.requestManaExactForTool(stack, (EntityPlayer) entity, manaVal, true)) + this.addMana(stack, -manaVal); + } + + public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { + if (!world.isRemote && this.getMana(stack) != this.getMaxMana(stack) + && ManaItemHandler.requestManaExactForTool(stack, player, 1000, true)) + this.addMana(stack, 1000); + } + + public void addArmorSetDescription(ItemStack stack, List list) { + addStringToTooltip(StatCollector.translateToLocal("ab.armorset.nebula.desc0"), list); + addStringToTooltip(StatCollector.translateToLocal("botania.armorset.terrasteel.desc1"), list); + addStringToTooltip(StatCollector.translateToLocal("botania.armorset.terrasteel.desc2"), list); + } + + public int getDamage(ItemStack stack) { + float mana = getMana(stack); + return 1000 - (int) (mana / getMaxMana(stack) * 1000.0F); + } + + public int getDisplayDamage(ItemStack stack) { + return getDamage(stack); + } + + public static String playerStr(EntityPlayer player) { + return player.getGameProfile().getName() + ":" + player.worldObj.isRemote; + } + + public String getArmorSetName() { + return StatCollector.translateToLocal("ab.armorset.nebula.name"); + } + + public float getManaFractionForDisplay(ItemStack stack) { + return (float) getMana(stack) / (float) getMaxMana(stack); + } + + public static void setMana(ItemStack stack, int mana) { + ItemNBTHelper.setInt(stack, TAG_MANA, mana); + } + + public void addMana(ItemStack stack, int mana) { + setMana(stack, Math.min(getMana(stack) + mana, getMaxMana(stack))); + stack.setItemDamage(getDamage(stack)); + } + + public boolean canExportManaToItem(ItemStack stack, ItemStack stack1) { + return false; + } + + public boolean canExportManaToPool(ItemStack arg0, TileEntity arg1) { + return false; + } + + public boolean canReceiveManaFromItem(ItemStack arg0, ItemStack arg1) { + return true; + } + + public boolean canReceiveManaFromPool(ItemStack arg0, TileEntity arg1) { + return true; + } + + public int getMana(ItemStack stack) { + return ItemNBTHelper.getInt(stack, TAG_MANA, 0); + } + + public int getMaxMana(ItemStack arg0) { + return MAX_MANA; + } + + public boolean isNoExport(ItemStack arg0) { + return true; + } +} diff --git a/src/main/java/ab/common/item/equipment/armor/ItemNebulaBoots.java b/src/main/java/ab/common/item/equipment/armor/ItemNebulaBoots.java index d77d549..9124bbe 100644 --- a/src/main/java/ab/common/item/equipment/armor/ItemNebulaBoots.java +++ b/src/main/java/ab/common/item/equipment/armor/ItemNebulaBoots.java @@ -2,78 +2,83 @@ package ab.common.item.equipment.armor; import java.util.ArrayList; import java.util.List; -import java.util.UUID; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingEvent; + import vazkii.botania.common.Botania; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class ItemNebulaBoots extends ItemNebulaArmor { - - private static final float MAX_SPEED = 0.275f; - public static List playersWithStepup = new ArrayList(); - public ItemNebulaBoots() { - super(3, "nebulaBoots"); - MinecraftForge.EVENT_BUS.register(this); - } - - public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { - super.onArmorTick(world, player, stack); - if(world.isRemote && player.getCurrentArmor(0) != null && player.getCurrentArmor(0).getItem() instanceof ItemNebulaBoots && player.isSprinting()) { - float w = 0.6F; - float c = 1.0F - w; - float r = w + (float)Math.random() * c; - float g = w + (float)Math.random() * c; - float b = w + (float)Math.random() * c; - for(int i = 0; i < 2; i++) - Botania.proxy.sparkleFX(world, player.posX + (Math.random() - 0.5f), player.posY - 1.25f + (Math.random() / 4 - 0.125f), player.posZ + (Math.random() - 0.5f), r, g, b, (float)(0.7f + (Math.random() / 2)), 25); - } - } - - @SubscribeEvent - public void updatePlayerStepStatus(LivingEvent.LivingUpdateEvent event) { - if(event.entityLiving instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer)event.entityLiving; - ItemStack armor = player.getCurrentArmor(0); - String s = playerStr(player); - if(playersWithStepup.contains(s)) { - if(shouldPlayerHaveStepup(player)) { - if((player.onGround || player.capabilities.isFlying) && player.moveForward > 0.0F) { - float speed = getSpeed(armor) * (player.isSprinting() ? 1.0f : 0.2f); - player.moveFlying(0.0F, 1.0F, player.capabilities.isFlying ? speed * 0.6f : speed); - } - if(player.isSneaking()) { - player.stepHeight = 0.50001F; - } else { - player.stepHeight = 1.0F; - } - } else { - player.stepHeight = 0.5F; - playersWithStepup.remove(s); - } - } else if(shouldPlayerHaveStepup(player)) { - playersWithStepup.add(s); - player.stepHeight = 1.0F; - } - } - } - - private boolean shouldPlayerHaveStepup(EntityPlayer player) { - ItemStack armor = player.getCurrentArmor(0); - return (armor != null && armor.getItem() instanceof ItemNebulaBoots); - } - - private float getSpeed(ItemStack stack) { - return MAX_SPEED * (1.0f - (this.getDamage(stack) / 1000.0f)); - } + private static final float MAX_SPEED = 0.275f; + public static List playersWithStepup = new ArrayList(); + + public ItemNebulaBoots() { + super(3, "nebulaBoots"); + MinecraftForge.EVENT_BUS.register(this); + } + + public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { + super.onArmorTick(world, player, stack); + if (world.isRemote && player.getCurrentArmor(0) != null + && player.getCurrentArmor(0).getItem() instanceof ItemNebulaBoots + && player.isSprinting()) { + float w = 0.6F; + float c = 1.0F - w; + float r = w + (float) Math.random() * c; + float g = w + (float) Math.random() * c; + float b = w + (float) Math.random() * c; + for (int i = 0; i < 2; i++) Botania.proxy.sparkleFX( + world, + player.posX + (Math.random() - 0.5f), + player.posY - 1.25f + (Math.random() / 4 - 0.125f), + player.posZ + (Math.random() - 0.5f), + r, + g, + b, + (float) (0.7f + (Math.random() / 2)), + 25); + } + } + + @SubscribeEvent + public void updatePlayerStepStatus(LivingEvent.LivingUpdateEvent event) { + if (event.entityLiving instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.entityLiving; + ItemStack armor = player.getCurrentArmor(0); + String s = playerStr(player); + if (playersWithStepup.contains(s)) { + if (shouldPlayerHaveStepup(player)) { + if ((player.onGround || player.capabilities.isFlying) && player.moveForward > 0.0F) { + float speed = getSpeed(armor) * (player.isSprinting() ? 1.0f : 0.2f); + player.moveFlying(0.0F, 1.0F, player.capabilities.isFlying ? speed * 0.6f : speed); + } + if (player.isSneaking()) { + player.stepHeight = 0.50001F; + } else { + player.stepHeight = 1.0F; + } + } else { + player.stepHeight = 0.5F; + playersWithStepup.remove(s); + } + } else if (shouldPlayerHaveStepup(player)) { + playersWithStepup.add(s); + player.stepHeight = 1.0F; + } + } + } + + private boolean shouldPlayerHaveStepup(EntityPlayer player) { + ItemStack armor = player.getCurrentArmor(0); + return (armor != null && armor.getItem() instanceof ItemNebulaBoots); + } + + private float getSpeed(ItemStack stack) { + return MAX_SPEED * (1.0f - (this.getDamage(stack) / 1000.0f)); + } } diff --git a/src/main/java/ab/common/item/equipment/armor/ItemNebulaChest.java b/src/main/java/ab/common/item/equipment/armor/ItemNebulaChest.java index a8cb6f2..7108c53 100644 --- a/src/main/java/ab/common/item/equipment/armor/ItemNebulaChest.java +++ b/src/main/java/ab/common/item/equipment/armor/ItemNebulaChest.java @@ -4,11 +4,6 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - -import ab.common.lib.register.ItemListAB; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; @@ -16,46 +11,56 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingEvent; -public class ItemNebulaChest extends ItemNebulaArmor { - - public static List playersWithFlight = new ArrayList(); +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; - public ItemNebulaChest() { - super(1, "nebulaChest"); - MinecraftForge.EVENT_BUS.register(this); - } - - public Multimap getAttributeModifiers(ItemStack stack) { - HashMultimap hashMultimap = HashMultimap.create(); - UUID uuid = new UUID(getUnlocalizedName().hashCode(), 0L); - hashMultimap.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), new AttributeModifier(uuid, "NebulaChest modifier", 1.0D * (1.0f - (this.getDamage(stack) / 1000.0f)), 0)); - return (Multimap)hashMultimap; - } - - @SubscribeEvent - public void updatePlayerFlyStatus(LivingEvent.LivingUpdateEvent event) { - if(event.entityLiving instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer)event.entityLiving; - if(playersWithFlight.contains(playerStr(player))) { - if(shouldPlayerHaveFlight(player)) { - player.capabilities.allowFlying = true; - } 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; - } - } - } - - private static boolean shouldPlayerHaveFlight(EntityPlayer player) { - ItemStack armor = player.getCurrentArmor(2); - return (armor != null && armor.getItem() instanceof ItemNebulaChest); - } -} \ No newline at end of file +public class ItemNebulaChest extends ItemNebulaArmor { + + public static List playersWithFlight = new ArrayList(); + + public ItemNebulaChest() { + super(1, "nebulaChest"); + MinecraftForge.EVENT_BUS.register(this); + } + + public Multimap getAttributeModifiers(ItemStack stack) { + HashMultimap hashMultimap = HashMultimap.create(); + UUID uuid = new UUID(getUnlocalizedName().hashCode(), 0L); + hashMultimap.put( + SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), + new AttributeModifier( + uuid, + "NebulaChest modifier", + 1.0D * (1.0f - (this.getDamage(stack) / 1000.0f)), + 0)); + return (Multimap) hashMultimap; + } + + @SubscribeEvent + public void updatePlayerFlyStatus(LivingEvent.LivingUpdateEvent event) { + if (event.entityLiving instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.entityLiving; + if (playersWithFlight.contains(playerStr(player))) { + if (shouldPlayerHaveFlight(player)) { + player.capabilities.allowFlying = true; + } 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; + } + } + } + + private static boolean shouldPlayerHaveFlight(EntityPlayer player) { + ItemStack armor = player.getCurrentArmor(2); + return (armor != null && armor.getItem() instanceof ItemNebulaChest); + } +} diff --git a/src/main/java/ab/common/item/equipment/armor/ItemNebulaHelm.java b/src/main/java/ab/common/item/equipment/armor/ItemNebulaHelm.java index 339f746..663c978 100644 --- a/src/main/java/ab/common/item/equipment/armor/ItemNebulaHelm.java +++ b/src/main/java/ab/common/item/equipment/armor/ItemNebulaHelm.java @@ -3,9 +3,6 @@ package ab.common.item.equipment.armor; import java.util.List; import java.util.UUID; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; @@ -16,94 +13,96 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.World; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.mana.IManaDiscountArmor; import vazkii.botania.api.mana.IManaGivingItem; import vazkii.botania.api.mana.IManaItem; -import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; + public class ItemNebulaHelm extends ItemNebulaArmor implements IManaDiscountArmor, IManaGivingItem { - private static final String TAG_COSMIC_FACE = "enableCosmicFace"; - - public ItemNebulaHelm() { - this("nebulaHelm"); - } - - public ItemNebulaHelm(String str) { - super(0, str); - } - - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if(player.isSneaking()) - setCosmicFace(stack, !enableCosmicFace(stack)); - else - super.onItemRightClick(stack, world, player); - return stack; - } - - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { - super.addInformation(stack, player, list, adv); - if(!GuiScreen.isShiftKeyDown() && !enableCosmicFace(stack)) - addStringToTooltip(EnumChatFormatting.GREEN + StatCollector.translateToLocal("ab.nebulaHelm.mask"), list); - } - - public boolean enableCosmicFace(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, TAG_COSMIC_FACE, true); - } - - public void setCosmicFace(ItemStack stack, boolean enable) { - ItemNBTHelper.setBoolean(stack, TAG_COSMIC_FACE, enable); - } - - 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(1.0F); - dispatchManaExact(stack, player, 2, true); - } - } - - public static boolean dispatchManaExact(ItemStack stack, EntityPlayer player, int manaToSend, boolean add) { - if (stack == null) - return false; - InventoryPlayer inventoryPlayer = player.inventory; - IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); - int invSize = inventoryPlayer.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 : (IInventory)inventoryPlayer; - int slot = i - (useBaubles ? invSize : 0); - ItemStack stackInSlot = inv.getStackInSlot(slot); - if(stackInSlot != stack) - 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(add) - manaItemSlot.addMana(stackInSlot, manaToSend); - if(useBaubles) - BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot); - return true; - } - } - } - return false; - } - - public float getDiscount(ItemStack stack, int slot, EntityPlayer player) { - return hasArmorSet(player) ? 0.30F : 0.0F; - } - - public Multimap getAttributeModifiers(ItemStack stack) { - HashMultimap hashMultimap = HashMultimap.create(); - UUID uuid = new UUID(getUnlocalizedName().hashCode(), 0L); - hashMultimap.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(uuid, "NebulaHelm modifier", 20.0D * (1.0f - (this.getDamage(stack) / 1000.0f)), 0)); - return (Multimap)hashMultimap; - } + private static final String TAG_COSMIC_FACE = "enableCosmicFace"; + + public ItemNebulaHelm() { + this("nebulaHelm"); + } + + public ItemNebulaHelm(String str) { + super(0, str); + } + + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (player.isSneaking()) setCosmicFace(stack, !enableCosmicFace(stack)); + else super.onItemRightClick(stack, world, player); + return stack; + } + + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { + super.addInformation(stack, player, list, adv); + if (!GuiScreen.isShiftKeyDown() && !enableCosmicFace(stack)) + addStringToTooltip(EnumChatFormatting.GREEN + StatCollector.translateToLocal("ab.nebulaHelm.mask"), list); + } + + public boolean enableCosmicFace(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, TAG_COSMIC_FACE, true); + } + + public void setCosmicFace(ItemStack stack, boolean enable) { + ItemNBTHelper.setBoolean(stack, TAG_COSMIC_FACE, enable); + } + + 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(1.0F); + dispatchManaExact(stack, player, 2, true); + } + } + + public static boolean dispatchManaExact(ItemStack stack, EntityPlayer player, int manaToSend, boolean add) { + if (stack == null) return false; + InventoryPlayer inventoryPlayer = player.inventory; + IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player); + int invSize = inventoryPlayer.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 : (IInventory) inventoryPlayer; + int slot = i - (useBaubles ? invSize : 0); + ItemStack stackInSlot = inv.getStackInSlot(slot); + if (stackInSlot != stack) 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 (add) manaItemSlot.addMana(stackInSlot, manaToSend); + if (useBaubles) BotaniaAPI.internalHandler.sendBaubleUpdatePacket(player, slot); + return true; + } + } + } + return false; + } + + public float getDiscount(ItemStack stack, int slot, EntityPlayer player) { + return hasArmorSet(player) ? 0.30F : 0.0F; + } + + public Multimap getAttributeModifiers(ItemStack stack) { + HashMultimap hashMultimap = HashMultimap.create(); + UUID uuid = new UUID(getUnlocalizedName().hashCode(), 0L); + hashMultimap.put( + SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), + new AttributeModifier( + uuid, + "NebulaHelm modifier", + 20.0D * (1.0f - (this.getDamage(stack) / 1000.0f)), + 0)); + return (Multimap) hashMultimap; + } } diff --git a/src/main/java/ab/common/item/equipment/armor/ItemNebulaHelmRevealing.java b/src/main/java/ab/common/item/equipment/armor/ItemNebulaHelmRevealing.java index fd76755..2f50f26 100644 --- a/src/main/java/ab/common/item/equipment/armor/ItemNebulaHelmRevealing.java +++ b/src/main/java/ab/common/item/equipment/armor/ItemNebulaHelmRevealing.java @@ -1,24 +1,26 @@ package ab.common.item.equipment.armor; -import cpw.mods.fml.common.Optional.Interface; -import cpw.mods.fml.common.Optional.InterfaceList; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; + import thaumcraft.api.IGoggles; import thaumcraft.api.nodes.IRevealer; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; -@InterfaceList({@Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IGoggles", striprefs = true), @Interface(modid = "Thaumcraft", iface = "thaumcraft.api.nodes.IRevealer", striprefs = true)}) +@InterfaceList({ @Interface(modid = "Thaumcraft", iface = "thaumcraft.api.IGoggles", striprefs = true), + @Interface(modid = "Thaumcraft", iface = "thaumcraft.api.nodes.IRevealer", striprefs = true) }) public class ItemNebulaHelmRevealing extends ItemNebulaHelm implements IGoggles, IRevealer { - public ItemNebulaHelmRevealing() { - super("nebulaHelmRevealing"); - } - - public boolean showNodes(ItemStack itemstack, EntityLivingBase player) { - return true; - } - - public boolean showIngamePopups(ItemStack itemstack, EntityLivingBase player) { - return true; - } + public ItemNebulaHelmRevealing() { + super("nebulaHelmRevealing"); + } + + public boolean showNodes(ItemStack itemstack, EntityLivingBase player) { + return true; + } + + public boolean showIngamePopups(ItemStack itemstack, EntityLivingBase player) { + return true; + } } diff --git a/src/main/java/ab/common/item/equipment/armor/ItemNebulaLegs.java b/src/main/java/ab/common/item/equipment/armor/ItemNebulaLegs.java index 3b253fa..0b57239 100644 --- a/src/main/java/ab/common/item/equipment/armor/ItemNebulaLegs.java +++ b/src/main/java/ab/common/item/equipment/armor/ItemNebulaLegs.java @@ -1,44 +1,36 @@ package ab.common.item.equipment.armor; -import java.util.UUID; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingEvent; -import vazkii.botania.common.Botania; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class ItemNebulaLegs extends ItemNebulaArmor { - public ItemNebulaLegs() { - super(2, "nebulaLegs"); - MinecraftForge.EVENT_BUS.register(this); - } + public ItemNebulaLegs() { + super(2, "nebulaLegs"); + MinecraftForge.EVENT_BUS.register(this); + } - @SubscribeEvent - public void onPlayerJump(LivingEvent.LivingJumpEvent event) { - if (event.entityLiving instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer)event.entityLiving; - ItemStack legs = player.getCurrentArmor(1); - if (legs != null && legs.getItem() instanceof ItemNebulaLegs) { - player.motionY += getJump(legs); - player.fallDistance = -getFallBuffer(legs); - } - } - } - - private float getJump(ItemStack stack) { - return 0.3f * (1.0f - (this.getDamage(stack) / 1000.0f)); - } - - private float getFallBuffer(ItemStack stack) { - return 12.0f * (1.0f - (this.getDamage(stack) / 1000.0f)); - } + @SubscribeEvent + public void onPlayerJump(LivingEvent.LivingJumpEvent event) { + if (event.entityLiving instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.entityLiving; + ItemStack legs = player.getCurrentArmor(1); + if (legs != null && legs.getItem() instanceof ItemNebulaLegs) { + player.motionY += getJump(legs); + player.fallDistance = -getFallBuffer(legs); + } + } + } + + private float getJump(ItemStack stack) { + return 0.3f * (1.0f - (this.getDamage(stack) / 1000.0f)); + } + + private float getFallBuffer(ItemStack stack) { + return 12.0f * (1.0f - (this.getDamage(stack) / 1000.0f)); + } } diff --git a/src/main/java/ab/common/item/equipment/armor/ItemWildHuntArmor.java b/src/main/java/ab/common/item/equipment/armor/ItemWildHuntArmor.java index 1f49c3d..da0aef9 100644 --- a/src/main/java/ab/common/item/equipment/armor/ItemWildHuntArmor.java +++ b/src/main/java/ab/common/item/equipment/armor/ItemWildHuntArmor.java @@ -2,74 +2,75 @@ package ab.common.item.equipment.armor; import java.util.List; -import ab.AdvancedBotany; -import ab.api.AdvancedBotanyAPI; -import ab.client.model.armor.ModelArmorWildHunt; -import ab.common.lib.register.ItemListAB; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; + import vazkii.botania.common.item.equipment.armor.manasteel.ItemManasteelArmor; +import ab.AdvancedBotany; +import ab.api.AdvancedBotanyAPI; +import ab.client.model.armor.ModelArmorWildHunt; +import ab.common.lib.register.ItemListAB; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemWildHuntArmor extends ItemManasteelArmor { - - static ItemStack[] armorset; - public ItemWildHuntArmor(int type, String name) { - super(type, name, AdvancedBotanyAPI.wildHundArmor); - this.setCreativeTab(AdvancedBotany.tabAB); - } - - public EnumRarity getRarity(ItemStack stack) { - return AdvancedBotanyAPI.rarityWildHunt; - } - - public ItemStack[] getArmorSetStacks() { - if(armorset == null) - armorset = new ItemStack[] { new ItemStack(ItemListAB.itemWildHuntHelm), new ItemStack(ItemListAB.itemWildHuntChest), new ItemStack(ItemListAB.itemWildHuntLegs), new ItemStack(ItemListAB.itemWildHuntBoots) }; - return armorset; - } - - 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() == ItemListAB.itemWildHuntHelm); - case 1: - return (stack.getItem() == ItemListAB.itemWildHuntChest); - case 2: - return (stack.getItem() == ItemListAB.itemWildHuntLegs); - case 3: - return (stack.getItem() == ItemListAB.itemWildHuntBoots); - } - return false; - } - - @SideOnly(Side.CLIENT) - public ModelBiped provideArmorModelForSlot(ItemStack stack, int slot) { - this.models[slot] = new ModelArmorWildHunt(slot); - return this.models[slot]; - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister ir) { - this.itemIcon = ir.registerIcon("ab:" + this.getUnlocalizedName().replaceAll("item\\.", "")); - } - - public String getArmorTextureAfterInk(ItemStack stack, int slot) { - return "ab:textures/model/wildHuntArmor.png"; - } - - public void addArmorSetDescription(ItemStack stack, List list) { - addStringToTooltip(StatCollector.translateToLocal("ab.armorset.wildHunt.desc0"), list); - addStringToTooltip(StatCollector.translateToLocal("ab.armorset.wildHunt.desc1"), list); - addStringToTooltip(StatCollector.translateToLocal("ab.armorset.wildHunt.desc2"), list); - } -} \ No newline at end of file + static ItemStack[] armorset; + + public ItemWildHuntArmor(int type, String name) { + super(type, name, AdvancedBotanyAPI.wildHundArmor); + this.setCreativeTab(AdvancedBotany.tabAB); + } + + public EnumRarity getRarity(ItemStack stack) { + return AdvancedBotanyAPI.rarityWildHunt; + } + + public ItemStack[] getArmorSetStacks() { + if (armorset == null) armorset = new ItemStack[] { new ItemStack(ItemListAB.itemWildHuntHelm), + new ItemStack(ItemListAB.itemWildHuntChest), new ItemStack(ItemListAB.itemWildHuntLegs), + new ItemStack(ItemListAB.itemWildHuntBoots) }; + return armorset; + } + + 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() == ItemListAB.itemWildHuntHelm); + case 1: + return (stack.getItem() == ItemListAB.itemWildHuntChest); + case 2: + return (stack.getItem() == ItemListAB.itemWildHuntLegs); + case 3: + return (stack.getItem() == ItemListAB.itemWildHuntBoots); + } + return false; + } + + @SideOnly(Side.CLIENT) + public ModelBiped provideArmorModelForSlot(ItemStack stack, int slot) { + this.models[slot] = new ModelArmorWildHunt(slot); + return this.models[slot]; + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister ir) { + this.itemIcon = ir.registerIcon("ab:" + this.getUnlocalizedName().replaceAll("item\\.", "")); + } + + public String getArmorTextureAfterInk(ItemStack stack, int slot) { + return "ab:textures/model/wildHuntArmor.png"; + } + + public void addArmorSetDescription(ItemStack stack, List list) { + addStringToTooltip(StatCollector.translateToLocal("ab.armorset.wildHunt.desc0"), list); + addStringToTooltip(StatCollector.translateToLocal("ab.armorset.wildHunt.desc1"), list); + addStringToTooltip(StatCollector.translateToLocal("ab.armorset.wildHunt.desc2"), list); + } +} diff --git a/src/main/java/ab/common/item/equipment/armor/ItemWildHuntBoots.java b/src/main/java/ab/common/item/equipment/armor/ItemWildHuntBoots.java index d383175..deecab3 100644 --- a/src/main/java/ab/common/item/equipment/armor/ItemWildHuntBoots.java +++ b/src/main/java/ab/common/item/equipment/armor/ItemWildHuntBoots.java @@ -2,7 +2,7 @@ package ab.common.item.equipment.armor; public class ItemWildHuntBoots extends ItemWildHuntArmor { - public ItemWildHuntBoots() { - super(3, "wildHuntBoots"); - } + public ItemWildHuntBoots() { + super(3, "wildHuntBoots"); + } } diff --git a/src/main/java/ab/common/item/equipment/armor/ItemWildHuntChest.java b/src/main/java/ab/common/item/equipment/armor/ItemWildHuntChest.java index ae4ae66..a2a2ac3 100644 --- a/src/main/java/ab/common/item/equipment/armor/ItemWildHuntChest.java +++ b/src/main/java/ab/common/item/equipment/armor/ItemWildHuntChest.java @@ -2,7 +2,7 @@ package ab.common.item.equipment.armor; public class ItemWildHuntChest extends ItemWildHuntArmor { - public ItemWildHuntChest() { - super(1, "wildHuntChest"); - } -} \ No newline at end of file + public ItemWildHuntChest() { + super(1, "wildHuntChest"); + } +} diff --git a/src/main/java/ab/common/item/equipment/armor/ItemWildHuntHelm.java b/src/main/java/ab/common/item/equipment/armor/ItemWildHuntHelm.java index 3944445..90a9f3e 100644 --- a/src/main/java/ab/common/item/equipment/armor/ItemWildHuntHelm.java +++ b/src/main/java/ab/common/item/equipment/armor/ItemWildHuntHelm.java @@ -2,7 +2,7 @@ package ab.common.item.equipment.armor; public class ItemWildHuntHelm extends ItemWildHuntArmor { - public ItemWildHuntHelm() { - super(0, "wildHuntHelm"); - } -} \ No newline at end of file + public ItemWildHuntHelm() { + super(0, "wildHuntHelm"); + } +} diff --git a/src/main/java/ab/common/item/equipment/armor/ItemWildHuntLegs.java b/src/main/java/ab/common/item/equipment/armor/ItemWildHuntLegs.java index 3bd9737..42cbabf 100644 --- a/src/main/java/ab/common/item/equipment/armor/ItemWildHuntLegs.java +++ b/src/main/java/ab/common/item/equipment/armor/ItemWildHuntLegs.java @@ -2,7 +2,7 @@ package ab.common.item.equipment.armor; public class ItemWildHuntLegs extends ItemWildHuntArmor { - public ItemWildHuntLegs() { - super(2, "wildHuntLegs"); - } -} \ No newline at end of file + public ItemWildHuntLegs() { + super(2, "wildHuntLegs"); + } +} diff --git a/src/main/java/ab/common/item/relic/ItemFreyrSlingshot.java b/src/main/java/ab/common/item/relic/ItemFreyrSlingshot.java index 65209de..7451e1b 100644 --- a/src/main/java/ab/common/item/relic/ItemFreyrSlingshot.java +++ b/src/main/java/ab/common/item/relic/ItemFreyrSlingshot.java @@ -1,75 +1,59 @@ package ab.common.item.relic; -import java.util.List; - -import ab.AdvancedBotany; -import ab.common.entity.EntityManaVine; -import ab.common.item.ItemMod; -import net.minecraft.client.particle.EntityFX; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.stats.Achievement; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; -import vazkii.botania.api.mana.IManaItem; -import vazkii.botania.api.mana.IManaTooltipDisplay; + import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; -import vazkii.botania.common.achievement.AchievementMod; -import vazkii.botania.common.core.helper.ItemNBTHelper; +import ab.common.entity.EntityManaVine; public class ItemFreyrSlingshot extends ItemModRelic implements IManaUsingItem { - protected static final int MAX_MANA = 50000; + protected static final int MAX_MANA = 50000; - private static final String TAG_MANA = "mana"; + private static final String TAG_MANA = "mana"; - public ItemFreyrSlingshot() { - super("freyrSlingshot"); - } - - public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int par4) { - int j = getMaxItemUseDuration(stack) - par4; - float f = j / 20.0F; - f = (f * f + f * 2.0F) / 3.0F; - if(f < 1.0F) - return; - if(!world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, 5000, true)) { - EntityManaVine ball = new EntityManaVine(world, player); - ball.motionX *= 0.9D; - ball.motionY *= 0.9D; - ball.motionZ *= 0.9D; - ball.setAttacker(player.getCommandSenderName()); - world.spawnEntityInWorld(ball); - player.worldObj.playSoundAtEntity(player, "ab:freyrSlingshot", 0.4F, 2.8F); - } - } - - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if(ManaItemHandler.requestManaExactForTool(stack, player, 5000, false)) - player.setItemInUse(stack, getMaxItemUseDuration(stack)); - return stack; - } - - public int getMaxItemUseDuration(ItemStack par1ItemStack) { - return 42000; - } - - public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - return par1ItemStack; - } - - public EnumAction getItemUseAction(ItemStack par1ItemStack) { - return EnumAction.bow; - } - - public boolean usesMana(ItemStack stack) { - return true; - } -} \ No newline at end of file + public ItemFreyrSlingshot() { + super("freyrSlingshot"); + } + + public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int par4) { + int j = getMaxItemUseDuration(stack) - par4; + float f = j / 20.0F; + f = (f * f + f * 2.0F) / 3.0F; + if (f < 1.0F) return; + if (!world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, 5000, true)) { + EntityManaVine ball = new EntityManaVine(world, player); + ball.motionX *= 0.9D; + ball.motionY *= 0.9D; + ball.motionZ *= 0.9D; + ball.setAttacker(player.getCommandSenderName()); + world.spawnEntityInWorld(ball); + player.worldObj.playSoundAtEntity(player, "ab:freyrSlingshot", 0.4F, 2.8F); + } + } + + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (ManaItemHandler.requestManaExactForTool(stack, player, 5000, false)) + player.setItemInUse(stack, getMaxItemUseDuration(stack)); + return stack; + } + + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 42000; + } + + public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + return par1ItemStack; + } + + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.bow; + } + + public boolean usesMana(ItemStack stack) { + return true; + } +} diff --git a/src/main/java/ab/common/item/relic/ItemHornPlenty.java b/src/main/java/ab/common/item/relic/ItemHornPlenty.java index 50a9af1..554d572 100644 --- a/src/main/java/ab/common/item/relic/ItemHornPlenty.java +++ b/src/main/java/ab/common/item/relic/ItemHornPlenty.java @@ -1,13 +1,5 @@ package ab.common.item.relic; -import ab.client.core.handler.ItemsRemainingRender; -import ab.client.core.handler.PlayerItemUsingSound.ClientSoundHandler; -import ab.common.core.handler.ConfigABHandler; -import ab.common.core.handler.NetworkHandler; -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 net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.IBossDisplayData; @@ -18,128 +10,141 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingDropsEvent; + import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; +import ab.client.core.handler.PlayerItemUsingSound.ClientSoundHandler; +import ab.common.core.handler.ConfigABHandler; +import ab.common.core.handler.NetworkHandler; +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 ItemHornPlenty extends ItemModRelic { - public static final String[] dropFewItems = new String[] { "dropFewItems", "func_70628_a" }; - private static final short maxChargeLoot = 16; - private static final int manaCost = 64000; - - public ItemHornPlenty() { - super("hornPlenty"); - MinecraftForge.EVENT_BUS.register(this); - } - - public void onUpdate(ItemStack stack, World world, Entity entity, int pos, boolean equipped) { - super.onUpdate(stack, world, entity, pos, equipped); - if(!world.isRemote && entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer)entity; - short lastChargeLoot = getLastChargeLoot(stack); - short chargeLoot = getChargeLoot(stack); - if(lastChargeLoot != chargeLoot) { - setLastChargeLoot(stack, chargeLoot); - NetworkHandler.sendPacketToHornHud((EntityPlayerMP)player, chargeLoot); - } - } - } - - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if(!hasChargeLoot(stack) && ManaItemHandler.requestManaExactForTool(stack, player, manaCost, false)) - player.setItemInUse(stack, getMaxItemUseDuration(stack)); - return stack; - } - - public void onUsingTick(ItemStack stack, EntityPlayer player, int time) { - time = this.getMaxItemUseDuration(stack) - time; - if(time > 48) { - if(!player.worldObj.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, manaCost, true)) { - setChargeLoot(stack, maxChargeLoot); - player.worldObj.playSoundAtEntity(player, "random.orb", 1.2F, 4.0F); - } - player.stopUsingItem(); - } else if(player.worldObj.isRemote) - ClientSoundHandler.playSound(player, "ab:hornPlentyUsing", 2.4f, 2.47F, 19, false); - } - - @SideOnly(Side.CLIENT) - public boolean showDurabilityBar(ItemStack stack) { - return hasChargeLoot(stack); - } - - @SideOnly(Side.CLIENT) - public double getDurabilityForDisplay(ItemStack stack) { - return 1.0f - (double)(getChargeLoot(stack)) / (double)maxChargeLoot; - } - - public int getMaxItemUseDuration(ItemStack stack) { - return 42000; - } - - public boolean isFull3D() { - return true; - } - - public EnumAction getItemUseAction(ItemStack stack) { - return EnumAction.bow; - } + public static final String[] dropFewItems = new String[] { "dropFewItems", "func_70628_a" }; + private static final short maxChargeLoot = 16; + private static final int manaCost = 64000; - @SubscribeEvent - public void onPlayerAttack(LivingDropsEvent event) { - if(event != null && event.source != null && event.source.getSourceOfDamage() instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer)event.source.getSourceOfDamage(); - ItemStack horn = null; - for(int i = 0; i < player.inventory.getSizeInventory(); i++) { - ItemStack stack = player.inventory.getStackInSlot(i); - if(stack == null) - continue; - else if(stack.getItem() instanceof ItemHornPlenty) { - if(!hasChargeLoot(stack)) - continue; - horn = stack; - break; - } - } - if(!player.worldObj.isRemote && horn != null && hasChargeLoot(horn)) { - if(player.worldObj.rand.nextInt(100) < 20 && event.entityLiving != null && !(event.entityLiving instanceof IBossDisplayData) && isVallidEntity(event.entityLiving)) { - try { - EntityLivingBase liv = event.entityLiving; - ReflectionHelper.findMethod(EntityLivingBase.class, liv, dropFewItems, new Class[] { boolean.class, int.class } ).invoke(liv, new Object[] { true, (int)(event.lootingLevel * 1.5f) }); - setChargeLoot(horn, (short)(getChargeLoot(horn) - 1)); - player.worldObj.playSoundAtEntity(player, "random.orb", 1.9F, 0.8F); - } catch(Exception e) { - e.printStackTrace(); - } - } - } - } - } - - public void setLastChargeLoot(ItemStack stack, short count) { - ItemNBTHelper.setShort(stack, "lastChargeLoot", count); - } - - public short getLastChargeLoot(ItemStack stack) { - return ItemNBTHelper.getShort(stack, "lastChargeLoot", (short)0); - } - - public void setChargeLoot(ItemStack stack, short count) { - ItemNBTHelper.setShort(stack, "chargeLoot", count); - } - - public short getChargeLoot(ItemStack stack) { - return ItemNBTHelper.getShort(stack, "chargeLoot", (short)0); - } - - public boolean hasChargeLoot(ItemStack stack) { - return ItemNBTHelper.getInt(stack, "chargeLoot", 0) > 0; - } - - public static boolean isVallidEntity(EntityLivingBase liv) { - for(String entityName : ConfigABHandler.lockEntityListToHorn) - if(liv.getClass().getSimpleName().equals(entityName)) - return false; - return true; - } -} \ No newline at end of file + public ItemHornPlenty() { + super("hornPlenty"); + MinecraftForge.EVENT_BUS.register(this); + } + + public void onUpdate(ItemStack stack, World world, Entity entity, int pos, boolean equipped) { + super.onUpdate(stack, world, entity, pos, equipped); + if (!world.isRemote && entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) entity; + short lastChargeLoot = getLastChargeLoot(stack); + short chargeLoot = getChargeLoot(stack); + if (lastChargeLoot != chargeLoot) { + setLastChargeLoot(stack, chargeLoot); + NetworkHandler.sendPacketToHornHud((EntityPlayerMP) player, chargeLoot); + } + } + } + + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (!hasChargeLoot(stack) && ManaItemHandler.requestManaExactForTool(stack, player, manaCost, false)) + player.setItemInUse(stack, getMaxItemUseDuration(stack)); + return stack; + } + + public void onUsingTick(ItemStack stack, EntityPlayer player, int time) { + time = this.getMaxItemUseDuration(stack) - time; + if (time > 48) { + if (!player.worldObj.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, manaCost, true)) { + setChargeLoot(stack, maxChargeLoot); + player.worldObj.playSoundAtEntity(player, "random.orb", 1.2F, 4.0F); + } + player.stopUsingItem(); + } else if (player.worldObj.isRemote) + ClientSoundHandler.playSound(player, "ab:hornPlentyUsing", 2.4f, 2.47F, 19, false); + } + + @SideOnly(Side.CLIENT) + public boolean showDurabilityBar(ItemStack stack) { + return hasChargeLoot(stack); + } + + @SideOnly(Side.CLIENT) + public double getDurabilityForDisplay(ItemStack stack) { + return 1.0f - (double) (getChargeLoot(stack)) / (double) maxChargeLoot; + } + + public int getMaxItemUseDuration(ItemStack stack) { + return 42000; + } + + public boolean isFull3D() { + return true; + } + + public EnumAction getItemUseAction(ItemStack stack) { + return EnumAction.bow; + } + + @SubscribeEvent + public void onPlayerAttack(LivingDropsEvent event) { + if (event != null && event.source != null && event.source.getSourceOfDamage() instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.source.getSourceOfDamage(); + ItemStack horn = null; + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { + ItemStack stack = player.inventory.getStackInSlot(i); + if (stack == null) continue; + else if (stack.getItem() instanceof ItemHornPlenty) { + if (!hasChargeLoot(stack)) continue; + horn = stack; + break; + } + } + if (!player.worldObj.isRemote && horn != null && hasChargeLoot(horn)) { + if (player.worldObj.rand.nextInt(100) < 20 && event.entityLiving != null + && !(event.entityLiving instanceof IBossDisplayData) + && isVallidEntity(event.entityLiving)) { + try { + EntityLivingBase liv = event.entityLiving; + ReflectionHelper + .findMethod( + EntityLivingBase.class, + liv, + dropFewItems, + new Class[] { boolean.class, int.class }) + .invoke(liv, new Object[] { true, (int) (event.lootingLevel * 1.5f) }); + setChargeLoot(horn, (short) (getChargeLoot(horn) - 1)); + player.worldObj.playSoundAtEntity(player, "random.orb", 1.9F, 0.8F); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + } + + public void setLastChargeLoot(ItemStack stack, short count) { + ItemNBTHelper.setShort(stack, "lastChargeLoot", count); + } + + public short getLastChargeLoot(ItemStack stack) { + return ItemNBTHelper.getShort(stack, "lastChargeLoot", (short) 0); + } + + public void setChargeLoot(ItemStack stack, short count) { + ItemNBTHelper.setShort(stack, "chargeLoot", count); + } + + public short getChargeLoot(ItemStack stack) { + return ItemNBTHelper.getShort(stack, "chargeLoot", (short) 0); + } + + public boolean hasChargeLoot(ItemStack stack) { + return ItemNBTHelper.getInt(stack, "chargeLoot", 0) > 0; + } + + public static boolean isVallidEntity(EntityLivingBase liv) { + for (String entityName : ConfigABHandler.lockEntityListToHorn) + if (liv.getClass().getSimpleName().equals(entityName)) return false; + return true; + } +} diff --git a/src/main/java/ab/common/item/relic/ItemModRelic.java b/src/main/java/ab/common/item/relic/ItemModRelic.java index 0942308..8df26ce 100644 --- a/src/main/java/ab/common/item/relic/ItemModRelic.java +++ b/src/main/java/ab/common/item/relic/ItemModRelic.java @@ -2,50 +2,56 @@ package ab.common.item.relic; import java.util.List; -import ab.AdvancedBotany; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; + import vazkii.botania.common.item.relic.ItemRelic; +import ab.AdvancedBotany; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemModRelic extends ItemRelic { - public ItemModRelic(String name) { - super(name); - this.setCreativeTab(AdvancedBotany.tabAB); - this.setNoRepair(); - } - - public String getUnlocalizedNameInefficiently(ItemStack stack) { - String str = this.getUnlocalizedName(stack); + public ItemModRelic(String name) { + super(name); + this.setCreativeTab(AdvancedBotany.tabAB); + this.setNoRepair(); + } + + public String getUnlocalizedNameInefficiently(ItemStack stack) { + String str = this.getUnlocalizedName(stack); return str == null ? "" : StatCollector.translateToLocal(str); - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister ir) { - String str = this.getUnlocalizedName(); - this.itemIcon = ir.registerIcon("ab:" + str.replace("item.", "")); - } - - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean p_77624_4_) { - if(GuiScreen.isShiftKeyDown()) { - String bind = getSoulbindUsernameS(stack); - if(bind.isEmpty()) - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.relicUnbound"), list); - else { - addStringToTooltip(String.format(StatCollector.translateToLocal("botaniamisc.relicSoulbound"), new Object[] { bind }), list); - if(!isRightPlayer(player, stack)) - addStringToTooltip(String.format(StatCollector.translateToLocal("botaniamisc.notYourSagittarius"), new Object[] { bind }), list); - } - } else - addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), list); - } - - public void addStringToTooltip(String s, List tooltip) { - tooltip.add(s.replaceAll("&", "\u00A7")); - } -} \ No newline at end of file + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister ir) { + String str = this.getUnlocalizedName(); + this.itemIcon = ir.registerIcon("ab:" + str.replace("item.", "")); + } + + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean p_77624_4_) { + if (GuiScreen.isShiftKeyDown()) { + String bind = getSoulbindUsernameS(stack); + if (bind.isEmpty()) addStringToTooltip(StatCollector.translateToLocal("botaniamisc.relicUnbound"), list); + else { + addStringToTooltip( + String.format( + StatCollector.translateToLocal("botaniamisc.relicSoulbound"), + new Object[] { bind }), + list); + if (!isRightPlayer(player, stack)) addStringToTooltip( + String.format( + StatCollector.translateToLocal("botaniamisc.notYourSagittarius"), + new Object[] { bind }), + list); + } + } else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), list); + } + + public void addStringToTooltip(String s, List tooltip) { + tooltip.add(s.replaceAll("&", "\u00A7")); + } +} diff --git a/src/main/java/ab/common/item/relic/ItemPocketWardrobe.java b/src/main/java/ab/common/item/relic/ItemPocketWardrobe.java index 78e50e3..866d6a4 100644 --- a/src/main/java/ab/common/item/relic/ItemPocketWardrobe.java +++ b/src/main/java/ab/common/item/relic/ItemPocketWardrobe.java @@ -1,13 +1,5 @@ package ab.common.item.relic; -import org.lwjgl.opengl.GL11; - -import ab.AdvancedBotany; -import ab.client.core.ClientHelper; -import ab.common.entity.EntityAnonymousSteve; -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.entity.AbstractClientPlayer; import net.minecraft.client.entity.EntityClientPlayerMP; @@ -25,294 +17,297 @@ import net.minecraft.world.World; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingAttackEvent; + +import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; +import ab.client.core.ClientHelper; +import ab.common.entity.EntityAnonymousSteve; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemPocketWardrobe extends ItemModRelic { - - protected static final ResourceLocation glowPriorityTexture = new ResourceLocation("ab:textures/misc/glow2.png"); - protected static final ResourceLocation glowTexture = new ResourceLocation("ab:textures/misc/glow1.png"); - protected static final int segmentCount = 5; - protected static final int maxSegmentCount = 12; - - public ItemPocketWardrobe() { - super("autoPocketWardrobe"); - MinecraftForge.EVENT_BUS.register(this); - } - - public void onUpdate(ItemStack pocketWardrobe, World world, Entity entity, int pos, boolean equipped) { - super.onUpdate(pocketWardrobe, world, entity, pos, equipped); - boolean eqLastTick = wasEquipped(pocketWardrobe); - if(!equipped && eqLastTick) - setEquipped(pocketWardrobe, equipped); - if(!eqLastTick && equipped && entity instanceof EntityLivingBase) { - setEquipped(pocketWardrobe, equipped); - int angles = 360; - int segAngles = angles / maxSegmentCount; - float shift = segAngles / 2.0f * segmentCount; - setRotationBase(pocketWardrobe, getCheckingAngle((EntityLivingBase)entity) - shift); - } - int tick = getFightingTick(pocketWardrobe); - if(tick > 0) - setFightingTick(pocketWardrobe, tick - 1); - else if(!world.isRemote && tick == 0 && getFightingMode(pocketWardrobe) && entity != null && entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer)entity; - setFightingMode(pocketWardrobe, false); - swapArmorSet(pocketWardrobe, player, getPrioritySet(pocketWardrobe)); - } - } - - public void setArmorSet(ItemStack pocketWardrobe, ItemStack[] armorSet, int segment) { - NBTTagList nbtList = new NBTTagList(); - int i = -1; - for(ItemStack armor : armorSet) { - i++; - if(armor == null) - continue; - NBTTagCompound cmp = new NBTTagCompound(); - cmp.setByte("slot", (byte)i); - armor.copy().writeToNBT(cmp); - nbtList.appendTag(cmp); - } - ItemNBTHelper.setList(pocketWardrobe, "armorSet" + segment, nbtList); - } - - public static ItemStack[] getArmorSet(ItemStack pocketWardrobe, int segment) { - if(segment >= segmentCount) - return null; - ItemStack[] armorSet = new ItemStack[4]; - NBTTagList nbtList = ItemNBTHelper.getList(pocketWardrobe, "armorSet" + segment, 10, false); - for(int i = 0; i < nbtList.tagCount(); i++) { - NBTTagCompound cmp = nbtList.getCompoundTagAt(i); - byte slotCount = cmp.getByte("slot"); - if(slotCount >= 0 && slotCount <= segmentCount) - armorSet[slotCount] = ItemStack.loadItemStackFromNBT(cmp); - } - return armorSet; - } - - public ItemStack onItemRightClick(ItemStack pocketWardrobe, World world, EntityPlayer player) { - int segment = getSegmentLookedAt(pocketWardrobe, player); - if(segment == -1) - return pocketWardrobe; - if(player.isSneaking()) { - setPrioritySet(pocketWardrobe, segment); - } else { - swapArmorSet(pocketWardrobe, player, segment); - } - return pocketWardrobe; - } - - public void swapArmorSet(ItemStack stack, EntityPlayer player, int segment) { - ItemStack[] playerSet = player.inventory.armorInventory; - player.inventory.armorInventory = getArmorSet(stack, segment); - setArmorSet(stack, playerSet, segment); - if(!player.worldObj.isRemote) - player.worldObj.playSoundAtEntity(player, "ab:lokiCubeArmor", 0.3f, 0.86f); - } - - @SubscribeEvent - public void onPlayerAttack(LivingAttackEvent event) { - if(event.entityLiving != null && event.entityLiving instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer)event.entityLiving; - if(player.capabilities.isCreativeMode) - return; - for(int i = 0; i < player.inventory.getSizeInventory(); i++) { - ItemStack stack = player.inventory.getStackInSlot(i); - if(stack != null && stack.getItem() instanceof ItemPocketWardrobe) { - ItemPocketWardrobe item = (ItemPocketWardrobe)stack.getItem(); - if(!item.getFightingMode(stack)) { - int armorPriorirySlot = item.getPrioritySet(stack); - ItemStack[] armorSet = item.getArmorSet(stack, armorPriorirySlot); - boolean hasArmor = false; - for(int j = 0; j < armorSet.length; j++) - if(armorSet[j] != null) { - hasArmor = true; - break; - } - if(hasArmor) { - item.setFightingTick(stack, 32); - item.setFightingMode(stack, true); - item.swapArmorSet(stack, player, armorPriorirySlot); - return; - } - } else { - item.setFightingTick(stack, 32); - return; - } - } - } - } - } - - public ResourceLocation getGlowTexture(ItemStack stack, int segment) { - return getPrioritySet(stack) == segment ? glowPriorityTexture : glowTexture; - } - - @SideOnly(Side.CLIENT) - @SubscribeEvent - public void onRenderWorldLast(RenderWorldLastEvent event) { - EntityClientPlayerMP entityClientPlayerMP = (Minecraft.getMinecraft()).thePlayer; - ItemStack stack = entityClientPlayerMP.getCurrentEquippedItem(); - if(stack != null && stack.getItem() instanceof ItemPocketWardrobe) - render(stack, (EntityPlayer)entityClientPlayerMP, 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(); - 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 / maxSegmentCount; - float shift = base - ((segAngles / 2.0f) * segmentCount); - float u = 1.0F; - float v = 0.25F; - float s = 3.6F; - float m = 0.8F; - float y = v * 6.0F; - float y0 = 0.0F; - int segmentLookedAt = getSegmentLookedAt(stack, (EntityLivingBase)player); - for(int seg = 0; seg < segmentCount; seg++) { - ClientHelper.setLightmapTextureCoords(); - float rotationAngle = (seg + 0.5F) * segAngles + shift; - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glEnable(3042); - GL11.glBlendFunc(770, 771); - GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); - GL11.glDisable(GL11.GL_CULL_FACE); - float a = alpha; - if(segmentLookedAt == seg) { - a += 0.3F; - y0 = -y; - } - if(seg % 2 == 0) { - GL11.glColor4f(0.6F, 0.6F, 0.6F, a); - } else { - GL11.glColor4f(1.0F, 1.0F, 1.0F, a); - } - ItemPocketWardrobe item = (ItemPocketWardrobe)stack.getItem(); - mc.renderEngine.bindTexture(item.getGlowTexture(stack, seg)); - tess.startDrawingQuads(); - for(int i = 0; i < segAngles; i++) { - float ang = (i + seg * segAngles) + shift; - double xp = Math.cos(ang * Math.PI / 180.0D) * s; - double zp = Math.sin(ang * Math.PI / 180.0D) * s; - tess.addVertexWithUV(xp * m, y, zp * m, u, v); - tess.addVertexWithUV(xp, y0, zp, u, 0.0D); - xp = Math.cos((ang + 1.0F) * Math.PI / 180.0D) * s; - zp = Math.sin((ang + 1.0F) * Math.PI / 180.0D) * s; - tess.addVertexWithUV(xp, y0, zp, 0.0D, 0.0D); - tess.addVertexWithUV(xp * m, y, zp * m, 0.0D, v); - } - y0 = 0.0F; - tess.draw(); - GL11.glPopMatrix(); - AbstractClientPlayer steve = new EntityAnonymousSteve(player.worldObj); - steve.inventory.armorInventory = getArmorSet(stack, seg); - boolean hasArmor = false; - for(int l = 0; l < steve.inventory.armorInventory.length; l++) - if(steve.inventory.armorItemInSlot(l) != null) { - hasArmor = true; - break; - } - if(hasArmor) { - GL11.glPushMatrix(); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F); - double worldTime = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks + seg * 2.75f; - GL11.glTranslated(s * m, -0.75F + Math.sin(worldTime / 12.0D) / 26.0D, 0.0F); - float scale = 0.6F; - GL11.glRotatef(-90.0f, 0.0f, 1.0f, 0.0f); - GL11.glTranslatef(0.0f, 0.8125f, 0.0f); - GL11.glScalef(scale, scale, scale); - steve.setPositionAndRotation(player.posX, player.posY, player.posZ, 0.0f, 10.0f); - RenderManager.instance.renderEntityWithPosYaw(steve, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); - Minecraft.getMinecraft().entityRenderer.disableLightmap(partialTicks); - GL11.glPopMatrix(); - } - ClientHelper.setLightmapTextureCoords(); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glDisable(3042); - } - GL11.glPopMatrix(); - } - - protected static int getSegmentLookedAt(ItemStack stack, EntityLivingBase player) { - float yaw = getCheckingAngle(player, getRotationBase(stack)); - int angles = 360; - int segAngles = angles / maxSegmentCount; - for(int seg = 0; seg < segmentCount; seg++) { - float calcAngle = seg * segAngles; - if(yaw >= calcAngle && yaw < calcAngle + segAngles) - return seg; - } - return -1; - } - - protected static float getCheckingAngle(EntityLivingBase player, float base) { - float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw) + 90.0f; - int angles = 360; - int segAngles = angles / maxSegmentCount; - float shift = segAngles / 2.0f * segmentCount; - if(yaw < 0.0f) - yaw = 360.0F + yaw; - yaw -= 360.0F - base; - float angle = 360.0F - yaw + shift; - if(angle > 360.0F) - angle %= 360.0F; - return angle; - } - - protected static float getCheckingAngle(EntityLivingBase player) { - return getCheckingAngle(player, 0.0F); - } - - public static void setEquipped(ItemStack stack, boolean equipped) { - ItemNBTHelper.setBoolean(stack, "equipped", equipped); - } - - public static boolean wasEquipped(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, "equipped", false); - } - - public static void setRotationBase(ItemStack stack, float rotation) { - ItemNBTHelper.setFloat(stack, "rotationBase", rotation); - } - - public static float getRotationBase(ItemStack stack) { - return ItemNBTHelper.getFloat(stack, "rotationBase", 0.0F); - } - - public static void setFightingMode(ItemStack stack, boolean mode) { - ItemNBTHelper.setBoolean(stack, "fightingMode", mode); - } - - public static boolean getFightingMode(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, "fightingMode", false); - } - - public static void setFightingTick(ItemStack stack, int tick) { - ItemNBTHelper.setInt(stack, "fightingTick", tick); - } - - public static int getFightingTick(ItemStack stack) { - return ItemNBTHelper.getInt(stack, "fightingTick", 0); - } - - public static void setPrioritySet(ItemStack stack, int segment) { - ItemNBTHelper.setInt(stack, "prioritySet", segment); - } - - public static int getPrioritySet(ItemStack stack) { - return ItemNBTHelper.getInt(stack, "prioritySet", 2); - } -} \ No newline at end of file + + protected static final ResourceLocation glowPriorityTexture = new ResourceLocation("ab:textures/misc/glow2.png"); + protected static final ResourceLocation glowTexture = new ResourceLocation("ab:textures/misc/glow1.png"); + protected static final int segmentCount = 5; + protected static final int maxSegmentCount = 12; + + public ItemPocketWardrobe() { + super("autoPocketWardrobe"); + MinecraftForge.EVENT_BUS.register(this); + } + + public void onUpdate(ItemStack pocketWardrobe, World world, Entity entity, int pos, boolean equipped) { + super.onUpdate(pocketWardrobe, world, entity, pos, equipped); + boolean eqLastTick = wasEquipped(pocketWardrobe); + if (!equipped && eqLastTick) setEquipped(pocketWardrobe, equipped); + if (!eqLastTick && equipped && entity instanceof EntityLivingBase) { + setEquipped(pocketWardrobe, equipped); + int angles = 360; + int segAngles = angles / maxSegmentCount; + float shift = segAngles / 2.0f * segmentCount; + setRotationBase(pocketWardrobe, getCheckingAngle((EntityLivingBase) entity) - shift); + } + int tick = getFightingTick(pocketWardrobe); + if (tick > 0) setFightingTick(pocketWardrobe, tick - 1); + else if (!world.isRemote && tick == 0 + && getFightingMode(pocketWardrobe) + && entity != null + && entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) entity; + setFightingMode(pocketWardrobe, false); + swapArmorSet(pocketWardrobe, player, getPrioritySet(pocketWardrobe)); + } + } + + public void setArmorSet(ItemStack pocketWardrobe, ItemStack[] armorSet, int segment) { + NBTTagList nbtList = new NBTTagList(); + int i = -1; + for (ItemStack armor : armorSet) { + i++; + if (armor == null) continue; + NBTTagCompound cmp = new NBTTagCompound(); + cmp.setByte("slot", (byte) i); + armor.copy().writeToNBT(cmp); + nbtList.appendTag(cmp); + } + ItemNBTHelper.setList(pocketWardrobe, "armorSet" + segment, nbtList); + } + + public static ItemStack[] getArmorSet(ItemStack pocketWardrobe, int segment) { + if (segment >= segmentCount) return null; + ItemStack[] armorSet = new ItemStack[4]; + NBTTagList nbtList = ItemNBTHelper.getList(pocketWardrobe, "armorSet" + segment, 10, false); + for (int i = 0; i < nbtList.tagCount(); i++) { + NBTTagCompound cmp = nbtList.getCompoundTagAt(i); + byte slotCount = cmp.getByte("slot"); + if (slotCount >= 0 && slotCount <= segmentCount) armorSet[slotCount] = ItemStack.loadItemStackFromNBT(cmp); + } + return armorSet; + } + + public ItemStack onItemRightClick(ItemStack pocketWardrobe, World world, EntityPlayer player) { + int segment = getSegmentLookedAt(pocketWardrobe, player); + if (segment == -1) return pocketWardrobe; + if (player.isSneaking()) { + setPrioritySet(pocketWardrobe, segment); + } else { + swapArmorSet(pocketWardrobe, player, segment); + } + return pocketWardrobe; + } + + public void swapArmorSet(ItemStack stack, EntityPlayer player, int segment) { + ItemStack[] playerSet = player.inventory.armorInventory; + player.inventory.armorInventory = getArmorSet(stack, segment); + setArmorSet(stack, playerSet, segment); + if (!player.worldObj.isRemote) player.worldObj.playSoundAtEntity(player, "ab:lokiCubeArmor", 0.3f, 0.86f); + } + + @SubscribeEvent + public void onPlayerAttack(LivingAttackEvent event) { + if (event.entityLiving != null && event.entityLiving instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.entityLiving; + if (player.capabilities.isCreativeMode) return; + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { + ItemStack stack = player.inventory.getStackInSlot(i); + if (stack != null && stack.getItem() instanceof ItemPocketWardrobe) { + ItemPocketWardrobe item = (ItemPocketWardrobe) stack.getItem(); + if (!item.getFightingMode(stack)) { + int armorPriorirySlot = item.getPrioritySet(stack); + ItemStack[] armorSet = item.getArmorSet(stack, armorPriorirySlot); + boolean hasArmor = false; + for (int j = 0; j < armorSet.length; j++) if (armorSet[j] != null) { + hasArmor = true; + break; + } + if (hasArmor) { + item.setFightingTick(stack, 32); + item.setFightingMode(stack, true); + item.swapArmorSet(stack, player, armorPriorirySlot); + return; + } + } else { + item.setFightingTick(stack, 32); + return; + } + } + } + } + } + + public ResourceLocation getGlowTexture(ItemStack stack, int segment) { + return getPrioritySet(stack) == segment ? glowPriorityTexture : glowTexture; + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onRenderWorldLast(RenderWorldLastEvent event) { + EntityClientPlayerMP entityClientPlayerMP = (Minecraft.getMinecraft()).thePlayer; + ItemStack stack = entityClientPlayerMP.getCurrentEquippedItem(); + if (stack != null && stack.getItem() instanceof ItemPocketWardrobe) + render(stack, (EntityPlayer) entityClientPlayerMP, 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(); + 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 / maxSegmentCount; + float shift = base - ((segAngles / 2.0f) * segmentCount); + float u = 1.0F; + float v = 0.25F; + float s = 3.6F; + float m = 0.8F; + float y = v * 6.0F; + float y0 = 0.0F; + int segmentLookedAt = getSegmentLookedAt(stack, (EntityLivingBase) player); + for (int seg = 0; seg < segmentCount; seg++) { + ClientHelper.setLightmapTextureCoords(); + float rotationAngle = (seg + 0.5F) * segAngles + shift; + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); + GL11.glDisable(GL11.GL_CULL_FACE); + float a = alpha; + if (segmentLookedAt == seg) { + a += 0.3F; + y0 = -y; + } + if (seg % 2 == 0) { + GL11.glColor4f(0.6F, 0.6F, 0.6F, a); + } else { + GL11.glColor4f(1.0F, 1.0F, 1.0F, a); + } + ItemPocketWardrobe item = (ItemPocketWardrobe) stack.getItem(); + mc.renderEngine.bindTexture(item.getGlowTexture(stack, seg)); + tess.startDrawingQuads(); + for (int i = 0; i < segAngles; i++) { + float ang = (i + seg * segAngles) + shift; + double xp = Math.cos(ang * Math.PI / 180.0D) * s; + double zp = Math.sin(ang * Math.PI / 180.0D) * s; + tess.addVertexWithUV(xp * m, y, zp * m, u, v); + tess.addVertexWithUV(xp, y0, zp, u, 0.0D); + xp = Math.cos((ang + 1.0F) * Math.PI / 180.0D) * s; + zp = Math.sin((ang + 1.0F) * Math.PI / 180.0D) * s; + tess.addVertexWithUV(xp, y0, zp, 0.0D, 0.0D); + tess.addVertexWithUV(xp * m, y, zp * m, 0.0D, v); + } + y0 = 0.0F; + tess.draw(); + GL11.glPopMatrix(); + AbstractClientPlayer steve = new EntityAnonymousSteve(player.worldObj); + steve.inventory.armorInventory = getArmorSet(stack, seg); + boolean hasArmor = false; + for (int l = 0; l < steve.inventory.armorInventory.length; l++) + if (steve.inventory.armorItemInSlot(l) != null) { + hasArmor = true; + break; + } + if (hasArmor) { + GL11.glPushMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F); + double worldTime = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks + seg * 2.75f; + GL11.glTranslated(s * m, -0.75F + Math.sin(worldTime / 12.0D) / 26.0D, 0.0F); + float scale = 0.6F; + GL11.glRotatef(-90.0f, 0.0f, 1.0f, 0.0f); + GL11.glTranslatef(0.0f, 0.8125f, 0.0f); + GL11.glScalef(scale, scale, scale); + steve.setPositionAndRotation(player.posX, player.posY, player.posZ, 0.0f, 10.0f); + RenderManager.instance.renderEntityWithPosYaw(steve, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); + Minecraft.getMinecraft().entityRenderer.disableLightmap(partialTicks); + GL11.glPopMatrix(); + } + ClientHelper.setLightmapTextureCoords(); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDisable(3042); + } + GL11.glPopMatrix(); + } + + protected static int getSegmentLookedAt(ItemStack stack, EntityLivingBase player) { + float yaw = getCheckingAngle(player, getRotationBase(stack)); + int angles = 360; + int segAngles = angles / maxSegmentCount; + for (int seg = 0; seg < segmentCount; seg++) { + float calcAngle = seg * segAngles; + if (yaw >= calcAngle && yaw < calcAngle + segAngles) return seg; + } + return -1; + } + + protected static float getCheckingAngle(EntityLivingBase player, float base) { + float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw) + 90.0f; + int angles = 360; + int segAngles = angles / maxSegmentCount; + float shift = segAngles / 2.0f * segmentCount; + if (yaw < 0.0f) yaw = 360.0F + yaw; + yaw -= 360.0F - base; + float angle = 360.0F - yaw + shift; + if (angle > 360.0F) angle %= 360.0F; + return angle; + } + + protected static float getCheckingAngle(EntityLivingBase player) { + return getCheckingAngle(player, 0.0F); + } + + public static void setEquipped(ItemStack stack, boolean equipped) { + ItemNBTHelper.setBoolean(stack, "equipped", equipped); + } + + public static boolean wasEquipped(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, "equipped", false); + } + + public static void setRotationBase(ItemStack stack, float rotation) { + ItemNBTHelper.setFloat(stack, "rotationBase", rotation); + } + + public static float getRotationBase(ItemStack stack) { + return ItemNBTHelper.getFloat(stack, "rotationBase", 0.0F); + } + + public static void setFightingMode(ItemStack stack, boolean mode) { + ItemNBTHelper.setBoolean(stack, "fightingMode", mode); + } + + public static boolean getFightingMode(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, "fightingMode", false); + } + + public static void setFightingTick(ItemStack stack, int tick) { + ItemNBTHelper.setInt(stack, "fightingTick", tick); + } + + public static int getFightingTick(ItemStack stack) { + return ItemNBTHelper.getInt(stack, "fightingTick", 0); + } + + public static void setPrioritySet(ItemStack stack, int segment) { + ItemNBTHelper.setInt(stack, "prioritySet", segment); + } + + public static int getPrioritySet(ItemStack stack) { + return ItemNBTHelper.getInt(stack, "prioritySet", 2); + } +} diff --git a/src/main/java/ab/common/item/relic/ItemSphereNavigation.java b/src/main/java/ab/common/item/relic/ItemSphereNavigation.java index 059b69f..fdd3eb7 100644 --- a/src/main/java/ab/common/item/relic/ItemSphereNavigation.java +++ b/src/main/java/ab/common/item/relic/ItemSphereNavigation.java @@ -3,201 +3,211 @@ package ab.common.item.relic; import java.awt.Color; import java.util.List; -import ab.client.core.handler.ItemsRemainingRender; -import ab.common.core.handler.ConfigABHandler; -import ab.common.core.handler.NetworkHandler; -import ab.common.lib.register.ItemListAB; -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; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.util.StatCollector; import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; + import vazkii.botania.api.mana.ManaItemHandler; -import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.ItemNBTHelper; +import ab.client.core.handler.ItemsRemainingRender; +import ab.common.core.handler.ConfigABHandler; +import ab.common.core.handler.NetworkHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemSphereNavigation extends ItemModRelic { - - public static IIcon[] icons; - public static final int rangeSearch = 16; - public static final int maxCooldown = 158; - - public ItemSphereNavigation() { - super("sphereNavigation"); - } - - public void registerIcons(IIconRegister ir) { - icons = new IIcon[5]; - for(int i = 0; i < icons.length; i++) - icons[i] = icons[i] = ir.registerIcon("ab:" + "sphereNavigation_" + i); - } - - @SideOnly(Side.CLIENT) - public IIcon getIcon(ItemStack stack, int pass) { - return this.icons[pass == 0 ? 0 : (pass == 1 ? 1 : 4)]; - } - - public boolean requiresMultipleRenderPasses() { - return true; - } - - public String getItemStackDisplayName(ItemStack stack) { - Block block = getFindBlock(stack); - int meta = getFindMeta(stack); - ItemStack rStack = new ItemStack(block, 1, meta); - return super.getItemStackDisplayName(stack) + ((rStack == null || rStack.getItem() == null) ? "" : (EnumChatFormatting.RESET + " (" + EnumChatFormatting.GREEN + rStack.getDisplayName() + EnumChatFormatting.RESET + ")")); - } - - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { - super.addInformation(stack, player, list, par4); - addStringToTooltip(StatCollector.translateToLocal(stack.getItemDamage() == 0 ? "botaniamisc.active" : "botaniamisc.inactive"), list); - } - - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if(getFindBlock(stack) != null && player.isSneaking()) { - int dmg = stack.getItemDamage(); - stack.setItemDamage((dmg ^ 0xFFFFFFFF) & 0x1); - world.playSoundAtEntity(player, "random.orb", 0.3F, 0.1F); - } - return stack; - } - - public void onUpdate(ItemStack stack, World world, Entity entity, int pos, boolean equipped) { - super.onUpdate(stack, world, entity, pos, equipped); - if(entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer)entity; - if(!world.isRemote && stack.getItemDamage() == 0 && getFindBlock(stack) != null && canWork(stack) && ManaItemHandler.requestManaExactForTool(stack, player, ConfigABHandler.sphereNavigationManaCost, true)) { - setMaxTick(stack); - NetworkHandler.sendPacketToFindBlocks((EntityPlayerMP)player, getFindBlock(stack), getFindMeta(stack)); - } - } - } - - public static void findBlocks(World world, Block findBlock, int findMeta, EntityPlayer player) { - if(world.isRemote) { - ItemStack renderStack = null; - int maxFindedBlocks = 32; - int findedBlocks = 0; - label1703: - for(int y = -rangeSearch * 2; y < rangeSearch; y++) { - for(int x = -rangeSearch; x < rangeSearch; x++) { - if(!(world.rand.nextInt(maxFindedBlocks) < (maxFindedBlocks - findedBlocks)) || world.rand.nextBoolean()) - continue; - for(int z = -rangeSearch; z < rangeSearch; z++) { - if(!(world.rand.nextInt(maxFindedBlocks) < (maxFindedBlocks - findedBlocks)) || world.rand.nextBoolean()) - continue; - else if(findedBlocks >= maxFindedBlocks) - break label1703; - int posX = MathHelper.floor_double(player.posX) + x; - int posY = MathHelper.floor_double(player.posY) + y; - int posZ = MathHelper.floor_double(player.posZ) + z; - if(posY < 0) - continue; - Block block = world.getBlock(posX, posY, posZ); - if(!Block.isEqualTo(block, findBlock)) - continue; - int meta = world.getBlockMetadata(posX, posY, posZ); - if(meta == findMeta) { - if(renderStack == null) - renderStack = getRenderStackForBlock(world, block, meta, posX, posY, posZ); - findedBlocks++; - float maxAge = 2.7f + (0.5f * (float)(Math.random())); - Botania.proxy.setWispFXDepthTest(false); - Botania.proxy.setWispFXDistanceLimit(false); - float far = 120.0f - (((Math.abs(x) + Math.min(rangeSearch, Math.abs(y)) + Math.abs(z)) / (rangeSearch * 4.0f)) * 120.0f); - if(far <= 70) - far *= 0.1f; - Color color = new Color(Color.HSBtoRGB(far / 360.0f, 0.9f + (float)(Math.random() * 0.1f), 1.0f)); - for(int i = 0; i < 11; i++) - Botania.proxy.wispFX(world, posX + 0.5f + (Math.random() - 0.5f), posY + 0.5f + (Math.random() - 0.5f), posZ + 0.5f + (Math.random() - 0.5f), color.getRed() / 100.0f, color.getGreen() / 100.0f, color.getBlue() / 100.0f, 0.3f + (float)(Math.random() * 0.25f), 0.0f, maxAge); - Botania.proxy.setWispFXDistanceLimit(true); - Botania.proxy.setWispFXDepthTest(true); - } - } - } - } - if(renderStack != null) - ItemsRemainingRender.set(renderStack, StatCollector.translateToLocal("ab.sphereNavigation.founded") + " " + findedBlocks); - } - } - - public static ItemStack getRenderStackForBlock(World world, Block block, int meta, int x, int y, int z) { - if(block != null) { - Item item = Item.getItemFromBlock(block); - if(item != null) { - ItemStack findStack = new ItemStack(block, 1, meta); - if(findStack != null) - return findStack; - } else { - Item item1 = block.getItem(world, x, y, z); - if(item1 != null) { - ItemStack findStack = new ItemStack(item1, 1, meta); - if(findStack != null) - return findStack; - } - } - } - return null; - } - - public boolean onItemUse(ItemStack stack, EntityPlayer p, World world, int x, int y, int z, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { - if(p.isSneaking()) { - Block block = world.getBlock(x, y, z); - if(block != null) { - int meta = world.getBlockMetadata(x, y, z); - ItemStack findStack = getRenderStackForBlock(world, block, meta, x, y, z); - if(findStack != null) { - setFindBlock(stack, block, meta); - if(world.isRemote) - ItemsRemainingRender.set(findStack, findStack.getDisplayName()); - return true; - } - } - } - return false; - } - - public boolean canWork(ItemStack stack) { - int tick = ItemNBTHelper.getInt(stack, "cooldown", 0); - if(tick == 0) - return true; - else if(tick > 0) - ItemNBTHelper.setInt(stack, "cooldown", tick - 1); - return false; - } - - public void setMaxTick(ItemStack stack) { - ItemNBTHelper.setInt(stack, "cooldown", maxCooldown); - } - - public static void setFindBlock(ItemStack stack, Block block, int meta) { - ItemNBTHelper.setInt(stack, "findBlockID", Block.getIdFromBlock(block)); - ItemNBTHelper.setInt(stack, "findBlockMeta", meta); - } - - public static Block getFindBlock(ItemStack stack) { - int blockID = ItemNBTHelper.getInt(stack, "findBlockID", 0); - if(blockID == 0) - return null; - else - return Block.getBlockById(blockID); - } - - public static int getFindMeta(ItemStack stack) { - return ItemNBTHelper.getInt(stack, "findBlockMeta", -1); - } -} \ No newline at end of file + + public static IIcon[] icons; + public static final int rangeSearch = 16; + public static final int maxCooldown = 158; + + public ItemSphereNavigation() { + super("sphereNavigation"); + } + + public void registerIcons(IIconRegister ir) { + icons = new IIcon[5]; + for (int i = 0; i < icons.length; i++) icons[i] = icons[i] = ir.registerIcon("ab:" + "sphereNavigation_" + i); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int pass) { + return this.icons[pass == 0 ? 0 : (pass == 1 ? 1 : 4)]; + } + + public boolean requiresMultipleRenderPasses() { + return true; + } + + public String getItemStackDisplayName(ItemStack stack) { + Block block = getFindBlock(stack); + int meta = getFindMeta(stack); + ItemStack rStack = new ItemStack(block, 1, meta); + return super.getItemStackDisplayName(stack) + ((rStack == null || rStack.getItem() == null) ? "" + : (EnumChatFormatting.RESET + " (" + + EnumChatFormatting.GREEN + + rStack.getDisplayName() + + EnumChatFormatting.RESET + + ")")); + } + + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { + super.addInformation(stack, player, list, par4); + addStringToTooltip( + StatCollector + .translateToLocal(stack.getItemDamage() == 0 ? "botaniamisc.active" : "botaniamisc.inactive"), + list); + } + + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (getFindBlock(stack) != null && player.isSneaking()) { + int dmg = stack.getItemDamage(); + stack.setItemDamage((dmg ^ 0xFFFFFFFF) & 0x1); + world.playSoundAtEntity(player, "random.orb", 0.3F, 0.1F); + } + return stack; + } + + public void onUpdate(ItemStack stack, World world, Entity entity, int pos, boolean equipped) { + super.onUpdate(stack, world, entity, pos, equipped); + if (entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) entity; + if (!world.isRemote && stack.getItemDamage() == 0 + && getFindBlock(stack) != null + && canWork(stack) + && ManaItemHandler + .requestManaExactForTool(stack, player, ConfigABHandler.sphereNavigationManaCost, true)) { + setMaxTick(stack); + NetworkHandler.sendPacketToFindBlocks((EntityPlayerMP) player, getFindBlock(stack), getFindMeta(stack)); + } + } + } + + public static void findBlocks(World world, Block findBlock, int findMeta, EntityPlayer player) { + if (world.isRemote) { + ItemStack renderStack = null; + int maxFindedBlocks = 32; + int findedBlocks = 0; + label1703: for (int y = -rangeSearch * 2; y < rangeSearch; y++) { + for (int x = -rangeSearch; x < rangeSearch; x++) { + if (!(world.rand.nextInt(maxFindedBlocks) < (maxFindedBlocks - findedBlocks)) + || world.rand.nextBoolean()) + continue; + for (int z = -rangeSearch; z < rangeSearch; z++) { + if (!(world.rand.nextInt(maxFindedBlocks) < (maxFindedBlocks - findedBlocks)) + || world.rand.nextBoolean()) + continue; + else if (findedBlocks >= maxFindedBlocks) break label1703; + int posX = MathHelper.floor_double(player.posX) + x; + int posY = MathHelper.floor_double(player.posY) + y; + int posZ = MathHelper.floor_double(player.posZ) + z; + if (posY < 0) continue; + Block block = world.getBlock(posX, posY, posZ); + if (!Block.isEqualTo(block, findBlock)) continue; + int meta = world.getBlockMetadata(posX, posY, posZ); + if (meta == findMeta) { + if (renderStack == null) + renderStack = getRenderStackForBlock(world, block, meta, posX, posY, posZ); + findedBlocks++; + float maxAge = 2.7f + (0.5f * (float) (Math.random())); + Botania.proxy.setWispFXDepthTest(false); + Botania.proxy.setWispFXDistanceLimit(false); + float far = 120.0f - (((Math.abs(x) + Math.min(rangeSearch, Math.abs(y)) + Math.abs(z)) + / (rangeSearch * 4.0f)) * 120.0f); + if (far <= 70) far *= 0.1f; + Color color = new Color( + Color.HSBtoRGB(far / 360.0f, 0.9f + (float) (Math.random() * 0.1f), 1.0f)); + for (int i = 0; i < 11; i++) Botania.proxy.wispFX( + world, + posX + 0.5f + (Math.random() - 0.5f), + posY + 0.5f + (Math.random() - 0.5f), + posZ + 0.5f + (Math.random() - 0.5f), + color.getRed() / 100.0f, + color.getGreen() / 100.0f, + color.getBlue() / 100.0f, + 0.3f + (float) (Math.random() * 0.25f), + 0.0f, + maxAge); + Botania.proxy.setWispFXDistanceLimit(true); + Botania.proxy.setWispFXDepthTest(true); + } + } + } + } + if (renderStack != null) ItemsRemainingRender.set( + renderStack, + StatCollector.translateToLocal("ab.sphereNavigation.founded") + " " + findedBlocks); + } + } + + public static ItemStack getRenderStackForBlock(World world, Block block, int meta, int x, int y, int z) { + if (block != null) { + Item item = Item.getItemFromBlock(block); + if (item != null) { + ItemStack findStack = new ItemStack(block, 1, meta); + if (findStack != null) return findStack; + } else { + Item item1 = block.getItem(world, x, y, z); + if (item1 != null) { + ItemStack findStack = new ItemStack(item1, 1, meta); + if (findStack != null) return findStack; + } + } + } + return null; + } + + public boolean onItemUse(ItemStack stack, EntityPlayer p, World world, int x, int y, int z, int p_77648_7_, + float p_77648_8_, float p_77648_9_, float p_77648_10_) { + if (p.isSneaking()) { + Block block = world.getBlock(x, y, z); + if (block != null) { + int meta = world.getBlockMetadata(x, y, z); + ItemStack findStack = getRenderStackForBlock(world, block, meta, x, y, z); + if (findStack != null) { + setFindBlock(stack, block, meta); + if (world.isRemote) ItemsRemainingRender.set(findStack, findStack.getDisplayName()); + return true; + } + } + } + return false; + } + + public boolean canWork(ItemStack stack) { + int tick = ItemNBTHelper.getInt(stack, "cooldown", 0); + if (tick == 0) return true; + else if (tick > 0) ItemNBTHelper.setInt(stack, "cooldown", tick - 1); + return false; + } + + public void setMaxTick(ItemStack stack) { + ItemNBTHelper.setInt(stack, "cooldown", maxCooldown); + } + + public static void setFindBlock(ItemStack stack, Block block, int meta) { + ItemNBTHelper.setInt(stack, "findBlockID", Block.getIdFromBlock(block)); + ItemNBTHelper.setInt(stack, "findBlockMeta", meta); + } + + public static Block getFindBlock(ItemStack stack) { + int blockID = ItemNBTHelper.getInt(stack, "findBlockID", 0); + if (blockID == 0) return null; + else return Block.getBlockById(blockID); + } + + public static int getFindMeta(ItemStack stack) { + return ItemNBTHelper.getInt(stack, "findBlockMeta", -1); + } +} diff --git a/src/main/java/ab/common/item/relic/ItemTalismanHiddenRiches.java b/src/main/java/ab/common/item/relic/ItemTalismanHiddenRiches.java index 2d6a838..7f81f59 100644 --- a/src/main/java/ab/common/item/relic/ItemTalismanHiddenRiches.java +++ b/src/main/java/ab/common/item/relic/ItemTalismanHiddenRiches.java @@ -2,285 +2,282 @@ package ab.common.item.relic; import java.util.ArrayList; import java.util.List; -import java.util.Random; -import org.lwjgl.opengl.GL11; - -import ab.AdvancedBotany; -import ab.client.core.ClientHelper; -import ab.client.core.handler.PlayerItemUsingSound.ClientSoundHandler; -import ab.common.entity.EntityAnonymousSteve; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -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.entity.AbstractClientPlayer; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.tileentity.TileEntityRendererChestHelper; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.common.MinecraftForge; + +import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; +import ab.AdvancedBotany; +import ab.client.core.ClientHelper; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemTalismanHiddenRiches extends ItemModRelic { - protected static List chestList = new ArrayList(); - protected static final ResourceLocation glowTexture = new ResourceLocation("ab:textures/misc/glow3.png"); - protected static final int segmentCount = 11; - protected static final int maxSegmentCount = 16; - - public ItemTalismanHiddenRiches() { - super("talismanHiddenRiches"); - MinecraftForge.EVENT_BUS.register(this); - } - - public void onUpdate(ItemStack stack, World world, Entity entity, int pos, boolean equipped) { - super.onUpdate(stack, world, entity, pos, equipped); - if(entity != null && entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer)entity; - boolean eqLastTick = wasEquipped(stack); - if(!equipped && eqLastTick) - setEquipped(stack, equipped); - if(!eqLastTick && equipped) { - setEquipped(stack, equipped); - int angles = 360; - int segAngles = angles / maxSegmentCount; - float shift = segAngles / 2.0f * segmentCount; - setRotationBase(stack, getCheckingAngle((EntityLivingBase)entity) - shift); - } - if(world.isRemote) { - if(equipped) { - for(int i = 0; i < segmentCount; i++) { - TileEntityChest chest = getChestForSegment(i); - if(chest != null) { - chest.prevLidAngle = chest.lidAngle; - float lidAngel = chest.lidAngle; - if(i == getOpenChest(stack) && chest.lidAngle < 1.0F) { - if(lidAngel == 0.0F) - Minecraft.getMinecraft().theWorld.playSound(player.posX, player.posY - 0.5f, player.posZ, "random.chestopen", 0.5f, world.rand.nextFloat() * 0.1F + 0.9F, false); - chest.lidAngle = Math.min(1.0f, lidAngel + 0.1F); - } else if(i != getOpenChest(stack) && lidAngel > 0.0F) { - if((int)(lidAngel * 10) == 5) - Minecraft.getMinecraft().theWorld.playSound(player.posX, player.posY - 0.5f, player.posZ, "random.chestclosed", 0.5f, world.rand.nextFloat() * 0.1F + 0.9F, false); - chest.lidAngle = Math.max(0.0f, lidAngel - 0.1F); - } - } - } - } - } - } - } - - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - int segment = getSegmentLookedAt(stack, player); - if(segment == -1) - return stack; - setOpenChest(stack, segment); - player.openGui(AdvancedBotany.instance, 0, world, 0, 0, 0); - return stack; - } - - @SideOnly(Side.CLIENT) - @SubscribeEvent - public void onRenderWorldLast(RenderWorldLastEvent event) { - EntityClientPlayerMP entityClientPlayerMP = (Minecraft.getMinecraft()).thePlayer; - ItemStack stack = entityClientPlayerMP.getCurrentEquippedItem(); - if(stack != null && stack.getItem() instanceof ItemTalismanHiddenRiches) - render(stack, (EntityPlayer)entityClientPlayerMP, 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(); - 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 / maxSegmentCount; - float shift = base - ((segAngles / 2.0f) * segmentCount); - float u = 1.0F; - float v = 0.25F; - float s = 3.2F; - float m = 0.8F; - float y = v * 6.0F; - float y0 = 0.0F; - int segmentLookedAt = getSegmentLookedAt(stack, (EntityLivingBase)player); - for(int seg = 0; seg < segmentCount; seg++) { - ClientHelper.setLightmapTextureCoords(); - float rotationAngle = (seg + 0.5F) * segAngles + shift; - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glEnable(3042); - GL11.glBlendFunc(770, 771); - GL11.glDisable(GL11.GL_CULL_FACE); - - GL11.glPushMatrix(); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(s * m, -0.75F, 0.0F); - double worldTime = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks + seg * 2.75f; - GL11.glTranslated(0.375f, Math.sin(worldTime / 8.0D) / 20.0D, -0.375F); - float scale = 0.75F; - GL11.glScalef(scale, scale, scale); - - GL11.glRotatef(-90.0f, 0.0f, 1.0f, 0.0f); - TileEntityChest chest = getChestForSegment(seg); - TileEntityRendererDispatcher.instance.renderTileEntityAt(chest, 0.0D, 0.0D, 0.0D, partialTicks); - - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); - float a = alpha; - if(segmentLookedAt == seg) { - a += 0.3F; - y0 = -y; - } - if(seg % 2 == 0) { - GL11.glColor4f(0.6F, 0.6F, 0.6F, a); - } else { - GL11.glColor4f(1.0F, 1.0F, 1.0F, a); - } - ItemTalismanHiddenRiches item = (ItemTalismanHiddenRiches)stack.getItem(); - mc.renderEngine.bindTexture(item.getGlowTexture(stack, seg)); - tess.startDrawingQuads(); - for(int i = 0; i < segAngles; i++) { - float ang = (i + seg * segAngles) + shift; - double xp = Math.cos(ang * Math.PI / 180.0D) * s; - double zp = Math.sin(ang * Math.PI / 180.0D) * s; - tess.addVertexWithUV(xp * m, y, zp * m, u, v); - tess.addVertexWithUV(xp, y0, zp, u, 0.0D); - xp = Math.cos((ang + 1.0F) * Math.PI / 180.0D) * s; - zp = Math.sin((ang + 1.0F) * Math.PI / 180.0D) * s; - tess.addVertexWithUV(xp, y0, zp, 0.0D, 0.0D); - tess.addVertexWithUV(xp * m, y, zp * m, 0.0D, v); - } - y0 = 0.0F; - tess.draw(); - GL11.glPopMatrix(); - - ClientHelper.setLightmapTextureCoords(); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glDisable(3042); - } - GL11.glPopMatrix(); - } + protected static List chestList = new ArrayList(); + protected static final ResourceLocation glowTexture = new ResourceLocation("ab:textures/misc/glow3.png"); + protected static final int segmentCount = 11; + protected static final int maxSegmentCount = 16; - private ResourceLocation getGlowTexture(ItemStack stack, int seg) { - return glowTexture; - } + public ItemTalismanHiddenRiches() { + super("talismanHiddenRiches"); + MinecraftForge.EVENT_BUS.register(this); + } - protected static int getSegmentLookedAt(ItemStack stack, EntityLivingBase player) { - float yaw = getCheckingAngle(player, getRotationBase(stack)); - int angles = 360; - int segAngles = angles / maxSegmentCount; - for(int seg = 0; seg < segmentCount; seg++) { - float calcAngle = seg * segAngles; - if(yaw >= calcAngle && yaw < calcAngle + segAngles) - return seg; - } - return -1; - } - - protected static float getCheckingAngle(EntityLivingBase player, float base) { - float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw) + 90.0f; - int angles = 360; - int segAngles = angles / maxSegmentCount; - float shift = segAngles / 2.0f * segmentCount; - if(yaw < 0.0f) - yaw = 360.0F + yaw; - yaw -= 360.0F - base; - float angle = 360.0F - yaw + shift; - if(angle > 360.0F) - angle %= 360.0F; - return angle; - } - - protected static float getCheckingAngle(EntityLivingBase player) { - return getCheckingAngle(player, 0.0F); - } - - public static void setEquipped(ItemStack stack, boolean equipped) { - ItemNBTHelper.setBoolean(stack, "equipped", equipped); - } - - public static boolean wasEquipped(ItemStack stack) { - return ItemNBTHelper.getBoolean(stack, "equipped", false); - } - - public static void setRotationBase(ItemStack stack, float rotation) { - ItemNBTHelper.setFloat(stack, "rotationBase", rotation); - } - - public static float getRotationBase(ItemStack stack) { - return ItemNBTHelper.getFloat(stack, "rotationBase", 0.0F); - } - - public static void setOpenChest(ItemStack stack, int segment) { - ItemNBTHelper.setInt(stack, "openChest", segment); - } - - public static int getOpenChest(ItemStack stack) { - return ItemNBTHelper.getInt(stack, "openChest", -1); - } - - public static TileEntityChest getChestForSegment(int segment) { - if(chestList.isEmpty()) - for(int i = 0; i < segmentCount; i++) - chestList.add(new TileEntityChest()); - if(segment < 0 || segment > segmentCount) - return null; - return chestList.get(segment); - } - - public static void setChestLoot(ItemStack stack, ItemStack[] loot, int segment) { - NBTTagList nbtList = new NBTTagList(); - int i = -1; - for(ItemStack item : loot) { - i++; - if(item == null) - continue; - NBTTagCompound cmp = new NBTTagCompound(); - cmp.setByte("slot", (byte)i); - item.copy().writeToNBT(cmp); - nbtList.appendTag(cmp); - } - ItemNBTHelper.setList(stack, "chestLoot" + segment, nbtList); - } - - public static ItemStack[] getChestLoot(ItemStack stack, int segment) { - if(segment >= segmentCount) - return null; - ItemStack[] loot = new ItemStack[27]; - NBTTagList nbtList = ItemNBTHelper.getList(stack, "chestLoot" + segment, 10, false); - for(int i = 0; i < nbtList.tagCount(); i++) { - NBTTagCompound cmp = nbtList.getCompoundTagAt(i); - byte slotCount = cmp.getByte("slot"); - if(slotCount >= 0) - loot[slotCount] = ItemStack.loadItemStackFromNBT(cmp); - } - return loot; - } -} \ No newline at end of file + public void onUpdate(ItemStack stack, World world, Entity entity, int pos, boolean equipped) { + super.onUpdate(stack, world, entity, pos, equipped); + if (entity != null && entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) entity; + boolean eqLastTick = wasEquipped(stack); + if (!equipped && eqLastTick) setEquipped(stack, equipped); + if (!eqLastTick && equipped) { + setEquipped(stack, equipped); + int angles = 360; + int segAngles = angles / maxSegmentCount; + float shift = segAngles / 2.0f * segmentCount; + setRotationBase(stack, getCheckingAngle((EntityLivingBase) entity) - shift); + } + if (world.isRemote) { + if (equipped) { + for (int i = 0; i < segmentCount; i++) { + TileEntityChest chest = getChestForSegment(i); + if (chest != null) { + chest.prevLidAngle = chest.lidAngle; + float lidAngel = chest.lidAngle; + if (i == getOpenChest(stack) && chest.lidAngle < 1.0F) { + if (lidAngel == 0.0F) Minecraft.getMinecraft().theWorld.playSound( + player.posX, + player.posY - 0.5f, + player.posZ, + "random.chestopen", + 0.5f, + world.rand.nextFloat() * 0.1F + 0.9F, + false); + chest.lidAngle = Math.min(1.0f, lidAngel + 0.1F); + } else if (i != getOpenChest(stack) && lidAngel > 0.0F) { + if ((int) (lidAngel * 10) == 5) Minecraft.getMinecraft().theWorld.playSound( + player.posX, + player.posY - 0.5f, + player.posZ, + "random.chestclosed", + 0.5f, + world.rand.nextFloat() * 0.1F + 0.9F, + false); + chest.lidAngle = Math.max(0.0f, lidAngel - 0.1F); + } + } + } + } + } + } + } + + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + int segment = getSegmentLookedAt(stack, player); + if (segment == -1) return stack; + setOpenChest(stack, segment); + player.openGui(AdvancedBotany.instance, 0, world, 0, 0, 0); + return stack; + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onRenderWorldLast(RenderWorldLastEvent event) { + EntityClientPlayerMP entityClientPlayerMP = (Minecraft.getMinecraft()).thePlayer; + ItemStack stack = entityClientPlayerMP.getCurrentEquippedItem(); + if (stack != null && stack.getItem() instanceof ItemTalismanHiddenRiches) + render(stack, (EntityPlayer) entityClientPlayerMP, 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(); + 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 / maxSegmentCount; + float shift = base - ((segAngles / 2.0f) * segmentCount); + float u = 1.0F; + float v = 0.25F; + float s = 3.2F; + float m = 0.8F; + float y = v * 6.0F; + float y0 = 0.0F; + int segmentLookedAt = getSegmentLookedAt(stack, (EntityLivingBase) player); + for (int seg = 0; seg < segmentCount; seg++) { + ClientHelper.setLightmapTextureCoords(); + float rotationAngle = (seg + 0.5F) * segAngles + shift; + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glDisable(GL11.GL_CULL_FACE); + + GL11.glPushMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(s * m, -0.75F, 0.0F); + double worldTime = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks + seg * 2.75f; + GL11.glTranslated(0.375f, Math.sin(worldTime / 8.0D) / 20.0D, -0.375F); + float scale = 0.75F; + GL11.glScalef(scale, scale, scale); + + GL11.glRotatef(-90.0f, 0.0f, 1.0f, 0.0f); + TileEntityChest chest = getChestForSegment(seg); + TileEntityRendererDispatcher.instance.renderTileEntityAt(chest, 0.0D, 0.0D, 0.0D, partialTicks); + + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); + float a = alpha; + if (segmentLookedAt == seg) { + a += 0.3F; + y0 = -y; + } + if (seg % 2 == 0) { + GL11.glColor4f(0.6F, 0.6F, 0.6F, a); + } else { + GL11.glColor4f(1.0F, 1.0F, 1.0F, a); + } + ItemTalismanHiddenRiches item = (ItemTalismanHiddenRiches) stack.getItem(); + mc.renderEngine.bindTexture(item.getGlowTexture(stack, seg)); + tess.startDrawingQuads(); + for (int i = 0; i < segAngles; i++) { + float ang = (i + seg * segAngles) + shift; + double xp = Math.cos(ang * Math.PI / 180.0D) * s; + double zp = Math.sin(ang * Math.PI / 180.0D) * s; + tess.addVertexWithUV(xp * m, y, zp * m, u, v); + tess.addVertexWithUV(xp, y0, zp, u, 0.0D); + xp = Math.cos((ang + 1.0F) * Math.PI / 180.0D) * s; + zp = Math.sin((ang + 1.0F) * Math.PI / 180.0D) * s; + tess.addVertexWithUV(xp, y0, zp, 0.0D, 0.0D); + tess.addVertexWithUV(xp * m, y, zp * m, 0.0D, v); + } + y0 = 0.0F; + tess.draw(); + GL11.glPopMatrix(); + + ClientHelper.setLightmapTextureCoords(); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDisable(3042); + } + GL11.glPopMatrix(); + } + + private ResourceLocation getGlowTexture(ItemStack stack, int seg) { + return glowTexture; + } + + protected static int getSegmentLookedAt(ItemStack stack, EntityLivingBase player) { + float yaw = getCheckingAngle(player, getRotationBase(stack)); + int angles = 360; + int segAngles = angles / maxSegmentCount; + for (int seg = 0; seg < segmentCount; seg++) { + float calcAngle = seg * segAngles; + if (yaw >= calcAngle && yaw < calcAngle + segAngles) return seg; + } + return -1; + } + + protected static float getCheckingAngle(EntityLivingBase player, float base) { + float yaw = MathHelper.wrapAngleTo180_float(player.rotationYaw) + 90.0f; + int angles = 360; + int segAngles = angles / maxSegmentCount; + float shift = segAngles / 2.0f * segmentCount; + if (yaw < 0.0f) yaw = 360.0F + yaw; + yaw -= 360.0F - base; + float angle = 360.0F - yaw + shift; + if (angle > 360.0F) angle %= 360.0F; + return angle; + } + + protected static float getCheckingAngle(EntityLivingBase player) { + return getCheckingAngle(player, 0.0F); + } + + public static void setEquipped(ItemStack stack, boolean equipped) { + ItemNBTHelper.setBoolean(stack, "equipped", equipped); + } + + public static boolean wasEquipped(ItemStack stack) { + return ItemNBTHelper.getBoolean(stack, "equipped", false); + } + + public static void setRotationBase(ItemStack stack, float rotation) { + ItemNBTHelper.setFloat(stack, "rotationBase", rotation); + } + + public static float getRotationBase(ItemStack stack) { + return ItemNBTHelper.getFloat(stack, "rotationBase", 0.0F); + } + + public static void setOpenChest(ItemStack stack, int segment) { + ItemNBTHelper.setInt(stack, "openChest", segment); + } + + public static int getOpenChest(ItemStack stack) { + return ItemNBTHelper.getInt(stack, "openChest", -1); + } + + public static TileEntityChest getChestForSegment(int segment) { + if (chestList.isEmpty()) for (int i = 0; i < segmentCount; i++) chestList.add(new TileEntityChest()); + if (segment < 0 || segment > segmentCount) return null; + return chestList.get(segment); + } + + public static void setChestLoot(ItemStack stack, ItemStack[] loot, int segment) { + NBTTagList nbtList = new NBTTagList(); + int i = -1; + for (ItemStack item : loot) { + i++; + if (item == null) continue; + NBTTagCompound cmp = new NBTTagCompound(); + cmp.setByte("slot", (byte) i); + item.copy().writeToNBT(cmp); + nbtList.appendTag(cmp); + } + ItemNBTHelper.setList(stack, "chestLoot" + segment, nbtList); + } + + public static ItemStack[] getChestLoot(ItemStack stack, int segment) { + if (segment >= segmentCount) return null; + ItemStack[] loot = new ItemStack[27]; + NBTTagList nbtList = ItemNBTHelper.getList(stack, "chestLoot" + segment, 10, false); + for (int i = 0; i < nbtList.tagCount(); i++) { + NBTTagCompound cmp = nbtList.getCompoundTagAt(i); + byte slotCount = cmp.getByte("slot"); + if (slotCount >= 0) loot[slotCount] = ItemStack.loadItemStackFromNBT(cmp); + } + return loot; + } +} diff --git a/src/main/java/ab/common/lib/register/AchievementRegister.java b/src/main/java/ab/common/lib/register/AchievementRegister.java index 175207c..021ebf2 100644 --- a/src/main/java/ab/common/lib/register/AchievementRegister.java +++ b/src/main/java/ab/common/lib/register/AchievementRegister.java @@ -1,34 +1,48 @@ package ab.common.lib.register; -import java.util.ArrayList; -import java.util.List; - -import ab.api.AchievementAB; -import ab.api.AdvancedBotanyAPI; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.stats.Achievement; import net.minecraftforge.common.AchievementPage; -import vazkii.botania.common.core.handler.ConfigHandler; -import vazkii.botania.common.item.ModItems; + +import ab.api.AchievementAB; +import ab.api.AdvancedBotanyAPI; public class AchievementRegister { - - public static Achievement relicSlingshot; - public static Achievement relicPocketArmor; - public static Achievement relicItemChest; - public static Achievement fateBoard; - public static Achievement hornPlenty; - public static Achievement sphereNavigation; - public static void init() { - relicSlingshot = new AchievementAB("relicSlingshot", 0, 2, new ItemStack(ItemListAB.itemFreyrSlingshot), null); - relicPocketArmor = new AchievementAB("relicPocketArmor", 0, -2, new ItemStack(ItemListAB.itemPocketWardrobe), null); - relicItemChest = new AchievementAB("relicItemChest", 2, 1, new ItemStack(ItemListAB.itemTalismanHiddenRiches), null); - hornPlenty = new AchievementAB("relicHornPlenty", 2, -1, new ItemStack(ItemListAB.itemHornPlenty), null); - sphereNavigation = new AchievementAB("relicSphereNavigation", -2, 1, new ItemStack(ItemListAB.itemSphereNavigation), null); - fateBoard = new AchievementAB("fateBoard", 0, 0, new ItemStack(BlockListAB.blockBoardFate, 1, 1), null).setSpecial(); - AchievementPage page = new AchievementPage("Advanced Botany", AdvancedBotanyAPI.achievements.toArray(new Achievement[AdvancedBotanyAPI.achievements.size()])); - AchievementPage.registerAchievementPage(page); - } -} \ No newline at end of file + public static Achievement relicSlingshot; + public static Achievement relicPocketArmor; + public static Achievement relicItemChest; + public static Achievement fateBoard; + public static Achievement hornPlenty; + public static Achievement sphereNavigation; + + public static void init() { + relicSlingshot = new AchievementAB("relicSlingshot", 0, 2, new ItemStack(ItemListAB.itemFreyrSlingshot), null); + relicPocketArmor = new AchievementAB( + "relicPocketArmor", + 0, + -2, + new ItemStack(ItemListAB.itemPocketWardrobe), + null); + relicItemChest = new AchievementAB( + "relicItemChest", + 2, + 1, + new ItemStack(ItemListAB.itemTalismanHiddenRiches), + null); + hornPlenty = new AchievementAB("relicHornPlenty", 2, -1, new ItemStack(ItemListAB.itemHornPlenty), null); + sphereNavigation = new AchievementAB( + "relicSphereNavigation", + -2, + 1, + new ItemStack(ItemListAB.itemSphereNavigation), + null); + fateBoard = new AchievementAB("fateBoard", 0, 0, new ItemStack(BlockListAB.blockBoardFate, 1, 1), null) + .setSpecial(); + AchievementPage page = new AchievementPage( + "Advanced Botany", + AdvancedBotanyAPI.achievements + .toArray(new Achievement[AdvancedBotanyAPI.achievements.size()])); + AchievementPage.registerAchievementPage(page); + } +} diff --git a/src/main/java/ab/common/lib/register/BlockListAB.java b/src/main/java/ab/common/lib/register/BlockListAB.java index d60dc47..4d183d4 100644 --- a/src/main/java/ab/common/lib/register/BlockListAB.java +++ b/src/main/java/ab/common/lib/register/BlockListAB.java @@ -1,8 +1,10 @@ package ab.common.lib.register; +import net.minecraft.block.Block; + +import vazkii.botania.common.Botania; import ab.common.block.BlockABSpreader; import ab.common.block.BlockABStorage; -import ab.common.block.BlockNidavellirForge; import ab.common.block.BlockAntigravitation; import ab.common.block.BlockBoardFate; import ab.common.block.BlockEngineerHopper; @@ -13,9 +15,9 @@ import ab.common.block.BlockMagicCraftCrate; import ab.common.block.BlockManaCharger; import ab.common.block.BlockManaContainer; import ab.common.block.BlockManaCrystalCube; +import ab.common.block.BlockNidavellirForge; import ab.common.block.BlockTerraFarmland; import ab.common.block.tile.TileABSpreader; -import ab.common.block.tile.TileNidavellirForge; import ab.common.block.tile.TileBoardFate; import ab.common.block.tile.TileEngineerHopper; import ab.common.block.tile.TileGameBoard; @@ -24,99 +26,96 @@ import ab.common.block.tile.TileMagicCraftCrate; import ab.common.block.tile.TileManaCharger; import ab.common.block.tile.TileManaContainer; import ab.common.block.tile.TileManaCrystalCube; +import ab.common.block.tile.TileNidavellirForge; import ab.common.core.handler.ConfigABHandler; import ab.common.item.block.ItemBlockBase; import ab.common.item.block.ItemBlockBoard; import cpw.mods.fml.common.registry.GameRegistry; -import net.minecraft.block.Block; -import vazkii.botania.common.Botania; -import vazkii.botania.common.core.handler.ConfigHandler; public class BlockListAB { - - public static Block blockABSpreader; - public static Block blockABPlate; - public static Block blockLebethron; - public static Block blockManaContainer; - public static Block blockABStorage; - public static Block blockManaCrystalCube; - public static Block blockTerraFarmland; - public static Block blockAntigravitation; - public static Block blockManaCharger; - public static Block blockEngineerHopper; - public static Block blockFreyrLiana; - public static Block blockLuminousFreyrLiana; - public static Block blockMagicCraftCrate; - public static Block blockBoardFate; - - public static int blockABSpreaderRI; - public static int blockManaContainerRI; - public static int blockManaCrystalCubeRI; - public static int blockManaChargerRI; - public static int blockEngineerHopperRI; - public static int blockABPlateRI; - - public static void init() { - initializeBlocks(); - registerBlocks(); - registerTileEntities(); - } - - private static void initializeBlocks() { - BlockListAB.blockABSpreader = new BlockABSpreader(); - BlockListAB.blockABPlate = new BlockNidavellirForge(); - BlockListAB.blockLebethron = new BlockLebethronWood(); - BlockListAB.blockManaContainer = new BlockManaContainer(); - BlockListAB.blockABStorage = new BlockABStorage(); - BlockListAB.blockManaCrystalCube = new BlockManaCrystalCube(); - BlockListAB.blockTerraFarmland = new BlockTerraFarmland(); - BlockListAB.blockAntigravitation = new BlockAntigravitation(); - BlockListAB.blockManaCharger = new BlockManaCharger(); - BlockListAB.blockEngineerHopper = new BlockEngineerHopper(); - BlockListAB.blockLuminousFreyrLiana = new BlockLuminousFreyrLiana(); - BlockListAB.blockFreyrLiana = new BlockFreyrLiana(); - BlockListAB.blockBoardFate = new BlockBoardFate(); - if(Botania.thaumcraftLoaded && ConfigABHandler.hasAutoThaum) - BlockListAB.blockMagicCraftCrate = new BlockMagicCraftCrate(); - } - - private static void registerBlocks() { - GameRegistry.registerBlock(BlockListAB.blockABSpreader, "blockABSpreader"); - GameRegistry.registerBlock(BlockListAB.blockABPlate, "blockABPlate"); - GameRegistry.registerBlock(BlockListAB.blockManaContainer, ItemBlockBase.class, "blockManaContainer"); - GameRegistry.registerBlock(BlockListAB.blockLebethron, ItemBlockBase.class, "blockLebethron"); - GameRegistry.registerBlock(BlockListAB.blockABStorage, ItemBlockBase.class, "blockABStorage"); - GameRegistry.registerBlock(BlockListAB.blockManaCrystalCube, "blockManaCrystalCube"); - GameRegistry.registerBlock(BlockListAB.blockTerraFarmland, "blockTerraFarmland"); - GameRegistry.registerBlock(BlockListAB.blockAntigravitation, "blockAntigravitation"); - GameRegistry.registerBlock(BlockListAB.blockManaCharger, "blockManaCharger"); - GameRegistry.registerBlock(BlockListAB.blockEngineerHopper, "blockEngineerHopper"); - GameRegistry.registerBlock(BlockListAB.blockFreyrLiana, "blockFreyrLiana"); - GameRegistry.registerBlock(BlockListAB.blockLuminousFreyrLiana, "blockLuminousFreyrLiana"); - GameRegistry.registerBlock(BlockListAB.blockBoardFate, ItemBlockBoard.class, "blockBoardFate"); - } - - private static void registerTileEntities() { - GameRegistry.registerTileEntity(TileABSpreader.class, "tileABSpreader"); - GameRegistry.registerTileEntity(TileNidavellirForge.class, "tileAgglomerationPlate"); - GameRegistry.registerTileEntity(TileLebethronCore.class, "tileLebethronCore"); - GameRegistry.registerTileEntity(TileManaContainer.class, "tileManaContainer"); - GameRegistry.registerTileEntity(TileManaCrystalCube.class, "tileManaCrystalCube"); - GameRegistry.registerTileEntity(TileEngineerHopper.class, "tileEngineerHopper"); - if(ConfigABHandler.hasManaCharger) - GameRegistry.registerTileEntity(TileManaCharger.class, "tileManaCharger"); - GameRegistry.registerTileEntity(TileBoardFate.class, "tileBoardFate"); - GameRegistry.registerTileEntity(TileGameBoard.class, "tileGameBoard"); - if(Botania.thaumcraftLoaded && ConfigABHandler.hasAutoThaum) - GameRegistry.registerTileEntity(TileMagicCraftCrate.class, "tileMagicCraftCrate"); - } - - static { - BlockListAB.blockABSpreaderRI = -1; - BlockListAB.blockManaContainerRI = -1; - BlockListAB.blockManaCrystalCubeRI = -1; - BlockListAB.blockManaChargerRI = -1; - BlockListAB.blockEngineerHopperRI = -1; - BlockListAB.blockABPlateRI = -1; - } -} \ No newline at end of file + + public static Block blockABSpreader; + public static Block blockABPlate; + public static Block blockLebethron; + public static Block blockManaContainer; + public static Block blockABStorage; + public static Block blockManaCrystalCube; + public static Block blockTerraFarmland; + public static Block blockAntigravitation; + public static Block blockManaCharger; + public static Block blockEngineerHopper; + public static Block blockFreyrLiana; + public static Block blockLuminousFreyrLiana; + public static Block blockMagicCraftCrate; + public static Block blockBoardFate; + + public static int blockABSpreaderRI; + public static int blockManaContainerRI; + public static int blockManaCrystalCubeRI; + public static int blockManaChargerRI; + public static int blockEngineerHopperRI; + public static int blockABPlateRI; + + public static void init() { + initializeBlocks(); + registerBlocks(); + registerTileEntities(); + } + + private static void initializeBlocks() { + BlockListAB.blockABSpreader = new BlockABSpreader(); + BlockListAB.blockABPlate = new BlockNidavellirForge(); + BlockListAB.blockLebethron = new BlockLebethronWood(); + BlockListAB.blockManaContainer = new BlockManaContainer(); + BlockListAB.blockABStorage = new BlockABStorage(); + BlockListAB.blockManaCrystalCube = new BlockManaCrystalCube(); + BlockListAB.blockTerraFarmland = new BlockTerraFarmland(); + BlockListAB.blockAntigravitation = new BlockAntigravitation(); + BlockListAB.blockManaCharger = new BlockManaCharger(); + BlockListAB.blockEngineerHopper = new BlockEngineerHopper(); + BlockListAB.blockLuminousFreyrLiana = new BlockLuminousFreyrLiana(); + BlockListAB.blockFreyrLiana = new BlockFreyrLiana(); + BlockListAB.blockBoardFate = new BlockBoardFate(); + if (Botania.thaumcraftLoaded && ConfigABHandler.hasAutoThaum) + BlockListAB.blockMagicCraftCrate = new BlockMagicCraftCrate(); + } + + private static void registerBlocks() { + GameRegistry.registerBlock(BlockListAB.blockABSpreader, "blockABSpreader"); + GameRegistry.registerBlock(BlockListAB.blockABPlate, "blockABPlate"); + GameRegistry.registerBlock(BlockListAB.blockManaContainer, ItemBlockBase.class, "blockManaContainer"); + GameRegistry.registerBlock(BlockListAB.blockLebethron, ItemBlockBase.class, "blockLebethron"); + GameRegistry.registerBlock(BlockListAB.blockABStorage, ItemBlockBase.class, "blockABStorage"); + GameRegistry.registerBlock(BlockListAB.blockManaCrystalCube, "blockManaCrystalCube"); + GameRegistry.registerBlock(BlockListAB.blockTerraFarmland, "blockTerraFarmland"); + GameRegistry.registerBlock(BlockListAB.blockAntigravitation, "blockAntigravitation"); + GameRegistry.registerBlock(BlockListAB.blockManaCharger, "blockManaCharger"); + GameRegistry.registerBlock(BlockListAB.blockEngineerHopper, "blockEngineerHopper"); + GameRegistry.registerBlock(BlockListAB.blockFreyrLiana, "blockFreyrLiana"); + GameRegistry.registerBlock(BlockListAB.blockLuminousFreyrLiana, "blockLuminousFreyrLiana"); + GameRegistry.registerBlock(BlockListAB.blockBoardFate, ItemBlockBoard.class, "blockBoardFate"); + } + + private static void registerTileEntities() { + GameRegistry.registerTileEntity(TileABSpreader.class, "tileABSpreader"); + GameRegistry.registerTileEntity(TileNidavellirForge.class, "tileAgglomerationPlate"); + GameRegistry.registerTileEntity(TileLebethronCore.class, "tileLebethronCore"); + GameRegistry.registerTileEntity(TileManaContainer.class, "tileManaContainer"); + GameRegistry.registerTileEntity(TileManaCrystalCube.class, "tileManaCrystalCube"); + GameRegistry.registerTileEntity(TileEngineerHopper.class, "tileEngineerHopper"); + if (ConfigABHandler.hasManaCharger) GameRegistry.registerTileEntity(TileManaCharger.class, "tileManaCharger"); + GameRegistry.registerTileEntity(TileBoardFate.class, "tileBoardFate"); + GameRegistry.registerTileEntity(TileGameBoard.class, "tileGameBoard"); + if (Botania.thaumcraftLoaded && ConfigABHandler.hasAutoThaum) + GameRegistry.registerTileEntity(TileMagicCraftCrate.class, "tileMagicCraftCrate"); + } + + static { + BlockListAB.blockABSpreaderRI = -1; + BlockListAB.blockManaContainerRI = -1; + BlockListAB.blockManaCrystalCubeRI = -1; + BlockListAB.blockManaChargerRI = -1; + BlockListAB.blockEngineerHopperRI = -1; + BlockListAB.blockABPlateRI = -1; + } +} diff --git a/src/main/java/ab/common/lib/register/EntityListAB.java b/src/main/java/ab/common/lib/register/EntityListAB.java index d3fe0c5..ddadb63 100644 --- a/src/main/java/ab/common/lib/register/EntityListAB.java +++ b/src/main/java/ab/common/lib/register/EntityListAB.java @@ -11,13 +11,29 @@ import cpw.mods.fml.common.registry.EntityRegistry; public class EntityListAB { - public static void init() { - int id = 0; - EntityRegistry.registerModEntity(EntityAdvancedSpark.class, "advancedSpark", id++, AdvancedBotany.instance, 64, 10, false); - EntityRegistry.registerModEntity(EntityNebulaBlaze.class, "nebulaBlaze", id++, AdvancedBotany.instance, 64, 10, true); - EntityRegistry.registerModEntity(EntityManaVine.class, "manaVineBall", id++, AdvancedBotany.instance, 64, 10, true); - EntityRegistry.registerModEntity(EntityAlphirinePortal.class, "alphirinePortal", id++, AdvancedBotany.instance, 64, 10, false); - EntityRegistry.registerModEntity(EntitySword.class, "entitySword", id++, AdvancedBotany.instance, 64, 10, true); - EntityRegistry.registerModEntity(EntitySeed.class, "entitySeed", id++, AdvancedBotany.instance, 64, 10, true); - } + public static void init() { + int id = 0; + EntityRegistry.registerModEntity( + EntityAdvancedSpark.class, + "advancedSpark", + id++, + AdvancedBotany.instance, + 64, + 10, + false); + EntityRegistry + .registerModEntity(EntityNebulaBlaze.class, "nebulaBlaze", id++, AdvancedBotany.instance, 64, 10, true); + EntityRegistry + .registerModEntity(EntityManaVine.class, "manaVineBall", id++, AdvancedBotany.instance, 64, 10, true); + EntityRegistry.registerModEntity( + EntityAlphirinePortal.class, + "alphirinePortal", + id++, + AdvancedBotany.instance, + 64, + 10, + false); + EntityRegistry.registerModEntity(EntitySword.class, "entitySword", id++, AdvancedBotany.instance, 64, 10, true); + EntityRegistry.registerModEntity(EntitySeed.class, "entitySeed", id++, AdvancedBotany.instance, 64, 10, true); + } } diff --git a/src/main/java/ab/common/lib/register/FlowerRegister.java b/src/main/java/ab/common/lib/register/FlowerRegister.java index 7f70b9d..a9ce751 100644 --- a/src/main/java/ab/common/lib/register/FlowerRegister.java +++ b/src/main/java/ab/common/lib/register/FlowerRegister.java @@ -1,30 +1,30 @@ package ab.common.lib.register; +import vazkii.botania.api.BotaniaAPI; +import vazkii.botania.api.subtile.SubTileEntity; +import vazkii.botania.common.Botania; import ab.common.block.subtile.ABSubTileSignature; import ab.common.block.subtile.SubTileAncientAlphirine; import ab.common.block.subtile.SubTileArdentAzarcissus; import ab.common.block.subtile.SubTileAspecolus; import ab.common.block.subtile.SubTileDictarius; import ab.common.block.subtile.SubTilePureGladiolus; -import vazkii.botania.api.BotaniaAPI; -import vazkii.botania.api.subtile.SubTileEntity; -import vazkii.botania.common.Botania; public class FlowerRegister { - public static void init() { - registerFlower(SubTileAncientAlphirine.class, "ancientAlphirine"); - registerFlower(SubTileDictarius.class, "dictarius"); - registerFlower(SubTileArdentAzarcissus.class, "ardentAzarcissus"); - if(Botania.thaumcraftLoaded) { - registerFlower(SubTileAspecolus.class, "aspecolus"); - registerFlower(SubTilePureGladiolus.class, "pureGladiolus"); - } - } - - static void registerFlower(Class subTile, String name) { - BotaniaAPI.registerSubTile(name, subTile); - BotaniaAPI.registerSubTileSignature(subTile, new ABSubTileSignature(name)); - BotaniaAPI.addSubTileToCreativeMenu(name); - } + public static void init() { + registerFlower(SubTileAncientAlphirine.class, "ancientAlphirine"); + registerFlower(SubTileDictarius.class, "dictarius"); + registerFlower(SubTileArdentAzarcissus.class, "ardentAzarcissus"); + if (Botania.thaumcraftLoaded) { + registerFlower(SubTileAspecolus.class, "aspecolus"); + registerFlower(SubTilePureGladiolus.class, "pureGladiolus"); + } + } + + static void registerFlower(Class subTile, String name) { + BotaniaAPI.registerSubTile(name, subTile); + BotaniaAPI.registerSubTileSignature(subTile, new ABSubTileSignature(name)); + BotaniaAPI.addSubTileToCreativeMenu(name); + } } diff --git a/src/main/java/ab/common/lib/register/ItemListAB.java b/src/main/java/ab/common/lib/register/ItemListAB.java index a3889ee..d5b01e5 100644 --- a/src/main/java/ab/common/lib/register/ItemListAB.java +++ b/src/main/java/ab/common/lib/register/ItemListAB.java @@ -1,5 +1,8 @@ package ab.common.lib.register; +import net.minecraft.item.Item; + +import vazkii.botania.common.Botania; import ab.common.core.handler.ConfigABHandler; import ab.common.item.*; import ab.common.item.equipment.*; @@ -8,107 +11,99 @@ import ab.common.item.equipment.armor.ItemNebulaChest; import ab.common.item.equipment.armor.ItemNebulaHelm; import ab.common.item.equipment.armor.ItemNebulaHelmRevealing; import ab.common.item.equipment.armor.ItemNebulaLegs; -import ab.common.item.equipment.armor.ItemWildHuntBoots; -import ab.common.item.equipment.armor.ItemWildHuntChest; -import ab.common.item.equipment.armor.ItemWildHuntHelm; -import ab.common.item.equipment.armor.ItemWildHuntLegs; import ab.common.item.relic.ItemFreyrSlingshot; import ab.common.item.relic.ItemHornPlenty; import ab.common.item.relic.ItemPocketWardrobe; import ab.common.item.relic.ItemSphereNavigation; import ab.common.item.relic.ItemTalismanHiddenRiches; import cpw.mods.fml.common.registry.GameRegistry; -import net.minecraft.item.Item; -import vazkii.botania.common.Botania; -import vazkii.botania.common.core.handler.ConfigHandler; public class ItemListAB { - - public static Item itemABResource; - public static Item itemMithrillRing; - public static Item itemMihrillMultiTool; - public static Item itemNebulaRing; - public static Item itemAdvancedSpark; - public static Item itemMithrillSword; - public static Item itemTerraHoe; - public static Item itemManaFlower; - public static Item itemBlackHalo; - public static Item itemNebulaBlaze; - public static Item itemAntigravityCharm; - public static Item itemNebulaHelm; - public static Item itemNebulaHelmReveal; - public static Item itemNebulaChest; - public static Item itemNebulaLegs; - public static Item itemNebulaBoots; - public static Item itemFreyrSlingshot; - public static Item itemNebulaRod; - public static Item itemCraftingPattern; - public static Item itemSprawlRod; - public static Item itemPocketWardrobe; - public static Item itemTalismanHiddenRiches; - public static Item itemHornPlenty; - public static Item itemSphereNavigation; - public static Item itemAquaSword; - public static Item itemWildHuntHelm; - public static Item itemWildHuntChest; - public static Item itemWildHuntLegs; - public static Item itemWildHuntBoots; - - public static void init() { - ItemListAB.itemABResource = new ItemABResource(); - GameRegistry.registerItem(itemABResource, "itemABResource"); - ItemListAB.itemMithrillRing = new ItemMithrillRing("mithrillManaRing"); - GameRegistry.registerItem(itemMithrillRing, "itemMithrillRing"); - ItemListAB.itemNebulaRing = new ItemNebulaRing("nebulaManaRing"); - GameRegistry.registerItem(itemNebulaRing, "itemNebulaRing"); - ItemListAB.itemMihrillMultiTool = new ItemMithrillMultiTool(); - GameRegistry.registerItem(itemMihrillMultiTool, "itemMihrillMultiTool"); - ItemListAB.itemAdvancedSpark = new ItemAdvancedSpark(); - GameRegistry.registerItem(itemAdvancedSpark, "itemAdvancedSpark"); - ItemListAB.itemMithrillSword = new ItemSpaceBlade(); - GameRegistry.registerItem(itemMithrillSword, "itemMithrillSword"); - ItemListAB.itemTerraHoe = new ItemTerraHoe(); - GameRegistry.registerItem(itemTerraHoe, "itemTerraHoe"); - ItemListAB.itemManaFlower = new ItemManaFlower(); - GameRegistry.registerItem(itemManaFlower, "itemManaFlower"); - ItemListAB.itemBlackHalo = new ItemBlackHalo(); - GameRegistry.registerItem(itemBlackHalo, "itemBlackHalo"); - ItemListAB.itemNebulaBlaze = new ItemNebulaBlaze(); - GameRegistry.registerItem(itemNebulaBlaze, "itemNebulaBlaze"); - ItemListAB.itemAntigravityCharm = new ItemAntigravityCharm(); - GameRegistry.registerItem(itemAntigravityCharm, "itemAntigravityCharm"); - ItemListAB.itemNebulaRod = new ItemNebulaRod(); - GameRegistry.registerItem(itemNebulaRod, "itemNebulaRod"); - ItemListAB.itemSprawlRod = new ItemSprawlRod(); - GameRegistry.registerItem(itemSprawlRod, "itemSprawlRod"); - ItemListAB.itemAquaSword = new ItemAquaSword(); - GameRegistry.registerItem(itemAquaSword, "itemAquaSword"); - - ItemListAB.itemPocketWardrobe = new ItemPocketWardrobe(); - ItemListAB.itemTalismanHiddenRiches = new ItemTalismanHiddenRiches(); - ItemListAB.itemFreyrSlingshot = new ItemFreyrSlingshot(); - ItemListAB.itemHornPlenty = new ItemHornPlenty(); - ItemListAB.itemSphereNavigation = new ItemSphereNavigation(); -// ItemListAB.itemWildHuntHelm = new ItemWildHuntHelm(); -// ItemListAB.itemWildHuntChest = new ItemWildHuntChest(); -// ItemListAB.itemWildHuntLegs = new ItemWildHuntLegs(); -// ItemListAB.itemWildHuntBoots = new ItemWildHuntBoots(); - - ItemListAB.itemNebulaHelm = new ItemNebulaHelm(); - ItemListAB.itemNebulaChest = new ItemNebulaChest(); - ItemListAB.itemNebulaLegs = new ItemNebulaLegs(); - ItemListAB.itemNebulaBoots = new ItemNebulaBoots(); - if(Botania.thaumcraftLoaded) - thaumcraft(); - - } - - public static void thaumcraft() { - ItemListAB.itemNebulaHelmReveal = new ItemNebulaHelmRevealing(); - if(ConfigABHandler.hasAutoThaum) { - ItemListAB.itemCraftingPattern = new ItemCraftingPattern(); - GameRegistry.registerItem(itemCraftingPattern, "itemCraftingPattern"); - } - } + public static Item itemABResource; + public static Item itemMithrillRing; + public static Item itemMihrillMultiTool; + public static Item itemNebulaRing; + public static Item itemAdvancedSpark; + public static Item itemMithrillSword; + public static Item itemTerraHoe; + public static Item itemManaFlower; + public static Item itemBlackHalo; + public static Item itemNebulaBlaze; + public static Item itemAntigravityCharm; + public static Item itemNebulaHelm; + public static Item itemNebulaHelmReveal; + public static Item itemNebulaChest; + public static Item itemNebulaLegs; + public static Item itemNebulaBoots; + public static Item itemFreyrSlingshot; + public static Item itemNebulaRod; + public static Item itemCraftingPattern; + public static Item itemSprawlRod; + public static Item itemPocketWardrobe; + public static Item itemTalismanHiddenRiches; + public static Item itemHornPlenty; + public static Item itemSphereNavigation; + public static Item itemAquaSword; + public static Item itemWildHuntHelm; + public static Item itemWildHuntChest; + public static Item itemWildHuntLegs; + public static Item itemWildHuntBoots; + + public static void init() { + ItemListAB.itemABResource = new ItemABResource(); + GameRegistry.registerItem(itemABResource, "itemABResource"); + ItemListAB.itemMithrillRing = new ItemMithrillRing("mithrillManaRing"); + GameRegistry.registerItem(itemMithrillRing, "itemMithrillRing"); + ItemListAB.itemNebulaRing = new ItemNebulaRing("nebulaManaRing"); + GameRegistry.registerItem(itemNebulaRing, "itemNebulaRing"); + ItemListAB.itemMihrillMultiTool = new ItemMithrillMultiTool(); + GameRegistry.registerItem(itemMihrillMultiTool, "itemMihrillMultiTool"); + ItemListAB.itemAdvancedSpark = new ItemAdvancedSpark(); + GameRegistry.registerItem(itemAdvancedSpark, "itemAdvancedSpark"); + ItemListAB.itemMithrillSword = new ItemSpaceBlade(); + GameRegistry.registerItem(itemMithrillSword, "itemMithrillSword"); + ItemListAB.itemTerraHoe = new ItemTerraHoe(); + GameRegistry.registerItem(itemTerraHoe, "itemTerraHoe"); + ItemListAB.itemManaFlower = new ItemManaFlower(); + GameRegistry.registerItem(itemManaFlower, "itemManaFlower"); + ItemListAB.itemBlackHalo = new ItemBlackHalo(); + GameRegistry.registerItem(itemBlackHalo, "itemBlackHalo"); + ItemListAB.itemNebulaBlaze = new ItemNebulaBlaze(); + GameRegistry.registerItem(itemNebulaBlaze, "itemNebulaBlaze"); + ItemListAB.itemAntigravityCharm = new ItemAntigravityCharm(); + GameRegistry.registerItem(itemAntigravityCharm, "itemAntigravityCharm"); + ItemListAB.itemNebulaRod = new ItemNebulaRod(); + GameRegistry.registerItem(itemNebulaRod, "itemNebulaRod"); + ItemListAB.itemSprawlRod = new ItemSprawlRod(); + GameRegistry.registerItem(itemSprawlRod, "itemSprawlRod"); + ItemListAB.itemAquaSword = new ItemAquaSword(); + GameRegistry.registerItem(itemAquaSword, "itemAquaSword"); + + ItemListAB.itemPocketWardrobe = new ItemPocketWardrobe(); + ItemListAB.itemTalismanHiddenRiches = new ItemTalismanHiddenRiches(); + ItemListAB.itemFreyrSlingshot = new ItemFreyrSlingshot(); + ItemListAB.itemHornPlenty = new ItemHornPlenty(); + ItemListAB.itemSphereNavigation = new ItemSphereNavigation(); + + // ItemListAB.itemWildHuntHelm = new ItemWildHuntHelm(); + // ItemListAB.itemWildHuntChest = new ItemWildHuntChest(); + // ItemListAB.itemWildHuntLegs = new ItemWildHuntLegs(); + // ItemListAB.itemWildHuntBoots = new ItemWildHuntBoots(); + + ItemListAB.itemNebulaHelm = new ItemNebulaHelm(); + ItemListAB.itemNebulaChest = new ItemNebulaChest(); + ItemListAB.itemNebulaLegs = new ItemNebulaLegs(); + ItemListAB.itemNebulaBoots = new ItemNebulaBoots(); + if (Botania.thaumcraftLoaded) thaumcraft(); + + } + + public static void thaumcraft() { + ItemListAB.itemNebulaHelmReveal = new ItemNebulaHelmRevealing(); + if (ConfigABHandler.hasAutoThaum) { + ItemListAB.itemCraftingPattern = new ItemCraftingPattern(); + GameRegistry.registerItem(itemCraftingPattern, "itemCraftingPattern"); + } + } } diff --git a/src/main/java/ab/common/lib/register/RecipeListAB.java b/src/main/java/ab/common/lib/register/RecipeListAB.java index 42d8b63..85f2b83 100644 --- a/src/main/java/ab/common/lib/register/RecipeListAB.java +++ b/src/main/java/ab/common/lib/register/RecipeListAB.java @@ -1,21 +1,8 @@ package ab.common.lib.register; -import java.io.Serializable; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import ab.api.AdvancedBotanyAPI; -import ab.api.recipe.RecipeAdvancedPlate; -import ab.api.recipe.RecipeAncientAlphirine; -import ab.api.recipe.lexicon.AdvancedPlateCraftPage; -import ab.api.recipe.lexicon.AlphirineCraftPage; -import ab.common.block.tile.TileNidavellirForge; -import ab.common.block.tile.TileLebethronCore; -import ab.common.block.tile.TileMagicCraftCrate; -import ab.common.core.handler.ConfigABHandler; -import ab.common.item.ItemCraftingPattern; -import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -24,6 +11,7 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; + import thaumcraft.common.config.ConfigBlocks; import thaumcraft.common.config.ConfigItems; import vazkii.botania.api.BotaniaAPI; @@ -35,7 +23,6 @@ import vazkii.botania.api.recipe.RecipePetals; import vazkii.botania.common.Botania; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.ModFluffBlocks; -import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.block.ItemBlockSpecialFlower; import vazkii.botania.common.lexicon.BLexiconCategory; @@ -43,287 +30,661 @@ import vazkii.botania.common.lexicon.BLexiconEntry; import vazkii.botania.common.lexicon.RLexiconEntry; import vazkii.botania.common.lexicon.page.PageImage; import vazkii.botania.common.lexicon.page.PageText; +import ab.api.AdvancedBotanyAPI; +import ab.api.recipe.RecipeAdvancedPlate; +import ab.api.recipe.RecipeAncientAlphirine; +import ab.api.recipe.lexicon.AdvancedPlateCraftPage; +import ab.api.recipe.lexicon.AlphirineCraftPage; +import ab.common.block.tile.TileLebethronCore; +import ab.common.core.handler.ConfigABHandler; +import ab.common.item.ItemCraftingPattern; +import cpw.mods.fml.common.registry.GameRegistry; public class RecipeListAB { - public static LexiconCategory categoryForgotten; - - public static RecipeAncientAlphirine lebethroneRecipe; - public static RecipeAncientAlphirine forgottenLandRecipe; - public static RecipeAncientAlphirine advancedSparkRecipe; - public static RecipeAncientAlphirine manaFlowerRecipe; - public static RecipeAncientAlphirine hopperRecipe; - public static RecipeAncientAlphirine fateBoardRecipe; - - public static RecipeAdvancedPlate manaStarRecipe; - public static RecipeAdvancedPlate terrasteelRecipe; - public static RecipeAdvancedPlate mithrillRecipe; - public static RecipeAdvancedPlate nebulaRecipe; - - public static RecipePetals alphirineRecipe; - public static RecipePetals dictariusRecipe; - public static RecipePetals aspecolusRecipe; - public static RecipePetals pureGladRecipe; - public static RecipePetals azartFlowerRecipe; - - public static LexiconEntry advandedAgglomerationPlate; - public static LexiconEntry ancientAlphirine; - public static LexiconEntry lebethronWood; - public static LexiconEntry lebethronSpreader; - public static LexiconEntry mithrill; - public static LexiconEntry manaContainer; - public static LexiconEntry manaCrystalCube; - public static LexiconEntry terraHoe; - public static LexiconEntry manaRings; - public static LexiconEntry manaFlower; - public static LexiconEntry mithrillSword; - public static LexiconEntry nebula; - public static LexiconEntry blackHalo; - public static LexiconEntry antigravityCharm; - public static LexiconEntry nebulaBlaze; - public static LexiconEntry aspecolus; - public static LexiconEntry dictarius; - public static LexiconEntry manaCharger; - public static LexiconEntry nebulaArmor; - public static LexiconEntry freyrSlingshot; - public static LexiconEntry engineerHopper; - public static LexiconEntry nebulaRod; - public static LexiconEntry thaumAutoCraft; - public static LexiconEntry gladious; - public static LexiconEntry gameBoard; - public static LexiconEntry fateBoard; - public static LexiconEntry richesKey; - public static LexiconEntry cubeWardrobe; - public static LexiconEntry sphereNavigation; - public static LexiconEntry hornPlenty; - public static LexiconEntry sprawlRod; - public static LexiconEntry azartFlower; - public static LexiconEntry aquaSword; - - public static KnowledgeType forgotten; - - public static void init() { - relicInit(); - - BotaniaAPI.addCategory(categoryForgotten = new BLexiconCategory("forgotten", 5)); - forgotten = BotaniaAPI.registerKnowledgeType("ab_forgotten", EnumChatFormatting.BLUE, false); - - lebethroneRecipe = AdvancedBotanyAPI.registerAlphirineRecipe(new ItemStack(BlockListAB.blockLebethron), new ItemStack(ModBlocks.dreamwood, 1, 0), 15); - forgottenLandRecipe = AdvancedBotanyAPI.registerAlphirineRecipe(new ItemStack(ItemListAB.itemABResource, 1, 3), new ItemStack(ModItems.manaResource, 1, 15), 75); - advancedSparkRecipe = AdvancedBotanyAPI.registerAlphirineRecipe(new ItemStack(ItemListAB.itemAdvancedSpark), new ItemStack(ModItems.spark), 11); - manaFlowerRecipe = AdvancedBotanyAPI.registerAlphirineRecipe(new ItemStack(ItemListAB.itemABResource, 1, 4), new ItemStack(ModBlocks.flower, 1, 32767), 32); - hopperRecipe = AdvancedBotanyAPI.registerAlphirineRecipe(new ItemStack(BlockListAB.blockEngineerHopper), new ItemStack(Blocks.hopper), 23); - fateBoardRecipe = AdvancedBotanyAPI.registerAlphirineRecipe(new ItemStack(BlockListAB.blockBoardFate, 1, 1), new ItemStack(BlockListAB.blockBoardFate), 60); - - mithrillRecipe = AdvancedBotanyAPI.registerAdvancedPlateRecipe(new ItemStack(ItemListAB.itemABResource, 1, 0), new ItemStack(ModItems.manaResource, 1, 5), new ItemStack(ModBlocks.storage, 1, 0), new ItemStack(ModItems.manaResource, 1, 18), 2500000, 0x25d6b7); - terrasteelRecipe = AdvancedBotanyAPI.registerAdvancedPlateRecipe(new ItemStack(ModItems.manaResource, 1, 4), new ItemStack(ModItems.manaResource, 1, 2), new ItemStack(ModItems.manaResource, 1, 0), new ItemStack(ModItems.manaResource, 1, 1), 500000, 0x29de20); - manaStarRecipe = AdvancedBotanyAPI.registerAdvancedPlateRecipe(new ItemStack(ItemListAB.itemABResource, 1, 2), new ItemStack(ModItems.manaResource, 1, 23), new ItemStack(ModItems.manaResource, 1, 5), new ItemStack(Items.nether_star), 250000, 0x6bc9ec); - nebulaRecipe = AdvancedBotanyAPI.registerAdvancedPlateRecipe(new ItemStack(ItemListAB.itemABResource, 1, 5), new ItemStack(ModItems.manaResource, 1, 8), new ItemStack(ModBlocks.storage, 1, 4), new ItemStack(ItemListAB.itemABResource, 1, 1), 25000000, 0x8d16e0); - - ancientAlphirine = new BLexiconEntry("ancientAlphirine", categoryForgotten); - alphirineRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType("ancientAlphirine"), new ItemStack(ModItems.manaResource, 1, 5), new ItemStack(ModItems.manaResource, 1, 5), new ItemStack(ModItems.manaResource, 1, 5), new ItemStack(ModItems.manaResource, 1, 5), new ItemStack(ModItems.rune, 1, 8), new ItemStack(ModItems.rune, 1, 4), new ItemStack(ModItems.rune, 1, 5), new ItemStack(ModItems.rune, 1, 6), new ItemStack(ModItems.rune, 1, 7), new ItemStack(ModItems.petal, 1, 1), new ItemStack(ModItems.petal, 1, 4)); - ancientAlphirine.setPriority().setKnowledgeType(BotaniaAPI.elvenKnowledge).setLexiconPages(new LexiconPage[] { new PageText("0"), new PageText("1"), new PageImage("2", "ab:textures/misc/ancientAlphirine.png"), BotaniaAPI.internalHandler.petalRecipePage(".petalCraft", alphirineRecipe), new AlphirineCraftPage(ancientAlphirine, forgottenLandRecipe.getOutput(), ".alphirineCraft") }).setIcon(ItemBlockSpecialFlower.ofType("ancientAlphirine")); - - GameRegistry.addShapedRecipe(new ItemStack(BlockListAB.blockABPlate), new Object[] { "MPM", " F ", "BRB", Character.valueOf('F'), new ItemStack(Blocks.anvil), Character.valueOf('M'), new ItemStack(ModBlocks.storage), Character.valueOf('P'), new ItemStack(ModBlocks.terraPlate), Character.valueOf('B'), new ItemStack(ItemListAB.itemABResource, 1, 3), Character.valueOf('R'), new ItemStack(ModItems.rune, 1, 3)}); - advandedAgglomerationPlate = new BLexiconEntry("advancedPlate", categoryForgotten); - advandedAgglomerationPlate.setPriority().setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[] {new PageText("0"), BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()), new AdvancedPlateCraftPage(advandedAgglomerationPlate, terrasteelRecipe.getOutput(), ".abCraft0"), new AdvancedPlateCraftPage(advandedAgglomerationPlate, manaStarRecipe.getOutput(), ".abCraft1") }).setIcon(new ItemStack(BlockListAB.blockABPlate)); - - GameRegistry.addShapedRecipe(new ItemStack(BlockListAB.blockABSpreader), new Object[] { "WMW", "PSP", "WMW", Character.valueOf('M'), new ItemStack(ItemListAB.itemABResource, 1, 2), Character.valueOf('P'), new ItemStack(ModBlocks.pylon), Character.valueOf('S'), new ItemStack(ModBlocks.spreader, 1, 3), Character.valueOf('W'), new ItemStack(BlockListAB.blockLebethron, 1, 4)}); - lebethronSpreader = new BLexiconEntry("lebethronSpreader", categoryForgotten); - lebethronSpreader.setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[] { new PageText("0"), BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()) }).setIcon(new ItemStack(BlockListAB.blockABSpreader)); - - addShapelessOreDictRecipe(new ItemStack(BlockListAB.blockLebethron, 4, 1), new Object[] { new ItemStack(BlockListAB.blockLebethron)}); - IRecipe leb1 = getLastRecipe(); - addShapelessOreDictRecipe(new ItemStack(BlockListAB.blockLebethron, 1, 2), new Object[] { new ItemStack(BlockListAB.blockLebethron, 1, 1), new ItemStack(Items.wheat_seeds)}); - IRecipe leb2 = getLastRecipe(); - addShapelessOreDictRecipe(new ItemStack(BlockListAB.blockLebethron, 1, 3), new Object[] { new ItemStack(BlockListAB.blockLebethron), new ItemStack(Items.glowstone_dust)}); - IRecipe leb3 = getLastRecipe(); - GameRegistry.addShapedRecipe(new ItemStack(BlockListAB.blockLebethron, 1, 4), new Object[] { "4W5", "WPW", "6W7", Character.valueOf('P'), new ItemStack(ModBlocks.pylon, 1, 1), Character.valueOf('W'), new ItemStack(BlockListAB.blockLebethron), Character.valueOf('4'), new ItemStack(ModItems.rune, 1, 4), Character.valueOf('5'), new ItemStack(ModItems.rune, 1, 5), Character.valueOf('6'), new ItemStack(ModItems.rune, 1, 6), Character.valueOf('7'), new ItemStack(ModItems.rune, 1, 7)}); - IRecipe leb4 = getLastRecipe(); - lebethronWood = new BLexiconEntry("lebethronWood", categoryForgotten); - lebethronWood.setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[] { new PageText("0"), new AlphirineCraftPage(lebethronWood, lebethroneRecipe.getOutput(), ".alphirineCraft"), BotaniaAPI.internalHandler.craftingRecipePage(".craft0", leb1), BotaniaAPI.internalHandler.craftingRecipePage(".craft0", leb2), BotaniaAPI.internalHandler.craftingRecipePage(".craft0", leb3), BotaniaAPI.internalHandler.craftingRecipePage(".craft0", leb4), new PageText("1"), BotaniaAPI.internalHandler.multiblockPage(".structure", TileLebethronCore.makeMultiblockSet()) }).setIcon(new ItemStack(BlockListAB.blockLebethron)); + public static LexiconCategory categoryForgotten; - GameRegistry.addShapedRecipe(new ItemStack(ItemListAB.itemMihrillMultiTool), new Object[] { " MB", " FM", "F ", Character.valueOf('F'), new ItemStack(ModItems.manaResource, 1, 3), Character.valueOf('B'), new ItemStack(ModBlocks.livingwood), Character.valueOf('M'), new ItemStack(ItemListAB.itemABResource)}); - mithrill = new BLexiconEntry("mithrill", categoryForgotten); - mithrill.setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[] { new PageText("0"), new AdvancedPlateCraftPage(mithrill, mithrillRecipe.getOutput(), ".abCraft"), new PageText("1"), BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()) }).setIcon(new ItemStack(ItemListAB.itemMihrillMultiTool)); - - GameRegistry.addShapedRecipe(new ItemStack(BlockListAB.blockManaContainer), new Object[] { "MGM", "LPL", "M3M", Character.valueOf('M'), new ItemStack(ItemListAB.itemABResource), Character.valueOf('L'), new ItemStack(ModBlocks.pool), Character.valueOf('P'), new ItemStack(ModBlocks.pylon), Character.valueOf('3'), new ItemStack(ModItems.rune, 1, 3), Character.valueOf('G'), new ItemStack(ModItems.rune, 1, 15)}); - IRecipe cont1 = getLastRecipe(); - GameRegistry.addShapedRecipe(new ItemStack(BlockListAB.blockManaContainer, 1, 1), new Object[] { "MGM", "LPL", "M3M", Character.valueOf('M'), new ItemStack(ItemListAB.itemABResource, 1, 1), Character.valueOf('L'), new ItemStack(ModBlocks.pool, 1, 2), Character.valueOf('P'), new ItemStack(ModBlocks.pylon), Character.valueOf('3'), new ItemStack(ModItems.rune, 1, 3), Character.valueOf('G'), new ItemStack(ModItems.rune, 1, 15)}); - IRecipe cont2 = getLastRecipe(); - GameRegistry.addShapedRecipe(new ItemStack(BlockListAB.blockManaContainer, 1, 2), new Object[] { "MGM", "LPL", "M3M", Character.valueOf('M'), new ItemStack(ItemListAB.itemABResource), Character.valueOf('L'), new ItemStack(ModBlocks.pool, 1, 3), Character.valueOf('P'), new ItemStack(ModBlocks.pylon), Character.valueOf('3'), new ItemStack(ModItems.rune, 1, 3), Character.valueOf('G'), new ItemStack(ModItems.rune, 1, 15)}); - IRecipe cont3 = getLastRecipe(); - manaContainer = new BLexiconEntry("manaContainer", categoryForgotten); - manaContainer.setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[] { new PageText("0"), BotaniaAPI.internalHandler.craftingRecipePage(".craft0", cont1), BotaniaAPI.internalHandler.craftingRecipePage(".craft1", cont2), BotaniaAPI.internalHandler.craftingRecipePage(".craft2", cont3), new PageText("1"), new AlphirineCraftPage(manaContainer, advancedSparkRecipe.getOutput(), ".alphirineCraft") }).setIcon(new ItemStack(BlockListAB.blockManaContainer)); - - GameRegistry.addShapedRecipe(new ItemStack(BlockListAB.blockManaCrystalCube), new Object[] { "TST", "GWG", "DMD", Character.valueOf('D'), new ItemStack(ModBlocks.dreamwood), Character.valueOf('W'), new ItemStack(ModItems.twigWand, 1, 32767), Character.valueOf('G'), new ItemStack(ModBlocks.manaGlass), Character.valueOf('M'), new ItemStack(ModItems.manaResource), Character.valueOf('T'), new ItemStack(ModItems.manaResource, 1, 18), Character.valueOf('S'), new ItemStack(ModItems.spark)}); - manaCrystalCube = new BLexiconEntry("manaCrystalCube", BotaniaAPI.categoryMana); - manaCrystalCube.setKnowledgeType(BotaniaAPI.elvenKnowledge).setLexiconPages(new LexiconPage[] { new PageText("0"), BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()) }).setIcon(new ItemStack(BlockListAB.blockManaCrystalCube)); - - GameRegistry.addShapedRecipe(new ItemStack(ItemListAB.itemTerraHoe), new Object[] { "TTL", "RW ", " W ", Character.valueOf('T'), new ItemStack(ModItems.manaResource, 1, 4), Character.valueOf('L'), new ItemStack(ModItems.manaResource, 1, 18), Character.valueOf('W'), new ItemStack(ModItems.manaResource, 1, 3), Character.valueOf('R'), new ItemStack(ModItems.rune, 1, 2)}); - terraHoe = new BLexiconEntry("terraHoe", BotaniaAPI.categoryTools); - terraHoe.setLexiconPages(new LexiconPage[]{ new PageText("0"), BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()) }).setIcon(new ItemStack(ItemListAB.itemTerraHoe)); - - GameRegistry.addShapedRecipe(new ItemStack(ItemListAB.itemMithrillRing), new Object[] { "LML", "MRM", "LML", Character.valueOf('M'), new ItemStack(ItemListAB.itemABResource), Character.valueOf('L'), new ItemStack(ItemListAB.itemABResource, 1, 1), Character.valueOf('R'), new ItemStack(ModItems.manaRingGreater)}); - IRecipe ring1 = getLastRecipe(); - GameRegistry.addShapedRecipe(new ItemStack(ItemListAB.itemNebulaRing), new Object[] { "LML", "MRM", "LML", Character.valueOf('M'), new ItemStack(ItemListAB.itemABResource, 1, 6), Character.valueOf('L'), new ItemStack(ModItems.manaResource, 1, 5), Character.valueOf('R'), new ItemStack(ItemListAB.itemMithrillRing)}); - IRecipe ring2 = getLastRecipe(); - manaRings = new BLexiconEntry("manaRings", categoryForgotten); - manaRings.setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[]{ new PageText("0"), BotaniaAPI.internalHandler.craftingRecipePage(".craft0", ring1), BotaniaAPI.internalHandler.craftingRecipePage(".craft1", ring2)}).setIcon(new ItemStack(ItemListAB.itemMithrillRing)); - AdvancedBotanyAPI.registerFarmlandSeed(Blocks.nether_wart, 3); - - GameRegistry.addShapedRecipe(new ItemStack(ItemListAB.itemManaFlower), new Object[] { " F ", " M ", " R ", Character.valueOf('F'), new ItemStack(ItemListAB.itemABResource, 1, 4), Character.valueOf('M'), new ItemStack(ModItems.manaBottle), Character.valueOf('R'), new ItemStack(ModItems.rune, 1, 8)}); - manaFlower = new BLexiconEntry("manaFlower", categoryForgotten); - manaFlower.setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[] { new PageText("0"), new AlphirineCraftPage(manaFlower, manaFlowerRecipe.getOutput(), ".alphirineCraft"), BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe())}).setIcon(new ItemStack(ItemListAB.itemManaFlower)); - - GameRegistry.addShapedRecipe(new ItemStack(ItemListAB.itemMithrillSword), new Object[] { " M", "SM ", "WS ", Character.valueOf('S'), new ItemStack(ItemListAB.itemABResource, 1, 6), Character.valueOf('T'), new ItemStack(ModItems.terraSword), Character.valueOf('M'), new ItemStack(ItemListAB.itemABResource), Character.valueOf('W'), new ItemStack(ModItems.manaResource, 1, 3)}); - mithrillSword = new BLexiconEntry("mithrillSword", categoryForgotten); - mithrillSword.setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[] { new PageText("0"), new PageText("1"), BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()) }).setIcon(new ItemStack(ItemListAB.itemMithrillSword)); - - dictariusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType("dictarius"), new ItemStack(ItemListAB.itemABResource, 1, 4), new ItemStack(ModItems.manaResource, 1, 5), new ItemStack(ModItems.manaResource, 1, 5), new ItemStack(ModItems.rune, 1, 15), new ItemStack(ModItems.petal, 1, 4), new ItemStack(ModItems.petal, 1, 4), new ItemStack(ModItems.petal, 1, 1)); - dictarius = new BLexiconEntry("dictarius", BotaniaAPI.categoryGenerationFlowers); - dictarius.setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[] { new PageText("0"), new PageText("1"), BotaniaAPI.internalHandler.petalRecipePage(".petalCraft", dictariusRecipe)}); + public static RecipeAncientAlphirine lebethroneRecipe; + public static RecipeAncientAlphirine forgottenLandRecipe; + public static RecipeAncientAlphirine advancedSparkRecipe; + public static RecipeAncientAlphirine manaFlowerRecipe; + public static RecipeAncientAlphirine hopperRecipe; + public static RecipeAncientAlphirine fateBoardRecipe; - nebula = new BLexiconEntry("nebula", categoryForgotten); - nebula.setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[] { new PageText("0"), new AdvancedPlateCraftPage(nebula, nebulaRecipe.getOutput(), ".abCraft")}); + public static RecipeAdvancedPlate manaStarRecipe; + public static RecipeAdvancedPlate terrasteelRecipe; + public static RecipeAdvancedPlate mithrillRecipe; + public static RecipeAdvancedPlate nebulaRecipe; - GameRegistry.addShapedRecipe(new ItemStack(ItemListAB.itemBlackHalo), new Object[] { " E ", "DHD", " E ", Character.valueOf('E'), new ItemStack(ModItems.manaResource, 1, 7), Character.valueOf('H'), new ItemStack(ModItems.autocraftingHalo), Character.valueOf('D'), new ItemStack(ModItems.blackHoleTalisman)}); - blackHalo = new BLexiconEntry("blackHalo", BotaniaAPI.categoryTools); - blackHalo.setKnowledgeType(BotaniaAPI.elvenKnowledge).setLexiconPages(new LexiconPage[] { new PageText("0"), BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe())}); - - GameRegistry.addShapedRecipe(new ItemStack(ItemListAB.itemAntigravityCharm), new Object[] { " G ", "GDG", "ERE", Character.valueOf('E'), new ItemStack(ModItems.manaResource, 1, 7), Character.valueOf('G'), new ItemStack(ModBlocks.elfGlass), Character.valueOf('D'), new ItemStack(ModBlocks.floatingFlower, 1, 32767), Character.valueOf('R'), new ItemStack(ModItems.rune, 1, 3)}); - antigravityCharm = new BLexiconEntry("antigravityCharm", BotaniaAPI.categoryTools); - antigravityCharm.setKnowledgeType(BotaniaAPI.elvenKnowledge).setLexiconPages(new LexiconPage[] { new PageText("0"), BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe())}).setIcon(new ItemStack(ItemListAB.itemAntigravityCharm)); - - GameRegistry.addShapedRecipe(new ItemStack(ItemListAB.itemNebulaBlaze), new Object[] { " N ", "MMN", "AMN", Character.valueOf('N'), new ItemStack(ItemListAB.itemABResource, 1, 6), Character.valueOf('A'), new ItemStack(ItemListAB.itemABResource, 1, 3), Character.valueOf('M'), new ItemStack(ModBlocks.storage)}); - nebulaBlaze = new BLexiconEntry("nebulaBlaze", categoryForgotten); - nebulaBlaze.setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[] { new PageText("0"), BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe())}); - - if(ConfigABHandler.hasManaCharger) { - GameRegistry.addShapedRecipe(new ItemStack(BlockListAB.blockManaCharger), new Object[] { "NLN", "MPM", " R ", Character.valueOf('N'), new ItemStack(ItemListAB.itemABResource, 1, 1), Character.valueOf('L'), new ItemStack(ModBlocks.livingrock), Character.valueOf('M'), new ItemStack(ModBlocks.bellows), Character.valueOf('P'), new ItemStack(ModBlocks.pylon), Character.valueOf('R'), new ItemStack(ModItems.rune, 1, 8)}); - manaCharger = new BLexiconEntry("manaCharger", categoryForgotten); - manaCharger.setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[] { new PageText("0"), BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe())}); - } + public static RecipePetals alphirineRecipe; + public static RecipePetals dictariusRecipe; + public static RecipePetals aspecolusRecipe; + public static RecipePetals pureGladRecipe; + public static RecipePetals azartFlowerRecipe; - GameRegistry.addShapedRecipe(new ItemStack(ItemListAB.itemNebulaHelm), new Object[] { "RNR", "NHN", " E ", Character.valueOf('N'), new ItemStack(ItemListAB.itemABResource, 1, 5), Character.valueOf('R'), new ItemStack(ModItems.manaResource, 1, 7), Character.valueOf('H'), new ItemStack(ModItems.terrasteelHelm), Character.valueOf('E'), new ItemStack(ModItems.manaResource, 1, 8)}); - IRecipe nHelm = getLastRecipe(); - GameRegistry.addShapedRecipe(new ItemStack(ItemListAB.itemNebulaChest), new Object[] { "RTR", "NHN", "ENE", Character.valueOf('N'), new ItemStack(ItemListAB.itemABResource, 1, 5), Character.valueOf('R'), new ItemStack(ModItems.manaResource, 1, 7), Character.valueOf('H'), new ItemStack(ModItems.terrasteelChest), Character.valueOf('E'), new ItemStack(ModItems.manaResource, 1, 8), Character.valueOf('T'), new ItemStack(ModItems.flightTiara, 1, 32767)}); - IRecipe nChest = getLastRecipe(); - GameRegistry.addShapedRecipe(new ItemStack(ItemListAB.itemNebulaLegs), new Object[] { "ENE", "RHR", "NAN", Character.valueOf('N'), new ItemStack(ItemListAB.itemABResource, 1, 5), Character.valueOf('R'), new ItemStack(ModItems.manaResource, 1, 7), Character.valueOf('H'), new ItemStack(ModItems.terrasteelLegs), Character.valueOf('E'), new ItemStack(ModItems.manaResource, 1, 8), Character.valueOf('A'), new ItemStack(ItemListAB.itemABResource, 1, 3)}); - IRecipe nLegs = getLastRecipe(); - GameRegistry.addShapedRecipe(new ItemStack(ItemListAB.itemNebulaBoots), new Object[] { "RBR", "NHN", " E ", Character.valueOf('N'), new ItemStack(ItemListAB.itemABResource, 1, 5), Character.valueOf('R'), new ItemStack(ModItems.manaResource, 1, 7), Character.valueOf('H'), new ItemStack(ModItems.terrasteelBoots), Character.valueOf('E'), new ItemStack(ModItems.manaResource, 1, 8), Character.valueOf('B'), new ItemStack(ModItems.speedUpBelt)}); - IRecipe nBoots = getLastRecipe(); - nebulaArmor = new BLexiconEntry("nebulaArmor", categoryForgotten); - nebulaArmor.setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[] { new PageText("0"), new PageText("1"), BotaniaAPI.internalHandler.craftingRecipePage(".craft0", nHelm), BotaniaAPI.internalHandler.craftingRecipePage(".craft1", nChest), BotaniaAPI.internalHandler.craftingRecipePage(".craft2", nLegs), BotaniaAPI.internalHandler.craftingRecipePage(".craft3", nBoots)}); - - engineerHopper = new BLexiconEntry("engineerHopper", categoryForgotten); - engineerHopper.setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[] { new PageText("0"), new PageImage("1", "ab:textures/misc/engineerHopper.png"), new PageText("2"), new PageText("3"), new PageText("4"), new AlphirineCraftPage(engineerHopper, hopperRecipe.getOutput(), ".alphirineCraft")}); - - GameRegistry.addShapedRecipe(new ItemStack(ItemListAB.itemNebulaRod), new Object[] { " WN", " RW", "W ", Character.valueOf('W'), new ItemStack(ModItems.manaResource, 1, 13), Character.valueOf('R'), new ItemStack(ModItems.rune, 1, 8), Character.valueOf('N'), new ItemStack(ItemListAB.itemABResource, 1, 6)}); - nebulaRod = new BLexiconEntry("nebulaRod", categoryForgotten); - nebulaRod.setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[] { new PageText("0"), BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe())}); - - GameRegistry.addShapedRecipe(new ItemStack(BlockListAB.blockBoardFate), new Object[] { " ", "QDQ", "MPM", Character.valueOf('Q'), new ItemStack(ModFluffBlocks.manaQuartz), Character.valueOf('D'), new ItemStack(ModItems.manaResource, 1, 2), Character.valueOf('M'), new ItemStack(ModItems.manaResource), Character.valueOf('P'), new ItemStack(ModItems.manaResource, 1, 23)}); - gameBoard = new BLexiconEntry("gameBoard", BotaniaAPI.categoryMisc); - gameBoard.setLexiconPages(new LexiconPage[] { new PageText("0"), BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe())}); - - fateBoard = new BLexiconEntry("fateBoard", categoryForgotten); - fateBoard.setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[] { new PageText("0"), new AlphirineCraftPage(fateBoard, fateBoardRecipe.getOutput(), ".alphirineCraft")}); - - freyrSlingshot = new RLexiconEntry("freyrSlingshot", BotaniaAPI.categoryAlfhomancy, AchievementRegister.relicSlingshot); - freyrSlingshot.setLexiconPages(new LexiconPage[] { new PageText("0"), new PageText("1")}); - - richesKey = new RLexiconEntry("richesKey", BotaniaAPI.categoryAlfhomancy, AchievementRegister.relicItemChest); - richesKey.setLexiconPages(new LexiconPage[] { new PageText("0")}); - - cubeWardrobe = new RLexiconEntry("cubeWardrobe", BotaniaAPI.categoryAlfhomancy, AchievementRegister.relicPocketArmor); - cubeWardrobe.setLexiconPages(new LexiconPage[] { new PageText("0")}); - - sphereNavigation = new RLexiconEntry("sphereNavigation", BotaniaAPI.categoryAlfhomancy, AchievementRegister.sphereNavigation); - sphereNavigation.setLexiconPages(new LexiconPage[] { new PageText("0")}); - - hornPlenty = new RLexiconEntry("hornPlenty", BotaniaAPI.categoryAlfhomancy, AchievementRegister.hornPlenty); - hornPlenty.setLexiconPages(new LexiconPage[] { new PageText("0")}); + public static LexiconEntry advandedAgglomerationPlate; + public static LexiconEntry ancientAlphirine; + public static LexiconEntry lebethronWood; + public static LexiconEntry lebethronSpreader; + public static LexiconEntry mithrill; + public static LexiconEntry manaContainer; + public static LexiconEntry manaCrystalCube; + public static LexiconEntry terraHoe; + public static LexiconEntry manaRings; + public static LexiconEntry manaFlower; + public static LexiconEntry mithrillSword; + public static LexiconEntry nebula; + public static LexiconEntry blackHalo; + public static LexiconEntry antigravityCharm; + public static LexiconEntry nebulaBlaze; + public static LexiconEntry aspecolus; + public static LexiconEntry dictarius; + public static LexiconEntry manaCharger; + public static LexiconEntry nebulaArmor; + public static LexiconEntry freyrSlingshot; + public static LexiconEntry engineerHopper; + public static LexiconEntry nebulaRod; + public static LexiconEntry thaumAutoCraft; + public static LexiconEntry gladious; + public static LexiconEntry gameBoard; + public static LexiconEntry fateBoard; + public static LexiconEntry richesKey; + public static LexiconEntry cubeWardrobe; + public static LexiconEntry sphereNavigation; + public static LexiconEntry hornPlenty; + public static LexiconEntry sprawlRod; + public static LexiconEntry azartFlower; + public static LexiconEntry aquaSword; - GameRegistry.addShapedRecipe(new ItemStack(ItemListAB.itemSprawlRod), new Object[] { " SC", " WS", "W ", Character.valueOf('S'), new ItemStack(ModItems.grassSeeds, 1, 32767), Character.valueOf('C'), new ItemStack(BlockListAB.blockLebethron, 1, 4), Character.valueOf('W'), new ItemStack(ModItems.manaResource, 1, 3)}); - sprawlRod = new BLexiconEntry("sprawlRod", categoryForgotten); - sprawlRod.setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[] { new PageText("0"), BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe())}); - - azartFlowerRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType("ardentAzarcissus"), new ItemStack(ItemListAB.itemABResource, 1, 4), new ItemStack(ModItems.petal, 1, 11), new ItemStack(ModItems.petal, 1, 11), new ItemStack(ModItems.petal, 1, 14), new ItemStack(ModItems.petal, 1, 14), new ItemStack(ModItems.petal, 1, 13), new ItemStack(ModItems.manaResource, 1, 5)); - azartFlower = new BLexiconEntry("azartFlower", BotaniaAPI.categoryGenerationFlowers); - azartFlower.setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[] { new PageText("0"), BotaniaAPI.internalHandler.petalRecipePage(".petalCraft", azartFlowerRecipe)}); - - GameRegistry.addShapedRecipe(new ItemStack(ItemListAB.itemAquaSword), new Object[] { " N", "RM ", "WR ", Character.valueOf('N'), new ItemStack(ItemListAB.itemABResource, 1, 1), Character.valueOf('M'), new ItemStack(ItemListAB.itemABResource), Character.valueOf('R'), new ItemStack(ModItems.rune), Character.valueOf('W'), new ItemStack(ModItems.manaResource, 1, 13)}); - aquaSword = new BLexiconEntry("aquaSword", categoryForgotten); - aquaSword.setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[] { new PageText("0"), BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe())}); - - if(Botania.thaumcraftLoaded) - thaumcraft(); - - addShapelessOreDictRecipe(new ItemStack(ItemListAB.itemABResource, 9, 1), new Object[] { new ItemStack(ItemListAB.itemABResource)}); - addShapelessOreDictRecipe(new ItemStack(ItemListAB.itemABResource, 9, 0), new Object[] { new ItemStack(BlockListAB.blockABStorage)}); - addShapelessOreDictRecipe(new ItemStack(ItemListAB.itemABResource, 9, 6), new Object[] { new ItemStack(ItemListAB.itemABResource, 1, 5)}); - GameRegistry.addShapedRecipe(new ItemStack(BlockListAB.blockABStorage), new Object[] { "III", "III", "III", Character.valueOf('I'), new ItemStack(ItemListAB.itemABResource)}); - GameRegistry.addShapedRecipe(new ItemStack(ItemListAB.itemABResource, 1, 5), new Object[] { "III", "III", "III", Character.valueOf('I'), new ItemStack(ItemListAB.itemABResource, 1, 6)}); - } - - public static void thaumcraft() { - aspecolus = new BLexiconEntry("aspecolus", BotaniaAPI.categoryFunctionalFlowers); - aspecolusRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType("aspecolus"), new ItemStack(ModItems.manaResource, 1, 6), new ItemStack(ModItems.manaResource, 1, 5), new ItemStack(ModItems.rune, 1, 1), new ItemStack(ModItems.rune), new ItemStack(ItemListAB.itemABResource, 1, 2), new ItemStack(ModItems.petal, 1, 10), new ItemStack(ModItems.petal, 1, 13)); - aspecolus.setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[] { new PageText("0"), BotaniaAPI.internalHandler.petalRecipePage(".petalCraft", aspecolusRecipe) }).setIcon(ItemBlockSpecialFlower.ofType("aspecolus")); - addShapelessOreDictRecipe(new ItemStack(ItemListAB.itemNebulaHelmReveal), new Object[] { new ItemStack(ItemListAB.itemNebulaHelm), new ItemStack(ConfigItems.itemGoggles)}); - - if(ConfigABHandler.hasAutoThaum) { - List recipes = new ArrayList(); - for(int i = 1; i < 10; i++) { - boolean[][] patterns = ItemCraftingPattern.getPattern(i); - List str = new ArrayList(); - for(int j = 0; j < patterns.length; j++) { - String str1 = ""; - for(int k = 0; k < patterns[j].length; k++) - str1 += patterns[j][k] ? "T" : "H"; - str.add(str1); - } - GameRegistry.addShapedRecipe(new ItemStack(ItemListAB.itemCraftingPattern, 1, i), new Object[] { str.get(0), str.get(1), str.get(2), Character.valueOf('T'), new ItemStack(ItemListAB.itemCraftingPattern), Character.valueOf('H'), new ItemStack(ConfigItems.itemNugget, 1, 6)}); - recipes.add(getLastRecipe()); - } - IRecipe crate = GameRegistry.addShapedRecipe(new ItemStack(BlockListAB.blockMagicCraftCrate), new Object[] { "TST", "WCW", "W W", Character.valueOf('W'), new ItemStack(ConfigBlocks.blockMagicalLog), Character.valueOf('S'), new ItemStack(ConfigItems.itemResource, 1, 14), Character.valueOf('T'), new ItemStack(ConfigItems.itemResource, 1, 7), Character.valueOf('C'), new ItemStack(ModBlocks.openCrate, 1, 1)}); - addShapelessOreDictRecipe(new ItemStack(ItemListAB.itemCraftingPattern, 48), new Object[] { new ItemStack(Blocks.crafting_table), new ItemStack(ModBlocks.livingrock), new ItemStack(ConfigItems.itemResource, 1, 14)}); - thaumAutoCraft = new BLexiconEntry("thaumAutoCraft", BotaniaAPI.categoryDevices); - thaumAutoCraft.setKnowledgeType(BotaniaAPI.elvenKnowledge).setLexiconPages(new LexiconPage[] { new PageText("0"), BotaniaAPI.internalHandler.craftingRecipePage(".craft", crate) , BotaniaAPI.internalHandler.craftingRecipePage(".craft0", getLastRecipe()), BotaniaAPI.internalHandler.craftingRecipesPage(".craft1", recipes)}); + public static KnowledgeType forgotten; - } + public static void init() { + relicInit(); - pureGladRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType("pureGladiolus"), new ItemStack(ItemListAB.itemABResource, 1, 4), new ItemStack(ModItems.rune, 1, 8), new ItemStack(ModItems.petal, 1, 8), new ItemStack(ModItems.petal, 1, 4), new ItemStack(ModItems.petal, 1, 14), new ItemStack(ModItems.petal, 1, 5), new ItemStack(ModItems.petal, 1, 13), new ItemStack(ModItems.petal, 1, 11)); - gladious = new BLexiconEntry("gladious", BotaniaAPI.categoryFunctionalFlowers); - gladious.setKnowledgeType(forgotten).setLexiconPages(new LexiconPage[] { new PageText("0"), BotaniaAPI.internalHandler.petalRecipePage(".petalCraft", pureGladRecipe)}); - } - - public static void relicInit() { - AdvancedBotanyAPI.diceList.add(new ItemStack(ModItems.dice)); - - AdvancedBotanyAPI.relicList.add(new ItemStack(ModItems.infiniteFruit)); - AdvancedBotanyAPI.relicList.add(new ItemStack(ModItems.kingKey)); - AdvancedBotanyAPI.relicList.add(new ItemStack(ModItems.flugelEye)); - AdvancedBotanyAPI.relicList.add(new ItemStack(ModItems.thorRing)); - AdvancedBotanyAPI.relicList.add(new ItemStack(ModItems.odinRing)); - AdvancedBotanyAPI.relicList.add(new ItemStack(ModItems.lokiRing)); - AdvancedBotanyAPI.relicList.add(new ItemStack(ItemListAB.itemFreyrSlingshot)); - AdvancedBotanyAPI.relicList.add(new ItemStack(ItemListAB.itemTalismanHiddenRiches)); - AdvancedBotanyAPI.relicList.add(new ItemStack(ItemListAB.itemPocketWardrobe)); - AdvancedBotanyAPI.relicList.add(new ItemStack(ItemListAB.itemSphereNavigation)); - AdvancedBotanyAPI.relicList.add(new ItemStack(ItemListAB.itemHornPlenty)); - } - - private static IRecipe getLastRecipe() { - return (IRecipe)CraftingManager.getInstance().getRecipeList().get(CraftingManager.getInstance().getRecipeList().size() - 1); - } - - 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)); - } -} \ No newline at end of file + BotaniaAPI.addCategory(categoryForgotten = new BLexiconCategory("forgotten", 5)); + forgotten = BotaniaAPI.registerKnowledgeType("ab_forgotten", EnumChatFormatting.BLUE, false); + + lebethroneRecipe = AdvancedBotanyAPI.registerAlphirineRecipe( + new ItemStack(BlockListAB.blockLebethron), + new ItemStack(ModBlocks.dreamwood, 1, 0), + 15); + forgottenLandRecipe = AdvancedBotanyAPI.registerAlphirineRecipe( + new ItemStack(ItemListAB.itemABResource, 1, 3), + new ItemStack(ModItems.manaResource, 1, 15), + 75); + advancedSparkRecipe = AdvancedBotanyAPI.registerAlphirineRecipe( + new ItemStack(ItemListAB.itemAdvancedSpark), + new ItemStack(ModItems.spark), + 11); + manaFlowerRecipe = AdvancedBotanyAPI.registerAlphirineRecipe( + new ItemStack(ItemListAB.itemABResource, 1, 4), + new ItemStack(ModBlocks.flower, 1, 32767), + 32); + hopperRecipe = AdvancedBotanyAPI.registerAlphirineRecipe( + new ItemStack(BlockListAB.blockEngineerHopper), + new ItemStack(Blocks.hopper), + 23); + fateBoardRecipe = AdvancedBotanyAPI.registerAlphirineRecipe( + new ItemStack(BlockListAB.blockBoardFate, 1, 1), + new ItemStack(BlockListAB.blockBoardFate), + 60); + + mithrillRecipe = AdvancedBotanyAPI.registerAdvancedPlateRecipe( + new ItemStack(ItemListAB.itemABResource, 1, 0), + new ItemStack(ModItems.manaResource, 1, 5), + new ItemStack(ModBlocks.storage, 1, 0), + new ItemStack(ModItems.manaResource, 1, 18), + 2500000, + 0x25d6b7); + terrasteelRecipe = AdvancedBotanyAPI.registerAdvancedPlateRecipe( + new ItemStack(ModItems.manaResource, 1, 4), + new ItemStack(ModItems.manaResource, 1, 2), + new ItemStack(ModItems.manaResource, 1, 0), + new ItemStack(ModItems.manaResource, 1, 1), + 500000, + 0x29de20); + manaStarRecipe = AdvancedBotanyAPI.registerAdvancedPlateRecipe( + new ItemStack(ItemListAB.itemABResource, 1, 2), + new ItemStack(ModItems.manaResource, 1, 23), + new ItemStack(ModItems.manaResource, 1, 5), + new ItemStack(Items.nether_star), + 250000, + 0x6bc9ec); + nebulaRecipe = AdvancedBotanyAPI.registerAdvancedPlateRecipe( + new ItemStack(ItemListAB.itemABResource, 1, 5), + new ItemStack(ModItems.manaResource, 1, 8), + new ItemStack(ModBlocks.storage, 1, 4), + new ItemStack(ItemListAB.itemABResource, 1, 1), + 25000000, + 0x8d16e0); + + ancientAlphirine = new BLexiconEntry("ancientAlphirine", categoryForgotten); + alphirineRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType("ancientAlphirine"), + new ItemStack(ModItems.manaResource, 1, 5), + new ItemStack(ModItems.manaResource, 1, 5), + new ItemStack(ModItems.manaResource, 1, 5), + new ItemStack(ModItems.manaResource, 1, 5), + new ItemStack(ModItems.rune, 1, 8), + new ItemStack(ModItems.rune, 1, 4), + new ItemStack(ModItems.rune, 1, 5), + new ItemStack(ModItems.rune, 1, 6), + new ItemStack(ModItems.rune, 1, 7), + new ItemStack(ModItems.petal, 1, 1), + new ItemStack(ModItems.petal, 1, 4)); + ancientAlphirine.setPriority().setKnowledgeType(BotaniaAPI.elvenKnowledge).setLexiconPages( + new LexiconPage[] { new PageText("0"), new PageText("1"), + new PageImage("2", "ab:textures/misc/ancientAlphirine.png"), + BotaniaAPI.internalHandler.petalRecipePage(".petalCraft", alphirineRecipe), + new AlphirineCraftPage(ancientAlphirine, forgottenLandRecipe.getOutput(), ".alphirineCraft") }) + .setIcon(ItemBlockSpecialFlower.ofType("ancientAlphirine")); + + GameRegistry.addShapedRecipe( + new ItemStack(BlockListAB.blockABPlate), + new Object[] { "MPM", " F ", "BRB", Character.valueOf('F'), new ItemStack(Blocks.anvil), + Character.valueOf('M'), new ItemStack(ModBlocks.storage), Character.valueOf('P'), + new ItemStack(ModBlocks.terraPlate), Character.valueOf('B'), + new ItemStack(ItemListAB.itemABResource, 1, 3), Character.valueOf('R'), + new ItemStack(ModItems.rune, 1, 3) }); + advandedAgglomerationPlate = new BLexiconEntry("advancedPlate", categoryForgotten); + advandedAgglomerationPlate.setPriority().setKnowledgeType(forgotten) + .setLexiconPages( + new LexiconPage[] { new PageText("0"), + BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()), + new AdvancedPlateCraftPage( + advandedAgglomerationPlate, + terrasteelRecipe.getOutput(), + ".abCraft0"), + new AdvancedPlateCraftPage( + advandedAgglomerationPlate, + manaStarRecipe.getOutput(), + ".abCraft1") }) + .setIcon(new ItemStack(BlockListAB.blockABPlate)); + + GameRegistry.addShapedRecipe( + new ItemStack(BlockListAB.blockABSpreader), + new Object[] { "WMW", "PSP", "WMW", Character.valueOf('M'), + new ItemStack(ItemListAB.itemABResource, 1, 2), Character.valueOf('P'), + new ItemStack(ModBlocks.pylon), Character.valueOf('S'), new ItemStack(ModBlocks.spreader, 1, 3), + Character.valueOf('W'), new ItemStack(BlockListAB.blockLebethron, 1, 4) }); + lebethronSpreader = new BLexiconEntry("lebethronSpreader", categoryForgotten); + lebethronSpreader.setKnowledgeType(forgotten) + .setLexiconPages( + new LexiconPage[] { new PageText("0"), + BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()) }) + .setIcon(new ItemStack(BlockListAB.blockABSpreader)); + + addShapelessOreDictRecipe( + new ItemStack(BlockListAB.blockLebethron, 4, 1), + new Object[] { new ItemStack(BlockListAB.blockLebethron) }); + IRecipe leb1 = getLastRecipe(); + addShapelessOreDictRecipe( + new ItemStack(BlockListAB.blockLebethron, 1, 2), + new Object[] { new ItemStack(BlockListAB.blockLebethron, 1, 1), new ItemStack(Items.wheat_seeds) }); + IRecipe leb2 = getLastRecipe(); + addShapelessOreDictRecipe( + new ItemStack(BlockListAB.blockLebethron, 1, 3), + new Object[] { new ItemStack(BlockListAB.blockLebethron), new ItemStack(Items.glowstone_dust) }); + IRecipe leb3 = getLastRecipe(); + GameRegistry.addShapedRecipe( + new ItemStack(BlockListAB.blockLebethron, 1, 4), + new Object[] { "4W5", "WPW", "6W7", Character.valueOf('P'), new ItemStack(ModBlocks.pylon, 1, 1), + Character.valueOf('W'), new ItemStack(BlockListAB.blockLebethron), Character.valueOf('4'), + new ItemStack(ModItems.rune, 1, 4), Character.valueOf('5'), new ItemStack(ModItems.rune, 1, 5), + Character.valueOf('6'), new ItemStack(ModItems.rune, 1, 6), Character.valueOf('7'), + new ItemStack(ModItems.rune, 1, 7) }); + IRecipe leb4 = getLastRecipe(); + lebethronWood = new BLexiconEntry("lebethronWood", categoryForgotten); + lebethronWood.setKnowledgeType(forgotten) + .setLexiconPages( + new LexiconPage[] { new PageText("0"), + new AlphirineCraftPage(lebethronWood, lebethroneRecipe.getOutput(), ".alphirineCraft"), + BotaniaAPI.internalHandler.craftingRecipePage(".craft0", leb1), + BotaniaAPI.internalHandler.craftingRecipePage(".craft0", leb2), + BotaniaAPI.internalHandler.craftingRecipePage(".craft0", leb3), + BotaniaAPI.internalHandler.craftingRecipePage(".craft0", leb4), new PageText("1"), + BotaniaAPI.internalHandler + .multiblockPage(".structure", TileLebethronCore.makeMultiblockSet()) }) + .setIcon(new ItemStack(BlockListAB.blockLebethron)); + + GameRegistry.addShapedRecipe( + new ItemStack(ItemListAB.itemMihrillMultiTool), + new Object[] { " MB", " FM", "F ", Character.valueOf('F'), new ItemStack(ModItems.manaResource, 1, 3), + Character.valueOf('B'), new ItemStack(ModBlocks.livingwood), Character.valueOf('M'), + new ItemStack(ItemListAB.itemABResource) }); + mithrill = new BLexiconEntry("mithrill", categoryForgotten); + mithrill.setKnowledgeType(forgotten).setLexiconPages( + new LexiconPage[] { new PageText("0"), + new AdvancedPlateCraftPage(mithrill, mithrillRecipe.getOutput(), ".abCraft"), new PageText("1"), + BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()) }) + .setIcon(new ItemStack(ItemListAB.itemMihrillMultiTool)); + + GameRegistry.addShapedRecipe( + new ItemStack(BlockListAB.blockManaContainer), + new Object[] { "MGM", "LPL", "M3M", Character.valueOf('M'), new ItemStack(ItemListAB.itemABResource), + Character.valueOf('L'), new ItemStack(ModBlocks.pool), Character.valueOf('P'), + new ItemStack(ModBlocks.pylon), Character.valueOf('3'), new ItemStack(ModItems.rune, 1, 3), + Character.valueOf('G'), new ItemStack(ModItems.rune, 1, 15) }); + IRecipe cont1 = getLastRecipe(); + GameRegistry.addShapedRecipe( + new ItemStack(BlockListAB.blockManaContainer, 1, 1), + new Object[] { "MGM", "LPL", "M3M", Character.valueOf('M'), + new ItemStack(ItemListAB.itemABResource, 1, 1), Character.valueOf('L'), + new ItemStack(ModBlocks.pool, 1, 2), Character.valueOf('P'), new ItemStack(ModBlocks.pylon), + Character.valueOf('3'), new ItemStack(ModItems.rune, 1, 3), Character.valueOf('G'), + new ItemStack(ModItems.rune, 1, 15) }); + IRecipe cont2 = getLastRecipe(); + GameRegistry.addShapedRecipe( + new ItemStack(BlockListAB.blockManaContainer, 1, 2), + new Object[] { "MGM", "LPL", "M3M", Character.valueOf('M'), new ItemStack(ItemListAB.itemABResource), + Character.valueOf('L'), new ItemStack(ModBlocks.pool, 1, 3), Character.valueOf('P'), + new ItemStack(ModBlocks.pylon), Character.valueOf('3'), new ItemStack(ModItems.rune, 1, 3), + Character.valueOf('G'), new ItemStack(ModItems.rune, 1, 15) }); + IRecipe cont3 = getLastRecipe(); + manaContainer = new BLexiconEntry("manaContainer", categoryForgotten); + manaContainer.setKnowledgeType(forgotten).setLexiconPages( + new LexiconPage[] { new PageText("0"), BotaniaAPI.internalHandler.craftingRecipePage(".craft0", cont1), + BotaniaAPI.internalHandler.craftingRecipePage(".craft1", cont2), + BotaniaAPI.internalHandler.craftingRecipePage(".craft2", cont3), new PageText("1"), + new AlphirineCraftPage(manaContainer, advancedSparkRecipe.getOutput(), ".alphirineCraft") }) + .setIcon(new ItemStack(BlockListAB.blockManaContainer)); + + GameRegistry.addShapedRecipe( + new ItemStack(BlockListAB.blockManaCrystalCube), + new Object[] { "TST", "GWG", "DMD", Character.valueOf('D'), new ItemStack(ModBlocks.dreamwood), + Character.valueOf('W'), new ItemStack(ModItems.twigWand, 1, 32767), Character.valueOf('G'), + new ItemStack(ModBlocks.manaGlass), Character.valueOf('M'), + new ItemStack(ModItems.manaResource), Character.valueOf('T'), + new ItemStack(ModItems.manaResource, 1, 18), Character.valueOf('S'), + new ItemStack(ModItems.spark) }); + manaCrystalCube = new BLexiconEntry("manaCrystalCube", BotaniaAPI.categoryMana); + manaCrystalCube.setKnowledgeType(BotaniaAPI.elvenKnowledge) + .setLexiconPages( + new LexiconPage[] { new PageText("0"), + BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()) }) + .setIcon(new ItemStack(BlockListAB.blockManaCrystalCube)); + + GameRegistry.addShapedRecipe( + new ItemStack(ItemListAB.itemTerraHoe), + new Object[] { "TTL", "RW ", " W ", Character.valueOf('T'), new ItemStack(ModItems.manaResource, 1, 4), + Character.valueOf('L'), new ItemStack(ModItems.manaResource, 1, 18), Character.valueOf('W'), + new ItemStack(ModItems.manaResource, 1, 3), Character.valueOf('R'), + new ItemStack(ModItems.rune, 1, 2) }); + terraHoe = new BLexiconEntry("terraHoe", BotaniaAPI.categoryTools); + terraHoe.setLexiconPages( + new LexiconPage[] { new PageText("0"), + BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()) }) + .setIcon(new ItemStack(ItemListAB.itemTerraHoe)); + + GameRegistry.addShapedRecipe( + new ItemStack(ItemListAB.itemMithrillRing), + new Object[] { "LML", "MRM", "LML", Character.valueOf('M'), new ItemStack(ItemListAB.itemABResource), + Character.valueOf('L'), new ItemStack(ItemListAB.itemABResource, 1, 1), Character.valueOf('R'), + new ItemStack(ModItems.manaRingGreater) }); + IRecipe ring1 = getLastRecipe(); + GameRegistry.addShapedRecipe( + new ItemStack(ItemListAB.itemNebulaRing), + new Object[] { "LML", "MRM", "LML", Character.valueOf('M'), + new ItemStack(ItemListAB.itemABResource, 1, 6), Character.valueOf('L'), + new ItemStack(ModItems.manaResource, 1, 5), Character.valueOf('R'), + new ItemStack(ItemListAB.itemMithrillRing) }); + IRecipe ring2 = getLastRecipe(); + manaRings = new BLexiconEntry("manaRings", categoryForgotten); + manaRings.setKnowledgeType(forgotten).setLexiconPages( + new LexiconPage[] { new PageText("0"), BotaniaAPI.internalHandler.craftingRecipePage(".craft0", ring1), + BotaniaAPI.internalHandler.craftingRecipePage(".craft1", ring2) }) + .setIcon(new ItemStack(ItemListAB.itemMithrillRing)); + AdvancedBotanyAPI.registerFarmlandSeed(Blocks.nether_wart, 3); + + GameRegistry.addShapedRecipe( + new ItemStack(ItemListAB.itemManaFlower), + new Object[] { " F ", " M ", " R ", Character.valueOf('F'), + new ItemStack(ItemListAB.itemABResource, 1, 4), Character.valueOf('M'), + new ItemStack(ModItems.manaBottle), Character.valueOf('R'), + new ItemStack(ModItems.rune, 1, 8) }); + manaFlower = new BLexiconEntry("manaFlower", categoryForgotten); + manaFlower.setKnowledgeType(forgotten) + .setLexiconPages( + new LexiconPage[] { new PageText("0"), + new AlphirineCraftPage(manaFlower, manaFlowerRecipe.getOutput(), ".alphirineCraft"), + BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()) }) + .setIcon(new ItemStack(ItemListAB.itemManaFlower)); + + GameRegistry.addShapedRecipe( + new ItemStack(ItemListAB.itemMithrillSword), + new Object[] { " M", "SM ", "WS ", Character.valueOf('S'), + new ItemStack(ItemListAB.itemABResource, 1, 6), Character.valueOf('T'), + new ItemStack(ModItems.terraSword), Character.valueOf('M'), + new ItemStack(ItemListAB.itemABResource), Character.valueOf('W'), + new ItemStack(ModItems.manaResource, 1, 3) }); + mithrillSword = new BLexiconEntry("mithrillSword", categoryForgotten); + mithrillSword.setKnowledgeType(forgotten) + .setLexiconPages( + new LexiconPage[] { new PageText("0"), new PageText("1"), + BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()) }) + .setIcon(new ItemStack(ItemListAB.itemMithrillSword)); + + dictariusRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType("dictarius"), + new ItemStack(ItemListAB.itemABResource, 1, 4), + new ItemStack(ModItems.manaResource, 1, 5), + new ItemStack(ModItems.manaResource, 1, 5), + new ItemStack(ModItems.rune, 1, 15), + new ItemStack(ModItems.petal, 1, 4), + new ItemStack(ModItems.petal, 1, 4), + new ItemStack(ModItems.petal, 1, 1)); + dictarius = new BLexiconEntry("dictarius", BotaniaAPI.categoryGenerationFlowers); + dictarius.setKnowledgeType(forgotten).setLexiconPages( + new LexiconPage[] { new PageText("0"), new PageText("1"), + BotaniaAPI.internalHandler.petalRecipePage(".petalCraft", dictariusRecipe) }); + + nebula = new BLexiconEntry("nebula", categoryForgotten); + nebula.setKnowledgeType(forgotten).setLexiconPages( + new LexiconPage[] { new PageText("0"), + new AdvancedPlateCraftPage(nebula, nebulaRecipe.getOutput(), ".abCraft") }); + + GameRegistry.addShapedRecipe( + new ItemStack(ItemListAB.itemBlackHalo), + new Object[] { " E ", "DHD", " E ", Character.valueOf('E'), new ItemStack(ModItems.manaResource, 1, 7), + Character.valueOf('H'), new ItemStack(ModItems.autocraftingHalo), Character.valueOf('D'), + new ItemStack(ModItems.blackHoleTalisman) }); + blackHalo = new BLexiconEntry("blackHalo", BotaniaAPI.categoryTools); + blackHalo.setKnowledgeType(BotaniaAPI.elvenKnowledge).setLexiconPages( + new LexiconPage[] { new PageText("0"), + BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()) }); + + GameRegistry.addShapedRecipe( + new ItemStack(ItemListAB.itemAntigravityCharm), + new Object[] { " G ", "GDG", "ERE", Character.valueOf('E'), new ItemStack(ModItems.manaResource, 1, 7), + Character.valueOf('G'), new ItemStack(ModBlocks.elfGlass), Character.valueOf('D'), + new ItemStack(ModBlocks.floatingFlower, 1, 32767), Character.valueOf('R'), + new ItemStack(ModItems.rune, 1, 3) }); + antigravityCharm = new BLexiconEntry("antigravityCharm", BotaniaAPI.categoryTools); + antigravityCharm.setKnowledgeType(BotaniaAPI.elvenKnowledge) + .setLexiconPages( + new LexiconPage[] { new PageText("0"), + BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()) }) + .setIcon(new ItemStack(ItemListAB.itemAntigravityCharm)); + + GameRegistry.addShapedRecipe( + new ItemStack(ItemListAB.itemNebulaBlaze), + new Object[] { " N ", "MMN", "AMN", Character.valueOf('N'), + new ItemStack(ItemListAB.itemABResource, 1, 6), Character.valueOf('A'), + new ItemStack(ItemListAB.itemABResource, 1, 3), Character.valueOf('M'), + new ItemStack(ModBlocks.storage) }); + nebulaBlaze = new BLexiconEntry("nebulaBlaze", categoryForgotten); + nebulaBlaze.setKnowledgeType(forgotten).setLexiconPages( + new LexiconPage[] { new PageText("0"), + BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()) }); + + if (ConfigABHandler.hasManaCharger) { + GameRegistry.addShapedRecipe( + new ItemStack(BlockListAB.blockManaCharger), + new Object[] { "NLN", "MPM", " R ", Character.valueOf('N'), + new ItemStack(ItemListAB.itemABResource, 1, 1), Character.valueOf('L'), + new ItemStack(ModBlocks.livingrock), Character.valueOf('M'), + new ItemStack(ModBlocks.bellows), Character.valueOf('P'), new ItemStack(ModBlocks.pylon), + Character.valueOf('R'), new ItemStack(ModItems.rune, 1, 8) }); + manaCharger = new BLexiconEntry("manaCharger", categoryForgotten); + manaCharger.setKnowledgeType(forgotten).setLexiconPages( + new LexiconPage[] { new PageText("0"), + BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()) }); + } + + GameRegistry.addShapedRecipe( + new ItemStack(ItemListAB.itemNebulaHelm), + new Object[] { "RNR", "NHN", " E ", Character.valueOf('N'), + new ItemStack(ItemListAB.itemABResource, 1, 5), Character.valueOf('R'), + new ItemStack(ModItems.manaResource, 1, 7), Character.valueOf('H'), + new ItemStack(ModItems.terrasteelHelm), Character.valueOf('E'), + new ItemStack(ModItems.manaResource, 1, 8) }); + IRecipe nHelm = getLastRecipe(); + GameRegistry.addShapedRecipe( + new ItemStack(ItemListAB.itemNebulaChest), + new Object[] { "RTR", "NHN", "ENE", Character.valueOf('N'), + new ItemStack(ItemListAB.itemABResource, 1, 5), Character.valueOf('R'), + new ItemStack(ModItems.manaResource, 1, 7), Character.valueOf('H'), + new ItemStack(ModItems.terrasteelChest), Character.valueOf('E'), + new ItemStack(ModItems.manaResource, 1, 8), Character.valueOf('T'), + new ItemStack(ModItems.flightTiara, 1, 32767) }); + IRecipe nChest = getLastRecipe(); + GameRegistry.addShapedRecipe( + new ItemStack(ItemListAB.itemNebulaLegs), + new Object[] { "ENE", "RHR", "NAN", Character.valueOf('N'), + new ItemStack(ItemListAB.itemABResource, 1, 5), Character.valueOf('R'), + new ItemStack(ModItems.manaResource, 1, 7), Character.valueOf('H'), + new ItemStack(ModItems.terrasteelLegs), Character.valueOf('E'), + new ItemStack(ModItems.manaResource, 1, 8), Character.valueOf('A'), + new ItemStack(ItemListAB.itemABResource, 1, 3) }); + IRecipe nLegs = getLastRecipe(); + GameRegistry.addShapedRecipe( + new ItemStack(ItemListAB.itemNebulaBoots), + new Object[] { "RBR", "NHN", " E ", Character.valueOf('N'), + new ItemStack(ItemListAB.itemABResource, 1, 5), Character.valueOf('R'), + new ItemStack(ModItems.manaResource, 1, 7), Character.valueOf('H'), + new ItemStack(ModItems.terrasteelBoots), Character.valueOf('E'), + new ItemStack(ModItems.manaResource, 1, 8), Character.valueOf('B'), + new ItemStack(ModItems.speedUpBelt) }); + IRecipe nBoots = getLastRecipe(); + nebulaArmor = new BLexiconEntry("nebulaArmor", categoryForgotten); + nebulaArmor.setKnowledgeType(forgotten).setLexiconPages( + new LexiconPage[] { new PageText("0"), new PageText("1"), + BotaniaAPI.internalHandler.craftingRecipePage(".craft0", nHelm), + BotaniaAPI.internalHandler.craftingRecipePage(".craft1", nChest), + BotaniaAPI.internalHandler.craftingRecipePage(".craft2", nLegs), + BotaniaAPI.internalHandler.craftingRecipePage(".craft3", nBoots) }); + + engineerHopper = new BLexiconEntry("engineerHopper", categoryForgotten); + engineerHopper.setKnowledgeType(forgotten).setLexiconPages( + new LexiconPage[] { new PageText("0"), new PageImage("1", "ab:textures/misc/engineerHopper.png"), + new PageText("2"), new PageText("3"), new PageText("4"), + new AlphirineCraftPage(engineerHopper, hopperRecipe.getOutput(), ".alphirineCraft") }); + + GameRegistry.addShapedRecipe( + new ItemStack(ItemListAB.itemNebulaRod), + new Object[] { " WN", " RW", "W ", Character.valueOf('W'), new ItemStack(ModItems.manaResource, 1, 13), + Character.valueOf('R'), new ItemStack(ModItems.rune, 1, 8), Character.valueOf('N'), + new ItemStack(ItemListAB.itemABResource, 1, 6) }); + nebulaRod = new BLexiconEntry("nebulaRod", categoryForgotten); + nebulaRod.setKnowledgeType(forgotten).setLexiconPages( + new LexiconPage[] { new PageText("0"), + BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()) }); + + GameRegistry.addShapedRecipe( + new ItemStack(BlockListAB.blockBoardFate), + new Object[] { " ", "QDQ", "MPM", Character.valueOf('Q'), new ItemStack(ModFluffBlocks.manaQuartz), + Character.valueOf('D'), new ItemStack(ModItems.manaResource, 1, 2), Character.valueOf('M'), + new ItemStack(ModItems.manaResource), Character.valueOf('P'), + new ItemStack(ModItems.manaResource, 1, 23) }); + gameBoard = new BLexiconEntry("gameBoard", BotaniaAPI.categoryMisc); + gameBoard.setLexiconPages( + new LexiconPage[] { new PageText("0"), + BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()) }); + + fateBoard = new BLexiconEntry("fateBoard", categoryForgotten); + fateBoard.setKnowledgeType(forgotten).setLexiconPages( + new LexiconPage[] { new PageText("0"), + new AlphirineCraftPage(fateBoard, fateBoardRecipe.getOutput(), ".alphirineCraft") }); + + freyrSlingshot = new RLexiconEntry( + "freyrSlingshot", + BotaniaAPI.categoryAlfhomancy, + AchievementRegister.relicSlingshot); + freyrSlingshot.setLexiconPages(new LexiconPage[] { new PageText("0"), new PageText("1") }); + + richesKey = new RLexiconEntry("richesKey", BotaniaAPI.categoryAlfhomancy, AchievementRegister.relicItemChest); + richesKey.setLexiconPages(new LexiconPage[] { new PageText("0") }); + + cubeWardrobe = new RLexiconEntry( + "cubeWardrobe", + BotaniaAPI.categoryAlfhomancy, + AchievementRegister.relicPocketArmor); + cubeWardrobe.setLexiconPages(new LexiconPage[] { new PageText("0") }); + + sphereNavigation = new RLexiconEntry( + "sphereNavigation", + BotaniaAPI.categoryAlfhomancy, + AchievementRegister.sphereNavigation); + sphereNavigation.setLexiconPages(new LexiconPage[] { new PageText("0") }); + + hornPlenty = new RLexiconEntry("hornPlenty", BotaniaAPI.categoryAlfhomancy, AchievementRegister.hornPlenty); + hornPlenty.setLexiconPages(new LexiconPage[] { new PageText("0") }); + + GameRegistry.addShapedRecipe( + new ItemStack(ItemListAB.itemSprawlRod), + new Object[] { " SC", " WS", "W ", Character.valueOf('S'), + new ItemStack(ModItems.grassSeeds, 1, 32767), Character.valueOf('C'), + new ItemStack(BlockListAB.blockLebethron, 1, 4), Character.valueOf('W'), + new ItemStack(ModItems.manaResource, 1, 3) }); + sprawlRod = new BLexiconEntry("sprawlRod", categoryForgotten); + sprawlRod.setKnowledgeType(forgotten).setLexiconPages( + new LexiconPage[] { new PageText("0"), + BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()) }); + + azartFlowerRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType("ardentAzarcissus"), + new ItemStack(ItemListAB.itemABResource, 1, 4), + new ItemStack(ModItems.petal, 1, 11), + new ItemStack(ModItems.petal, 1, 11), + new ItemStack(ModItems.petal, 1, 14), + new ItemStack(ModItems.petal, 1, 14), + new ItemStack(ModItems.petal, 1, 13), + new ItemStack(ModItems.manaResource, 1, 5)); + azartFlower = new BLexiconEntry("azartFlower", BotaniaAPI.categoryGenerationFlowers); + azartFlower.setKnowledgeType(forgotten).setLexiconPages( + new LexiconPage[] { new PageText("0"), + BotaniaAPI.internalHandler.petalRecipePage(".petalCraft", azartFlowerRecipe) }); + + GameRegistry.addShapedRecipe( + new ItemStack(ItemListAB.itemAquaSword), + new Object[] { " N", "RM ", "WR ", Character.valueOf('N'), + new ItemStack(ItemListAB.itemABResource, 1, 1), Character.valueOf('M'), + new ItemStack(ItemListAB.itemABResource), Character.valueOf('R'), new ItemStack(ModItems.rune), + Character.valueOf('W'), new ItemStack(ModItems.manaResource, 1, 13) }); + aquaSword = new BLexiconEntry("aquaSword", categoryForgotten); + aquaSword.setKnowledgeType(forgotten).setLexiconPages( + new LexiconPage[] { new PageText("0"), + BotaniaAPI.internalHandler.craftingRecipePage(".craft", getLastRecipe()) }); + + if (Botania.thaumcraftLoaded) thaumcraft(); + + addShapelessOreDictRecipe( + new ItemStack(ItemListAB.itemABResource, 9, 1), + new Object[] { new ItemStack(ItemListAB.itemABResource) }); + addShapelessOreDictRecipe( + new ItemStack(ItemListAB.itemABResource, 9, 0), + new Object[] { new ItemStack(BlockListAB.blockABStorage) }); + addShapelessOreDictRecipe( + new ItemStack(ItemListAB.itemABResource, 9, 6), + new Object[] { new ItemStack(ItemListAB.itemABResource, 1, 5) }); + GameRegistry.addShapedRecipe( + new ItemStack(BlockListAB.blockABStorage), + new Object[] { "III", "III", "III", Character.valueOf('I'), new ItemStack(ItemListAB.itemABResource) }); + GameRegistry.addShapedRecipe( + new ItemStack(ItemListAB.itemABResource, 1, 5), + new Object[] { "III", "III", "III", Character.valueOf('I'), + new ItemStack(ItemListAB.itemABResource, 1, 6) }); + } + + public static void thaumcraft() { + aspecolus = new BLexiconEntry("aspecolus", BotaniaAPI.categoryFunctionalFlowers); + aspecolusRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType("aspecolus"), + new ItemStack(ModItems.manaResource, 1, 6), + new ItemStack(ModItems.manaResource, 1, 5), + new ItemStack(ModItems.rune, 1, 1), + new ItemStack(ModItems.rune), + new ItemStack(ItemListAB.itemABResource, 1, 2), + new ItemStack(ModItems.petal, 1, 10), + new ItemStack(ModItems.petal, 1, 13)); + aspecolus.setKnowledgeType(forgotten) + .setLexiconPages( + new LexiconPage[] { new PageText("0"), + BotaniaAPI.internalHandler.petalRecipePage(".petalCraft", aspecolusRecipe) }) + .setIcon(ItemBlockSpecialFlower.ofType("aspecolus")); + addShapelessOreDictRecipe( + new ItemStack(ItemListAB.itemNebulaHelmReveal), + new Object[] { new ItemStack(ItemListAB.itemNebulaHelm), new ItemStack(ConfigItems.itemGoggles) }); + + if (ConfigABHandler.hasAutoThaum) { + List recipes = new ArrayList(); + for (int i = 1; i < 10; i++) { + boolean[][] patterns = ItemCraftingPattern.getPattern(i); + List str = new ArrayList(); + for (int j = 0; j < patterns.length; j++) { + String str1 = ""; + for (int k = 0; k < patterns[j].length; k++) str1 += patterns[j][k] ? "T" : "H"; + str.add(str1); + } + GameRegistry.addShapedRecipe( + new ItemStack(ItemListAB.itemCraftingPattern, 1, i), + new Object[] { str.get(0), str.get(1), str.get(2), Character.valueOf('T'), + new ItemStack(ItemListAB.itemCraftingPattern), Character.valueOf('H'), + new ItemStack(ConfigItems.itemNugget, 1, 6) }); + recipes.add(getLastRecipe()); + } + IRecipe crate = GameRegistry.addShapedRecipe( + new ItemStack(BlockListAB.blockMagicCraftCrate), + new Object[] { "TST", "WCW", "W W", Character.valueOf('W'), + new ItemStack(ConfigBlocks.blockMagicalLog), Character.valueOf('S'), + new ItemStack(ConfigItems.itemResource, 1, 14), Character.valueOf('T'), + new ItemStack(ConfigItems.itemResource, 1, 7), Character.valueOf('C'), + new ItemStack(ModBlocks.openCrate, 1, 1) }); + addShapelessOreDictRecipe( + new ItemStack(ItemListAB.itemCraftingPattern, 48), + new Object[] { new ItemStack(Blocks.crafting_table), new ItemStack(ModBlocks.livingrock), + new ItemStack(ConfigItems.itemResource, 1, 14) }); + thaumAutoCraft = new BLexiconEntry("thaumAutoCraft", BotaniaAPI.categoryDevices); + thaumAutoCraft.setKnowledgeType(BotaniaAPI.elvenKnowledge).setLexiconPages( + new LexiconPage[] { new PageText("0"), + BotaniaAPI.internalHandler.craftingRecipePage(".craft", crate), + BotaniaAPI.internalHandler.craftingRecipePage(".craft0", getLastRecipe()), + BotaniaAPI.internalHandler.craftingRecipesPage(".craft1", recipes) }); + + } + + pureGladRecipe = BotaniaAPI.registerPetalRecipe( + ItemBlockSpecialFlower.ofType("pureGladiolus"), + new ItemStack(ItemListAB.itemABResource, 1, 4), + new ItemStack(ModItems.rune, 1, 8), + new ItemStack(ModItems.petal, 1, 8), + new ItemStack(ModItems.petal, 1, 4), + new ItemStack(ModItems.petal, 1, 14), + new ItemStack(ModItems.petal, 1, 5), + new ItemStack(ModItems.petal, 1, 13), + new ItemStack(ModItems.petal, 1, 11)); + gladious = new BLexiconEntry("gladious", BotaniaAPI.categoryFunctionalFlowers); + gladious.setKnowledgeType(forgotten).setLexiconPages( + new LexiconPage[] { new PageText("0"), + BotaniaAPI.internalHandler.petalRecipePage(".petalCraft", pureGladRecipe) }); + } + + public static void relicInit() { + AdvancedBotanyAPI.diceList.add(new ItemStack(ModItems.dice)); + + AdvancedBotanyAPI.relicList.add(new ItemStack(ModItems.infiniteFruit)); + AdvancedBotanyAPI.relicList.add(new ItemStack(ModItems.kingKey)); + AdvancedBotanyAPI.relicList.add(new ItemStack(ModItems.flugelEye)); + AdvancedBotanyAPI.relicList.add(new ItemStack(ModItems.thorRing)); + AdvancedBotanyAPI.relicList.add(new ItemStack(ModItems.odinRing)); + AdvancedBotanyAPI.relicList.add(new ItemStack(ModItems.lokiRing)); + AdvancedBotanyAPI.relicList.add(new ItemStack(ItemListAB.itemFreyrSlingshot)); + AdvancedBotanyAPI.relicList.add(new ItemStack(ItemListAB.itemTalismanHiddenRiches)); + AdvancedBotanyAPI.relicList.add(new ItemStack(ItemListAB.itemPocketWardrobe)); + AdvancedBotanyAPI.relicList.add(new ItemStack(ItemListAB.itemSphereNavigation)); + AdvancedBotanyAPI.relicList.add(new ItemStack(ItemListAB.itemHornPlenty)); + } + + private static IRecipe getLastRecipe() { + return (IRecipe) CraftingManager.getInstance().getRecipeList() + .get(CraftingManager.getInstance().getRecipeList().size() - 1); + } + + 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/ab/common/minetweaker/AdvancedPlateMT.java b/src/main/java/ab/common/minetweaker/AdvancedPlateMT.java index 73345bc..32ba90e 100644 --- a/src/main/java/ab/common/minetweaker/AdvancedPlateMT.java +++ b/src/main/java/ab/common/minetweaker/AdvancedPlateMT.java @@ -1,98 +1,109 @@ package ab.common.minetweaker; -import ab.api.AdvancedBotanyAPI; -import ab.api.recipe.RecipeAdvancedPlate; import minetweaker.IUndoableAction; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; import minetweaker.api.minecraft.MineTweakerMC; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; +import ab.api.AdvancedBotanyAPI; +import ab.api.recipe.RecipeAdvancedPlate; @ZenClass("mods.advBotany.AdvancedPlate") public class AdvancedPlateMT { - - @ZenMethod - public static void addRecipe(IItemStack output, String rgb, IItemStack input1, IItemStack input2, IItemStack input3, int mana) { - MineTweakerAPI.apply(new Add(new RecipeAdvancedPlate(MineTweakerMC.getItemStack(output), mana, Integer.decode(rgb), MineTweakerMC.getItemStack(input1), MineTweakerMC.getItemStack(input2), MineTweakerMC.getItemStack(input3)))); - } - - private static class Add implements IUndoableAction { - - private RecipeAdvancedPlate recipe; - - public Add(RecipeAdvancedPlate recipe) { - this.recipe = recipe; - } - - public void apply() { - AdvancedBotanyAPI.advancedPlateRecipes.add(recipe); - } - - public boolean canUndo() { - return true; - } - - public void undo() { - AdvancedBotanyAPI.advancedPlateRecipes.remove(recipe); - } - - public String describe() { - return "Adding Advanced Plate Recipe for " + recipe.getOutput().getDisplayName(); - } - - public String describeUndo() { - return "Removing Advanced Plate Recipe for " + recipe.getOutput().getDisplayName(); - } - - public Object getOverrideKey() { - return null; - } - } - - @ZenMethod - public static void remove(IItemStack output) { - MineTweakerAPI.apply(new Remove(MineTweakerMC.getItemStack(output))); - } - - private static class Remove implements IUndoableAction { - - private ItemStack output; - private RecipeAdvancedPlate recipe; - - public Remove(ItemStack output) { - this.output = output; - } - - public void apply() { - for(RecipeAdvancedPlate r : AdvancedBotanyAPI.advancedPlateRecipes) { - if(r.getOutput() != null && r.getOutput().isItemEqual(output)) { - AdvancedBotanyAPI.advancedPlateRecipes.remove(r); - recipe = r; - break; - } - } - } - - public boolean canUndo() { - return true; - } - - public void undo() { - AdvancedBotanyAPI.advancedPlateRecipes.add(recipe); - } - - public String describe() { - return "Removing Advanced Plate Recipe for " + output.getDisplayName(); - } - - public String describeUndo() { - return "Restoring Advanced Plate Recipe for " + output.getDisplayName(); - } - - public Object getOverrideKey() { - return null; - } - } -} \ No newline at end of file + + @ZenMethod + public static void addRecipe(IItemStack output, String rgb, IItemStack input1, IItemStack input2, IItemStack input3, + int mana) { + MineTweakerAPI.apply( + new Add( + new RecipeAdvancedPlate( + MineTweakerMC.getItemStack(output), + mana, + Integer.decode(rgb), + MineTweakerMC.getItemStack(input1), + MineTweakerMC.getItemStack(input2), + MineTweakerMC.getItemStack(input3)))); + } + + private static class Add implements IUndoableAction { + + private RecipeAdvancedPlate recipe; + + public Add(RecipeAdvancedPlate recipe) { + this.recipe = recipe; + } + + public void apply() { + AdvancedBotanyAPI.advancedPlateRecipes.add(recipe); + } + + public boolean canUndo() { + return true; + } + + public void undo() { + AdvancedBotanyAPI.advancedPlateRecipes.remove(recipe); + } + + public String describe() { + return "Adding Advanced Plate Recipe for " + recipe.getOutput().getDisplayName(); + } + + public String describeUndo() { + return "Removing Advanced Plate Recipe for " + recipe.getOutput().getDisplayName(); + } + + public Object getOverrideKey() { + return null; + } + } + + @ZenMethod + public static void remove(IItemStack output) { + MineTweakerAPI.apply(new Remove(MineTweakerMC.getItemStack(output))); + } + + private static class Remove implements IUndoableAction { + + private ItemStack output; + private RecipeAdvancedPlate recipe; + + public Remove(ItemStack output) { + this.output = output; + } + + public void apply() { + for (RecipeAdvancedPlate r : AdvancedBotanyAPI.advancedPlateRecipes) { + if (r.getOutput() != null && r.getOutput().isItemEqual(output)) { + AdvancedBotanyAPI.advancedPlateRecipes.remove(r); + recipe = r; + break; + } + } + } + + public boolean canUndo() { + return true; + } + + public void undo() { + AdvancedBotanyAPI.advancedPlateRecipes.add(recipe); + } + + public String describe() { + return "Removing Advanced Plate Recipe for " + output.getDisplayName(); + } + + public String describeUndo() { + return "Restoring Advanced Plate Recipe for " + output.getDisplayName(); + } + + public Object getOverrideKey() { + return null; + } + } +} diff --git a/src/main/java/ab/common/minetweaker/AdvancedPlatePageMT.java b/src/main/java/ab/common/minetweaker/AdvancedPlatePageMT.java index 83d6f76..4af8657 100644 --- a/src/main/java/ab/common/minetweaker/AdvancedPlatePageMT.java +++ b/src/main/java/ab/common/minetweaker/AdvancedPlatePageMT.java @@ -2,145 +2,145 @@ package ab.common.minetweaker; import java.util.List; -import ab.api.recipe.lexicon.AdvancedPlateCraftPage; import minetweaker.IUndoableAction; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; import minetweaker.api.minecraft.MineTweakerMC; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconPage; +import ab.api.recipe.lexicon.AdvancedPlateCraftPage; @ZenClass("mods.advBotany.AdvancedPlatePage") public class AdvancedPlatePageMT { - - @ZenMethod - public static void refresh(String name, int page) { - List entries = BotaniaAPI.getAllEntries(); - LexiconEntry entry = null; - LexiconPage recipePage = null; - for(int i = 0; i < entries.size(); i++) { - if(((LexiconEntry)entries.get(i)).getUnlocalizedName().equalsIgnoreCase(name)) { - entry = entries.get(i); - recipePage = entries.get(i).pages.get(page); - break; - } - } - if(entry == null) { - MineTweakerAPI.getLogger().logError("Cannot find lexicon entry"); - return; - } - else if(recipePage == null || !(recipePage instanceof AdvancedPlateCraftPage)) { - MineTweakerAPI.getLogger().logError("Cannot find Advanced Plate Craft Page"); - return; - } - MineTweakerAPI.apply(new RefreshPage(entry, (AdvancedPlateCraftPage)recipePage, page)); - } - - private static class RefreshPage implements IUndoableAction { - - private LexiconEntry entry; - private AdvancedPlateCraftPage page; - private ItemStack result; - private int pageCount; - - public RefreshPage(LexiconEntry lexEntry, AdvancedPlateCraftPage abPlatePage, int count) { - page = abPlatePage; - result = abPlatePage.getResult(); - pageCount = count; - entry = lexEntry; - } - - public void apply() { - page.refreshRecipe(entry, result); - } - - public boolean canUndo() { - return true; - } - - public void undo() { - for(LexiconPage page : entry.pages) { - if(page instanceof AdvancedPlateCraftPage) { - AdvancedPlateCraftPage platePage = (AdvancedPlateCraftPage)page; - if(platePage.getResult().isItemEqual(result)) - return; - } - } - entry.pages.add(pageCount, new AdvancedPlateCraftPage(entry, result, page.getUnlocalizedName())); - } - - public String describe() { - return "Refresh Advanced Plate Page for item " + result.getDisplayName(); - } - - public String describeUndo() { - return "Undo Refresh Advanced Plate Page for item " + result.getDisplayName(); - } - - public Object getOverrideKey() { - return null; - } - } - - @ZenMethod - public static void addPage(String name, int page, IItemStack stack, String text) { - LexiconEntry entry = null; - ItemStack result = MineTweakerMC.getItemStack(stack); - List entries = BotaniaAPI.getAllEntries(); - for(int i = 0; i < entries.size(); i++) { - if(((LexiconEntry)entries.get(i)).getUnlocalizedName().equalsIgnoreCase(name)) { - entry = entries.get(i); - break; - } - } - if(entry == null) { - MineTweakerAPI.getLogger().logError("Cannot find lexicon entry"); - return; - } - page = Math.min(entry.pages.size(), page); - MineTweakerAPI.apply(new AddPage(entry, result, page, text)); - } - - private static class AddPage implements IUndoableAction { - - private LexiconEntry entry; - private ItemStack result; - private int pageCount; - private String name; - - public AddPage(LexiconEntry lexEntry, ItemStack stack, int count, String text) { - entry = lexEntry; - result = stack; - pageCount = count; - name = text; - } - - public void apply() { - entry.pages.add(pageCount, new AdvancedPlateCraftPage(entry, result, name)); - } - - public boolean canUndo() { - return true; - } - - public void undo() { - entry.pages.remove(pageCount); - } - - public String describe() { - return "Add Advanced Plate Page for item " + result.getDisplayName(); - } - - public String describeUndo() { - return "Remove Advanced Plate Page for item " + result.getDisplayName(); - } - - public Object getOverrideKey() { - return null; - } - } -} \ No newline at end of file + + @ZenMethod + public static void refresh(String name, int page) { + List entries = BotaniaAPI.getAllEntries(); + LexiconEntry entry = null; + LexiconPage recipePage = null; + for (int i = 0; i < entries.size(); i++) { + if (((LexiconEntry) entries.get(i)).getUnlocalizedName().equalsIgnoreCase(name)) { + entry = entries.get(i); + recipePage = entries.get(i).pages.get(page); + break; + } + } + if (entry == null) { + MineTweakerAPI.getLogger().logError("Cannot find lexicon entry"); + return; + } else if (recipePage == null || !(recipePage instanceof AdvancedPlateCraftPage)) { + MineTweakerAPI.getLogger().logError("Cannot find Advanced Plate Craft Page"); + return; + } + MineTweakerAPI.apply(new RefreshPage(entry, (AdvancedPlateCraftPage) recipePage, page)); + } + + private static class RefreshPage implements IUndoableAction { + + private LexiconEntry entry; + private AdvancedPlateCraftPage page; + private ItemStack result; + private int pageCount; + + public RefreshPage(LexiconEntry lexEntry, AdvancedPlateCraftPage abPlatePage, int count) { + page = abPlatePage; + result = abPlatePage.getResult(); + pageCount = count; + entry = lexEntry; + } + + public void apply() { + page.refreshRecipe(entry, result); + } + + public boolean canUndo() { + return true; + } + + public void undo() { + for (LexiconPage page : entry.pages) { + if (page instanceof AdvancedPlateCraftPage) { + AdvancedPlateCraftPage platePage = (AdvancedPlateCraftPage) page; + if (platePage.getResult().isItemEqual(result)) return; + } + } + entry.pages.add(pageCount, new AdvancedPlateCraftPage(entry, result, page.getUnlocalizedName())); + } + + public String describe() { + return "Refresh Advanced Plate Page for item " + result.getDisplayName(); + } + + public String describeUndo() { + return "Undo Refresh Advanced Plate Page for item " + result.getDisplayName(); + } + + public Object getOverrideKey() { + return null; + } + } + + @ZenMethod + public static void addPage(String name, int page, IItemStack stack, String text) { + LexiconEntry entry = null; + ItemStack result = MineTweakerMC.getItemStack(stack); + List entries = BotaniaAPI.getAllEntries(); + for (int i = 0; i < entries.size(); i++) { + if (((LexiconEntry) entries.get(i)).getUnlocalizedName().equalsIgnoreCase(name)) { + entry = entries.get(i); + break; + } + } + if (entry == null) { + MineTweakerAPI.getLogger().logError("Cannot find lexicon entry"); + return; + } + page = Math.min(entry.pages.size(), page); + MineTweakerAPI.apply(new AddPage(entry, result, page, text)); + } + + private static class AddPage implements IUndoableAction { + + private LexiconEntry entry; + private ItemStack result; + private int pageCount; + private String name; + + public AddPage(LexiconEntry lexEntry, ItemStack stack, int count, String text) { + entry = lexEntry; + result = stack; + pageCount = count; + name = text; + } + + public void apply() { + entry.pages.add(pageCount, new AdvancedPlateCraftPage(entry, result, name)); + } + + public boolean canUndo() { + return true; + } + + public void undo() { + entry.pages.remove(pageCount); + } + + public String describe() { + return "Add Advanced Plate Page for item " + result.getDisplayName(); + } + + public String describeUndo() { + return "Remove Advanced Plate Page for item " + result.getDisplayName(); + } + + public Object getOverrideKey() { + return null; + } + } +} diff --git a/src/main/java/ab/common/minetweaker/AlphirineMT.java b/src/main/java/ab/common/minetweaker/AlphirineMT.java index 9aef082..d8fc6cc 100644 --- a/src/main/java/ab/common/minetweaker/AlphirineMT.java +++ b/src/main/java/ab/common/minetweaker/AlphirineMT.java @@ -1,98 +1,105 @@ package ab.common.minetweaker; -import ab.api.AdvancedBotanyAPI; -import ab.api.recipe.RecipeAncientAlphirine; import minetweaker.IUndoableAction; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; import minetweaker.api.minecraft.MineTweakerMC; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; +import ab.api.AdvancedBotanyAPI; +import ab.api.recipe.RecipeAncientAlphirine; @ZenClass("mods.advBotany.AncientAlphirine") public class AlphirineMT { - - @ZenMethod - public static void addRecipe(IItemStack output, IItemStack input, int chance) { - MineTweakerAPI.apply(new Add(new RecipeAncientAlphirine(MineTweakerMC.getItemStack(output), MineTweakerMC.getItemStack(input), chance))); - } - - private static class Add implements IUndoableAction { - - private RecipeAncientAlphirine recipe; - - public Add(RecipeAncientAlphirine recipe) { - this.recipe = recipe; - } - - public void apply() { - AdvancedBotanyAPI.alphirineRecipes.add(recipe); - } - - public boolean canUndo() { - return true; - } - - public void undo() { - AdvancedBotanyAPI.alphirineRecipes.remove(recipe); - } - - public String describe() { - return "Adding Ancient Alphirine Recipe for " + recipe.getOutput().getDisplayName(); - } - - public String describeUndo() { - return "Removing Ancient Alphirine Recipe for " + recipe.getOutput().getDisplayName(); - } - - public Object getOverrideKey() { - return null; - } - } - - @ZenMethod - public static void remove(IItemStack output) { - MineTweakerAPI.apply(new Remove(MineTweakerMC.getItemStack(output))); - } - - private static class Remove implements IUndoableAction { - - private ItemStack output; - private RecipeAncientAlphirine recipe; - - public Remove(ItemStack output) { - this.output = output; - } - - public void apply() { - for(RecipeAncientAlphirine r : AdvancedBotanyAPI.alphirineRecipes) { - if(r.getOutput() != null && r.getOutput().isItemEqual(output)) { - AdvancedBotanyAPI.alphirineRecipes.remove(r); - recipe = r; - break; - } - } - } - - public boolean canUndo() { - return true; - } - - public void undo() { - AdvancedBotanyAPI.alphirineRecipes.add(recipe); - } - - public String describe() { - return "Removing Ancient Alphirine Recipe for " + output.getDisplayName(); - } - - public String describeUndo() { - return "Restoring Ancient Alphirinedvanced Plate Recipe for " + output.getDisplayName(); - } - - public Object getOverrideKey() { - return null; - } - } -} \ No newline at end of file + + @ZenMethod + public static void addRecipe(IItemStack output, IItemStack input, int chance) { + MineTweakerAPI.apply( + new Add( + new RecipeAncientAlphirine( + MineTweakerMC.getItemStack(output), + MineTweakerMC.getItemStack(input), + chance))); + } + + private static class Add implements IUndoableAction { + + private RecipeAncientAlphirine recipe; + + public Add(RecipeAncientAlphirine recipe) { + this.recipe = recipe; + } + + public void apply() { + AdvancedBotanyAPI.alphirineRecipes.add(recipe); + } + + public boolean canUndo() { + return true; + } + + public void undo() { + AdvancedBotanyAPI.alphirineRecipes.remove(recipe); + } + + public String describe() { + return "Adding Ancient Alphirine Recipe for " + recipe.getOutput().getDisplayName(); + } + + public String describeUndo() { + return "Removing Ancient Alphirine Recipe for " + recipe.getOutput().getDisplayName(); + } + + public Object getOverrideKey() { + return null; + } + } + + @ZenMethod + public static void remove(IItemStack output) { + MineTweakerAPI.apply(new Remove(MineTweakerMC.getItemStack(output))); + } + + private static class Remove implements IUndoableAction { + + private ItemStack output; + private RecipeAncientAlphirine recipe; + + public Remove(ItemStack output) { + this.output = output; + } + + public void apply() { + for (RecipeAncientAlphirine r : AdvancedBotanyAPI.alphirineRecipes) { + if (r.getOutput() != null && r.getOutput().isItemEqual(output)) { + AdvancedBotanyAPI.alphirineRecipes.remove(r); + recipe = r; + break; + } + } + } + + public boolean canUndo() { + return true; + } + + public void undo() { + AdvancedBotanyAPI.alphirineRecipes.add(recipe); + } + + public String describe() { + return "Removing Ancient Alphirine Recipe for " + output.getDisplayName(); + } + + public String describeUndo() { + return "Restoring Ancient Alphirinedvanced Plate Recipe for " + output.getDisplayName(); + } + + public Object getOverrideKey() { + return null; + } + } +} diff --git a/src/main/java/ab/common/minetweaker/AlphirinePageMT.java b/src/main/java/ab/common/minetweaker/AlphirinePageMT.java index c18992c..a666468 100644 --- a/src/main/java/ab/common/minetweaker/AlphirinePageMT.java +++ b/src/main/java/ab/common/minetweaker/AlphirinePageMT.java @@ -1,145 +1,146 @@ package ab.common.minetweaker; import java.util.List; -import ab.api.recipe.lexicon.AlphirineCraftPage; + import minetweaker.IUndoableAction; import minetweaker.MineTweakerAPI; import minetweaker.api.item.IItemStack; import minetweaker.api.minecraft.MineTweakerMC; + import net.minecraft.item.ItemStack; + import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconPage; +import ab.api.recipe.lexicon.AlphirineCraftPage; @ZenClass("mods.advBotany.AlphirinePage") public class AlphirinePageMT { - - @ZenMethod - public static void refresh(String name, int page) { - List entries = BotaniaAPI.getAllEntries(); - LexiconEntry entry = null; - LexiconPage recipePage = null; - for(int i = 0; i < entries.size(); i++) { - if(((LexiconEntry)entries.get(i)).getUnlocalizedName().equalsIgnoreCase(name)) { - entry = entries.get(i); - recipePage = entries.get(i).pages.get(page); - break; - } - } - if(entry == null) { - MineTweakerAPI.getLogger().logError("Cannot find lexicon entry"); - return; - } - else if(recipePage == null || !(recipePage instanceof AlphirineCraftPage)) { - MineTweakerAPI.getLogger().logError("Cannot find Alphirine Craft Page"); - return; - } - MineTweakerAPI.apply(new RefreshPage(entry, (AlphirineCraftPage)recipePage, page)); - } - - private static class RefreshPage implements IUndoableAction { - - private LexiconEntry entry; - private AlphirineCraftPage page; - private ItemStack result; - private int pageCount; - - public RefreshPage(LexiconEntry lexEntry, AlphirineCraftPage abPlatePage, int count) { - page = abPlatePage; - result = abPlatePage.getResult(); - pageCount = count; - entry = lexEntry; - } - - public void apply() { - page.refreshRecipe(entry, result); - } - - public boolean canUndo() { - return true; - } - - public void undo() { - for(LexiconPage page : entry.pages) { - if(page instanceof AlphirineCraftPage) { - AlphirineCraftPage platePage = (AlphirineCraftPage)page; - if(platePage.getResult().isItemEqual(result)) - return; - } - } - entry.pages.add(pageCount, new AlphirineCraftPage(entry, result, page.getUnlocalizedName())); - } - - public String describe() { - return "Refresh Alphirine Page for item " + result.getDisplayName(); - } - - public String describeUndo() { - return "Undo Refresh Alphirine Page for item " + result.getDisplayName(); - } - - public Object getOverrideKey() { - return null; - } - } - - @ZenMethod - public static void addPage(String name, int page, IItemStack stack, String text) { - LexiconEntry entry = null; - ItemStack result = MineTweakerMC.getItemStack(stack); - List entries = BotaniaAPI.getAllEntries(); - for(int i = 0; i < entries.size(); i++) { - if(((LexiconEntry)entries.get(i)).getUnlocalizedName().equalsIgnoreCase(name)) { - entry = entries.get(i); - break; - } - } - if(entry == null) { - MineTweakerAPI.getLogger().logError("Cannot find lexicon entry"); - return; - } - page = Math.min(entry.pages.size(), page); - MineTweakerAPI.apply(new AddPage(entry, result, page, text)); - } - - private static class AddPage implements IUndoableAction { - - private LexiconEntry entry; - private ItemStack result; - private int pageCount; - private String name; - - public AddPage(LexiconEntry lexEntry, ItemStack stack, int count, String text) { - entry = lexEntry; - result = stack; - pageCount = count; - name = text; - } - - public void apply() { - entry.pages.add(pageCount, new AlphirineCraftPage(entry, result, name)); - } - - public boolean canUndo() { - return true; - } - - public void undo() { - entry.pages.remove(pageCount); - } - - public String describe() { - return "Add Alphirine Page for item " + result.getDisplayName(); - } - - public String describeUndo() { - return "Remove Alphirine Page for item " + result.getDisplayName(); - } - - public Object getOverrideKey() { - return null; - } - } -} \ No newline at end of file + + @ZenMethod + public static void refresh(String name, int page) { + List entries = BotaniaAPI.getAllEntries(); + LexiconEntry entry = null; + LexiconPage recipePage = null; + for (int i = 0; i < entries.size(); i++) { + if (((LexiconEntry) entries.get(i)).getUnlocalizedName().equalsIgnoreCase(name)) { + entry = entries.get(i); + recipePage = entries.get(i).pages.get(page); + break; + } + } + if (entry == null) { + MineTweakerAPI.getLogger().logError("Cannot find lexicon entry"); + return; + } else if (recipePage == null || !(recipePage instanceof AlphirineCraftPage)) { + MineTweakerAPI.getLogger().logError("Cannot find Alphirine Craft Page"); + return; + } + MineTweakerAPI.apply(new RefreshPage(entry, (AlphirineCraftPage) recipePage, page)); + } + + private static class RefreshPage implements IUndoableAction { + + private LexiconEntry entry; + private AlphirineCraftPage page; + private ItemStack result; + private int pageCount; + + public RefreshPage(LexiconEntry lexEntry, AlphirineCraftPage abPlatePage, int count) { + page = abPlatePage; + result = abPlatePage.getResult(); + pageCount = count; + entry = lexEntry; + } + + public void apply() { + page.refreshRecipe(entry, result); + } + + public boolean canUndo() { + return true; + } + + public void undo() { + for (LexiconPage page : entry.pages) { + if (page instanceof AlphirineCraftPage) { + AlphirineCraftPage platePage = (AlphirineCraftPage) page; + if (platePage.getResult().isItemEqual(result)) return; + } + } + entry.pages.add(pageCount, new AlphirineCraftPage(entry, result, page.getUnlocalizedName())); + } + + public String describe() { + return "Refresh Alphirine Page for item " + result.getDisplayName(); + } + + public String describeUndo() { + return "Undo Refresh Alphirine Page for item " + result.getDisplayName(); + } + + public Object getOverrideKey() { + return null; + } + } + + @ZenMethod + public static void addPage(String name, int page, IItemStack stack, String text) { + LexiconEntry entry = null; + ItemStack result = MineTweakerMC.getItemStack(stack); + List entries = BotaniaAPI.getAllEntries(); + for (int i = 0; i < entries.size(); i++) { + if (((LexiconEntry) entries.get(i)).getUnlocalizedName().equalsIgnoreCase(name)) { + entry = entries.get(i); + break; + } + } + if (entry == null) { + MineTweakerAPI.getLogger().logError("Cannot find lexicon entry"); + return; + } + page = Math.min(entry.pages.size(), page); + MineTweakerAPI.apply(new AddPage(entry, result, page, text)); + } + + private static class AddPage implements IUndoableAction { + + private LexiconEntry entry; + private ItemStack result; + private int pageCount; + private String name; + + public AddPage(LexiconEntry lexEntry, ItemStack stack, int count, String text) { + entry = lexEntry; + result = stack; + pageCount = count; + name = text; + } + + public void apply() { + entry.pages.add(pageCount, new AlphirineCraftPage(entry, result, name)); + } + + public boolean canUndo() { + return true; + } + + public void undo() { + entry.pages.remove(pageCount); + } + + public String describe() { + return "Add Alphirine Page for item " + result.getDisplayName(); + } + + public String describeUndo() { + return "Remove Alphirine Page for item " + result.getDisplayName(); + } + + public Object getOverrideKey() { + return null; + } + } +} diff --git a/src/main/java/ab/common/minetweaker/MineTweakerConfig.java b/src/main/java/ab/common/minetweaker/MineTweakerConfig.java index 9f1e0d4..b557d1a 100644 --- a/src/main/java/ab/common/minetweaker/MineTweakerConfig.java +++ b/src/main/java/ab/common/minetweaker/MineTweakerConfig.java @@ -4,10 +4,10 @@ import minetweaker.MineTweakerAPI; public class MineTweakerConfig { - public static void registerMT() { - MineTweakerAPI.registerClass(AdvancedPlateMT.class); - MineTweakerAPI.registerClass(AdvancedPlatePageMT.class); - MineTweakerAPI.registerClass(AlphirineMT.class); - MineTweakerAPI.registerClass(AlphirinePageMT.class); - } + public static void registerMT() { + MineTweakerAPI.registerClass(AdvancedPlateMT.class); + MineTweakerAPI.registerClass(AdvancedPlatePageMT.class); + MineTweakerAPI.registerClass(AlphirineMT.class); + MineTweakerAPI.registerClass(AlphirinePageMT.class); + } }