LOOOONG night, but it compiles and technically works.
This commit is contained in:
parent
b69a965060
commit
65b5237a38
13 changed files with 410 additions and 0 deletions
|
|
@ -0,0 +1,60 @@
|
|||
package com.oitsjustjose.tinkers_addons;
|
||||
|
||||
import com.oitsjustjose.tinkers_addons.items.ItemModMaterial;
|
||||
import com.oitsjustjose.tinkers_addons.lib.Config;
|
||||
import com.oitsjustjose.tinkers_addons.lib.Lib;
|
||||
import com.oitsjustjose.tinkers_addons.modifiers.ModAutoRepair;
|
||||
import com.oitsjustjose.tinkers_addons.util.ClientProxy;
|
||||
import com.oitsjustjose.tinkers_addons.util.CommonProxy;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
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.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import slimeknights.tconstruct.library.modifiers.Modifier;
|
||||
|
||||
@Mod(modid = Lib.MODID, name = Lib.NAME, version = Lib.VERSION, guiFactory = Lib.GUI_FACTORY, acceptedMinecraftVersions = "1.8.9", dependencies = "required-after:tconstruct@[1.8.9-2.2.1,);" + "required-after:mantle@[1.8.9-0.9.0,)")
|
||||
public class TinkersAddons
|
||||
{
|
||||
@Instance(Lib.MODID)
|
||||
public static TinkersAddons instance;
|
||||
|
||||
@SidedProxy(clientSide = Lib.CLIENT_PROXY, serverSide = Lib.COMMON_PROXY, modId = Lib.MODID)
|
||||
public static CommonProxy proxy;
|
||||
|
||||
public static Config modConfig;
|
||||
public static Item moss_ball;
|
||||
public static Modifier auto_repair;
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
CommonProxy.preInit();
|
||||
modConfig = new Config(event.getSuggestedConfigurationFile());
|
||||
MinecraftForge.EVENT_BUS.register(modConfig);
|
||||
MinecraftForge.EVENT_BUS.register(new ModAutoRepair());
|
||||
|
||||
moss_ball = new ItemModMaterial();
|
||||
auto_repair = new ModAutoRepair();
|
||||
auto_repair.addItem(moss_ball, 1, 1);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event)
|
||||
{
|
||||
if (event.getSide().isClient())
|
||||
ClientProxy.init();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.oitsjustjose.tinkers_addons.gui;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
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.fml.client.IModGuiFactory;
|
||||
import net.minecraftforge.fml.client.config.GuiConfig;
|
||||
import net.minecraftforge.fml.client.config.IConfigElement;
|
||||
|
||||
public class ConfigGUI extends GuiConfig
|
||||
{
|
||||
public ConfigGUI(GuiScreen guiScreen)
|
||||
{
|
||||
super(guiScreen, getConfigElements(), Lib.MODID, false, true, GuiConfig.getAbridgedConfigPath(TinkersAddons.modConfig.config.toString()));
|
||||
}
|
||||
|
||||
private static List<IConfigElement> getConfigElements()
|
||||
{
|
||||
List<IConfigElement> list = Lists.newArrayList();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static class GUIFactory implements IModGuiFactory
|
||||
{
|
||||
@Override
|
||||
public void initialize(Minecraft minecraftInstance)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiScreen> mainConfigGuiClass()
|
||||
{
|
||||
return ConfigGUI.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.oitsjustjose.tinkers_addons.items;
|
||||
|
||||
import com.oitsjustjose.tinkers_addons.lib.Lib;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import slimeknights.tconstruct.library.TinkerRegistry;
|
||||
|
||||
public class ItemModMaterial extends Item
|
||||
{
|
||||
public ItemModMaterial()
|
||||
{
|
||||
this.setUnlocalizedName(Lib.MODID + ".moss_ball");
|
||||
this.setCreativeTab(TinkerRegistry.tabParts);
|
||||
GameRegistry.registerItem(this, "moss_ball");
|
||||
Lib.add(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package com.oitsjustjose.tinkers_addons.lib;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class Config
|
||||
{
|
||||
public Configuration config;
|
||||
|
||||
public boolean enableAutoRepair;
|
||||
|
||||
public Config(File file)
|
||||
{
|
||||
config = new Configuration(file);
|
||||
initialize();
|
||||
}
|
||||
|
||||
void initialize()
|
||||
{
|
||||
Property property;
|
||||
|
||||
property = config.get(config.CATEGORY_GENERAL, "Enable Auto-Repair", true);
|
||||
property.comment = "Allows you to enable or disable the auto-repair trait";
|
||||
enableAutoRepair = property.getBoolean();
|
||||
|
||||
if (config.hasChanged())
|
||||
config.save();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event)
|
||||
{
|
||||
if (event.modID.equalsIgnoreCase(Lib.MODID))
|
||||
initialize();
|
||||
}
|
||||
}
|
||||
43
src/main/java/com/oitsjustjose/tinkers_addons/lib/Lib.java
Normal file
43
src/main/java/com/oitsjustjose/tinkers_addons/lib/Lib.java
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
package com.oitsjustjose.tinkers_addons.lib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class Lib
|
||||
{
|
||||
public static final String MODID = "TinkersAddons";
|
||||
public static final String NAME = "Tinkers' Addons";
|
||||
public static final String VERSION = "@VERSION@";
|
||||
public static final String CLIENT_PROXY = "com.oitsjustjose.tinkers_addons.util.ClientProxy";
|
||||
public static final String COMMON_PROXY = "com.oitsjustjose.tinkers_addons.util.CommonProxy";
|
||||
public static final String GUI_FACTORY = "com.oitsjustjose.tinkers_addons.gui.ConfigGUI$GUIFactory";
|
||||
|
||||
public static final String TAG_AUTO_REPAIR = "Auto-Repair";
|
||||
public static final String TAG_AUTO_REPAIR_COOLDOWN = "Last Auto-Repair";
|
||||
public static final String TAG_REDSTONE_FLUX = "Redstone Flux";
|
||||
|
||||
private static final ArrayList<Item> allItems = new ArrayList<Item>();
|
||||
private static final ArrayList<Block> allBlocks = new ArrayList<Block>();
|
||||
|
||||
public static ArrayList<Item> getModItems()
|
||||
{
|
||||
return allItems;
|
||||
}
|
||||
|
||||
public static ArrayList<Block> getModBlocks()
|
||||
{
|
||||
return allBlocks;
|
||||
}
|
||||
|
||||
public static void add(Item item)
|
||||
{
|
||||
allItems.add(item);
|
||||
}
|
||||
|
||||
public static void add(Block block)
|
||||
{
|
||||
allBlocks.add(block);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
package com.oitsjustjose.tinkers_addons.modifiers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.oitsjustjose.tinkers_addons.lib.Lib;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import slimeknights.tconstruct.library.modifiers.Modifier;
|
||||
import slimeknights.tconstruct.library.modifiers.ModifierAspect;
|
||||
import slimeknights.tconstruct.library.tools.ToolCore;
|
||||
import slimeknights.tconstruct.library.tools.ToolNBT;
|
||||
import slimeknights.tconstruct.library.utils.TagUtil;
|
||||
import slimeknights.tconstruct.library.utils.ToolHelper;
|
||||
|
||||
public class ModAutoRepair extends Modifier
|
||||
{
|
||||
//TODO: actually keep track of auto-repair level now!
|
||||
public ModAutoRepair()
|
||||
{
|
||||
super("auto-repair");
|
||||
addAspects(new ModifierAspect.LevelAspect(this, 5), new ModifierAspect.DataAspect(this, 0x2CA401), ModifierAspect.freeModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip(NBTTagCompound modifierTag, boolean detailed)
|
||||
{
|
||||
return super.getTooltip(modifierTag, detailed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyEffect(NBTTagCompound rootCompound, NBTTagCompound modifierTag)
|
||||
{
|
||||
ToolNBT toolData = TagUtil.getOriginalToolStats(rootCompound);
|
||||
NBTTagCompound tag = TagUtil.getToolTag(rootCompound);
|
||||
int autoRepairLevel = toolData.get().getInteger(Lib.TAG_AUTO_REPAIR) + 1;
|
||||
tag.setInteger(Lib.TAG_AUTO_REPAIR, autoRepairLevel);
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||
public void onUpdate(PlayerEvent event)
|
||||
{
|
||||
if (event.entityPlayer == null)
|
||||
return;
|
||||
|
||||
EntityPlayer player = event.entityPlayer;
|
||||
ArrayList<ItemStack> tinkersTools = new ArrayList<ItemStack>();
|
||||
for (ItemStack iterStack : player.inventory.mainInventory)
|
||||
if (iterStack != null && iterStack.getItem() instanceof ToolCore)
|
||||
tinkersTools.add(iterStack);
|
||||
|
||||
for (ItemStack iterStack : tinkersTools)
|
||||
{
|
||||
NBTTagCompound tag = TagUtil.getToolTag(iterStack.getTagCompound());
|
||||
int autoRepairLevel = tag.getInteger(Lib.TAG_AUTO_REPAIR);
|
||||
long lastRepairTime = tag.getLong(Lib.TAG_AUTO_REPAIR_COOLDOWN);
|
||||
// Calculates that the last repair time stored minus the current time is less than or equal to 30 seconds divided by auto-repair level
|
||||
if ((System.currentTimeMillis() - lastRepairTime) >= (15000))
|
||||
{
|
||||
ToolHelper.healTool(iterStack, autoRepairLevel, event.entityPlayer);
|
||||
tag.setLong(Lib.TAG_AUTO_REPAIR_COOLDOWN, System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
package com.oitsjustjose.tinkers_addons.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.oitsjustjose.tinkers_addons.lib.Lib;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import slimeknights.tconstruct.library.TinkerRegistry;
|
||||
|
||||
public class ClientProxy extends CommonProxy
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void init()
|
||||
{
|
||||
ArrayList<Block> blocks = Lib.getModBlocks();
|
||||
ArrayList<Item> items = Lib.getModItems();
|
||||
|
||||
for (Block b : blocks)
|
||||
register(b, "");
|
||||
for (Item i : items)
|
||||
register(i, "");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static void register(Item item, String customName)
|
||||
{
|
||||
int meta = 0;
|
||||
|
||||
List<ItemStack> subItems = new ArrayList<ItemStack>();
|
||||
item.getSubItems(item, TinkerRegistry.tabParts, subItems);
|
||||
for (ItemStack sub : subItems)
|
||||
{
|
||||
String name = item.getUnlocalizedName(sub).substring(19).toLowerCase();
|
||||
ModelBakery.registerItemVariants(item, new ResourceLocation(Lib.MODID.toLowerCase(), name));
|
||||
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, meta, new ModelResourceLocation(Lib.MODID.toLowerCase() + ":" + name, "inventory"));
|
||||
meta++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static void register(Block block, String customName)
|
||||
{
|
||||
int meta = 0;
|
||||
Item itemBlock = Item.getItemFromBlock(block);
|
||||
if (itemBlock.getHasSubtypes())
|
||||
{
|
||||
List<ItemStack> subItems = new ArrayList<ItemStack>();
|
||||
itemBlock.getSubItems(itemBlock, TinkerRegistry.tabParts, subItems);
|
||||
for (ItemStack sub : subItems)
|
||||
{
|
||||
String name = itemBlock.getUnlocalizedName(sub).toLowerCase().replace("tinkersaddons.", "").replace("tile.", "");
|
||||
ModelBakery.registerItemVariants(itemBlock, new ResourceLocation(Lib.MODID.toLowerCase(), name));
|
||||
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(itemBlock, meta, new ModelResourceLocation(Lib.MODID.toLowerCase() + ":" + name, "inventory"));
|
||||
meta++;
|
||||
}
|
||||
}
|
||||
else if (customName == "")
|
||||
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(itemBlock, 0, new ModelResourceLocation(Lib.MODID.toLowerCase() + ":" + block.getUnlocalizedName().substring(19).toLowerCase(), "inventory"));
|
||||
else
|
||||
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(itemBlock, 0, new ModelResourceLocation(Lib.MODID.toLowerCase() + ":" + customName, "inventory"));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.oitsjustjose.tinkers_addons.util;
|
||||
|
||||
public class CommonProxy
|
||||
{
|
||||
public static void preInit()
|
||||
{
|
||||
};
|
||||
|
||||
public static void init()
|
||||
{
|
||||
};
|
||||
}
|
||||
6
src/main/resources/assets/tinkersaddons/lang/en_US.lang
Normal file
6
src/main/resources/assets/tinkersaddons/lang/en_US.lang
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#Items
|
||||
item.TinkersAddons.moss_ball.name=Moss Ball
|
||||
|
||||
#Modifiers
|
||||
modifier.auto-repair.name=Auto-Repair
|
||||
modifier.auto-repair.desc=§oFree repair...§r\n..You didn't realize you missed this, did you?
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"parent": "builtin/generated",
|
||||
"textures": {
|
||||
"layer0": "tinkersaddons:item/moss_ball"
|
||||
},
|
||||
"display": {
|
||||
"thirdperson": {
|
||||
"rotation": [ -90, 0, 0 ],
|
||||
"translation": [ 0, 1, -3 ],
|
||||
"scale": [ 0.55, 0.55, 0.55 ]
|
||||
},
|
||||
"firstperson": {
|
||||
"rotation": [ 0, -135, 25 ],
|
||||
"translation": [ 0, 4, 2 ],
|
||||
"scale": [ 1.7, 1.7, 1.7 ]
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
src/main/resources/assets/tinkersaddons/textures/item/Thumbs.db
Normal file
BIN
src/main/resources/assets/tinkersaddons/textures/item/Thumbs.db
Normal file
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 207 B |
16
src/main/resources/mcmod.info
Normal file
16
src/main/resources/mcmod.info
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
[
|
||||
{
|
||||
"modid": "TinkersAddons",
|
||||
"name": "Tinkers' Addons",
|
||||
"description": "Adding back old modifiers to Tinkers' Construct 2.0",
|
||||
"version": "${version}",
|
||||
"mcversion": "${mcversion}",
|
||||
"url": "",
|
||||
"updateUrl": "",
|
||||
"authorList": ["oitsjustjose"],
|
||||
"credits": "",
|
||||
"logoFile": "",
|
||||
"screenshots": [],
|
||||
"dependencies": []
|
||||
}
|
||||
]
|
||||
Loading…
Reference in a new issue