2014-05-02 21:31:20 +02:00
|
|
|
/*******************************************************************************
|
2014-08-07 08:29:25 +02:00
|
|
|
* Copyright (c) 2011-2014 SirSengir.
|
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
|
* are made available under the terms of the GNU Lesser Public License v3
|
|
|
|
|
* which accompanies this distribution, and is available at
|
2014-08-07 02:56:58 -07:00
|
|
|
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
2015-01-26 22:26:21 -08:00
|
|
|
*
|
2014-08-07 08:29:25 +02:00
|
|
|
* Various Contributors including, but not limited to:
|
|
|
|
|
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
2014-05-02 21:31:20 +02:00
|
|
|
******************************************************************************/
|
|
|
|
|
package forestry.plugins;
|
|
|
|
|
|
2014-12-18 00:29:19 -08:00
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
|
import net.minecraft.init.Items;
|
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
|
2015-09-26 16:05:05 -07:00
|
|
|
import net.minecraftforge.oredict.OreDictionary;
|
|
|
|
|
|
2015-11-05 04:47:04 -08:00
|
|
|
import cpw.mods.fml.common.FMLCommonHandler;
|
2014-12-18 00:29:19 -08:00
|
|
|
|
2014-12-13 01:42:52 -08:00
|
|
|
import forestry.api.mail.EnumAddressee;
|
2014-05-02 21:31:20 +02:00
|
|
|
import forestry.api.mail.EnumPostage;
|
|
|
|
|
import forestry.api.mail.PostManager;
|
|
|
|
|
import forestry.api.recipes.RecipeManagers;
|
2015-11-08 19:24:46 -08:00
|
|
|
import forestry.core.GuiHandlerBase;
|
2015-09-25 15:06:43 -07:00
|
|
|
import forestry.core.ISaveEventHandler;
|
|
|
|
|
import forestry.core.blocks.BlockBase;
|
2014-05-02 21:31:20 +02:00
|
|
|
import forestry.core.config.Config;
|
2015-09-25 15:06:43 -07:00
|
|
|
import forestry.core.config.Constants;
|
2014-05-02 21:31:20 +02:00
|
|
|
import forestry.core.config.ForestryBlock;
|
|
|
|
|
import forestry.core.config.ForestryItem;
|
2014-12-13 18:58:49 -08:00
|
|
|
import forestry.core.fluids.Fluids;
|
2015-09-25 15:06:43 -07:00
|
|
|
import forestry.core.items.ItemBlockForestry;
|
2015-11-05 04:47:04 -08:00
|
|
|
import forestry.core.items.ItemWithGui;
|
|
|
|
|
import forestry.core.network.GuiId;
|
2015-11-17 19:34:11 -08:00
|
|
|
import forestry.core.network.IPacketRegistry;
|
2015-10-17 12:25:13 -07:00
|
|
|
import forestry.core.recipes.RecipeUtil;
|
2015-09-25 15:06:43 -07:00
|
|
|
import forestry.core.recipes.ShapedRecipeCustom;
|
|
|
|
|
import forestry.core.tiles.MachineDefinition;
|
2014-05-02 21:31:20 +02:00
|
|
|
import forestry.mail.GuiHandlerMail;
|
|
|
|
|
import forestry.mail.PostRegistry;
|
|
|
|
|
import forestry.mail.PostalCarrier;
|
|
|
|
|
import forestry.mail.SaveEventHandlerMail;
|
|
|
|
|
import forestry.mail.TickHandlerMailClient;
|
2014-11-13 04:25:10 -08:00
|
|
|
import forestry.mail.commands.CommandMail;
|
2014-05-02 21:31:20 +02:00
|
|
|
import forestry.mail.items.ItemLetter;
|
|
|
|
|
import forestry.mail.items.ItemStamps;
|
|
|
|
|
import forestry.mail.items.ItemStamps.StampInfo;
|
2015-11-17 19:34:11 -08:00
|
|
|
import forestry.mail.network.PacketRegistryMail;
|
2015-09-25 15:06:43 -07:00
|
|
|
import forestry.mail.tiles.TileMailbox;
|
|
|
|
|
import forestry.mail.tiles.TilePhilatelist;
|
|
|
|
|
import forestry.mail.tiles.TileTrader;
|
2014-12-18 00:29:19 -08:00
|
|
|
import forestry.mail.triggers.MailTriggers;
|
2014-05-02 21:31:20 +02:00
|
|
|
|
2015-09-25 15:06:43 -07:00
|
|
|
@Plugin(pluginID = "Mail", name = "Mail", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.mail.description")
|
2014-09-20 22:43:13 -07:00
|
|
|
public class PluginMail extends ForestryPlugin {
|
2014-05-02 21:31:20 +02:00
|
|
|
|
2015-08-02 01:15:41 -07:00
|
|
|
private static MachineDefinition definitionMailbox;
|
|
|
|
|
private static MachineDefinition definitionTradestation;
|
|
|
|
|
private static MachineDefinition definitionPhilatelist;
|
|
|
|
|
private static StampInfo[] stampDefinitions;
|
2014-05-02 21:31:20 +02:00
|
|
|
|
2015-04-05 14:16:41 -07:00
|
|
|
@Override
|
|
|
|
|
protected void setupAPI() {
|
|
|
|
|
super.setupAPI();
|
|
|
|
|
|
|
|
|
|
PostManager.postRegistry = new PostRegistry();
|
|
|
|
|
PostManager.postRegistry.registerCarrier(new PostalCarrier(EnumAddressee.PLAYER));
|
|
|
|
|
PostManager.postRegistry.registerCarrier(new PostalCarrier(EnumAddressee.TRADER));
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-05 04:47:04 -08:00
|
|
|
@Override
|
|
|
|
|
protected void registerItemsAndBlocks() {
|
|
|
|
|
|
|
|
|
|
stampDefinitions = new StampInfo[]{
|
|
|
|
|
new StampInfo("1n", EnumPostage.P_1, ForestryItem.apatite, 0x4a8ca7, 0xffffff),
|
|
|
|
|
new StampInfo("2n", EnumPostage.P_2, "ingotCopper", 0xe8c814, 0xffffff),
|
|
|
|
|
new StampInfo("5n", EnumPostage.P_5, "ingotTin", 0x9c0707, 0xffffff),
|
|
|
|
|
new StampInfo("10n", EnumPostage.P_10, Items.gold_ingot, 0x7bd1b8, 0xffffff),
|
|
|
|
|
new StampInfo("20n", EnumPostage.P_20, Items.diamond, 0xff9031, 0xfff7dd),
|
|
|
|
|
new StampInfo("50n", EnumPostage.P_50, Items.emerald, 0x6431d7, 0xfff7dd),
|
|
|
|
|
new StampInfo("100n", EnumPostage.P_100, Items.nether_star, 0xd731ba, 0xfff7dd)}; //new StampInfo("200n", EnumPostage.P_200, Item.netherStar, 0xcd9831, 0xfff7dd)};
|
|
|
|
|
|
|
|
|
|
/* STAMPS */
|
|
|
|
|
ForestryItem.stamps.registerItem(new ItemStamps(stampDefinitions), "stamps");
|
|
|
|
|
|
|
|
|
|
/* LETTER */
|
|
|
|
|
ForestryItem.letters.registerItem(new ItemLetter(), "letters");
|
|
|
|
|
|
|
|
|
|
/* CATALOGUE */
|
|
|
|
|
Item itemCatalogue = new ItemWithGui(GuiId.CatalogueGUI).setMaxStackSize(1);
|
|
|
|
|
ForestryItem.catalogue.registerItem(itemCatalogue, "catalogue");
|
|
|
|
|
|
|
|
|
|
ForestryBlock.mail.registerBlock(new BlockBase(Material.iron), ItemBlockForestry.class, "mail");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 21:31:20 +02:00
|
|
|
@Override
|
|
|
|
|
public void preInit() {
|
|
|
|
|
super.preInit();
|
2014-11-13 04:25:10 -08:00
|
|
|
|
|
|
|
|
PluginCore.rootCommand.addChildCommand(new CommandMail());
|
2014-05-02 21:31:20 +02:00
|
|
|
|
2015-11-05 04:47:04 -08:00
|
|
|
if (Config.mailAlertEnabled) {
|
|
|
|
|
FMLCommonHandler.instance().bus().register(new TickHandlerMailClient());
|
|
|
|
|
}
|
2014-05-02 21:31:20 +02:00
|
|
|
|
2015-09-25 15:06:43 -07:00
|
|
|
ShapedRecipeCustom recipe = ShapedRecipeCustom.createShapedRecipe(ForestryBlock.mail.getItemStack(1, Constants.DEFINITION_MAILBOX_META),
|
2014-05-02 21:31:20 +02:00
|
|
|
" # ", "#Y#", "XXX",
|
|
|
|
|
'#', "ingotTin",
|
2015-08-21 02:01:41 -05:00
|
|
|
'X', "chestWood",
|
2014-05-02 21:31:20 +02:00
|
|
|
'Y', ForestryItem.sturdyCasing);
|
|
|
|
|
|
2014-08-18 05:20:29 -07:00
|
|
|
BlockBase mail = ((BlockBase) ForestryBlock.mail.block());
|
2014-05-02 21:31:20 +02:00
|
|
|
|
2015-09-25 15:06:43 -07:00
|
|
|
definitionMailbox = mail.addDefinition(new MachineDefinition(Constants.DEFINITION_MAILBOX_META, "forestry.Mailbox", TileMailbox.class, recipe).setFaces(0, 1, 2, 2, 2, 2, 0, 7));
|
2014-08-18 05:20:29 -07:00
|
|
|
|
|
|
|
|
recipe = ShapedRecipeCustom.createShapedRecipe(
|
2015-09-25 15:06:43 -07:00
|
|
|
ForestryBlock.mail.getItemStack(1, Constants.DEFINITION_TRADESTATION_META),
|
2014-08-18 05:20:29 -07:00
|
|
|
"Z#Z",
|
|
|
|
|
"#Y#",
|
|
|
|
|
"XWX",
|
2014-05-02 21:31:20 +02:00
|
|
|
'#', ForestryItem.tubes.getItemStack(1, 2),
|
2015-08-21 02:01:41 -05:00
|
|
|
'X', "chestWood",
|
2014-05-02 21:31:20 +02:00
|
|
|
'Y', ForestryItem.sturdyCasing,
|
|
|
|
|
'Z', ForestryItem.tubes.getItemStack(1, 3),
|
|
|
|
|
'W', ForestryItem.circuitboards.getItemStack(1, 2));
|
2015-09-25 15:06:43 -07:00
|
|
|
definitionTradestation = mail.addDefinition(new MachineDefinition(Constants.DEFINITION_TRADESTATION_META, "forestry.Tradestation", TileTrader.class, recipe).setFaces(0, 1, 2, 3, 4, 4, 0, 7));
|
2014-05-02 21:31:20 +02:00
|
|
|
|
2015-09-25 15:06:43 -07:00
|
|
|
definitionPhilatelist = mail.addDefinition(new MachineDefinition(Constants.DEFINITION_PHILATELIST_META, "forestry.Philatelist", TilePhilatelist.class)
|
2014-08-18 05:20:29 -07:00
|
|
|
.setFaces(0, 1, 2, 3, 2, 2, 0, 7));
|
2015-04-05 14:16:41 -07:00
|
|
|
}
|
2014-05-02 21:31:20 +02:00
|
|
|
|
2015-04-05 14:16:41 -07:00
|
|
|
@Override
|
|
|
|
|
protected void registerTriggers() {
|
|
|
|
|
MailTriggers.initialize();
|
2014-05-02 21:31:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void doInit() {
|
|
|
|
|
super.doInit();
|
|
|
|
|
|
|
|
|
|
definitionMailbox.register();
|
|
|
|
|
definitionTradestation.register();
|
|
|
|
|
definitionPhilatelist.register();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2015-11-08 19:24:46 -08:00
|
|
|
public GuiHandlerBase getGuiHandler() {
|
2014-05-02 21:31:20 +02:00
|
|
|
return new GuiHandlerMail();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2015-11-17 19:34:11 -08:00
|
|
|
public IPacketRegistry getPacketRegistry() {
|
|
|
|
|
return new PacketRegistryMail();
|
2014-05-02 21:31:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void registerRecipes() {
|
|
|
|
|
// Letters
|
2014-10-01 22:28:21 -07:00
|
|
|
|
|
|
|
|
Item stampGlue;
|
|
|
|
|
if (PluginManager.Module.APICULTURE.isEnabled()) {
|
2015-10-17 12:25:13 -07:00
|
|
|
RecipeUtil.addShapelessRecipe(ForestryItem.letters.getItemStack(), Items.paper, ForestryItem.propolis.getItemStack(1, OreDictionary.WILDCARD_VALUE));
|
2014-10-01 22:28:21 -07:00
|
|
|
stampGlue = ForestryItem.honeyDrop.item();
|
|
|
|
|
} else {
|
2015-10-17 12:25:13 -07:00
|
|
|
RecipeUtil.addShapelessRecipe(ForestryItem.letters.getItemStack(), Items.paper, Items.slime_ball);
|
2014-10-01 22:28:21 -07:00
|
|
|
stampGlue = Items.slime_ball;
|
|
|
|
|
}
|
2014-05-02 21:31:20 +02:00
|
|
|
|
2015-01-26 22:26:21 -08:00
|
|
|
if (Config.craftingStampsEnabled) {
|
2014-05-02 21:31:20 +02:00
|
|
|
for (int i = 0; i < stampDefinitions.length; i++) {
|
2015-01-26 22:26:21 -08:00
|
|
|
if (Config.collectorStamps.contains(stampDefinitions[i].name)) {
|
2014-05-02 21:31:20 +02:00
|
|
|
continue;
|
2015-01-26 22:26:21 -08:00
|
|
|
}
|
2014-05-02 21:31:20 +02:00
|
|
|
|
2015-10-17 12:25:13 -07:00
|
|
|
RecipeUtil.addRecipe(ForestryItem.stamps.getItemStack(9, i),
|
2014-10-01 22:28:21 -07:00
|
|
|
"XXX", "###", "ZZZ",
|
|
|
|
|
'X', stampDefinitions[i].getCraftingIngredient(),
|
|
|
|
|
'#', Items.paper,
|
|
|
|
|
'Z', stampGlue);
|
2014-12-24 00:43:22 -08:00
|
|
|
RecipeManagers.carpenterManager.addRecipe(10, Fluids.SEEDOIL.getFluid(300), null, ForestryItem.stamps.getItemStack(9, i),
|
2014-10-01 22:28:21 -07:00
|
|
|
"XXX", "###",
|
|
|
|
|
'X', stampDefinitions[i].getCraftingIngredient(),
|
|
|
|
|
'#', Items.paper);
|
2014-05-02 21:31:20 +02:00
|
|
|
}
|
2015-01-26 22:26:21 -08:00
|
|
|
}
|
2014-05-02 21:31:20 +02:00
|
|
|
|
|
|
|
|
// Recycling
|
2015-10-17 12:25:13 -07:00
|
|
|
RecipeUtil.addRecipe(new ItemStack(Items.paper), "###", '#', ForestryItem.letters.getItemStack(1, OreDictionary.WILDCARD_VALUE));
|
2014-05-02 21:31:20 +02:00
|
|
|
|
|
|
|
|
// Carpenter
|
2014-12-24 00:43:22 -08:00
|
|
|
RecipeManagers.carpenterManager.addRecipe(10, Fluids.WATER.getFluid(250), null, ForestryItem.letters.getItemStack(), "###", "###", '#', ForestryItem.woodPulp);
|
2014-05-02 21:31:20 +02:00
|
|
|
|
2015-10-17 12:25:13 -07:00
|
|
|
RecipeUtil.addShapelessRecipe(ForestryItem.catalogue.getItemStack(), ForestryItem.stamps.getItemStack(1, OreDictionary.WILDCARD_VALUE), new ItemStack(Items.book));
|
2014-05-02 21:31:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ISaveEventHandler getSaveEventHandler() {
|
|
|
|
|
return new SaveEventHandlerMail();
|
|
|
|
|
}
|
|
|
|
|
}
|