Pretty big whack of stuff. Added a TransmutationKnowledgeRegistryProxy for API access to what players and the template know how to transmute. More robust serialization options for the AbilityRegistry. Added the ability to filter a given set of ItemStacks by their display name (starts with and contains). Added the ability to only load in Abilities from file on initial load of of a world (more control for map makers there)
This commit is contained in:
parent
998bd5fe3e
commit
334a92e54c
|
@ -13,6 +13,7 @@ import com.pahimar.ee3.recipe.RecipeRegistry;
|
|||
import com.pahimar.ee3.recipe.RecipesAludel;
|
||||
import com.pahimar.ee3.reference.Messages;
|
||||
import com.pahimar.ee3.reference.Reference;
|
||||
import com.pahimar.ee3.reference.Settings;
|
||||
import com.pahimar.ee3.util.LogHelper;
|
||||
import com.pahimar.ee3.util.SerializationHelper;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
@ -55,8 +56,7 @@ public class EquivalentExchange3
|
|||
|
||||
TransmutationKnowledgeRegistry.getInstance();
|
||||
|
||||
AbilityRegistry.getInstance().loadAbilityRegistryFromFile();
|
||||
AbilityRegistry.getInstance().saveAbilityRegistryToFile();
|
||||
AbilityRegistry.getInstance().loadAbilityRegistryFromFile(Settings.Abilities.onlyLoadFile);
|
||||
|
||||
event.registerServerCommand(new CommandEE());
|
||||
}
|
||||
|
@ -156,4 +156,9 @@ public class EquivalentExchange3
|
|||
{
|
||||
return AlchemyArrayRegistry.getInstance();
|
||||
}
|
||||
|
||||
public TransmutationKnowledgeRegistry getTransmutationKnowledgeRegistry()
|
||||
{
|
||||
return TransmutationKnowledgeRegistry.getInstance();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,215 @@
|
|||
package com.pahimar.ee3.api;
|
||||
|
||||
import com.pahimar.ee3.EquivalentExchange3;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class TransmutationKnowledgeRegistryProxy
|
||||
{
|
||||
public static boolean doesPlayerKnow(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().doesPlayerKnow(entityPlayer, itemStack);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean canPlayerLearn(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().canPlayerLearn(entityPlayer, itemStack);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Set<ItemStack> getPlayerKnownTransmutations(EntityPlayer entityPlayer)
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getPlayersKnownTransmutations(entityPlayer);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Set<ItemStack> getPlayerKnownTransmutationsFilteredStartsWith(EntityPlayer entityPlayer, String filterString)
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getPlayersKnownTransmutationsFilteredStartsWith(entityPlayer, filterString);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Set<ItemStack> getPlayerKnownTransmutationsFilteredContains(EntityPlayer entityPlayer, String filterString)
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getPlayersKnownTransmutationsFilteredContains(entityPlayer, filterString);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void teachPlayer(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().teachPlayer(entityPlayer, itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
public static void teachPlayerEverything(EntityPlayer entityPlayer)
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().teachPlayerEverything(entityPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
public static void makePlayerForget(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().makePlayerForget(entityPlayer, itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
public static void makePlayerForgetEverything(EntityPlayer entityPlayer)
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().makePlayerForgetEverything(entityPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean doesTemplateKnow(ItemStack itemStack)
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().doesTemplateKnow(itemStack);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Set<ItemStack> getTemplateKnownTransmutations()
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getTemplatesKnownTransmutations();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Set<ItemStack> getTemplateKnownTransmutationsFilteredStartsWith(String filterString)
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getTemplatesKnownTransmutationsFilteredStartsWith(filterString);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Set<ItemStack> getTemplateKnownTransmutationsFilteredContains(String filterString)
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
return EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().getTemplatesKnownTransmutationsFilteredContains(filterString);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void teachTemplate(ItemStack itemStack)
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().teachTemplate(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
public static void teachTemplateEverything()
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().teachTemplateEverything();
|
||||
}
|
||||
}
|
||||
|
||||
public static void makeTemplateForget(ItemStack itemStack)
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().makeTemplateForget(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
public static void makeTemplateForgetEverything()
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().makeTemplateForgetEverything();
|
||||
}
|
||||
}
|
||||
|
||||
@Mod.Instance("EE3")
|
||||
private static Object ee3Mod;
|
||||
|
||||
private static class EE3Wrapper
|
||||
{
|
||||
private static EquivalentExchange3 ee3mod;
|
||||
}
|
||||
|
||||
private static void init()
|
||||
{
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
EE3Wrapper.ee3mod = (EquivalentExchange3) ee3Mod;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package com.pahimar.ee3.command;
|
||||
|
||||
import com.pahimar.ee3.api.AbilityRegistryProxy;
|
||||
import com.pahimar.ee3.knowledge.AbilityRegistry;
|
||||
import com.pahimar.ee3.reference.Messages;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import net.minecraft.command.CommandBase;
|
||||
|
@ -78,7 +77,6 @@ public class CommandSetItemLearnable extends CommandBase
|
|||
}
|
||||
|
||||
AbilityRegistryProxy.setAsLearnable(itemStack);
|
||||
AbilityRegistry.getInstance().saveAbilityRegistryToFile();
|
||||
func_152373_a(commandSender, this, Messages.Commands.SET_ITEM_LEARNABLE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.pahimar.ee3.command;
|
||||
|
||||
import com.pahimar.ee3.api.AbilityRegistryProxy;
|
||||
import com.pahimar.ee3.knowledge.AbilityRegistry;
|
||||
import com.pahimar.ee3.reference.Messages;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import net.minecraft.command.CommandBase;
|
||||
|
@ -78,7 +77,6 @@ public class CommandSetItemNotLearnable extends CommandBase
|
|||
}
|
||||
|
||||
AbilityRegistryProxy.setAsNotLearnable(itemStack);
|
||||
AbilityRegistry.getInstance().saveAbilityRegistryToFile();
|
||||
func_152373_a(commandSender, this, Messages.Commands.SET_ITEM_NOT_LEARNABLE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.pahimar.ee3.command;
|
||||
|
||||
import com.pahimar.ee3.api.AbilityRegistryProxy;
|
||||
import com.pahimar.ee3.knowledge.AbilityRegistry;
|
||||
import com.pahimar.ee3.reference.Messages;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import net.minecraft.command.CommandBase;
|
||||
|
@ -78,7 +77,6 @@ public class CommandSetItemNotRecoverable extends CommandBase
|
|||
}
|
||||
|
||||
AbilityRegistryProxy.setAsRecoverable(itemStack);
|
||||
AbilityRegistry.getInstance().saveAbilityRegistryToFile();
|
||||
func_152373_a(commandSender, this, Messages.Commands.SET_ITEM_NOT_RECOVERABLE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.pahimar.ee3.command;
|
||||
|
||||
import com.pahimar.ee3.api.AbilityRegistryProxy;
|
||||
import com.pahimar.ee3.knowledge.AbilityRegistry;
|
||||
import com.pahimar.ee3.reference.Messages;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import net.minecraft.command.CommandBase;
|
||||
|
@ -78,7 +77,6 @@ public class CommandSetItemRecoverable extends CommandBase
|
|||
}
|
||||
|
||||
AbilityRegistryProxy.setAsRecoverable(itemStack);
|
||||
AbilityRegistry.getInstance().saveAbilityRegistryToFile();
|
||||
func_152373_a(commandSender, this, Messages.Commands.SET_ITEM_RECOVERABLE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.pahimar.ee3.handler;
|
||||
|
||||
import com.pahimar.ee3.knowledge.AbilityRegistry;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
|
||||
public class AbilityRegistrySerializationHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public void onServerTick(TickEvent.ServerTickEvent event)
|
||||
{
|
||||
if (event.phase == TickEvent.Phase.END)
|
||||
{
|
||||
if (FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getWorldTime() % 600 == 0)
|
||||
{
|
||||
AbilityRegistry.getInstance().saveAbilityRegistryToFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,6 +29,7 @@ public class ConfigurationHandler
|
|||
// TODO Come back and do these constants in logical locations and names
|
||||
Settings.General.syncThreshold = configuration.getInt(Messages.Configuration.GENERAL_SYNC_THRESHOLD, Configuration.CATEGORY_GENERAL, 5, 0, Short.MAX_VALUE, StatCollector.translateToLocal(Messages.Configuration.GENERAL_SYNC_THRESHOLD_COMMENT), Messages.Configuration.GENERAL_SYNC_THRESHOLD_LABEL);
|
||||
Settings.Sounds.soundMode = ConfigurationHelper.getString(configuration, Messages.Configuration.SOUND_MODE, Configuration.CATEGORY_GENERAL, "All", StatCollector.translateToLocal(Messages.Configuration.SOUND_MODE_COMMENT), new String[]{"All", "Self", "None"}, Messages.Configuration.SOUND_MODE_LABEL);
|
||||
Settings.Abilities.onlyLoadFile = configuration.getBoolean(Messages.Configuration.ABILITIES_ONLY_LOAD_FILE, Configuration.CATEGORY_GENERAL, false, StatCollector.translateToLocal(Messages.Configuration.ABILITIES_ONLY_LOAD_FILE_COMMENT), Messages.Configuration.ABILITIES_ONLY_LOAD_FILE_LABEL);
|
||||
|
||||
if (configuration.hasChanged())
|
||||
{
|
||||
|
|
|
@ -13,12 +13,13 @@ import java.util.Iterator;
|
|||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
// TODO Serialize the sets to separate JSON for map makers, cause you know, I love them
|
||||
public class AbilityRegistry implements JsonSerializer<AbilityRegistry>, JsonDeserializer<AbilityRegistry>
|
||||
{
|
||||
private static final Gson jsonSerializer = (new GsonBuilder()).setPrettyPrinting().registerTypeAdapter(AbilityRegistry.class, new AbilityRegistry()).create();
|
||||
private static File abilityDirectory;
|
||||
private static AbilityRegistry abilityRegistry = null;
|
||||
|
||||
private static File abilityDirectory;
|
||||
private boolean hasBeenModified;
|
||||
private Set<WrappedStack> notLearnableSet;
|
||||
private Set<WrappedStack> notRecoverableSet;
|
||||
|
||||
|
@ -27,6 +28,7 @@ public class AbilityRegistry implements JsonSerializer<AbilityRegistry>, JsonDes
|
|||
abilityDirectory = new File(SerializationHelper.getDataDirectory(), "abilities");
|
||||
abilityDirectory.mkdirs();
|
||||
|
||||
hasBeenModified = false;
|
||||
notLearnableSet = new TreeSet<WrappedStack>();
|
||||
notRecoverableSet = new TreeSet<WrappedStack>();
|
||||
}
|
||||
|
@ -68,7 +70,7 @@ public class AbilityRegistry implements JsonSerializer<AbilityRegistry>, JsonDes
|
|||
{
|
||||
if (WrappedStack.canBeWrapped(object))
|
||||
{
|
||||
notLearnableSet.remove(new WrappedStack(object));
|
||||
hasBeenModified = notLearnableSet.remove(new WrappedStack(object));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +78,7 @@ public class AbilityRegistry implements JsonSerializer<AbilityRegistry>, JsonDes
|
|||
{
|
||||
if (WrappedStack.canBeWrapped(object))
|
||||
{
|
||||
notLearnableSet.add(new WrappedStack(object));
|
||||
hasBeenModified = notLearnableSet.add(new WrappedStack(object));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +101,7 @@ public class AbilityRegistry implements JsonSerializer<AbilityRegistry>, JsonDes
|
|||
{
|
||||
if (WrappedStack.canBeWrapped(object))
|
||||
{
|
||||
notRecoverableSet.remove(new WrappedStack(object));
|
||||
hasBeenModified = notRecoverableSet.remove(new WrappedStack(object));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,7 +109,7 @@ public class AbilityRegistry implements JsonSerializer<AbilityRegistry>, JsonDes
|
|||
{
|
||||
if (WrappedStack.canBeWrapped(object))
|
||||
{
|
||||
notRecoverableSet.add(new WrappedStack(object));
|
||||
hasBeenModified = notRecoverableSet.add(new WrappedStack(object));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -207,38 +209,48 @@ public class AbilityRegistry implements JsonSerializer<AbilityRegistry>, JsonDes
|
|||
|
||||
public void saveAbilityRegistryToFile()
|
||||
{
|
||||
abilityDirectory.mkdirs();
|
||||
writeToFile(new File(abilityDirectory, Files.ABILITIES_JSON_FILE));
|
||||
if (abilityDirectory != null)
|
||||
{
|
||||
abilityDirectory.mkdirs();
|
||||
writeToFile(new File(abilityDirectory, Files.ABILITIES_JSON_FILE));
|
||||
}
|
||||
}
|
||||
|
||||
private void writeToFile(File file)
|
||||
{
|
||||
JsonWriter jsonWriter;
|
||||
|
||||
try
|
||||
if (hasBeenModified)
|
||||
{
|
||||
jsonWriter = new JsonWriter(new FileWriter(file));
|
||||
jsonWriter.setIndent(" ");
|
||||
jsonSerializer.toJson(this, AbilityRegistry.class, jsonWriter);
|
||||
jsonWriter.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
try
|
||||
{
|
||||
jsonWriter = new JsonWriter(new FileWriter(file));
|
||||
jsonWriter.setIndent(" ");
|
||||
jsonSerializer.toJson(this, AbilityRegistry.class, jsonWriter);
|
||||
jsonWriter.close();
|
||||
hasBeenModified = false;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadAbilityRegistryFromFile()
|
||||
public void loadAbilityRegistryFromFile(boolean loadFileOnly)
|
||||
{
|
||||
File abilitiesFile = new File(abilityDirectory, Files.ABILITIES_JSON_FILE);
|
||||
|
||||
if (abilitiesFile.exists())
|
||||
if (abilityDirectory != null)
|
||||
{
|
||||
readFromFile(abilitiesFile);
|
||||
File abilitiesFile = new File(abilityDirectory, Files.ABILITIES_JSON_FILE);
|
||||
|
||||
if (abilitiesFile.exists())
|
||||
{
|
||||
readFromFile(abilitiesFile, loadFileOnly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void readFromFile(File file)
|
||||
private void readFromFile(File file, boolean loadFileOnly)
|
||||
{
|
||||
JsonReader jsonReader;
|
||||
|
||||
|
@ -248,21 +260,31 @@ public class AbilityRegistry implements JsonSerializer<AbilityRegistry>, JsonDes
|
|||
AbilityRegistry abilityRegistry1 = jsonSerializer.fromJson(jsonReader, AbilityRegistry.class);
|
||||
jsonReader.close();
|
||||
|
||||
for (WrappedStack wrappedStack : abilityRegistry1.getNotLearnableStacks())
|
||||
if (!loadFileOnly)
|
||||
{
|
||||
if (!this.notLearnableSet.contains(wrappedStack))
|
||||
for (WrappedStack wrappedStack : abilityRegistry1.getNotLearnableStacks())
|
||||
{
|
||||
this.notLearnableSet.add(wrappedStack);
|
||||
if (!this.notLearnableSet.contains(wrappedStack))
|
||||
{
|
||||
this.notLearnableSet.add(wrappedStack);
|
||||
}
|
||||
}
|
||||
|
||||
for (WrappedStack wrappedStack : abilityRegistry1.getNotRecoverableSet())
|
||||
{
|
||||
if (!this.notRecoverableSet.contains(wrappedStack))
|
||||
{
|
||||
this.notRecoverableSet.add(wrappedStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.notLearnableSet = abilityRegistry1.notLearnableSet;
|
||||
this.notRecoverableSet = abilityRegistry1.notRecoverableSet;
|
||||
}
|
||||
|
||||
for (WrappedStack wrappedStack : abilityRegistry1.getNotRecoverableSet())
|
||||
{
|
||||
if (!this.notRecoverableSet.contains(wrappedStack))
|
||||
{
|
||||
this.notRecoverableSet.add(wrappedStack);
|
||||
}
|
||||
}
|
||||
hasBeenModified = true;
|
||||
}
|
||||
catch (FileNotFoundException ignored)
|
||||
{
|
||||
|
|
|
@ -25,7 +25,7 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
|
||||
public TransmutationKnowledge()
|
||||
{
|
||||
this(new TreeSet<ItemStack>(ItemHelper.comparator));
|
||||
this(new TreeSet<ItemStack>(ItemHelper.displayNameComparator));
|
||||
}
|
||||
|
||||
public TransmutationKnowledge(Collection<ItemStack> knownTransmutations)
|
||||
|
@ -36,7 +36,7 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
public TransmutationKnowledge(Collection<ItemStack> knownTransmutations, boolean canTransmuteEverything)
|
||||
{
|
||||
this.canTransmuteEverything = canTransmuteEverything;
|
||||
this.knownTransmutations = new TreeSet<ItemStack>(ItemHelper.comparator);
|
||||
this.knownTransmutations = new TreeSet<ItemStack>(ItemHelper.displayNameComparator);
|
||||
this.knownTransmutations.addAll(knownTransmutations);
|
||||
hasBeenModified = false;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
public TransmutationKnowledge(NBTTagCompound nbtTagCompound)
|
||||
{
|
||||
canTransmuteEverything = false;
|
||||
this.knownTransmutations = new TreeSet<ItemStack>(ItemHelper.comparator);
|
||||
this.knownTransmutations = new TreeSet<ItemStack>(ItemHelper.displayNameComparator);
|
||||
this.readFromNBT(nbtTagCompound);
|
||||
hasBeenModified = false;
|
||||
}
|
||||
|
@ -124,6 +124,16 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
return hasBeenModified;
|
||||
}
|
||||
|
||||
public Set<ItemStack> filterByNameStartsWith(String filterString)
|
||||
{
|
||||
return ItemHelper.filterByNameStartsWith(knownTransmutations, filterString);
|
||||
}
|
||||
|
||||
public Set<ItemStack> filterByNameContains(String filterString)
|
||||
{
|
||||
return ItemHelper.filterByNameContains(knownTransmutations, filterString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound)
|
||||
{
|
||||
|
@ -132,7 +142,7 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
if (nbtTagCompound.hasKey(Names.NBT.ITEM_TRANSMUTATION_KNOWLEDGE))
|
||||
{
|
||||
NBTTagList tagList = nbtTagCompound.getTagList(Names.NBT.ITEM_TRANSMUTATION_KNOWLEDGE, 10);
|
||||
knownTransmutations = new TreeSet<ItemStack>(ItemHelper.comparator);
|
||||
knownTransmutations = new TreeSet<ItemStack>(ItemHelper.displayNameComparator);
|
||||
for (int i = 0; i < tagList.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
|
||||
|
@ -142,7 +152,7 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
}
|
||||
else
|
||||
{
|
||||
knownTransmutations = new TreeSet<ItemStack>(ItemHelper.comparator);
|
||||
knownTransmutations = new TreeSet<ItemStack>(ItemHelper.displayNameComparator);
|
||||
}
|
||||
|
||||
if (nbtTagCompound.hasKey(Names.NBT.CAN_TRANSMUTE_ANYTHING))
|
||||
|
@ -156,7 +166,7 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
}
|
||||
else
|
||||
{
|
||||
knownTransmutations = new TreeSet<ItemStack>(ItemHelper.comparator);
|
||||
knownTransmutations = new TreeSet<ItemStack>(ItemHelper.displayNameComparator);
|
||||
canTransmuteEverything = false;
|
||||
}
|
||||
}
|
||||
|
@ -181,15 +191,6 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
return "TransmutationKnowledge";
|
||||
}
|
||||
|
||||
public static TransmutationKnowledge readTransmutationKnowledgeFromNBT(NBTTagCompound nbtTagCompound)
|
||||
{
|
||||
TransmutationKnowledge transmutationKnowledge = new TransmutationKnowledge();
|
||||
|
||||
transmutationKnowledge.readFromNBT(nbtTagCompound);
|
||||
|
||||
return transmutationKnowledge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
@ -236,7 +237,7 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
JsonObject jsonObject = (JsonObject) json;
|
||||
|
||||
boolean canTransmuteEverything;
|
||||
Set<ItemStack> itemStacks = new TreeSet<ItemStack>(ItemHelper.comparator);
|
||||
Set<ItemStack> itemStacks = new TreeSet<ItemStack>(ItemHelper.displayNameComparator);
|
||||
|
||||
if (jsonObject.has("canTransmuteEverything") && jsonObject.get("canTransmuteEverything").isJsonPrimitive())
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.pahimar.ee3.knowledge;
|
||||
|
||||
import com.pahimar.ee3.reference.Files;
|
||||
import com.pahimar.ee3.util.ItemHelper;
|
||||
import com.pahimar.ee3.util.SerializationHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -61,6 +62,26 @@ public class TransmutationKnowledgeRegistry
|
|||
return templateKnowledge.getKnownTransmutations();
|
||||
}
|
||||
|
||||
public Set<ItemStack> getTemplatesKnownTransmutationsFilteredStartsWith(String filterString)
|
||||
{
|
||||
if (templateKnowledge == null)
|
||||
{
|
||||
loadTemplateKnowledgeFromDisk();
|
||||
}
|
||||
|
||||
return ItemHelper.filterByNameStartsWith(templateKnowledge.getKnownTransmutations(), filterString);
|
||||
}
|
||||
|
||||
public Set<ItemStack> getTemplatesKnownTransmutationsFilteredContains(String filterString)
|
||||
{
|
||||
if (templateKnowledge == null)
|
||||
{
|
||||
loadTemplateKnowledgeFromDisk();
|
||||
}
|
||||
|
||||
return ItemHelper.filterByNameContains(templateKnowledge.getKnownTransmutations(), filterString);
|
||||
}
|
||||
|
||||
public boolean doesTemplateKnow(ItemStack itemStack)
|
||||
{
|
||||
if (templateKnowledge == null)
|
||||
|
@ -146,24 +167,77 @@ public class TransmutationKnowledgeRegistry
|
|||
*/
|
||||
public Set<ItemStack> getPlayersKnownTransmutations(EntityPlayer entityPlayer)
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(entityPlayer);
|
||||
if (entityPlayer != null)
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(entityPlayer);
|
||||
|
||||
return playerKnowledgeMap.get(entityPlayer.getUniqueID()).getKnownTransmutations();
|
||||
if (playerKnowledgeMap.containsKey(entityPlayer.getUniqueID()))
|
||||
{
|
||||
return playerKnowledgeMap.get(entityPlayer.getUniqueID()).getKnownTransmutations();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set<ItemStack> getPlayersKnownTransmutationsFilteredStartsWith(EntityPlayer entityPlayer, String startsWith)
|
||||
{
|
||||
if (entityPlayer != null)
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(entityPlayer);
|
||||
|
||||
if (playerKnowledgeMap.containsKey(entityPlayer.getUniqueID()))
|
||||
{
|
||||
return playerKnowledgeMap.get(entityPlayer.getUniqueID()).filterByNameStartsWith(startsWith);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set<ItemStack> getPlayersKnownTransmutationsFilteredContains(EntityPlayer entityPlayer, String contains)
|
||||
{
|
||||
if (entityPlayer != null)
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(entityPlayer);
|
||||
|
||||
if (playerKnowledgeMap.containsKey(entityPlayer.getUniqueID()))
|
||||
{
|
||||
return playerKnowledgeMap.get(entityPlayer.getUniqueID()).filterByNameContains(contains);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean doesPlayerKnow(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(entityPlayer);
|
||||
if (entityPlayer != null && itemStack != null)
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(entityPlayer);
|
||||
|
||||
return playerKnowledgeMap.get(entityPlayer.getUniqueID()).isKnown(itemStack);
|
||||
if (playerKnowledgeMap.containsKey(entityPlayer.getUniqueID()))
|
||||
{
|
||||
return playerKnowledgeMap.get(entityPlayer.getUniqueID()).isKnown(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canPlayerLearn(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
if (AbilityRegistry.getInstance().isLearnable(itemStack))
|
||||
if (entityPlayer != null && itemStack != null)
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(entityPlayer);
|
||||
return !playerKnowledgeMap.get(entityPlayer.getUniqueID()).isKnown(itemStack);
|
||||
if (AbilityRegistry.getInstance().isLearnable(itemStack))
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(entityPlayer);
|
||||
|
||||
if (playerKnowledgeMap.containsKey(entityPlayer.getUniqueID()))
|
||||
{
|
||||
return !playerKnowledgeMap.get(entityPlayer.getUniqueID()).isKnown(itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -171,38 +245,63 @@ public class TransmutationKnowledgeRegistry
|
|||
|
||||
public void teachPlayer(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
if (canPlayerLearn(entityPlayer, itemStack))
|
||||
if (entityPlayer != null && itemStack != null && canPlayerLearn(entityPlayer, itemStack))
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(entityPlayer);
|
||||
playerKnowledgeMap.get(entityPlayer.getUniqueID()).learnTransmutation(itemStack);
|
||||
if (playerKnowledgeMap.containsKey(entityPlayer.getUniqueID()))
|
||||
{
|
||||
playerKnowledgeMap.get(entityPlayer.getUniqueID()).learnTransmutation(itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void teachPlayerEverything(EntityPlayer entityPlayer)
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(entityPlayer);
|
||||
playerKnowledgeMap.get(entityPlayer.getUniqueID()).setCanTransmuteEverything(true);
|
||||
if (entityPlayer != null)
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(entityPlayer);
|
||||
|
||||
if (playerKnowledgeMap.containsKey(entityPlayer.getUniqueID()))
|
||||
{
|
||||
playerKnowledgeMap.get(entityPlayer.getUniqueID()).setCanTransmuteEverything(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setPlayerCanTransmuteEverything(EntityPlayer entityPlayer, boolean canTransmuteEverything)
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(entityPlayer);
|
||||
playerKnowledgeMap.get(entityPlayer.getUniqueID()).setCanTransmuteEverything(canTransmuteEverything);
|
||||
if (entityPlayer != null)
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(entityPlayer);
|
||||
if (playerKnowledgeMap.containsKey(entityPlayer.getUniqueID()))
|
||||
{
|
||||
playerKnowledgeMap.get(entityPlayer.getUniqueID()).setCanTransmuteEverything(canTransmuteEverything);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void makePlayerForget(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
if (doesPlayerKnow(entityPlayer, itemStack))
|
||||
if (entityPlayer != null && itemStack != null && doesPlayerKnow(entityPlayer, itemStack))
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(entityPlayer);
|
||||
playerKnowledgeMap.get(entityPlayer.getUniqueID()).forgetTransmutation(itemStack);
|
||||
if (playerKnowledgeMap.containsKey(entityPlayer.getUniqueID()))
|
||||
{
|
||||
playerKnowledgeMap.get(entityPlayer.getUniqueID()).forgetTransmutation(itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void makePlayerForgetEverything(EntityPlayer entityPlayer)
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(entityPlayer);
|
||||
playerKnowledgeMap.get(entityPlayer.getUniqueID()).forgetAllTransmutations();
|
||||
if (entityPlayer != null)
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(entityPlayer);
|
||||
if (playerKnowledgeMap.containsKey(entityPlayer.getUniqueID()))
|
||||
{
|
||||
playerKnowledgeMap.get(entityPlayer.getUniqueID()).forgetAllTransmutations();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -212,35 +311,45 @@ public class TransmutationKnowledgeRegistry
|
|||
*/
|
||||
public void loadTemplateKnowledgeFromDisk()
|
||||
{
|
||||
File templateFile = new File(dataKnowledgeDirectory, Files.TEMPLATE_JSON_FILE);
|
||||
|
||||
if (!templateFile.exists())
|
||||
if (dataKnowledgeDirectory != null)
|
||||
{
|
||||
templateKnowledge = new TransmutationKnowledge();
|
||||
SerializationHelper.writeTransmutationKnowledgeToFile(dataKnowledgeDirectory, Files.TEMPLATE_JSON_FILE, templateKnowledge);
|
||||
File templateFile = new File(dataKnowledgeDirectory, Files.TEMPLATE_JSON_FILE);
|
||||
|
||||
if (!templateFile.exists())
|
||||
{
|
||||
templateKnowledge = new TransmutationKnowledge();
|
||||
SerializationHelper.writeTransmutationKnowledgeToFile(dataKnowledgeDirectory, Files.TEMPLATE_JSON_FILE, templateKnowledge);
|
||||
}
|
||||
else
|
||||
{
|
||||
templateKnowledge = SerializationHelper.readTransmutationKnowledgeFromFile(dataKnowledgeDirectory, Files.TEMPLATE_JSON_FILE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
templateKnowledge = SerializationHelper.readTransmutationKnowledgeFromFile(dataKnowledgeDirectory, Files.TEMPLATE_JSON_FILE);
|
||||
templateKnowledge = new TransmutationKnowledge();
|
||||
}
|
||||
}
|
||||
|
||||
public void saveTemplateKnowledgeToDisk()
|
||||
{
|
||||
if (templateKnowledge != null)
|
||||
if (dataKnowledgeDirectory != null)
|
||||
{
|
||||
SerializationHelper.writeTransmutationKnowledgeToFile(dataKnowledgeDirectory, Files.TEMPLATE_JSON_FILE, templateKnowledge);
|
||||
}
|
||||
else
|
||||
{
|
||||
templateKnowledge = new TransmutationKnowledge();
|
||||
SerializationHelper.writeTransmutationKnowledgeToFile(dataKnowledgeDirectory, Files.TEMPLATE_JSON_FILE, templateKnowledge);
|
||||
if (templateKnowledge != null)
|
||||
{
|
||||
SerializationHelper.writeTransmutationKnowledgeToFile(dataKnowledgeDirectory, Files.TEMPLATE_JSON_FILE, templateKnowledge);
|
||||
}
|
||||
else
|
||||
{
|
||||
templateKnowledge = new TransmutationKnowledge();
|
||||
SerializationHelper.writeTransmutationKnowledgeToFile(dataKnowledgeDirectory, Files.TEMPLATE_JSON_FILE, templateKnowledge);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadPlayerFromDiskIfNeeded(EntityPlayer entityPlayer)
|
||||
{
|
||||
if (entityPlayer != null && entityPlayer.getUniqueID() != null)
|
||||
if (entityPlayer != null && entityPlayer.getUniqueID() != null && playerKnowledgeDirectory != null)
|
||||
{
|
||||
if (!playerKnowledgeMap.containsKey(entityPlayer.getUniqueID()))
|
||||
{
|
||||
|
@ -272,7 +381,7 @@ public class TransmutationKnowledgeRegistry
|
|||
|
||||
public void savePlayerKnowledgeToDisk(EntityPlayer entityPlayer)
|
||||
{
|
||||
if (entityPlayer != null && entityPlayer.getUniqueID() != null)
|
||||
if (entityPlayer != null && entityPlayer.getUniqueID() != null && playerKnowledgeDirectory != null)
|
||||
{
|
||||
if (playerKnowledgeMap.containsKey(entityPlayer.getUniqueID()) && playerKnowledgeMap.get(entityPlayer.getUniqueID()) != null && playerKnowledgeMap.get(entityPlayer.getUniqueID()).hasBeenModified())
|
||||
{
|
||||
|
@ -288,11 +397,17 @@ public class TransmutationKnowledgeRegistry
|
|||
|
||||
public void saveAll()
|
||||
{
|
||||
saveTemplateKnowledgeToDisk();
|
||||
|
||||
for (UUID playerUUID : playerKnowledgeMap.keySet())
|
||||
if (dataKnowledgeDirectory != null)
|
||||
{
|
||||
SerializationHelper.writeTransmutationKnowledgeToFile(playerKnowledgeDirectory, playerUUID.toString() + ".json", playerKnowledgeMap.get(playerUUID));
|
||||
saveTemplateKnowledgeToDisk();
|
||||
}
|
||||
|
||||
if (playerKnowledgeDirectory != null)
|
||||
{
|
||||
for (UUID playerUUID : playerKnowledgeMap.keySet())
|
||||
{
|
||||
SerializationHelper.writeTransmutationKnowledgeToFile(playerKnowledgeDirectory, playerUUID.toString() + ".json", playerKnowledgeMap.get(playerUUID));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ public abstract class CommonProxy implements IProxy
|
|||
PlayerEventHandler playerEventHandler = new PlayerEventHandler();
|
||||
|
||||
FMLCommonHandler.instance().bus().register(new ConfigurationHandler());
|
||||
FMLCommonHandler.instance().bus().register(new AbilityRegistrySerializationHandler());
|
||||
FMLCommonHandler.instance().bus().register(itemEventHandler);
|
||||
MinecraftForge.EVENT_BUS.register(itemEventHandler);
|
||||
MinecraftForge.EVENT_BUS.register(new WorldEventHandler());
|
||||
|
|
|
@ -71,5 +71,9 @@ public final class Messages
|
|||
public static final String SOUND_MODE = "soundMode";
|
||||
public static final String SOUND_MODE_LABEL = "general.sound.soundMode.label";
|
||||
public static final String SOUND_MODE_COMMENT = "general.sound.soundMode.comment";
|
||||
|
||||
public static final String ABILITIES_ONLY_LOAD_FILE = "abilities.onlyLoadFile";
|
||||
public static final String ABILITIES_ONLY_LOAD_FILE_LABEL = "general.abilities.onlyLoadFile.label";
|
||||
public static final String ABILITIES_ONLY_LOAD_FILE_COMMENT = "general.abilities.onlyLoadFile.comment";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,4 +11,9 @@ public class Settings
|
|||
{
|
||||
public static String soundMode;
|
||||
}
|
||||
|
||||
public static class Abilities
|
||||
{
|
||||
public static boolean onlyLoadFile;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ItemHelper
|
||||
|
@ -19,7 +21,7 @@ public class ItemHelper
|
|||
return clonedItemStack;
|
||||
}
|
||||
|
||||
public static Comparator<ItemStack> comparator = new Comparator<ItemStack>()
|
||||
public static Comparator<ItemStack> baseComparator = new Comparator<ItemStack>()
|
||||
{
|
||||
public int compare(ItemStack itemStack1, ItemStack itemStack2)
|
||||
{
|
||||
|
@ -90,6 +92,84 @@ public class ItemHelper
|
|||
}
|
||||
};
|
||||
|
||||
public static Comparator<ItemStack> displayNameComparator = new Comparator<ItemStack>()
|
||||
{
|
||||
public int compare(ItemStack itemStack1, ItemStack itemStack2)
|
||||
{
|
||||
if (itemStack1 != null && itemStack2 != null)
|
||||
{
|
||||
if (itemStack1.getDisplayName().equalsIgnoreCase(itemStack2.getDisplayName()))
|
||||
{
|
||||
// Sort on itemID
|
||||
if (Item.getIdFromItem(itemStack1.getItem()) - Item.getIdFromItem(itemStack2.getItem()) == 0)
|
||||
{
|
||||
// Sort on item
|
||||
if (itemStack1.getItem() == itemStack2.getItem())
|
||||
{
|
||||
// Then sort on meta
|
||||
if (itemStack1.getItemDamage() == itemStack2.getItemDamage())
|
||||
{
|
||||
// Then sort on NBT
|
||||
if (itemStack1.hasTagCompound() && itemStack2.hasTagCompound())
|
||||
{
|
||||
// Then sort on stack size
|
||||
if (ItemStack.areItemStackTagsEqual(itemStack1, itemStack2))
|
||||
{
|
||||
return (itemStack1.stackSize - itemStack2.stackSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (itemStack1.getTagCompound().hashCode() - itemStack2.getTagCompound().hashCode());
|
||||
}
|
||||
}
|
||||
else if (!(itemStack1.hasTagCompound()) && itemStack2.hasTagCompound())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (itemStack1.hasTagCompound() && !(itemStack2.hasTagCompound()))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (itemStack1.stackSize - itemStack2.stackSize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return (itemStack1.getItemDamage() - itemStack2.getItemDamage());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return itemStack1.getItem().getUnlocalizedName(itemStack1).compareToIgnoreCase(itemStack2.getItem().getUnlocalizedName(itemStack2));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return Item.getIdFromItem(itemStack1.getItem()) - Item.getIdFromItem(itemStack2.getItem());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return itemStack1.getDisplayName().compareToIgnoreCase(itemStack2.getDisplayName());
|
||||
}
|
||||
}
|
||||
else if (itemStack1 != null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (itemStack2 != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Compares two ItemStacks for equality, testing itemID, metaData, stackSize, and their NBTTagCompounds (if they are
|
||||
* present)
|
||||
|
@ -100,7 +180,7 @@ public class ItemHelper
|
|||
*/
|
||||
public static boolean equals(ItemStack first, ItemStack second)
|
||||
{
|
||||
return (comparator.compare(first, second) == 0);
|
||||
return (displayNameComparator.compare(first, second) == 0);
|
||||
}
|
||||
|
||||
public static boolean equalsIgnoreStackSize(ItemStack itemStack1, ItemStack itemStack2)
|
||||
|
@ -139,7 +219,7 @@ public class ItemHelper
|
|||
|
||||
public static int compare(ItemStack itemStack1, ItemStack itemStack2)
|
||||
{
|
||||
return comparator.compare(itemStack1, itemStack2);
|
||||
return displayNameComparator.compare(itemStack1, itemStack2);
|
||||
}
|
||||
|
||||
public static String toString(ItemStack itemStack)
|
||||
|
@ -159,6 +239,40 @@ public class ItemHelper
|
|||
return "null";
|
||||
}
|
||||
|
||||
public static Set<ItemStack> filterByNameStartsWith(Set<ItemStack> unfilteredItemStackSet, String filterString)
|
||||
{
|
||||
Set<ItemStack> nameSortedSet = new TreeSet<ItemStack>(ItemHelper.displayNameComparator);
|
||||
|
||||
for (ItemStack itemStack : unfilteredItemStackSet)
|
||||
{
|
||||
String itemDisplayName = itemStack.getDisplayName().toLowerCase();
|
||||
|
||||
if (itemDisplayName.startsWith(filterString))
|
||||
{
|
||||
nameSortedSet.add(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
return nameSortedSet;
|
||||
}
|
||||
|
||||
public static Set<ItemStack> filterByNameContains(Set<ItemStack> unfilteredItemStackSet, String filterString)
|
||||
{
|
||||
Set<ItemStack> nameSortedSet = new TreeSet<ItemStack>(ItemHelper.displayNameComparator);
|
||||
|
||||
for (ItemStack itemStack : unfilteredItemStackSet)
|
||||
{
|
||||
String itemDisplayName = itemStack.getDisplayName().toLowerCase();
|
||||
|
||||
if (itemDisplayName.contains(filterString))
|
||||
{
|
||||
nameSortedSet.add(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
return nameSortedSet;
|
||||
}
|
||||
|
||||
public static boolean hasOwner(ItemStack itemStack)
|
||||
{
|
||||
return (NBTHelper.hasTag(itemStack, Names.NBT.OWNER_UUID_MOST_SIG) && NBTHelper.hasTag(itemStack, Names.NBT.OWNER_UUID_LEAST_SIG)) || NBTHelper.hasTag(itemStack, Names.NBT.OWNER);
|
||||
|
|
|
@ -15,6 +15,9 @@ general.transmutation.knowledge.template.comment=If true, new player's will have
|
|||
general.sound.soundMode.label=Sounds
|
||||
general.sound.soundMode.comment='All' plays mod sounds from all players, 'Self' only plays mod sounds from you, and 'None' plays no mod sounds
|
||||
|
||||
general.abilities.onlyLoadFile.label=Only load Abilities file
|
||||
general.abilities.onlyLoadFile.comment=Setting this to true means that Abilities are initially only loaded from file, rather than from both file and from other mods
|
||||
|
||||
# Keys
|
||||
key.categories.ee3=Equivalent Exchange 3
|
||||
key.charge=Charge
|
||||
|
|
Loading…
Reference in a new issue