2014-09-24 14:32:58 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (c) 2012 cpw.
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the GNU Public License v3.0
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.gnu.org/licenses/gpl.html
|
2016-05-19 01:47:25 +02:00
|
|
|
* <p>
|
2014-09-24 14:32:58 +02:00
|
|
|
* Contributors:
|
2016-05-19 01:47:25 +02:00
|
|
|
* cpw - initial API and implementation
|
2014-09-24 14:32:58 +02:00
|
|
|
******************************************************************************/
|
|
|
|
package cpw.mods.ironchest;
|
|
|
|
|
2016-05-19 01:47:25 +02:00
|
|
|
import java.util.Properties;
|
|
|
|
|
2016-11-18 16:26:10 +01:00
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
2014-12-02 21:25:03 +01:00
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
2014-09-24 14:32:58 +02:00
|
|
|
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;
|
2016-11-18 16:26:10 +01:00
|
|
|
import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent;
|
|
|
|
import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent.MissingMapping;
|
2014-09-24 14:32:58 +02:00
|
|
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
|
|
|
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
2016-11-18 16:26:10 +01:00
|
|
|
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
2014-09-24 14:32:58 +02:00
|
|
|
import net.minecraftforge.fml.common.registry.GameRegistry;
|
|
|
|
|
2016-11-19 19:03:30 +01:00
|
|
|
@Mod(modid = IronChest.MOD_ID, name = "Iron Chests", dependencies = "required-after:forge@[13.19.0.2142,)", acceptedMinecraftVersions = "[1.11, 1.12)")
|
2015-05-27 23:17:59 +02:00
|
|
|
public class IronChest
|
2014-09-26 01:40:09 +02:00
|
|
|
{
|
2016-08-06 18:22:04 +02:00
|
|
|
public static final String MOD_ID = "ironchest";
|
2016-05-19 01:47:25 +02:00
|
|
|
|
|
|
|
@Instance(IronChest.MOD_ID)
|
|
|
|
public static IronChest instance;
|
|
|
|
|
2014-09-24 14:32:58 +02:00
|
|
|
@SidedProxy(clientSide = "cpw.mods.ironchest.client.ClientProxy", serverSide = "cpw.mods.ironchest.CommonProxy")
|
|
|
|
public static CommonProxy proxy;
|
|
|
|
|
2016-05-19 01:47:25 +02:00
|
|
|
public static BlockIronChest ironChestBlock;
|
2016-11-17 22:39:07 +01:00
|
|
|
|
2016-05-19 01:47:25 +02:00
|
|
|
public static ItemIronChest ironChestItemBlock;
|
2014-09-24 14:32:58 +02:00
|
|
|
|
2014-09-25 04:40:29 +02:00
|
|
|
@EventHandler
|
2016-05-19 01:47:25 +02:00
|
|
|
public void preInit(FMLPreInitializationEvent event)
|
2014-09-24 14:32:58 +02:00
|
|
|
{
|
2016-05-19 01:47:25 +02:00
|
|
|
Properties properties = event.getVersionProperties();
|
2016-04-21 20:29:22 +02:00
|
|
|
|
2016-05-19 01:47:25 +02:00
|
|
|
if (properties != null)
|
|
|
|
{
|
|
|
|
String major = properties.getProperty("IronChest.build.major.number");
|
|
|
|
String minor = properties.getProperty("IronChest.build.minor.number");
|
|
|
|
String rev = properties.getProperty("IronChest.build.revision.number");
|
|
|
|
String build = properties.getProperty("IronChest.build.number");
|
|
|
|
event.getModMetadata().version = String.format("%s.%s.%s build %s", major, minor, rev, build);
|
|
|
|
}
|
2016-04-21 20:29:22 +02:00
|
|
|
|
2016-05-19 01:47:25 +02:00
|
|
|
ChestChangerType.buildItems();
|
|
|
|
ironChestBlock = GameRegistry.register(new BlockIronChest());
|
|
|
|
ironChestItemBlock = GameRegistry.register(new ItemIronChest(ironChestBlock));
|
2015-05-27 23:17:59 +02:00
|
|
|
|
2016-05-19 01:47:25 +02:00
|
|
|
for (IronChestType typ : IronChestType.VALUES)
|
2014-09-24 14:32:58 +02:00
|
|
|
{
|
2016-11-17 22:39:07 +01:00
|
|
|
if (typ.clazz != null)
|
2016-11-18 16:28:27 +01:00
|
|
|
{
|
2016-11-17 22:39:07 +01:00
|
|
|
GameRegistry.registerTileEntity(typ.clazz, "IronChest." + typ.name());
|
2016-11-18 16:28:27 +01:00
|
|
|
}
|
2014-09-24 14:32:58 +02:00
|
|
|
}
|
2016-05-19 01:47:25 +02:00
|
|
|
|
2014-09-26 02:03:18 +02:00
|
|
|
IronChestType.registerBlocksAndRecipes(ironChestBlock);
|
|
|
|
ChestChangerType.generateRecipes();
|
2014-09-24 14:32:58 +02:00
|
|
|
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
|
|
|
|
proxy.registerRenderInformation();
|
2016-06-12 04:36:20 +02:00
|
|
|
MinecraftForge.EVENT_BUS.register(new OcelotsSitOnChestsHandler());
|
2014-09-25 04:40:29 +02:00
|
|
|
}
|
2016-11-18 16:26:10 +01:00
|
|
|
|
2017-03-05 18:55:00 +01:00
|
|
|
@EventHandler
|
2016-11-18 16:26:10 +01:00
|
|
|
public void onMissingMappings(FMLMissingMappingsEvent event)
|
|
|
|
{
|
|
|
|
for (MissingMapping mapping : event.get())
|
|
|
|
{
|
|
|
|
if (mapping.resourceLocation.getResourceDomain().equals(IronChest.MOD_ID))
|
|
|
|
{
|
|
|
|
@Nonnull
|
|
|
|
String path = mapping.resourceLocation.getResourcePath();
|
|
|
|
|
|
|
|
if (path.endsWith("blockironchest"))
|
|
|
|
{
|
|
|
|
path = path.replace("blockironchest", "iron_chest");
|
|
|
|
ResourceLocation newRes = new ResourceLocation(mapping.resourceLocation.getResourceDomain(), path);
|
|
|
|
Block block = ForgeRegistries.BLOCKS.getValue(newRes);
|
|
|
|
|
|
|
|
if (block != null)
|
|
|
|
{
|
|
|
|
if (mapping.type == GameRegistry.Type.BLOCK)
|
|
|
|
{
|
|
|
|
mapping.remap(block);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mapping.remap(Item.getItemFromBlock(block));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (path.endsWith("irongoldupgrade"))
|
|
|
|
{
|
|
|
|
path = path.replace("irongoldupgrade", "iron_gold_upgrade");
|
|
|
|
replaceUpgradeItem(path, mapping);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (path.endsWith("golddiamondupgrade"))
|
|
|
|
{
|
|
|
|
path = path.replace("golddiamondupgrade", "gold_diamond_upgrade");
|
|
|
|
replaceUpgradeItem(path, mapping);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (path.endsWith("coppersilverupgrade"))
|
|
|
|
{
|
|
|
|
path = path.replace("coppersilverupgrade", "copper_silver_upgrade");
|
|
|
|
replaceUpgradeItem(path, mapping);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (path.endsWith("silvergoldupgrade"))
|
|
|
|
{
|
|
|
|
path = path.replace("silvergoldupgrade", "silver_gold_upgrade");
|
|
|
|
replaceUpgradeItem(path, mapping);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (path.endsWith("copperironupgrade"))
|
|
|
|
{
|
|
|
|
path = path.replace("copperironupgrade", "copper_iron_upgrade");
|
|
|
|
replaceUpgradeItem(path, mapping);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (path.endsWith("diamondcrystalupgrade"))
|
|
|
|
{
|
|
|
|
path = path.replace("diamondcrystalupgrade", "diamond_crystal_upgrade");
|
|
|
|
replaceUpgradeItem(path, mapping);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (path.endsWith("woodironupgrade"))
|
|
|
|
{
|
|
|
|
path = path.replace("woodironupgrade", "wood_iron_upgrade");
|
|
|
|
replaceUpgradeItem(path, mapping);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (path.endsWith("woodcopperupgrade"))
|
|
|
|
{
|
|
|
|
path = path.replace("woodcopperupgrade", "wood_copper_upgrade");
|
|
|
|
replaceUpgradeItem(path, mapping);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (path.endsWith("diamondobsidianupgrade"))
|
|
|
|
{
|
|
|
|
path = path.replace("diamondobsidianupgrade", "diamond_obsidian_upgrade");
|
|
|
|
replaceUpgradeItem(path, mapping);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void replaceUpgradeItem(String path, MissingMapping mapping)
|
|
|
|
{
|
|
|
|
ResourceLocation newRes = new ResourceLocation(mapping.resourceLocation.getResourceDomain(), path);
|
|
|
|
Item item = ForgeRegistries.ITEMS.getValue(newRes);
|
|
|
|
|
|
|
|
if (item != null)
|
|
|
|
{
|
|
|
|
mapping.remap(item);
|
|
|
|
}
|
|
|
|
}
|
2014-09-24 14:32:58 +02:00
|
|
|
}
|