From 66f575551bb6bb208d457940b46eb36c52a4d80e Mon Sep 17 00:00:00 2001 From: Jacky Scrubby Date: Sat, 3 Oct 2020 23:53:04 +0800 Subject: [PATCH] 1.2 Update - Fixed infinity armor no clip breaking spectator mode (finally), closes #4 - Corrected wordings on the infinity sword tooltip - Added GunpowderLib as a required dependency, refactored some codes to call methods from new library --- README.md | 6 +- build.gradle | 117 +++++++++--------- gradle.properties | 6 +- .../jackyy/avaritiatweaks/AvaritiaTweaks.java | 6 +- .../compat/botania/BotaniaCompat.java | 7 +- .../compat/botania/block/BlockGaia.java | 2 +- .../compat/botania/block/BlockInfinitato.java | 4 +- .../compat/botania/tile/TileInfinitato.java | 4 +- .../avaritiatweaks/compat/jei/JEICompat.java | 7 +- .../item/ItemEnhancementCrystal.java | 4 +- .../tweaks/ModEventsHandler.java | 59 ++++----- .../jackyy/avaritiatweaks/util/ModUtils.java | 43 +++---- .../assets/avaritiatweaks/lang/en_US.lang | 1 + .../assets/avaritiatweaks/lang/zh_CN.lang | 1 + src/main/resources/mcmod.info | 2 +- 15 files changed, 129 insertions(+), 140 deletions(-) diff --git a/README.md b/README.md index 4c731e0..f3b2d15 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ Submit any bug reports / suggestions via [issue tracker](https://github.com/Jack ## Contact Me - Twitter DM - [@JackyyTV](https://twitter.com/JackyyTV) -- Discord DM - Jacky#3044 +- Discord DM - Jacky#1234 - Twitch PM - [Jackyy](https://www.twitch.tv/jackyy) -- Reddit DM - [Jacky1356400](https://www.reddit.com/message/compose/?to=Jacky1356400) +- Reddit DM - [JackyyTV](https://www.reddit.com/message/compose/?to=JackyyTV) --- @@ -37,7 +37,7 @@ If you would like to set up the workspace yourself to submit PRs of features add - Decompiled source: `gradlew setupDecompWorkspace` - Obfuscated source: `gradlew setupDevWorkspace` - CI server: `gradlew setupCIWorkspace` - + 3. Either use `gradlew build` to build the jar file (Output is in `build/libs`), or setup the IDE if you are going to modify any codes. Both IntelliJ IDEA and Eclipse are included below since they're more popular IDEs. - IntelliJ IDEA: Do `gradlew idea`, open the `.ipr` file and import the gradle file, then execute the `genIntellijRuns` task in the "Gradle" tab. - Eclipse: Do `gradlew eclipse` and open the directory as project. diff --git a/build.gradle b/build.gradle index 8dce0af..edd10d6 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,11 @@ buildscript { - repositories { - jcenter() - maven { url = "http://files.minecraftforge.net/maven" } - } - dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' - } + repositories { + jcenter() + maven { url = "http://files.minecraftforge.net/maven" } + } + dependencies { + classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' + } } apply plugin: 'net.minecraftforge.gradle.forge' @@ -15,80 +15,79 @@ archivesBaseName = "AvaritiaTweaks" sourceCompatibility = targetCompatibility = "1.8" compileJava { - sourceCompatibility = targetCompatibility = "1.8" + sourceCompatibility = targetCompatibility = "1.8" } minecraft { - version = "${forge_version}" - runDir = "run" - mappings = "${mappings_version}" + version = "${forge_version}" + runDir = "run" + mappings = "${mappings_version}" - replace '@FINGERPRINT@', project.findProperty('signSHA1') - replaceIn "AvaritiaTweaks.java" + replace '@FINGERPRINT@', project.findProperty('signSHA1') + replaceIn "AvaritiaTweaks.java" } repositories { - maven { - name = "JEI Maven" - url = "http://dvs1.progwml6.com/files/maven" - } - maven { - name = "Hwyla Maven" - url = "https://tehnut.info/maven" - } - maven { - name = "CB Maven" - url = "http://chickenbones.net/maven" - } - maven { - name = "CoFH Maven" - url = "http://maven.covers1624.net" - } - maven { - name = "CraftTweaker Maven" - url = "http://maven.blamejared.com" - } + maven { + name = "JEI Maven" + url = "https://dvs1.progwml6.com/files/maven" + } + maven { + name = "CB Maven" + url = "http://chickenbones.net/maven" + } + maven { + name = "CoFH Maven" + url = "http://maven.covers1624.net" + } + maven { + name = "Curse Maven" + url = "https://www.cursemaven.com" + } } dependencies { - deobfCompile "mezz.jei:jei_1.12.2:+" - deobfCompile "mcp.mobius.waila:Hwyla:+" - deobfCompile "codechicken:CodeChickenLib:1.12.2-+:universal" - deobfCompile "morph.avaritia:Avaritia:1.12-+:universal" - deobfCompile "vazkii.botania:Botania:+:universal" + deobfCompile "mezz.jei:jei_1.12.2:+" + deobfCompile "curse.maven:hwyla:2568751" //1.8.26-B41_1.12.2 + deobfCompile "curse.maven:gunpowderlib:2852431" //1.12.2-1.0 + deobfCompile "codechicken:CodeChickenLib:1.12.2-+:universal" + deobfCompile("morph.avaritia:Avaritia:1.12.2-+:universal") { + transitive = false + } + deobfCompile "curse.maven:botania:2846950" //r1.10-363 } processResources { - inputs.property "version", project.version - inputs.property "mcversion", project.minecraft.version - from(sourceSets.main.resources.srcDirs) { - include 'mcmod.info' - expand 'version':project.version, 'mcversion':project.minecraft.version - } - from(sourceSets.main.resources.srcDirs) { - exclude 'mcmod.info' - } + inputs.property "version", project.version + inputs.property "mcversion", project.minecraft.version + from(sourceSets.main.resources.srcDirs) { + include 'mcmod.info' + expand 'version':project.version, 'mcversion':project.minecraft.version + } + from(sourceSets.main.resources.srcDirs) { + exclude 'mcmod.info' + } } task signJar(type: SignJar, dependsOn: reobfJar) { - onlyIf { - project.hasProperty('keyStore') - } - keyStore = project.findProperty('keyStore') - alias = project.findProperty('keyStoreAlias') - storePass = project.findProperty('keyStorePass') - keyPass = project.findProperty('keyStoreKeyPass') - inputFile = jar.archivePath - outputFile = jar.archivePath + onlyIf { + project.hasProperty('keyStore') + } + keyStore = project.findProperty('keyStore') + alias = project.findProperty('keyStoreAlias') + storePass = project.findProperty('keyStorePass') + keyPass = project.findProperty('keyStoreKeyPass') + inputFile = jar.archivePath + outputFile = jar.archivePath } build.dependsOn signJar task deobfJar(type: Jar) { - from sourceSets.main.output - classifier = 'deobf' + from sourceSets.main.output + classifier = 'deobf' } artifacts { - archives deobfJar + archives deobfJar } diff --git a/gradle.properties b/gradle.properties index 71bfbbe..e06a878 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,6 +2,6 @@ # This is required to provide enough memory for the Minecraft decompilation process. org.gradle.jvmargs=-Xmx4G mc_version=1.12.2 -forge_version=1.12.2-14.23.2.2611 -mod_version=1.1 -mappings_version=snapshot_20180204 +forge_version=1.12.2-14.23.5.2847 +mod_version=1.2 +mappings_version=stable_39 diff --git a/src/main/java/jackyy/avaritiatweaks/AvaritiaTweaks.java b/src/main/java/jackyy/avaritiatweaks/AvaritiaTweaks.java index e9e9e69..11d2bb4 100644 --- a/src/main/java/jackyy/avaritiatweaks/AvaritiaTweaks.java +++ b/src/main/java/jackyy/avaritiatweaks/AvaritiaTweaks.java @@ -18,14 +18,14 @@ public class AvaritiaTweaks { public static final String MODID = "avaritiatweaks"; public static final String MODNAME = "Avaritia Tweaks"; - public static final String VERSION = "1.12.2-1.1"; + public static final String VERSION = "1.12.2-1.2"; public static final String MCVERSION = "[1.12,1.13)"; - public static final String DEPENDS = "required-after:avaritia;required-after:codechickenlib;after:botania;"; + public static final String DEPENDS = "required-after:avaritia;required-after:codechickenlib;required-after:gunpowderlib;after:botania;"; public static final String COMMON_PROXY = "jackyy.avaritiatweaks.proxy.CommonProxy"; public static final String CLIENT_PROXY = "jackyy.avaritiatweaks.proxy.ClientProxy"; public static final CreativeTabs TAB = new CreativeTabs(MODID) { @Override - public ItemStack getTabIconItem() { + public ItemStack createIcon() { return new ItemStack(ModTweaks.enhancementCrystal); } }; diff --git a/src/main/java/jackyy/avaritiatweaks/compat/botania/BotaniaCompat.java b/src/main/java/jackyy/avaritiatweaks/compat/botania/BotaniaCompat.java index a46e4c2..d9944c0 100644 --- a/src/main/java/jackyy/avaritiatweaks/compat/botania/BotaniaCompat.java +++ b/src/main/java/jackyy/avaritiatweaks/compat/botania/BotaniaCompat.java @@ -9,6 +9,7 @@ import jackyy.avaritiatweaks.compat.botania.tile.TileInfinitato; import jackyy.avaritiatweaks.config.ModConfig; import jackyy.avaritiatweaks.util.ModUtils; +import jackyy.gunpowderlib.helper.ObjectHelper; import net.minecraft.block.Block; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.init.Items; @@ -66,7 +67,7 @@ public String getUnlocalizedLoreTextForStack(ItemStack stack) { } if (ModConfig.compats.botania.infinitato) { e.getRegistry().register(infinitato); - GameRegistry.registerTileEntity(TileInfinitato.class, "Avaritia_Infinitato"); + GameRegistry.registerTileEntity(TileInfinitato.class, new ResourceLocation(AvaritiaTweaks.MODID, "infinitato_tile")); } } @@ -116,9 +117,9 @@ public static void initRecipes() { GameRegistry.addShapedRecipe( new ResourceLocation(AvaritiaTweaks.MODID, "gaia_ingots_to_block"), null, new ItemStack(gaiaBlock), "XXX", "XXX", "XXX", - 'X', ModUtils.getStackFromName("botania:manaresource", 1, 14) + 'X', ObjectHelper.getItemStackByName("botania:manaresource", 1, 14) ); - GameRegistry.addShapelessRecipe(new ResourceLocation(AvaritiaTweaks.MODID, "gaia_block_to_ingots"), null, ModUtils.getStackFromName("botania:manaresource", 9, 14), Ingredient.fromStacks(new ItemStack(gaiaBlock))); + GameRegistry.addShapelessRecipe(new ResourceLocation(AvaritiaTweaks.MODID, "gaia_block_to_ingots"), null, ObjectHelper.getItemStackByName("botania:manaresource", 9, 14), Ingredient.fromStacks(new ItemStack(gaiaBlock))); } if (ModConfig.compats.botania.soarleander) { BotaniaAPI.registerRuneAltarRecipe( diff --git a/src/main/java/jackyy/avaritiatweaks/compat/botania/block/BlockGaia.java b/src/main/java/jackyy/avaritiatweaks/compat/botania/block/BlockGaia.java index 07cbb2e..38887da 100644 --- a/src/main/java/jackyy/avaritiatweaks/compat/botania/block/BlockGaia.java +++ b/src/main/java/jackyy/avaritiatweaks/compat/botania/block/BlockGaia.java @@ -19,7 +19,7 @@ public class BlockGaia extends Block { public BlockGaia() { super(Material.IRON); setRegistryName("gaia_block"); - setUnlocalizedName(AvaritiaTweaks.MODID + ".gaia_block"); + setTranslationKey(AvaritiaTweaks.MODID + ".gaia_block"); setSoundType(SoundType.METAL); setHarvestLevel("pickaxe", 3); setHardness(50.0F); diff --git a/src/main/java/jackyy/avaritiatweaks/compat/botania/block/BlockInfinitato.java b/src/main/java/jackyy/avaritiatweaks/compat/botania/block/BlockInfinitato.java index cf7197f..e35616c 100644 --- a/src/main/java/jackyy/avaritiatweaks/compat/botania/block/BlockInfinitato.java +++ b/src/main/java/jackyy/avaritiatweaks/compat/botania/block/BlockInfinitato.java @@ -31,7 +31,7 @@ public class BlockInfinitato extends BlockContainer implements ILexiconable { public BlockInfinitato() { super(Material.CLOTH); setRegistryName("infinitato"); - setUnlocalizedName(AvaritiaTweaks.MODID + ".infinitato"); + setTranslationKey(AvaritiaTweaks.MODID + ".infinitato"); setHardness(0.25F); setCreativeTab(AvaritiaTweaks.TAB); } @@ -155,7 +155,7 @@ public boolean isNormalCube(IBlockState state) { return false; } - @Override + @Override @SuppressWarnings("deprecation") public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.ENTITYBLOCK_ANIMATED; } diff --git a/src/main/java/jackyy/avaritiatweaks/compat/botania/tile/TileInfinitato.java b/src/main/java/jackyy/avaritiatweaks/compat/botania/tile/TileInfinitato.java index d4ce15e..ef12160 100644 --- a/src/main/java/jackyy/avaritiatweaks/compat/botania/tile/TileInfinitato.java +++ b/src/main/java/jackyy/avaritiatweaks/compat/botania/tile/TileInfinitato.java @@ -1,6 +1,6 @@ package jackyy.avaritiatweaks.compat.botania.tile; -import jackyy.avaritiatweaks.util.ModUtils; +import jackyy.gunpowderlib.helper.ObjectHelper; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; @@ -26,7 +26,7 @@ public void interact(EntityPlayer player, EnumHand hand, ItemStack stack, EnumFa jump(); if(name.equalsIgnoreCase("shia labeouf") && !world.isRemote && nextDoIt == 0) { nextDoIt = 40; - world.playSound(player, player.getPosition(), ModUtils.getSoundFromName("botania:doit"), + world.playSound(player, player.getPosition(), ObjectHelper.getSoundByName("botania", "doit"), SoundCategory.BLOCKS, 2.5F, 0.7F); } double radius = 10.5; diff --git a/src/main/java/jackyy/avaritiatweaks/compat/jei/JEICompat.java b/src/main/java/jackyy/avaritiatweaks/compat/jei/JEICompat.java index 39951f4..02073e2 100644 --- a/src/main/java/jackyy/avaritiatweaks/compat/jei/JEICompat.java +++ b/src/main/java/jackyy/avaritiatweaks/compat/jei/JEICompat.java @@ -4,6 +4,7 @@ import jackyy.avaritiatweaks.tweaks.ModTweaks; import mezz.jei.api.*; import mezz.jei.api.ingredients.IModIngredientRegistration; +import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IRecipeCategoryRegistration; import morph.avaritia.init.ModBlocks; import morph.avaritia.init.ModItems; @@ -29,9 +30,9 @@ public void registerCategories(IRecipeCategoryRegistration registry) { public void register(IModRegistry registry) { if (ModConfig.compats.jeiCompat) { if (ModConfig.compats.jei.descriptions) { - registry.addIngredientInfo(ModItems.neutron_pile, ItemStack.class, "desc.avaritiatweaks.neutron_pile"); - registry.addIngredientInfo(new ItemStack(ModBlocks.neutron_collector), ItemStack.class, "desc.avaritiatweaks.neutron_collector"); - registry.addIngredientInfo(new ItemStack(ModTweaks.enhancementCrystal), ItemStack.class, "desc.avaritiatweaks.enhancement_crystal"); + registry.addIngredientInfo(ModItems.neutron_pile, VanillaTypes.ITEM, "desc.avaritiatweaks.neutron_pile"); + registry.addIngredientInfo(new ItemStack(ModBlocks.neutron_collector), VanillaTypes.ITEM, "desc.avaritiatweaks.neutron_collector"); + registry.addIngredientInfo(new ItemStack(ModTweaks.enhancementCrystal), VanillaTypes.ITEM, "desc.avaritiatweaks.enhancement_crystal"); } } } diff --git a/src/main/java/jackyy/avaritiatweaks/item/ItemEnhancementCrystal.java b/src/main/java/jackyy/avaritiatweaks/item/ItemEnhancementCrystal.java index 8593a39..91e9ff1 100644 --- a/src/main/java/jackyy/avaritiatweaks/item/ItemEnhancementCrystal.java +++ b/src/main/java/jackyy/avaritiatweaks/item/ItemEnhancementCrystal.java @@ -26,7 +26,7 @@ public class ItemEnhancementCrystal extends Item implements IHaloRenderItem { public ItemEnhancementCrystal() { setRegistryName("enhancement_crystal"); - setUnlocalizedName(AvaritiaTweaks.MODID + ".enhancement_crystal"); + setTranslationKey(AvaritiaTweaks.MODID + ".enhancement_crystal"); setCreativeTab(AvaritiaTweaks.TAB); } @@ -45,7 +45,7 @@ public void getSubItems(CreativeTabs tab, NonNullList list) { } @Override - public EnumRarity getRarity(ItemStack stack) { + public EnumRarity getForgeRarity(ItemStack stack) { return ModItems.COSMIC_RARITY; } diff --git a/src/main/java/jackyy/avaritiatweaks/tweaks/ModEventsHandler.java b/src/main/java/jackyy/avaritiatweaks/tweaks/ModEventsHandler.java index ab39cbb..02c1f3e 100644 --- a/src/main/java/jackyy/avaritiatweaks/tweaks/ModEventsHandler.java +++ b/src/main/java/jackyy/avaritiatweaks/tweaks/ModEventsHandler.java @@ -4,9 +4,9 @@ import jackyy.avaritiatweaks.config.ModConfig; import jackyy.avaritiatweaks.packet.PacketHandler; import jackyy.avaritiatweaks.packet.PacketToggleNoClip; +import jackyy.avaritiatweaks.util.ModUtils; import morph.avaritia.handler.AvaritiaEventHandler; import morph.avaritia.init.ModItems; -import morph.avaritia.item.ItemArmorInfinity; import morph.avaritia.item.tools.ItemSwordInfinity; import morph.avaritia.util.TextUtils; import net.minecraft.block.Block; @@ -17,8 +17,6 @@ import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; @@ -72,48 +70,35 @@ public void onLeftClick(PlayerInteractEvent.LeftClickBlock event) { public void armorTick(LivingEvent.LivingUpdateEvent event) { if (event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)event.getEntityLiving(); - if (isArmorValid(player, EntityEquipmentSlot.HEAD)) { - checkAndAddEffect(player, ModConfig.infinityArmor.infinityHelmetPotionEffects); + if (ModUtils.isArmorValid(player, EntityEquipmentSlot.HEAD)) { + ModUtils.checkAndAddEffect(player, ModConfig.infinityArmor.infinityHelmetPotionEffects); } - if (isArmorValid(player, EntityEquipmentSlot.CHEST)) { - checkAndAddEffect(player, ModConfig.infinityArmor.infinityChestplatePotionEffects); + if (ModUtils.isArmorValid(player, EntityEquipmentSlot.CHEST)) { + ModUtils.checkAndAddEffect(player, ModConfig.infinityArmor.infinityChestplatePotionEffects); } - if (isArmorValid(player, EntityEquipmentSlot.LEGS)) { - checkAndAddEffect(player, ModConfig.infinityArmor.infinityLeggingsPotionEffects); + if (ModUtils.isArmorValid(player, EntityEquipmentSlot.LEGS)) { + ModUtils.checkAndAddEffect(player, ModConfig.infinityArmor.infinityLeggingsPotionEffects); } - if (isArmorValid(player, EntityEquipmentSlot.FEET)) { - checkAndAddEffect(player, ModConfig.infinityArmor.infinityBootsPotionEffects); + if (ModUtils.isArmorValid(player, EntityEquipmentSlot.FEET)) { + ModUtils.checkAndAddEffect(player, ModConfig.infinityArmor.infinityBootsPotionEffects); } - if (isArmorValid(player, EntityEquipmentSlot.CHEST) && AvaritiaEventHandler.isInfinite(player) && noClip) { - player.capabilities.isFlying = true; - player.noClip = true; - } - if (!AvaritiaEventHandler.isInfinite(player) && !noClip) { - player.noClip = false; - } - if (noClip && !player.capabilities.isFlying) { - player.capabilities.isFlying = true; - } - } - } - - private static boolean isArmorValid(EntityPlayer player, EntityEquipmentSlot slot) { - ItemStack armor = player.getItemStackFromSlot(slot); - return armor != ItemStack.EMPTY && armor.getItem() instanceof ItemArmorInfinity - && armor.getTagCompound() != null && armor.getTagCompound().getInteger("enhanced") == 1; - } - - private static void checkAndAddEffect(EntityPlayer player, String[] potions) { - for (String potion : potions) { - Potion effect = Potion.getPotionFromResourceLocation(potion); - if (effect != null) { - player.addPotionEffect(new PotionEffect(effect, 300, 0, false, false)); + if (ModConfig.infinityArmor.infinityArmorNoClip && !player.isSpectator()) { + if (ModUtils.isArmorValid(player, EntityEquipmentSlot.CHEST) && AvaritiaEventHandler.isInfinite(player) && noClip) { + player.capabilities.isFlying = true; + player.noClip = true; + } + if (!AvaritiaEventHandler.isInfinite(player) && !noClip) { + player.noClip = false; + } + if (noClip && !player.capabilities.isFlying) { + player.capabilities.isFlying = true; + } } } } public static void toggleNoClip(EntityPlayer player) { - if (isArmorValid(player, EntityEquipmentSlot.CHEST)) { + if (ModUtils.isArmorValid(player, EntityEquipmentSlot.CHEST)) { if (MAP.containsKey(player) && MAP.get(player)) { MAP.remove(player); noClip = false; @@ -134,7 +119,7 @@ public void onTooltip(ItemTooltipEvent event) { if (item instanceof ItemSwordInfinity && ModConfig.tweaks.fixInfinitySwordTooltip) { for (int x = 0; x < tooltip.size(); x++) { if (tooltip.get(x).contains(I18n.format("attribute.name.generic.attackDamage"))) { - tooltip.set(x, " " + TextUtils.makeFabulous(I18n.format("tip.infinity")) + " " + tooltip.set(x, " " + TextUtils.makeFabulous(I18n.format("tooltips.avaritiatweaks.infinite")) + " " + TextFormatting.GRAY + I18n.format("attribute.name.generic.attackDamage")); return; } diff --git a/src/main/java/jackyy/avaritiatweaks/util/ModUtils.java b/src/main/java/jackyy/avaritiatweaks/util/ModUtils.java index f85c3b6..d5545ef 100644 --- a/src/main/java/jackyy/avaritiatweaks/util/ModUtils.java +++ b/src/main/java/jackyy/avaritiatweaks/util/ModUtils.java @@ -2,38 +2,24 @@ import jackyy.avaritiatweaks.AvaritiaTweaks; import jackyy.avaritiatweaks.tweaks.ModTweaks; +import jackyy.gunpowderlib.helper.ObjectHelper; +import morph.avaritia.item.ItemArmorInfinity; import net.minecraft.enchantment.Enchantment; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Enchantments; -import net.minecraft.init.SoundEvents; -import net.minecraft.item.Item; +import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundEvent; import net.minecraftforge.fml.common.registry.GameRegistry; public class ModUtils { - public static ItemStack getStackFromName(String name, int amount, int meta) { - Item item = Item.REGISTRY.getObject(new ResourceLocation(name)); - ItemStack stack = ItemStack.EMPTY; - if (item != null) { - stack = new ItemStack(item, amount, meta); - } - return stack; - } - - public static SoundEvent getSoundFromName(String name) { - SoundEvent sound = SoundEvent.REGISTRY.getObject(new ResourceLocation(name)); - if (sound != null) { - return sound; - } - return SoundEvents.BLOCK_ANVIL_PLACE; - } - public static ItemStack getFlower(String type) { - ItemStack flower = getStackFromName("botania:specialflower", 1, 0); + ItemStack flower = ObjectHelper.getItemStackByName("botania:specialflower", 1, 0); NBTTagCompound tag = new NBTTagCompound(); tag.setString("type", type); flower.setTagCompound(tag); @@ -77,4 +63,19 @@ public static void addEnhancementToolsRecipe(String name, ItemStack input, ItemS GameRegistry.addShapelessRecipe(new ResourceLocation(AvaritiaTweaks.MODID, name + "_remove"), null, input, Ingredient.fromStacks(output)); } + public static boolean isArmorValid(EntityPlayer player, EntityEquipmentSlot slot) { + ItemStack armor = player.getItemStackFromSlot(slot); + return armor != ItemStack.EMPTY && armor.getItem() instanceof ItemArmorInfinity + && armor.getTagCompound() != null && armor.getTagCompound().getInteger("enhanced") == 1; + } + + public static void checkAndAddEffect(EntityPlayer player, String[] potions) { + for (String potion : potions) { + Potion effect = Potion.getPotionFromResourceLocation(potion); + if (effect != null) { + player.addPotionEffect(new PotionEffect(effect, 300, 0, false, false)); + } + } + } + } diff --git a/src/main/resources/assets/avaritiatweaks/lang/en_US.lang b/src/main/resources/assets/avaritiatweaks/lang/en_US.lang index fd887fc..820b335 100644 --- a/src/main/resources/assets/avaritiatweaks/lang/en_US.lang +++ b/src/main/resources/assets/avaritiatweaks/lang/en_US.lang @@ -16,6 +16,7 @@ tile.avaritiatweaks.gaia_block.name=Gaia Block tooltips.avaritiatweaks.enhancement_crystal=Infinity isn't even enough. tooltips.avaritiatweaks.noclip.enabled=No Clip Mode: §a§lEnabled§r tooltips.avaritiatweaks.noclip.disabled=No Clip Mode: §c§lDisabled§r +tooltips.avaritiatweaks.infinite=Infinite #Messages msg.avaritiatweaks.noclip.enabled=No Clip Mode is now §aEnabled§r diff --git a/src/main/resources/assets/avaritiatweaks/lang/zh_CN.lang b/src/main/resources/assets/avaritiatweaks/lang/zh_CN.lang index 4c161e0..a515c68 100644 --- a/src/main/resources/assets/avaritiatweaks/lang/zh_CN.lang +++ b/src/main/resources/assets/avaritiatweaks/lang/zh_CN.lang @@ -16,6 +16,7 @@ tile.avaritiatweaks.gaia_block.name=盖亚块 tooltips.avaritiatweaks.enhancement_crystal=无尽或许还不够贪婪 tooltips.avaritiatweaks.noclip.enabled=观察者模式:§a§l启用§r tooltips.avaritiatweaks.noclip.disabled=观察者模式:§c§l禁用§r +tooltips.avaritiatweaks.infinite=无限 #Messages msg.avaritiatweaks.noclip.enabled=观察者模式已经§a启用§r diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index af7b9e5..0a3e5c5 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -3,7 +3,7 @@ "modid": "avaritiatweaks", "name": "Avaritia Tweaks", "description": "Enhances Avaritia to another level!", - "version": "1.12.2-1.1", + "version": "1.12.2-1.2", "mcversion": "1.12.2", "url": "https://github.com/JackyyTV/AvaritiaTweaks", "updateUrl": "",