Merge branch '1.8-Rewrite' of https://github.com/WayofTime/BloodMagic into 1.8-Rewrite
Conflicts: src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java
This commit is contained in:
commit
4734f1207a
24 changed files with 549 additions and 96 deletions
|
@ -1,9 +1,11 @@
|
|||
package WayofTime.bloodmagic.api.registry;
|
||||
|
||||
import WayofTime.bloodmagic.api.BlockStack;
|
||||
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -27,6 +29,17 @@ public class ImperfectRitualRegistry {
|
|||
}
|
||||
}
|
||||
|
||||
public static ImperfectRitual getRitualForBlock(BlockStack blockStack) {
|
||||
for (ImperfectRitual imperfectRitual : getRegistry().values()) {
|
||||
if (imperfectRitual.getRequiredBlock().equals(blockStack)) {
|
||||
System.out.println(imperfectRitual.toString());
|
||||
return imperfectRitual;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ImperfectRitual getRitualForId(String id) {
|
||||
return registry.get(id);
|
||||
}
|
||||
|
@ -44,13 +57,22 @@ public class ImperfectRitualRegistry {
|
|||
}
|
||||
|
||||
public static boolean ritualEnabled(ImperfectRitual imperfectRitual) {
|
||||
return enabledRituals.get(imperfectRitual);
|
||||
try {
|
||||
return enabledRituals.get(imperfectRitual);
|
||||
} catch (NullPointerException e) {
|
||||
BloodMagicAPI.getLogger().error("Invalid Imperfect Ritual was called");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static BiMap<String, ImperfectRitual> getRegistry() {
|
||||
return HashBiMap.create(registry);
|
||||
}
|
||||
|
||||
public static BiMap<ImperfectRitual, Boolean> getEnabledMap() {
|
||||
return HashBiMap.create(enabledRituals);
|
||||
}
|
||||
|
||||
public static ArrayList<String> getIds() {
|
||||
return new ArrayList<String>(registry.keySet());
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package WayofTime.bloodmagic.api.registry;
|
|||
|
||||
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.api.ritual.Ritual;
|
||||
import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import java.util.ArrayList;
|
||||
|
@ -43,13 +44,22 @@ public class RitualRegistry {
|
|||
}
|
||||
|
||||
public static boolean ritualEnabled(Ritual ritual) {
|
||||
return enabledRituals.get(ritual);
|
||||
try {
|
||||
return enabledRituals.get(ritual);
|
||||
} catch (NullPointerException e) {
|
||||
BloodMagicAPI.getLogger().error("Invalid Ritual was called");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static BiMap<String, Ritual> getRegistry() {
|
||||
return HashBiMap.create(registry);
|
||||
}
|
||||
|
||||
public static BiMap<Ritual, Boolean> getEnabledMap() {
|
||||
return HashBiMap.create(enabledRituals);
|
||||
}
|
||||
|
||||
public static ArrayList<String> getIds() {
|
||||
return new ArrayList<String>(registry.keySet());
|
||||
}
|
||||
|
|
|
@ -1,15 +1,21 @@
|
|||
package WayofTime.bloodmagic.api.ritual;
|
||||
|
||||
import WayofTime.bloodmagic.api.ritual.imperfect.IImperfectRitualStone;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IMasterRitualStone extends IImperfectRitualStone {
|
||||
public interface IMasterRitualStone {
|
||||
|
||||
String getOwner();
|
||||
|
||||
boolean activateRitual(ItemStack activationCrystal, EntityPlayer activator);
|
||||
|
||||
void performRitual(World world, BlockPos pos, Ritual ritual);
|
||||
|
||||
void stopRitual();
|
||||
|
||||
void setCooldown(int cooldown);
|
||||
|
||||
int getCooldown();
|
||||
|
@ -18,15 +24,11 @@ public interface IMasterRitualStone extends IImperfectRitualStone {
|
|||
|
||||
EnumFacing getDirection();
|
||||
|
||||
NBTTagCompound getCustomRitualTag();
|
||||
|
||||
void setCustomRitualTag(NBTTagCompound tag);
|
||||
|
||||
boolean areTanksEmpty();
|
||||
|
||||
int getRunningTime();
|
||||
|
||||
LocalRitualStorage getLocalStorage();
|
||||
World getWorld();
|
||||
|
||||
void setLocalStorage(LocalRitualStorage storage);
|
||||
BlockPos getPos();
|
||||
}
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
package WayofTime.bloodmagic.api.ritual;
|
||||
|
||||
import WayofTime.bloodmagic.api.NBTHolder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
||||
/**
|
||||
* This class is used to pass ritual-specific data into the RitualEffect from the containing Master Ritual Stone. This is basically used as auxiliary storage,
|
||||
* for when simply storing to NBT becomes... difficult.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class LocalRitualStorage {
|
||||
|
||||
private BlockPos pos;
|
||||
|
||||
public void writeToNBT(NBTTagCompound tagCompound) {
|
||||
tagCompound.setInteger(NBTHolder.NBT_COORDX, pos.getX());
|
||||
tagCompound.setInteger(NBTHolder.NBT_COORDY, pos.getY());
|
||||
tagCompound.setInteger(NBTHolder.NBT_COORDZ, pos.getZ());
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
this.pos = new BlockPos(tagCompound.getInteger(NBTHolder.NBT_COORDX), tagCompound.getInteger(NBTHolder.NBT_COORDY), tagCompound.getInteger(NBTHolder.NBT_COORDZ));
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package WayofTime.bloodmagic.api.ritual;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -9,6 +10,7 @@ import java.util.ArrayList;
|
|||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public abstract class Ritual {
|
||||
|
||||
private final String name;
|
||||
|
@ -32,10 +34,6 @@ public abstract class Ritual {
|
|||
|
||||
public abstract ArrayList<RitualComponent> getComponents();
|
||||
|
||||
public LocalRitualStorage getNewLocalStorage() {
|
||||
return new LocalRitualStorage();
|
||||
}
|
||||
|
||||
public void addOffsetRunes(ArrayList<RitualComponent> components, int offset1, int offset2, int y, EnumRuneType rune) {
|
||||
components.add(new RitualComponent(new BlockPos(offset1, y, offset2), rune));
|
||||
components.add(new RitualComponent(new BlockPos(offset2, y, offset1), rune));
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package WayofTime.bloodmagic.api.ritual.imperfect;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IImperfectRitualStone {
|
||||
|
||||
String getOwner();
|
||||
boolean performRitual(World world, BlockPos pos, ImperfectRitual imperfectRitual, EntityPlayer player);
|
||||
|
||||
World getWorld();
|
||||
|
||||
|
|
|
@ -1,19 +1,29 @@
|
|||
package WayofTime.bloodmagic.api.ritual.imperfect;
|
||||
|
||||
import WayofTime.bloodmagic.api.BlockStack;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
public abstract class ImperfectRitual {
|
||||
|
||||
private final String name;
|
||||
private final BlockStack requiredBlock;
|
||||
private final int activationCost;
|
||||
private final boolean lightshow;
|
||||
|
||||
public ImperfectRitual(BlockStack requiredBlock, int activationCost) {
|
||||
this(requiredBlock, activationCost, false);
|
||||
public ImperfectRitual(String name, BlockStack requiredBlock, int activationCost) {
|
||||
this(name, requiredBlock, activationCost, false);
|
||||
}
|
||||
|
||||
public abstract boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player);
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName() + ":" + getRequiredBlock().toString() + "@" + getActivationCost();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package WayofTime.bloodmagic.api.util.helper;
|
||||
|
||||
import WayofTime.bloodmagic.api.registry.ImperfectRitualRegistry;
|
||||
import WayofTime.bloodmagic.api.registry.RitualRegistry;
|
||||
import WayofTime.bloodmagic.api.ritual.Ritual;
|
||||
import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual;
|
||||
import com.google.common.collect.BiMap;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import sun.misc.Launcher;
|
||||
|
||||
|
@ -28,6 +31,14 @@ public class RitualHelper {
|
|||
return RitualRegistry.getIds().get(previousIndex);
|
||||
}
|
||||
|
||||
public static void checkImperfectRituals(Configuration config, String packageName, String category) {
|
||||
checkRituals(config, packageName, category, ImperfectRitual.class, ImperfectRitualRegistry.enabledRituals);
|
||||
}
|
||||
|
||||
public static void checkRituals(Configuration config, String packageName, String category) {
|
||||
checkRituals(config, packageName, category, Ritual.class, RitualRegistry.enabledRituals);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds your Ritual to the {@link RitualRegistry#enabledRituals} Map.
|
||||
* This is used to determine whether your effect is enabled or not.
|
||||
|
@ -35,13 +46,16 @@ public class RitualHelper {
|
|||
* The config option will be created as {@code B:ClassName=true} with a comment of
|
||||
* {@code Enables the ClassName ritual}.
|
||||
*
|
||||
* Use {@link #}
|
||||
*
|
||||
* Should be safe to modify at any point.
|
||||
*
|
||||
* @param config - Your mod's Forge {@link Configuration} object.
|
||||
* @param packageName - The package your Rituals are located in.
|
||||
* @param category - The config category to write to.
|
||||
*/
|
||||
public static void checkRituals(Configuration config, String packageName, String category) {
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void checkRituals(Configuration config, String packageName, String category, Class ritualClass, BiMap enabledMap) {
|
||||
String name = packageName;
|
||||
if (!name.startsWith("/"))
|
||||
name = "/" + name;
|
||||
|
@ -60,8 +74,9 @@ public class RitualHelper {
|
|||
try {
|
||||
Object o = Class.forName(packageName + "." + className).newInstance();
|
||||
|
||||
if (o instanceof Ritual)
|
||||
RitualRegistry.enabledRituals.put((Ritual) o, config.get(category, className, true).getBoolean());
|
||||
if (ritualClass.isInstance(o))
|
||||
enabledMap.put(ritualClass.cast(o),
|
||||
config.get(category, className, true).getBoolean());
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue