Initial Work on Rituals

Added the framework for Rituals, including the automatic registration of rituals using the annotation.
This includes:
- The Master Ritual Stone
- The regular Ritual Stones (all 7 types)
- The Ritual Registration system
- The activation crystal items.
- Reintroduction of the Demon Will Aura (changed saved Dimension ID from Integer to ResourceLocation)

Localization needs to be completed, as well as the implementation of all the rituals.
This commit is contained in:
WayofTime 2020-10-24 14:50:25 -04:00
parent 0a9717f1ed
commit 1f0dcb608a
61 changed files with 3943 additions and 26 deletions

View file

@ -0,0 +1,20 @@
package wayoftime.bloodmagic.ritual.imperfect;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
* This interface is for internal implementation only.
* <p>
* It is provided via the API for easy obtaining of basic data.
*/
public interface IImperfectRitualStone
{
boolean performRitual(World world, BlockPos pos, ImperfectRitual imperfectRitual, PlayerEntity player);
World getRitualWorld();
BlockPos getRitualPos();
}

View file

@ -0,0 +1,108 @@
package wayoftime.bloodmagic.ritual.imperfect;
import java.util.function.Predicate;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;
/**
* Abstract class for creating new imperfect rituals. To register, annotate your
* class with {@link WayofTime.bloodmagic.ritual.RitualRegister.Imperfect}
*/
public abstract class ImperfectRitual
{
private final String name;
private final Predicate<BlockState> blockRequirement;
private final int activationCost;
private final boolean lightShow;
private final String unlocalizedName;
public ImperfectRitual(String name, Predicate<BlockState> blockRequirement, int activationCost, boolean lightShow, String unlocalizedName)
{
this.name = name;
this.blockRequirement = blockRequirement;
this.activationCost = activationCost;
this.lightShow = lightShow;
this.unlocalizedName = unlocalizedName;
}
/**
* @param name The name of the ritual
* @param blockRequirement The block required above the ImperfectRitualStone
* @param activationCost Base LP cost for activating the ritual
*/
public ImperfectRitual(String name, Predicate<BlockState> blockRequirement, int activationCost, String unlocalizedName)
{
this(name, blockRequirement, activationCost, false, unlocalizedName);
}
/**
* Called when the player activates the ritual
* {@link WayofTime.bloodmagic.tile.TileImperfectRitualStone#performRitual(World, net.minecraft.util.math.BlockPos, ImperfectRitual, PlayerEntity)}
*
* @param imperfectRitualStone - The {@link IImperfectRitualStone} that the
* ritual is bound to
* @param player - The player activating the ritual
* @return - Whether activation was successful
*/
public abstract boolean onActivate(IImperfectRitualStone imperfectRitualStone, PlayerEntity player);
public String getName()
{
return name;
}
public Predicate<BlockState> getBlockRequirement()
{
return blockRequirement;
}
public int getActivationCost()
{
return activationCost;
}
public boolean isLightShow()
{
return lightShow;
}
public String getTranslationKey()
{
return unlocalizedName;
}
@Override
public String toString()
{
return getName() + "@" + getActivationCost();
}
@Override
public boolean equals(Object o)
{
if (this == o)
return true;
if (!(o instanceof ImperfectRitual))
return false;
ImperfectRitual that = (ImperfectRitual) o;
if (activationCost != that.activationCost)
return false;
if (name != null ? !name.equals(that.name) : that.name != null)
return false;
return unlocalizedName != null ? unlocalizedName.equals(that.unlocalizedName) : that.unlocalizedName == null;
}
@Override
public int hashCode()
{
int result = name != null ? name.hashCode() : 0;
result = 31 * result + activationCost;
result = 31 * result + (unlocalizedName != null ? unlocalizedName.hashCode() : 0);
return result;
}
}