diff --git a/apis/mcp/mobius/waila/api/IWailaBlock.java b/apis/mcp/mobius/waila/api/IWailaBlock.java deleted file mode 100644 index 8b4dd13..0000000 --- a/apis/mcp/mobius/waila/api/IWailaBlock.java +++ /dev/null @@ -1,34 +0,0 @@ -package mcp.mobius.waila.api; - -import java.util.List; - -import net.minecraft.item.ItemStack; - -@Deprecated -public interface IWailaBlock { - /* - * Use this method to return an item stack in case the default lookup system fails. - * Return null if you want to use the default lookup system. - * You get the world, the player and the location of the block. With that, it is easy to gather information & tile entities - */ - ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config); - - /* Waila HUD is divided into 3 zones. The head corresponds to the item name, - * body to where you mostly want to put informations, and I reserve the tail for modname display - */ - - /* Those 2 methods works exactly the same way, except they are related to a different zone in Waila HUD. - * You get in input world, player and the block location. You also get the itemstack as returned by the default lookup system or getWailaStack(). - * ConfigHandler provides the current Waila config state so you can show/hide elements depending on the configuration. Refer the ConfigHandler class for more info. - * currenttip represents the current list of text lines in the tooltip zone. - * For example, getWailaHead() will have the current item name as currenttip. - * You can modify the tips, add more, remove some, etc. - * When you are done, just returns the currenttip and it will display in Waila. - * - * Always return the currenttip is you don't want to modify the current zone. - */ - - List getWailaHead(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config); - List getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config); - List getWailaTail(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config); -} diff --git a/apis/mcp/mobius/waila/api/IWailaBlockDecorator.java b/apis/mcp/mobius/waila/api/IWailaBlockDecorator.java deleted file mode 100644 index 935d475..0000000 --- a/apis/mcp/mobius/waila/api/IWailaBlockDecorator.java +++ /dev/null @@ -1,9 +0,0 @@ -package mcp.mobius.waila.api; - -import net.minecraft.item.ItemStack; - -public interface IWailaBlockDecorator { - - void decorateBlock(ItemStack itemStack, IWailaDataAccessor accessor, IWailaConfigHandler config); - -} diff --git a/apis/mcp/mobius/waila/api/IWailaConfigHandler.java b/apis/mcp/mobius/waila/api/IWailaConfigHandler.java deleted file mode 100644 index faede63..0000000 --- a/apis/mcp/mobius/waila/api/IWailaConfigHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -package mcp.mobius.waila.api; - -import java.util.HashMap; -import java.util.Set; - -public interface IWailaConfigHandler { - /* Returns a set of all the currently loaded modules in the config handler */ - public Set getModuleNames(); - - /* Returns all the currently available options for a given module */ - public HashMap getConfigKeys(String modName); - - /* Add a new option to a given module - * - * modName is the name of the module to add the option to (ie : Buildcraft, IndustrialCraft2, etc) - * key is the config key (ie : bc.tankcontent, ic2.inputvalue) - * name is the human readable name of the option (ie : "Tank content", "Max EU Input") - * */ - //public void addConfig(String modName, String key, String name); - - /* Returns the current value of an option (true/false) with a default value defvalue if not set*/ - public boolean getConfig(String key, boolean defvalue); - - /* Returns the current value of an option (true/false) with a default value true if not set*/ - public boolean getConfig(String key); - - //public void setConfig(String key, boolean value); -} diff --git a/apis/mcp/mobius/waila/api/IWailaDataAccessor.java b/apis/mcp/mobius/waila/api/IWailaDataAccessor.java deleted file mode 100644 index 0288624..0000000 --- a/apis/mcp/mobius/waila/api/IWailaDataAccessor.java +++ /dev/null @@ -1,33 +0,0 @@ -package mcp.mobius.waila.api; - -import net.minecraft.block.Block; -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.MovingObjectPosition; -import net.minecraft.util.Vec3; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -/* The Accessor is used to get some basic data out of the game without having to request - * direct access to the game engine. - * It will also return things that are unmodified by the overriding systems (like getWailaStack). - */ - -public interface IWailaDataAccessor { - - World getWorld(); - EntityPlayer getPlayer(); - Block getBlock(); - int getBlockID(); - int getMetadata(); - TileEntity getTileEntity(); - MovingObjectPosition getPosition(); - Vec3 getRenderingPosition(); - NBTTagCompound getNBTData(); - int getNBTInteger(NBTTagCompound tag, String keyname); - double getPartialFrame(); - ForgeDirection getSide(); - ItemStack getStack(); -} diff --git a/apis/mcp/mobius/waila/api/IWailaDataProvider.java b/apis/mcp/mobius/waila/api/IWailaDataProvider.java deleted file mode 100644 index 4859d9c..0000000 --- a/apis/mcp/mobius/waila/api/IWailaDataProvider.java +++ /dev/null @@ -1,33 +0,0 @@ -package mcp.mobius.waila.api; - -import java.util.List; - -import net.minecraft.item.ItemStack; - -public interface IWailaDataProvider{ - /* - * Use this method to return an item stack in case the default lookup system fails. - * Return null if you want to use the default lookup system. - * You get the world, the player and the location of the block. With that, it is easy to gather information & tile entities - */ - ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config); - - /* Waila HUD is divided into 3 zones. The head corresponds to the item name, - * body to where you mostly want to put informations, and I reserve the tail for modname display - */ - - /* Those 2 methods works exactly the same way, except they are related to a different zone in Waila HUD. - * You get in input world, player and the block location. You also get the itemstack as returned by the default lookup system or getWailaStack(). - * ConfigHandler provides the current Waila config state so you can show/hide elements depending on the configuration. Refer the ConfigHandler class for more info. - * currenttip represents the current list of text lines in the tooltip zone. - * For example, getWailaHead() will have the current item name as currenttip. - * You can modify the tips, add more, remove some, etc. - * When you are done, just returns the currenttip and it will display in Waila. - * - * Always return the currenttip is you don't want to modify the current zone. - */ - - List getWailaHead(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config); - List getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config); - List getWailaTail(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config); -} diff --git a/apis/mcp/mobius/waila/api/IWailaEntityAccessor.java b/apis/mcp/mobius/waila/api/IWailaEntityAccessor.java deleted file mode 100644 index 788067a..0000000 --- a/apis/mcp/mobius/waila/api/IWailaEntityAccessor.java +++ /dev/null @@ -1,24 +0,0 @@ -package mcp.mobius.waila.api; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.Vec3; -import net.minecraft.world.World; - -/* The Accessor is used to get some basic data out of the game without having to request - * direct access to the game engine. - * It will also return things that are unmodified by the overriding systems (like getWailaStack). - */ - -public interface IWailaEntityAccessor { - World getWorld(); - EntityPlayer getPlayer(); - Entity getEntity(); - MovingObjectPosition getPosition(); - Vec3 getRenderingPosition(); - NBTTagCompound getNBTData(); - int getNBTInteger(NBTTagCompound tag, String keyname); - double getPartialFrame(); -} diff --git a/apis/mcp/mobius/waila/api/IWailaEntityProvider.java b/apis/mcp/mobius/waila/api/IWailaEntityProvider.java deleted file mode 100644 index 9548289..0000000 --- a/apis/mcp/mobius/waila/api/IWailaEntityProvider.java +++ /dev/null @@ -1,16 +0,0 @@ -package mcp.mobius.waila.api; - -import java.util.List; - -import net.minecraft.entity.Entity; - -public interface IWailaEntityProvider { - - /* A way to get an override on the entity returned by the raytracing */ - Entity getWailaOverride(IWailaEntityAccessor accessor, IWailaConfigHandler config); - - /* The classical HEAD/BODY/TAIL text getters */ - List getWailaHead(Entity entity, List currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config); - List getWailaBody(Entity entity, List currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config); - List getWailaTail(Entity entity, List currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config); -} diff --git a/apis/mcp/mobius/waila/api/IWailaFMPAccessor.java b/apis/mcp/mobius/waila/api/IWailaFMPAccessor.java deleted file mode 100644 index 19e01fa..0000000 --- a/apis/mcp/mobius/waila/api/IWailaFMPAccessor.java +++ /dev/null @@ -1,27 +0,0 @@ -package mcp.mobius.waila.api; - -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.MovingObjectPosition; -import net.minecraft.util.Vec3; -import net.minecraft.world.World; - -/* The Accessor is used to get some basic data out of the game without having to request - * direct access to the game engine. - * It will also return things that are unmodified by the overriding systems (like getWailaStack). - */ - -public interface IWailaFMPAccessor { - World getWorld(); - EntityPlayer getPlayer(); - TileEntity getTileEntity(); - MovingObjectPosition getPosition(); - NBTTagCompound getNBTData(); - NBTTagCompound getFullNBTData(); - int getNBTInteger(NBTTagCompound tag, String keyname); - double getPartialFrame(); - Vec3 getRenderingPosition(); - String getID(); -} diff --git a/apis/mcp/mobius/waila/api/IWailaFMPDecorator.java b/apis/mcp/mobius/waila/api/IWailaFMPDecorator.java deleted file mode 100644 index 839af31..0000000 --- a/apis/mcp/mobius/waila/api/IWailaFMPDecorator.java +++ /dev/null @@ -1,7 +0,0 @@ -package mcp.mobius.waila.api; - -import net.minecraft.item.ItemStack; - -public interface IWailaFMPDecorator { - void decorateBlock(ItemStack itemStack, IWailaFMPAccessor accessor, IWailaConfigHandler config); -} diff --git a/apis/mcp/mobius/waila/api/IWailaFMPProvider.java b/apis/mcp/mobius/waila/api/IWailaFMPProvider.java deleted file mode 100644 index 232c83e..0000000 --- a/apis/mcp/mobius/waila/api/IWailaFMPProvider.java +++ /dev/null @@ -1,12 +0,0 @@ -package mcp.mobius.waila.api; - -import java.util.List; - -import net.minecraft.item.ItemStack; - -public interface IWailaFMPProvider { - /* The classical HEAD/BODY/TAIL text getters */ - List getWailaHead(ItemStack itemStack, List currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config); - List getWailaBody(ItemStack itemStack, List currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config); - List getWailaTail(ItemStack itemStack, List currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config); -} diff --git a/apis/mcp/mobius/waila/api/IWailaRegistrar.java b/apis/mcp/mobius/waila/api/IWailaRegistrar.java deleted file mode 100644 index 162aeb6..0000000 --- a/apis/mcp/mobius/waila/api/IWailaRegistrar.java +++ /dev/null @@ -1,44 +0,0 @@ -package mcp.mobius.waila.api; - -public interface IWailaRegistrar { - /* Add a config option in the section modname with displayed text configtext and access key keyname */ - public void addConfig(String modname, String keyname, String configtext); - public void addConfigRemote(String modname, String keyname, String configtext); - public void addConfig(String modname, String keyname); - public void addConfigRemote(String modname, String keyname); - - /* Register a stack overrider for the given blockID */ - public void registerStackProvider(IWailaDataProvider dataProvider, Class block); - - /* Same thing, but works on a class hierarchy instead */ - public void registerHeadProvider (IWailaDataProvider dataProvider, Class block); - public void registerBodyProvider (IWailaDataProvider dataProvider, Class block); - public void registerTailProvider (IWailaDataProvider dataProvider, Class block); - - /* Entity text registration methods */ - public void registerHeadProvider (IWailaEntityProvider dataProvider, Class entity); - public void registerBodyProvider (IWailaEntityProvider dataProvider, Class entity); - public void registerTailProvider (IWailaEntityProvider dataProvider, Class entity); - public void registerOverrideEntityProvider (IWailaEntityProvider dataProvider, Class entity); - - /* FMP Providers */ - public void registerHeadProvider(IWailaFMPProvider dataProvider, String name); - public void registerBodyProvider(IWailaFMPProvider dataProvider, String name); - public void registerTailProvider(IWailaFMPProvider dataProvider, String name); - - /* The block decorators */ - public void registerDecorator (IWailaBlockDecorator decorator, Class block); - public void registerDecorator (IWailaFMPDecorator decorator, String name); - - /* Selective NBT key syncing. Will register a key to sync over the network for the given class (block, te or ent). - * Accept * as a ending wildcard - * registerNBTKey("bob.*", MyBlock.class) - * registerNBTKey("data.life", MyEntity.class) - * registerNBTKey("*", MyTileEntity.class) will reproduce the full tag syncing from 1.4.5 - * */ - public void registerSyncedNBTKey(String key, Class target); - - /* UNUSED FOR NOW (Will be used for the ingame wiki */ - public void registerDocTextFile (String filename); - public void registerShortDataProvider (IWailaSummaryProvider dataProvider, Class item); -} diff --git a/apis/mcp/mobius/waila/api/IWailaSummaryProvider.java b/apis/mcp/mobius/waila/api/IWailaSummaryProvider.java deleted file mode 100644 index f790649..0000000 --- a/apis/mcp/mobius/waila/api/IWailaSummaryProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -package mcp.mobius.waila.api; - -import java.util.LinkedHashMap; - -import net.minecraft.item.ItemStack; - -public interface IWailaSummaryProvider { - /* This interface is used to control the display data in the description screen */ - - /* BASIC TOOLS & ITEMS DATA */ - //EnumToolMaterial getMaterial(ItemStack stack); - //String getMaterialName(ItemStack stack); - //String getEffectiveBlock(ItemStack stack); - //int getHarvestLevel(ItemStack stack); - //float getEfficiencyOnProperMaterial(ItemStack stack); - //int getEnchantability(ItemStack stack); - //int getDamageVsEntity(ItemStack stack); - //int getDurability(ItemStack stack); - - LinkedHashMap getSummary(ItemStack stack, LinkedHashMap currentSummary, IWailaConfigHandler config); -} diff --git a/apis/mcp/mobius/waila/api/SpecialChars.java b/apis/mcp/mobius/waila/api/SpecialChars.java deleted file mode 100644 index 5bd92a8..0000000 --- a/apis/mcp/mobius/waila/api/SpecialChars.java +++ /dev/null @@ -1,40 +0,0 @@ -package mcp.mobius.waila.api; - -public class SpecialChars { - - public static String MCStyle = "\u00A7"; - - public static String BLACK = MCStyle + "0"; - public static String DBLUE = MCStyle + "1"; - public static String DGREEN = MCStyle + "2"; - public static String DAQUA = MCStyle + "3"; - public static String DRED = MCStyle + "4"; - public static String DPURPLE = MCStyle + "5"; - public static String GOLD = MCStyle + "6"; - public static String GRAY = MCStyle + "7"; - public static String DGRAY = MCStyle + "8"; - public static String BLUE = MCStyle + "9"; - public static String GREEN = MCStyle + "a"; - public static String AQUA = MCStyle + "b"; - public static String RED = MCStyle + "c"; - public static String LPURPLE = MCStyle + "d"; - public static String YELLOW = MCStyle + "e"; - public static String WHITE = MCStyle + "f"; - - public static String OBF = MCStyle + "k"; - public static String BOLD = MCStyle + "l"; - public static String STRIKE = MCStyle + "m"; - public static String UNDER = MCStyle + "n"; - public static String ITALIC = MCStyle + "o"; - public static String RESET = MCStyle + "r"; - - public static String WailaStyle = "\u00A4"; - public static String WailaIcon = "\u00A5"; - public static String TAB = WailaStyle + WailaStyle +"a"; - public static String ALIGNRIGHT = WailaStyle + WailaStyle +"b"; - public static String ALIGNCENTER = WailaStyle + WailaStyle +"c"; - public static String HEART = WailaStyle + WailaIcon +"a"; - public static String HHEART = WailaStyle + WailaIcon +"b"; - public static String EHEART = WailaStyle + WailaIcon +"c"; - -} diff --git a/apis/mcp/mobius/waila/api/package-info.java b/apis/mcp/mobius/waila/api/package-info.java deleted file mode 100644 index 9b5e663..0000000 --- a/apis/mcp/mobius/waila/api/package-info.java +++ /dev/null @@ -1,3 +0,0 @@ -@API(apiVersion="1.0",owner="Waila",provides="WailaAPI") -package mcp.mobius.waila.api; -import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/build.gradle b/build.gradle index bd4ec43..ca941af 100644 --- a/build.gradle +++ b/build.gradle @@ -1,83 +1,77 @@ buildscript { - repositories { - mavenCentral() - maven { - name = "forge" - url = "http://files.minecraftforge.net/maven" - } - maven { - name = "sonatype" - url = "https://oss.sonatype.org/content/repositories/snapshots/" - } - } - dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' - } + repositories { + mavenCentral() + maven { + name = "forge" + url = "http://files.minecraftforge.net/maven" + } + maven { + name = "sonatype" + url = "https://oss.sonatype.org/content/repositories/snapshots/" + } + } + dependencies { + classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' + } } apply plugin: 'forge' minecraft { - version = "1.7.2-10.12.1.1060" + version = "1.8-11.14.1.1334" + mappings = "snapshot_20141130" +} + +repositories { + maven { + url "http://mobiusstrip.eu/maven" + } + maven { + url "http://chickenbones.net/maven/" + } +} + +dependencies { + compile "mcp.mobius.waila:Waila:1.6.0_B1_1.8.1" } group = project.projectDir.name.toLowerCase() archivesBaseName = project.projectDir.name + "-mc" + project.minecraft.version sourceSets.main{ - java { - srcDirs 'java', 'apis' //set the source folder as the /src subfolder + java { + srcDirs 'java', 'apis' } - resources { - srcDirs 'resources' //set the resources folder as the /resources subfolder + resources { + srcDirs 'resources' } } -dependencies { - compile fileTree(dir: 'libs', include: '*.jar,*.zip') -} - -// variable replacement in source files -task processSourcesCustom(type:Copy){ +// variable substitution in java files +task processSourceMainJava(type:Copy) { + inputs.property "vars", project.version + project.minecraft.version from('java') { include '**/ModInfo.java' - + include '**/package-info.java' expand 'version':project.version, 'mcversion':project.minecraft.version } into project.buildDir.getPath()+"/sources/java" } -// remove waila api from the build -task removeWailaAPI(type:Delete) { - delete += sourceSets.main.output.classesDir.getPath()+"/mcp" -} - -// delete mcmod.info so that it gets a fresh version copied in every time -task cleanModInfo(type: Delete) { - delete file(sourceSets.main.output.resourcesDir.getPath()+"/mcmod.info") -} - // correct task ordering -processResources.dependsOn cleanModInfo -compileJava.dependsOn processSourcesCustom afterEvaluate { project -> - processSourcesCustom.shouldRunAfter(sourceMainJava) - compileJava.finalizedBy(removeWailaAPI) + sourceMainJava.finalizedBy(processSourceMainJava) } processResources { - // replace stuff in mcmod.info, nothing else - from(sourceSets.main.resources.srcDirs) { - include 'mcmod.info' - - // replace version and mcversion - expand 'version':project.version, 'mcversion':project.minecraft.version - } - - // copy everything else, thats not the mcmod.info - from(sourceSets.main.resources.srcDirs) { - exclude 'mcmod.info' - } + inputs.property "vars", project.version + project.minecraft.version + from(sourceSets.main.resources.srcDirs) { + include '**/*.info' + expand 'version':project.version, 'mcversion':project.minecraft.version + } + from(sourceSets.main.resources.srcDirs) { + exclude '**/*.info' + } } \ No newline at end of file diff --git a/java/squeek/wailaharvestability/ModWailaHarvestability.java b/java/squeek/wailaharvestability/ModWailaHarvestability.java index f7ac58b..f1b104f 100644 --- a/java/squeek/wailaharvestability/ModWailaHarvestability.java +++ b/java/squeek/wailaharvestability/ModWailaHarvestability.java @@ -1,17 +1,14 @@ package squeek.wailaharvestability; -import squeek.wailaharvestability.helpers.ToolHelper; -import squeek.wailaharvestability.proxy.ProxyIguanaTweaks; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLInterModComms; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import squeek.wailaharvestability.setup.MissingHarvestInfo; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLInterModComms; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @Mod(modid = ModInfo.MODID, version = ModInfo.VERSION, dependencies = "after:TConstruct;after:ExtraTiC;after:TSteelworks;after:Mariculture", acceptableRemoteVersions = "*") public class ModWailaHarvestability @@ -39,12 +36,5 @@ public class ModWailaHarvestability @EventHandler public void postInit(FMLPostInitializationEvent event) { - if (Loader.isModLoaded("IguanaTweaksTConstruct")) - { - hasIguanaTweaks = true; - ProxyIguanaTweaks.init(); - } - - ToolHelper.init(); } } diff --git a/java/squeek/wailaharvestability/WailaHandler.java b/java/squeek/wailaharvestability/WailaHandler.java index 6451a91..ad7a879 100644 --- a/java/squeek/wailaharvestability/WailaHandler.java +++ b/java/squeek/wailaharvestability/WailaHandler.java @@ -5,12 +5,14 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; +import mcp.mobius.waila.api.ITaggedList.ITipList; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; +import mcp.mobius.waila.api.IWailaDataAccessorServer; import mcp.mobius.waila.api.IWailaDataProvider; import mcp.mobius.waila.api.IWailaRegistrar; -import mcp.mobius.waila.api.impl.ConfigHandler; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -18,8 +20,10 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemShears; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.StatCollector; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.IShearable; @@ -39,18 +43,12 @@ public class WailaHandler implements IWailaDataProvider } @Override - public List getWailaHead(ItemStack itemStack, List toolTip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { - return toolTip; - } - - @Override - public List getWailaBody(ItemStack itemStack, List toolTip, IWailaDataAccessor accessor, IWailaConfigHandler config) + public ITipList getWailaBody(ItemStack itemStack, ITipList toolTip, IWailaDataAccessor accessor, IWailaConfigHandler config) { Block block = accessor.getBlock(); - int meta = accessor.getMetadata(); + IBlockState blockState = accessor.getBlockState(); - if (ProxyCreativeBlocks.isCreativeBlock(block, meta)) + if (ProxyCreativeBlocks.isCreativeBlock(block, accessor.getMetadata())) return toolTip; EntityPlayer player = accessor.getPlayer(); @@ -59,14 +57,14 @@ public class WailaHandler implements IWailaDataProvider if (itemStack.getItem() instanceof ItemBlock) { block = Block.getBlockFromItem(itemStack.getItem()); - meta = itemStack.getItemDamage(); + blockState = block.getStateFromMeta(itemStack.getItemDamage()); } boolean minimalLayout = config.getConfig("harvestability.minimal", false); - + List stringParts = new ArrayList(); - getHarvestability(stringParts, player, block, meta, accessor.getPosition(), config, minimalLayout); - + getHarvestability(stringParts, player, block, blockState, accessor.getPosition(), config, minimalLayout); + if (!stringParts.isEmpty()) { if (minimalLayout) @@ -74,11 +72,11 @@ public class WailaHandler implements IWailaDataProvider else toolTip.addAll(stringParts); } - + return toolTip; } - - public void getHarvestability(List stringList, EntityPlayer player, Block block, int meta, MovingObjectPosition position, IWailaConfigHandler config, boolean minimalLayout) + + public void getHarvestability(List stringList, EntityPlayer player, Block block, IBlockState blockState, BlockPos position, IWailaConfigHandler config, boolean minimalLayout) { boolean isSneaking = player.isSneaking(); boolean showHarvestLevel = config.getConfig("harvestability.harvestlevel") && (!config.getConfig("harvestability.harvestlevel.sneakingonly") || isSneaking); @@ -90,31 +88,26 @@ public class WailaHandler implements IWailaDataProvider if (showHarvestLevel || showEffectiveTool || showCurrentlyHarvestable) { - if (showOresOnly && !OreHelper.isBlockAnOre(block, meta)) + if (showOresOnly && !OreHelper.isBlockAnOre(block, block.getMetaFromState(blockState))) { return; } - if (BlockHelper.isBlockUnbreakable(block, player.worldObj, position.blockX, position.blockY, position.blockZ)) + if (BlockHelper.isBlockUnbreakable(block, player.worldObj, position)) { String unbreakableString = ColorHelper.getBooleanColor(false) + Config.NOT_CURRENTLY_HARVESTABLE_STRING + (!minimalLayout ? EnumChatFormatting.RESET + StatCollector.translateToLocal("wailaharvestability.harvestable") : ""); stringList.add(unbreakableString); return; } - // needed to stop array index out of bounds exceptions on mob spawners - // block.getHarvestLevel/getHarvestTool are only 16 elements big - if (meta >= 16) - meta = 0; - - int harvestLevel = block.getHarvestLevel(meta); - String effectiveTool = BlockHelper.getEffectiveToolOf(player.worldObj, position.blockX, position.blockY, position.blockZ, block, meta); + int harvestLevel = block.getHarvestLevel(blockState); + String effectiveTool = BlockHelper.getEffectiveToolOf(player.worldObj, position, block, blockState); if (effectiveTool != null && harvestLevel < 0) harvestLevel = 0; boolean blockHasEffectiveTools = harvestLevel >= 0 && effectiveTool != null; - String shearability = getShearabilityString(player, block, meta, position, config); - String silkTouchability = getSilkTouchabilityString(player, block, meta, position, config); + String shearability = getShearabilityString(player, block, blockState, position, config); + String silkTouchability = getSilkTouchabilityString(player, block, blockState, position, config); if (toolRequiredOnly && block.getMaterial().isToolNotRequired() && !blockHasEffectiveTools && shearability.isEmpty() && silkTouchability.isEmpty()) return; @@ -127,13 +120,12 @@ public class WailaHandler implements IWailaDataProvider ItemStack itemHeld = player.getHeldItem(); if (itemHeld != null) { - isHoldingTinkersTool = ToolHelper.hasToolTag(itemHeld); - canHarvest = ToolHelper.canToolHarvestBlock(itemHeld, block, meta) || (!isHoldingTinkersTool && block.canHarvestBlock(player, meta)); - isAboveMinHarvestLevel = (showCurrentlyHarvestable || showHarvestLevel) && ToolHelper.canToolHarvestLevel(itemHeld, block, meta, harvestLevel); - isEffective = showEffectiveTool && ToolHelper.isToolEffectiveAgainst(itemHeld, block, meta, effectiveTool); + canHarvest = ToolHelper.canToolHarvestBlock(itemHeld, block, blockState) || (!isHoldingTinkersTool && block.canHarvestBlock(player.worldObj, position, player)); + isAboveMinHarvestLevel = (showCurrentlyHarvestable || showHarvestLevel) && ToolHelper.canToolHarvestLevel(itemHeld, player.worldObj, position, harvestLevel); + isEffective = showEffectiveTool && ToolHelper.isToolEffectiveAgainst(itemHeld, player.worldObj, position, block, effectiveTool); } - boolean isCurrentlyHarvestable = (canHarvest && isAboveMinHarvestLevel) || (!isHoldingTinkersTool && ForgeHooks.canHarvestBlock(block, player, meta)); + boolean isCurrentlyHarvestable = (canHarvest && isAboveMinHarvestLevel) || (!isHoldingTinkersTool && ForgeHooks.canHarvestBlock(block, player, player.worldObj, position)); if (hideWhileHarvestable && isCurrentlyHarvestable) return; @@ -145,7 +137,7 @@ public class WailaHandler implements IWailaDataProvider String separator = (!shearability.isEmpty() || !silkTouchability.isEmpty() ? " " : ""); stringList.add(currentlyHarvestable + separator + silkTouchability + (!silkTouchability.isEmpty() ? separator : "") + shearability); } - if (harvestLevel != -1 && showEffectiveTool) + if (harvestLevel != -1 && showEffectiveTool && effectiveTool != null) { String effectiveToolString; if (StatCollector.canTranslate("wailaharvestability.toolclass." + effectiveTool)) @@ -158,30 +150,30 @@ public class WailaHandler implements IWailaDataProvider stringList.add((!minimalLayout ? StatCollector.translateToLocal("wailaharvestability.harvestlevel") : "") + ColorHelper.getBooleanColor(isAboveMinHarvestLevel && canHarvest) + StringHelper.stripFormatting(StringHelper.getHarvestLevelName(harvestLevel))); } } - - public String getShearabilityString(EntityPlayer player, Block block, int meta, MovingObjectPosition position, IWailaConfigHandler config) + + public String getShearabilityString(EntityPlayer player, Block block, IBlockState blockState, BlockPos position, IWailaConfigHandler config) { boolean isSneaking = player.isSneaking(); boolean showShearability = config.getConfig("harvestability.shearability") && (!config.getConfig("harvestability.shearability.sneakingonly") || isSneaking); - - if (showShearability && (block instanceof IShearable || block == Blocks.deadbush || (block == Blocks.double_plant && block.getItemDropped(meta, new Random(), 0) == null))) + + if (showShearability && (block instanceof IShearable || block == Blocks.deadbush || (block == Blocks.double_plant && block.getItemDropped(blockState, new Random(), 0) == null))) { ItemStack itemHeld = player.getHeldItem(); boolean isHoldingShears = itemHeld != null && itemHeld.getItem() instanceof ItemShears; - boolean isShearable = isHoldingShears && ((IShearable) block).isShearable(itemHeld, player.worldObj, position.blockX, position.blockY, position.blockZ); + boolean isShearable = isHoldingShears && ((IShearable) block).isShearable(itemHeld, player.worldObj, position); return ColorHelper.getBooleanColor(isShearable, !isShearable && isHoldingShears) + Config.SHEARABILITY_STRING; } return ""; } - public String getSilkTouchabilityString(EntityPlayer player, Block block, int meta, MovingObjectPosition position, IWailaConfigHandler config) + public String getSilkTouchabilityString(EntityPlayer player, Block block, IBlockState blockState, BlockPos position, IWailaConfigHandler config) { boolean isSneaking = player.isSneaking(); boolean showSilkTouchability = config.getConfig("harvestability.silktouchability") && (!config.getConfig("harvestability.silktouchability.sneakingonly") || isSneaking); - - if (showSilkTouchability && block.canSilkHarvest(player.worldObj, player, position.blockX, position.blockY, position.blockZ, meta)) + + if (showSilkTouchability && block.canSilkHarvest(player.worldObj, position, blockState, player)) { - boolean silkTouchMatters = block.getItemDropped(meta, new Random(), 0) != Item.getItemFromBlock(block) || block.quantityDropped(new Random()) <= 0; + boolean silkTouchMatters = block.getItemDropped(blockState, new Random(), 0) != Item.getItemFromBlock(block) || block.quantityDropped(new Random()) <= 0; if (silkTouchMatters) { boolean hasSilkTouch = EnchantmentHelper.getSilkTouchModifier(player); @@ -191,12 +183,6 @@ public class WailaHandler implements IWailaDataProvider return ""; } - @Override - public List getWailaTail(ItemStack itemStack, List toolTip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { - return toolTip; - } - public static HashMap configOptions = new HashMap(); static { @@ -218,15 +204,30 @@ public class WailaHandler implements IWailaDataProvider public static void callbackRegister(IWailaRegistrar registrar) { - WailaHandler instance = new WailaHandler(); - for (Map.Entry entry : configOptions.entrySet()) { - // hacky way to set default values to anything but true - ConfigHandler.instance().getConfig(entry.getKey(), entry.getValue()); - registrar.addConfig("Harvestability", entry.getKey(), "option." + entry.getKey()); + registrar.addConfig("Harvestability", entry.getKey(), entry.getValue()); } + WailaHandler instance = new WailaHandler(); registrar.registerBodyProvider(instance, Block.class); } + + @Override + public ITipList getWailaHead(ItemStack itemStack, ITipList currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) + { + return currenttip; + } + + @Override + public ITipList getWailaTail(ItemStack itemStack, ITipList currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) + { + return currenttip; + } + + @Override + public NBTTagCompound getNBTData(TileEntity te, NBTTagCompound tag, IWailaDataAccessorServer accessor) + { + return null; + } } \ No newline at end of file diff --git a/java/squeek/wailaharvestability/helpers/BlockHelper.java b/java/squeek/wailaharvestability/helpers/BlockHelper.java index 7f18e0a..e919d1f 100644 --- a/java/squeek/wailaharvestability/helpers/BlockHelper.java +++ b/java/squeek/wailaharvestability/helpers/BlockHelper.java @@ -3,9 +3,11 @@ package squeek.wailaharvestability.helpers; import java.util.HashMap; import java.util.Map; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemTool; +import net.minecraft.util.BlockPos; import net.minecraft.world.World; public class BlockHelper @@ -18,18 +20,18 @@ public class BlockHelper testTools.put("axe", new ItemStack(Items.wooden_axe)); } - public static String getEffectiveToolOf(World world, int x, int y, int z, Block block, int metadata) + public static String getEffectiveToolOf(World world, BlockPos blockPos, Block block, IBlockState blockState) { - String effectiveTool = block.getHarvestTool(metadata); + String effectiveTool = block.getHarvestTool(blockState); if (effectiveTool == null) { - float hardness = block.getBlockHardness(world, x, y, z); + float hardness = block.getBlockHardness(world, blockPos); if (hardness > 0f) { for (Map.Entry testToolEntry : testTools.entrySet()) { ItemStack testTool = testToolEntry.getValue(); - if (testTool != null && testTool.getItem() instanceof ItemTool && testTool.func_150997_a(block) >= ((ItemTool) testTool.getItem()).func_150913_i().getEfficiencyOnProperMaterial()) + if (testTool != null && testTool.getItem() instanceof ItemTool && testTool.getStrVsBlock(block) >= ((ItemTool) testTool.getItem()).getToolMaterial().getEfficiencyOnProperMaterial()) { effectiveTool = testToolEntry.getKey(); break; @@ -40,8 +42,8 @@ public class BlockHelper return effectiveTool; } - public static boolean isBlockUnbreakable(Block block, World world, int x, int y, int z) + public static boolean isBlockUnbreakable(Block block, World world, BlockPos blockPos) { - return block.getBlockHardness(world, x, y, z) == -1.0f; + return block.getBlockHardness(world, blockPos) == -1.0f; } } diff --git a/java/squeek/wailaharvestability/helpers/OreHelper.java b/java/squeek/wailaharvestability/helpers/OreHelper.java index 5510b71..7d8bb0c 100644 --- a/java/squeek/wailaharvestability/helpers/OreHelper.java +++ b/java/squeek/wailaharvestability/helpers/OreHelper.java @@ -18,10 +18,13 @@ public class OreHelper public static boolean isItemAnOre(ItemStack itemStack) { - // check the ore dictionary to see if it starts with "ore" - int oreID = -1; - if ((oreID = OreDictionary.getOreID(itemStack)) != -1 && OreDictionary.getOreName(oreID).startsWith("ore")) - return true; + // check the ore dictionary to see if any entry starts with "ore" + int[] oreIDs = OreDictionary.getOreIDs(itemStack); + for (int oreID : oreIDs) + { + if (OreDictionary.getOreName(oreID).startsWith("ore")) + return true; + } // ore in the display name (but not part of another word) if (itemStack.getDisplayName().matches(".*(^|\\s)([oO]re)($|\\s).*")) diff --git a/java/squeek/wailaharvestability/helpers/StringHelper.java b/java/squeek/wailaharvestability/helpers/StringHelper.java index 850625f..3685053 100644 --- a/java/squeek/wailaharvestability/helpers/StringHelper.java +++ b/java/squeek/wailaharvestability/helpers/StringHelper.java @@ -3,8 +3,6 @@ package squeek.wailaharvestability.helpers; import java.lang.reflect.Method; import java.util.HashMap; import java.util.List; -import squeek.wailaharvestability.ModWailaHarvestability; -import squeek.wailaharvestability.proxy.ProxyIguanaTweaks; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; @@ -40,9 +38,6 @@ public class StringHelper } else { - if (ModWailaHarvestability.hasIguanaTweaks) - return ProxyIguanaTweaks.getHarvestLevelName(num); - String unlocalized = "gui.partcrafter.mining" + (num + 1); String localized = StringHelper.getLocalizedString(unlocalized); if (!unlocalized.equals(localized)) diff --git a/java/squeek/wailaharvestability/helpers/ToolHelper.java b/java/squeek/wailaharvestability/helpers/ToolHelper.java index 07051c2..8e36f8d 100644 --- a/java/squeek/wailaharvestability/helpers/ToolHelper.java +++ b/java/squeek/wailaharvestability/helpers/ToolHelper.java @@ -1,135 +1,43 @@ package squeek.wailaharvestability.helpers; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; import java.util.Set; -import cpw.mods.fml.common.Loader; import net.minecraft.block.Block; -import net.minecraft.item.Item; +import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.BlockPos; +import net.minecraft.world.IBlockAccess; import net.minecraftforge.common.ForgeHooks; public class ToolHelper { - // tinkers construct - private static Class HarvestTool = null; - private static Class DualHarvestTool = null; - private static Method getHarvestType = null; - private static Method getSecondHarvestType = null; - public static boolean tinkersConstructLoaded = false; - - public static void init() - { - if (Loader.isModLoaded("TConstruct")) - { - try - { - HarvestTool = Class.forName("tconstruct.library.tools.HarvestTool"); - DualHarvestTool = Class.forName("tconstruct.library.tools.DualHarvestTool"); - getHarvestType = HarvestTool.getDeclaredMethod("getHarvestType"); - getSecondHarvestType = DualHarvestTool.getDeclaredMethod("getSecondHarvestType"); - getHarvestType.setAccessible(true); - getSecondHarvestType.setAccessible(true); - tinkersConstructLoaded = true; - } - catch (Exception e) - { - return; - } - } - } - - public static boolean hasToolTag(ItemStack itemStack) - { - return itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("InfiTool"); - } - - public static NBTTagCompound getToolTag(ItemStack tool) - { - NBTTagCompound tag = null; - if (tool.hasTagCompound()) - tag = tool.getTagCompound().getCompoundTag("InfiTool"); - return tag; - } - - public static int getPrimaryHarvestLevel(NBTTagCompound toolTag) - { - return toolTag.getInteger("HarvestLevel"); - } - - public static int getSecondaryHarvestLevel(NBTTagCompound toolTag) - { - return toolTag.getInteger("HarvestLevel2"); - } - public static Set getToolClassesOf(ItemStack tool) { return tool.getItem().getToolClasses(tool); } - + public static boolean isToolOfClass(ItemStack tool, String toolClass) { return getToolClassesOf(tool).contains(toolClass); } - + public static boolean toolHasAnyToolClass(ItemStack tool) { return !getToolClassesOf(tool).isEmpty(); } - public static boolean isToolEffectiveAgainst(ItemStack tool, Block block, int metadata, String effectiveToolClass) + public static boolean isToolEffectiveAgainst(ItemStack tool, IBlockAccess blockAccess, BlockPos blockPos, Block block, String effectiveToolClass) { - if (tinkersConstructLoaded && HarvestTool.isInstance(tool.getItem())) - { - Item item = tool.getItem(); - List harvestTypes = new ArrayList(); - try - { - harvestTypes.add((String) getHarvestType.invoke(item)); - } - catch (Exception e) - { - e.printStackTrace(); - tinkersConstructLoaded = false; - } - - if (DualHarvestTool.isInstance(item)) - { - try - { - harvestTypes.add((String) getSecondHarvestType.invoke(item)); - } - catch (Exception e) - { - e.printStackTrace(); - tinkersConstructLoaded = false; - } - } - - return harvestTypes.contains(effectiveToolClass); - } - return ForgeHooks.isToolEffective(tool, block, metadata) || (toolHasAnyToolClass(tool) ? isToolOfClass(tool, effectiveToolClass) : tool.func_150997_a(block) > 1.5f); // func_150997_a = getStrVsBlock + return ForgeHooks.isToolEffective(blockAccess, blockPos, tool) || (toolHasAnyToolClass(tool) ? isToolOfClass(tool, effectiveToolClass) : tool.getStrVsBlock(block) > 1.5f); // func_150997_a = getStrVsBlock } - public static boolean canToolHarvestLevel(ItemStack tool, Block block, int metadata, int harvestLevel) + public static boolean canToolHarvestLevel(ItemStack tool, IBlockAccess blockAccess, BlockPos blockPos, int harvestLevel) { - boolean canTinkersToolHarvestBlock = false; - - NBTTagCompound toolTag = ToolHelper.getToolTag(tool); - if (toolTag != null) - { - int toolHarvestLevel = Math.max(ToolHelper.getPrimaryHarvestLevel(toolTag), ToolHelper.getSecondaryHarvestLevel(toolTag)); - canTinkersToolHarvestBlock = toolHarvestLevel >= harvestLevel; - } - - return canTinkersToolHarvestBlock || ForgeHooks.canToolHarvestBlock(block, metadata, tool); + return ForgeHooks.canToolHarvestBlock(blockAccess, blockPos, tool); } - public static boolean canToolHarvestBlock(ItemStack tool, Block block, int metadata) + public static boolean canToolHarvestBlock(ItemStack tool, Block block, IBlockState blockState) { - return block.getMaterial().isToolNotRequired() || tool.func_150998_b(block); // func_150998_b = canHarvestBlock + return block.getMaterial().isToolNotRequired() || tool.canHarvestBlock(block); // func_150998_b = canHarvestBlock } } diff --git a/java/squeek/wailaharvestability/proxy/ProxyCreativeBlocks.java b/java/squeek/wailaharvestability/proxy/ProxyCreativeBlocks.java index 9783763..5460e28 100644 --- a/java/squeek/wailaharvestability/proxy/ProxyCreativeBlocks.java +++ b/java/squeek/wailaharvestability/proxy/ProxyCreativeBlocks.java @@ -2,7 +2,7 @@ package squeek.wailaharvestability.proxy; import java.lang.reflect.Method; import net.minecraft.block.Block; -import cpw.mods.fml.common.Loader; +import net.minecraftforge.fml.common.Loader; public class ProxyCreativeBlocks { diff --git a/java/squeek/wailaharvestability/proxy/ProxyIguanaTweaks.java b/java/squeek/wailaharvestability/proxy/ProxyIguanaTweaks.java deleted file mode 100644 index b554162..0000000 --- a/java/squeek/wailaharvestability/proxy/ProxyIguanaTweaks.java +++ /dev/null @@ -1,38 +0,0 @@ -package squeek.wailaharvestability.proxy; - -import java.lang.reflect.Method; - -public class ProxyIguanaTweaks -{ - private static Class HarvestLevels = null; - private static Method proxyGetHarvestLevelName; - - public static void init() - { - try - { - HarvestLevels = Class.forName("iguanaman.iguanatweakstconstruct.util.HarvestLevels"); - proxyGetHarvestLevelName = HarvestLevels.getDeclaredMethod("getHarvestLevelName", int.class); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - public static String getHarvestLevelName(int num) - { - String harvestLevelName = ""; - - try - { - harvestLevelName = (String) proxyGetHarvestLevelName.invoke(null, num); - } - catch (Exception e) - { - e.printStackTrace(); - } - - return harvestLevelName; - } -}