Added in some basic events to the API (only the knowledge ones fire right now). These events are cancellable, and fire just before someone learns/forgets something. Cancelling the event will stop the change from happening. Also updated Waila and removed the need for CCC/CCL in mods/.
This commit is contained in:
parent
b6ea2905d0
commit
a317d47b3b
34
build.gradle
34
build.gradle
|
@ -21,17 +21,22 @@ apply plugin: 'curseforge'
|
|||
apply plugin: 'maven'
|
||||
|
||||
repositories {
|
||||
maven { // The repo from which to get waila
|
||||
name "Mobius Repo"
|
||||
url "http://mobiusstrip.eu/maven"
|
||||
}
|
||||
maven { // the repo from which to get NEI and stuff
|
||||
name 'CB Repo'
|
||||
url "http://chickenbones.net/maven/"
|
||||
}
|
||||
maven { // The repo from which to get waila
|
||||
name "Mobius Repo"
|
||||
url "http://mobiusstrip.eu/maven"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
compile "mcp.mobius.waila:Waila:1.5.6_dev1_1.7.10"
|
||||
compile('mcp.mobius.waila:Waila:1.5.11-RC2-NONEI_1.7.10') {
|
||||
exclude group: 'mcp.mobius.waila'
|
||||
}
|
||||
compile "codechicken:CodeChickenLib:1.7.10-1.1.3.136:dev"
|
||||
compile "codechicken:CodeChickenCore:1.7.10-1.0.6.43:dev"
|
||||
compile "codechicken:NotEnoughItems:1.7.10-1.0.4.105:dev"
|
||||
}
|
||||
|
||||
ext.configFile = file "build.properties"
|
||||
|
@ -171,25 +176,6 @@ task signJar(dependsOn: ["reobf", "devJar"]) {
|
|||
}
|
||||
}
|
||||
|
||||
task copyChicken(type: Copy, dependsOn: "extractUserDev") {
|
||||
from { configurations.compile }
|
||||
include "**/*Chicken*.jar", "**/*NotEnoughItems*.jar"
|
||||
exclude "**/CodeChickenLib*" // because CCC downloads it anyways.. -_-
|
||||
into file("./run/mods") // paralell to the assets dir
|
||||
mustRunAfter "deobfBinJar"
|
||||
mustRunAfter "repackMinecraft"
|
||||
}
|
||||
tasks.setupDevWorkspace.dependsOn copyChicken
|
||||
tasks.setupDecompWorkspace.dependsOn copyChicken
|
||||
|
||||
// Stop MCP from crashing the client on every start. -.-'
|
||||
runClient {
|
||||
args '--noCoreSearch'
|
||||
}
|
||||
runServer {
|
||||
args '--noCoreSearch'
|
||||
}
|
||||
|
||||
curse {
|
||||
dependsOn 'reobf'
|
||||
onlyIf { return project.hasProperty('ee3_curseforge_apikey') }
|
||||
|
|
|
@ -124,7 +124,7 @@ public class EquivalentExchange3
|
|||
WorldEventHandler.hasInitilialized = false;
|
||||
|
||||
EnergyValueRegistry.getInstance().save();
|
||||
TransmutationKnowledgeRegistry.getInstance().saveAll();
|
||||
TransmutationKnowledgeRegistry.getInstance().clear();
|
||||
AbilityRegistry.getInstance().save();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package com.pahimar.ee3.api.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public class AbilityEvent extends Event
|
||||
{
|
||||
public final Object object;
|
||||
|
||||
public AbilityEvent(Object object)
|
||||
{
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class SetLearnableEvent extends AbilityEvent
|
||||
{
|
||||
public SetLearnableEvent(Object object)
|
||||
{
|
||||
super(object);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SetNotLearnableEvent extends AbilityEvent
|
||||
{
|
||||
public SetNotLearnableEvent(Object object)
|
||||
{
|
||||
super(object);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SetRecoverableEvent extends AbilityEvent
|
||||
{
|
||||
public SetRecoverableEvent(Object object)
|
||||
{
|
||||
super(object);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SetNotRecoverableEvent extends AbilityEvent
|
||||
{
|
||||
public SetNotRecoverableEvent(Object object)
|
||||
{
|
||||
super(object);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.pahimar.ee3.api.event;
|
||||
|
||||
import com.pahimar.ee3.api.exchange.EnergyValue;
|
||||
import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public class EnergyValueEvent extends Event
|
||||
{
|
||||
public final Object object;
|
||||
public final EnergyValueRegistryProxy.Phase phase;
|
||||
public final EntityPlayer entityPlayer;
|
||||
|
||||
public EnergyValueEvent(Object object, EnergyValueRegistryProxy.Phase phase, EntityPlayer entityPlayer)
|
||||
{
|
||||
this.object = object;
|
||||
this.phase = phase;
|
||||
this.entityPlayer = entityPlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class SetEnergyValueEvent extends EnergyValueEvent
|
||||
{
|
||||
public final EnergyValue newEnergyValue;
|
||||
|
||||
public SetEnergyValueEvent(Object object, EnergyValue newEnergyValue, EnergyValueRegistryProxy.Phase phase, EntityPlayer entityPlayer)
|
||||
{
|
||||
super(object, phase, entityPlayer);
|
||||
this.newEnergyValue = newEnergyValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static class RemoveEnergyValueEvent extends EnergyValueEvent
|
||||
{
|
||||
public RemoveEnergyValueEvent(Object object, EnergyValueRegistryProxy.Phase phase, EntityPlayer entityPlayer)
|
||||
{
|
||||
super(object, phase, entityPlayer);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.pahimar.ee3.api.event;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraftforge.event.entity.EntityEvent;
|
||||
|
||||
public class EntityTransmutationEvent extends EntityEvent
|
||||
{
|
||||
public final Entity newEntity;
|
||||
|
||||
public EntityTransmutationEvent(Entity originalEntity, Entity newEntity)
|
||||
{
|
||||
super(originalEntity);
|
||||
this.newEntity = newEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package com.pahimar.ee3.api.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerKnowledgeEvent extends Event
|
||||
{
|
||||
public final UUID playerUUID;
|
||||
|
||||
private PlayerKnowledgeEvent(EntityPlayer entityPlayer)
|
||||
{
|
||||
this(entityPlayer.getUniqueID());
|
||||
}
|
||||
|
||||
private PlayerKnowledgeEvent(UUID playerUUID)
|
||||
{
|
||||
this.playerUUID = playerUUID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class PlayerLearnKnowledgeEvent extends PlayerKnowledgeEvent
|
||||
{
|
||||
public final ItemStack itemStack;
|
||||
|
||||
public PlayerLearnKnowledgeEvent(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
super(entityPlayer);
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
|
||||
public PlayerLearnKnowledgeEvent(UUID playerUUID, ItemStack itemStack)
|
||||
{
|
||||
super(playerUUID);
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PlayerForgetKnowledgeEvent extends PlayerKnowledgeEvent
|
||||
{
|
||||
public final ItemStack itemStack;
|
||||
|
||||
public PlayerForgetKnowledgeEvent(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
super(entityPlayer);
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
|
||||
public PlayerForgetKnowledgeEvent(UUID playerUUID, ItemStack itemStack)
|
||||
{
|
||||
super(playerUUID);
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PlayerForgetAllKnowledgeEvent extends PlayerKnowledgeEvent
|
||||
{
|
||||
public PlayerForgetAllKnowledgeEvent(EntityPlayer entityPlayer)
|
||||
{
|
||||
super(entityPlayer);
|
||||
}
|
||||
|
||||
public PlayerForgetAllKnowledgeEvent(UUID playerUUID)
|
||||
{
|
||||
super(playerUUID);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.pahimar.ee3.api.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class TabletTransmutationEvent extends Event
|
||||
{
|
||||
public final EntityPlayer entityPlayer;
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int z;
|
||||
public final ItemStack itemStack;
|
||||
|
||||
public TabletTransmutationEvent(EntityPlayer entityPlayer, int x, int y, int z, ItemStack itemStack)
|
||||
{
|
||||
this.entityPlayer = entityPlayer;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.pahimar.ee3.api.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class TemplateKnowledgeEvent extends Event
|
||||
{
|
||||
@Override
|
||||
public boolean isCancelable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class TemplateLearnKnowledgeEvent extends TemplateKnowledgeEvent
|
||||
{
|
||||
public final ItemStack itemStack;
|
||||
|
||||
public TemplateLearnKnowledgeEvent(ItemStack itemStack)
|
||||
{
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
}
|
||||
|
||||
public static class TemplateForgetKnowledgeEvent extends TemplateKnowledgeEvent
|
||||
{
|
||||
public final ItemStack itemStack;
|
||||
|
||||
public TemplateForgetKnowledgeEvent(ItemStack itemStack)
|
||||
{
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
}
|
||||
|
||||
public static class TemplateForgetAllKnowledgeEvent extends TemplateKnowledgeEvent
|
||||
{
|
||||
public TemplateForgetAllKnowledgeEvent()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.pahimar.ee3.api.event;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
|
||||
public class WorldTransmutationEvent extends BlockEvent
|
||||
{
|
||||
public final ForgeDirection sideHit;
|
||||
public final EntityLiving entityLiving;
|
||||
public final ItemStack heldItemStack;
|
||||
|
||||
public WorldTransmutationEvent(int x, int y, int z, World world, Block block, int blockMetaData, ForgeDirection sideHit, EntityLiving entityLiving)
|
||||
{
|
||||
super(x, y, z, world, block, blockMetaData);
|
||||
this.sideHit = sideHit;
|
||||
this.entityLiving = entityLiving;
|
||||
this.heldItemStack = entityLiving.getHeldItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -63,12 +63,17 @@ public final class EnergyValueRegistryProxy
|
|||
}
|
||||
|
||||
public static EnergyValue getEnergyValue(Object object, boolean strict)
|
||||
{
|
||||
return getEnergyValue(Phase.ALL, object, strict);
|
||||
}
|
||||
|
||||
public static EnergyValue getEnergyValue(Phase phase, Object object, boolean strict)
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
return EE3Wrapper.ee3mod.getEnergyValueRegistry().getEnergyValue(object, strict);
|
||||
return EE3Wrapper.ee3mod.getEnergyValueRegistry().getEnergyValue(phase, object, strict);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -140,6 +145,7 @@ public final class EnergyValueRegistryProxy
|
|||
{
|
||||
PRE_ASSIGNMENT,
|
||||
POST_ASSIGNMENT,
|
||||
RUNTIME,
|
||||
ALL
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,26 +150,6 @@ public class TransmutationKnowledgeRegistryProxy
|
|||
}
|
||||
}
|
||||
|
||||
public static void teachPlayerEverything(EntityPlayer entityPlayer)
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().teachPlayerEverything(entityPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
public static void teachPlayerEverything(UUID playerUUID)
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().teachPlayerEverything(playerUUID);
|
||||
}
|
||||
}
|
||||
|
||||
public static void makePlayerForget(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
init();
|
||||
|
@ -268,16 +248,6 @@ public class TransmutationKnowledgeRegistryProxy
|
|||
}
|
||||
}
|
||||
|
||||
public static void teachTemplateEverything()
|
||||
{
|
||||
init();
|
||||
|
||||
if (ee3Mod != null)
|
||||
{
|
||||
EE3Wrapper.ee3mod.getTransmutationKnowledgeRegistry().teachTemplateEverything();
|
||||
}
|
||||
}
|
||||
|
||||
public static void makeTemplateForget(ItemStack itemStack)
|
||||
{
|
||||
init();
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package com.pahimar.ee3.command;
|
||||
|
||||
import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandDebug extends CommandBase
|
||||
{
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return Names.Commands.DEBUG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender commandSender)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender commandSender, String[] args)
|
||||
{
|
||||
EnergyValueRegistryProxy.dumpEnergyValueRegistryToLog(EnergyValueRegistryProxy.Phase.PRE_ASSIGNMENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List addTabCompletionOptions(ICommandSender commandSender, String[] args)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -71,7 +71,6 @@ public class CommandEE extends CommandBase
|
|||
modCommands.add(new CommandPlayerForgetEverything());
|
||||
modCommands.add(new CommandPlayerForgetItem());
|
||||
modCommands.add(new CommandPlayerForgetCurrentItem());
|
||||
modCommands.add(new CommandTemplateLearnEverything());
|
||||
modCommands.add(new CommandTemplateLearnItem());
|
||||
modCommands.add(new CommandTemplateLearnCurrentItem());
|
||||
modCommands.add(new CommandTemplateForgetEverything());
|
||||
|
@ -82,6 +81,7 @@ public class CommandEE extends CommandBase
|
|||
modCommands.add(new CommandSetItemRecoverable());
|
||||
modCommands.add(new CommandSetItemNotRecoverable());
|
||||
modCommands.add(new CommandRunTest());
|
||||
modCommands.add(new CommandDebug());
|
||||
|
||||
for (CommandBase commandBase : modCommands)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.pahimar.ee3.command;
|
||||
|
||||
import com.pahimar.ee3.knowledge.TransmutationKnowledgeRegistry;
|
||||
import com.pahimar.ee3.api.knowledge.TransmutationKnowledgeRegistryProxy;
|
||||
import com.pahimar.ee3.reference.Messages;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
@ -48,7 +48,7 @@ public class CommandPlayerForgetCurrentItem extends CommandBase
|
|||
ItemStack itemStack = ((EntityPlayer) commandSender).getCurrentEquippedItem();
|
||||
if (itemStack != null)
|
||||
{
|
||||
TransmutationKnowledgeRegistry.getInstance().makePlayerForget(entityPlayer, itemStack);
|
||||
TransmutationKnowledgeRegistryProxy.makePlayerForget(entityPlayer, itemStack);
|
||||
func_152373_a(commandSender, this, Messages.Commands.PLAYER_FORGET_CURRENT_ITEM_SUCCESS, new Object[]{commandSender.getCommandSenderName(), entityPlayer.getCommandSenderName(), itemStack.func_151000_E()});
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.pahimar.ee3.command;
|
||||
|
||||
import com.pahimar.ee3.knowledge.TransmutationKnowledgeRegistry;
|
||||
import com.pahimar.ee3.api.knowledge.TransmutationKnowledgeRegistryProxy;
|
||||
import com.pahimar.ee3.reference.Messages;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
@ -44,7 +44,7 @@ public class CommandPlayerForgetEverything extends CommandBase
|
|||
|
||||
if (entityPlayer != null)
|
||||
{
|
||||
TransmutationKnowledgeRegistry.getInstance().makePlayerForgetEverything(entityPlayer);
|
||||
TransmutationKnowledgeRegistryProxy.makePlayerForgetEverything(entityPlayer);
|
||||
func_152373_a(commandSender, this, Messages.Commands.PLAYER_FORGET_EVERYTHING_SUCCESS, new Object[]{commandSender.getCommandSenderName(), entityPlayer.getCommandSenderName()});
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.pahimar.ee3.command;
|
||||
|
||||
import com.pahimar.ee3.knowledge.TransmutationKnowledgeRegistry;
|
||||
import com.pahimar.ee3.api.knowledge.TransmutationKnowledgeRegistryProxy;
|
||||
import com.pahimar.ee3.reference.Messages;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
@ -82,7 +82,7 @@ public class CommandPlayerForgetItem extends CommandBase
|
|||
}
|
||||
}
|
||||
|
||||
TransmutationKnowledgeRegistry.getInstance().makePlayerForget(entityPlayer, itemStack);
|
||||
TransmutationKnowledgeRegistryProxy.makePlayerForget(entityPlayer, itemStack);
|
||||
func_152373_a(commandSender, this, Messages.Commands.PLAYER_FORGET_ITEM_SUCCESS, new Object[]{commandSender.getCommandSenderName(), entityPlayer.getCommandSenderName(), itemStack.func_151000_E()});
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.pahimar.ee3.command;
|
||||
|
||||
import com.pahimar.ee3.api.knowledge.TransmutationKnowledgeRegistryProxy;
|
||||
import com.pahimar.ee3.knowledge.AbilityRegistry;
|
||||
import com.pahimar.ee3.knowledge.TransmutationKnowledgeRegistry;
|
||||
import com.pahimar.ee3.reference.Messages;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
@ -52,7 +52,7 @@ public class CommandPlayerLearnCurrentItem extends CommandBase
|
|||
{
|
||||
if (AbilityRegistry.getInstance().isLearnable(itemStack))
|
||||
{
|
||||
TransmutationKnowledgeRegistry.getInstance().teachPlayer(entityPlayer, itemStack);
|
||||
TransmutationKnowledgeRegistryProxy.teachPlayer(entityPlayer, itemStack);
|
||||
func_152373_a(commandSender, this, Messages.Commands.PLAYER_LEARN_CURRENT_ITEM_SUCCESS, new Object[]{commandSender.getCommandSenderName(), entityPlayer.getCommandSenderName(), itemStack.func_151000_E()});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.pahimar.ee3.command;
|
||||
|
||||
import com.pahimar.ee3.api.knowledge.TransmutationKnowledgeRegistryProxy;
|
||||
import com.pahimar.ee3.knowledge.AbilityRegistry;
|
||||
import com.pahimar.ee3.knowledge.TransmutationKnowledgeRegistry;
|
||||
import com.pahimar.ee3.reference.Messages;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
@ -85,7 +85,7 @@ public class CommandPlayerLearnItem extends CommandBase
|
|||
|
||||
if (AbilityRegistry.getInstance().isLearnable(itemStack))
|
||||
{
|
||||
TransmutationKnowledgeRegistry.getInstance().teachPlayer(entityPlayer, itemStack);
|
||||
TransmutationKnowledgeRegistryProxy.teachPlayer(entityPlayer, itemStack);
|
||||
func_152373_a(commandSender, this, Messages.Commands.PLAYER_LEARN_ITEM_SUCCESS, new Object[]{commandSender.getCommandSenderName(), entityPlayer.getCommandSenderName(), itemStack.func_151000_E()});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
package com.pahimar.ee3.command;
|
||||
|
||||
import com.pahimar.ee3.knowledge.TransmutationKnowledgeRegistry;
|
||||
import com.pahimar.ee3.reference.Messages;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
|
||||
public class CommandTemplateLearnEverything extends CommandBase
|
||||
{
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return Names.Commands.TEMPLATE_LEARN_EVERYTHING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender commandSender)
|
||||
{
|
||||
return Messages.Commands.TEMPLATE_LEARN_EVERYTHING_USAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender commandSender, String[] args)
|
||||
{
|
||||
TransmutationKnowledgeRegistry.getInstance().teachTemplateEverything();
|
||||
func_152373_a(commandSender, this, Messages.Commands.TEMPLATE_LEARN_EVERYTHING_SUCCESS, new Object[]{commandSender.getCommandSenderName()});
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@ import com.google.gson.*;
|
|||
import com.pahimar.ee3.api.exchange.EnergyValue;
|
||||
import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy;
|
||||
import com.pahimar.ee3.api.exchange.IEnergyValueProvider;
|
||||
import com.pahimar.ee3.knowledge.AbilityRegistry;
|
||||
import com.pahimar.ee3.recipe.RecipeRegistry;
|
||||
import com.pahimar.ee3.reference.Files;
|
||||
import com.pahimar.ee3.reference.Reference;
|
||||
|
@ -128,17 +127,28 @@ public class EnergyValueRegistry implements JsonSerializer<EnergyValueRegistry>,
|
|||
|
||||
public EnergyValue getEnergyValue(Object object)
|
||||
{
|
||||
return getEnergyValueFromMap(energyValueRegistry.stackMappings, object, false);
|
||||
return getEnergyValue(EnergyValueRegistryProxy.Phase.ALL, object, false);
|
||||
}
|
||||
|
||||
public EnergyValue getEnergyValue(Object object, boolean strict)
|
||||
{
|
||||
return getEnergyValueFromMap(energyValueRegistry.stackMappings, object, strict);
|
||||
return getEnergyValue(EnergyValueRegistryProxy.Phase.ALL, object, strict);
|
||||
}
|
||||
|
||||
public EnergyValue getEnergyValueForStack(Object object)
|
||||
public EnergyValue getEnergyValue(EnergyValueRegistryProxy.Phase phase, Object object, boolean strict)
|
||||
{
|
||||
return getEnergyValueForStack(object, false);
|
||||
if (phase == EnergyValueRegistryProxy.Phase.PRE_ASSIGNMENT)
|
||||
{
|
||||
return getEnergyValueFromMap(preAssignedMappings, object, strict);
|
||||
}
|
||||
else if (phase == EnergyValueRegistryProxy.Phase.POST_ASSIGNMENT)
|
||||
{
|
||||
return getEnergyValueFromMap(postAssignedMappings, object, strict);
|
||||
}
|
||||
else
|
||||
{
|
||||
return getEnergyValueFromMap(energyValueRegistry.stackMappings, object, strict);
|
||||
}
|
||||
}
|
||||
|
||||
public EnergyValue getEnergyValueForStack(Object object, boolean strict)
|
||||
|
@ -332,7 +342,6 @@ public class EnergyValueRegistry implements JsonSerializer<EnergyValueRegistry>,
|
|||
{
|
||||
runDynamicEnergyValueResolution();
|
||||
}
|
||||
AbilityRegistry.getInstance().discoverAllLearnableItemStacks();
|
||||
this.shouldRegenNextRestart = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,24 +3,22 @@ package com.pahimar.ee3.knowledge;
|
|||
import com.google.gson.*;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.pahimar.ee3.api.event.AbilityEvent;
|
||||
import com.pahimar.ee3.api.knowledge.AbilityRegistryProxy;
|
||||
import com.pahimar.ee3.exchange.EnergyValueRegistry;
|
||||
import com.pahimar.ee3.exchange.OreStack;
|
||||
import com.pahimar.ee3.exchange.WrappedStack;
|
||||
import com.pahimar.ee3.reference.Comparators;
|
||||
import com.pahimar.ee3.reference.Files;
|
||||
import com.pahimar.ee3.util.LoaderHelper;
|
||||
import com.pahimar.ee3.util.LogHelper;
|
||||
import com.pahimar.ee3.util.SerializationHelper;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
public class AbilityRegistry implements JsonSerializer<AbilityRegistry>, JsonDeserializer<AbilityRegistry>
|
||||
|
@ -32,7 +30,6 @@ public class AbilityRegistry implements JsonSerializer<AbilityRegistry>, JsonDes
|
|||
private boolean hasBeenModified;
|
||||
private Set<WrappedStack> notLearnableSet;
|
||||
private Set<WrappedStack> notRecoverableSet;
|
||||
private SortedSet<ItemStack> allLearnableItemStacks = new TreeSet<ItemStack>(Comparators.idComparator);
|
||||
|
||||
private AbilityRegistry()
|
||||
{
|
||||
|
@ -58,33 +55,6 @@ public class AbilityRegistry implements JsonSerializer<AbilityRegistry>, JsonDes
|
|||
notRecoverableSet = new TreeSet<WrappedStack>();
|
||||
}
|
||||
|
||||
public void discoverAllLearnableItemStacks()
|
||||
{
|
||||
this.allLearnableItemStacks = new TreeSet<ItemStack>(Comparators.idComparator);
|
||||
for (WrappedStack wrappedStack : EnergyValueRegistry.getInstance().getStackValueMap().keySet())
|
||||
{
|
||||
if (isLearnable(wrappedStack) && EnergyValueRegistry.getInstance().getEnergyValue(wrappedStack) != null)
|
||||
{
|
||||
if (wrappedStack.getWrappedObject() instanceof OreStack)
|
||||
{
|
||||
for (ItemStack itemStack : OreDictionary.getOres(((OreStack) wrappedStack.getWrappedObject()).oreName))
|
||||
{
|
||||
this.allLearnableItemStacks.add(itemStack);
|
||||
}
|
||||
}
|
||||
else if (wrappedStack.getWrappedObject() instanceof ItemStack)
|
||||
{
|
||||
this.allLearnableItemStacks.add((ItemStack) wrappedStack.getWrappedObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SortedSet<ItemStack> getAllLearnableItemStacks()
|
||||
{
|
||||
return allLearnableItemStacks;
|
||||
}
|
||||
|
||||
public Set<WrappedStack> getNotLearnableStacks()
|
||||
{
|
||||
return this.notLearnableSet;
|
||||
|
@ -115,10 +85,13 @@ public class AbilityRegistry implements JsonSerializer<AbilityRegistry>, JsonDes
|
|||
{
|
||||
WrappedStack wrappedStack = WrappedStack.wrap(object);
|
||||
|
||||
if (wrappedStack != null && notLearnableSet.remove(wrappedStack))
|
||||
if (wrappedStack != null && !MinecraftForge.EVENT_BUS.post(new AbilityEvent.SetLearnableEvent(object)))
|
||||
{
|
||||
hasBeenModified = true;
|
||||
LogHelper.trace(String.format("AbilityRegistry[%s]: Mod with ID '%s' set object %s as LEARNABLE", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack));
|
||||
if (notLearnableSet.remove(wrappedStack))
|
||||
{
|
||||
hasBeenModified = true;
|
||||
LogHelper.trace(String.format("AbilityRegistry[%s]: Mod with ID '%s' set object %s as LEARNABLE", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,10 +102,13 @@ public class AbilityRegistry implements JsonSerializer<AbilityRegistry>, JsonDes
|
|||
{
|
||||
WrappedStack wrappedStack = WrappedStack.wrap(object);
|
||||
|
||||
if (wrappedStack != null && notLearnableSet.add(wrappedStack))
|
||||
if (wrappedStack != null && !MinecraftForge.EVENT_BUS.post(new AbilityEvent.SetNotLearnableEvent(object)))
|
||||
{
|
||||
hasBeenModified = true;
|
||||
LogHelper.trace(String.format("AbilityRegistry[%s]: Mod with ID '%s' set object %s as NOT LEARNABLE", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack));
|
||||
if (notLearnableSet.add(wrappedStack))
|
||||
{
|
||||
hasBeenModified = true;
|
||||
LogHelper.trace(String.format("AbilityRegistry[%s]: Mod with ID '%s' set object %s as NOT LEARNABLE", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -159,10 +135,13 @@ public class AbilityRegistry implements JsonSerializer<AbilityRegistry>, JsonDes
|
|||
{
|
||||
WrappedStack wrappedStack = WrappedStack.wrap(object);
|
||||
|
||||
if (wrappedStack != null && notRecoverableSet.remove(wrappedStack))
|
||||
if (wrappedStack != null && !MinecraftForge.EVENT_BUS.post(new AbilityEvent.SetRecoverableEvent(object)))
|
||||
{
|
||||
hasBeenModified = true;
|
||||
LogHelper.trace(String.format("AbilityRegistry[%s]: Mod with ID '%s' set object %s as RECOVERABLE", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack));
|
||||
if (notRecoverableSet.remove(wrappedStack))
|
||||
{
|
||||
hasBeenModified = true;
|
||||
LogHelper.trace(String.format("AbilityRegistry[%s]: Mod with ID '%s' set object %s as RECOVERABLE", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -173,10 +152,13 @@ public class AbilityRegistry implements JsonSerializer<AbilityRegistry>, JsonDes
|
|||
{
|
||||
WrappedStack wrappedStack = WrappedStack.wrap(object);
|
||||
|
||||
if (wrappedStack != null && notRecoverableSet.add(wrappedStack))
|
||||
if (wrappedStack != null && !MinecraftForge.EVENT_BUS.post(new AbilityEvent.SetNotRecoverableEvent(object)))
|
||||
{
|
||||
hasBeenModified = true;
|
||||
LogHelper.trace(String.format("AbilityRegistry[%s]: Mod with ID '%s' set object %s as NOT RECOVERABLE", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack));
|
||||
if (notRecoverableSet.add(wrappedStack))
|
||||
{
|
||||
hasBeenModified = true;
|
||||
LogHelper.trace(String.format("AbilityRegistry[%s]: Mod with ID '%s' set object %s as NOT RECOVERABLE", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,23 +5,18 @@ import com.google.gson.stream.JsonReader;
|
|||
import com.google.gson.stream.JsonWriter;
|
||||
import com.pahimar.ee3.exchange.JsonItemStack;
|
||||
import com.pahimar.ee3.reference.Comparators;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import com.pahimar.ee3.util.FilterUtils;
|
||||
import com.pahimar.ee3.util.INBTTaggable;
|
||||
import com.pahimar.ee3.util.ItemHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
|
||||
public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<TransmutationKnowledge>, JsonDeserializer<TransmutationKnowledge>
|
||||
public class TransmutationKnowledge implements JsonSerializer<TransmutationKnowledge>, JsonDeserializer<TransmutationKnowledge>
|
||||
{
|
||||
private static final Gson jsonSerializer = (new GsonBuilder()).setPrettyPrinting().registerTypeAdapter(TransmutationKnowledge.class, new TransmutationKnowledge()).create();
|
||||
private boolean canTransmuteEverything;
|
||||
private Set<ItemStack> knownTransmutations;
|
||||
private boolean hasBeenModified = false;
|
||||
|
||||
|
@ -32,12 +27,6 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
|
||||
public TransmutationKnowledge(Collection<ItemStack> knownTransmutations)
|
||||
{
|
||||
this(knownTransmutations, false);
|
||||
}
|
||||
|
||||
public TransmutationKnowledge(Collection<ItemStack> knownTransmutations, boolean canTransmuteEverything)
|
||||
{
|
||||
this.canTransmuteEverything = canTransmuteEverything;
|
||||
this.knownTransmutations = new TreeSet<ItemStack>(Comparators.idComparator);
|
||||
this.knownTransmutations.addAll(knownTransmutations);
|
||||
hasBeenModified = false;
|
||||
|
@ -48,49 +37,16 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
this(Arrays.asList(knownTransmutations));
|
||||
}
|
||||
|
||||
public TransmutationKnowledge(NBTTagCompound nbtTagCompound)
|
||||
{
|
||||
canTransmuteEverything = false;
|
||||
this.knownTransmutations = new TreeSet<ItemStack>(Comparators.idComparator);
|
||||
this.readFromNBT(nbtTagCompound);
|
||||
hasBeenModified = false;
|
||||
}
|
||||
|
||||
public boolean isKnown(ItemStack itemStack)
|
||||
{
|
||||
if (canTransmuteEverything)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack unitItemStack = itemStack.copy();
|
||||
unitItemStack.stackSize = 1;
|
||||
return this.knownTransmutations.contains(unitItemStack);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canTransmuteEverything()
|
||||
{
|
||||
return canTransmuteEverything;
|
||||
}
|
||||
|
||||
public void setCanTransmuteEverything(boolean canTransmuteEverything)
|
||||
{
|
||||
this.canTransmuteEverything = canTransmuteEverything;
|
||||
hasBeenModified = true;
|
||||
ItemStack unitItemStack = itemStack.copy();
|
||||
unitItemStack.stackSize = 1;
|
||||
return this.knownTransmutations.contains(unitItemStack);
|
||||
}
|
||||
|
||||
public Set<ItemStack> getKnownTransmutations()
|
||||
{
|
||||
if (canTransmuteEverything)
|
||||
{
|
||||
return AbilityRegistry.getInstance().getAllLearnableItemStacks();
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.knownTransmutations;
|
||||
}
|
||||
return this.knownTransmutations;
|
||||
}
|
||||
|
||||
public boolean learnTransmutation(ItemStack itemStack)
|
||||
|
@ -124,7 +80,6 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
public void forgetAllTransmutations()
|
||||
{
|
||||
this.knownTransmutations.clear();
|
||||
canTransmuteEverything = false;
|
||||
hasBeenModified = true;
|
||||
}
|
||||
|
||||
|
@ -143,63 +98,6 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
return FilterUtils.filterByNameContains(getKnownTransmutations(), filterString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound)
|
||||
{
|
||||
if (nbtTagCompound != null && nbtTagCompound.hasKey(Names.NBT.ITEM_TRANSMUTATION_KNOWLEDGE))
|
||||
{
|
||||
if (nbtTagCompound.hasKey(Names.NBT.ITEM_TRANSMUTATION_KNOWLEDGE))
|
||||
{
|
||||
NBTTagList tagList = nbtTagCompound.getTagList(Names.NBT.ITEM_TRANSMUTATION_KNOWLEDGE, 10);
|
||||
knownTransmutations = new TreeSet<ItemStack>(Comparators.idComparator);
|
||||
for (int i = 0; i < tagList.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
|
||||
ItemStack itemStack = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||
knownTransmutations.add(itemStack);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
knownTransmutations = new TreeSet<ItemStack>(Comparators.idComparator);
|
||||
}
|
||||
|
||||
if (nbtTagCompound.hasKey(Names.NBT.CAN_TRANSMUTE_ANYTHING))
|
||||
{
|
||||
canTransmuteEverything = nbtTagCompound.getBoolean(Names.NBT.CAN_TRANSMUTE_ANYTHING);
|
||||
}
|
||||
else
|
||||
{
|
||||
canTransmuteEverything = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
knownTransmutations = new TreeSet<ItemStack>(Comparators.idComparator);
|
||||
canTransmuteEverything = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtTagCompound)
|
||||
{
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (ItemStack itemStack : knownTransmutations)
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
itemStack.writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
nbtTagCompound.setTag(Names.NBT.ITEM_TRANSMUTATION_KNOWLEDGE, tagList);
|
||||
nbtTagCompound.setBoolean(Names.NBT.CAN_TRANSMUTE_ANYTHING, canTransmuteEverything);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTagLabel()
|
||||
{
|
||||
return "TransmutationKnowledge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
@ -245,18 +143,8 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
{
|
||||
JsonObject jsonObject = (JsonObject) json;
|
||||
|
||||
boolean canTransmuteEverything;
|
||||
Set<ItemStack> itemStacks = new TreeSet<ItemStack>(Comparators.idComparator);
|
||||
|
||||
if (jsonObject.has("canTransmuteEverything") && jsonObject.get("canTransmuteEverything").isJsonPrimitive())
|
||||
{
|
||||
canTransmuteEverything = jsonObject.get("canTransmuteEverything").getAsBoolean();
|
||||
}
|
||||
else
|
||||
{
|
||||
canTransmuteEverything = false;
|
||||
}
|
||||
|
||||
if (jsonObject.has("knownTransmutations") && jsonObject.get("knownTransmutations").isJsonArray())
|
||||
{
|
||||
JsonArray jsonArray = (JsonArray) jsonObject.get("knownTransmutations");
|
||||
|
@ -294,7 +182,7 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
}
|
||||
}
|
||||
|
||||
return new TransmutationKnowledge(itemStacks, canTransmuteEverything);
|
||||
return new TransmutationKnowledge(itemStacks);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -305,8 +193,6 @@ public class TransmutationKnowledge implements INBTTaggable, JsonSerializer<Tran
|
|||
{
|
||||
JsonObject jsonTransmutationKnowledge = new JsonObject();
|
||||
|
||||
jsonTransmutationKnowledge.addProperty("canTransmuteEverything", transmutationKnowledge.canTransmuteEverything());
|
||||
|
||||
JsonArray knownTransmutations = new JsonArray();
|
||||
for (ItemStack itemStack : transmutationKnowledge.getKnownTransmutations())
|
||||
{
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package com.pahimar.ee3.knowledge;
|
||||
|
||||
import com.pahimar.ee3.api.event.PlayerKnowledgeEvent;
|
||||
import com.pahimar.ee3.api.event.TemplateKnowledgeEvent;
|
||||
import com.pahimar.ee3.reference.Files;
|
||||
import com.pahimar.ee3.util.FilterUtils;
|
||||
import com.pahimar.ee3.util.SerializationHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
|
@ -14,8 +17,7 @@ import java.util.UUID;
|
|||
public class TransmutationKnowledgeRegistry
|
||||
{
|
||||
private static TransmutationKnowledgeRegistry transmutationKnowledgeRegistry = null;
|
||||
private static File playerKnowledgeDirectory;
|
||||
private static File dataKnowledgeDirectory;
|
||||
private static File playerKnowledgeDirectory, dataKnowledgeDirectory;
|
||||
private static TransmutationKnowledge templateKnowledge;
|
||||
private static HashMap<UUID, TransmutationKnowledge> playerKnowledgeMap;
|
||||
|
||||
|
@ -47,11 +49,7 @@ public class TransmutationKnowledgeRegistry
|
|||
return templateKnowledge;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/** Template Related Transmutation Knowledge **/
|
||||
/**
|
||||
* *************************************************************************
|
||||
*/
|
||||
/* Template Related Transmutation Knowledge */
|
||||
public Set<ItemStack> getTemplatesKnownTransmutations()
|
||||
{
|
||||
if (templateKnowledge == null)
|
||||
|
@ -113,24 +111,11 @@ public class TransmutationKnowledgeRegistry
|
|||
loadTemplateKnowledgeFromDisk();
|
||||
}
|
||||
|
||||
if (canTemplateLearn(itemStack))
|
||||
if (canTemplateLearn(itemStack) && !MinecraftForge.EVENT_BUS.post(new TemplateKnowledgeEvent.TemplateLearnKnowledgeEvent(itemStack)))
|
||||
{
|
||||
templateKnowledge.learnTransmutation(itemStack);
|
||||
saveTemplateKnowledgeToDisk();
|
||||
}
|
||||
|
||||
saveTemplateKnowledgeToDisk();
|
||||
}
|
||||
|
||||
public void teachTemplateEverything()
|
||||
{
|
||||
if (templateKnowledge == null)
|
||||
{
|
||||
loadTemplateKnowledgeFromDisk();
|
||||
}
|
||||
|
||||
templateKnowledge.setCanTransmuteEverything(true);
|
||||
|
||||
saveTemplateKnowledgeToDisk();
|
||||
}
|
||||
|
||||
public void makeTemplateForget(ItemStack itemStack)
|
||||
|
@ -140,12 +125,11 @@ public class TransmutationKnowledgeRegistry
|
|||
loadTemplateKnowledgeFromDisk();
|
||||
}
|
||||
|
||||
if (doesTemplateKnow(itemStack))
|
||||
if (doesTemplateKnow(itemStack) && !MinecraftForge.EVENT_BUS.post(new TemplateKnowledgeEvent.TemplateForgetKnowledgeEvent(itemStack)))
|
||||
{
|
||||
templateKnowledge.forgetTransmutation(itemStack);
|
||||
saveTemplateKnowledgeToDisk();
|
||||
}
|
||||
|
||||
saveTemplateKnowledgeToDisk();
|
||||
}
|
||||
|
||||
public void makeTemplateForgetEverything()
|
||||
|
@ -155,16 +139,14 @@ public class TransmutationKnowledgeRegistry
|
|||
loadTemplateKnowledgeFromDisk();
|
||||
}
|
||||
|
||||
templateKnowledge.forgetAllTransmutations();
|
||||
|
||||
saveTemplateKnowledgeToDisk();
|
||||
if (!MinecraftForge.EVENT_BUS.post(new TemplateKnowledgeEvent.TemplateForgetAllKnowledgeEvent()))
|
||||
{
|
||||
templateKnowledge.forgetAllTransmutations();
|
||||
saveTemplateKnowledgeToDisk();
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/** Player Related Transmutation Knowledge **/
|
||||
/**
|
||||
* *************************************************************************
|
||||
*/
|
||||
/* Player Related Transmutation Knowledge */
|
||||
public Set<ItemStack> getPlayersKnownTransmutations(EntityPlayer entityPlayer)
|
||||
{
|
||||
if (entityPlayer != null)
|
||||
|
@ -311,7 +293,7 @@ public class TransmutationKnowledgeRegistry
|
|||
if (playerUUID != null && itemStack != null && canPlayerLearn(playerUUID, itemStack))
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(playerUUID);
|
||||
if (playerKnowledgeMap.containsKey(playerUUID))
|
||||
if (playerKnowledgeMap.containsKey(playerUUID) && !MinecraftForge.EVENT_BUS.post(new PlayerKnowledgeEvent.PlayerLearnKnowledgeEvent(playerUUID, itemStack)))
|
||||
{
|
||||
playerKnowledgeMap.get(playerUUID).learnTransmutation(itemStack);
|
||||
savePlayerKnowledgeToDisk(playerUUID);
|
||||
|
@ -319,49 +301,6 @@ public class TransmutationKnowledgeRegistry
|
|||
}
|
||||
}
|
||||
|
||||
public void teachPlayerEverything(EntityPlayer entityPlayer)
|
||||
{
|
||||
if (entityPlayer != null)
|
||||
{
|
||||
teachPlayerEverything(entityPlayer.getUniqueID());
|
||||
}
|
||||
}
|
||||
|
||||
public void teachPlayerEverything(UUID playerUUID)
|
||||
{
|
||||
if (playerUUID != null)
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(playerUUID);
|
||||
|
||||
if (playerKnowledgeMap.containsKey(playerUUID))
|
||||
{
|
||||
playerKnowledgeMap.get(playerUUID).setCanTransmuteEverything(true);
|
||||
savePlayerKnowledgeToDisk(playerUUID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setPlayerCanTransmuteEverything(EntityPlayer entityPlayer, boolean canTransmuteEverything)
|
||||
{
|
||||
if (entityPlayer != null)
|
||||
{
|
||||
setPlayerCanTransmuteEverything(entityPlayer.getUniqueID(), canTransmuteEverything);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPlayerCanTransmuteEverything(UUID playerUUID, boolean canTransmuteEverything)
|
||||
{
|
||||
if (playerUUID != null)
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(playerUUID);
|
||||
if (playerKnowledgeMap.containsKey(playerUUID))
|
||||
{
|
||||
playerKnowledgeMap.get(playerUUID).setCanTransmuteEverything(canTransmuteEverything);
|
||||
savePlayerKnowledgeToDisk(playerUUID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void makePlayerForget(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
if (entityPlayer != null)
|
||||
|
@ -375,7 +314,7 @@ public class TransmutationKnowledgeRegistry
|
|||
if (playerUUID != null && itemStack != null && doesPlayerKnow(playerUUID, itemStack))
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(playerUUID);
|
||||
if (playerKnowledgeMap.containsKey(playerUUID))
|
||||
if (playerKnowledgeMap.containsKey(playerUUID) && !MinecraftForge.EVENT_BUS.post(new PlayerKnowledgeEvent.PlayerForgetKnowledgeEvent(playerUUID, itemStack)))
|
||||
{
|
||||
playerKnowledgeMap.get(playerUUID).forgetTransmutation(itemStack);
|
||||
savePlayerKnowledgeToDisk(playerUUID);
|
||||
|
@ -396,7 +335,7 @@ public class TransmutationKnowledgeRegistry
|
|||
if (playerUUID != null)
|
||||
{
|
||||
loadPlayerFromDiskIfNeeded(playerUUID);
|
||||
if (playerKnowledgeMap.containsKey(playerUUID))
|
||||
if (playerKnowledgeMap.containsKey(playerUUID) && !MinecraftForge.EVENT_BUS.post(new PlayerKnowledgeEvent.PlayerForgetAllKnowledgeEvent(playerUUID)))
|
||||
{
|
||||
playerKnowledgeMap.get(playerUUID).forgetAllTransmutations();
|
||||
savePlayerKnowledgeToDisk(playerUUID);
|
||||
|
@ -404,11 +343,7 @@ public class TransmutationKnowledgeRegistry
|
|||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/** Serialization **/
|
||||
/**
|
||||
* *************************************************************************
|
||||
*/
|
||||
/* Serialization */
|
||||
public void loadTemplateKnowledgeFromDisk()
|
||||
{
|
||||
if (dataKnowledgeDirectory != null)
|
||||
|
@ -534,4 +469,10 @@ public class TransmutationKnowledgeRegistry
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
saveAll();
|
||||
this.transmutationKnowledgeRegistry = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,6 @@ public class Names
|
|||
{
|
||||
public static final String ITEMS = "Items";
|
||||
public static final String ITEM_TRANSMUTATION_KNOWLEDGE = "transmutationKnowledge";
|
||||
public static final String CAN_TRANSMUTE_ANYTHING = "CAN_TRANSMUTE_ANYTHING";
|
||||
public static final String CHARGE_LEVEL = "chargeLevel";
|
||||
public static final String MODE = "mode";
|
||||
public static final String CRAFTING_GUI_OPEN = "craftingGuiOpen";
|
||||
|
@ -164,6 +163,7 @@ public class Names
|
|||
public static final String SET_ITEM_RECOVERABLE = "set-item-recoverable";
|
||||
public static final String SET_ITEM_NOT_RECOVERABLE = "set-item-not-recoverable";
|
||||
public static final String RUN_TEST = "run-tests";
|
||||
public static final String DEBUG = "debug";
|
||||
}
|
||||
|
||||
public static final class AlchemyArrays
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.pahimar.ee3.tileentity;
|
||||
|
||||
import com.pahimar.ee3.api.knowledge.TransmutationKnowledgeRegistryProxy;
|
||||
import com.pahimar.ee3.knowledge.AbilityRegistry;
|
||||
import com.pahimar.ee3.knowledge.TransmutationKnowledgeRegistry;
|
||||
import com.pahimar.ee3.network.PacketHandler;
|
||||
import com.pahimar.ee3.network.message.MessageTileEntityResearchStation;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
|
@ -215,7 +215,7 @@ public class TileEntityResearchStation extends TileEntityEE implements IInventor
|
|||
|
||||
if (alchemicalTome != null && playerUUID != null)
|
||||
{
|
||||
return TransmutationKnowledgeRegistry.getInstance().canPlayerLearn(playerUUID, inventory[ITEM_SLOT_INVENTORY_INDEX]);
|
||||
return TransmutationKnowledgeRegistryProxy.canPlayerLearn(playerUUID, inventory[ITEM_SLOT_INVENTORY_INDEX]);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -228,7 +228,7 @@ public class TileEntityResearchStation extends TileEntityEE implements IInventor
|
|||
|
||||
if (alchemicalTome != null && playerUUID != null)
|
||||
{
|
||||
return TransmutationKnowledgeRegistry.getInstance().doesPlayerKnow(playerUUID, inventory[ITEM_SLOT_INVENTORY_INDEX]);
|
||||
return TransmutationKnowledgeRegistryProxy.doesPlayerKnow(playerUUID, inventory[ITEM_SLOT_INVENTORY_INDEX]);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -238,7 +238,7 @@ public class TileEntityResearchStation extends TileEntityEE implements IInventor
|
|||
{
|
||||
if (this.canLearnItemStack())
|
||||
{
|
||||
TransmutationKnowledgeRegistry.getInstance().teachPlayer(ItemHelper.getOwnerUUID(inventory[TOME_SLOT_INVENTORY_INDEX]), inventory[ITEM_SLOT_INVENTORY_INDEX]);
|
||||
TransmutationKnowledgeRegistryProxy.teachPlayer(ItemHelper.getOwnerUUID(inventory[TOME_SLOT_INVENTORY_INDEX]), inventory[ITEM_SLOT_INVENTORY_INDEX]);
|
||||
|
||||
this.inventory[ITEM_SLOT_INVENTORY_INDEX].stackSize--;
|
||||
|
||||
|
|
|
@ -5,8 +5,12 @@ import com.pahimar.ee3.reference.Messages;
|
|||
import com.pahimar.ee3.reference.Names;
|
||||
import com.pahimar.ee3.tileentity.*;
|
||||
import mcp.mobius.waila.api.*;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -144,6 +148,12 @@ public class WailaDataProvider implements IWailaDataProvider
|
|||
return currentTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void callbackRegister(IWailaRegistrar registrar)
|
||||
{
|
||||
registrar.registerHeadProvider(new WailaDataProvider(), TileEntityAludel.class);
|
||||
|
|
|
@ -9,7 +9,7 @@ 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
|
||||
|
||||
general.energyvalues.regenerateEnergyValuesWhen.label=Regenerate EnergyValues
|
||||
general.energyvalues.regenerateEnergyValuesWhen.comment=When to regenerate EnergyValues. Options are "When Mods Change" (when mods are added, removed, or updated) or "Never" (only generate the first time).
|
||||
general.energyvalues.regenerateEnergyValuesWhen.comment=When to regenerate EnergyValues. Options are "Always" (every time Minecraft starts), "When Mods Change" (when mods are added, removed, or updated) or "Never" (only generate the first time).
|
||||
|
||||
# Keys
|
||||
key.categories.ee3=Equivalent Exchange 3
|
||||
|
@ -139,8 +139,6 @@ commands.ee3.player-forget-item.usage=/ee3 player-forget-item <playername> <item
|
|||
commands.ee3.player-forget-item.success=%s made %s forget how to transmute %s
|
||||
commands.ee3.player-forget-current-item.usage=/ee3 player-forget-current-item <playername>
|
||||
commands.ee3.player-forget-current-item.success=%s made %s forget how to transmute %s
|
||||
commands.ee3.template-learn-everything.usage=/ee3 template-learn-everything
|
||||
commands.ee3.template-learn-everything.success=%s taught the knowledge template how to transmute everything
|
||||
commands.ee3.template-learn-item.usage=/ee3 template-learn-item <item> <data> [dataTag]
|
||||
commands.ee3.template-learn-item.success=%s taught the knowledge template how to transmute %s
|
||||
commands.ee3.template-learn-current-item.usage=/ee3 template-learn-current-item
|
||||
|
|
Loading…
Reference in New Issue