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.init.Items;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
|
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.PostManager;
|
|
|
|
|
import forestry.api.recipes.RecipeManagers;
|
2015-11-18 16:55:42 -08:00
|
|
|
import forestry.apiculture.items.ItemRegistryApiculture;
|
2015-11-08 19:24:46 -08:00
|
|
|
import forestry.core.GuiHandlerBase;
|
2015-09-25 15:06:43 -07:00
|
|
|
import forestry.core.ISaveEventHandler;
|
2015-11-17 22:28:46 -08:00
|
|
|
import forestry.core.circuits.EnumCircuitBoardType;
|
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-12-13 18:58:49 -08:00
|
|
|
import forestry.core.fluids.Fluids;
|
2015-11-17 22:28:46 -08:00
|
|
|
import forestry.core.items.EnumElectronTube;
|
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.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;
|
2015-11-18 21:52:44 -08:00
|
|
|
import forestry.mail.blocks.BlockMailType;
|
|
|
|
|
import forestry.mail.blocks.BlockRegistryMail;
|
2014-11-13 04:25:10 -08:00
|
|
|
import forestry.mail.commands.CommandMail;
|
2015-11-18 16:55:42 -08:00
|
|
|
import forestry.mail.items.EnumStampDefinition;
|
|
|
|
|
import forestry.mail.items.ItemRegistryMail;
|
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;
|
2015-11-18 21:52:44 -08:00
|
|
|
import forestry.mail.tiles.TileStampCollector;
|
2015-09-25 15:06:43 -07:00
|
|
|
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;
|
2015-11-18 21:52:44 -08:00
|
|
|
private static MachineDefinition definitionStampColletor;
|
2015-11-18 16:55:42 -08:00
|
|
|
|
|
|
|
|
public static ItemRegistryMail items;
|
2015-11-18 21:52:44 -08:00
|
|
|
public static BlockRegistryMail blocks;
|
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() {
|
2015-11-18 16:55:42 -08:00
|
|
|
items = new ItemRegistryMail();
|
2015-11-18 21:52:44 -08:00
|
|
|
blocks = new BlockRegistryMail();
|
2015-11-05 04:47:04 -08:00
|
|
|
}
|
|
|
|
|
|
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-11-18 21:52:44 -08:00
|
|
|
definitionMailbox = new MachineDefinition(BlockMailType.MAILBOX.ordinal(), "forestry.Mailbox", TileMailbox.class)
|
2015-11-18 21:05:25 -08:00
|
|
|
.setFaces(0, 1, 2, 2, 2, 2, 0, 7);
|
2015-11-18 21:52:44 -08:00
|
|
|
blocks.mail.addDefinition(definitionMailbox);
|
2014-08-18 05:20:29 -07:00
|
|
|
|
2015-11-18 21:52:44 -08:00
|
|
|
definitionTradestation = new MachineDefinition(BlockMailType.TRADE_STATION.ordinal(), "forestry.Tradestation", TileTrader.class)
|
2015-11-18 21:05:25 -08:00
|
|
|
.setFaces(0, 1, 2, 3, 4, 4, 0, 7);
|
2015-11-18 21:52:44 -08:00
|
|
|
blocks.mail.addDefinition(definitionTradestation);
|
2014-05-02 21:31:20 +02:00
|
|
|
|
2015-11-18 21:52:44 -08:00
|
|
|
definitionStampColletor = new MachineDefinition(BlockMailType.STAMP_COLLECTOR.ordinal(), "forestry.Philatelist", TileStampCollector.class)
|
2015-11-18 21:05:25 -08:00
|
|
|
.setFaces(0, 1, 2, 3, 2, 2, 0, 7);
|
2015-11-18 21:52:44 -08:00
|
|
|
blocks.mail.addDefinition(definitionStampColletor);
|
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();
|
2015-11-18 21:52:44 -08:00
|
|
|
definitionStampColletor.register();
|
2014-05-02 21:31:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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() {
|
2015-11-18 16:55:42 -08:00
|
|
|
Object stampGlue;
|
|
|
|
|
Object letterGlue;
|
2014-10-01 22:28:21 -07:00
|
|
|
|
2015-11-18 16:55:42 -08:00
|
|
|
ItemRegistryApiculture beeItems = PluginApiculture.items;
|
|
|
|
|
if (beeItems != null) {
|
|
|
|
|
stampGlue = beeItems.honeyDrop;
|
|
|
|
|
letterGlue = beeItems.propolis.getWildcard();
|
2014-10-01 22:28:21 -07:00
|
|
|
} else {
|
|
|
|
|
stampGlue = Items.slime_ball;
|
2015-11-18 16:55:42 -08:00
|
|
|
letterGlue = Items.slime_ball;
|
2014-10-01 22:28:21 -07:00
|
|
|
}
|
2014-05-02 21:31:20 +02:00
|
|
|
|
2015-11-18 16:55:42 -08:00
|
|
|
RecipeUtil.addShapelessRecipe(items.letters.getItemStack(), Items.paper, letterGlue);
|
|
|
|
|
|
2015-01-26 22:26:21 -08:00
|
|
|
if (Config.craftingStampsEnabled) {
|
2015-11-18 16:55:42 -08:00
|
|
|
for (EnumStampDefinition stampDefinition : EnumStampDefinition.VALUES) {
|
|
|
|
|
if (Config.collectorStamps.contains(stampDefinition.getName())) {
|
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-11-18 21:52:44 -08:00
|
|
|
ItemStack stamps = items.stamps.get(stampDefinition, 9);
|
|
|
|
|
|
|
|
|
|
RecipeUtil.addRecipe(stamps,
|
|
|
|
|
"XXX",
|
|
|
|
|
"###",
|
|
|
|
|
"ZZZ",
|
2015-11-18 16:55:42 -08:00
|
|
|
'X', stampDefinition.getCraftingIngredient(),
|
2014-10-01 22:28:21 -07:00
|
|
|
'#', Items.paper,
|
|
|
|
|
'Z', stampGlue);
|
2015-11-18 21:52:44 -08:00
|
|
|
RecipeManagers.carpenterManager.addRecipe(10, Fluids.SEEDOIL.getFluid(300), null, stamps,
|
|
|
|
|
"XXX",
|
|
|
|
|
"###",
|
2015-11-18 16:55:42 -08:00
|
|
|
'X', stampDefinition.getCraftingIngredient(),
|
2014-10-01 22:28:21 -07:00
|
|
|
'#', 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-11-18 21:52:44 -08:00
|
|
|
RecipeUtil.addRecipe(new ItemStack(Items.paper), "###", '#', items.letters.getWildcard());
|
2014-05-02 21:31:20 +02:00
|
|
|
|
|
|
|
|
// Carpenter
|
2015-11-18 16:55:42 -08:00
|
|
|
RecipeManagers.carpenterManager.addRecipe(10, Fluids.WATER.getFluid(250), null, items.letters.getItemStack(), "###", "###", '#', PluginCore.items.woodPulp);
|
2014-05-02 21:31:20 +02:00
|
|
|
|
2015-11-18 21:52:44 -08:00
|
|
|
RecipeUtil.addShapelessRecipe(items.catalogue.getItemStack(), items.stamps.getWildcard(), new ItemStack(Items.book));
|
2015-11-18 21:05:25 -08:00
|
|
|
|
2015-11-18 21:52:44 -08:00
|
|
|
RecipeUtil.addRecipe(blocks.mail.get(BlockMailType.MAILBOX),
|
2015-11-18 21:05:25 -08:00
|
|
|
" # ",
|
|
|
|
|
"#Y#",
|
|
|
|
|
"XXX",
|
|
|
|
|
'#', "ingotTin",
|
|
|
|
|
'X', "chestWood",
|
|
|
|
|
'Y', PluginCore.items.sturdyCasing);
|
|
|
|
|
|
2015-11-18 21:52:44 -08:00
|
|
|
RecipeUtil.addRecipe(blocks.mail.get(BlockMailType.TRADE_STATION),
|
2015-11-18 21:05:25 -08:00
|
|
|
"Z#Z",
|
|
|
|
|
"#Y#",
|
|
|
|
|
"XWX",
|
|
|
|
|
'#', PluginCore.items.tubes.get(EnumElectronTube.BRONZE, 1),
|
|
|
|
|
'X', "chestWood",
|
|
|
|
|
'Y', PluginCore.items.sturdyCasing,
|
|
|
|
|
'Z', PluginCore.items.tubes.get(EnumElectronTube.IRON, 1),
|
2015-11-18 21:52:44 -08:00
|
|
|
'W', PluginCore.items.circuitboards.get(EnumCircuitBoardType.REFINED));
|
2014-05-02 21:31:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ISaveEventHandler getSaveEventHandler() {
|
|
|
|
|
return new SaveEventHandlerMail();
|
|
|
|
|
}
|
|
|
|
|
}
|