diff --git a/build.gradle b/build.gradle index 0bfdb1d..b6ffc5a 100644 --- a/build.gradle +++ b/build.gradle @@ -52,6 +52,7 @@ dependencies { // modImplementation files("libs/") // coremodImplementation files("libs/") + modImplementation files("libs/VintageCore-1.5.2-1.0.3-dev.jar") modImplementation files("libs/industrialcraft-2_1.117.385-lf.jar") modImplementation files("libs/gregtechmod311.jar") modImplementation files("libs/buildcraft-A-3.7.2.jar") diff --git a/gradle.properties b/gradle.properties index 5e4b149..b523821 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ # Sets default memory used for gradle commands. Can be overridden by user or command line properties. # This is required to provide enough memory for the Minecraft decompilation process. -mod_version = 1.5.2-2.2.2t +mod_version = 1.5.2-2.2.2u modid = gravisuite minecraft = 1.5.2 minecraft_forge = 1.5.2-7.8.1.738 \ No newline at end of file diff --git a/libs/VintageCore-1.5.2-1.0.3-dev.jar b/libs/VintageCore-1.5.2-1.0.3-dev.jar new file mode 100644 index 0000000..874ffe9 Binary files /dev/null and b/libs/VintageCore-1.5.2-1.0.3-dev.jar differ diff --git a/src/main/java/reforged/mods/gravisuite/GraviSuite.java b/src/main/java/reforged/mods/gravisuite/GraviSuite.java index fd2a076..c24d820 100644 --- a/src/main/java/reforged/mods/gravisuite/GraviSuite.java +++ b/src/main/java/reforged/mods/gravisuite/GraviSuite.java @@ -8,6 +8,9 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.LanguageRegistry; +import mods.vintage.core.helpers.BlockHelper; +import mods.vintage.core.platform.lang.ILangProvider; +import mods.vintage.core.platform.lang.LangManager; import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; @@ -18,16 +21,17 @@ import reforged.mods.gravisuite.network.NetworkHandler; import reforged.mods.gravisuite.network.NetworkHandlerClient; import reforged.mods.gravisuite.proxy.CommonProxy; -import reforged.mods.gravisuite.utils.Helpers; import reforged.mods.gravisuite.utils.Refs; +import java.util.Arrays; +import java.util.List; import java.util.logging.Logger; @Mod(modid = Refs.id, name = Refs.name, version = Refs.version, acceptedMinecraftVersions = Refs.mc, dependencies = Refs.deps) @NetworkMod(clientSideRequired = true, clientPacketHandlerSpec = @NetworkMod.SidedPacketHandler(channels = { Refs.id }, packetHandler = NetworkHandlerClient.class), serverPacketHandlerSpec = @NetworkMod.SidedPacketHandler(channels = { Refs.id }, packetHandler = NetworkHandler.class)) -public class GraviSuite { +public class GraviSuite implements ILangProvider { @SidedProxy(clientSide = Refs.client, serverSide = Refs.common) public static CommonProxy proxy; @@ -59,6 +63,7 @@ public GraviSuite() { public void preInit(FMLPreInitializationEvent e) { proxy.preInit(e); GraviSuiteData.init(); + LangManager.THIS.registerLangProvider(this); } @Mod.Init @@ -75,7 +80,7 @@ public void postInit(FMLPostInitializationEvent e) { public void onRightClick(PlayerInteractEvent e) { if (GraviSuiteConfig.inspect_mode && e.entityPlayer.getHeldItem() != null) { if (e.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK && e.entityPlayer.getHeldItem().getItem() == Item.stick) { - Block block = Helpers.getBlock(e.entity.worldObj, e.x, e.y, e.z); + Block block = BlockHelper.getBlock(e.entity.worldObj, e.x, e.y, e.z); int metadata = e.entityPlayer.worldObj.getBlockMetadata(e.x, e.y, e.z); if (block != null) { logger.info("Block: " + block.getLocalizedName() + " | Class Name: " + block.getClass().getName()); @@ -84,4 +89,14 @@ public void onRightClick(PlayerInteractEvent e) { } } } + + @Override + public String getModid() { + return Refs.id; + } + + @Override + public List getLocalizationList() { + return Arrays.asList(GraviSuiteConfig.langs); + } } diff --git a/src/main/java/reforged/mods/gravisuite/GraviSuiteConfig.java b/src/main/java/reforged/mods/gravisuite/GraviSuiteConfig.java index ce30591..e0e1cd6 100644 --- a/src/main/java/reforged/mods/gravisuite/GraviSuiteConfig.java +++ b/src/main/java/reforged/mods/gravisuite/GraviSuiteConfig.java @@ -15,8 +15,7 @@ public class GraviSuiteConfig { public static Configuration id_config; public static Configuration main_config; - public static String additional_languages; - public static String default_language; + public static String[] langs; public static String[] logs; public static String[] leaves; @@ -94,8 +93,7 @@ public static void initConfig() { log_wrench = getBoolean(Refs.general, "enable_wrench_logging", log_wrench, "Should GraviTool Wrench be logged? [Debug purposes only!]"); inspect_mode = getBoolean(Refs.general, "enable_inspect_mode", inspect_mode, "Enable inspect mode. Helps identify block name, class and metadata."); - default_language = getString(Refs.general, "default_language", "en_US,ru_RU", "Default Language. DO NOT CHANGE THIS! Use additional_languages field instead!"); - additional_languages = getString(Refs.general, "additional_languages", "", "Additional supported localizations. Place your .lang file in config/gravisuite/lang folder and list here. Format: no spaces, comma separated. Ex: ,"); + langs = getString(Refs.general, "localizations", new String[] { "en_US", "ru_RU" }, "Supported localizations. Place your .lang file in config/gravisuite/lang folder or inside mods/gravisuite/lang inside modJar"); magnet_range = getInt(Refs.general, "magnet_range", 1, 16, magnet_range, "Magnet Range."); magnet_max_capacity = getInt(Refs.general, "magnet_max_capacity", 1, Integer.MAX_VALUE, magnet_max_capacity, "Magnet Attraction Capacity."); diff --git a/src/main/java/reforged/mods/gravisuite/GraviSuiteRecipes.java b/src/main/java/reforged/mods/gravisuite/GraviSuiteRecipes.java index c43c205..7e63f61 100644 --- a/src/main/java/reforged/mods/gravisuite/GraviSuiteRecipes.java +++ b/src/main/java/reforged/mods/gravisuite/GraviSuiteRecipes.java @@ -2,6 +2,7 @@ import ic2.api.item.Items; import ic2.api.recipe.Recipes; +import mods.vintage.core.helpers.RecipeHelper; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import reforged.mods.gravisuite.utils.Helpers; @@ -54,7 +55,7 @@ public static void initRecipes() { 'D', Items.getItem("glassFiberCableItem"), 'F', Items.getItem("advancedCircuit")); - Helpers.removeRecipeByOutput(Items.getItem("quantumBodyarmor")); + RecipeHelper.removeRecipeByOutput(Items.getItem("quantumBodyarmor")); Recipes.advRecipes.addRecipe(Items.getItem("quantumBodyarmor"), "ANA", "ILI", "IAI", 'A', Items.getItem("advancedAlloy"), diff --git a/src/main/java/reforged/mods/gravisuite/events/client/AudioHandler.java b/src/main/java/reforged/mods/gravisuite/events/client/AudioHandler.java index 9ed48ef..ad8e780 100644 --- a/src/main/java/reforged/mods/gravisuite/events/client/AudioHandler.java +++ b/src/main/java/reforged/mods/gravisuite/events/client/AudioHandler.java @@ -2,11 +2,12 @@ import cpw.mods.fml.common.TickType; import ic2.core.audio.AudioSource; +import mods.vintage.core.platform.events.tick.TickEvents; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import reforged.mods.gravisuite.GraviSuite; import reforged.mods.gravisuite.audio.IAudioProvider; -import reforged.mods.gravisuite.events.tick.TickEvents; +import reforged.mods.gravisuite.utils.Refs; import java.util.EnumSet; @@ -17,6 +18,10 @@ public class AudioHandler extends TickEvents.PlayerTickEvent { boolean USED; AudioSource AUDIO_SOURCE; + public AudioHandler() { + super(Refs.id); + } + @Override public void tickStart(EnumSet enumSet, Object... objects) { if (shouldTick(enumSet)) { diff --git a/src/main/java/reforged/mods/gravisuite/events/client/ClientArmorHandler.java b/src/main/java/reforged/mods/gravisuite/events/client/ClientArmorHandler.java index 237a807..5c22d82 100644 --- a/src/main/java/reforged/mods/gravisuite/events/client/ClientArmorHandler.java +++ b/src/main/java/reforged/mods/gravisuite/events/client/ClientArmorHandler.java @@ -1,12 +1,13 @@ package reforged.mods.gravisuite.events.client; import cpw.mods.fml.common.TickType; +import mods.vintage.core.platform.events.tick.TickEvents; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import reforged.mods.gravisuite.GraviSuite; -import reforged.mods.gravisuite.events.tick.TickEvents; import reforged.mods.gravisuite.items.armors.ItemAdvancedQuant; import reforged.mods.gravisuite.proxy.CommonProxy; +import reforged.mods.gravisuite.utils.Refs; import java.util.EnumSet; @@ -16,6 +17,10 @@ public class ClientArmorHandler extends TickEvents.PlayerTickEvent { public static boolean firstLoad = false; + public ClientArmorHandler() { + super(Refs.id); + } + @Override public void tickStart(EnumSet enumSet, Object... objects) { if (shouldTick(enumSet)) { diff --git a/src/main/java/reforged/mods/gravisuite/events/client/KeyboardHandler.java b/src/main/java/reforged/mods/gravisuite/events/client/KeyboardHandler.java index 3534b89..c819a80 100644 --- a/src/main/java/reforged/mods/gravisuite/events/client/KeyboardHandler.java +++ b/src/main/java/reforged/mods/gravisuite/events/client/KeyboardHandler.java @@ -1,8 +1,9 @@ package reforged.mods.gravisuite.events.client; import cpw.mods.fml.common.TickType; +import mods.vintage.core.platform.events.tick.TickEvents; import reforged.mods.gravisuite.GraviSuite; -import reforged.mods.gravisuite.events.tick.TickEvents; +import reforged.mods.gravisuite.utils.Refs; import java.util.EnumSet; @@ -10,6 +11,10 @@ public class KeyboardHandler extends TickEvents.ClientTickEvent { public static final KeyboardHandler THIS = new KeyboardHandler(); + public KeyboardHandler() { + super(Refs.id); + } + @Override public void tickStart(EnumSet enumSet, Object... objects) { if (shouldTick(enumSet)) { diff --git a/src/main/java/reforged/mods/gravisuite/events/client/OverlayHandler.java b/src/main/java/reforged/mods/gravisuite/events/client/OverlayHandler.java index b0ab422..53e02b9 100644 --- a/src/main/java/reforged/mods/gravisuite/events/client/OverlayHandler.java +++ b/src/main/java/reforged/mods/gravisuite/events/client/OverlayHandler.java @@ -3,19 +3,19 @@ import cpw.mods.fml.common.TickType; import ic2.api.item.IElectricItem; import ic2.core.IC2; +import mods.vintage.core.platform.events.tick.TickEvents; +import mods.vintage.core.platform.lang.FormattedTranslator; +import mods.vintage.core.platform.lang.Translator; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import reforged.mods.gravisuite.GraviSuiteConfig; -import reforged.mods.gravisuite.events.tick.TickEvents; import reforged.mods.gravisuite.items.armors.ItemAdvancedQuant; import reforged.mods.gravisuite.items.armors.base.ItemBaseJetpack; import reforged.mods.gravisuite.utils.Helpers; -import reforged.mods.gravisuite.utils.LangHelper; import reforged.mods.gravisuite.utils.Refs; -import reforged.mods.gravisuite.utils.TextFormatter; import java.util.EnumSet; @@ -30,6 +30,10 @@ public class OverlayHandler extends TickEvents.RenderTickEvent { public static Minecraft mc = Minecraft.getMinecraft(); + public OverlayHandler() { + super(Refs.id); + } + @Override public void tickEnd(EnumSet type, Object... objects) { if (shouldTick(type)) { @@ -56,7 +60,7 @@ public void renderOverlay(Minecraft mc) { } // ENERGY STATUS - String energyToDisplay = Refs.energy_level_gold + " " + getEnergyTextColor(charge) + TextFormatter.WHITE.literal("%"); + String energyToDisplay = Refs.energy_level_gold + " " + getEnergyTextColor(charge) + FormattedTranslator.WHITE.literal("%"); // HOVER MODE STATUS @@ -141,10 +145,10 @@ public void renderOverlay(Minecraft mc) { if (armor.getItem() instanceof ItemBaseJetpack) { int xPos = scaledRes.getScaledWidth() / 2; int yPos = scaledRes.getScaledHeight() - 85; - String quick_change = LangHelper.format(Refs.quick_charge); + String quick_change = Translator.format(Refs.quick_charge); int width = mc.fontRenderer.getStringWidth(quick_change); if (tag.getBoolean(ItemBaseJetpack.NBT_ACTIVE) && IC2.keyboard.isAltKeyDown(player)) { - mc.ingameGUI.drawString(mc.fontRenderer, TextFormatter.GREEN.format(Refs.quick_charge), xPos - width / 2, yPos, 0); + mc.ingameGUI.drawString(mc.fontRenderer, FormattedTranslator.GREEN.format(Refs.quick_charge), xPos - width / 2, yPos, 0); } } } @@ -171,21 +175,21 @@ private int getXOffset(String value) { } public static String getEnergyTextColor(int energyLevel) { - TextFormatter colorCode = TextFormatter.WHITE; // white + FormattedTranslator colorCode = FormattedTranslator.WHITE; // white if (energyLevel >= 90) { - colorCode = TextFormatter.GREEN; // green + colorCode = FormattedTranslator.GREEN; // green } if ((energyLevel <= 90) && (energyLevel > 75)) { - colorCode = TextFormatter.YELLOW; // yellow + colorCode = FormattedTranslator.YELLOW; // yellow } if ((energyLevel <= 75) && (energyLevel > 50)) { - colorCode = TextFormatter.GOLD; // gold + colorCode = FormattedTranslator.GOLD; // gold } if ((energyLevel <= 50) && (energyLevel > 35)) { - colorCode = TextFormatter.RED; // red + colorCode = FormattedTranslator.RED; // red } if (energyLevel <= 35) { - colorCode = TextFormatter.DARK_RED; // dark_red + colorCode = FormattedTranslator.DARK_RED; // dark_red } return colorCode.literal(String.valueOf(energyLevel)); } diff --git a/src/main/java/reforged/mods/gravisuite/events/server/ServerArmorHandler.java b/src/main/java/reforged/mods/gravisuite/events/server/ServerArmorHandler.java index 4889e4c..36ae364 100644 --- a/src/main/java/reforged/mods/gravisuite/events/server/ServerArmorHandler.java +++ b/src/main/java/reforged/mods/gravisuite/events/server/ServerArmorHandler.java @@ -1,11 +1,12 @@ package reforged.mods.gravisuite.events.server; import cpw.mods.fml.common.TickType; +import mods.vintage.core.platform.events.tick.TickEvents; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import reforged.mods.gravisuite.events.tick.TickEvents; import reforged.mods.gravisuite.items.armors.ItemAdvancedQuant; import reforged.mods.gravisuite.proxy.CommonProxy; +import reforged.mods.gravisuite.utils.Refs; import java.util.EnumSet; @@ -15,6 +16,10 @@ public class ServerArmorHandler extends TickEvents.PlayerTickEvent { public static boolean firstLoad = false; + public ServerArmorHandler() { + super(Refs.id); + } + @Override public void tickStart(EnumSet enumSet, Object... objects) { if (shouldTick(enumSet)) { diff --git a/src/main/java/reforged/mods/gravisuite/events/tick/BaseTickEvent.java b/src/main/java/reforged/mods/gravisuite/events/tick/BaseTickEvent.java deleted file mode 100644 index ec17a8c..0000000 --- a/src/main/java/reforged/mods/gravisuite/events/tick/BaseTickEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -package reforged.mods.gravisuite.events.tick; - -import cpw.mods.fml.common.ITickHandler; -import cpw.mods.fml.common.TickType; -import reforged.mods.gravisuite.utils.Refs; - -import java.util.EnumSet; - -public class BaseTickEvent implements ITickHandler { - - TickType TYPE; - - public BaseTickEvent(TickType type) { - this.TYPE = type; - } - - @Override - public void tickStart(EnumSet enumSet, Object... objects) {} - - @Override - public void tickEnd(EnumSet enumSet, Object... objects) {} - - @Override - public EnumSet ticks() { - return EnumSet.of(this.TYPE); - } - - @Override - public String getLabel() { - return Refs.id; - } - - public boolean shouldTick(EnumSet type) { - return type.contains(this.TYPE); - } -} diff --git a/src/main/java/reforged/mods/gravisuite/events/tick/TickEvents.java b/src/main/java/reforged/mods/gravisuite/events/tick/TickEvents.java deleted file mode 100644 index 765f833..0000000 --- a/src/main/java/reforged/mods/gravisuite/events/tick/TickEvents.java +++ /dev/null @@ -1,42 +0,0 @@ -package reforged.mods.gravisuite.events.tick; - -import cpw.mods.fml.common.TickType; - -public class TickEvents { - - public static class WorldTickEvent extends BaseTickEvent { - public WorldTickEvent() { - super(TickType.WORLD); - } - } - - public static class RenderTickEvent extends BaseTickEvent { - public RenderTickEvent() { - super(TickType.RENDER); - } - } - - public static class WorldLoadTickEvent extends BaseTickEvent { - public WorldLoadTickEvent() { - super(TickType.WORLDLOAD); - } - } - - public static class ClientTickEvent extends BaseTickEvent { - public ClientTickEvent() { - super(TickType.CLIENT); - } - } - - public static class ServerTickEvent extends BaseTickEvent { - public ServerTickEvent() { - super(TickType.SERVER); - } - } - - public static class PlayerTickEvent extends BaseTickEvent { - public PlayerTickEvent() { - super(TickType.PLAYER); - } - } -} diff --git a/src/main/java/reforged/mods/gravisuite/items/armors/base/ItemArmorElectric.java b/src/main/java/reforged/mods/gravisuite/items/armors/base/ItemArmorElectric.java index aa156fa..352515c 100644 --- a/src/main/java/reforged/mods/gravisuite/items/armors/base/ItemArmorElectric.java +++ b/src/main/java/reforged/mods/gravisuite/items/armors/base/ItemArmorElectric.java @@ -5,6 +5,7 @@ import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; import ic2.api.item.IMetalArmor; +import mods.vintage.core.platform.lang.FormattedTranslator; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLiving; @@ -16,7 +17,6 @@ import net.minecraftforge.common.ISpecialArmor; import reforged.mods.gravisuite.utils.Helpers; import reforged.mods.gravisuite.utils.Refs; -import reforged.mods.gravisuite.utils.TextFormatter; import java.util.List; @@ -69,7 +69,7 @@ public String getArmorTextureFile(ItemStack itemStack) { @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean isDebugMode) { - tooltip.add(TextFormatter.AQUA.format(Helpers.getCharge(stack) + "/" + this.getMaxCharge(stack) + " EU" + " @ Tier " + this.tier)); + tooltip.add(FormattedTranslator.AQUA.format("message.info.energy", Helpers.getCharge(stack), this.getMaxCharge(stack), FormattedTranslator.WHITE.format("message.info.energy.tier", FormattedTranslator.YELLOW.literal(this.tier + "")))); } @Override diff --git a/src/main/java/reforged/mods/gravisuite/items/tools/ItemAdvancedChainsaw.java b/src/main/java/reforged/mods/gravisuite/items/tools/ItemAdvancedChainsaw.java index e2129ae..c4ba114 100644 --- a/src/main/java/reforged/mods/gravisuite/items/tools/ItemAdvancedChainsaw.java +++ b/src/main/java/reforged/mods/gravisuite/items/tools/ItemAdvancedChainsaw.java @@ -7,6 +7,11 @@ import ic2.core.IC2; import ic2.core.audio.AudioSource; import ic2.core.audio.PositionSpec; +import mods.vintage.core.helpers.BlockHelper; +import mods.vintage.core.helpers.StackHelper; +import mods.vintage.core.helpers.ToolHelper; +import mods.vintage.core.helpers.Utils; +import mods.vintage.core.helpers.pos.BlockPos; import net.minecraft.block.Block; import net.minecraft.block.BlockLog; import net.minecraft.enchantment.Enchantment; @@ -31,7 +36,6 @@ import reforged.mods.gravisuite.items.tools.base.ItemToolElectric; import reforged.mods.gravisuite.utils.Helpers; import reforged.mods.gravisuite.utils.Refs; -import reforged.mods.gravisuite.utils.pos.BlockPos; import java.util.*; @@ -120,10 +124,10 @@ public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPla if (GraviSuiteConfig.chainsaw_tree_capitator && readToolMode(stack, NBT_TCAPITATOR)) { ItemStack blockStack = new ItemStack(block, 1, 32767); boolean isLog = false; - List logs = Helpers.getStackFromOre("log"); - logs.addAll(Helpers.getStackFromOre("wood")); // just in case some mod uses old oredict name + List logs = StackHelper.getStackFromOre("log"); + logs.addAll(StackHelper.getStackFromOre("wood")); // just in case some mod uses old oredict name for (ItemStack check : logs) { - if (Helpers.areStacksEqual(check, blockStack) || isLog(block)) { + if (StackHelper.areStacksEqual(check, blockStack) || isLog(block)) { isLog = true; break; } @@ -140,7 +144,7 @@ public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPla break; } if (canOperate(stack)) { - if (canHarvestBlock(block, stack) && harvestBlock(world, coord.getX(), coord.getY(), coord.getZ(), player) && !player.capabilities.isCreativeMode) { + if (canHarvestBlock(block, stack) && ToolHelper.harvestBlock(world, coord.getX(), coord.getY(), coord.getZ(), player) && !player.capabilities.isCreativeMode) { ElectricItem.manager.use(stack, this.energyPerOperation, player); } } @@ -292,31 +296,31 @@ public boolean isLog(Block block) { String[] logs = GraviSuiteConfig.logs; boolean configLogs = false; for (String log : logs) { - if (Helpers.instanceOf(block, log)) configLogs = true; + if (Utils.instanceOf(block, log)) configLogs = true; break; } return block instanceof BlockLog || configLogs; } public boolean isLeaves(World world, BlockPos pos) { - Block block = Helpers.getBlock(world, pos); + Block block = BlockHelper.getBlock(world, pos); String[] leaves = GraviSuiteConfig.leaves; boolean configLeaves = false; for (String leave : leaves) { - if (Helpers.instanceOf(block, leave)) configLeaves = true; + if (Utils.instanceOf(block, leave)) configLeaves = true; break; } return getBOPStatus(world, pos) || configLeaves; } private boolean getBOPStatus(World world, BlockPos pos) { - int meta = Helpers.getBlockMetadata(world, pos) | 8; - Block block = Helpers.getBlock(world, pos); + int meta = BlockHelper.getBlockMetadata(world, pos) | 8; + Block block = BlockHelper.getBlock(world, pos); if (Loader.isModLoaded("BiomesOPlenty")) { - if (Helpers.instanceOf(block, "biomesoplenty.blocks.BlockBOPPetals") || - Helpers.instanceOf(block, "biomesoplenty.blocks.BlockBOPLeaves") || - Helpers.instanceOf(block, "biomesoplenty.blocks.BlockBOPColorizedLeaves") || - Helpers.instanceOf(block, "biomesoplenty.blocks.BlockBOPAppleLeaves")) { + if (Utils.instanceOf(block, "biomesoplenty.blocks.BlockBOPPetals") || + Utils.instanceOf(block, "biomesoplenty.blocks.BlockBOPLeaves") || + Utils.instanceOf(block, "biomesoplenty.blocks.BlockBOPColorizedLeaves") || + Utils.instanceOf(block, "biomesoplenty.blocks.BlockBOPAppleLeaves")) { return meta >= 8 && meta <= 15; } } @@ -328,13 +332,13 @@ private interface BlockAction { } public LinkedList scanForTree(final World world, final BlockPos startPos, int limit) { - Block block = Helpers.getBlock(world, startPos); + Block block = BlockHelper.getBlock(world, startPos); ItemStack blockStack = new ItemStack(block, 1, 32767); boolean isLog = false; - List logs = Helpers.getStackFromOre("log"); - logs.addAll(Helpers.getStackFromOre("wood")); // just in case some mod uses old oredict name + List logs = StackHelper.getStackFromOre("log"); + logs.addAll(StackHelper.getStackFromOre("wood")); // just in case some mod uses old oredict name for (ItemStack check : logs) { - if (Helpers.areStacksEqual(check, blockStack) || isLog(block)) { + if (StackHelper.areStacksEqual(check, blockStack) || isLog(block)) { isLog = true; break; } @@ -346,7 +350,7 @@ public LinkedList scanForTree(final World world, final BlockPos startP LinkedList result = recursiveSearch(world, startPos, new BlockAction() { @Override public boolean onBlock(BlockPos pos, Block block, boolean isRightBlock) { - int metadata = Helpers.getBlockMetadata(world, pos) | 8; + int metadata = BlockHelper.getBlockMetadata(world, pos) | 8; boolean isLeave = metadata >= 8 && metadata <= 11; if (block.isLeaves(world, pos.getX(), pos.getY(), pos.getZ()) && isLeave || isLeaves(world, pos)) leavesFound[0] = true; return true; @@ -357,7 +361,7 @@ public boolean onBlock(BlockPos pos, Block block, boolean isRightBlock) { // Recursively scan 3x3x3 cubes while keeping track of already scanned blocks to avoid cycles. private static LinkedList recursiveSearch(final World world, final BlockPos start, @Nullable final BlockAction action, int limit) { - Block wantedBlock = Helpers.getBlock(world, start); + Block wantedBlock = BlockHelper.getBlock(world, start); boolean abort = false; final LinkedList result = new LinkedList(); final Set visited = new HashSet(); @@ -373,8 +377,8 @@ private static LinkedList recursiveSearch(final World world, final Blo for (int y = y0 - 1; y <= y0 + 1 && !abort; ++y) { for (int x = x0 - 1; x <= x0 + 1 && !abort; ++x) { final BlockPos pos = new BlockPos(x, y, z); - Block checkBlock = Helpers.getBlock(world, pos); - if ((Helpers.isAir(world, pos) || !visited.add(pos))) { + Block checkBlock = BlockHelper.getBlock(world, pos); + if ((BlockHelper.isAir(world, pos) || !visited.add(pos))) { continue; } final boolean isRightBlock = checkBlock.blockID == wantedBlock.blockID; diff --git a/src/main/java/reforged/mods/gravisuite/items/tools/ItemAdvancedDrill.java b/src/main/java/reforged/mods/gravisuite/items/tools/ItemAdvancedDrill.java index c1ad36e..a95d6a8 100644 --- a/src/main/java/reforged/mods/gravisuite/items/tools/ItemAdvancedDrill.java +++ b/src/main/java/reforged/mods/gravisuite/items/tools/ItemAdvancedDrill.java @@ -4,6 +4,11 @@ import cpw.mods.fml.relauncher.SideOnly; import ic2.api.item.ElectricItem; import ic2.core.IC2; +import mods.vintage.core.helpers.BlockHelper; +import mods.vintage.core.helpers.StackHelper; +import mods.vintage.core.helpers.ToolHelper; +import mods.vintage.core.helpers.pos.BlockPos; +import mods.vintage.core.platform.lang.FormattedTranslator; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.enchantment.Enchantment; @@ -22,8 +27,6 @@ import reforged.mods.gravisuite.items.tools.base.ItemToolElectric; import reforged.mods.gravisuite.utils.Helpers; import reforged.mods.gravisuite.utils.Refs; -import reforged.mods.gravisuite.utils.TextFormatter; -import reforged.mods.gravisuite.utils.pos.BlockPos; import java.util.*; @@ -100,7 +103,7 @@ public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPla World world = player.worldObj; DrillMode mode = readToolMode(stack); DrillProps props = readToolProps(stack); - MovingObjectPosition mop = Helpers.raytraceFromEntity(world, player, false, 4.5D); + MovingObjectPosition mop = BlockHelper.raytraceFromEntity(world, player, false, 4.5D); int block = world.getBlockId(x, y, z); int radius = player.isSneaking() ? 0 : 1; float refStrength = Block.blocksList[block].getBlockHardness(world, x, y, z); @@ -135,7 +138,7 @@ public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPla float strength = adjBlock.getBlockHardness(world, pos.getX(), pos.getY(), pos.getZ()); if (strength > 0f && strength / refStrength <= 8f) { if (canOperate(stack)) { - if (canHarvestBlock(adjBlock, stack) && harvestBlock(world, pos.getX(), pos.getY(), pos.getZ(), player)) { + if (canHarvestBlock(adjBlock, stack) && ToolHelper.harvestBlock(world, pos.getX(), pos.getY(), pos.getZ(), player)) { ElectricItem.manager.use(stack, props.energy_cost, player); } } @@ -298,8 +301,8 @@ public EnumRarity getRarity(ItemStack stack) { @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean flag) { - tooltip.add(TextFormatter.AQUA.format(Helpers.getCharge(stack) + "/" + this.getMaxCharge(stack) + " EU" + " @ Tier " + this.tier)); - tooltip.add(TextFormatter.GOLD.format(Refs.vein_miner)); + super.addInformation(stack, player, tooltip, flag); + tooltip.add(FormattedTranslator.GOLD.format(Refs.vein_miner)); if (Helpers.isShiftKeyDown()) { tooltip.add(Helpers.pressXAndYForZ(Refs.to_change_2, Refs.SNEAK_KEY, "Right Click", Refs.ENCH_MODE + ".stat")); } else { @@ -356,7 +359,7 @@ public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPla } ItemStack blockStack = new ItemStack(block, 1, world.getBlockMetadata(x, y, z)); boolean isOre = false; - for (ItemStack oreStack : Helpers.getStackFromOre("ore")) { + for (ItemStack oreStack : StackHelper.getStackFromOre("ore")) { if (oreStack.isItemEqual(blockStack)) { isOre = true; break; @@ -366,7 +369,7 @@ public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPla return false; if (isOre && !player.capabilities.isCreativeMode) { BlockPos origin = new BlockPos(x, y, z); - for (BlockPos coord : Helpers.veinPos(world, origin, 128)) { + for (BlockPos coord : BlockHelper.veinPos(world, origin, 128)) { if (coord.equals(origin)) { continue; } @@ -374,7 +377,7 @@ public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPla break; } if (ElectricItem.manager.canUse(stack, this.energy_per_use)) { - if (canHarvestBlock(block, stack) && harvestBlock(world, coord.getX(), coord.getY(), coord.getZ(), player)) { + if (canHarvestBlock(block, stack) && ToolHelper.harvestBlock(world, coord.getX(), coord.getY(), coord.getZ(), player)) { ElectricItem.manager.use(stack, this.energy_per_use, player); } } diff --git a/src/main/java/reforged/mods/gravisuite/items/tools/ItemGraviTool.java b/src/main/java/reforged/mods/gravisuite/items/tools/ItemGraviTool.java index d2db588..32dc91b 100644 --- a/src/main/java/reforged/mods/gravisuite/items/tools/ItemGraviTool.java +++ b/src/main/java/reforged/mods/gravisuite/items/tools/ItemGraviTool.java @@ -13,6 +13,7 @@ import ic2.core.audio.PositionSpec; import ic2.core.block.machine.tileentity.TileEntityTerra; import mods.railcraft.api.core.items.IToolCrowbar; +import mods.vintage.core.helpers.BlockHelper; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.item.EntityItem; @@ -28,7 +29,6 @@ import net.minecraftforge.common.ForgeDirection; import reforged.mods.gravisuite.GraviSuiteConfig; import reforged.mods.gravisuite.items.tools.base.ItemToolElectric; -import reforged.mods.gravisuite.utils.BlockHelper; import reforged.mods.gravisuite.utils.Helpers; import reforged.mods.gravisuite.utils.Refs; import universalelectricity.prefab.implement.IToolConfigurator; diff --git a/src/main/java/reforged/mods/gravisuite/items/tools/ItemVajra.java b/src/main/java/reforged/mods/gravisuite/items/tools/ItemVajra.java index ec47432..707e7ff 100644 --- a/src/main/java/reforged/mods/gravisuite/items/tools/ItemVajra.java +++ b/src/main/java/reforged/mods/gravisuite/items/tools/ItemVajra.java @@ -4,6 +4,10 @@ import cpw.mods.fml.relauncher.SideOnly; import ic2.api.item.ElectricItem; import ic2.core.IC2; +import mods.vintage.core.helpers.BlockHelper; +import mods.vintage.core.helpers.StackHelper; +import mods.vintage.core.helpers.ToolHelper; +import mods.vintage.core.helpers.pos.BlockPos; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; @@ -21,7 +25,6 @@ import reforged.mods.gravisuite.items.tools.base.ItemToolElectric; import reforged.mods.gravisuite.utils.Helpers; import reforged.mods.gravisuite.utils.Refs; -import reforged.mods.gravisuite.utils.pos.BlockPos; import java.util.IdentityHashMap; import java.util.List; @@ -126,7 +129,7 @@ public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPla } ItemStack blockStack = new ItemStack(block, 1, world.getBlockMetadata(x, y, z)); boolean isOre = false; - for (ItemStack oreStack : Helpers.getStackFromOre("ore")) { + for (ItemStack oreStack : StackHelper.getStackFromOre("ore")) { if (oreStack.isItemEqual(blockStack)) { isOre = true; break; @@ -135,7 +138,7 @@ public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPla boolean veinGeneral = ((mode == VajraMode.VEIN && isOre) || mode == VajraMode.VEIN_EXTENDED); if (veinGeneral) { BlockPos origin = new BlockPos(x, y, z); - Set vein = Helpers.veinPos(world, origin, player.isSneaking() ? 0 : 128); + Set vein = BlockHelper.veinPos(world, origin, player.isSneaking() ? 0 : 128); for (BlockPos coord : vein) { if (coord.equals(origin)) { continue; @@ -144,7 +147,7 @@ public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPla break; } if (canOperate(stack)) { - if (canHarvestBlock(block) && harvestBlock(world, coord.getX(), coord.getY(), coord.getZ(), player) && !player.capabilities.isCreativeMode) { + if (canHarvestBlock(block) && ToolHelper.harvestBlock(world, coord.getX(), coord.getY(), coord.getZ(), player) && !player.capabilities.isCreativeMode) { ElectricItem.manager.use(stack, props.energyCost, player); } } diff --git a/src/main/java/reforged/mods/gravisuite/items/tools/ItemVoider.java b/src/main/java/reforged/mods/gravisuite/items/tools/ItemVoider.java index 7b20e70..a23e30d 100644 --- a/src/main/java/reforged/mods/gravisuite/items/tools/ItemVoider.java +++ b/src/main/java/reforged/mods/gravisuite/items/tools/ItemVoider.java @@ -4,6 +4,7 @@ import cpw.mods.fml.relauncher.SideOnly; import ic2.api.item.ElectricItem; import ic2.core.IC2; +import mods.vintage.core.platform.lang.FormattedTranslator; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumToolMaterial; @@ -17,7 +18,6 @@ import reforged.mods.gravisuite.items.tools.base.ItemToolElectric; import reforged.mods.gravisuite.utils.Helpers; import reforged.mods.gravisuite.utils.Refs; -import reforged.mods.gravisuite.utils.TextFormatter; import java.util.List; @@ -42,7 +42,7 @@ public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, b tooltip.add(Helpers.pressForInfo(Refs.SNEAK_KEY)); } if (filterStack != null) { - tooltip.add(TextFormatter.GOLD.format("message.info.filter", filterStack.getDisplayName())); + tooltip.add(FormattedTranslator.GOLD.format("message.info.filter", filterStack.getDisplayName())); } } diff --git a/src/main/java/reforged/mods/gravisuite/items/tools/base/ItemToolBase.java b/src/main/java/reforged/mods/gravisuite/items/tools/base/ItemToolBase.java index 9fe761d..e2f304a 100644 --- a/src/main/java/reforged/mods/gravisuite/items/tools/base/ItemToolBase.java +++ b/src/main/java/reforged/mods/gravisuite/items/tools/base/ItemToolBase.java @@ -1,15 +1,8 @@ package reforged.mods.gravisuite.items.tools.base; import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.EnumToolMaterial; import net.minecraft.item.ItemTool; -import net.minecraft.network.packet.Packet14BlockDig; -import net.minecraft.network.packet.Packet53BlockChange; -import net.minecraft.world.World; -import net.minecraftforge.common.ForgeHooks; import reforged.mods.gravisuite.GraviSuite; public class ItemToolBase extends ItemTool { @@ -21,60 +14,4 @@ protected ItemToolBase(int id, String name, EnumToolMaterial material) { this.setNoRepair(); this.setCreativeTab(GraviSuite.graviTab); } - - public boolean harvestBlock(World world, int x, int y, int z, EntityPlayer player) { - if (world.isAirBlock(x, y, z)) { - return false; - } else { - EntityPlayerMP playerMP = null; - if (player instanceof EntityPlayerMP) { - playerMP = (EntityPlayerMP)player; - } - - Block block = Block.blocksList[world.getBlockId(x, y, z)]; - int blockMetadata = world.getBlockMetadata(x, y, z); - if (!ForgeHooks.canHarvestBlock(block, player, 0)) { - return false; - } else if (!ForgeHooks.canHarvestBlock(block, player, blockMetadata)) { - return false; - } else { - if (player.capabilities.isCreativeMode) { - if (!world.isRemote) { - block.onBlockHarvested(world, x, y, z, blockMetadata, player); - } else { - world.playAuxSFX(2001, x, y, z, world.getBlockId(x, y, z) | blockMetadata << 12); - } - - if (block.removeBlockByPlayer(world, player, x, y, z)) { - block.onBlockDestroyedByPlayer(world, x, y, z, blockMetadata); - } - - if (!world.isRemote) { - assert playerMP != null; - playerMP.playerNetServerHandler.sendPacketToPlayer(new Packet53BlockChange()); - } else { - Minecraft.getMinecraft().getNetHandler().addToSendQueue(new Packet14BlockDig()); - } - - } else { - world.playAuxSFXAtEntity(player, 2001, x, y, z, world.getBlockId(x, y, z) | blockMetadata << 12); - if (!world.isRemote) { - block.onBlockHarvested(world, x, y, z, blockMetadata, player); - if (block.removeBlockByPlayer(world, player, x, y, z)) { - block.onBlockDestroyedByPlayer(world, x, y, z, blockMetadata); - block.harvestBlock(world, player, x, y, z, blockMetadata); - } - assert playerMP != null; - playerMP.playerNetServerHandler.sendPacketToPlayer(new Packet53BlockChange()); - } else { - if (block.removeBlockByPlayer(world, player, x, y, z)) { - block.onBlockDestroyedByPlayer(world, x, y, z, blockMetadata); - } - Minecraft.getMinecraft().getNetHandler().addToSendQueue(new Packet14BlockDig()); - } - } - return true; - } - } - } } diff --git a/src/main/java/reforged/mods/gravisuite/items/tools/base/ItemToolElectric.java b/src/main/java/reforged/mods/gravisuite/items/tools/base/ItemToolElectric.java index 11980ae..97d51cf 100644 --- a/src/main/java/reforged/mods/gravisuite/items/tools/base/ItemToolElectric.java +++ b/src/main/java/reforged/mods/gravisuite/items/tools/base/ItemToolElectric.java @@ -4,6 +4,7 @@ import cpw.mods.fml.relauncher.SideOnly; import ic2.api.item.IElectricItem; import ic2.core.IC2; +import mods.vintage.core.platform.lang.FormattedTranslator; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLiving; @@ -16,7 +17,6 @@ import net.minecraftforge.event.ForgeEventFactory; import reforged.mods.gravisuite.utils.Helpers; import reforged.mods.gravisuite.utils.Refs; -import reforged.mods.gravisuite.utils.TextFormatter; import java.util.List; import java.util.Locale; @@ -57,7 +57,7 @@ public void getSubItems(int is, CreativeTabs tabs, List items) { @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean isDebugMode) { - tooltip.add(TextFormatter.AQUA.literal(Helpers.getCharge(stack) + "/" + this.getMaxCharge(stack) + " EU" + " @ Tier " + this.tier)); + tooltip.add(FormattedTranslator.AQUA.format("message.info.energy", Helpers.getCharge(stack), this.getMaxCharge(stack), FormattedTranslator.WHITE.format("message.info.energy.tier", FormattedTranslator.YELLOW.literal(this.tier + "")))); } @Override diff --git a/src/main/java/reforged/mods/gravisuite/keyboard/GraviSuiteKeyboardClient.java b/src/main/java/reforged/mods/gravisuite/keyboard/GraviSuiteKeyboardClient.java index ece1f04..87932ea 100644 --- a/src/main/java/reforged/mods/gravisuite/keyboard/GraviSuiteKeyboardClient.java +++ b/src/main/java/reforged/mods/gravisuite/keyboard/GraviSuiteKeyboardClient.java @@ -2,6 +2,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import mods.vintage.core.helpers.KeyHelper; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; import org.lwjgl.input.Keyboard; @@ -18,9 +19,8 @@ public class GraviSuiteKeyboardClient extends GraviSuiteKeyboard { private int lastKeyState = 0; public GraviSuiteKeyboardClient() { - // Register Keybinds using 1.7.10 method - Minecraft.getMinecraft().gameSettings.keyBindings = Helpers.add(Minecraft.getMinecraft().gameSettings.keyBindings, engine_toggle); - Minecraft.getMinecraft().gameSettings.keyBindings = Helpers.add(Minecraft.getMinecraft().gameSettings.keyBindings, magnet_toggle); + KeyHelper.registerKeybindings(engine_toggle); + KeyHelper.registerKeybindings(magnet_toggle); } @Override diff --git a/src/main/java/reforged/mods/gravisuite/proxy/CommonProxy.java b/src/main/java/reforged/mods/gravisuite/proxy/CommonProxy.java index 789f1b3..f85a1fa 100644 --- a/src/main/java/reforged/mods/gravisuite/proxy/CommonProxy.java +++ b/src/main/java/reforged/mods/gravisuite/proxy/CommonProxy.java @@ -1,22 +1,15 @@ package reforged.mods.gravisuite.proxy; import cpw.mods.fml.common.ITickHandler; -import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.TickRegistry; import cpw.mods.fml.relauncher.Side; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import reforged.mods.gravisuite.GraviSuite; import reforged.mods.gravisuite.GraviSuiteConfig; -import reforged.mods.gravisuite.GraviSuiteData; import reforged.mods.gravisuite.GraviSuiteRecipes; import reforged.mods.gravisuite.events.server.ServerArmorHandler; -import reforged.mods.gravisuite.utils.LangHelper; -import reforged.mods.gravisuite.utils.Refs; import java.util.HashMap; import java.util.Map; @@ -29,18 +22,9 @@ public class CommonProxy { public void preInit(FMLPreInitializationEvent e) { registerTickHandlers(ServerArmorHandler.THIS); GraviSuiteConfig.initConfig(); - LangHelper.init(); } - public void init(FMLInitializationEvent e) { -// if (Loader.isModLoaded("TreeCapitator")) { -// NBTTagCompound capitatorModConfig = new NBTTagCompound(); -// capitatorModConfig.setString("modID", Refs.id); -// capitatorModConfig.setString("axeIDList", GraviSuiteData.advanced_chainsaw.itemID + "; " + GraviSuiteData.vajra.itemID); -// FMLInterModComms.sendMessage("TreeCapitator", "ThirdPartyModConfig", capitatorModConfig); -// GraviSuite.logger.info("TreeCapitator Compat Loaded!"); -// } - } + public void init(FMLInitializationEvent e) {} public void postInit(FMLPostInitializationEvent e) { GraviSuiteRecipes.initRecipes(); diff --git a/src/main/java/reforged/mods/gravisuite/utils/BlockHelper.java b/src/main/java/reforged/mods/gravisuite/utils/BlockHelper.java deleted file mode 100644 index 7b5e621..0000000 --- a/src/main/java/reforged/mods/gravisuite/utils/BlockHelper.java +++ /dev/null @@ -1,191 +0,0 @@ -package reforged.mods.gravisuite.utils; - -import net.minecraft.block.*; -import net.minecraft.world.World; - -public class BlockHelper { - - public static final int[][] SIDE_COORD_MOD = new int[][]{{0, -1, 0}, {0, 1, 0}, {0, 0, -1}, {0, 0, 1}, {-1, 0, 0}, {1, 0, 0}}; - public static final int[] SIDE_LEFT = new int[]{4, 5, 5, 4, 2, 3}; - public static final int[] SIDE_RIGHT = new int[]{5, 4, 4, 5, 3, 2}; - public static final int[] SIDE_OPPOSITE = new int[]{1, 0, 3, 2, 5, 4}; - - public static int getRotateType(Block block) { - if (block instanceof BlockChest) { - return 9; - } - if (block instanceof BlockWood) { - return 7; - } - if (block instanceof BlockDispenser || block instanceof BlockPistonBase || block instanceof BlockHopper) { - return 2; - } - if (block instanceof BlockRailBase) { - return 3; - } - if (block instanceof BlockHalfSlab) { - return 8; - } - if (block instanceof BlockStairs) { - return 5; - } - if (block instanceof BlockFurnace) { - return 1; - } - if (block instanceof BlockSign) { - return 11; - } - if (block instanceof BlockLever) { - return 10; - } - if (block instanceof BlockPumpkin) { - return 4; - } - if (block instanceof BlockRedstoneRepeater) { - return 6; - } - return 0; - } - - public static int[] getAdjacentCoordinatesForSide(int x, int y, int z, int side) { - return new int[]{x + SIDE_COORD_MOD[side][0], y + SIDE_COORD_MOD[side][1], z + SIDE_COORD_MOD[side][2]}; - } - - public static int rotate(World world, int block, int meta, int x, int y, int z) { - int shift; - switch (getRotateType(Block.blocksList[block])) { - case 1: - return SIDE_LEFT[meta]; - case 2: - if (meta < 6) { - ++meta; - return meta % 6; - } - - return meta; - case 3: - if (meta < 2) { - ++meta; - return meta % 2; - } - - return meta; - case 4: - ++meta; - return meta % 4; - case 5: - ++meta; - return meta % 8; - case 6: - int upper = meta & 12; - int lower = meta & 3; - ++lower; - return upper + lower % 4; - case 7: - return (meta + 4) % 12; - case 8: - return (meta + 8) % 16; - case 9: - for(shift = 2; shift < 6; ++shift) { - int[] coords; - coords = getAdjacentCoordinatesForSide(x, y, z, shift); - if (world.getBlockId(coords[0], coords[1], coords[2]) == block) { - world.setBlockMetadataWithNotify(coords[0], coords[1], coords[2], SIDE_OPPOSITE[meta], 1); - return SIDE_OPPOSITE[meta]; - } - } - - return SIDE_LEFT[meta]; - case 10: - shift = 0; - if (meta > 7) { - meta -= 8; - shift = 8; - } - - if (meta == 5) { - return 6 + shift; - } else if (meta == 6) { - return 5 + shift; - } else if (meta == 7) { - return 0 + shift; - } else { - if (meta == 0) { - return 7 + shift; - } - - return meta + shift; - } - case 11: - ++meta; - return meta % 16; - default: - return meta; - } - } - - public static int rotateAlt(World world, int block, int meta, int x, int y, int z) { - int shift; - switch (getRotateType(Block.blocksList[block])) { - case 1: - return SIDE_RIGHT[meta]; - case 2: - if (meta < 6) { - return (meta + 5) % 6; - } - - return meta; - case 3: - if (meta < 2) { - ++meta; - return meta % 2; - } - - return meta; - case 4: - return (meta + 3) % 4; - case 5: - return (meta + 7) % 8; - case 6: - int upper = meta & 12; - int lower = meta & 3; - return upper + (lower + 3) % 4; - case 7: - return (meta + 8) % 12; - case 8: - return (meta + 8) % 16; - case 9: - for(shift = 2; shift < 6; ++shift) { - int[] coords; - coords = getAdjacentCoordinatesForSide(x, y, z, shift); - if (world.getBlockId(coords[0], coords[1], coords[2]) == block) { - world.setBlockMetadataWithNotify(coords[0], coords[1], coords[2], SIDE_OPPOSITE[meta], 1); - return SIDE_OPPOSITE[meta]; - } - } - - return SIDE_RIGHT[meta]; - case 10: - shift = 0; - if (meta > 7) { - meta -= 8; - shift = 8; - } - - if (meta == 5) { - return 6 + shift; - } else if (meta == 6) { - return 5 + shift; - } else if (meta == 7) { - return shift; - } else if (meta == 0) { - return 7 + shift; - } - case 11: - ++meta; - return meta % 16; - default: - return meta; - } - } -} diff --git a/src/main/java/reforged/mods/gravisuite/utils/Helpers.java b/src/main/java/reforged/mods/gravisuite/utils/Helpers.java index 5146a09..a324fc6 100644 --- a/src/main/java/reforged/mods/gravisuite/utils/Helpers.java +++ b/src/main/java/reforged/mods/gravisuite/utils/Helpers.java @@ -2,182 +2,23 @@ import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; -import net.minecraft.block.Block; +import mods.vintage.core.platform.lang.FormattedTranslator; import net.minecraft.client.Minecraft; -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.ItemStack; -import net.minecraft.item.crafting.CraftingManager; -import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.MathHelper; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.Vec3; -import net.minecraft.world.World; -import net.minecraftforge.oredict.OreDictionary; import org.lwjgl.input.Keyboard; -import reforged.mods.gravisuite.utils.pos.BlockPos; -import java.lang.reflect.Array; -import java.util.ArrayList; -import java.util.LinkedHashSet; import java.util.List; -import java.util.Set; public class Helpers { - public static boolean instanceOf(Object obj, String clazz) { - if (obj == null) - return false; - try { - Class c = Class.forName(clazz); - if (c.isInstance(obj)) - return true; - } catch (Throwable ignored) { - } - return false; - } - - public static boolean isAir(World world, BlockPos pos) { - return world.isAirBlock(pos.getX(), pos.getY(), pos.getZ()); - } - - public static int getBlockMetadata(World world, BlockPos pos) { - return world.getBlockMetadata(pos.getX(), pos.getY(), pos.getZ()); - } - - public static Block getBlock(World world, BlockPos pos) { - return getBlock(world, pos.getX(), pos.getY(), pos.getZ()); - } - - public static Block getBlock(World world, int x, int y, int z) { - return Block.blocksList[world.getBlockId(x, y, z)]; - } - - public static boolean areStacksEqual(ItemStack aStack, ItemStack bStack) { - return aStack != null && bStack != null && - aStack.itemID == bStack.itemID && - (aStack.getTagCompound() == null == (bStack.getTagCompound() == null)) && - (aStack.getTagCompound() == null || aStack.getTagCompound().equals(bStack.getTagCompound())) - && (aStack.getItemDamage() == bStack.getItemDamage() || aStack.getItemDamage() == 32767 || bStack.getItemDamage() == 32767); - } - - public static Set veinPos(World world, BlockPos origin, int maxVeinSize) { - int originID = world.getBlockId(origin.getX(), origin.getY(), origin.getZ()); - Set found = new LinkedHashSet(); - Set openSet = new LinkedHashSet(); - openSet.add(origin); // add origin - while (!openSet.isEmpty()) { // just in case check if it's not empty - BlockPos blockPos = openSet.iterator().next(); - found.add(blockPos); // add blockPos to found list for return - openSet.remove(blockPos); // remove it and continue - if (found.size() > maxVeinSize) { // nah, too much - return found; - } - for (BlockPos pos : BlockPos.getAllInBoxMutable(blockPos.add(-1, -1, -1), blockPos.add(1, 1, 1))) { - if (!found.contains(pos)) { // we check if it's not in the list already - int checkedBlockId = world.getBlockId(pos.getX(), pos.getY(), pos.getZ()); - if (checkedBlockId != 0) { - if (originID == checkedBlockId) { - openSet.add(pos.toImmutable()); // add to openSet so we add it later when !openSet.isEmpty() - } - if (originID == Block.oreRedstone.blockID || originID == Block.oreRedstoneGlowing.blockID) { - if (checkedBlockId == Block.oreRedstone.blockID || checkedBlockId == Block.oreRedstoneGlowing.blockID) { - openSet.add(pos.toImmutable()); - } - } - } - } - } - } - return found; - } - - @SuppressWarnings("unchecked") - public static void removeRecipeByOutput(ItemStack stack) { - if (stack != null) { - ArrayList recipeList = (ArrayList) CraftingManager.getInstance().getRecipeList(); - for (int i = 0; i < recipeList.size(); i++) { - ItemStack output = recipeList.get(i).getRecipeOutput(); - if (output != null) { - if (stack.isItemEqual(recipeList.get(i).getRecipeOutput())) { - recipeList.remove(i); - } - } - } - } - } - public static ItemStack withSize(ItemStack stack, int count) { ItemStack returnStack = stack.copy(); returnStack.stackSize = count; return returnStack; } - public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean checkFluid, double range) { - float f = 1.0F; - float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f; - float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f; - double d0 = player.prevPosX + (player.posX - player.prevPosX) * f; - double d1 = player.prevPosY + (player.posY - player.prevPosY) * f; - if ((!world.isRemote) && ((player instanceof EntityPlayer))) { - d1 += 1.62D; - } - double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * f; - Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2); - float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F); - float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F); - float f5 = -MathHelper.cos(-f1 * 0.017453292F); - float f6 = MathHelper.sin(-f1 * 0.017453292F); - float f7 = f4 * f5; - float f8 = f3 * f5; - double d3 = range; - if ((player instanceof EntityPlayerMP)) { - d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance(); - } - Vec3 vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3); - return world.rayTraceBlocks_do_do(vec3, vec31, checkFluid, !checkFluid); - } - - // Java 8+ method - public static T[] add(final T[] array, final T element) { - final Class type; - if (array != null) { - type = array.getClass().getComponentType(); - } else if (element != null) { - type = element.getClass(); - } else { - throw new IllegalArgumentException("Arguments cannot both be null"); - } - @SuppressWarnings("unchecked") // type must be T - final T[] newArray = (T[]) copyArrayGrow(array, type); - newArray[newArray.length - 1] = element; - return newArray; - } - - private static Object copyArrayGrow(final Object array, final Class newArrayComponentType) { - if (array != null) { - final int arrayLength = Array.getLength(array); - final Object newArray = Array.newInstance(array.getClass().getComponentType(), arrayLength + 1); - System.arraycopy(array, 0, newArray, 0, arrayLength); - return newArray; - } - return Array.newInstance(newArrayComponentType, 1); - } - - public static List getStackFromOre(String startWith) { - List stacks = new ArrayList(); - for (String name : OreDictionary.getOreNames()) { - if (name.startsWith(startWith)) { - List oreDictList = OreDictionary.getOres(name); - stacks.addAll(oreDictList); - } - } - return stacks; - } - public static ItemStack getCharged(Item item, int charge) { if (!(item instanceof IElectricItem)) { throw new IllegalArgumentException(item + " must be an instanceof IElectricItem"); @@ -213,19 +54,19 @@ public static boolean isShiftKeyDown() { } public static String pressForInfo(String data) { - return TextFormatter.GRAY.format("message.info.press", TextFormatter.GOLD.format(data)); + return FormattedTranslator.GRAY.format("message.info.press", FormattedTranslator.GOLD.format(data)); } public static String pressXForY(String message, String key1, String action) { - return TextFormatter.GRAY.format(message, TextFormatter.GOLD.literal(key1), TextFormatter.YELLOW.format(action)); + return FormattedTranslator.GRAY.format(message, FormattedTranslator.GOLD.literal(key1), FormattedTranslator.YELLOW.format(action)); } public static String pressXAndYForZ(String message, String key1, String key2, String action) { - return TextFormatter.GRAY.format(message, TextFormatter.GOLD.literal(key1), TextFormatter.GOLD.literal(key2), TextFormatter.YELLOW.format(action)); + return FormattedTranslator.GRAY.format(message, FormattedTranslator.GOLD.literal(key1), FormattedTranslator.GOLD.literal(key2), FormattedTranslator.YELLOW.format(action)); } public static String clickFor(String key, String message) { - return TextFormatter.GRAY.format("message.info.click.block", TextFormatter.GOLD.literal(key), TextFormatter.YELLOW.format(message)); + return FormattedTranslator.GRAY.format("message.info.click.block", FormattedTranslator.GOLD.literal(key), FormattedTranslator.YELLOW.format(message)); } public static String getStatusMessage(boolean status) { diff --git a/src/main/java/reforged/mods/gravisuite/utils/LangHelper.java b/src/main/java/reforged/mods/gravisuite/utils/LangHelper.java deleted file mode 100644 index e866d05..0000000 --- a/src/main/java/reforged/mods/gravisuite/utils/LangHelper.java +++ /dev/null @@ -1,94 +0,0 @@ -package reforged.mods.gravisuite.utils; - -import cpw.mods.fml.common.registry.LanguageRegistry; -import net.minecraft.client.Minecraft; -import net.minecraft.util.StatCollector; -import net.minecraft.util.StringTranslate; -import reforged.mods.gravisuite.GraviSuite; -import reforged.mods.gravisuite.GraviSuiteConfig; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.Properties; - -public final class LangHelper { - - public LangHelper() { - throw new UnsupportedOperationException(); - } - - // TODO: make it possible to use different languages on the fly - - public static void init() { - if (!GraviSuiteConfig.additional_languages.isEmpty()) { - String[] LANGS = GraviSuiteConfig.additional_languages.split(","); - if (LANGS.length == 1) { - addEntry(GraviSuiteConfig.additional_languages); - } else { - for (String lang : LANGS) { - addEntry(lang); - } - } - } else { - String[] LANGS = GraviSuiteConfig.default_language.split(","); - if (LANGS.length == 1) { - addEntry(GraviSuiteConfig.default_language); - } else { - for (String lang : LANGS) { - addEntry(lang); - } - } - } - LanguageRegistry.reloadLanguageTable(); - } - - private static void addEntry(String lang) { - InputStream stream = null; - InputStreamReader reader = null; - try { - if (GraviSuiteConfig.additional_languages.isEmpty()) { - stream = LangHelper.class.getResourceAsStream("/mods/gravisuite/lang/" + lang + ".lang"); // use the default .lang file from modJar - } else { - stream = new FileInputStream(Minecraft.getMinecraftDir() + "/config/gravisuite/lang/" + lang + ".lang"); // use the lang files from config/gravisuite/lang folder - } - if (stream == null) { - throw new IOException("Couldn't load language file."); - } - - reader = new InputStreamReader(stream, "UTF-8"); - Properties props = new Properties(); - props.load(reader); - for (String key : props.stringPropertyNames()) { - LanguageRegistry.instance().addStringLocalization(key, lang, props.getProperty(key)); - } - - } catch (Throwable t) { - GraviSuite.logger.severe("Error loading language " + lang + "."); - t.printStackTrace(); - } finally { - if (stream != null) { - try { - stream.close(); - } catch (Throwable ignored) { - } - } - if (reader != null) { - try { - reader.close(); - } catch (Throwable ignored) { - } - } - } - } - - public static String format(String key, Object... args) { - return format(null, key, args); - } - - public static String format(StringTranslate translator, String key, Object... args) { - if (translator == null) return StatCollector.translateToLocalFormatted(key, args); - return translator.translateKeyFormat(key, args); - } -} diff --git a/src/main/java/reforged/mods/gravisuite/utils/Refs.java b/src/main/java/reforged/mods/gravisuite/utils/Refs.java index 029dafc..3f94843 100644 --- a/src/main/java/reforged/mods/gravisuite/utils/Refs.java +++ b/src/main/java/reforged/mods/gravisuite/utils/Refs.java @@ -1,12 +1,13 @@ package reforged.mods.gravisuite.utils; +import mods.vintage.core.platform.lang.FormattedTranslator; import net.minecraft.util.StatCollector; public class Refs { public static final String id = "gravisuite"; public static final String name = "GraviSuite - Addon"; - public static final String version = "1.5.2-2.2.2t"; + public static final String version = "1.5.2-2.2.2u"; public static final String mc = "[1.5.2]"; public static final String deps = "required-after:IC2;after:GregTech_Addon;after:TreeCapitator"; @@ -72,42 +73,42 @@ public class Refs { // Formatted Messages // \247 - public static final String energy_level = TextFormatter.WHITE.format(ENERGY_LEVEL); - public static final String energy_level_gold = TextFormatter.GOLD.format(ENERGY_LEVEL); - public static final String jetpack_engine = TextFormatter.YELLOW.format(JETPACK_ENGINE); - public static final String jetpack_engine_gold = TextFormatter.GOLD.format(JETPACK_ENGINE); - public static final String jetpack_hover = TextFormatter.YELLOW.format(JETPACK_HOVER); - public static final String jetpack_hover_gold = TextFormatter.GOLD.format(JETPACK_HOVER); - public static final String status_on = TextFormatter.GREEN.format(STATUS_ON); - public static final String status_off = TextFormatter.RED.format(STATUS_OFF); - public static final String status_low = TextFormatter.RED.format(STATUS_LOW_ENERGY); - public static final String status_shutdown = TextFormatter.RED.format(STATUS_SHUTDOWN); - public static final String gravitation_engine = TextFormatter.AQUA.format(GRAVITATION_ENGINE); - public static final String gravitation_levitation = TextFormatter.AQUA.format(LEVITATION); - public static final String eff_tool_mode = TextFormatter.YELLOW.format(EFF_MODE); - public static final String eff_tool_mode_gold = TextFormatter.GOLD.format(EFF_MODE); - public static final String eff_tool_mode_normal = TextFormatter.LIGHT_PURPLE.format(EFF_MODE_NORMAL); - public static final String eff_tool_mode_low = TextFormatter.GREEN.format(EFF_MODE_LOW_POWER); - public static final String eff_tool_mode_fine = TextFormatter.AQUA.format(EFF_MODE_FINE); - public static final String tool_mode_magnet = TextFormatter.YELLOW.format(MAGNET_MODE); - public static final String tool_mode_magnet_gold = TextFormatter.GOLD.format(MAGNET_MODE); - public static final String tool_mode_shear = TextFormatter.YELLOW.format(SHEAR_MODE); - public static final String tool_mode_capitator = TextFormatter.YELLOW.format(CAPITATOR_MODE); - public static final String tool_mode_shear_gold = TextFormatter.GOLD.format(SHEAR_MODE); - public static final String tool_mode_capitator_gold = TextFormatter.GOLD.format(CAPITATOR_MODE); - public static final String tool_mining_mode = TextFormatter.YELLOW.format(MINING_MODE); - public static final String tool_mining_mode_gold = TextFormatter.GOLD.format(MINING_MODE); - public static final String tool_mode = TextFormatter.YELLOW.format(MODE); - public static final String tool_mode_gold = TextFormatter.GOLD.format(MODE); - public static final String ench_mode_yellow = TextFormatter.YELLOW.format(ENCH_MODE); - public static final String tool_mode_normal = TextFormatter.GREEN.format(MODE_NORMAL); - public static final String tool_mode_big_holes = TextFormatter.LIGHT_PURPLE.format(MODE_BIG_HOLES); - public static final String tool_mode_vein = TextFormatter.AQUA.format(MODE_VEIN); - public static final String tool_mode_vein_extended = TextFormatter.LIGHT_PURPLE.format(MODE_VEIN_EXTENDED); - public static final String tool_mode_silk = TextFormatter.GREEN.format(MODE_SILK); - public static final String tool_mode_fortune = TextFormatter.AQUA.format(MODE_FORTUNE); - public static final String tool_mode_hoe = TextFormatter.GREEN.format(TOOL_MODE_HOE); - public static final String tool_mode_treetap = TextFormatter.GOLD.format(TOOL_MODE_TREETAP); - public static final String tool_mode_wrench = TextFormatter.AQUA.format(TOOL_MODE_WRENCH); - public static final String tool_mode_screwdriver = TextFormatter.LIGHT_PURPLE.format(TOOL_MODE_SCREWDRIVER); + public static final String energy_level = FormattedTranslator.WHITE.format(ENERGY_LEVEL); + public static final String energy_level_gold = FormattedTranslator.GOLD.format(ENERGY_LEVEL); + public static final String jetpack_engine = FormattedTranslator.YELLOW.format(JETPACK_ENGINE); + public static final String jetpack_engine_gold = FormattedTranslator.GOLD.format(JETPACK_ENGINE); + public static final String jetpack_hover = FormattedTranslator.YELLOW.format(JETPACK_HOVER); + public static final String jetpack_hover_gold = FormattedTranslator.GOLD.format(JETPACK_HOVER); + public static final String status_on = FormattedTranslator.GREEN.format(STATUS_ON); + public static final String status_off = FormattedTranslator.RED.format(STATUS_OFF); + public static final String status_low = FormattedTranslator.RED.format(STATUS_LOW_ENERGY); + public static final String status_shutdown = FormattedTranslator.RED.format(STATUS_SHUTDOWN); + public static final String gravitation_engine = FormattedTranslator.AQUA.format(GRAVITATION_ENGINE); + public static final String gravitation_levitation = FormattedTranslator.AQUA.format(LEVITATION); + public static final String eff_tool_mode = FormattedTranslator.YELLOW.format(EFF_MODE); + public static final String eff_tool_mode_gold = FormattedTranslator.GOLD.format(EFF_MODE); + public static final String eff_tool_mode_normal = FormattedTranslator.LIGHT_PURPLE.format(EFF_MODE_NORMAL); + public static final String eff_tool_mode_low = FormattedTranslator.GREEN.format(EFF_MODE_LOW_POWER); + public static final String eff_tool_mode_fine = FormattedTranslator.AQUA.format(EFF_MODE_FINE); + public static final String tool_mode_magnet = FormattedTranslator.YELLOW.format(MAGNET_MODE); + public static final String tool_mode_magnet_gold = FormattedTranslator.GOLD.format(MAGNET_MODE); + public static final String tool_mode_shear = FormattedTranslator.YELLOW.format(SHEAR_MODE); + public static final String tool_mode_capitator = FormattedTranslator.YELLOW.format(CAPITATOR_MODE); + public static final String tool_mode_shear_gold = FormattedTranslator.GOLD.format(SHEAR_MODE); + public static final String tool_mode_capitator_gold = FormattedTranslator.GOLD.format(CAPITATOR_MODE); + public static final String tool_mining_mode = FormattedTranslator.YELLOW.format(MINING_MODE); + public static final String tool_mining_mode_gold = FormattedTranslator.GOLD.format(MINING_MODE); + public static final String tool_mode = FormattedTranslator.YELLOW.format(MODE); + public static final String tool_mode_gold = FormattedTranslator.GOLD.format(MODE); + public static final String ench_mode_yellow = FormattedTranslator.YELLOW.format(ENCH_MODE); + public static final String tool_mode_normal = FormattedTranslator.GREEN.format(MODE_NORMAL); + public static final String tool_mode_big_holes = FormattedTranslator.LIGHT_PURPLE.format(MODE_BIG_HOLES); + public static final String tool_mode_vein = FormattedTranslator.AQUA.format(MODE_VEIN); + public static final String tool_mode_vein_extended = FormattedTranslator.LIGHT_PURPLE.format(MODE_VEIN_EXTENDED); + public static final String tool_mode_silk = FormattedTranslator.GREEN.format(MODE_SILK); + public static final String tool_mode_fortune = FormattedTranslator.AQUA.format(MODE_FORTUNE); + public static final String tool_mode_hoe = FormattedTranslator.GREEN.format(TOOL_MODE_HOE); + public static final String tool_mode_treetap = FormattedTranslator.GOLD.format(TOOL_MODE_TREETAP); + public static final String tool_mode_wrench = FormattedTranslator.AQUA.format(TOOL_MODE_WRENCH); + public static final String tool_mode_screwdriver = FormattedTranslator.LIGHT_PURPLE.format(TOOL_MODE_SCREWDRIVER); } diff --git a/src/main/java/reforged/mods/gravisuite/utils/TextFormatter.java b/src/main/java/reforged/mods/gravisuite/utils/TextFormatter.java deleted file mode 100644 index 1d5d28d..0000000 --- a/src/main/java/reforged/mods/gravisuite/utils/TextFormatter.java +++ /dev/null @@ -1,43 +0,0 @@ -package reforged.mods.gravisuite.utils; - -public enum TextFormatter { - BLACK("0"), - DARK_BLUE("1"), - DARK_GREEN("2"), - DARK_AQUA("3"), - DARK_RED("4"), - DARK_PURPLE("5"), - GOLD("6"), - GRAY("7"), // default text color - DARK_GRAY("8"), - BLUE("9"), - GREEN("a"), - AQUA("b"), - RED("c"), - LIGHT_PURPLE("d"), - YELLOW("e"), - WHITE("f"); - - private final String colorCode; - - TextFormatter(String colorIndex) { - this.colorCode = "\247" + colorIndex; - } - - public String literal(String text) { - return this.colorCode + text + GRAY; - } - - public String format(String text) { - return this.colorCode + LangHelper.format(text) + GRAY; - } - - public String format(String text, Object... args) { - return this.colorCode + LangHelper.format(text, args) + GRAY; - } - - @Override - public String toString() { - return this.colorCode; - } -} diff --git a/src/main/java/reforged/mods/gravisuite/utils/pos/BlockPos.java b/src/main/java/reforged/mods/gravisuite/utils/pos/BlockPos.java deleted file mode 100644 index 3fdcbe9..0000000 --- a/src/main/java/reforged/mods/gravisuite/utils/pos/BlockPos.java +++ /dev/null @@ -1,115 +0,0 @@ -package reforged.mods.gravisuite.utils.pos; - -import com.google.common.collect.AbstractIterator; -import net.jcip.annotations.Immutable; - -import java.util.Iterator; - -@Immutable -public class BlockPos extends Vec3i { - - public BlockPos(int x, int y, int z) { - super(x, y, z); - } - - public BlockPos(double x, double y, double z) { - super(x, y, z); - } - - public BlockPos(Vec3i source) { - this(source.getX(), source.getY(), source.getZ()); - } - - public BlockPos add(double x, double y, double z) { - return x == 0.0D && y == 0.0D && z == 0.0D ? this : new BlockPos((double) this.getX() + x, (double) this.getY() + y, (double) this.getZ() + z); - } - - public BlockPos add(int x, int y, int z) { - return x == 0 && y == 0 && z == 0 ? this : new BlockPos(this.getX() + x, this.getY() + y, this.getZ() + z); - } - - public BlockPos add(Vec3i vec) { - return this.add(vec.getX(), vec.getY(), vec.getZ()); - } - - public BlockPos toImmutable() { - return this; - } - - public static Iterable getAllInBoxMutable(BlockPos from, BlockPos to) { - return getAllInBoxMutable(Math.min(from.getX(), to.getX()), Math.min(from.getY(), to.getY()), Math.min(from.getZ(), to.getZ()), Math.max(from.getX(), to.getX()), Math.max(from.getY(), to.getY()), Math.max(from.getZ(), to.getZ())); - } - - public static Iterable getAllInBoxMutable(final int x1, final int y1, final int z1, final int x2, final int y2, final int z2) { - return new Iterable() { - public Iterator iterator() { - return new AbstractIterator() { - private MutableBlockPos pos; - - protected MutableBlockPos computeNext() { - if (this.pos == null) { - this.pos = new MutableBlockPos(x1, y1, z1); - return this.pos; - } else if (this.pos.x == x2 && this.pos.y == y2 && this.pos.z == z2) { - return this.endOfData(); - } else { - if (this.pos.x < x2) { - ++this.pos.x; - } else if (this.pos.y < y2) { - this.pos.x = x1; - ++this.pos.y; - } else if (this.pos.z < z2) { - this.pos.x = x1; - this.pos.y = y1; - ++this.pos.z; - } - - return this.pos; - } - } - }; - } - }; - } - - public static class MutableBlockPos extends BlockPos { - protected int x; - protected int y; - protected int z; - - public MutableBlockPos(int x, int y, int z) { - super(0, 0, 0); - this.x = x; - this.y = y; - this.z = z; - } - - public BlockPos add(double x, double y, double z) { - return super.add(x, y, z).toImmutable(); - } - - public BlockPos add(int x, int y, int z) { - return super.add(x, y, z).toImmutable(); - } - - public int getX() { - return this.x; - } - - public int getY() { - return this.y; - } - - public int getZ() { - return this.z; - } - - public void setY(int yIn) { - this.y = yIn; - } - - public BlockPos toImmutable() { - return new BlockPos(this); - } - } -} diff --git a/src/main/java/reforged/mods/gravisuite/utils/pos/Vec3i.java b/src/main/java/reforged/mods/gravisuite/utils/pos/Vec3i.java deleted file mode 100644 index 5810dc1..0000000 --- a/src/main/java/reforged/mods/gravisuite/utils/pos/Vec3i.java +++ /dev/null @@ -1,90 +0,0 @@ -package reforged.mods.gravisuite.utils.pos; - -import com.google.common.base.Objects; -import net.jcip.annotations.Immutable; -import net.minecraft.util.MathHelper; - -@Immutable -public class Vec3i implements Comparable { - /** - * X coordinate - */ - private final int x; - /** - * Y coordinate - */ - private final int y; - /** - * Z coordinate - */ - private final int z; - - public Vec3i(int xIn, int yIn, int zIn) { - this.x = xIn; - this.y = yIn; - this.z = zIn; - } - - public Vec3i(double xIn, double yIn, double zIn) { - this(MathHelper.floor_double(xIn), MathHelper.floor_double(yIn), MathHelper.floor_double(zIn)); - } - - /** - * Gets the X coordinate. - */ - public int getX() { - return this.x; - } - - /** - * Gets the Y coordinate. - */ - public int getY() { - return this.y; - } - - /** - * Gets the Z coordinate. - */ - public int getZ() { - return this.z; - } - - @Override - public boolean equals(Object p_equals_1_) { - if (this == p_equals_1_) { - return true; - } else if (!(p_equals_1_ instanceof Vec3i)) { - return false; - } else { - Vec3i vec3i = (Vec3i) p_equals_1_; - - if (this.getX() != vec3i.getX()) { - return false; - } else if (this.getY() != vec3i.getY()) { - return false; - } else { - return this.getZ() == vec3i.getZ(); - } - } - } - - @Override - public int hashCode() { - return (this.getY() + this.getZ() * 31) * 31 + this.getX(); - } - - @Override - public int compareTo(Vec3i p_compareTo_1_) { - if (this.getY() == p_compareTo_1_.getY()) { - return this.getZ() == p_compareTo_1_.getZ() ? this.getX() - p_compareTo_1_.getX() : this.getZ() - p_compareTo_1_.getZ(); - } else { - return this.getY() - p_compareTo_1_.getY(); - } - } - - @Override - public String toString() { - return Objects.toStringHelper(this).add("x", this.getX()).add("y", this.getY()).add("z", this.getZ()).toString(); - } -} diff --git a/src/main/resources/mods/gravisuite/lang/en_US.lang b/src/main/resources/mods/gravisuite/lang/en_US.lang index 4a4d9f3..7bcba73 100644 --- a/src/main/resources/mods/gravisuite/lang/en_US.lang +++ b/src/main/resources/mods/gravisuite/lang/en_US.lang @@ -98,5 +98,6 @@ message.info.filter.set=Set the filter message.vein.active=Active Vein Miner message.info.filter=Void Filter: %s message.info.quick_change=[!] Quick Mode Change [!] - - +## USE TOGETHER: AQUA.format("message.info.energy", WHITE.format("message.info.energy.tier", tier)) +message.info.energy=%s/%s EU %s +message.info.energy.tier=(Tier: %s) \ No newline at end of file diff --git a/src/main/resources/mods/gravisuite/lang/ru_RU.lang b/src/main/resources/mods/gravisuite/lang/ru_RU.lang index 882ec48..394182f 100644 --- a/src/main/resources/mods/gravisuite/lang/ru_RU.lang +++ b/src/main/resources/mods/gravisuite/lang/ru_RU.lang @@ -91,4 +91,7 @@ message.info.filter.set=чтобы установить фильтр message.vein.active=Активный режим добычи рудной жилы message.info.filter=Уничтожать предмет: %s -message.info.quick_change=[!] Быстрое переключение режимов [!] \ No newline at end of file +message.info.quick_change=[!] Быстрое переключение режимов [!] +## USE TOGETHER: AQUA.format("message.info.energy", WHITE.format("message.info.energy.tier", tier)) +message.info.energy=%s/%s EU %s +message.info.energy.tier=(Т: %s) \ No newline at end of file