Code Cleanup
This commit is contained in:
parent
18a4f12ea5
commit
f1e65f65d8
10 changed files with 51 additions and 33 deletions
|
|
@ -5,13 +5,15 @@ import com.oitsjustjose.tinkers_addons.lib.Lib;
|
|||
import com.oitsjustjose.tinkers_addons.lib.LibItems;
|
||||
import com.oitsjustjose.tinkers_addons.lib.LibModifiers;
|
||||
import com.oitsjustjose.tinkers_addons.util.ClientRegistry;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.Mod.Instance;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
|
||||
@Mod(modid = Lib.MODID, name = Lib.NAME, version = Lib.VERSION, guiFactory = Lib.GUI_FACTORY, dependencies = "required-after:tconstruct@[1.12-2.7.3.30,);" + "required-after:mantle@[1.12-1.3.1.21,)")
|
||||
@Mod(modid = Lib.MODID, name = Lib.NAME, version = Lib.VERSION, guiFactory = Lib.GUI_FACTORY, dependencies = "required-after:tconstruct@[1.12-2.7.3.30,);"
|
||||
+ "required-after:mantle@[1.12-1.3.1.21,)")
|
||||
public class TinkersAddons
|
||||
{
|
||||
@Instance(Lib.MODID)
|
||||
|
|
@ -32,5 +34,4 @@ public class TinkersAddons
|
|||
modItems = new LibItems();
|
||||
modModifiers = new LibModifiers();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,7 +1,10 @@
|
|||
package com.oitsjustjose.tinkers_addons.gui;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.oitsjustjose.tinkers_addons.TinkersAddons;
|
||||
import com.oitsjustjose.tinkers_addons.lib.Lib;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.common.config.ConfigElement;
|
||||
|
|
@ -9,16 +12,16 @@ import net.minecraftforge.common.config.Configuration;
|
|||
import net.minecraftforge.fml.client.IModGuiFactory;
|
||||
import net.minecraftforge.fml.client.config.GuiConfig;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class ConfigGUI extends GuiConfig
|
||||
{
|
||||
public ConfigGUI(GuiScreen guiScreen)
|
||||
{
|
||||
super(guiScreen, new ConfigElement(TinkersAddons.modConfig.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), Lib.MODID, false, true, GuiConfig.getAbridgedConfigPath(TinkersAddons.modConfig.config.toString()));
|
||||
super(guiScreen,
|
||||
new ConfigElement(TinkersAddons.modConfig.config.getCategory(Configuration.CATEGORY_GENERAL))
|
||||
.getChildElements(),
|
||||
Lib.MODID, false, true, GuiConfig.getAbridgedConfigPath(TinkersAddons.modConfig.config.toString()));
|
||||
}
|
||||
|
||||
|
||||
public static class GUIFactory implements IModGuiFactory
|
||||
{
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,7 +1,12 @@
|
|||
package com.oitsjustjose.tinkers_addons.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.oitsjustjose.tinkers_addons.TinkersAddons;
|
||||
import com.oitsjustjose.tinkers_addons.lib.Lib;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
|
|
@ -16,9 +21,6 @@ import net.minecraftforge.fml.relauncher.Side;
|
|||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import slimeknights.tconstruct.library.TinkerRegistry;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ItemModifier extends Item
|
||||
{
|
||||
|
|
@ -36,7 +38,8 @@ public class ItemModifier extends Item
|
|||
{
|
||||
for (int i = 0; i < EnumType.values().length; i++)
|
||||
{
|
||||
TinkersAddons.clientRegistry.register(new ItemStack(this, 1, i), new ResourceLocation(Lib.MODID, EnumType.byMetadata(i).getName()), "inventory");
|
||||
TinkersAddons.clientRegistry.register(new ItemStack(this, 1, i),
|
||||
new ResourceLocation(Lib.MODID, EnumType.byMetadata(i).getName()), "inventory");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -69,16 +72,14 @@ public class ItemModifier extends Item
|
|||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn)
|
||||
{
|
||||
tooltip.add(I18n.translateToLocal(Lib.MODID + "." + EnumType.byMetadata(stack.getItemDamage()) + ".description"));
|
||||
tooltip.add(
|
||||
I18n.translateToLocal(Lib.MODID + "." + EnumType.byMetadata(stack.getItemDamage()) + ".description"));
|
||||
}
|
||||
|
||||
public enum EnumType implements IStringSerializable
|
||||
{
|
||||
AMELIORATION_TOME(0, "amelioration_tome"),
|
||||
IRON_TOOLKIT(1, "iron_toolkit"),
|
||||
GOLD_TOOLKIT(2, "gold_toolkit"),
|
||||
DIAMOND_TOOLKIT(3, "diamond_toolkit"),
|
||||
ENDER_TOOLKIT(4, "ender_toolkit");
|
||||
AMELIORATION_TOME(0, "amelioration_tome"), IRON_TOOLKIT(1, "iron_toolkit"), GOLD_TOOLKIT(2, "gold_toolkit"),
|
||||
DIAMOND_TOOLKIT(3, "diamond_toolkit"), ENDER_TOOLKIT(4, "ender_toolkit");
|
||||
|
||||
private static final EnumType[] META_LOOKUP = new EnumType[values().length];
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package com.oitsjustjose.tinkers_addons.lib;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Config
|
||||
{
|
||||
public Configuration config;
|
||||
|
|
@ -27,23 +27,28 @@ public class Config
|
|||
{
|
||||
Property property;
|
||||
|
||||
property = config.get(Configuration.CATEGORY_GENERAL, "Enable Amelioration Kit mod for tools", true).setRequiresMcRestart(true);
|
||||
property = config.get(Configuration.CATEGORY_GENERAL, "Enable Amelioration Kit mod for tools", true)
|
||||
.setRequiresMcRestart(true);
|
||||
property.setComment("Amelioration Kits are the method of getting Pre-TiCon 2 auto-repair");
|
||||
enableAmelioration = property.getBoolean();
|
||||
|
||||
property = config.get(Configuration.CATEGORY_GENERAL, "Enable 1st bonus modifier mod for tools", true).setRequiresMcRestart(true);
|
||||
property = config.get(Configuration.CATEGORY_GENERAL, "Enable 1st bonus modifier mod for tools", true)
|
||||
.setRequiresMcRestart(true);
|
||||
property.setComment("Re-adds the diamond + gold block recipe to increase modifiers on a tool if enabled");
|
||||
enableExtraModifierLvl1 = property.getBoolean();
|
||||
|
||||
property = config.get(Configuration.CATEGORY_GENERAL, "Enable 2nd bonus modifier mod for tools", true).setRequiresMcRestart(true);
|
||||
property = config.get(Configuration.CATEGORY_GENERAL, "Enable 2nd bonus modifier mod for tools", true)
|
||||
.setRequiresMcRestart(true);
|
||||
property.setComment("Re-adds the diamond block + gold apple recipe to increase modifiers on a tool if enabled");
|
||||
enableExtraModifierLvl2 = property.getBoolean();
|
||||
|
||||
property = config.get(Configuration.CATEGORY_GENERAL, "Enable 3rd bonus modifier mod for tools", true).setRequiresMcRestart(true);
|
||||
property = config.get(Configuration.CATEGORY_GENERAL, "Enable 3rd bonus modifier mod for tools", true)
|
||||
.setRequiresMcRestart(true);
|
||||
property.setComment("Re-adds the nether star recipe to increase modifiers on a tool if enabled");
|
||||
enableExtraModifierLvl3 = property.getBoolean();
|
||||
|
||||
property = config.get(Configuration.CATEGORY_GENERAL, "Enable 4th bonus modifier mod for tools", true).setRequiresMcRestart(true);
|
||||
property = config.get(Configuration.CATEGORY_GENERAL, "Enable 4th bonus modifier mod for tools", true)
|
||||
.setRequiresMcRestart(true);
|
||||
property.setComment("Adds a new Dragon Egg based Bonus Modifier if enabled");
|
||||
enableExtraModifierLvl4 = property.getBoolean();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.oitsjustjose.tinkers_addons.lib;
|
||||
|
||||
import com.oitsjustjose.tinkers_addons.items.ItemModifier;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class LibItems
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.oitsjustjose.tinkers_addons.lib;
|
|||
import com.oitsjustjose.tinkers_addons.TinkersAddons;
|
||||
import com.oitsjustjose.tinkers_addons.modifiers.ModAutoRepair;
|
||||
import com.oitsjustjose.tinkers_addons.modifiers.ModExtraModifier;
|
||||
|
||||
import slimeknights.tconstruct.library.modifiers.Modifier;
|
||||
|
||||
public class LibModifiers
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
package com.oitsjustjose.tinkers_addons.modifiers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.oitsjustjose.tinkers_addons.TinkersAddons;
|
||||
import com.oitsjustjose.tinkers_addons.lib.Lib;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
|
@ -17,14 +20,13 @@ import slimeknights.tconstruct.library.tools.ToolCore;
|
|||
import slimeknights.tconstruct.library.utils.TagUtil;
|
||||
import slimeknights.tconstruct.library.utils.ToolHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ModAutoRepair extends Modifier
|
||||
{
|
||||
public ModAutoRepair()
|
||||
{
|
||||
super("auto-repair");
|
||||
this.addAspects(new ModifierAspect.LevelAspect(this, 5), new ModifierAspect.DataAspect(this, 0x2CA401), ModifierAspect.freeModifier);
|
||||
this.addAspects(new ModifierAspect.LevelAspect(this, 5), new ModifierAspect.DataAspect(this, 0x2CA401),
|
||||
ModifierAspect.freeModifier);
|
||||
this.addItem(new ItemStack(TinkersAddons.modItems.MODIFIERS, 1, 0), 1, 1);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
|
@ -65,7 +67,7 @@ public class ModAutoRepair extends Modifier
|
|||
{
|
||||
tinkersTools.add(player.getHeldItemOffhand());
|
||||
}
|
||||
|
||||
|
||||
for (ItemStack iterStack : tinkersTools)
|
||||
{
|
||||
autoRepairLevel = 0;
|
||||
|
|
@ -85,7 +87,8 @@ public class ModAutoRepair extends Modifier
|
|||
|
||||
long lastRepairTime = tag.getLong(Lib.TAG_AUTO_REPAIR_COOLDOWN);
|
||||
|
||||
if (autoRepairLevel > 0 && (System.currentTimeMillis() - lastRepairTime) >= (getRepairCooldown(player)) && !player.isSwingInProgress)
|
||||
if (autoRepairLevel > 0 && (System.currentTimeMillis() - lastRepairTime) >= (getRepairCooldown(player))
|
||||
&& !player.isSwingInProgress)
|
||||
{
|
||||
ToolHelper.healTool(iterStack, autoRepairLevel, player);
|
||||
tag.setLong(Lib.TAG_AUTO_REPAIR_COOLDOWN, System.currentTimeMillis());
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.oitsjustjose.tinkers_addons.modifiers;
|
||||
|
||||
import com.oitsjustjose.tinkers_addons.TinkersAddons;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import slimeknights.tconstruct.library.modifiers.Modifier;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.oitsjustjose.tinkers_addons.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
|
@ -10,12 +13,9 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ClientRegistry
|
||||
{
|
||||
private HashMap<ItemStack, ModelResourceLocation> LOCATIONS = new HashMap();
|
||||
private HashMap<ItemStack, ModelResourceLocation> LOCATIONS = new HashMap<>();
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
|
@ -23,7 +23,8 @@ public class ClientRegistry
|
|||
{
|
||||
for (Map.Entry<ItemStack, ModelResourceLocation> entry : LOCATIONS.entrySet())
|
||||
{
|
||||
ModelLoader.setCustomModelResourceLocation(entry.getKey().getItem(), entry.getKey().getItemDamage(), entry.getValue());
|
||||
ModelLoader.setCustomModelResourceLocation(entry.getKey().getItem(), entry.getKey().getItemDamage(),
|
||||
entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.oitsjustjose.tinkers_addons.util;
|
||||
|
||||
import com.oitsjustjose.tinkers_addons.lib.Lib;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue