Reorganized the AlchemyArrayEffects so it is easier to make more unique arrays. Also fixed an NPE when crafting sigils.
This commit is contained in:
parent
587e94d197
commit
c5f0333aac
6 changed files with 138 additions and 25 deletions
|
@ -1,18 +1,20 @@
|
|||
package WayofTime.bloodmagic.tile;
|
||||
|
||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
||||
import WayofTime.bloodmagic.api.registry.AlchemyArrayRecipeRegistry;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.util.ITickable;
|
||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
||||
import WayofTime.bloodmagic.api.registry.AlchemyArrayRecipeRegistry;
|
||||
|
||||
public class TileAlchemyArray extends TileInventory implements ITickable
|
||||
{
|
||||
public boolean isActive = false;
|
||||
public int activeCounter = 0;
|
||||
|
||||
private String key = "";
|
||||
private AlchemyArrayEffect arrayEffect;
|
||||
|
||||
public TileAlchemyArray()
|
||||
{
|
||||
super(2, "alchemyArray");
|
||||
|
@ -24,6 +26,14 @@ public class TileAlchemyArray extends TileInventory implements ITickable
|
|||
super.readFromNBT(tagCompound);
|
||||
this.isActive = tagCompound.getBoolean("isActive");
|
||||
this.activeCounter = tagCompound.getInteger("activeCounter");
|
||||
this.key = tagCompound.getString("key");
|
||||
|
||||
NBTTagCompound arrayTag = tagCompound.getCompoundTag("arrayTag");
|
||||
arrayEffect = AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(key);
|
||||
if (arrayEffect != null)
|
||||
{
|
||||
arrayEffect.readFromNBT(arrayTag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,6 +42,15 @@ public class TileAlchemyArray extends TileInventory implements ITickable
|
|||
super.writeToNBT(tagCompound);
|
||||
tagCompound.setBoolean("isActive", isActive);
|
||||
tagCompound.setInteger("activeCounter", activeCounter);
|
||||
tagCompound.setString("key", key);
|
||||
|
||||
NBTTagCompound arrayTag = new NBTTagCompound();
|
||||
if (arrayEffect != null)
|
||||
{
|
||||
arrayEffect.writeToNBT(arrayTag);
|
||||
}
|
||||
tagCompound.setTag("arrayTag", arrayTag);
|
||||
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
|
@ -51,6 +70,8 @@ public class TileAlchemyArray extends TileInventory implements ITickable
|
|||
{
|
||||
isActive = false;
|
||||
activeCounter = 0;
|
||||
arrayEffect = null;
|
||||
key = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,10 +79,35 @@ public class TileAlchemyArray extends TileInventory implements ITickable
|
|||
{
|
||||
AlchemyArrayEffect effect = AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(this.getStackInSlot(0), this.getStackInSlot(1));
|
||||
if (effect != null)
|
||||
{
|
||||
if (arrayEffect == null)
|
||||
{
|
||||
arrayEffect = effect;
|
||||
key = effect.getKey();
|
||||
} else
|
||||
{
|
||||
String effectKey = effect.getKey();
|
||||
if (effectKey.equals(key))
|
||||
{
|
||||
//Good! Moving on.
|
||||
} else
|
||||
{
|
||||
//Something has changed, therefore we have to move our stuffs.
|
||||
//TODO: Add an AlchemyArrayEffect.onBreak(); ?
|
||||
arrayEffect = effect;
|
||||
key = effect.getKey();
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (arrayEffect != null)
|
||||
{
|
||||
isActive = true;
|
||||
|
||||
if (effect.update(this, this.activeCounter))
|
||||
if (arrayEffect.update(this, this.activeCounter))
|
||||
{
|
||||
this.decrStackSize(0, 1);
|
||||
this.decrStackSize(1, 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue