Did more work on the Ritual Reader - functionally, it is at about 80%.
This commit is contained in:
parent
30f233b81a
commit
057a951732
|
@ -1,14 +1,16 @@
|
|||
package WayofTime.bloodmagic.api.ritual;
|
||||
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||
{
|
||||
public List<BlockPos> getContainedPositions(BlockPos pos)
|
||||
|
@ -27,6 +29,16 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
|
||||
public abstract void resetIterator();
|
||||
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method changes the area descriptor so that its range matches the two
|
||||
* blocks that are selected. When implementing this method, assume that
|
||||
|
@ -189,6 +201,24 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
resetIterator();
|
||||
resetCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
minimumOffset = new BlockPos(tag.getInteger(Constants.NBT.X_COORD + "min"), tag.getInteger(Constants.NBT.Y_COORD + "min"), tag.getInteger(Constants.NBT.Z_COORD + "min"));
|
||||
maximumOffset = new BlockPos(tag.getInteger(Constants.NBT.X_COORD + "max"), tag.getInteger(Constants.NBT.Y_COORD + "max"), tag.getInteger(Constants.NBT.Z_COORD + "max"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
tag.setInteger(Constants.NBT.X_COORD + "min", minimumOffset.getX());
|
||||
tag.setInteger(Constants.NBT.Y_COORD + "min", minimumOffset.getY());
|
||||
tag.setInteger(Constants.NBT.Z_COORD + "min", minimumOffset.getZ());
|
||||
tag.setInteger(Constants.NBT.X_COORD + "max", maximumOffset.getX());
|
||||
tag.setInteger(Constants.NBT.Y_COORD + "max", maximumOffset.getY());
|
||||
tag.setInteger(Constants.NBT.Z_COORD + "max", maximumOffset.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
public static class HemiSphere extends AreaDescriptor
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
|
@ -12,6 +13,7 @@ import lombok.ToString;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
|
@ -51,12 +53,44 @@ public abstract class Ritual
|
|||
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
NBTTagList tags = tag.getTagList("areas", 10);
|
||||
if (tags.hasNoTags())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < tags.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound newTag = tags.getCompoundTagAt(i);
|
||||
String rangeKey = newTag.getString("key");
|
||||
|
||||
NBTTagCompound storedTag = newTag.getCompoundTag("area");
|
||||
AreaDescriptor desc = this.getBlockRange(rangeKey);
|
||||
if (desc != null)
|
||||
{
|
||||
desc.readFromNBT(storedTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
NBTTagList tags = new NBTTagList();
|
||||
|
||||
for (Entry<String, AreaDescriptor> entry : modableRangeMap.entrySet())
|
||||
{
|
||||
NBTTagCompound newTag = new NBTTagCompound();
|
||||
newTag.setString("key", entry.getKey());
|
||||
NBTTagCompound storedTag = new NBTTagCompound();
|
||||
|
||||
entry.getValue().writeToNBT(storedTag);
|
||||
|
||||
newTag.setTag("area", storedTag);
|
||||
|
||||
tags.appendTag(newTag);
|
||||
}
|
||||
|
||||
tag.setTag("areas", tags);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -94,12 +94,14 @@ public class ItemRitualReader extends Item implements IVariantProvider
|
|||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
System.out.println("In onItemUse");
|
||||
EnumRitualReaderState state = this.getState(stack);
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof IMasterRitualStone)
|
||||
{
|
||||
IMasterRitualStone master = (IMasterRitualStone) tile;
|
||||
this.setBlockPos(stack, pos);
|
||||
this.setMasterBlockPos(stack, pos);
|
||||
this.setBlockPos(stack, BlockPos.ORIGIN);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
|
@ -132,15 +134,14 @@ public class ItemRitualReader extends Item implements IVariantProvider
|
|||
BlockPos containedPos = getBlockPos(stack);
|
||||
if (containedPos.equals(BlockPos.ORIGIN))
|
||||
{
|
||||
System.out.println("Getting first block...");
|
||||
this.setBlockPos(stack, pos.subtract(masterPos));
|
||||
ChatUtil.sendNoSpam(player, new TextComponentTranslation("ritual.BloodMagic.blockRange.firstBlock"));
|
||||
//TODO: Notify player.
|
||||
} else
|
||||
{
|
||||
tile = world.getTileEntity(masterPos);
|
||||
if (tile instanceof IMasterRitualStone)
|
||||
{
|
||||
System.out.println("Setting custom bounds...");
|
||||
IMasterRitualStone master = (IMasterRitualStone) tile;
|
||||
master.setBlockRangeByBounds(player, this.getCurrentBlockRange(stack), containedPos, pos.subtract(masterPos));
|
||||
}
|
||||
|
|
|
@ -345,6 +345,9 @@ public class TileMasterRitualStone extends TileEntity implements IMasterRitualSt
|
|||
if (player != null && !allowed)
|
||||
{
|
||||
ChatUtil.sendNoSpam(player, this.currentRitual.getErrorForBlockRangeOnFail(player, range, this, offset1, offset2));
|
||||
} else
|
||||
{
|
||||
ChatUtil.sendNoSpam(player, new TextComponentTranslation("ritual.BloodMagic.blockRange.success"));
|
||||
}
|
||||
|
||||
return allowed;
|
||||
|
@ -352,7 +355,7 @@ public class TileMasterRitualStone extends TileEntity implements IMasterRitualSt
|
|||
|
||||
if (player != null)
|
||||
{
|
||||
ChatUtil.sendNoSpam(player, "ritual.BloodMagic.blockRange.inactive");
|
||||
ChatUtil.sendNoSpam(player, new TextComponentTranslation("ritual.BloodMagic.blockRange.inactive"));
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -372,6 +372,8 @@ tooltip.BloodMagic.experienceTome.expLevel=Level: %d
|
|||
ritual.BloodMagic.blockRange.tooBig=The block range given is either too big or too far away from the MRS!
|
||||
ritual.BloodMagic.blockRange.inactive=The ritual stone is currently inactive, and cannot have its range modified.
|
||||
ritual.BloodMagic.blockRange.noRange=The range was not properly chosen.
|
||||
ritual.BloodMagic.blockRange.firstBlock=First block for new range stored.
|
||||
ritual.BloodMagic.blockRange.success=New range successfully set!
|
||||
|
||||
ritual.BloodMagic.testRitual=Test Ritual
|
||||
ritual.BloodMagic.waterRitual=Ritual of the Full Spring
|
||||
|
|
Loading…
Reference in a new issue