Untested Ritual Reader stuff, and removing some registry shenanigans.
This commit is contained in:
parent
db268b23a4
commit
30f233b81a
7 changed files with 344 additions and 29 deletions
|
@ -27,6 +27,16 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
|
||||
public abstract void resetIterator();
|
||||
|
||||
/**
|
||||
* This method changes the area descriptor so that its range matches the two
|
||||
* blocks that are selected. When implementing this method, assume that
|
||||
* these positions are the blocks that are clicked by the player.
|
||||
*
|
||||
* @param pos1
|
||||
* @param pos2
|
||||
*/
|
||||
public abstract void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2);
|
||||
|
||||
public static class Rectangle extends AreaDescriptor
|
||||
{
|
||||
private BlockPos minimumOffset;
|
||||
|
@ -170,6 +180,15 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
{
|
||||
currentPosition = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2)
|
||||
{
|
||||
setOffsets(pos1, pos2);
|
||||
maximumOffset = maximumOffset.add(1, 1, 1);
|
||||
resetIterator();
|
||||
resetCache();
|
||||
}
|
||||
}
|
||||
|
||||
public static class HemiSphere extends AreaDescriptor
|
||||
|
@ -293,6 +312,12 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
}
|
||||
|
||||
public static class Cross extends AreaDescriptor
|
||||
|
@ -379,5 +404,12 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package WayofTime.bloodmagic.api.ritual;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
|
||||
/**
|
||||
* This interface is for internal implementation only.
|
||||
|
@ -36,4 +39,14 @@ public interface IMasterRitualStone
|
|||
World getWorldObj();
|
||||
|
||||
BlockPos getBlockPos();
|
||||
|
||||
String getNextBlockRange(String range);
|
||||
|
||||
void provideInformationOfRitualToPlayer(EntityPlayer player);
|
||||
|
||||
void provideInformationOfRangeToPlayer(EntityPlayer player, String range);
|
||||
|
||||
void setActiveWillDrain(EntityPlayer player, List<EnumDemonWillType> typeList);
|
||||
|
||||
boolean setBlockRangeByBounds(EntityPlayer player, String range, BlockPos offset1, BlockPos offset2);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package WayofTime.bloodmagic.api.ritual;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
@ -8,19 +13,17 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Abstract class for creating new rituals. Rituals need be registered with
|
||||
* {@link WayofTime.bloodmagic.api.registry.RitualRegistry#registerRitual(Ritual, String)}
|
||||
*/
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
@EqualsAndHashCode(exclude = { "modableRangeMap" })
|
||||
@EqualsAndHashCode(exclude = { "modableRangeMap", "ritualComponents", "renderer" })
|
||||
@ToString
|
||||
public abstract class Ritual
|
||||
{
|
||||
|
@ -141,6 +144,79 @@ public abstract class Ritual
|
|||
return null;
|
||||
}
|
||||
|
||||
public List<String> getListOfRanges()
|
||||
{
|
||||
return new ArrayList<String>(modableRangeMap.keySet());
|
||||
}
|
||||
|
||||
public String getNextBlockRange(String range)
|
||||
{
|
||||
List<String> rangeList = getListOfRanges();
|
||||
|
||||
if (rangeList.isEmpty())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
if (!rangeList.contains(range))
|
||||
{
|
||||
return rangeList.get(0);
|
||||
}
|
||||
|
||||
boolean hasMatch = false;
|
||||
|
||||
for (String rangeCheck : rangeList)
|
||||
{
|
||||
if (hasMatch)
|
||||
{
|
||||
return rangeCheck;
|
||||
} else if (rangeCheck.equals(range))
|
||||
{
|
||||
hasMatch = true;
|
||||
}
|
||||
}
|
||||
|
||||
return rangeList.get(0);
|
||||
}
|
||||
|
||||
public boolean setBlockRangeByBounds(String range, IMasterRitualStone master, BlockPos offset1, BlockPos offset2)
|
||||
{
|
||||
AreaDescriptor descriptor = this.getBlockRange(range);
|
||||
if (canBlockRangeBeModified(descriptor, master, offset1, offset2))
|
||||
{
|
||||
descriptor.modifyAreaByBlockPositions(offset1, offset2);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean canBlockRangeBeModified(AreaDescriptor descriptor, IMasterRitualStone master, BlockPos offset1, BlockPos offset2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public ITextComponent getErrorForBlockRangeOnFail(EntityPlayer player, String range, IMasterRitualStone master, BlockPos offset1, BlockPos offset2)
|
||||
{
|
||||
return new TextComponentTranslation("ritual.BloodMagic.blockRange.tooBig");
|
||||
}
|
||||
|
||||
public ITextComponent provideInformationOfRitualToPlayer(EntityPlayer player)
|
||||
{
|
||||
return new TextComponentTranslation(this.getUnlocalizedName() + ".info");
|
||||
}
|
||||
|
||||
public ITextComponent provideInformationOfRangeToPlayer(EntityPlayer player, String range)
|
||||
{
|
||||
if (getListOfRanges().contains(range))
|
||||
{
|
||||
return new TextComponentTranslation(this.getUnlocalizedName() + "." + range + ".info");
|
||||
} else
|
||||
{
|
||||
return new TextComponentTranslation("ritual.BloodMagic.blockRange.noRange");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of {@link RitualComponent} for checking the ritual.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue