Scrapboxes work in dispensers (w/ config option)
This commit is contained in:
parent
c5302f8d6b
commit
02dd024e83
5 changed files with 150 additions and 112 deletions
|
@ -4,8 +4,7 @@ import java.io.File;
|
|||
|
||||
import org.apache.commons.lang3.time.StopWatch;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
@ -24,7 +23,6 @@ import reborncore.common.packets.AddDiscriminatorEvent;
|
|||
import reborncore.common.util.LogHelper;
|
||||
import reborncore.common.util.VersionChecker;
|
||||
import techreborn.achievement.TRAchievements;
|
||||
import techreborn.api.ScrapboxList;
|
||||
import techreborn.api.TechRebornAPI;
|
||||
import techreborn.api.recipe.RecipeHandler;
|
||||
import techreborn.api.recipe.recipeConfig.RecipeConfigManager;
|
||||
|
@ -33,19 +31,13 @@ import techreborn.command.TechRebornDevCommand;
|
|||
import techreborn.compat.CompatManager;
|
||||
import techreborn.compat.ICompatModule;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.dispenser.BehaviorDispenseScrapbox;
|
||||
import techreborn.events.OreUnifier;
|
||||
import techreborn.events.TRTickHandler;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.init.ModFluids;
|
||||
import techreborn.init.ModItems;
|
||||
import techreborn.init.ModLoot;
|
||||
import techreborn.init.ModParts;
|
||||
import techreborn.init.ModRecipes;
|
||||
import techreborn.init.RecipeCompact;
|
||||
import techreborn.init.*;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.packets.PacketAesu;
|
||||
import techreborn.packets.PacketIdsu;
|
||||
import techreborn.power.PowerTickEvent;
|
||||
import techreborn.proxies.CommonProxy;
|
||||
import techreborn.tiles.idsu.IDSUManager;
|
||||
import techreborn.world.TROreGen;
|
||||
|
@ -53,125 +45,126 @@ import techreborn.world.TreeGenerator;
|
|||
|
||||
@Mod(modid = ModInfo.MOD_ID, name = ModInfo.MOD_NAME, version = ModInfo.MOD_VERSION, dependencies = ModInfo.MOD_DEPENDENCUIES, guiFactory = ModInfo.GUI_FACTORY_CLASS, acceptedMinecraftVersions = "[1.8.8,1.8.9]")
|
||||
public class Core {
|
||||
public static ConfigTechReborn config;
|
||||
public static ConfigTechReborn config;
|
||||
|
||||
@SidedProxy(clientSide = ModInfo.CLIENT_PROXY_CLASS, serverSide = ModInfo.SERVER_PROXY_CLASS)
|
||||
public static CommonProxy proxy;
|
||||
@SidedProxy(clientSide = ModInfo.CLIENT_PROXY_CLASS, serverSide = ModInfo.SERVER_PROXY_CLASS)
|
||||
public static CommonProxy proxy;
|
||||
|
||||
@Mod.Instance
|
||||
public static Core INSTANCE;
|
||||
@Mod.Instance
|
||||
public static Core INSTANCE;
|
||||
|
||||
public VersionChecker versionChecker;
|
||||
public VersionChecker versionChecker;
|
||||
|
||||
public static LogHelper logHelper = new LogHelper(new ModInfo());
|
||||
public static LogHelper logHelper = new LogHelper(new ModInfo());
|
||||
|
||||
private static RecipeCompact recipeCompact;
|
||||
private static File configDir;
|
||||
private static RecipeCompact recipeCompact;
|
||||
private static File configDir;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preinit(FMLPreInitializationEvent event) {
|
||||
event.getModMetadata().version = ModInfo.MOD_VERSION;
|
||||
INSTANCE = this;
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
@Mod.EventHandler
|
||||
public void preinit(FMLPreInitializationEvent event) {
|
||||
event.getModMetadata().version = ModInfo.MOD_VERSION;
|
||||
INSTANCE = this;
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
String path = event.getSuggestedConfigurationFile().getAbsolutePath()
|
||||
.replace(ModInfo.MOD_ID, "TechReborn");
|
||||
String path = event.getSuggestedConfigurationFile().getAbsolutePath().replace(ModInfo.MOD_ID, "TechReborn");
|
||||
|
||||
config = ConfigTechReborn.initialize(new File(path));
|
||||
configDir = event.getModConfigurationDirectory();
|
||||
config = ConfigTechReborn.initialize(new File(path));
|
||||
configDir = event.getModConfigurationDirectory();
|
||||
|
||||
recipeCompact = new RecipeCompact();
|
||||
TechRebornAPI.recipeCompact = recipeCompact;
|
||||
recipeCompact = new RecipeCompact();
|
||||
TechRebornAPI.recipeCompact = recipeCompact;
|
||||
|
||||
for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) {
|
||||
compatModule.preInit(event);
|
||||
}
|
||||
for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) {
|
||||
compatModule.preInit(event);
|
||||
}
|
||||
|
||||
RecipeConfigManager.load(event.getModConfigurationDirectory());
|
||||
versionChecker = new VersionChecker("TechReborn", new ModInfo());
|
||||
versionChecker.checkVersionThreaded();
|
||||
RecipeConfigManager.load(event.getModConfigurationDirectory());
|
||||
versionChecker = new VersionChecker("TechReborn", new ModInfo());
|
||||
versionChecker.checkVersionThreaded();
|
||||
|
||||
logHelper.info("PreInitialization Complete");
|
||||
}
|
||||
logHelper.info("PreInitialization Complete");
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event) throws IllegalAccessException, InstantiationException {
|
||||
// Register ModBlocks
|
||||
ModBlocks.init();
|
||||
// Register Fluids
|
||||
ModFluids.init();
|
||||
// Register ModItems
|
||||
ModItems.init();
|
||||
// Registers Chest Loot
|
||||
ModLoot.init();
|
||||
//Multiparts
|
||||
ModParts.init();
|
||||
// Compat
|
||||
for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) {
|
||||
compatModule.init(event);
|
||||
}
|
||||
// Recipes
|
||||
StopWatch watch = new StopWatch();
|
||||
watch.start();
|
||||
ModRecipes.init();
|
||||
logHelper.all(watch + " : main recipes");
|
||||
watch.stop();
|
||||
//Client only init, needs to be done before parts system
|
||||
proxy.init();
|
||||
// WorldGen
|
||||
GameRegistry.registerWorldGenerator(new TROreGen(), 0);
|
||||
GameRegistry.registerWorldGenerator(new TreeGenerator(), 0);
|
||||
// DungeonLoot.init();
|
||||
// Register Gui Handler
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE, new GuiHandler());
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event) throws IllegalAccessException, InstantiationException {
|
||||
// Register ModBlocks
|
||||
ModBlocks.init();
|
||||
// Register Fluids
|
||||
ModFluids.init();
|
||||
// Register ModItems
|
||||
ModItems.init();
|
||||
// Registers Chest Loot
|
||||
ModLoot.init();
|
||||
// Multiparts
|
||||
ModParts.init();
|
||||
// Compat
|
||||
for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) {
|
||||
compatModule.init(event);
|
||||
}
|
||||
// Recipes
|
||||
StopWatch watch = new StopWatch();
|
||||
watch.start();
|
||||
ModRecipes.init();
|
||||
logHelper.all(watch + " : main recipes");
|
||||
watch.stop();
|
||||
// Client only init, needs to be done before parts system
|
||||
proxy.init();
|
||||
// WorldGen
|
||||
GameRegistry.registerWorldGenerator(new TROreGen(), 0);
|
||||
GameRegistry.registerWorldGenerator(new TreeGenerator(), 0);
|
||||
// DungeonLoot.init();
|
||||
// Register Gui Handler
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE, new GuiHandler());
|
||||
|
||||
// Achievements
|
||||
TRAchievements.init();
|
||||
// Multiblock events
|
||||
MinecraftForge.EVENT_BUS.register(new MultiblockEventHandler());
|
||||
// IDSU manager
|
||||
IDSUManager.INSTANCE = new IDSUManager();
|
||||
MinecraftForge.EVENT_BUS.register(IDSUManager.INSTANCE);
|
||||
MinecraftForge.EVENT_BUS.register(new MultiblockServerTickHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new TRTickHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new OreUnifier());
|
||||
logHelper.info("Initialization Complete");
|
||||
}
|
||||
// Achievements
|
||||
TRAchievements.init();
|
||||
// Multiblock events
|
||||
MinecraftForge.EVENT_BUS.register(new MultiblockEventHandler());
|
||||
// IDSU manager
|
||||
IDSUManager.INSTANCE = new IDSUManager();
|
||||
MinecraftForge.EVENT_BUS.register(IDSUManager.INSTANCE);
|
||||
MinecraftForge.EVENT_BUS.register(new MultiblockServerTickHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new TRTickHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new OreUnifier());
|
||||
if (config.scrapboxDispenser) {
|
||||
BlockDispenser.dispenseBehaviorRegistry.putObject(ModItems.scrapBox, new BehaviorDispenseScrapbox());
|
||||
}
|
||||
logHelper.info("Initialization Complete");
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postinit(FMLPostInitializationEvent event) throws Exception {
|
||||
// Has to be done here as Buildcraft registers their recipes late
|
||||
for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) {
|
||||
compatModule.postInit(event);
|
||||
}
|
||||
logHelper.info(RecipeHandler.recipeList.size() + " recipes loaded");
|
||||
@Mod.EventHandler
|
||||
public void postinit(FMLPostInitializationEvent event) throws Exception {
|
||||
// Has to be done here as Buildcraft registers their recipes late
|
||||
for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) {
|
||||
compatModule.postInit(event);
|
||||
}
|
||||
logHelper.info(RecipeHandler.recipeList.size() + " recipes loaded");
|
||||
|
||||
// RecipeHandler.scanForDupeRecipes();
|
||||
// RecipeHandler.scanForDupeRecipes();
|
||||
|
||||
//RecipeConfigManager.save();
|
||||
recipeCompact.saveMissingItems(configDir);
|
||||
}
|
||||
// RecipeConfigManager.save();
|
||||
recipeCompact.saveMissingItems(configDir);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void serverStarting(FMLServerStartingEvent event) {
|
||||
event.registerServerCommand(new TechRebornDevCommand());
|
||||
for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) {
|
||||
compatModule.serverStarting(event);
|
||||
}
|
||||
}
|
||||
@Mod.EventHandler
|
||||
public void serverStarting(FMLServerStartingEvent event) {
|
||||
event.registerServerCommand(new TechRebornDevCommand());
|
||||
for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) {
|
||||
compatModule.serverStarting(event);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent cfgChange) {
|
||||
if (cfgChange.modID.equals("TechReborn")) {
|
||||
ConfigTechReborn.Configs();
|
||||
}
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent cfgChange) {
|
||||
if (cfgChange.modID.equals("TechReborn")) {
|
||||
ConfigTechReborn.Configs();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void addDiscriminator(AddDiscriminatorEvent event) {
|
||||
event.getPacketHandler().addDiscriminator(event.getPacketHandler().nextDiscriminator, PacketAesu.class);
|
||||
event.getPacketHandler().addDiscriminator(event.getPacketHandler().nextDiscriminator, PacketIdsu.class);
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void addDiscriminator(AddDiscriminatorEvent event) {
|
||||
event.getPacketHandler().addDiscriminator(event.getPacketHandler().nextDiscriminator, PacketAesu.class);
|
||||
event.getPacketHandler().addDiscriminator(event.getPacketHandler().nextDiscriminator, PacketIdsu.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ import techreborn.compat.jei.scrapbox.ScrapboxRecipeCategory;
|
|||
import techreborn.compat.jei.scrapbox.ScrapboxRecipeHandler;
|
||||
import techreborn.compat.jei.vacuumFreezer.VacuumFreezerRecipeCategory;
|
||||
import techreborn.compat.jei.vacuumFreezer.VacuumFreezerRecipeHandler;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.init.ModItems;
|
||||
import techreborn.items.ItemParts;
|
||||
|
||||
@mezz.jei.api.JEIPlugin
|
||||
|
@ -120,6 +122,11 @@ public class TechRebornJeiPlugin extends BlankModPlugin {
|
|||
}
|
||||
|
||||
registry.addDescription(ItemParts.getPartByName("rubberSap"), StatCollector.translateToLocal("techreborn.desc.rubberSap"));
|
||||
if(!ConfigTechReborn.scrapboxDispenser){
|
||||
registry.addDescription(new ItemStack(ModItems.scrapBox), StatCollector.translateToLocal("techreborn.desc.scrapBoxNoDispenser"));
|
||||
} else {
|
||||
registry.addDescription(new ItemStack(ModItems.scrapBox), StatCollector.translateToLocal("techreborn.desc.scrapBox"));
|
||||
}
|
||||
|
||||
registry.addRecipeClickArea(GuiAlloyFurnace.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER, VanillaRecipeCategoryUid.FUEL);
|
||||
registry.addRecipeClickArea(GuiAlloySmelter.class, 80, 35, 26, 20, RecipeCategoryUids.ALLOY_SMELTER);
|
||||
|
|
|
@ -84,6 +84,8 @@ public class ConfigTechReborn {
|
|||
public static boolean UninsulatedElectocutionParticle;
|
||||
public static boolean UninsulatedElectocutionDamage;
|
||||
|
||||
public static boolean scrapboxDispenser;
|
||||
|
||||
// Power
|
||||
public static int ThermalGenertaorOutput;
|
||||
public static int CentrifugeInputTick;
|
||||
|
@ -692,6 +694,10 @@ public class ConfigTechReborn {
|
|||
.get(CATEGORY_WORLD, "Uninsulated Electocution Particle", true, "Spawn particles on contact with uninsulated cables")
|
||||
.getBoolean(true);
|
||||
|
||||
scrapboxDispenser = config
|
||||
.get(CATEGORY_WORLD, "Scrapboxes in Dispenser", true, "Allow scrapbox to be opened via dispenser")
|
||||
.getBoolean(true);
|
||||
|
||||
ExpensiveWatermill = config
|
||||
.get(CATEGORY_CRAFTING, "Expensive Watermill", true, "Allow TechReborn to change the Watermill recipe")
|
||||
.getBoolean(true);
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package techreborn.dispenser;
|
||||
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
||||
import net.minecraft.dispenser.IBlockSource;
|
||||
import net.minecraft.dispenser.IPosition;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import techreborn.api.ScrapboxList;
|
||||
import techreborn.init.ModItems;
|
||||
|
||||
public class BehaviorDispenseScrapbox extends BehaviorDefaultDispenseItem {
|
||||
|
||||
@Override
|
||||
protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
|
||||
int random = source.getWorld().rand.nextInt(ScrapboxList.stacks.size());
|
||||
ItemStack out = ScrapboxList.stacks.get(random).copy();
|
||||
float xOffset = source.getWorld().rand.nextFloat() * 0.8F + 0.1F;
|
||||
float yOffset = source.getWorld().rand.nextFloat() * 0.8F + 0.1F;
|
||||
float zOffset = source.getWorld().rand.nextFloat() * 0.8F + 0.1F;
|
||||
stack.splitStack(1);
|
||||
|
||||
EnumFacing enumfacing = BlockDispenser.getFacing(source.getBlockMetadata());
|
||||
IPosition iposition = BlockDispenser.getDispensePosition(source);
|
||||
doDispense(source.getWorld(), out, 6, enumfacing, iposition);
|
||||
return stack;
|
||||
}
|
||||
|
||||
}
|
|
@ -976,6 +976,8 @@ techreborn.jei.recipe.processing.time.1=Time: %s ticks
|
|||
techreborn.jei.recipe.processing.time.2=(%s seconds)
|
||||
jei.techreborn.scrapbox.name=Opening Scrapboxes
|
||||
techreborn.desc.rubberSap=In order to get sap, you need to find a rubber tree or obtain a rubber tree sapling and proceed to grow it. Once you have obtained a rubber tree, search around for little yellowish spots on the tree. If you don't see any, just wait a bit and eventually these yellow "sap" spots. To harvest the sap, use a treetap and use it on the log.
|
||||
techreborn.desc.scrapBox=Scrapboxes can be opened by either a simple use in hand, or by dispensers. That's right, just throw your scrapboxes into dispensers and give them a redstone signal, and boom! Random item!
|
||||
techreborn.desc.scrapBoxNoDispenser=Scrapboxes can be opened by a simple use in hand!
|
||||
|
||||
techreborn.jei.category.alloy.furnace=Alloy Furnace
|
||||
|
||||
|
|
Loading…
Reference in a new issue