Added rudimentary saving for rituals
This commit is contained in:
parent
3edfc3a8ac
commit
c26b7851a8
|
@ -19,6 +19,7 @@ public class Constants
|
||||||
public static final String ORB_TIER = "orbTier";
|
public static final String ORB_TIER = "orbTier";
|
||||||
public static final String CURRENT_ESSENCE = "currentEssence";
|
public static final String CURRENT_ESSENCE = "currentEssence";
|
||||||
public static final String CURRENT_RITUAL = "currentRitual";
|
public static final String CURRENT_RITUAL = "currentRitual";
|
||||||
|
public static final String CURRENT_RITUAL_TAG = "currentRitualTag";
|
||||||
public static final String IS_RUNNING = "isRunning";
|
public static final String IS_RUNNING = "isRunning";
|
||||||
public static final String RUNTIME = "runtime";
|
public static final String RUNTIME = "runtime";
|
||||||
public static final String DIRECTION = "direction";
|
public static final String DIRECTION = "direction";
|
||||||
|
|
|
@ -10,6 +10,7 @@ import lombok.RequiredArgsConstructor;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.BlockPos;
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
@ -45,6 +46,16 @@ public abstract class Ritual
|
||||||
this(name, crystalLevel, activationCost, null, unlocalizedName);
|
this(name, crystalLevel, activationCost, null, unlocalizedName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void readFromNBT(NBTTagCompound tag)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeToNBT(NBTTagCompound tag)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the player attempts to activate the ritual.
|
* Called when the player attempts to activate the ritual.
|
||||||
*
|
*
|
||||||
|
|
|
@ -62,6 +62,14 @@ public class TileMasterRitualStone extends TileEntity implements IMasterRitualSt
|
||||||
super.readFromNBT(tag);
|
super.readFromNBT(tag);
|
||||||
owner = tag.getString(Constants.NBT.OWNER_UUID);
|
owner = tag.getString(Constants.NBT.OWNER_UUID);
|
||||||
currentRitual = RitualRegistry.getRitualForId(tag.getString(Constants.NBT.CURRENT_RITUAL));
|
currentRitual = RitualRegistry.getRitualForId(tag.getString(Constants.NBT.CURRENT_RITUAL));
|
||||||
|
if (currentRitual != null)
|
||||||
|
{
|
||||||
|
NBTTagCompound ritualTag = tag.getCompoundTag(Constants.NBT.CURRENT_RITUAL_TAG);
|
||||||
|
if (ritualTag != null)
|
||||||
|
{
|
||||||
|
currentRitual.readFromNBT(ritualTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
active = tag.getBoolean(Constants.NBT.IS_RUNNING);
|
active = tag.getBoolean(Constants.NBT.IS_RUNNING);
|
||||||
activeTime = tag.getInteger(Constants.NBT.RUNTIME);
|
activeTime = tag.getInteger(Constants.NBT.RUNTIME);
|
||||||
direction = EnumFacing.VALUES[tag.getInteger(Constants.NBT.DIRECTION)];
|
direction = EnumFacing.VALUES[tag.getInteger(Constants.NBT.DIRECTION)];
|
||||||
|
@ -74,6 +82,12 @@ public class TileMasterRitualStone extends TileEntity implements IMasterRitualSt
|
||||||
String ritualId = RitualRegistry.getIdForRitual(getCurrentRitual());
|
String ritualId = RitualRegistry.getIdForRitual(getCurrentRitual());
|
||||||
tag.setString(Constants.NBT.OWNER_UUID, Strings.isNullOrEmpty(getOwner()) ? "" : getOwner());
|
tag.setString(Constants.NBT.OWNER_UUID, Strings.isNullOrEmpty(getOwner()) ? "" : getOwner());
|
||||||
tag.setString(Constants.NBT.CURRENT_RITUAL, Strings.isNullOrEmpty(ritualId) ? "" : ritualId);
|
tag.setString(Constants.NBT.CURRENT_RITUAL, Strings.isNullOrEmpty(ritualId) ? "" : ritualId);
|
||||||
|
if (currentRitual != null)
|
||||||
|
{
|
||||||
|
NBTTagCompound ritualTag = new NBTTagCompound();
|
||||||
|
currentRitual.writeToNBT(ritualTag);
|
||||||
|
tag.setTag(Constants.NBT.CURRENT_RITUAL_TAG, ritualTag);
|
||||||
|
}
|
||||||
tag.setBoolean(Constants.NBT.IS_RUNNING, isActive());
|
tag.setBoolean(Constants.NBT.IS_RUNNING, isActive());
|
||||||
tag.setInteger(Constants.NBT.RUNTIME, getActiveTime());
|
tag.setInteger(Constants.NBT.RUNTIME, getActiveTime());
|
||||||
tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex());
|
tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex());
|
||||||
|
|
Loading…
Reference in a new issue