Added more commands, updated botania to the (not yet released) api version we need, improved error logging, added lexicon recipe mapping functions, added more sanity checks.

This commit is contained in:
unknown 2015-01-21 15:15:42 -06:00
parent df85abd8c4
commit e97761fe30
8 changed files with 241 additions and 0 deletions

View file

@ -7,9 +7,12 @@ import minetweaker.api.minecraft.MineTweakerMC;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
import minetweaker.mc1710.MineTweakerMod;
import modtweaker.commands.MobMappingLogger;
import modtweaker.mods.botania.Botania;
import modtweaker.mods.botania.commands.BotaniaBrewLogger;
import modtweaker.mods.botania.lexicon.commands.LexiconCategoryLogger;
import modtweaker.mods.botania.lexicon.commands.LexiconEntryLogger;
import modtweaker.mods.botania.lexicon.commands.LexiconKnowledgeTypesLogger;
import modtweaker.mods.botania.lexicon.commands.LexiconPageLogger;
import modtweaker.mods.exnihilo.ExNihilo;
import modtweaker.mods.extendedworkbench.ExtendedWorkbench;
@ -86,6 +89,8 @@ public class ModTweaker {
}
});
MineTweakerAPI.server.addMineTweakerCommand("mobs", new String[] { "/minetweaker mobs", " Outputs a list of mob class mapping keys" }, new MobMappingLogger());
if (TweakerPlugin.isLoaded("Mekanism")) {
MineTweakerAPI.server.addMineTweakerCommand("gases", new String[] { "/minetweaker gases", " Outputs a list of all gas names in the game to the minetweaker log" }, new GasLogger());
}
@ -102,6 +107,8 @@ public class ModTweaker {
MineTweakerAPI.server.addMineTweakerCommand("lexiconCategories", new String[] { "/minetweaker lexiconCategories", " Outputs a list of lexicon categories" }, new LexiconCategoryLogger());
MineTweakerAPI.server.addMineTweakerCommand("lexiconEntries", new String[] { "/minetweaker lexiconEntries", "/minetweaker lexiconEntries [CATEGORY]", " Outputs a list of lexicon entries" }, new LexiconEntryLogger());
MineTweakerAPI.server.addMineTweakerCommand("lexiconPages", new String[] { "/minetweaker lexiconPages", "/minetweaker lexiconPages [ENTRY]", " Outputs a list of lexicon pages for the entry" }, new LexiconPageLogger());
MineTweakerAPI.server.addMineTweakerCommand("botaniaBrews", new String[] { "/minetweaker botaniaBrews", " Outputs a list of keys for botania brews" }, new BotaniaBrewLogger());
MineTweakerAPI.server.addMineTweakerCommand("lexiconKnowledgeTypes", new String[] { "/minetweaker lexiconKnowledgeTypes", " Outputs a list of keys for lexicon knowledge types" }, new LexiconKnowledgeTypesLogger());
}
}

View file

@ -0,0 +1,30 @@
package modtweaker.commands;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import net.minecraft.entity.EntityList;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.LexiconCategory;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
public class MobMappingLogger implements ICommandFunction{
@Override
public void execute(String[] arguments, IPlayer player) {
Set<String> keys=EntityList.stringToClassMapping.keySet();
System.out.println("Mob Keys: " + keys.size());
for (String key : keys) {
System.out.println("Mob Key " + key);
MineTweakerAPI.logCommand(key);
}
if (player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
}
}
}

View file

@ -0,0 +1,29 @@
package modtweaker.mods.botania.commands;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.LexiconCategory;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
public class BotaniaBrewLogger implements ICommandFunction{
@Override
public void execute(String[] arguments, IPlayer player) {
Set<String> brew_keys=BotaniaAPI.brewMap.keySet();
System.out.println("Brews: " + brew_keys.size());
for (String key : brew_keys) {
System.out.println("Brew " + key);
MineTweakerAPI.logCommand(key);
}
if (player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
}
}
}

View file

@ -16,14 +16,17 @@ import modtweaker.mods.botania.BotaniaHelper;
import modtweaker.mods.botania.lexicon.AddCategory;
import modtweaker.mods.botania.lexicon.AddEntry;
import modtweaker.mods.botania.lexicon.AddPage;
import modtweaker.mods.botania.lexicon.AddRecipeMapping;
import modtweaker.mods.botania.lexicon.RemoveCategory;
import modtweaker.mods.botania.lexicon.RemoveEntry;
import modtweaker.mods.botania.lexicon.RemovePage;
import modtweaker.mods.botania.lexicon.RemoveRecipeMapping;
import modtweaker.mods.botania.lexicon.SetCategoryIcon;
import modtweaker.mods.botania.lexicon.SetCategoryPriority;
import modtweaker.mods.botania.lexicon.SetEntryKnowledgeType;
import modtweaker.util.BaseListAddition;
import modtweaker.util.BaseListRemoval;
import net.minecraft.entity.EntityList;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.ResourceLocation;
@ -34,6 +37,7 @@ import vazkii.botania.api.lexicon.KnowledgeType;
import vazkii.botania.api.lexicon.LexiconCategory;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.lexicon.LexiconPage;
import vazkii.botania.api.lexicon.LexiconRecipeMappings;
import vazkii.botania.api.recipe.RecipeBrew;
import vazkii.botania.api.recipe.RecipeElvenTrade;
import vazkii.botania.api.recipe.RecipeManaInfusion;
@ -113,6 +117,11 @@ public class Lexicon {
MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+entry);
return;
}
if(EntityList.stringToClassMapping.containsKey(entity))
{
MineTweakerAPI.getLogger().logError("No such entity "+entity);
return;
}
LexiconPage page=new PageEntity(entity, entity, size);
MineTweakerAPI.apply(new AddPage(name,lexiconEntry,page,page_number));
}
@ -347,4 +356,34 @@ public class Lexicon {
MineTweakerAPI.apply(new SetCategoryIcon(lexiconCategory,icon));
}
@ZenMethod
public static void addRecipeMapping(IItemStack stack, String Entry, int page) {
LexiconEntry lexiconEntry=BotaniaHelper.findEntry(Entry);
if(LexiconRecipeMappings.getDataForStack(toStack(stack))!=null)
{
MineTweakerAPI.getLogger().logError("There is already a recipe mapping for "+stack);
return;
}
if(lexiconEntry==null)
{
MineTweakerAPI.getLogger().logError("Cannot find lexicon entry "+Entry);
return;
}
if(lexiconEntry.pages.size()<page)
{
MineTweakerAPI.getLogger().logError("Not enough pages in "+Entry);
return;
}
MineTweakerAPI.apply(new AddRecipeMapping(toStack(stack),lexiconEntry,page));
}
@ZenMethod
public static void removeRecipeMapping(IItemStack stack) {
if(LexiconRecipeMappings.getDataForStack(toStack(stack))==null)
{
MineTweakerAPI.getLogger().logError("There isn't a recipe mapping for "+stack);
return;
}
MineTweakerAPI.apply(new RemoveRecipeMapping(toStack(stack)));
}
}

View file

@ -0,0 +1,53 @@
package modtweaker.mods.botania.lexicon;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.LexiconCategory;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.lexicon.LexiconPage;
import vazkii.botania.api.lexicon.LexiconRecipeMappings;
import vazkii.botania.api.lexicon.LexiconRecipeMappings.EntryData;
import minetweaker.IUndoableAction;
public class AddRecipeMapping implements IUndoableAction {
ItemStack stack;
LexiconEntry entry;
int page;
public AddRecipeMapping(ItemStack stack, LexiconEntry entry, int page) {
this.stack =stack;
this.entry=entry;
this.page=page;
}
@Override
public void apply() {
LexiconRecipeMappings.map(stack, entry, page);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public String describe() {
return "Adding Lexicon Recipe Lookup: " + stack.getUnlocalizedName();
}
@Override
public String describeUndo() {
return "Removing Lexicon Recipe Lookup: " + stack.getUnlocalizedName();
}
@Override
public void undo() {
LexiconRecipeMappings.remove(stack);
}
@Override
public Object getOverrideKey() {
return null;
}
}

View file

@ -0,0 +1,54 @@
package modtweaker.mods.botania.lexicon;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.LexiconCategory;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.lexicon.LexiconPage;
import vazkii.botania.api.lexicon.LexiconRecipeMappings;
import vazkii.botania.api.lexicon.LexiconRecipeMappings.EntryData;
import minetweaker.IUndoableAction;
public class RemoveRecipeMapping implements IUndoableAction {
ItemStack stack;
LexiconEntry entry;
int page;
public RemoveRecipeMapping(ItemStack stack) {
this.stack =stack;
}
@Override
public void apply() {
EntryData data=LexiconRecipeMappings.getDataForStack(stack);
this.entry=data.entry;
this.page=data.page;
LexiconRecipeMappings.remove(stack);
}
@Override
public boolean canUndo() {
return true;
}
@Override
public String describe() {
return "Removing Lexicon Recipe Lookup: " + stack.getUnlocalizedName();
}
@Override
public String describeUndo() {
return "Adding Lexicon Recipe Lookup: " + stack.getUnlocalizedName();
}
@Override
public void undo() {
LexiconRecipeMappings.map(stack,entry,page);
}
@Override
public Object getOverrideKey() {
return null;
}
}

View file

@ -0,0 +1,29 @@
package modtweaker.mods.botania.lexicon.commands;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.LexiconCategory;
import minetweaker.MineTweakerAPI;
import minetweaker.MineTweakerImplementationAPI;
import minetweaker.api.player.IPlayer;
import minetweaker.api.server.ICommandFunction;
public class LexiconKnowledgeTypesLogger implements ICommandFunction{
@Override
public void execute(String[] arguments, IPlayer player) {
Set<String> types=BotaniaAPI.knowledgeTypes.keySet();
System.out.println("Knowledge Types: " + types.size());
for (String key : types) {
System.out.println("Knowledge Type " + key);
MineTweakerAPI.logCommand(key);
}
if (player != null) {
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
}
}
}