Run formatter
This commit is contained in:
parent
61c44a831b
commit
08258fd6ef
|
@ -1,15 +1,22 @@
|
||||||
package WayofTime.bloodmagic;
|
package WayofTime.bloodmagic;
|
||||||
|
|
||||||
import java.io.File;
|
import WayofTime.bloodmagic.annot.Handler;
|
||||||
import java.util.List;
|
import WayofTime.bloodmagic.api.registry.RitualRegistry;
|
||||||
|
import WayofTime.bloodmagic.api.util.helper.LogHelper;
|
||||||
import WayofTime.bloodmagic.api_impl.BloodMagicAPI;
|
import WayofTime.bloodmagic.api_impl.BloodMagicAPI;
|
||||||
import WayofTime.bloodmagic.apiv2.BloodMagicPlugin;
|
import WayofTime.bloodmagic.apiv2.BloodMagicPlugin;
|
||||||
import WayofTime.bloodmagic.apiv2.IBloodMagicPlugin;
|
import WayofTime.bloodmagic.apiv2.IBloodMagicPlugin;
|
||||||
|
import WayofTime.bloodmagic.client.gui.GuiHandler;
|
||||||
import WayofTime.bloodmagic.command.CommandBloodMagic;
|
import WayofTime.bloodmagic.command.CommandBloodMagic;
|
||||||
import WayofTime.bloodmagic.api.registry.RitualRegistry;
|
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||||
import WayofTime.bloodmagic.meteor.MeteorConfigHandler;
|
import WayofTime.bloodmagic.meteor.MeteorConfigHandler;
|
||||||
|
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
|
||||||
|
import WayofTime.bloodmagic.proxy.CommonProxy;
|
||||||
|
import WayofTime.bloodmagic.registry.*;
|
||||||
|
import WayofTime.bloodmagic.structures.ModDungeons;
|
||||||
import WayofTime.bloodmagic.util.PluginUtil;
|
import WayofTime.bloodmagic.util.PluginUtil;
|
||||||
|
import WayofTime.bloodmagic.util.Utils;
|
||||||
|
import WayofTime.bloodmagic.util.handler.IMCHandler;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -19,70 +26,51 @@ import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.SidedProxy;
|
import net.minecraftforge.fml.common.SidedProxy;
|
||||||
import net.minecraftforge.fml.common.event.*;
|
import net.minecraftforge.fml.common.event.*;
|
||||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||||
import WayofTime.bloodmagic.annot.Handler;
|
|
||||||
import WayofTime.bloodmagic.api.util.helper.LogHelper;
|
|
||||||
import WayofTime.bloodmagic.client.gui.GuiHandler;
|
|
||||||
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
|
|
||||||
import WayofTime.bloodmagic.proxy.CommonProxy;
|
|
||||||
import WayofTime.bloodmagic.registry.ModArmourTrackers;
|
|
||||||
import WayofTime.bloodmagic.registry.ModCorruptionBlocks;
|
|
||||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
|
||||||
import WayofTime.bloodmagic.registry.ModRecipes;
|
|
||||||
import WayofTime.bloodmagic.registry.ModRituals;
|
|
||||||
import WayofTime.bloodmagic.registry.ModTranquilityHandlers;
|
|
||||||
import WayofTime.bloodmagic.structures.ModDungeons;
|
|
||||||
import WayofTime.bloodmagic.util.Utils;
|
|
||||||
import WayofTime.bloodmagic.util.handler.IMCHandler;
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Mod(modid = BloodMagic.MODID, name = BloodMagic.NAME, version = BloodMagic.VERSION, dependencies = BloodMagic.DEPEND, guiFactory = "WayofTime.bloodmagic.client.gui.config.ConfigGuiFactory")
|
@Mod(modid = BloodMagic.MODID, name = BloodMagic.NAME, version = BloodMagic.VERSION, dependencies = BloodMagic.DEPEND, guiFactory = "WayofTime.bloodmagic.client.gui.config.ConfigGuiFactory")
|
||||||
public class BloodMagic
|
public class BloodMagic {
|
||||||
{
|
|
||||||
public static final String MODID = "bloodmagic";
|
public static final String MODID = "bloodmagic";
|
||||||
public static final String NAME = "Blood Magic: Alchemical Wizardry";
|
public static final String NAME = "Blood Magic: Alchemical Wizardry";
|
||||||
public static final String VERSION = "@VERSION@";
|
public static final String VERSION = "@VERSION@";
|
||||||
public static final String DEPEND = "required-after:guideapi;";
|
public static final String DEPEND = "required-after:guideapi;";
|
||||||
public static final CreativeTabs TAB_BM = new CreativeTabs(MODID + ".creativeTab")
|
public static final CreativeTabs TAB_BM = new CreativeTabs(MODID + ".creativeTab") {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getTabIconItem()
|
public ItemStack getTabIconItem() {
|
||||||
{
|
|
||||||
return new ItemStack(RegistrarBloodMagicItems.BLOOD_ORB);
|
return new ItemStack(RegistrarBloodMagicItems.BLOOD_ORB);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static CreativeTabs TAB_TOMES = new CreativeTabs(MODID + ".creativeTabTome")
|
public static final boolean IS_DEV = (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
|
||||||
{
|
public static final List<Pair<IBloodMagicPlugin, BloodMagicPlugin>> PLUGINS = Lists.newArrayList();
|
||||||
|
public static CreativeTabs TAB_TOMES = new CreativeTabs(MODID + ".creativeTabTome") {
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getTabIconItem()
|
public ItemStack getTabIconItem() {
|
||||||
{
|
|
||||||
return new ItemStack(RegistrarBloodMagicItems.UPGRADE_TOME);
|
return new ItemStack(RegistrarBloodMagicItems.UPGRADE_TOME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasSearchBar()
|
public boolean hasSearchBar() {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}.setNoTitle().setBackgroundImageName("item_search.png");
|
}.setNoTitle().setBackgroundImageName("item_search.png");
|
||||||
public static final boolean IS_DEV = (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
|
|
||||||
public static final List<Pair<IBloodMagicPlugin, BloodMagicPlugin>> PLUGINS = Lists.newArrayList();
|
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
FluidRegistry.enableUniversalBucket();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SidedProxy(serverSide = "WayofTime.bloodmagic.proxy.CommonProxy", clientSide = "WayofTime.bloodmagic.proxy.ClientProxy")
|
@SidedProxy(serverSide = "WayofTime.bloodmagic.proxy.CommonProxy", clientSide = "WayofTime.bloodmagic.proxy.ClientProxy")
|
||||||
public static CommonProxy proxy;
|
public static CommonProxy proxy;
|
||||||
@Mod.Instance(BloodMagic.MODID)
|
@Mod.Instance(BloodMagic.MODID)
|
||||||
public static BloodMagic instance;
|
public static BloodMagic instance;
|
||||||
|
|
||||||
|
static {
|
||||||
|
FluidRegistry.enableUniversalBucket();
|
||||||
|
}
|
||||||
|
|
||||||
public LogHelper logger = new LogHelper(MODID);
|
public LogHelper logger = new LogHelper(MODID);
|
||||||
private File configDir;
|
private File configDir;
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void preInit(FMLPreInitializationEvent event)
|
public void preInit(FMLPreInitializationEvent event) {
|
||||||
{
|
|
||||||
configDir = new File(event.getModConfigurationDirectory(), "BloodMagic");
|
configDir = new File(event.getModConfigurationDirectory(), "BloodMagic");
|
||||||
ConfigHandler.init(new File(configDir, "BloodMagic.cfg"));
|
ConfigHandler.init(new File(configDir, "BloodMagic.cfg"));
|
||||||
|
|
||||||
|
@ -96,8 +84,7 @@ public class BloodMagic
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void init(FMLInitializationEvent event)
|
public void init(FMLInitializationEvent event) {
|
||||||
{
|
|
||||||
BloodMagicPacketHandler.init();
|
BloodMagicPacketHandler.init();
|
||||||
for (Pair<IBloodMagicPlugin, BloodMagicPlugin> plugin : PLUGINS)
|
for (Pair<IBloodMagicPlugin, BloodMagicPlugin> plugin : PLUGINS)
|
||||||
plugin.getLeft().register(BloodMagicAPI.INSTANCE);
|
plugin.getLeft().register(BloodMagicAPI.INSTANCE);
|
||||||
|
@ -114,8 +101,7 @@ public class BloodMagic
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void postInit(FMLPostInitializationEvent event)
|
public void postInit(FMLPostInitializationEvent event) {
|
||||||
{
|
|
||||||
ModRecipes.addCompressionHandlers();
|
ModRecipes.addCompressionHandlers();
|
||||||
|
|
||||||
proxy.postInit();
|
proxy.postInit();
|
||||||
|
@ -127,20 +113,17 @@ public class BloodMagic
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void modMapping(FMLModIdMappingEvent event)
|
public void modMapping(FMLModIdMappingEvent event) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void serverStarting(FMLServerStartingEvent event)
|
public void serverStarting(FMLServerStartingEvent event) {
|
||||||
{
|
|
||||||
event.registerServerCommand(new CommandBloodMagic());
|
event.registerServerCommand(new CommandBloodMagic());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void onIMCRecieved(FMLInterModComms.IMCEvent event)
|
public void onIMCRecieved(FMLInterModComms.IMCEvent event) {
|
||||||
{
|
|
||||||
IMCHandler.handleIMC(event);
|
IMCHandler.handleIMC(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package WayofTime.bloodmagic;
|
package WayofTime.bloodmagic;
|
||||||
|
|
||||||
import java.io.*;
|
import WayofTime.bloodmagic.annot.Handler;
|
||||||
import java.util.ArrayList;
|
import WayofTime.bloodmagic.api.BlockStack;
|
||||||
import java.util.Arrays;
|
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
||||||
import java.util.HashMap;
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import WayofTime.bloodmagic.meteor.MeteorConfigHandler;
|
import WayofTime.bloodmagic.meteor.MeteorConfigHandler;
|
||||||
|
import WayofTime.bloodmagic.util.Utils;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
|
@ -15,15 +13,12 @@ import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
import WayofTime.bloodmagic.annot.Handler;
|
|
||||||
import WayofTime.bloodmagic.api.BlockStack;
|
import java.io.File;
|
||||||
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
import java.util.*;
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
|
||||||
import WayofTime.bloodmagic.util.Utils;
|
|
||||||
|
|
||||||
@Handler
|
@Handler
|
||||||
public class ConfigHandler
|
public class ConfigHandler {
|
||||||
{
|
|
||||||
public static Configuration config;
|
public static Configuration config;
|
||||||
|
|
||||||
// Teleposer
|
// Teleposer
|
||||||
|
@ -152,14 +147,20 @@ public class ConfigHandler
|
||||||
public static boolean thaumcraftGogglesUpgrade;
|
public static boolean thaumcraftGogglesUpgrade;
|
||||||
public static boolean ignoreCompressionSpamAddedByCompression;
|
public static boolean ignoreCompressionSpamAddedByCompression;
|
||||||
|
|
||||||
public static void init(File file)
|
@SubscribeEvent
|
||||||
{
|
public void onConfigChanged(ConfigChangedEvent event) {
|
||||||
|
if (event.getModID().equals(BloodMagic.MODID)) {
|
||||||
|
syncConfig();
|
||||||
|
MeteorConfigHandler.handleMeteors(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init(File file) {
|
||||||
config = new Configuration(file);
|
config = new Configuration(file);
|
||||||
syncConfig();
|
syncConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void syncConfig()
|
public static void syncConfig() {
|
||||||
{
|
|
||||||
String category;
|
String category;
|
||||||
|
|
||||||
category = "Item/Block Blacklisting";
|
category = "Item/Block Blacklisting";
|
||||||
|
@ -168,22 +169,22 @@ public class ConfigHandler
|
||||||
|
|
||||||
category = "Teleposer Blacklist";
|
category = "Teleposer Blacklist";
|
||||||
config.addCustomCategoryComment(category, "Block blacklisting");
|
config.addCustomCategoryComment(category, "Block blacklisting");
|
||||||
teleposerBlacklisting = config.getStringList("teleposerBlacklist", category, new String[] { "minecraft:bedrock", "minecraft:mob_spawner" }, "Stops specified blocks from being teleposed. Put entries on new lines. Valid syntax is:\nmodid:blockname:meta");
|
teleposerBlacklisting = config.getStringList("teleposerBlacklist", category, new String[]{"minecraft:bedrock", "minecraft:mob_spawner"}, "Stops specified blocks from being teleposed. Put entries on new lines. Valid syntax is:\nmodid:blockname:meta");
|
||||||
buildBlacklist(teleposerBlacklisting, teleposerBlacklist);
|
buildBlacklist(teleposerBlacklisting, teleposerBlacklist);
|
||||||
teleposerBlacklistEntity = Arrays.asList(config.getStringList("teleposerBlacklistEntity", category, new String[] {}, "Entity class names listed here will not be able to be teleposed."));
|
teleposerBlacklistEntity = Arrays.asList(config.getStringList("teleposerBlacklistEntity", category, new String[]{}, "Entity class names listed here will not be able to be teleposed."));
|
||||||
|
|
||||||
category = "Transposition Sigil Blacklist";
|
category = "Transposition Sigil Blacklist";
|
||||||
config.addCustomCategoryComment(category, "Block blacklisting");
|
config.addCustomCategoryComment(category, "Block blacklisting");
|
||||||
transpositionBlacklisting = config.getStringList("transpositionBlacklist", category, new String[] { "minecraft:bedrock", "minecraft:mob_spawner" }, "Stops specified blocks from being teleposed. Put entries on new lines. Valid syntax is:\nmodid:blockname:meta");
|
transpositionBlacklisting = config.getStringList("transpositionBlacklist", category, new String[]{"minecraft:bedrock", "minecraft:mob_spawner"}, "Stops specified blocks from being teleposed. Put entries on new lines. Valid syntax is:\nmodid:blockname:meta");
|
||||||
buildBlacklist(transpositionBlacklisting, transpositionBlacklist);
|
buildBlacklist(transpositionBlacklisting, transpositionBlacklist);
|
||||||
|
|
||||||
category = "Well of Suffering Blacklist";
|
category = "Well of Suffering Blacklist";
|
||||||
config.addCustomCategoryComment(category, "Entity blacklisting from WoS");
|
config.addCustomCategoryComment(category, "Entity blacklisting from WoS");
|
||||||
wellOfSufferingBlacklist = Arrays.asList(config.getStringList("wellOfSufferingBlacklist", category, new String[] { "EntityArmorStand", "EntitySentientSpecter" }, "Use the class name of the Entity to blacklist it from usage.\nIE: EntityWolf, EntityWitch, etc"));
|
wellOfSufferingBlacklist = Arrays.asList(config.getStringList("wellOfSufferingBlacklist", category, new String[]{"EntityArmorStand", "EntitySentientSpecter"}, "Use the class name of the Entity to blacklist it from usage.\nIE: EntityWolf, EntityWitch, etc"));
|
||||||
|
|
||||||
category = "Blood Altar Sacrificial Values";
|
category = "Blood Altar Sacrificial Values";
|
||||||
config.addCustomCategoryComment(category, "Entity Sacrificial Value Settings");
|
config.addCustomCategoryComment(category, "Entity Sacrificial Value Settings");
|
||||||
entitySacrificeValuesList = config.getStringList("entitySacrificeLP:HPValues", category, new String[] { "EntityVillager;100", "EntitySlime;15", "EntityEnderman;10", "EntityCow;100", "EntityChicken;100", "EntityHorse;100", "EntitySheep;100", "EntityWolf;100", "EntityOcelot;100", "EntityPig;100", "EntityRabbit;100", "EntityArmorStand;0", "EntitySentientSpecter;0" }, "Used to edit the amount of LP gained per HP sacrificed for the given entity.\nSetting an entity to 0 effectively blacklists it.\nIf a mod modifies an entity via the API, it will take precedence over this config.\nSyntax: EntityClassName;LPPerHP");
|
entitySacrificeValuesList = config.getStringList("entitySacrificeLP:HPValues", category, new String[]{"EntityVillager;100", "EntitySlime;15", "EntityEnderman;10", "EntityCow;100", "EntityChicken;100", "EntityHorse;100", "EntitySheep;100", "EntityWolf;100", "EntityOcelot;100", "EntityPig;100", "EntityRabbit;100", "EntityArmorStand;0", "EntitySentientSpecter;0"}, "Used to edit the amount of LP gained per HP sacrificed for the given entity.\nSetting an entity to 0 effectively blacklists it.\nIf a mod modifies an entity via the API, it will take precedence over this config.\nSyntax: EntityClassName;LPPerHP");
|
||||||
buildEntitySacrificeValues();
|
buildEntitySacrificeValues();
|
||||||
|
|
||||||
category = "Potions";
|
category = "Potions";
|
||||||
|
@ -310,19 +311,16 @@ public class ConfigHandler
|
||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void buildBlacklist(String[] blacklisting, List<BlockStack> blockBlacklist)
|
private static void buildBlacklist(String[] blacklisting, List<BlockStack> blockBlacklist) {
|
||||||
{
|
|
||||||
blockBlacklist.clear();
|
blockBlacklist.clear();
|
||||||
|
|
||||||
for (String blockSet : blacklisting)
|
for (String blockSet : blacklisting) {
|
||||||
{
|
|
||||||
String[] blockData = blockSet.split(":");
|
String[] blockData = blockSet.split(":");
|
||||||
|
|
||||||
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(blockData[0], blockData[1]));
|
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(blockData[0], blockData[1]));
|
||||||
int meta = 0;
|
int meta = 0;
|
||||||
|
|
||||||
if (blockData.length == 3)
|
if (blockData.length == 3) {
|
||||||
{
|
|
||||||
// Check if it's an int, if so, parse it. If not, set meta to 0
|
// Check if it's an int, if so, parse it. If not, set meta to 0
|
||||||
// to avoid crashing.
|
// to avoid crashing.
|
||||||
if (Utils.isInteger(blockData[2]))
|
if (Utils.isInteger(blockData[2]))
|
||||||
|
@ -337,12 +335,10 @@ public class ConfigHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void buildEntitySacrificeValues()
|
private static void buildEntitySacrificeValues() {
|
||||||
{
|
|
||||||
entitySacrificeValues.clear();
|
entitySacrificeValues.clear();
|
||||||
|
|
||||||
for (String entityData : entitySacrificeValuesList)
|
for (String entityData : entitySacrificeValuesList) {
|
||||||
{
|
|
||||||
String[] split = entityData.split(";");
|
String[] split = entityData.split(";");
|
||||||
|
|
||||||
int amount = 500;
|
int amount = 500;
|
||||||
|
@ -353,14 +349,4 @@ public class ConfigHandler
|
||||||
entitySacrificeValues.put(split[0], amount);
|
entitySacrificeValues.put(split[0], amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onConfigChanged(ConfigChangedEvent event)
|
|
||||||
{
|
|
||||||
if (event.getModID().equals(BloodMagic.MODID))
|
|
||||||
{
|
|
||||||
syncConfig();
|
|
||||||
MeteorConfigHandler.handleMeteors(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,16 @@
|
||||||
package WayofTime.bloodmagic.alchemyArray;
|
package WayofTime.bloodmagic.alchemyArray;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import WayofTime.bloodmagic.BloodMagic;
|
import WayofTime.bloodmagic.BloodMagic;
|
||||||
|
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
||||||
|
import WayofTime.bloodmagic.fakePlayer.FakePlayerBM;
|
||||||
|
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.ai.EntityAIBase;
|
import net.minecraft.entity.ai.EntityAIBase;
|
||||||
import net.minecraft.entity.ai.EntityAITasks;
|
import net.minecraft.entity.ai.EntityAITasks;
|
||||||
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry;
|
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry;
|
||||||
import net.minecraft.entity.monster.EntityBlaze;
|
import net.minecraft.entity.monster.*;
|
||||||
import net.minecraft.entity.monster.EntityEnderman;
|
|
||||||
import net.minecraft.entity.monster.EntityMob;
|
|
||||||
import net.minecraft.entity.monster.EntityPigZombie;
|
|
||||||
import net.minecraft.entity.monster.EntitySilverfish;
|
|
||||||
import net.minecraft.entity.monster.EntitySlime;
|
|
||||||
import net.minecraft.entity.monster.EntitySpider;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.pathfinding.Path;
|
import net.minecraft.pathfinding.Path;
|
||||||
import net.minecraft.pathfinding.PathFinder;
|
import net.minecraft.pathfinding.PathFinder;
|
||||||
|
@ -29,17 +21,13 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.FakePlayer;
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
|
||||||
import WayofTime.bloodmagic.fakePlayer.FakePlayerBM;
|
|
||||||
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Credits for the initial code go to Crazy Pants of EIO.
|
* Credits for the initial code go to Crazy Pants of EIO.
|
||||||
*/
|
*/
|
||||||
public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
|
public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect {
|
||||||
{
|
|
||||||
private FakePlayer target;
|
private FakePlayer target;
|
||||||
private Set<EntityLiving> tracking = new HashSet<EntityLiving>();
|
private Set<EntityLiving> tracking = new HashSet<EntityLiving>();
|
||||||
|
|
||||||
|
@ -48,26 +36,21 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
|
||||||
|
|
||||||
private int cooldown = 50;
|
private int cooldown = 50;
|
||||||
|
|
||||||
public AlchemyArrayEffectAttractor(String key)
|
public AlchemyArrayEffectAttractor(String key) {
|
||||||
{
|
|
||||||
super(key);
|
super(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(TileEntity tile, int ticksActive)
|
public boolean update(TileEntity tile, int ticksActive) {
|
||||||
{
|
if (tile.getWorld().isRemote) {
|
||||||
if (tile.getWorld().isRemote)
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockPos pos = tile.getPos();
|
BlockPos pos = tile.getPos();
|
||||||
counter++;
|
counter++;
|
||||||
if (counter < 10)
|
if (counter < 10) {
|
||||||
{
|
|
||||||
Iterator<EntityLiving> itr = tracking.iterator();
|
Iterator<EntityLiving> itr = tracking.iterator();
|
||||||
while (itr.hasNext())
|
while (itr.hasNext()) {
|
||||||
{
|
|
||||||
EntityLiving ent = itr.next();
|
EntityLiving ent = itr.next();
|
||||||
onEntityTick(pos, ent);
|
onEntityTick(pos, ent);
|
||||||
}
|
}
|
||||||
|
@ -82,8 +65,7 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
|
||||||
Set<EntityLiving> trackingThisTick = new HashSet<EntityLiving>();
|
Set<EntityLiving> trackingThisTick = new HashSet<EntityLiving>();
|
||||||
List<EntityLiving> entsInBounds = world.getEntitiesWithinAABB(EntityLiving.class, getBounds(pos));
|
List<EntityLiving> entsInBounds = world.getEntitiesWithinAABB(EntityLiving.class, getBounds(pos));
|
||||||
|
|
||||||
for (EntityLiving ent : entsInBounds)
|
for (EntityLiving ent : entsInBounds) {
|
||||||
{
|
|
||||||
if (!ent.isDead)// && isMobInFilter(ent))
|
if (!ent.isDead)// && isMobInFilter(ent))
|
||||||
{
|
{
|
||||||
double x = (pos.getX() + 0.5D - ent.posX);
|
double x = (pos.getX() + 0.5D - ent.posX);
|
||||||
|
@ -91,36 +73,30 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
|
||||||
double z = (pos.getZ() + 0.5D - ent.posZ);
|
double z = (pos.getZ() + 0.5D - ent.posZ);
|
||||||
double distance = Math.sqrt(x * x + y * y + z * z);
|
double distance = Math.sqrt(x * x + y * y + z * z);
|
||||||
|
|
||||||
if (distance < 2 && tracking.contains(ent))
|
if (distance < 2 && tracking.contains(ent)) {
|
||||||
{
|
|
||||||
setEntityCooldown(pos, ent, cooldown);
|
setEntityCooldown(pos, ent, cooldown);
|
||||||
removeAssignedAITask(pos, ent);
|
removeAssignedAITask(pos, ent);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!canEntityBeTracked(pos, ent))
|
if (!canEntityBeTracked(pos, ent)) {
|
||||||
{
|
|
||||||
// System.out.println("Cooldown: " + getEntityCooldown(pos, ent));
|
// System.out.println("Cooldown: " + getEntityCooldown(pos, ent));
|
||||||
decrementEntityCooldown(pos, ent);
|
decrementEntityCooldown(pos, ent);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tracking.contains(ent))
|
if (tracking.contains(ent)) {
|
||||||
{
|
|
||||||
trackingThisTick.add(ent);
|
trackingThisTick.add(ent);
|
||||||
onEntityTick(pos, ent);
|
onEntityTick(pos, ent);
|
||||||
} else if (tracking.size() < maxMobsAttracted && trackMob(pos, ent))
|
} else if (tracking.size() < maxMobsAttracted && trackMob(pos, ent)) {
|
||||||
{
|
|
||||||
trackingThisTick.add(ent);
|
trackingThisTick.add(ent);
|
||||||
onTracked(ent);
|
onTracked(ent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (EntityLiving e : tracking)
|
for (EntityLiving e : tracking) {
|
||||||
{
|
if (!trackingThisTick.contains(e)) {
|
||||||
if (!trackingThisTick.contains(e))
|
|
||||||
{
|
|
||||||
onUntracked(e);
|
onUntracked(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,124 +106,98 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canEntityBeTracked(BlockPos pos, EntityLiving entity)
|
public boolean canEntityBeTracked(BlockPos pos, EntityLiving entity) {
|
||||||
{
|
|
||||||
return getEntityCooldown(pos, entity) <= 0;
|
return getEntityCooldown(pos, entity) <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPosKey(BlockPos pos)
|
private String getPosKey(BlockPos pos) {
|
||||||
{
|
|
||||||
return "BMAttractor:" + pos;
|
return "BMAttractor:" + pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getEntityCooldown(BlockPos pos, EntityLiving entity)
|
public int getEntityCooldown(BlockPos pos, EntityLiving entity) {
|
||||||
{
|
|
||||||
return entity.getEntityData().getInteger(getPosKey(pos));
|
return entity.getEntityData().getInteger(getPosKey(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEntityCooldown(BlockPos pos, EntityLiving entity, int cooldown)
|
public void setEntityCooldown(BlockPos pos, EntityLiving entity, int cooldown) {
|
||||||
{
|
|
||||||
entity.getEntityData().setInteger(getPosKey(pos), cooldown);
|
entity.getEntityData().setInteger(getPosKey(pos), cooldown);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void decrementEntityCooldown(BlockPos pos, EntityLiving entity)
|
public void decrementEntityCooldown(BlockPos pos, EntityLiving entity) {
|
||||||
{
|
|
||||||
int cooldown = getEntityCooldown(pos, entity);
|
int cooldown = getEntityCooldown(pos, entity);
|
||||||
if (cooldown > 0)
|
if (cooldown > 0) {
|
||||||
{
|
|
||||||
setEntityCooldown(pos, entity, cooldown - 1);
|
setEntityCooldown(pos, entity, cooldown - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AxisAlignedBB getBounds(BlockPos pos)
|
public AxisAlignedBB getBounds(BlockPos pos) {
|
||||||
{
|
|
||||||
return new AxisAlignedBB(pos).expand(getRange(), getRange(), getRange());
|
return new AxisAlignedBB(pos).expand(getRange(), getRange(), getRange());
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getRange()
|
public float getRange() {
|
||||||
{
|
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onUntracked(EntityLiving e)
|
private void onUntracked(EntityLiving e) {
|
||||||
{
|
if (e instanceof EntityEnderman) {
|
||||||
if (e instanceof EntityEnderman)
|
|
||||||
{
|
|
||||||
e.getEntityData().setBoolean("BM:tracked", false);
|
e.getEntityData().setBoolean("BM:tracked", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onTracked(EntityLiving e)
|
private void onTracked(EntityLiving e) {
|
||||||
{
|
if (e instanceof EntityEnderman) {
|
||||||
if (e instanceof EntityEnderman)
|
|
||||||
{
|
|
||||||
e.getEntityData().setBoolean("BM:tracked", true);
|
e.getEntityData().setBoolean("BM:tracked", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onEntityTick(BlockPos pos, EntityLiving ent)
|
private void onEntityTick(BlockPos pos, EntityLiving ent) {
|
||||||
{
|
if (ent instanceof EntitySlime) {
|
||||||
if (ent instanceof EntitySlime)
|
|
||||||
{
|
|
||||||
ent.faceEntity(getTarget(ent.getEntityWorld(), pos), 10.0F, 20.0F);
|
ent.faceEntity(getTarget(ent.getEntityWorld(), pos), 10.0F, 20.0F);
|
||||||
} else if (ent instanceof EntitySilverfish)
|
} else if (ent instanceof EntitySilverfish) {
|
||||||
{
|
if (counter < 10) {
|
||||||
if (counter < 10)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EntitySilverfish sf = (EntitySilverfish) ent;
|
EntitySilverfish sf = (EntitySilverfish) ent;
|
||||||
Path pathentity = getPathEntityToEntity(ent, getTarget(ent.getEntityWorld(), pos), getRange());
|
Path pathentity = getPathEntityToEntity(ent, getTarget(ent.getEntityWorld(), pos), getRange());
|
||||||
sf.getNavigator().setPath(pathentity, sf.getAIMoveSpeed());
|
sf.getNavigator().setPath(pathentity, sf.getAIMoveSpeed());
|
||||||
} else if (ent instanceof EntityBlaze)
|
} else if (ent instanceof EntityBlaze) {
|
||||||
{
|
|
||||||
double x = (pos.getX() + 0.5D - ent.posX);
|
double x = (pos.getX() + 0.5D - ent.posX);
|
||||||
double y = (pos.getY() + 1D - ent.posY);
|
double y = (pos.getY() + 1D - ent.posY);
|
||||||
double z = (pos.getZ() + 0.5D - ent.posZ);
|
double z = (pos.getZ() + 0.5D - ent.posZ);
|
||||||
double distance = Math.sqrt(x * x + y * y + z * z);
|
double distance = Math.sqrt(x * x + y * y + z * z);
|
||||||
if (distance > 1.25)
|
if (distance > 1.25) {
|
||||||
{
|
|
||||||
double speed = 0.01;
|
double speed = 0.01;
|
||||||
ent.motionX += x / distance * speed;
|
ent.motionX += x / distance * speed;
|
||||||
if (y > 0)
|
if (y > 0) {
|
||||||
{
|
|
||||||
ent.motionY += (0.3 - ent.motionY) * 0.3;
|
ent.motionY += (0.3 - ent.motionY) * 0.3;
|
||||||
}
|
}
|
||||||
ent.motionZ += z / distance * speed;
|
ent.motionZ += z / distance * speed;
|
||||||
}
|
}
|
||||||
} else if (ent instanceof EntityPigZombie || ent instanceof EntitySpider)
|
} else if (ent instanceof EntityPigZombie || ent instanceof EntitySpider) {
|
||||||
{
|
|
||||||
forceMove(pos, ent);
|
forceMove(pos, ent);
|
||||||
// ent.setAttackTarget(target);
|
// ent.setAttackTarget(target);
|
||||||
} else if (ent instanceof EntityEnderman)
|
} else if (ent instanceof EntityEnderman) {
|
||||||
{
|
|
||||||
ent.setAttackTarget(getTarget(ent.getEntityWorld(), pos));
|
ent.setAttackTarget(getTarget(ent.getEntityWorld(), pos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void forceMove(BlockPos pos, EntityLiving ent)
|
private void forceMove(BlockPos pos, EntityLiving ent) {
|
||||||
{
|
|
||||||
double x = (pos.getX() + 0.5D - ent.posX);
|
double x = (pos.getX() + 0.5D - ent.posX);
|
||||||
double y = (pos.getY() + 1D - ent.posY);
|
double y = (pos.getY() + 1D - ent.posY);
|
||||||
double z = (pos.getZ() + 0.5D - ent.posZ);
|
double z = (pos.getZ() + 0.5D - ent.posZ);
|
||||||
double distance = Math.sqrt(x * x + y * y + z * z);
|
double distance = Math.sqrt(x * x + y * y + z * z);
|
||||||
if (distance > 2)
|
if (distance > 2) {
|
||||||
{
|
|
||||||
EntityMob mod = (EntityMob) ent;
|
EntityMob mod = (EntityMob) ent;
|
||||||
mod.faceEntity(getTarget(ent.getEntityWorld(), pos), 180, 0);
|
mod.faceEntity(getTarget(ent.getEntityWorld(), pos), 180, 0);
|
||||||
mod.getMoveHelper().strafe(0, 0.3f);
|
mod.getMoveHelper().strafe(0, 0.3f);
|
||||||
if (mod.posY < pos.getY())
|
if (mod.posY < pos.getY()) {
|
||||||
{
|
|
||||||
mod.setJumping(true);
|
mod.setJumping(true);
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
mod.setJumping(false);
|
mod.setJumping(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Path getPathEntityToEntity(Entity entity, Entity targetEntity, float range)
|
public Path getPathEntityToEntity(Entity entity, Entity targetEntity, float range) {
|
||||||
{
|
|
||||||
int targX = MathHelper.floor(targetEntity.posX);
|
int targX = MathHelper.floor(targetEntity.posX);
|
||||||
int targY = MathHelper.floor(targetEntity.posY + 1.0D);
|
int targY = MathHelper.floor(targetEntity.posY + 1.0D);
|
||||||
int targZ = MathHelper.floor(targetEntity.posZ);
|
int targZ = MathHelper.floor(targetEntity.posZ);
|
||||||
|
@ -256,74 +206,57 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
|
||||||
return pf.findPath(targetEntity.getEntityWorld(), (EntityLiving) entity, new BlockPos(targX, targY, targZ), range);
|
return pf.findPath(targetEntity.getEntityWorld(), (EntityLiving) entity, new BlockPos(targX, targY, targZ), range);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean trackMob(BlockPos pos, EntityLiving ent)
|
private boolean trackMob(BlockPos pos, EntityLiving ent) {
|
||||||
{
|
|
||||||
//TODO: Figure out if this crud is needed
|
//TODO: Figure out if this crud is needed
|
||||||
if (useSetTarget(ent))
|
if (useSetTarget(ent)) {
|
||||||
{
|
|
||||||
ent.setAttackTarget(getTarget(ent.getEntityWorld(), pos));
|
ent.setAttackTarget(getTarget(ent.getEntityWorld(), pos));
|
||||||
return true;
|
return true;
|
||||||
} else if (useSpecialCase(ent))
|
} else if (useSpecialCase(ent)) {
|
||||||
{
|
|
||||||
return applySpecialCase(pos, ent);
|
return applySpecialCase(pos, ent);
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
return attractUsingAITask(pos, ent);
|
return attractUsingAITask(pos, ent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean useSetTarget(EntityLiving ent)
|
private boolean useSetTarget(EntityLiving ent) {
|
||||||
{
|
|
||||||
return ent instanceof EntityPigZombie || ent instanceof EntitySpider || ent instanceof EntitySilverfish;
|
return ent instanceof EntityPigZombie || ent instanceof EntitySpider || ent instanceof EntitySilverfish;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeAssignedAITask(BlockPos pos, EntityLiving ent)
|
public void removeAssignedAITask(BlockPos pos, EntityLiving ent) {
|
||||||
{
|
|
||||||
Set<EntityAITaskEntry> entries = ent.tasks.taskEntries;
|
Set<EntityAITaskEntry> entries = ent.tasks.taskEntries;
|
||||||
EntityAIBase remove = null;
|
EntityAIBase remove = null;
|
||||||
for (EntityAITaskEntry entry : entries)
|
for (EntityAITaskEntry entry : entries) {
|
||||||
{
|
if (entry.action instanceof AttractTask) {
|
||||||
if (entry.action instanceof AttractTask)
|
|
||||||
{
|
|
||||||
AttractTask at = (AttractTask) entry.action;
|
AttractTask at = (AttractTask) entry.action;
|
||||||
if (at.coord.equals(pos))
|
if (at.coord.equals(pos)) {
|
||||||
{
|
|
||||||
remove = entry.action;
|
remove = entry.action;
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (remove != null)
|
if (remove != null) {
|
||||||
{
|
|
||||||
ent.tasks.removeTask(remove);
|
ent.tasks.removeTask(remove);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean attractUsingAITask(BlockPos pos, EntityLiving ent)
|
private boolean attractUsingAITask(BlockPos pos, EntityLiving ent) {
|
||||||
{
|
|
||||||
tracking.add(ent);
|
tracking.add(ent);
|
||||||
Set<EntityAITaskEntry> entries = ent.tasks.taskEntries;
|
Set<EntityAITaskEntry> entries = ent.tasks.taskEntries;
|
||||||
// boolean hasTask = false;
|
// boolean hasTask = false;
|
||||||
EntityAIBase remove = null;
|
EntityAIBase remove = null;
|
||||||
// boolean isTracked;
|
// boolean isTracked;
|
||||||
for (EntityAITaskEntry entry : entries)
|
for (EntityAITaskEntry entry : entries) {
|
||||||
{
|
if (entry.action instanceof AttractTask) {
|
||||||
if (entry.action instanceof AttractTask)
|
|
||||||
{
|
|
||||||
AttractTask at = (AttractTask) entry.action;
|
AttractTask at = (AttractTask) entry.action;
|
||||||
if (at.coord.equals(pos) || !at.shouldExecute())
|
if (at.coord.equals(pos) || !at.shouldExecute()) {
|
||||||
{
|
|
||||||
remove = entry.action;
|
remove = entry.action;
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (remove != null)
|
if (remove != null) {
|
||||||
{
|
|
||||||
ent.tasks.removeTask(remove);
|
ent.tasks.removeTask(remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,18 +266,14 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancelCurrentTasks(EntityLiving ent)
|
private void cancelCurrentTasks(EntityLiving ent) {
|
||||||
{
|
|
||||||
Iterator<EntityAITaskEntry> iterator = ent.tasks.taskEntries.iterator();
|
Iterator<EntityAITaskEntry> iterator = ent.tasks.taskEntries.iterator();
|
||||||
|
|
||||||
List<EntityAITasks.EntityAITaskEntry> currentTasks = new ArrayList<EntityAITasks.EntityAITaskEntry>();
|
List<EntityAITasks.EntityAITaskEntry> currentTasks = new ArrayList<EntityAITasks.EntityAITaskEntry>();
|
||||||
while (iterator.hasNext())
|
while (iterator.hasNext()) {
|
||||||
{
|
|
||||||
EntityAITaskEntry entityaitaskentry = iterator.next();
|
EntityAITaskEntry entityaitaskentry = iterator.next();
|
||||||
if (entityaitaskentry != null)
|
if (entityaitaskentry != null) {
|
||||||
{
|
if (entityaitaskentry.action instanceof AttractTask) {
|
||||||
if (entityaitaskentry.action instanceof AttractTask)
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,42 +282,34 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
|
||||||
}
|
}
|
||||||
// Only available way to stop current execution is to remove all current
|
// Only available way to stop current execution is to remove all current
|
||||||
// tasks, then re-add them
|
// tasks, then re-add them
|
||||||
for (EntityAITaskEntry task : currentTasks)
|
for (EntityAITaskEntry task : currentTasks) {
|
||||||
{
|
|
||||||
ent.tasks.removeTask(task.action);
|
ent.tasks.removeTask(task.action);
|
||||||
ent.tasks.addTask(task.priority, task.action);
|
ent.tasks.addTask(task.priority, task.action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean applySpecialCase(BlockPos pos, EntityLiving ent)
|
private boolean applySpecialCase(BlockPos pos, EntityLiving ent) {
|
||||||
{
|
if (ent instanceof EntitySlime) {
|
||||||
if (ent instanceof EntitySlime)
|
|
||||||
{
|
|
||||||
ent.faceEntity(getTarget(ent.getEntityWorld(), pos), 10.0F, 20.0F);
|
ent.faceEntity(getTarget(ent.getEntityWorld(), pos), 10.0F, 20.0F);
|
||||||
// ent.setAttackTarget(getTarget(ent.worldObj, pos));
|
// ent.setAttackTarget(getTarget(ent.worldObj, pos));
|
||||||
return true;
|
return true;
|
||||||
} else if (ent instanceof EntitySilverfish)
|
} else if (ent instanceof EntitySilverfish) {
|
||||||
{
|
|
||||||
EntitySilverfish es = (EntitySilverfish) ent;
|
EntitySilverfish es = (EntitySilverfish) ent;
|
||||||
Path pathentity = getPathEntityToEntity(ent, getTarget(ent.getEntityWorld(), pos), getRange());
|
Path pathentity = getPathEntityToEntity(ent, getTarget(ent.getEntityWorld(), pos), getRange());
|
||||||
es.getNavigator().setPath(pathentity, es.getAIMoveSpeed());
|
es.getNavigator().setPath(pathentity, es.getAIMoveSpeed());
|
||||||
return true;
|
return true;
|
||||||
} else if (ent instanceof EntityBlaze)
|
} else if (ent instanceof EntityBlaze) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean useSpecialCase(EntityLiving ent)
|
private boolean useSpecialCase(EntityLiving ent) {
|
||||||
{
|
|
||||||
return ent instanceof EntitySlime || ent instanceof EntitySilverfish || ent instanceof EntityBlaze;
|
return ent instanceof EntitySlime || ent instanceof EntitySilverfish || ent instanceof EntityBlaze;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FakePlayer getTarget(World world, BlockPos pos)
|
public FakePlayer getTarget(World world, BlockPos pos) {
|
||||||
{
|
if (target == null) {
|
||||||
if (target == null)
|
|
||||||
{
|
|
||||||
// System.out.println("...Hi? " + pos);
|
// System.out.println("...Hi? " + pos);
|
||||||
target = new Target(world, pos);
|
target = new Target(world, pos);
|
||||||
}
|
}
|
||||||
|
@ -396,17 +317,22 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Target extends FakePlayerBM
|
@Override
|
||||||
{
|
public void writeToNBT(NBTTagCompound tag) {
|
||||||
public Target(World world, BlockPos pos)
|
|
||||||
{
|
|
||||||
super(world, pos, new GameProfile(null, BloodMagic.MODID + "ArrayAttractor" + ":" + pos));
|
|
||||||
posY += 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class AttractTask extends EntityAIBase
|
@Override
|
||||||
{
|
public void readFromNBT(NBTTagCompound tag) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AlchemyArrayEffect getNewCopy() {
|
||||||
|
return new AlchemyArrayEffectAttractor(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class AttractTask extends EntityAIBase {
|
||||||
private EntityLiving mob;
|
private EntityLiving mob;
|
||||||
private BlockPos coord;
|
private BlockPos coord;
|
||||||
private FakePlayer target;
|
private FakePlayer target;
|
||||||
|
@ -414,21 +340,18 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
|
||||||
|
|
||||||
private boolean started = false;
|
private boolean started = false;
|
||||||
|
|
||||||
private AttractTask(EntityLiving mob, FakePlayer target, BlockPos coord)
|
private AttractTask(EntityLiving mob, FakePlayer target, BlockPos coord) {
|
||||||
{
|
|
||||||
this.mob = mob;
|
this.mob = mob;
|
||||||
this.coord = coord;
|
this.coord = coord;
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldExecute()
|
public boolean shouldExecute() {
|
||||||
{
|
|
||||||
boolean res = false;
|
boolean res = false;
|
||||||
//TODO:
|
//TODO:
|
||||||
TileEntity te = mob.getEntityWorld().getTileEntity(coord);
|
TileEntity te = mob.getEntityWorld().getTileEntity(coord);
|
||||||
if (te instanceof TileAlchemyArray)
|
if (te instanceof TileAlchemyArray) {
|
||||||
{
|
|
||||||
res = true;
|
res = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,55 +359,38 @@ public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resetTask()
|
public void resetTask() {
|
||||||
{
|
|
||||||
started = false;
|
started = false;
|
||||||
updatesSincePathing = 0;
|
updatesSincePathing = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInterruptible()
|
public boolean isInterruptible() {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTask()
|
public void updateTask() {
|
||||||
{
|
if (!started || updatesSincePathing > 20) {
|
||||||
if (!started || updatesSincePathing > 20)
|
|
||||||
{
|
|
||||||
started = true;
|
started = true;
|
||||||
int speed = 1;
|
int speed = 1;
|
||||||
// mob.getNavigator().setAvoidsWater(false);
|
// mob.getNavigator().setAvoidsWater(false);
|
||||||
boolean res = mob.getNavigator().tryMoveToEntityLiving(target, speed);
|
boolean res = mob.getNavigator().tryMoveToEntityLiving(target, speed);
|
||||||
if (!res)
|
if (!res) {
|
||||||
{
|
|
||||||
mob.getNavigator().tryMoveToXYZ(target.posX, target.posY + 1, target.posZ, speed);
|
mob.getNavigator().tryMoveToXYZ(target.posX, target.posY + 1, target.posZ, speed);
|
||||||
}
|
}
|
||||||
updatesSincePathing = 0;
|
updatesSincePathing = 0;
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
updatesSincePathing++;
|
updatesSincePathing++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private class Target extends FakePlayerBM {
|
||||||
public void writeToNBT(NBTTagCompound tag)
|
public Target(World world, BlockPos pos) {
|
||||||
{
|
super(world, pos, new GameProfile(null, BloodMagic.MODID + "ArrayAttractor" + ":" + pos));
|
||||||
|
posY += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFromNBT(NBTTagCompound tag)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AlchemyArrayEffect getNewCopy()
|
|
||||||
{
|
|
||||||
return new AlchemyArrayEffectAttractor(key);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package WayofTime.bloodmagic.alchemyArray;
|
package WayofTime.bloodmagic.alchemyArray;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
||||||
|
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting;
|
||||||
|
import WayofTime.bloodmagic.client.render.alchemyArray.BindingAlchemyCircleRenderer;
|
||||||
import net.minecraft.entity.effect.EntityLightningBolt;
|
import net.minecraft.entity.effect.EntityLightningBolt;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -7,34 +10,25 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
|
||||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting;
|
|
||||||
import WayofTime.bloodmagic.client.render.alchemyArray.BindingAlchemyCircleRenderer;
|
|
||||||
|
|
||||||
public class AlchemyArrayEffectBinding extends AlchemyArrayEffectCrafting
|
public class AlchemyArrayEffectBinding extends AlchemyArrayEffectCrafting {
|
||||||
{
|
public AlchemyArrayEffectBinding(String key, ItemStack outputStack) {
|
||||||
public AlchemyArrayEffectBinding(String key, ItemStack outputStack)
|
|
||||||
{
|
|
||||||
super(key, outputStack, 200);
|
super(key, outputStack, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(TileEntity tile, int ticksActive)
|
public boolean update(TileEntity tile, int ticksActive) {
|
||||||
{
|
if (ticksActive >= 50 && ticksActive <= 250) {
|
||||||
if (ticksActive >= 50 && ticksActive <= 250)
|
|
||||||
{
|
|
||||||
// TODO: Find a way to spawn lightning from only the server side -
|
// TODO: Find a way to spawn lightning from only the server side -
|
||||||
// does not render when just spawned on server, not client.
|
// does not render when just spawned on server, not client.
|
||||||
this.spawnLightningOnCircle(tile.getWorld(), tile.getPos(), ticksActive);
|
this.spawnLightningOnCircle(tile.getWorld(), tile.getPos(), ticksActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tile.getWorld().isRemote)
|
if (tile.getWorld().isRemote) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ticksActive >= 300)
|
if (ticksActive >= 300) {
|
||||||
{
|
|
||||||
BlockPos pos = tile.getPos();
|
BlockPos pos = tile.getPos();
|
||||||
|
|
||||||
ItemStack output = outputStack.copy();
|
ItemStack output = outputStack.copy();
|
||||||
|
@ -48,10 +42,8 @@ public class AlchemyArrayEffectBinding extends AlchemyArrayEffectCrafting
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnLightningOnCircle(World world, BlockPos pos, int ticksActive)
|
public void spawnLightningOnCircle(World world, BlockPos pos, int ticksActive) {
|
||||||
{
|
if (ticksActive % 50 == 0) {
|
||||||
if (ticksActive % 50 == 0)
|
|
||||||
{
|
|
||||||
int circle = ticksActive / 50 - 1;
|
int circle = ticksActive / 50 - 1;
|
||||||
float distance = BindingAlchemyCircleRenderer.getDistanceOfCircle(circle, ticksActive);
|
float distance = BindingAlchemyCircleRenderer.getDistanceOfCircle(circle, ticksActive);
|
||||||
float angle = BindingAlchemyCircleRenderer.getAngleOfCircle(circle, ticksActive);
|
float angle = BindingAlchemyCircleRenderer.getAngleOfCircle(circle, ticksActive);
|
||||||
|
@ -65,20 +57,17 @@ public class AlchemyArrayEffectBinding extends AlchemyArrayEffectCrafting
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound tag)
|
public void writeToNBT(NBTTagCompound tag) {
|
||||||
{
|
|
||||||
//EMPTY
|
//EMPTY
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound tag)
|
public void readFromNBT(NBTTagCompound tag) {
|
||||||
{
|
|
||||||
//EMPTY
|
//EMPTY
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlchemyArrayEffect getNewCopy()
|
public AlchemyArrayEffect getNewCopy() {
|
||||||
{
|
|
||||||
return new AlchemyArrayEffectBinding(key, outputStack);
|
return new AlchemyArrayEffectBinding(key, outputStack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package WayofTime.bloodmagic.alchemyArray;
|
package WayofTime.bloodmagic.alchemyArray;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
||||||
|
import WayofTime.bloodmagic.api.iface.IAlchemyArray;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
@ -7,34 +9,25 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
|
||||||
import WayofTime.bloodmagic.api.iface.IAlchemyArray;
|
|
||||||
|
|
||||||
public class AlchemyArrayEffectBounce extends AlchemyArrayEffect
|
public class AlchemyArrayEffectBounce extends AlchemyArrayEffect {
|
||||||
{
|
public AlchemyArrayEffectBounce(String key) {
|
||||||
public AlchemyArrayEffectBounce(String key)
|
|
||||||
{
|
|
||||||
super(key);
|
super(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(TileEntity tile, int ticksActive)
|
public boolean update(TileEntity tile, int ticksActive) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity)
|
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity) {
|
||||||
{
|
if (entity.isSneaking()) {
|
||||||
if (entity.isSneaking())
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
} else if (entity.motionY < 0.0D)
|
} else if (entity.motionY < 0.0D) {
|
||||||
{
|
|
||||||
entity.motionY = -entity.motionY;
|
entity.motionY = -entity.motionY;
|
||||||
|
|
||||||
if (!(entity instanceof EntityLivingBase))
|
if (!(entity instanceof EntityLivingBase)) {
|
||||||
{
|
|
||||||
entity.motionY *= 0.8D;
|
entity.motionY *= 0.8D;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,20 +36,17 @@ public class AlchemyArrayEffectBounce extends AlchemyArrayEffect
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound tag)
|
public void writeToNBT(NBTTagCompound tag) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound tag)
|
public void readFromNBT(NBTTagCompound tag) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlchemyArrayEffect getNewCopy()
|
public AlchemyArrayEffect getNewCopy() {
|
||||||
{
|
|
||||||
return new AlchemyArrayEffectBounce(key);
|
return new AlchemyArrayEffectBounce(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
package WayofTime.bloodmagic.alchemyArray;
|
package WayofTime.bloodmagic.alchemyArray;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
||||||
|
import WayofTime.bloodmagic.api.iface.IAlchemyArray;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -7,25 +9,19 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
|
||||||
import WayofTime.bloodmagic.api.iface.IAlchemyArray;
|
|
||||||
|
|
||||||
public class AlchemyArrayEffectMovement extends AlchemyArrayEffect
|
public class AlchemyArrayEffectMovement extends AlchemyArrayEffect {
|
||||||
{
|
public AlchemyArrayEffectMovement(String key) {
|
||||||
public AlchemyArrayEffectMovement(String key)
|
|
||||||
{
|
|
||||||
super(key);
|
super(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(TileEntity tile, int ticksActive)
|
public boolean update(TileEntity tile, int ticksActive) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity)
|
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity) {
|
||||||
{
|
|
||||||
double motionY = 0.5;
|
double motionY = 0.5;
|
||||||
double speed = 3;
|
double speed = 3;
|
||||||
EnumFacing direction = array.getRotation();
|
EnumFacing direction = array.getRotation();
|
||||||
|
@ -33,51 +29,47 @@ public class AlchemyArrayEffectMovement extends AlchemyArrayEffect
|
||||||
entity.motionY = motionY;
|
entity.motionY = motionY;
|
||||||
entity.fallDistance = 0;
|
entity.fallDistance = 0;
|
||||||
|
|
||||||
switch (direction)
|
switch (direction) {
|
||||||
{
|
case NORTH:
|
||||||
case NORTH:
|
entity.motionX = 0;
|
||||||
entity.motionX = 0;
|
entity.motionY = motionY;
|
||||||
entity.motionY = motionY;
|
entity.motionZ = -speed;
|
||||||
entity.motionZ = -speed;
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case SOUTH:
|
case SOUTH:
|
||||||
entity.motionX = 0;
|
entity.motionX = 0;
|
||||||
entity.motionY = motionY;
|
entity.motionY = motionY;
|
||||||
entity.motionZ = speed;
|
entity.motionZ = speed;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WEST:
|
case WEST:
|
||||||
entity.motionX = -speed;
|
entity.motionX = -speed;
|
||||||
entity.motionY = motionY;
|
entity.motionY = motionY;
|
||||||
entity.motionZ = 0;
|
entity.motionZ = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EAST:
|
case EAST:
|
||||||
entity.motionX = speed;
|
entity.motionX = speed;
|
||||||
entity.motionY = motionY;
|
entity.motionY = motionY;
|
||||||
entity.motionZ = 0;
|
entity.motionZ = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound tag)
|
public void writeToNBT(NBTTagCompound tag) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound tag)
|
public void readFromNBT(NBTTagCompound tag) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlchemyArrayEffect getNewCopy()
|
public AlchemyArrayEffect getNewCopy() {
|
||||||
{
|
|
||||||
return new AlchemyArrayEffectMovement(key);
|
return new AlchemyArrayEffectMovement(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,22 @@
|
||||||
package WayofTime.bloodmagic.alchemyArray;
|
package WayofTime.bloodmagic.alchemyArray;
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
||||||
import WayofTime.bloodmagic.api.iface.ISigil;
|
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
public class AlchemyArrayEffectSigil extends AlchemyArrayEffect
|
public class AlchemyArrayEffectSigil extends AlchemyArrayEffect {
|
||||||
{
|
|
||||||
private final ISigil sigil;
|
private final ISigil sigil;
|
||||||
|
|
||||||
public AlchemyArrayEffectSigil(String key, ISigil sigil)
|
public AlchemyArrayEffectSigil(String key, ISigil sigil) {
|
||||||
{
|
|
||||||
super(key);
|
super(key);
|
||||||
this.sigil = sigil;
|
this.sigil = sigil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(TileEntity tile, int ticksActive)
|
public boolean update(TileEntity tile, int ticksActive) {
|
||||||
{
|
|
||||||
//TODO: Need particles.
|
//TODO: Need particles.
|
||||||
if (sigil.hasArrayEffect())
|
if (sigil.hasArrayEffect()) {
|
||||||
{
|
|
||||||
sigil.performArrayEffect(tile.getWorld(), tile.getPos());
|
sigil.performArrayEffect(tile.getWorld(), tile.getPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,20 +24,17 @@ public class AlchemyArrayEffectSigil extends AlchemyArrayEffect
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound tag)
|
public void writeToNBT(NBTTagCompound tag) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound tag)
|
public void readFromNBT(NBTTagCompound tag) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlchemyArrayEffect getNewCopy()
|
public AlchemyArrayEffect getNewCopy() {
|
||||||
{
|
|
||||||
return new AlchemyArrayEffectSigil(key, sigil);
|
return new AlchemyArrayEffectSigil(key, sigil);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,8 @@
|
||||||
package WayofTime.bloodmagic.alchemyArray;
|
package WayofTime.bloodmagic.alchemyArray;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
||||||
import java.util.Iterator;
|
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
||||||
import java.util.List;
|
import com.google.common.base.Predicate;
|
||||||
|
|
||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.SharedMonsterAttributes;
|
import net.minecraft.entity.SharedMonsterAttributes;
|
||||||
import net.minecraft.entity.ai.EntityAIBase;
|
import net.minecraft.entity.ai.EntityAIBase;
|
||||||
|
@ -18,35 +17,29 @@ import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.FakePlayer;
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
|
||||||
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Credits for the initial code go to Crazy Pants of EIO.
|
* Credits for the initial code go to Crazy Pants of EIO.
|
||||||
*/
|
*/
|
||||||
public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect
|
public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect {
|
||||||
{
|
public static Predicate<EntityMob> checkSkeleton = new Predicate<EntityMob>() {
|
||||||
private EntitySkeleton turret;
|
|
||||||
|
|
||||||
public static Predicate<EntityMob> checkSkeleton = new Predicate<EntityMob>()
|
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(EntityMob input)
|
public boolean apply(EntityMob input) {
|
||||||
{
|
|
||||||
return !(input instanceof EntitySkeleton);
|
return !(input instanceof EntitySkeleton);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
private EntitySkeleton turret;
|
||||||
|
|
||||||
public AlchemyArrayEffectSkeletonTurret(String key)
|
public AlchemyArrayEffectSkeletonTurret(String key) {
|
||||||
{
|
|
||||||
super(key);
|
super(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(TileEntity tile, int ticksActive)
|
public boolean update(TileEntity tile, int ticksActive) {
|
||||||
{
|
|
||||||
// if (tile.getWorld().isRemote)
|
// if (tile.getWorld().isRemote)
|
||||||
// {
|
// {
|
||||||
// return false;
|
// return false;
|
||||||
|
@ -54,15 +47,13 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect
|
||||||
|
|
||||||
BlockPos pos = tile.getPos();
|
BlockPos pos = tile.getPos();
|
||||||
|
|
||||||
if (turret != null && !turret.isDead)
|
if (turret != null && !turret.isDead) {
|
||||||
{
|
|
||||||
double x = (pos.getX() + 0.5D - turret.posX);
|
double x = (pos.getX() + 0.5D - turret.posX);
|
||||||
double y = (pos.getY() + 1D - turret.posY);
|
double y = (pos.getY() + 1D - turret.posY);
|
||||||
double z = (pos.getZ() + 0.5D - turret.posZ);
|
double z = (pos.getZ() + 0.5D - turret.posZ);
|
||||||
double distance = Math.sqrt(x * x + y * y + z * z);
|
double distance = Math.sqrt(x * x + y * y + z * z);
|
||||||
|
|
||||||
if (distance < 2)
|
if (distance < 2) {
|
||||||
{
|
|
||||||
// turret.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 100, 100));
|
// turret.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 100, 100));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -72,8 +63,7 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect
|
||||||
|
|
||||||
List<EntitySkeleton> skeletonsInRange = world.getEntitiesWithinAABB(EntitySkeleton.class, getBounds(pos));
|
List<EntitySkeleton> skeletonsInRange = world.getEntitiesWithinAABB(EntitySkeleton.class, getBounds(pos));
|
||||||
|
|
||||||
for (EntitySkeleton entity : skeletonsInRange)
|
for (EntitySkeleton entity : skeletonsInRange) {
|
||||||
{
|
|
||||||
if (!entity.isDead)// && isMobInFilter(ent))
|
if (!entity.isDead)// && isMobInFilter(ent))
|
||||||
{
|
{
|
||||||
modifyAITargetTasks(entity);
|
modifyAITargetTasks(entity);
|
||||||
|
@ -85,13 +75,11 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AxisAlignedBB getBounds(BlockPos pos)
|
public AxisAlignedBB getBounds(BlockPos pos) {
|
||||||
{
|
|
||||||
return new AxisAlignedBB(pos).expand(getRange(), getRange(), getRange());
|
return new AxisAlignedBB(pos).expand(getRange(), getRange(), getRange());
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getRange()
|
public float getRange() {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,8 +93,7 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect
|
||||||
// e.getEntityData().setBoolean("BM:tracked", true);
|
// e.getEntityData().setBoolean("BM:tracked", true);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private boolean modifyAITargetTasks(EntitySkeleton entity)
|
private boolean modifyAITargetTasks(EntitySkeleton entity) {
|
||||||
{
|
|
||||||
cancelCurrentTargetTasks(entity);
|
cancelCurrentTargetTasks(entity);
|
||||||
|
|
||||||
// entity.setCombatTask();
|
// entity.setCombatTask();
|
||||||
|
@ -116,13 +103,11 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancelCurrentTargetTasks(EntityLiving entity)
|
private void cancelCurrentTargetTasks(EntityLiving entity) {
|
||||||
{
|
|
||||||
Iterator<EntityAITaskEntry> iterator = entity.targetTasks.taskEntries.iterator();
|
Iterator<EntityAITaskEntry> iterator = entity.targetTasks.taskEntries.iterator();
|
||||||
|
|
||||||
List<EntityAITasks.EntityAITaskEntry> currentTasks = new ArrayList<EntityAITasks.EntityAITaskEntry>();
|
List<EntityAITasks.EntityAITaskEntry> currentTasks = new ArrayList<EntityAITasks.EntityAITaskEntry>();
|
||||||
while (iterator.hasNext())
|
while (iterator.hasNext()) {
|
||||||
{
|
|
||||||
EntityAITaskEntry entityaitaskentry = iterator.next();
|
EntityAITaskEntry entityaitaskentry = iterator.next();
|
||||||
if (entityaitaskentry != null)// && entityaitaskentry.action instanceof EntityAITarget)
|
if (entityaitaskentry != null)// && entityaitaskentry.action instanceof EntityAITarget)
|
||||||
{
|
{
|
||||||
|
@ -130,14 +115,27 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (EntityAITaskEntry task : currentTasks)
|
for (EntityAITaskEntry task : currentTasks) {
|
||||||
{
|
|
||||||
entity.targetTasks.removeTask(task.action);
|
entity.targetTasks.removeTask(task.action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class AttractTask extends EntityAIBase
|
@Override
|
||||||
{
|
public void writeToNBT(NBTTagCompound tag) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readFromNBT(NBTTagCompound tag) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AlchemyArrayEffect getNewCopy() {
|
||||||
|
return new AlchemyArrayEffectSkeletonTurret(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class AttractTask extends EntityAIBase {
|
||||||
private EntityLiving mob;
|
private EntityLiving mob;
|
||||||
private BlockPos coord;
|
private BlockPos coord;
|
||||||
private FakePlayer target;
|
private FakePlayer target;
|
||||||
|
@ -145,21 +143,18 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect
|
||||||
|
|
||||||
private boolean started = false;
|
private boolean started = false;
|
||||||
|
|
||||||
private AttractTask(EntityLiving mob, FakePlayer target, BlockPos coord)
|
private AttractTask(EntityLiving mob, FakePlayer target, BlockPos coord) {
|
||||||
{
|
|
||||||
this.mob = mob;
|
this.mob = mob;
|
||||||
this.coord = coord;
|
this.coord = coord;
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldExecute()
|
public boolean shouldExecute() {
|
||||||
{
|
|
||||||
boolean res = false;
|
boolean res = false;
|
||||||
//TODO:
|
//TODO:
|
||||||
TileEntity te = mob.getEntityWorld().getTileEntity(coord);
|
TileEntity te = mob.getEntityWorld().getTileEntity(coord);
|
||||||
if (te instanceof TileAlchemyArray)
|
if (te instanceof TileAlchemyArray) {
|
||||||
{
|
|
||||||
res = true;
|
res = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,55 +162,31 @@ public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resetTask()
|
public void resetTask() {
|
||||||
{
|
|
||||||
started = false;
|
started = false;
|
||||||
updatesSincePathing = 0;
|
updatesSincePathing = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInterruptible()
|
public boolean isInterruptible() {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTask()
|
public void updateTask() {
|
||||||
{
|
if (!started || updatesSincePathing > 20) {
|
||||||
if (!started || updatesSincePathing > 20)
|
|
||||||
{
|
|
||||||
started = true;
|
started = true;
|
||||||
int speed = 1;
|
int speed = 1;
|
||||||
// mob.getNavigator().setAvoidsWater(false);
|
// mob.getNavigator().setAvoidsWater(false);
|
||||||
boolean res = mob.getNavigator().tryMoveToEntityLiving(target, speed);
|
boolean res = mob.getNavigator().tryMoveToEntityLiving(target, speed);
|
||||||
if (!res)
|
if (!res) {
|
||||||
{
|
|
||||||
mob.getNavigator().tryMoveToXYZ(target.posX, target.posY + 1, target.posZ, speed);
|
mob.getNavigator().tryMoveToXYZ(target.posX, target.posY + 1, target.posZ, speed);
|
||||||
}
|
}
|
||||||
updatesSincePathing = 0;
|
updatesSincePathing = 0;
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
updatesSincePathing++;
|
updatesSincePathing++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToNBT(NBTTagCompound tag)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFromNBT(NBTTagCompound tag)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AlchemyArrayEffect getNewCopy()
|
|
||||||
{
|
|
||||||
return new AlchemyArrayEffectSkeletonTurret(key);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,26 @@
|
||||||
package WayofTime.bloodmagic.alchemyArray;
|
package WayofTime.bloodmagic.alchemyArray;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
||||||
|
import WayofTime.bloodmagic.api.iface.IAlchemyArray;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
|
||||||
import WayofTime.bloodmagic.api.iface.IAlchemyArray;
|
|
||||||
|
|
||||||
public class AlchemyArrayEffectUpdraft extends AlchemyArrayEffect
|
public class AlchemyArrayEffectUpdraft extends AlchemyArrayEffect {
|
||||||
{
|
public AlchemyArrayEffectUpdraft(String key) {
|
||||||
public AlchemyArrayEffectUpdraft(String key)
|
|
||||||
{
|
|
||||||
super(key);
|
super(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(TileEntity tile, int ticksActive)
|
public boolean update(TileEntity tile, int ticksActive) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity)
|
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity) {
|
||||||
{
|
|
||||||
double motionY = 1.5;
|
double motionY = 1.5;
|
||||||
|
|
||||||
entity.fallDistance = 0;
|
entity.fallDistance = 0;
|
||||||
|
@ -33,20 +29,17 @@ public class AlchemyArrayEffectUpdraft extends AlchemyArrayEffect
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound tag)
|
public void writeToNBT(NBTTagCompound tag) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound tag)
|
public void readFromNBT(NBTTagCompound tag) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlchemyArrayEffect getNewCopy()
|
public AlchemyArrayEffect getNewCopy() {
|
||||||
{
|
|
||||||
return new AlchemyArrayEffectUpdraft(key);
|
return new AlchemyArrayEffectUpdraft(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,21 @@
|
||||||
package WayofTime.bloodmagic.altar;
|
package WayofTime.bloodmagic.altar;
|
||||||
|
|
||||||
import java.util.List;
|
import WayofTime.bloodmagic.api.BlockStack;
|
||||||
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
|
import WayofTime.bloodmagic.api.altar.*;
|
||||||
|
import WayofTime.bloodmagic.api.event.AltarCraftedEvent;
|
||||||
import WayofTime.bloodmagic.api.orb.BloodOrb;
|
import WayofTime.bloodmagic.api.orb.BloodOrb;
|
||||||
|
import WayofTime.bloodmagic.api.orb.IBloodOrb;
|
||||||
|
import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry;
|
||||||
|
import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry.AltarRecipe;
|
||||||
|
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||||
import WayofTime.bloodmagic.api_impl.BloodMagicAPI;
|
import WayofTime.bloodmagic.api_impl.BloodMagicAPI;
|
||||||
|
import WayofTime.bloodmagic.block.BlockBloodRune;
|
||||||
|
import WayofTime.bloodmagic.block.BlockLifeEssence;
|
||||||
|
import WayofTime.bloodmagic.tile.TileAltar;
|
||||||
|
import WayofTime.bloodmagic.util.Utils;
|
||||||
|
import com.google.common.base.Enums;
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -19,38 +31,26 @@ import net.minecraftforge.fluids.FluidTank;
|
||||||
import net.minecraftforge.fluids.capability.FluidTankPropertiesWrapper;
|
import net.minecraftforge.fluids.capability.FluidTankPropertiesWrapper;
|
||||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import WayofTime.bloodmagic.api.BlockStack;
|
import java.util.List;
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
|
||||||
import WayofTime.bloodmagic.api.altar.AltarComponent;
|
|
||||||
import WayofTime.bloodmagic.api.altar.AltarUpgrade;
|
|
||||||
import WayofTime.bloodmagic.api.altar.EnumAltarComponent;
|
|
||||||
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
|
|
||||||
import WayofTime.bloodmagic.api.altar.IAltarComponent;
|
|
||||||
import WayofTime.bloodmagic.api.event.AltarCraftedEvent;
|
|
||||||
import WayofTime.bloodmagic.api.orb.IBloodOrb;
|
|
||||||
import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry;
|
|
||||||
import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry.AltarRecipe;
|
|
||||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
|
||||||
import WayofTime.bloodmagic.block.BlockBloodRune;
|
|
||||||
import WayofTime.bloodmagic.block.BlockLifeEssence;
|
|
||||||
import WayofTime.bloodmagic.tile.TileAltar;
|
|
||||||
import WayofTime.bloodmagic.util.Utils;
|
|
||||||
|
|
||||||
import com.google.common.base.Enums;
|
public class BloodAltar implements IFluidHandler {
|
||||||
import com.google.common.base.Strings;
|
static {
|
||||||
|
EnumAltarTier.ONE.buildComponents();
|
||||||
public class BloodAltar implements IFluidHandler
|
EnumAltarTier.TWO.buildComponents();
|
||||||
{
|
EnumAltarTier.THREE.buildComponents();
|
||||||
private TileAltar tileAltar;
|
EnumAltarTier.FOUR.buildComponents();
|
||||||
private int internalCounter = 0;
|
EnumAltarTier.FIVE.buildComponents();
|
||||||
|
EnumAltarTier.SIX.buildComponents();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isActive;
|
public boolean isActive;
|
||||||
protected FluidStack fluidOutput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0);
|
protected FluidStack fluidOutput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0);
|
||||||
protected FluidStack fluidInput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0);
|
protected FluidStack fluidInput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0);
|
||||||
|
private TileAltar tileAltar;
|
||||||
|
private int internalCounter = 0;
|
||||||
private EnumAltarTier altarTier = EnumAltarTier.ONE;
|
private EnumAltarTier altarTier = EnumAltarTier.ONE;
|
||||||
private AltarUpgrade upgrade;
|
private AltarUpgrade upgrade;
|
||||||
private int capacity = Fluid.BUCKET_VOLUME * 10;
|
private int capacity = Fluid.BUCKET_VOLUME * 10;
|
||||||
|
@ -73,181 +73,21 @@ public class BloodAltar implements IFluidHandler
|
||||||
private int progress;
|
private int progress;
|
||||||
private int lockdownDuration;
|
private int lockdownDuration;
|
||||||
private int demonBloodDuration;
|
private int demonBloodDuration;
|
||||||
|
|
||||||
private int totalCharge = 0; //TODO save
|
private int totalCharge = 0; //TODO save
|
||||||
private int chargingRate = 0;
|
private int chargingRate = 0;
|
||||||
private int chargingFrequency = 0;
|
private int chargingFrequency = 0;
|
||||||
private int maxCharge = 0;
|
private int maxCharge = 0;
|
||||||
|
|
||||||
private int cooldownAfterCrafting = 60;
|
private int cooldownAfterCrafting = 60;
|
||||||
|
|
||||||
private AltarRecipe recipe;
|
private AltarRecipe recipe;
|
||||||
private ItemStack result = ItemStack.EMPTY;
|
private ItemStack result = ItemStack.EMPTY;
|
||||||
|
|
||||||
private EnumAltarTier currentTierDisplayed = EnumAltarTier.ONE;
|
private EnumAltarTier currentTierDisplayed = EnumAltarTier.ONE;
|
||||||
|
|
||||||
public BloodAltar(TileAltar tileAltar)
|
public BloodAltar(TileAltar tileAltar) {
|
||||||
{
|
|
||||||
this.tileAltar = tileAltar;
|
this.tileAltar = tileAltar;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||||
{
|
if (!tagCompound.hasKey(Constants.NBT.EMPTY)) {
|
||||||
EnumAltarTier.ONE.buildComponents();
|
|
||||||
EnumAltarTier.TWO.buildComponents();
|
|
||||||
EnumAltarTier.THREE.buildComponents();
|
|
||||||
EnumAltarTier.FOUR.buildComponents();
|
|
||||||
EnumAltarTier.FIVE.buildComponents();
|
|
||||||
EnumAltarTier.SIX.buildComponents();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EnumAltarTier getAltarTier(World world, BlockPos pos)
|
|
||||||
{
|
|
||||||
for (int i = EnumAltarTier.MAXTIERS - 1; i >= 1; i--)
|
|
||||||
{
|
|
||||||
if (checkAltarIsValid(world, pos, i))
|
|
||||||
{
|
|
||||||
return EnumAltarTier.values()[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return EnumAltarTier.ONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean checkAltarIsValid(World world, BlockPos worldPos, int altarTier)
|
|
||||||
{
|
|
||||||
for (AltarComponent altarComponent : EnumAltarTier.values()[altarTier].getAltarComponents())
|
|
||||||
{
|
|
||||||
BlockPos componentPos = worldPos.add(altarComponent.getOffset());
|
|
||||||
IBlockState state = world.getBlockState(componentPos);
|
|
||||||
|
|
||||||
if (altarComponent.getComponent() == EnumAltarComponent.NOTAIR && world.isAirBlock(componentPos))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (state.getBlock() instanceof IAltarComponent) {
|
|
||||||
EnumAltarComponent component = ((IAltarComponent) state.getBlock()).getType(world, state, componentPos);
|
|
||||||
if (component == null || component != altarComponent.getComponent())
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
EnumAltarComponent component = BloodMagicAPI.INSTANCE.getAltarComponents().get(state);
|
|
||||||
if (component == null || component != altarComponent.getComponent())
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Pair<BlockPos, EnumAltarComponent> getAltarMissingBlock(World world, BlockPos worldPos, int altarTier)
|
|
||||||
{
|
|
||||||
if (altarTier >= EnumAltarTier.MAXTIERS)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (AltarComponent altarComponent : EnumAltarTier.values()[altarTier].getAltarComponents())
|
|
||||||
{
|
|
||||||
BlockPos componentPos = worldPos.add(altarComponent.getOffset());
|
|
||||||
BlockStack worldBlock = new BlockStack(world.getBlockState(componentPos).getBlock(), world.getBlockState(componentPos).getBlock().getMetaFromState(world.getBlockState(componentPos)));
|
|
||||||
|
|
||||||
if (altarComponent.getComponent() != EnumAltarComponent.NOTAIR)
|
|
||||||
{
|
|
||||||
if (worldBlock.getBlock() instanceof IAltarComponent)
|
|
||||||
{
|
|
||||||
EnumAltarComponent component = ((IAltarComponent) worldBlock.getBlock()).getType(world, worldBlock.getState(), componentPos);
|
|
||||||
if (component == null || component != altarComponent.getComponent())
|
|
||||||
{
|
|
||||||
return Pair.of(componentPos, altarComponent.getComponent());
|
|
||||||
}
|
|
||||||
} else if (worldBlock.getBlock() != Utils.getBlockForComponent(altarComponent.getComponent()))
|
|
||||||
{
|
|
||||||
return new ImmutablePair<BlockPos, EnumAltarComponent>(componentPos, altarComponent.getComponent());
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
if (world.isAirBlock(componentPos))
|
|
||||||
{
|
|
||||||
return Pair.of(componentPos, altarComponent.getComponent());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AltarUpgrade getUpgrades(World world, BlockPos pos, EnumAltarTier altarTier)
|
|
||||||
{
|
|
||||||
if (world.isRemote)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
AltarUpgrade upgrades = new AltarUpgrade();
|
|
||||||
List<AltarComponent> list = altarTier.getAltarComponents();
|
|
||||||
|
|
||||||
for (AltarComponent altarComponent : list)
|
|
||||||
{
|
|
||||||
BlockPos componentPos = pos.add(altarComponent.getOffset());
|
|
||||||
|
|
||||||
if (altarComponent.isUpgradeSlot())
|
|
||||||
{
|
|
||||||
BlockStack worldBlock = new BlockStack(world.getBlockState(componentPos).getBlock(), world.getBlockState(componentPos).getBlock().getMetaFromState(world.getBlockState(componentPos)));
|
|
||||||
|
|
||||||
if (worldBlock.getBlock() instanceof BlockBloodRune)
|
|
||||||
{
|
|
||||||
switch (((BlockBloodRune) worldBlock.getBlock()).getRuneEffect(worldBlock.getMeta()))
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
upgrades.addSpeed();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
upgrades.addEfficiency();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
upgrades.addSacrifice();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
upgrades.addSelfSacrifice();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
upgrades.addDisplacement();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 6:
|
|
||||||
upgrades.addCapacity();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 7:
|
|
||||||
upgrades.addBetterCapacity();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 8:
|
|
||||||
upgrades.addOrbCapacity();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 9:
|
|
||||||
upgrades.addAcceleration();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 10:
|
|
||||||
upgrades.addCharging();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return upgrades;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void readFromNBT(NBTTagCompound tagCompound)
|
|
||||||
{
|
|
||||||
if (!tagCompound.hasKey(Constants.NBT.EMPTY))
|
|
||||||
{
|
|
||||||
FluidStack fluid = FluidStack.loadFluidStackFromNBT(tagCompound);
|
FluidStack fluid = FluidStack.loadFluidStackFromNBT(tagCompound);
|
||||||
|
|
||||||
if (fluid != null)
|
if (fluid != null)
|
||||||
|
@ -290,8 +130,7 @@ public class BloodAltar implements IFluidHandler
|
||||||
currentTierDisplayed = Enums.getIfPresent(EnumAltarTier.class, tagCompound.getString(Constants.NBT.ALTAR_CURRENT_TIER_DISPLAYED)).or(EnumAltarTier.ONE);
|
currentTierDisplayed = Enums.getIfPresent(EnumAltarTier.class, tagCompound.getString(Constants.NBT.ALTAR_CURRENT_TIER_DISPLAYED)).or(EnumAltarTier.ONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeToNBT(NBTTagCompound tagCompound)
|
public void writeToNBT(NBTTagCompound tagCompound) {
|
||||||
{
|
|
||||||
|
|
||||||
if (fluid != null)
|
if (fluid != null)
|
||||||
fluid.writeToNBT(tagCompound);
|
fluid.writeToNBT(tagCompound);
|
||||||
|
@ -334,8 +173,7 @@ public class BloodAltar implements IFluidHandler
|
||||||
tagCompound.setString(Constants.NBT.ALTAR_CURRENT_TIER_DISPLAYED, currentTierDisplayed.name());
|
tagCompound.setString(Constants.NBT.ALTAR_CURRENT_TIER_DISPLAYED, currentTierDisplayed.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startCycle()
|
public void startCycle() {
|
||||||
{
|
|
||||||
if (tileAltar.getWorld() != null)
|
if (tileAltar.getWorld() != null)
|
||||||
tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3);
|
tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3);
|
||||||
|
|
||||||
|
@ -349,14 +187,11 @@ public class BloodAltar implements IFluidHandler
|
||||||
|
|
||||||
ItemStack input = tileAltar.getStackInSlot(0);
|
ItemStack input = tileAltar.getStackInSlot(0);
|
||||||
|
|
||||||
if (!input.isEmpty())
|
if (!input.isEmpty()) {
|
||||||
{
|
|
||||||
// Do recipes
|
// Do recipes
|
||||||
AltarRecipe recipe = AltarRecipeRegistry.getRecipeForInput(input);
|
AltarRecipe recipe = AltarRecipeRegistry.getRecipeForInput(input);
|
||||||
if (recipe != null)
|
if (recipe != null) {
|
||||||
{
|
if (recipe.doesRequiredItemMatch(input, altarTier)) {
|
||||||
if (recipe.doesRequiredItemMatch(input, altarTier))
|
|
||||||
{
|
|
||||||
this.isActive = true;
|
this.isActive = true;
|
||||||
this.recipe = recipe;
|
this.recipe = recipe;
|
||||||
this.result = recipe.getOutput().isEmpty() ? ItemStack.EMPTY : new ItemStack(recipe.getOutput().getItem(), 1, recipe.getOutput().getMetadata());
|
this.result = recipe.getOutput().isEmpty() ? ItemStack.EMPTY : new ItemStack(recipe.getOutput().getItem(), 1, recipe.getOutput().getMetadata());
|
||||||
|
@ -372,8 +207,7 @@ public class BloodAltar implements IFluidHandler
|
||||||
isActive = false;
|
isActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update()
|
public void update() {
|
||||||
{
|
|
||||||
World world = tileAltar.getWorld();
|
World world = tileAltar.getWorld();
|
||||||
BlockPos pos = tileAltar.getPos();
|
BlockPos pos = tileAltar.getPos();
|
||||||
|
|
||||||
|
@ -386,17 +220,14 @@ public class BloodAltar implements IFluidHandler
|
||||||
if (lockdownDuration > 0)
|
if (lockdownDuration > 0)
|
||||||
lockdownDuration--;
|
lockdownDuration--;
|
||||||
|
|
||||||
if (internalCounter % 20 == 0)
|
if (internalCounter % 20 == 0) {
|
||||||
{
|
for (EnumFacing facing : EnumFacing.VALUES) {
|
||||||
for (EnumFacing facing : EnumFacing.VALUES)
|
|
||||||
{
|
|
||||||
BlockPos newPos = pos.offset(facing);
|
BlockPos newPos = pos.offset(facing);
|
||||||
IBlockState block = world.getBlockState(newPos);
|
IBlockState block = world.getBlockState(newPos);
|
||||||
block.getBlock().onNeighborChange(world, newPos, pos);
|
block.getBlock().onNeighborChange(world, newPos, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (internalCounter % (Math.max(20 - this.accelerationUpgrades, 1)) == 0)
|
if (internalCounter % (Math.max(20 - this.accelerationUpgrades, 1)) == 0) {
|
||||||
{
|
|
||||||
int syphonMax = (int) (20 * this.dislocationMultiplier);
|
int syphonMax = (int) (20 * this.dislocationMultiplier);
|
||||||
int fluidInputted;
|
int fluidInputted;
|
||||||
int fluidOutputted;
|
int fluidOutputted;
|
||||||
|
@ -411,8 +242,7 @@ public class BloodAltar implements IFluidHandler
|
||||||
tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3);
|
tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (internalCounter % this.getChargingFrequency() == 0 && !this.isActive)
|
if (internalCounter % this.getChargingFrequency() == 0 && !this.isActive) {
|
||||||
{
|
|
||||||
int chargeInputted = Math.min(chargingRate, this.fluid.amount);
|
int chargeInputted = Math.min(chargingRate, this.fluid.amount);
|
||||||
chargeInputted = Math.min(chargeInputted, maxCharge - totalCharge);
|
chargeInputted = Math.min(chargeInputted, maxCharge - totalCharge);
|
||||||
totalCharge += chargeInputted;
|
totalCharge += chargeInputted;
|
||||||
|
@ -426,10 +256,8 @@ public class BloodAltar implements IFluidHandler
|
||||||
updateAltar();
|
updateAltar();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAltar()
|
private void updateAltar() {
|
||||||
{
|
if (!isActive) {
|
||||||
if (!isActive)
|
|
||||||
{
|
|
||||||
if (cooldownAfterCrafting > 0)
|
if (cooldownAfterCrafting > 0)
|
||||||
cooldownAfterCrafting--;
|
cooldownAfterCrafting--;
|
||||||
return;
|
return;
|
||||||
|
@ -446,13 +274,11 @@ public class BloodAltar implements IFluidHandler
|
||||||
if (world.isRemote)
|
if (world.isRemote)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!canBeFilled)
|
if (!canBeFilled) {
|
||||||
{
|
|
||||||
boolean hasOperated = false;
|
boolean hasOperated = false;
|
||||||
int stackSize = input.getCount();
|
int stackSize = input.getCount();
|
||||||
|
|
||||||
if (totalCharge > 0)
|
if (totalCharge > 0) {
|
||||||
{
|
|
||||||
int chargeDrained = Math.min(liquidRequired * stackSize - progress, totalCharge);
|
int chargeDrained = Math.min(liquidRequired * stackSize - progress, totalCharge);
|
||||||
|
|
||||||
totalCharge -= chargeDrained;
|
totalCharge -= chargeDrained;
|
||||||
|
@ -460,8 +286,7 @@ public class BloodAltar implements IFluidHandler
|
||||||
|
|
||||||
hasOperated = true;
|
hasOperated = true;
|
||||||
}
|
}
|
||||||
if (fluid != null && fluid.amount >= 1)
|
if (fluid != null && fluid.amount >= 1) {
|
||||||
{
|
|
||||||
int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? consumptionRate * (1 + consumptionMultiplier) : consumptionRate), fluid.amount);
|
int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? consumptionRate * (1 + consumptionMultiplier) : consumptionRate), fluid.amount);
|
||||||
|
|
||||||
if (liquidDrained > (liquidRequired * stackSize - progress))
|
if (liquidDrained > (liquidRequired * stackSize - progress))
|
||||||
|
@ -472,27 +297,22 @@ public class BloodAltar implements IFluidHandler
|
||||||
|
|
||||||
hasOperated = true;
|
hasOperated = true;
|
||||||
|
|
||||||
if (internalCounter % 4 == 0 && world instanceof WorldServer)
|
if (internalCounter % 4 == 0 && world instanceof WorldServer) {
|
||||||
{
|
|
||||||
WorldServer server = (WorldServer) world;
|
WorldServer server = (WorldServer) world;
|
||||||
server.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0.2, 0, 0.2, 0);
|
server.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0.2, 0, 0.2, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (!hasOperated && progress > 0)
|
} else if (!hasOperated && progress > 0) {
|
||||||
{
|
|
||||||
progress -= (int) (efficiencyMultiplier * drainRate);
|
progress -= (int) (efficiencyMultiplier * drainRate);
|
||||||
|
|
||||||
if (internalCounter % 2 == 0 && world instanceof WorldServer)
|
if (internalCounter % 2 == 0 && world instanceof WorldServer) {
|
||||||
{
|
|
||||||
WorldServer server = (WorldServer) world;
|
WorldServer server = (WorldServer) world;
|
||||||
server.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0.1, 0, 0.1, 0);
|
server.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0.1, 0, 0.1, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasOperated)
|
if (hasOperated) {
|
||||||
{
|
if (progress >= liquidRequired * stackSize) {
|
||||||
if (progress >= liquidRequired * stackSize)
|
|
||||||
{
|
|
||||||
ItemStack result = this.result;
|
ItemStack result = this.result;
|
||||||
|
|
||||||
if (!result.isEmpty())
|
if (!result.isEmpty())
|
||||||
|
@ -502,8 +322,7 @@ public class BloodAltar implements IFluidHandler
|
||||||
tileAltar.setInventorySlotContents(0, result);
|
tileAltar.setInventorySlotContents(0, result);
|
||||||
progress = 0;
|
progress = 0;
|
||||||
|
|
||||||
if (world instanceof WorldServer)
|
if (world instanceof WorldServer) {
|
||||||
{
|
|
||||||
WorldServer server = (WorldServer) world;
|
WorldServer server = (WorldServer) world;
|
||||||
server.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 40, 0.3, 0, 0.3, 0);
|
server.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 40, 0.3, 0, 0.3, 0);
|
||||||
}
|
}
|
||||||
|
@ -512,8 +331,7 @@ public class BloodAltar implements IFluidHandler
|
||||||
this.isActive = false;
|
this.isActive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
ItemStack returnedItem = tileAltar.getStackInSlot(0);
|
ItemStack returnedItem = tileAltar.getStackInSlot(0);
|
||||||
|
|
||||||
if (returnedItem.isEmpty() || !(returnedItem.getItem() instanceof IBloodOrb))
|
if (returnedItem.isEmpty() || !(returnedItem.getItem() instanceof IBloodOrb))
|
||||||
|
@ -530,16 +348,14 @@ public class BloodAltar implements IFluidHandler
|
||||||
if (Strings.isNullOrEmpty(ownerUUID))
|
if (Strings.isNullOrEmpty(ownerUUID))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fluid != null && fluid.amount >= 1)
|
if (fluid != null && fluid.amount >= 1) {
|
||||||
{
|
|
||||||
int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? consumptionRate * (1 + consumptionMultiplier) : consumptionRate), fluid.amount);
|
int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? consumptionRate * (1 + consumptionMultiplier) : consumptionRate), fluid.amount);
|
||||||
|
|
||||||
BloodOrb orb = item.getOrb(returnedItem);
|
BloodOrb orb = item.getOrb(returnedItem);
|
||||||
int drain = orb == null ? 0 : NetworkHelper.getSoulNetwork(ownerUUID).add(liquidDrained, (int) (orb.getCapacity() * this.orbCapacityMultiplier));
|
int drain = orb == null ? 0 : NetworkHelper.getSoulNetwork(ownerUUID).add(liquidDrained, (int) (orb.getCapacity() * this.orbCapacityMultiplier));
|
||||||
fluid.amount = fluid.amount - drain;
|
fluid.amount = fluid.amount - drain;
|
||||||
|
|
||||||
if (drain > 0 && internalCounter % 4 == 0 && world instanceof WorldServer)
|
if (drain > 0 && internalCounter % 4 == 0 && world instanceof WorldServer) {
|
||||||
{
|
|
||||||
WorldServer server = (WorldServer) world;
|
WorldServer server = (WorldServer) world;
|
||||||
server.spawnParticle(EnumParticleTypes.SPELL_WITCH, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0, 0, 0, 0.001);
|
server.spawnParticle(EnumParticleTypes.SPELL_WITCH, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0, 0, 0, 0.001);
|
||||||
}
|
}
|
||||||
|
@ -549,8 +365,7 @@ public class BloodAltar implements IFluidHandler
|
||||||
tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3);
|
tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkTier()
|
public void checkTier() {
|
||||||
{
|
|
||||||
EnumAltarTier tier = BloodAltar.getAltarTier(tileAltar.getWorld(), tileAltar.getPos());
|
EnumAltarTier tier = BloodAltar.getAltarTier(tileAltar.getWorld(), tileAltar.getPos());
|
||||||
this.altarTier = tier;
|
this.altarTier = tier;
|
||||||
|
|
||||||
|
@ -559,8 +374,7 @@ public class BloodAltar implements IFluidHandler
|
||||||
if (tier.equals(currentTierDisplayed))
|
if (tier.equals(currentTierDisplayed))
|
||||||
currentTierDisplayed = EnumAltarTier.ONE;
|
currentTierDisplayed = EnumAltarTier.ONE;
|
||||||
|
|
||||||
if (tier.equals(EnumAltarTier.ONE))
|
if (tier.equals(EnumAltarTier.ONE)) {
|
||||||
{
|
|
||||||
upgrade = null;
|
upgrade = null;
|
||||||
isUpgraded = false;
|
isUpgraded = false;
|
||||||
this.consumptionMultiplier = 0;
|
this.consumptionMultiplier = 0;
|
||||||
|
@ -576,8 +390,7 @@ public class BloodAltar implements IFluidHandler
|
||||||
this.maxCharge = 0;
|
this.maxCharge = 0;
|
||||||
this.totalCharge = 0;
|
this.totalCharge = 0;
|
||||||
return;
|
return;
|
||||||
} else if (!tier.equals(EnumAltarTier.ONE) && upgrade != null)
|
} else if (!tier.equals(EnumAltarTier.ONE) && upgrade != null) {
|
||||||
{
|
|
||||||
this.isUpgraded = true;
|
this.isUpgraded = true;
|
||||||
this.accelerationUpgrades = upgrade.getAccelerationCount();
|
this.accelerationUpgrades = upgrade.getAccelerationCount();
|
||||||
this.consumptionMultiplier = (float) (0.20 * upgrade.getSpeedCount());
|
this.consumptionMultiplier = (float) (0.20 * upgrade.getSpeedCount());
|
||||||
|
@ -607,128 +420,103 @@ public class BloodAltar implements IFluidHandler
|
||||||
tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3);
|
tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int fillMainTank(int amount)
|
public int fillMainTank(int amount) {
|
||||||
{
|
|
||||||
int filledAmount = Math.min(capacity - fluid.amount, amount);
|
int filledAmount = Math.min(capacity - fluid.amount, amount);
|
||||||
fluid.amount += filledAmount;
|
fluid.amount += filledAmount;
|
||||||
|
|
||||||
return filledAmount;
|
return filledAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sacrificialDaggerCall(int amount, boolean isSacrifice)
|
public void sacrificialDaggerCall(int amount, boolean isSacrifice) {
|
||||||
{
|
if (this.lockdownDuration > 0) {
|
||||||
if (this.lockdownDuration > 0)
|
|
||||||
{
|
|
||||||
int amt = (int) Math.min(bufferCapacity - fluidInput.amount, (isSacrifice ? 1 + sacrificeEfficiencyMultiplier : 1 + selfSacrificeEfficiencyMultiplier) * amount);
|
int amt = (int) Math.min(bufferCapacity - fluidInput.amount, (isSacrifice ? 1 + sacrificeEfficiencyMultiplier : 1 + selfSacrificeEfficiencyMultiplier) * amount);
|
||||||
fluidInput.amount += amt;
|
fluidInput.amount += amt;
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
fluid.amount += Math.min(capacity - fluid.amount, (isSacrifice ? 1 + sacrificeEfficiencyMultiplier : 1 + selfSacrificeEfficiencyMultiplier) * amount);
|
fluid.amount += Math.min(capacity - fluid.amount, (isSacrifice ? 1 + sacrificeEfficiencyMultiplier : 1 + selfSacrificeEfficiencyMultiplier) * amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMainFluid(FluidStack fluid)
|
public void setMainFluid(FluidStack fluid) {
|
||||||
{
|
|
||||||
this.fluid = fluid;
|
this.fluid = fluid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOutputFluid(FluidStack fluid)
|
public void setOutputFluid(FluidStack fluid) {
|
||||||
{
|
|
||||||
this.fluidOutput = fluid;
|
this.fluidOutput = fluid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInputFluid(FluidStack fluid)
|
public void setInputFluid(FluidStack fluid) {
|
||||||
{
|
|
||||||
this.fluidInput = fluid;
|
this.fluidInput = fluid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AltarUpgrade getUpgrade()
|
public AltarUpgrade getUpgrade() {
|
||||||
{
|
|
||||||
return upgrade;
|
return upgrade;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpgrade(AltarUpgrade upgrade)
|
public void setUpgrade(AltarUpgrade upgrade) {
|
||||||
{
|
|
||||||
this.upgrade = upgrade;
|
this.upgrade = upgrade;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCapacity()
|
public int getCapacity() {
|
||||||
{
|
|
||||||
return capacity;
|
return capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FluidStack getFluid()
|
public FluidStack getFluid() {
|
||||||
{
|
|
||||||
return fluid;
|
return fluid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFluidAmount()
|
public int getFluidAmount() {
|
||||||
{
|
|
||||||
return fluid.amount;
|
return fluid.amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCurrentBlood()
|
public int getCurrentBlood() {
|
||||||
{
|
|
||||||
return getFluidAmount();
|
return getFluidAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EnumAltarTier getTier()
|
public EnumAltarTier getTier() {
|
||||||
{
|
|
||||||
return altarTier;
|
return altarTier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTier(EnumAltarTier tier)
|
public void setTier(EnumAltarTier tier) {
|
||||||
{
|
|
||||||
this.altarTier = tier;
|
this.altarTier = tier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProgress()
|
public int getProgress() {
|
||||||
{
|
|
||||||
return progress;
|
return progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getSacrificeMultiplier()
|
public float getSacrificeMultiplier() {
|
||||||
{
|
|
||||||
return sacrificeEfficiencyMultiplier;
|
return sacrificeEfficiencyMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getSelfSacrificeMultiplier()
|
public float getSelfSacrificeMultiplier() {
|
||||||
{
|
|
||||||
return selfSacrificeEfficiencyMultiplier;
|
return selfSacrificeEfficiencyMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getOrbMultiplier()
|
public float getOrbMultiplier() {
|
||||||
{
|
|
||||||
return orbCapacityMultiplier;
|
return orbCapacityMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getDislocationMultiplier()
|
public float getDislocationMultiplier() {
|
||||||
{
|
|
||||||
return dislocationMultiplier;
|
return dislocationMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getConsumptionMultiplier()
|
public float getConsumptionMultiplier() {
|
||||||
{
|
|
||||||
return consumptionMultiplier;
|
return consumptionMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getConsumptionRate()
|
public float getConsumptionRate() {
|
||||||
{
|
|
||||||
return consumptionRate;
|
return consumptionRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLiquidRequired()
|
public int getLiquidRequired() {
|
||||||
{
|
|
||||||
return liquidRequired;
|
return liquidRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBufferCapacity()
|
public int getBufferCapacity() {
|
||||||
{
|
|
||||||
return bufferCapacity;
|
return bufferCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setCurrentTierDisplayed(EnumAltarTier altarTier)
|
public boolean setCurrentTierDisplayed(EnumAltarTier altarTier) {
|
||||||
{
|
|
||||||
if (currentTierDisplayed == altarTier)
|
if (currentTierDisplayed == altarTier)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
|
@ -736,99 +524,79 @@ public class BloodAltar implements IFluidHandler
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addToDemonBloodDuration(int dur)
|
public void addToDemonBloodDuration(int dur) {
|
||||||
{
|
|
||||||
this.demonBloodDuration += dur;
|
this.demonBloodDuration += dur;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasDemonBlood()
|
public boolean hasDemonBlood() {
|
||||||
{
|
|
||||||
return this.demonBloodDuration > 0;
|
return this.demonBloodDuration > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void decrementDemonBlood()
|
public void decrementDemonBlood() {
|
||||||
{
|
|
||||||
this.demonBloodDuration = Math.max(0, this.demonBloodDuration - 1);
|
this.demonBloodDuration = Math.max(0, this.demonBloodDuration - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActive()
|
public void setActive() {
|
||||||
{
|
if (tileAltar.getStackInSlot(0).isEmpty()) {
|
||||||
if (tileAltar.getStackInSlot(0).isEmpty())
|
|
||||||
{
|
|
||||||
isActive = false;
|
isActive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isActive()
|
public boolean isActive() {
|
||||||
{
|
|
||||||
return isActive;
|
return isActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestPauseAfterCrafting(int amount)
|
public void requestPauseAfterCrafting(int amount) {
|
||||||
{
|
if (this.isActive) {
|
||||||
if (this.isActive)
|
|
||||||
{
|
|
||||||
this.cooldownAfterCrafting = amount;
|
this.cooldownAfterCrafting = amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getChargingRate()
|
public int getChargingRate() {
|
||||||
{
|
|
||||||
return chargingRate;
|
return chargingRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTotalCharge()
|
public int getTotalCharge() {
|
||||||
{
|
|
||||||
return totalCharge;
|
return totalCharge;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getChargingFrequency()
|
public int getChargingFrequency() {
|
||||||
{
|
|
||||||
return chargingFrequency == 0 ? 1 : chargingFrequency;
|
return chargingFrequency == 0 ? 1 : chargingFrequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int fill(FluidStack resource, boolean doFill)
|
public int fill(FluidStack resource, boolean doFill) {
|
||||||
{
|
if (resource == null || resource.getFluid() != BlockLifeEssence.getLifeEssence()) {
|
||||||
if (resource == null || resource.getFluid() != BlockLifeEssence.getLifeEssence())
|
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!doFill)
|
if (!doFill) {
|
||||||
{
|
if (fluidInput == null) {
|
||||||
if (fluidInput == null)
|
|
||||||
{
|
|
||||||
return Math.min(bufferCapacity, resource.amount);
|
return Math.min(bufferCapacity, resource.amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fluidInput.isFluidEqual(resource))
|
if (!fluidInput.isFluidEqual(resource)) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Math.min(bufferCapacity - fluidInput.amount, resource.amount);
|
return Math.min(bufferCapacity - fluidInput.amount, resource.amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fluidInput == null)
|
if (fluidInput == null) {
|
||||||
{
|
|
||||||
fluidInput = new FluidStack(resource, Math.min(bufferCapacity, resource.amount));
|
fluidInput = new FluidStack(resource, Math.min(bufferCapacity, resource.amount));
|
||||||
|
|
||||||
return fluidInput.amount;
|
return fluidInput.amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fluidInput.isFluidEqual(resource))
|
if (!fluidInput.isFluidEqual(resource)) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int filled = bufferCapacity - fluidInput.amount;
|
int filled = bufferCapacity - fluidInput.amount;
|
||||||
|
|
||||||
if (resource.amount < filled)
|
if (resource.amount < filled) {
|
||||||
{
|
|
||||||
fluidInput.amount += resource.amount;
|
fluidInput.amount += resource.amount;
|
||||||
filled = resource.amount;
|
filled = resource.amount;
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
fluidInput.amount = bufferCapacity;
|
fluidInput.amount = bufferCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -836,44 +604,160 @@ public class BloodAltar implements IFluidHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FluidStack drain(FluidStack resource, boolean doDrain)
|
public FluidStack drain(FluidStack resource, boolean doDrain) {
|
||||||
{
|
if (resource == null || !resource.isFluidEqual(fluidOutput)) {
|
||||||
if (resource == null || !resource.isFluidEqual(fluidOutput))
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return drain(resource.amount, doDrain);
|
return drain(resource.amount, doDrain);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FluidStack drain(int maxDrain, boolean doDrain)
|
public FluidStack drain(int maxDrain, boolean doDrain) {
|
||||||
{
|
if (fluidOutput == null) {
|
||||||
if (fluidOutput == null)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int drained = maxDrain;
|
int drained = maxDrain;
|
||||||
if (fluidOutput.amount < drained)
|
if (fluidOutput.amount < drained) {
|
||||||
{
|
|
||||||
drained = fluidOutput.amount;
|
drained = fluidOutput.amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
FluidStack stack = new FluidStack(fluidOutput, drained);
|
FluidStack stack = new FluidStack(fluidOutput, drained);
|
||||||
if (doDrain)
|
if (doDrain) {
|
||||||
{
|
|
||||||
fluidOutput.amount -= drained;
|
fluidOutput.amount -= drained;
|
||||||
}
|
}
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IFluidTankProperties[] getTankProperties()
|
public IFluidTankProperties[] getTankProperties() {
|
||||||
{
|
return new IFluidTankProperties[]{new FluidTankPropertiesWrapper(new FluidTank(fluid, capacity))};
|
||||||
return new IFluidTankProperties[] { new FluidTankPropertiesWrapper(new FluidTank(fluid, capacity)) };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EnumAltarTier getCurrentTierDisplayed() {
|
public EnumAltarTier getCurrentTierDisplayed() {
|
||||||
return currentTierDisplayed;
|
return currentTierDisplayed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EnumAltarTier getAltarTier(World world, BlockPos pos) {
|
||||||
|
for (int i = EnumAltarTier.MAXTIERS - 1; i >= 1; i--) {
|
||||||
|
if (checkAltarIsValid(world, pos, i)) {
|
||||||
|
return EnumAltarTier.values()[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return EnumAltarTier.ONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean checkAltarIsValid(World world, BlockPos worldPos, int altarTier) {
|
||||||
|
for (AltarComponent altarComponent : EnumAltarTier.values()[altarTier].getAltarComponents()) {
|
||||||
|
BlockPos componentPos = worldPos.add(altarComponent.getOffset());
|
||||||
|
IBlockState state = world.getBlockState(componentPos);
|
||||||
|
|
||||||
|
if (altarComponent.getComponent() == EnumAltarComponent.NOTAIR && world.isAirBlock(componentPos))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (state.getBlock() instanceof IAltarComponent) {
|
||||||
|
EnumAltarComponent component = ((IAltarComponent) state.getBlock()).getType(world, state, componentPos);
|
||||||
|
if (component == null || component != altarComponent.getComponent())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
EnumAltarComponent component = BloodMagicAPI.INSTANCE.getAltarComponents().get(state);
|
||||||
|
if (component == null || component != altarComponent.getComponent())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Pair<BlockPos, EnumAltarComponent> getAltarMissingBlock(World world, BlockPos worldPos, int altarTier) {
|
||||||
|
if (altarTier >= EnumAltarTier.MAXTIERS) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (AltarComponent altarComponent : EnumAltarTier.values()[altarTier].getAltarComponents()) {
|
||||||
|
BlockPos componentPos = worldPos.add(altarComponent.getOffset());
|
||||||
|
BlockStack worldBlock = new BlockStack(world.getBlockState(componentPos).getBlock(), world.getBlockState(componentPos).getBlock().getMetaFromState(world.getBlockState(componentPos)));
|
||||||
|
|
||||||
|
if (altarComponent.getComponent() != EnumAltarComponent.NOTAIR) {
|
||||||
|
if (worldBlock.getBlock() instanceof IAltarComponent) {
|
||||||
|
EnumAltarComponent component = ((IAltarComponent) worldBlock.getBlock()).getType(world, worldBlock.getState(), componentPos);
|
||||||
|
if (component == null || component != altarComponent.getComponent()) {
|
||||||
|
return Pair.of(componentPos, altarComponent.getComponent());
|
||||||
|
}
|
||||||
|
} else if (worldBlock.getBlock() != Utils.getBlockForComponent(altarComponent.getComponent())) {
|
||||||
|
return new ImmutablePair<BlockPos, EnumAltarComponent>(componentPos, altarComponent.getComponent());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (world.isAirBlock(componentPos)) {
|
||||||
|
return Pair.of(componentPos, altarComponent.getComponent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AltarUpgrade getUpgrades(World world, BlockPos pos, EnumAltarTier altarTier) {
|
||||||
|
if (world.isRemote) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
AltarUpgrade upgrades = new AltarUpgrade();
|
||||||
|
List<AltarComponent> list = altarTier.getAltarComponents();
|
||||||
|
|
||||||
|
for (AltarComponent altarComponent : list) {
|
||||||
|
BlockPos componentPos = pos.add(altarComponent.getOffset());
|
||||||
|
|
||||||
|
if (altarComponent.isUpgradeSlot()) {
|
||||||
|
BlockStack worldBlock = new BlockStack(world.getBlockState(componentPos).getBlock(), world.getBlockState(componentPos).getBlock().getMetaFromState(world.getBlockState(componentPos)));
|
||||||
|
|
||||||
|
if (worldBlock.getBlock() instanceof BlockBloodRune) {
|
||||||
|
switch (((BlockBloodRune) worldBlock.getBlock()).getRuneEffect(worldBlock.getMeta())) {
|
||||||
|
case 1:
|
||||||
|
upgrades.addSpeed();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
upgrades.addEfficiency();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
upgrades.addSacrifice();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
upgrades.addSelfSacrifice();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
upgrades.addDisplacement();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 6:
|
||||||
|
upgrades.addCapacity();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 7:
|
||||||
|
upgrades.addBetterCapacity();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 8:
|
||||||
|
upgrades.addOrbCapacity();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 9:
|
||||||
|
upgrades.addAcceleration();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 10:
|
||||||
|
upgrades.addCharging();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return upgrades;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,5 @@ import java.lang.annotation.Target;
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
public @interface Handler
|
public @interface Handler {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,32 +6,22 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class BlockStack
|
public class BlockStack {
|
||||||
{
|
|
||||||
private final Block block;
|
private final Block block;
|
||||||
private final int meta;
|
private final int meta;
|
||||||
private final IBlockState state;
|
private final IBlockState state;
|
||||||
|
|
||||||
public BlockStack(Block block, int meta)
|
public BlockStack(Block block, int meta) {
|
||||||
{
|
|
||||||
this.block = block;
|
this.block = block;
|
||||||
this.meta = meta;
|
this.meta = meta;
|
||||||
this.state = block.getStateFromMeta(meta);
|
this.state = block.getStateFromMeta(meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockStack(Block block)
|
public BlockStack(Block block) {
|
||||||
{
|
|
||||||
this(block, 0);
|
this(block, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BlockStack getStackFromPos(World world, BlockPos pos)
|
public ItemStack getItemStack() {
|
||||||
{
|
|
||||||
IBlockState state = world.getBlockState(pos);
|
|
||||||
return new BlockStack(state.getBlock(), state.getBlock().getMetaFromState(state));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getItemStack()
|
|
||||||
{
|
|
||||||
return new ItemStack(block, 1, meta);
|
return new ItemStack(block, 1, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,8 +56,12 @@ public class BlockStack
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
|
||||||
return getBlock().getRegistryName() + ":" + getMeta();
|
return getBlock().getRegistryName() + ":" + getMeta();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static BlockStack getStackFromPos(World world, BlockPos pos) {
|
||||||
|
IBlockState state = world.getBlockState(pos);
|
||||||
|
return new BlockStack(state.getBlock(), state.getBlock().getMetaFromState(state));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,11 @@ import net.minecraft.util.DamageSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The primary API class. Includes helper methods and blacklists.
|
* The primary API class. Includes helper methods and blacklists.
|
||||||
*
|
* <p>
|
||||||
* Some API methods can be used via IMC instead. The supported methods are:
|
* Some API methods can be used via IMC instead. The supported methods are:
|
||||||
*/
|
*/
|
||||||
// TODO - Nuke this class
|
// TODO - Nuke this class
|
||||||
public class BloodMagicAPI
|
public class BloodMagicAPI {
|
||||||
{
|
|
||||||
public static boolean loggingEnabled;
|
public static boolean loggingEnabled;
|
||||||
|
|
||||||
public static LogHelper logger = new LogHelper("BloodMagic|API");
|
public static LogHelper logger = new LogHelper("BloodMagic|API");
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
package WayofTime.bloodmagic.api;
|
package WayofTime.bloodmagic.api;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import WayofTime.bloodmagic.BloodMagic;
|
import WayofTime.bloodmagic.BloodMagic;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||||
|
|
||||||
public class Constants
|
import java.util.Locale;
|
||||||
{
|
|
||||||
public static class NBT
|
public class Constants {
|
||||||
{
|
public static class NBT {
|
||||||
public static final String OWNER_UUID = "ownerUUID";
|
public static final String OWNER_UUID = "ownerUUID";
|
||||||
public static final String OWNER_NAME = "ownerNAME";
|
public static final String OWNER_NAME = "ownerNAME";
|
||||||
public static final String USES = "uses";
|
public static final String USES = "uses";
|
||||||
|
@ -129,13 +127,11 @@ public class Constants
|
||||||
public static final String TANK = "tank";
|
public static final String TANK = "tank";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Mod
|
public static class Mod {
|
||||||
{
|
|
||||||
public static final String DOMAIN = BloodMagic.MODID.toLowerCase(Locale.ENGLISH) + ":";
|
public static final String DOMAIN = BloodMagic.MODID.toLowerCase(Locale.ENGLISH) + ":";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class Gui
|
public static final class Gui {
|
||||||
{
|
|
||||||
public static final int TELEPOSER_GUI = 0;
|
public static final int TELEPOSER_GUI = 0;
|
||||||
public static final int SOUL_FORGE_GUI = 1;
|
public static final int SOUL_FORGE_GUI = 1;
|
||||||
public static final int ROUTING_NODE_GUI = 2;
|
public static final int ROUTING_NODE_GUI = 2;
|
||||||
|
@ -144,8 +140,7 @@ public class Constants
|
||||||
public static final int SIGIL_HOLDING_GUI = 5;
|
public static final int SIGIL_HOLDING_GUI = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Compat
|
public static class Compat {
|
||||||
{
|
|
||||||
public static final String JEI_CATEGORY_ALTAR = BloodMagic.MODID + ":altar";
|
public static final String JEI_CATEGORY_ALTAR = BloodMagic.MODID + ":altar";
|
||||||
public static final String JEI_CATEGORY_BINDING = BloodMagic.MODID + ":binding";
|
public static final String JEI_CATEGORY_BINDING = BloodMagic.MODID + ":binding";
|
||||||
public static final String JEI_CATEGORY_ALCHEMYARRAY = BloodMagic.MODID + ":alchemyArray";
|
public static final String JEI_CATEGORY_ALCHEMYARRAY = BloodMagic.MODID + ":alchemyArray";
|
||||||
|
@ -163,8 +158,7 @@ public class Constants
|
||||||
public static final Item THAUMCRAFT_GOGGLES = ForgeRegistries.ITEMS.getValue(new ResourceLocation("Thaumcraft", "goggles"));
|
public static final Item THAUMCRAFT_GOGGLES = ForgeRegistries.ITEMS.getValue(new ResourceLocation("Thaumcraft", "goggles"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Misc
|
public static class Misc {
|
||||||
{
|
|
||||||
public static final int POTION_ARRAY_SIZE = 256;
|
public static final int POTION_ARRAY_SIZE = 256;
|
||||||
public static final float ALTERED_STEP_HEIGHT = 1.00314159f;
|
public static final float ALTERED_STEP_HEIGHT = 1.00314159f;
|
||||||
public static final int NIGHT_VISION_CONSTANT_BEGIN = 30002;
|
public static final int NIGHT_VISION_CONSTANT_BEGIN = 30002;
|
||||||
|
|
|
@ -6,10 +6,8 @@ import net.minecraft.util.DamageSource;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.TextComponentString;
|
import net.minecraft.util.text.TextComponentString;
|
||||||
|
|
||||||
public class DamageSourceBloodMagic extends DamageSource
|
public class DamageSourceBloodMagic extends DamageSource {
|
||||||
{
|
public DamageSourceBloodMagic() {
|
||||||
public DamageSourceBloodMagic()
|
|
||||||
{
|
|
||||||
super("bloodMagic");
|
super("bloodMagic");
|
||||||
|
|
||||||
setDamageBypassesArmor();
|
setDamageBypassesArmor();
|
||||||
|
@ -17,8 +15,7 @@ public class DamageSourceBloodMagic extends DamageSource
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITextComponent getDeathMessage(EntityLivingBase livingBase)
|
public ITextComponent getDeathMessage(EntityLivingBase livingBase) {
|
||||||
{
|
|
||||||
return new TextComponentString(TextHelper.localizeEffect("chat.bloodmagic.damageSource", livingBase.getName()));
|
return new TextComponentString(TextHelper.localizeEffect("chat.bloodmagic.damageSource", livingBase.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,7 @@ import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ItemStackWrapper
|
public class ItemStackWrapper {
|
||||||
{
|
|
||||||
public final Item item;
|
public final Item item;
|
||||||
public final int stackSize;
|
public final int stackSize;
|
||||||
public final int meta;
|
public final int meta;
|
||||||
|
@ -22,88 +21,49 @@ public class ItemStackWrapper
|
||||||
this.meta = meta;
|
this.meta = meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStackWrapper(Item item, int stackSize)
|
public ItemStackWrapper(Item item, int stackSize) {
|
||||||
{
|
|
||||||
this(item, stackSize, 0);
|
this(item, stackSize, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStackWrapper(Item item)
|
public ItemStackWrapper(Item item) {
|
||||||
{
|
|
||||||
this(item, 1, 0);
|
this(item, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStackWrapper(Block block, int stackSize, int meta)
|
public ItemStackWrapper(Block block, int stackSize, int meta) {
|
||||||
{
|
|
||||||
this(Item.getItemFromBlock(block), stackSize, meta);
|
this(Item.getItemFromBlock(block), stackSize, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStackWrapper(Block block, int stackSize)
|
public ItemStackWrapper(Block block, int stackSize) {
|
||||||
{
|
|
||||||
this(block, stackSize, 0);
|
this(block, stackSize, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStackWrapper(Block block)
|
public ItemStackWrapper(Block block) {
|
||||||
{
|
|
||||||
this(block, 1, 0);
|
this(block, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStackWrapper(BlockStack blockStack)
|
public ItemStackWrapper(BlockStack blockStack) {
|
||||||
{
|
|
||||||
this(blockStack.getBlock(), 1, blockStack.getMeta());
|
this(blockStack.getBlock(), 1, blockStack.getMeta());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public ItemStack toStack() {
|
||||||
public static ItemStackWrapper getHolder(ItemStack stack)
|
|
||||||
{
|
|
||||||
if (stack.isEmpty())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
ItemStackWrapper wrapper = new ItemStackWrapper(stack.getItem(), stack.getCount(), stack.getItemDamage());
|
|
||||||
wrapper.setNbtTag(stack.getTagCompound());
|
|
||||||
return wrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack toStack()
|
|
||||||
{
|
|
||||||
return new ItemStack(item, stackSize, meta);
|
return new ItemStack(item, stackSize, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDisplayName()
|
public String getDisplayName() {
|
||||||
{
|
|
||||||
return toStack().getDisplayName();
|
return toStack().getDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
|
||||||
return stackSize + "x" + item.getUnlocalizedName() + "@" + this.meta;
|
return stackSize + "x" + item.getUnlocalizedName() + "@" + this.meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack toStack(int count)
|
public ItemStack toStack(int count) {
|
||||||
{
|
|
||||||
ItemStack result = new ItemStack(item, count, meta);
|
ItemStack result = new ItemStack(item, count, meta);
|
||||||
result.setTagCompound(nbtTag);
|
result.setTagCompound(nbtTag);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ItemStackWrapper> toWrapperList(List<ItemStack> itemStackList)
|
|
||||||
{
|
|
||||||
List<ItemStackWrapper> wrapperList = new ArrayList<ItemStackWrapper>();
|
|
||||||
for (ItemStack stack : itemStackList)
|
|
||||||
wrapperList.add(ItemStackWrapper.getHolder(stack));
|
|
||||||
|
|
||||||
return wrapperList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<ItemStack> toStackList(List<ItemStackWrapper> wrapperList)
|
|
||||||
{
|
|
||||||
List<ItemStack> stackList = new ArrayList<ItemStack>();
|
|
||||||
for (ItemStackWrapper wrapper : wrapperList)
|
|
||||||
stackList.add(wrapper.toStack());
|
|
||||||
|
|
||||||
return stackList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Item getItem() {
|
public Item getItem() {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
@ -123,4 +83,30 @@ public class ItemStackWrapper
|
||||||
public void setNbtTag(NBTTagCompound nbtTag) {
|
public void setNbtTag(NBTTagCompound nbtTag) {
|
||||||
this.nbtTag = nbtTag;
|
this.nbtTag = nbtTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static ItemStackWrapper getHolder(ItemStack stack) {
|
||||||
|
if (stack.isEmpty())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
ItemStackWrapper wrapper = new ItemStackWrapper(stack.getItem(), stack.getCount(), stack.getItemDamage());
|
||||||
|
wrapper.setNbtTag(stack.getTagCompound());
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ItemStackWrapper> toWrapperList(List<ItemStack> itemStackList) {
|
||||||
|
List<ItemStackWrapper> wrapperList = new ArrayList<ItemStackWrapper>();
|
||||||
|
for (ItemStack stack : itemStackList)
|
||||||
|
wrapperList.add(ItemStackWrapper.getHolder(stack));
|
||||||
|
|
||||||
|
return wrapperList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ItemStack> toStackList(List<ItemStackWrapper> wrapperList) {
|
||||||
|
List<ItemStack> stackList = new ArrayList<ItemStack>();
|
||||||
|
for (ItemStackWrapper wrapper : wrapperList)
|
||||||
|
stackList.add(wrapper.toStack());
|
||||||
|
|
||||||
|
return stackList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
package WayofTime.bloodmagic.api.alchemyCrafting;
|
package WayofTime.bloodmagic.api.alchemyCrafting;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.iface.IAlchemyArray;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import WayofTime.bloodmagic.api.iface.IAlchemyArray;
|
|
||||||
|
|
||||||
public abstract class AlchemyArrayEffect
|
public abstract class AlchemyArrayEffect {
|
||||||
{
|
|
||||||
public final String key;
|
public final String key;
|
||||||
|
|
||||||
public AlchemyArrayEffect(String key) {
|
public AlchemyArrayEffect(String key) {
|
||||||
|
@ -24,8 +23,7 @@ public abstract class AlchemyArrayEffect
|
||||||
|
|
||||||
public abstract AlchemyArrayEffect getNewCopy();
|
public abstract AlchemyArrayEffect getNewCopy();
|
||||||
|
|
||||||
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity)
|
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,39 +6,32 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect
|
public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect {
|
||||||
{
|
|
||||||
public final ItemStack outputStack;
|
public final ItemStack outputStack;
|
||||||
public int tickLimit;
|
public int tickLimit;
|
||||||
|
|
||||||
public AlchemyArrayEffectCrafting(ItemStack outputStack)
|
public AlchemyArrayEffectCrafting(ItemStack outputStack) {
|
||||||
{
|
|
||||||
this(outputStack, 200);
|
this(outputStack, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlchemyArrayEffectCrafting(ItemStack outputStack, int tickLimit)
|
public AlchemyArrayEffectCrafting(ItemStack outputStack, int tickLimit) {
|
||||||
{
|
|
||||||
this(outputStack.toString() + tickLimit, outputStack, tickLimit);
|
this(outputStack.toString() + tickLimit, outputStack, tickLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlchemyArrayEffectCrafting(String key, ItemStack outputStack, int tickLimit)
|
public AlchemyArrayEffectCrafting(String key, ItemStack outputStack, int tickLimit) {
|
||||||
{
|
|
||||||
super(key);
|
super(key);
|
||||||
this.outputStack = outputStack;
|
this.outputStack = outputStack;
|
||||||
this.tickLimit = tickLimit;
|
this.tickLimit = tickLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(TileEntity tile, int ticksActive)
|
public boolean update(TileEntity tile, int ticksActive) {
|
||||||
{
|
|
||||||
// TODO: Add recipe rechecking to verify nothing screwy is going on.
|
// TODO: Add recipe rechecking to verify nothing screwy is going on.
|
||||||
if (tile.getWorld().isRemote)
|
if (tile.getWorld().isRemote) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ticksActive >= tickLimit)
|
if (ticksActive >= tickLimit) {
|
||||||
{
|
|
||||||
BlockPos pos = tile.getPos();
|
BlockPos pos = tile.getPos();
|
||||||
|
|
||||||
ItemStack output = outputStack.copy();
|
ItemStack output = outputStack.copy();
|
||||||
|
@ -54,20 +47,17 @@ public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound tag)
|
public void writeToNBT(NBTTagCompound tag) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound tag)
|
public void readFromNBT(NBTTagCompound tag) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlchemyArrayEffect getNewCopy()
|
public AlchemyArrayEffect getNewCopy() {
|
||||||
{
|
|
||||||
return new AlchemyArrayEffectCrafting(key, outputStack, tickLimit);
|
return new AlchemyArrayEffectCrafting(key, outputStack, tickLimit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package WayofTime.bloodmagic.api.alchemyCrafting;
|
package WayofTime.bloodmagic.api.alchemyCrafting;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
import net.minecraft.client.renderer.BufferBuilder;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
|
@ -8,73 +9,57 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
|
||||||
|
|
||||||
public class AlchemyCircleRenderer
|
public class AlchemyCircleRenderer {
|
||||||
{
|
|
||||||
public float offsetFromFace = -0.9f;
|
|
||||||
public final ResourceLocation arrayResource;
|
public final ResourceLocation arrayResource;
|
||||||
|
public float offsetFromFace = -0.9f;
|
||||||
|
|
||||||
public AlchemyCircleRenderer()
|
public AlchemyCircleRenderer() {
|
||||||
{
|
|
||||||
this(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png"));
|
this(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlchemyCircleRenderer(ResourceLocation arrayResource)
|
public AlchemyCircleRenderer(ResourceLocation arrayResource) {
|
||||||
{
|
|
||||||
this.arrayResource = arrayResource;
|
this.arrayResource = arrayResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getRotation(float craftTime)
|
public float getRotation(float craftTime) {
|
||||||
{
|
|
||||||
float offset = 2;
|
float offset = 2;
|
||||||
if (craftTime >= offset)
|
if (craftTime >= offset) {
|
||||||
{
|
|
||||||
float modifier = (float) Math.pow(craftTime - offset, 1.5);
|
float modifier = (float) Math.pow(craftTime - offset, 1.5);
|
||||||
return modifier * 1f;
|
return modifier * 1f;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getSecondaryRotation(float craftTime)
|
public float getSecondaryRotation(float craftTime) {
|
||||||
{
|
|
||||||
float offset = 50;
|
float offset = 50;
|
||||||
if (craftTime >= offset)
|
if (craftTime >= offset) {
|
||||||
{
|
|
||||||
float modifier = (float) Math.pow(craftTime - offset, 1.7);
|
float modifier = (float) Math.pow(craftTime - offset, 1.7);
|
||||||
return modifier * 0.5f;
|
return modifier * 0.5f;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getSizeModifier(float craftTime)
|
public float getSizeModifier(float craftTime) {
|
||||||
{
|
if (craftTime >= 150 && craftTime <= 250) {
|
||||||
if (craftTime >= 150 && craftTime <= 250)
|
|
||||||
{
|
|
||||||
return (200 - craftTime) / 50f;
|
return (200 - craftTime) / 50f;
|
||||||
}
|
}
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getVerticalOffset(float craftTime)
|
public float getVerticalOffset(float craftTime) {
|
||||||
{
|
if (craftTime >= 5) {
|
||||||
if (craftTime >= 5)
|
if (craftTime <= 40) {
|
||||||
{
|
|
||||||
if (craftTime <= 40)
|
|
||||||
{
|
|
||||||
return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3));
|
return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3));
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
return -0.4f;
|
return -0.4f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderAt(TileEntity tile, double x, double y, double z, float craftTime)
|
public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) {
|
||||||
{
|
if (!(tile instanceof TileAlchemyArray)) {
|
||||||
if (!(tile instanceof TileAlchemyArray))
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,30 +91,29 @@ public class AlchemyCircleRenderer
|
||||||
|
|
||||||
GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace);
|
GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace);
|
||||||
|
|
||||||
switch (sideHit)
|
switch (sideHit) {
|
||||||
{
|
case DOWN:
|
||||||
case DOWN:
|
GlStateManager.translate(0, 0, 1);
|
||||||
GlStateManager.translate(0, 0, 1);
|
GlStateManager.rotate(-90.0f, 1, 0, 0);
|
||||||
GlStateManager.rotate(-90.0f, 1, 0, 0);
|
break;
|
||||||
break;
|
case EAST:
|
||||||
case EAST:
|
GlStateManager.rotate(-90.0f, 0, 1, 0);
|
||||||
GlStateManager.rotate(-90.0f, 0, 1, 0);
|
GlStateManager.translate(0, 0, -1);
|
||||||
GlStateManager.translate(0, 0, -1);
|
break;
|
||||||
break;
|
case NORTH:
|
||||||
case NORTH:
|
break;
|
||||||
break;
|
case SOUTH:
|
||||||
case SOUTH:
|
GlStateManager.rotate(180.0f, 0, 1, 0);
|
||||||
GlStateManager.rotate(180.0f, 0, 1, 0);
|
GlStateManager.translate(-1, 0, -1);
|
||||||
GlStateManager.translate(-1, 0, -1);
|
break;
|
||||||
break;
|
case UP:
|
||||||
case UP:
|
GlStateManager.translate(0, 1, 0);
|
||||||
GlStateManager.translate(0, 1, 0);
|
GlStateManager.rotate(90.0f, 1, 0, 0);
|
||||||
GlStateManager.rotate(90.0f, 1, 0, 0);
|
break;
|
||||||
break;
|
case WEST:
|
||||||
case WEST:
|
GlStateManager.translate(0, 0, 1);
|
||||||
GlStateManager.translate(0, 0, 1);
|
GlStateManager.rotate(90.0f, 0, 1, 0);
|
||||||
GlStateManager.rotate(90.0f, 0, 1, 0);
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
|
|
|
@ -5,8 +5,7 @@ import net.minecraft.util.math.BlockPos;
|
||||||
/**
|
/**
|
||||||
* Used for building the altar structure.
|
* Used for building the altar structure.
|
||||||
*/
|
*/
|
||||||
public class AltarComponent
|
public class AltarComponent {
|
||||||
{
|
|
||||||
private BlockPos offset;
|
private BlockPos offset;
|
||||||
private boolean upgradeSlot;
|
private boolean upgradeSlot;
|
||||||
|
|
||||||
|
@ -14,14 +13,11 @@ public class AltarComponent
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a component location for the altar.
|
* Sets a component location for the altar.
|
||||||
*
|
*
|
||||||
* @param offset
|
* @param offset - Where the block should be in relation to the Altar
|
||||||
* - Where the block should be in relation to the Altar
|
* @param component - The type of Component the location should contain
|
||||||
* @param component
|
|
||||||
* - The type of Component the location should contain
|
|
||||||
*/
|
*/
|
||||||
public AltarComponent(BlockPos offset, EnumAltarComponent component)
|
public AltarComponent(BlockPos offset, EnumAltarComponent component) {
|
||||||
{
|
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
this.component = component;
|
this.component = component;
|
||||||
}
|
}
|
||||||
|
@ -29,22 +25,19 @@ public class AltarComponent
|
||||||
/**
|
/**
|
||||||
* Use for setting a location at which there must be a block, but the type
|
* Use for setting a location at which there must be a block, but the type
|
||||||
* of block does not matter.
|
* of block does not matter.
|
||||||
*
|
*
|
||||||
* @param offset
|
* @param offset - Where the block should be in relation to the Altar
|
||||||
* - Where the block should be in relation to the Altar
|
|
||||||
*/
|
*/
|
||||||
public AltarComponent(BlockPos offset)
|
public AltarComponent(BlockPos offset) {
|
||||||
{
|
|
||||||
this(offset, EnumAltarComponent.NOTAIR);
|
this(offset, EnumAltarComponent.NOTAIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the location to an upgrade slot.
|
* Sets the location to an upgrade slot.
|
||||||
*
|
*
|
||||||
* @return the current instance for further use.
|
* @return the current instance for further use.
|
||||||
*/
|
*/
|
||||||
public AltarComponent setUpgradeSlot()
|
public AltarComponent setUpgradeSlot() {
|
||||||
{
|
|
||||||
this.upgradeSlot = true;
|
this.upgradeSlot = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package WayofTime.bloodmagic.api.altar;
|
package WayofTime.bloodmagic.api.altar;
|
||||||
|
|
||||||
public class AltarUpgrade
|
public class AltarUpgrade {
|
||||||
{
|
|
||||||
private int speedCount;
|
private int speedCount;
|
||||||
private int efficiencyCount;
|
private int efficiencyCount;
|
||||||
private int sacrificeCount;
|
private int sacrificeCount;
|
||||||
|
@ -31,62 +30,52 @@ public class AltarUpgrade
|
||||||
|
|
||||||
// Adders
|
// Adders
|
||||||
|
|
||||||
public AltarUpgrade addSpeed()
|
public AltarUpgrade addSpeed() {
|
||||||
{
|
|
||||||
speedCount++;
|
speedCount++;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AltarUpgrade addEfficiency()
|
public AltarUpgrade addEfficiency() {
|
||||||
{
|
|
||||||
efficiencyCount++;
|
efficiencyCount++;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AltarUpgrade addSacrifice()
|
public AltarUpgrade addSacrifice() {
|
||||||
{
|
|
||||||
sacrificeCount++;
|
sacrificeCount++;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AltarUpgrade addSelfSacrifice()
|
public AltarUpgrade addSelfSacrifice() {
|
||||||
{
|
|
||||||
selfSacrificeCount++;
|
selfSacrificeCount++;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AltarUpgrade addDisplacement()
|
public AltarUpgrade addDisplacement() {
|
||||||
{
|
|
||||||
displacementCount++;
|
displacementCount++;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AltarUpgrade addCapacity()
|
public AltarUpgrade addCapacity() {
|
||||||
{
|
|
||||||
capacityCount++;
|
capacityCount++;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AltarUpgrade addOrbCapacity()
|
public AltarUpgrade addOrbCapacity() {
|
||||||
{
|
|
||||||
orbCapacityCount++;
|
orbCapacityCount++;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AltarUpgrade addBetterCapacity()
|
public AltarUpgrade addBetterCapacity() {
|
||||||
{
|
|
||||||
betterCapacityCount++;
|
betterCapacityCount++;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AltarUpgrade addAcceleration()
|
public AltarUpgrade addAcceleration() {
|
||||||
{
|
|
||||||
accelerationCount++;
|
accelerationCount++;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AltarUpgrade addCharging()
|
public AltarUpgrade addCharging() {
|
||||||
{
|
|
||||||
chargingCount++;
|
chargingCount++;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,7 @@ import java.util.Locale;
|
||||||
/**
|
/**
|
||||||
* List of different components used to construct different tiers of altars.
|
* List of different components used to construct different tiers of altars.
|
||||||
*/
|
*/
|
||||||
public enum EnumAltarComponent
|
public enum EnumAltarComponent {
|
||||||
{
|
|
||||||
GLOWSTONE,
|
GLOWSTONE,
|
||||||
BLOODSTONE,
|
BLOODSTONE,
|
||||||
BEACON,
|
BEACON,
|
||||||
|
@ -18,8 +17,7 @@ public enum EnumAltarComponent
|
||||||
private static final String BASE = "chat.bloodmagic.altar.comp.";
|
private static final String BASE = "chat.bloodmagic.altar.comp.";
|
||||||
private String key;
|
private String key;
|
||||||
|
|
||||||
EnumAltarComponent()
|
EnumAltarComponent() {
|
||||||
{
|
|
||||||
this.key = BASE + name().toLowerCase(Locale.ENGLISH);
|
this.key = BASE + name().toLowerCase(Locale.ENGLISH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,10 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
public enum EnumAltarTier
|
public enum EnumAltarTier {
|
||||||
{
|
ONE(), TWO() {
|
||||||
ONE(), TWO()
|
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public void buildComponents()
|
public void buildComponents() {
|
||||||
{
|
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(-1, -1, -1), EnumAltarComponent.BLOODRUNE));
|
altarComponents.add(new AltarComponent(new BlockPos(-1, -1, -1), EnumAltarComponent.BLOODRUNE));
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(0, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
altarComponents.add(new AltarComponent(new BlockPos(0, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(1, -1, -1), EnumAltarComponent.BLOODRUNE));
|
altarComponents.add(new AltarComponent(new BlockPos(1, -1, -1), EnumAltarComponent.BLOODRUNE));
|
||||||
|
@ -22,11 +19,9 @@ public enum EnumAltarTier
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(1, -1, 1), EnumAltarComponent.BLOODRUNE));
|
altarComponents.add(new AltarComponent(new BlockPos(1, -1, 1), EnumAltarComponent.BLOODRUNE));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
THREE()
|
THREE() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public void buildComponents()
|
public void buildComponents() {
|
||||||
{
|
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(-1, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
altarComponents.add(new AltarComponent(new BlockPos(-1, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(0, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
altarComponents.add(new AltarComponent(new BlockPos(0, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(1, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
altarComponents.add(new AltarComponent(new BlockPos(1, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||||
|
@ -48,8 +43,7 @@ public enum EnumAltarTier
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(-3, 1, 3), EnumAltarComponent.GLOWSTONE));
|
altarComponents.add(new AltarComponent(new BlockPos(-3, 1, 3), EnumAltarComponent.GLOWSTONE));
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(3, 1, 3), EnumAltarComponent.GLOWSTONE));
|
altarComponents.add(new AltarComponent(new BlockPos(3, 1, 3), EnumAltarComponent.GLOWSTONE));
|
||||||
|
|
||||||
for (int i = -2; i <= 2; i++)
|
for (int i = -2; i <= 2; i++) {
|
||||||
{
|
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(3, -2, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
altarComponents.add(new AltarComponent(new BlockPos(3, -2, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(-3, -2, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
altarComponents.add(new AltarComponent(new BlockPos(-3, -2, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(i, -2, 3), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
altarComponents.add(new AltarComponent(new BlockPos(i, -2, 3), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||||
|
@ -57,23 +51,19 @@ public enum EnumAltarTier
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
FOUR()
|
FOUR() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public void buildComponents()
|
public void buildComponents() {
|
||||||
{
|
|
||||||
altarComponents.addAll(THREE.getAltarComponents());
|
altarComponents.addAll(THREE.getAltarComponents());
|
||||||
|
|
||||||
for (int i = -3; i <= 3; i++)
|
for (int i = -3; i <= 3; i++) {
|
||||||
{
|
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(5, -3, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
altarComponents.add(new AltarComponent(new BlockPos(5, -3, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(-5, -3, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
altarComponents.add(new AltarComponent(new BlockPos(-5, -3, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(i, -3, 5), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
altarComponents.add(new AltarComponent(new BlockPos(i, -3, 5), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(i, -3, -5), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
altarComponents.add(new AltarComponent(new BlockPos(i, -3, -5), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = -2; i <= 1; i++)
|
for (int i = -2; i <= 1; i++) {
|
||||||
{
|
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(5, i, 5)));
|
altarComponents.add(new AltarComponent(new BlockPos(5, i, 5)));
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(5, i, -5)));
|
altarComponents.add(new AltarComponent(new BlockPos(5, i, -5)));
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(-5, i, -5)));
|
altarComponents.add(new AltarComponent(new BlockPos(-5, i, -5)));
|
||||||
|
@ -86,19 +76,16 @@ public enum EnumAltarTier
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(-5, 2, 5), EnumAltarComponent.BLOODSTONE));
|
altarComponents.add(new AltarComponent(new BlockPos(-5, 2, 5), EnumAltarComponent.BLOODSTONE));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
FIVE()
|
FIVE() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public void buildComponents()
|
public void buildComponents() {
|
||||||
{
|
|
||||||
altarComponents.addAll(FOUR.getAltarComponents());
|
altarComponents.addAll(FOUR.getAltarComponents());
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(-8, -3, 8), EnumAltarComponent.BEACON));
|
altarComponents.add(new AltarComponent(new BlockPos(-8, -3, 8), EnumAltarComponent.BEACON));
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(-8, -3, -8), EnumAltarComponent.BEACON));
|
altarComponents.add(new AltarComponent(new BlockPos(-8, -3, -8), EnumAltarComponent.BEACON));
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(8, -3, -8), EnumAltarComponent.BEACON));
|
altarComponents.add(new AltarComponent(new BlockPos(8, -3, -8), EnumAltarComponent.BEACON));
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(8, -3, 8), EnumAltarComponent.BEACON));
|
altarComponents.add(new AltarComponent(new BlockPos(8, -3, 8), EnumAltarComponent.BEACON));
|
||||||
|
|
||||||
for (int i = -6; i <= 6; i++)
|
for (int i = -6; i <= 6; i++) {
|
||||||
{
|
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(8, -4, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
altarComponents.add(new AltarComponent(new BlockPos(8, -4, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(-8, -4, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
altarComponents.add(new AltarComponent(new BlockPos(-8, -4, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(i, -4, 8), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
altarComponents.add(new AltarComponent(new BlockPos(i, -4, 8), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||||
|
@ -106,15 +93,12 @@ public enum EnumAltarTier
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SIX()
|
SIX() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public void buildComponents()
|
public void buildComponents() {
|
||||||
{
|
|
||||||
altarComponents.addAll(FIVE.getAltarComponents());
|
altarComponents.addAll(FIVE.getAltarComponents());
|
||||||
|
|
||||||
for (int i = -4; i <= 2; i++)
|
for (int i = -4; i <= 2; i++) {
|
||||||
{
|
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(11, i, 11)));
|
altarComponents.add(new AltarComponent(new BlockPos(11, i, 11)));
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(-11, i, -11)));
|
altarComponents.add(new AltarComponent(new BlockPos(-11, i, -11)));
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(11, i, -11)));
|
altarComponents.add(new AltarComponent(new BlockPos(11, i, -11)));
|
||||||
|
@ -126,8 +110,7 @@ public enum EnumAltarTier
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(11, 3, -11), EnumAltarComponent.CRYSTAL));
|
altarComponents.add(new AltarComponent(new BlockPos(11, 3, -11), EnumAltarComponent.CRYSTAL));
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(-11, 3, 11), EnumAltarComponent.CRYSTAL));
|
altarComponents.add(new AltarComponent(new BlockPos(-11, 3, 11), EnumAltarComponent.CRYSTAL));
|
||||||
|
|
||||||
for (int i = -9; i <= 9; i++)
|
for (int i = -9; i <= 9; i++) {
|
||||||
{
|
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(11, -5, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
altarComponents.add(new AltarComponent(new BlockPos(11, -5, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(-11, -5, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
altarComponents.add(new AltarComponent(new BlockPos(-11, -5, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||||
altarComponents.add(new AltarComponent(new BlockPos(i, -5, 11), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
altarComponents.add(new AltarComponent(new BlockPos(i, -5, 11), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||||
|
@ -141,13 +124,11 @@ public enum EnumAltarTier
|
||||||
|
|
||||||
ArrayList<AltarComponent> altarComponents = new ArrayList<AltarComponent>();
|
ArrayList<AltarComponent> altarComponents = new ArrayList<AltarComponent>();
|
||||||
|
|
||||||
public void buildComponents()
|
public void buildComponents() {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int toInt()
|
public int toInt() {
|
||||||
{
|
|
||||||
return ordinal() + 1;
|
return ordinal() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,7 @@ import net.minecraft.world.World;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public interface IAltarComponent
|
public interface IAltarComponent {
|
||||||
{
|
|
||||||
@Nullable
|
@Nullable
|
||||||
EnumAltarComponent getType(World world, IBlockState state, BlockPos pos);
|
EnumAltarComponent getType(World world, IBlockState state, BlockPos pos);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,5 @@ package WayofTime.bloodmagic.api.altar;
|
||||||
* Any item that implements this interface will not be pulled into the Altar on
|
* Any item that implements this interface will not be pulled into the Altar on
|
||||||
* right click.
|
* right click.
|
||||||
*/
|
*/
|
||||||
public interface IAltarManipulator
|
public interface IAltarManipulator {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package WayofTime.bloodmagic.api.altar;
|
package WayofTime.bloodmagic.api.altar;
|
||||||
|
|
||||||
public interface IBloodAltar
|
public interface IBloodAltar {
|
||||||
{
|
|
||||||
int getCapacity();
|
int getCapacity();
|
||||||
|
|
||||||
int getCurrentBlood();
|
int getCurrentBlood();
|
||||||
|
@ -48,9 +47,8 @@ public interface IBloodAltar
|
||||||
* Will set the altar to initiate a cooldown cycle after it crafts before
|
* Will set the altar to initiate a cooldown cycle after it crafts before
|
||||||
* starting to craft again, giving the user time to interact with the altar.
|
* starting to craft again, giving the user time to interact with the altar.
|
||||||
* This can only be set while the altar is not active.
|
* This can only be set while the altar is not active.
|
||||||
*
|
*
|
||||||
* @param cooldown
|
* @param cooldown - How long the cooldown should last
|
||||||
* - How long the cooldown should last
|
|
||||||
*/
|
*/
|
||||||
void requestPauseAfterCrafting(int cooldown);
|
void requestPauseAfterCrafting(int cooldown);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,14 +3,12 @@ package WayofTime.bloodmagic.api.compress;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public abstract class CompressionHandler
|
public abstract class CompressionHandler {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Called to look at the inventory and syphons the required stack. Returns
|
* Called to look at the inventory and syphons the required stack. Returns
|
||||||
* resultant stack if successful, and null if not.
|
* resultant stack if successful, and null if not.
|
||||||
*
|
*
|
||||||
* @param inv
|
* @param inv The inventory iterated through
|
||||||
* The inventory iterated through
|
|
||||||
* @return The result of the compression
|
* @return The result of the compression
|
||||||
*/
|
*/
|
||||||
public abstract ItemStack compressInventory(ItemStack[] inv, World world);
|
public abstract ItemStack compressInventory(ItemStack[] inv, World world);
|
||||||
|
|
|
@ -1,54 +1,44 @@
|
||||||
package WayofTime.bloodmagic.api.compress;
|
package WayofTime.bloodmagic.api.compress;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.util.Utils;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
|
||||||
import net.minecraftforge.items.IItemHandler;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
|
|
||||||
import WayofTime.bloodmagic.util.Utils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A registry aimed to help compress items in an inventory into its compressible
|
* A registry aimed to help compress items in an inventory into its compressible
|
||||||
* form.
|
* form.
|
||||||
*/
|
*/
|
||||||
public class CompressionRegistry
|
public class CompressionRegistry {
|
||||||
{
|
|
||||||
public static List<CompressionHandler> compressionRegistry = new ArrayList<CompressionHandler>();
|
public static List<CompressionHandler> compressionRegistry = new ArrayList<CompressionHandler>();
|
||||||
public static Map<ItemStack, Integer> thresholdMap = new HashMap<ItemStack, Integer>();
|
public static Map<ItemStack, Integer> thresholdMap = new HashMap<ItemStack, Integer>();
|
||||||
|
|
||||||
public static void registerHandler(CompressionHandler handler)
|
public static void registerHandler(CompressionHandler handler) {
|
||||||
{
|
|
||||||
compressionRegistry.add(handler);
|
compressionRegistry.add(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an item so that it only compresses while above this threshold
|
* Registers an item so that it only compresses while above this threshold
|
||||||
*
|
*
|
||||||
* @param stack
|
* @param stack item/block to be compressed
|
||||||
* item/block to be compressed
|
* @param threshold amount that is to be compressed
|
||||||
* @param threshold
|
|
||||||
* amount that is to be compressed
|
|
||||||
*/
|
*/
|
||||||
public static void registerItemThreshold(ItemStack stack, int threshold)
|
public static void registerItemThreshold(ItemStack stack, int threshold) {
|
||||||
{
|
|
||||||
thresholdMap.put(stack, threshold);
|
thresholdMap.put(stack, threshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack compressInventory(ItemStack[] inv, World world)
|
public static ItemStack compressInventory(ItemStack[] inv, World world) {
|
||||||
{
|
for (CompressionHandler handler : compressionRegistry) {
|
||||||
for (CompressionHandler handler : compressionRegistry)
|
|
||||||
{
|
|
||||||
ItemStack stack = handler.compressInventory(inv, world);
|
ItemStack stack = handler.compressInventory(inv, world);
|
||||||
if (stack != null)
|
if (stack != null) {
|
||||||
{
|
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,32 +46,24 @@ public class CompressionRegistry
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Pair<ItemStack, Boolean> compressInventory(TileEntity tile, World world)
|
public static Pair<ItemStack, Boolean> compressInventory(TileEntity tile, World world) {
|
||||||
{
|
if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) {
|
||||||
if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null))
|
|
||||||
{
|
|
||||||
IItemHandler itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
IItemHandler itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
||||||
ItemStack[] inventory = new ItemStack[itemHandler.getSlots()]; //THIS MUST NOT BE EDITED!
|
ItemStack[] inventory = new ItemStack[itemHandler.getSlots()]; //THIS MUST NOT BE EDITED!
|
||||||
ItemStack[] copyInventory = new ItemStack[itemHandler.getSlots()];
|
ItemStack[] copyInventory = new ItemStack[itemHandler.getSlots()];
|
||||||
|
|
||||||
for (int slot = 0; slot < itemHandler.getSlots(); slot++)
|
for (int slot = 0; slot < itemHandler.getSlots(); slot++) {
|
||||||
{
|
|
||||||
inventory[slot] = itemHandler.extractItem(slot, 64, true);
|
inventory[slot] = itemHandler.extractItem(slot, 64, true);
|
||||||
copyInventory[slot] = inventory[slot].copy();
|
copyInventory[slot] = inventory[slot].copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CompressionHandler handler : compressionRegistry)
|
for (CompressionHandler handler : compressionRegistry) {
|
||||||
{
|
|
||||||
ItemStack stack = handler.compressInventory(copyInventory, world);
|
ItemStack stack = handler.compressInventory(copyInventory, world);
|
||||||
if (!stack.isEmpty())
|
if (!stack.isEmpty()) {
|
||||||
{
|
for (int slot = 0; slot < itemHandler.getSlots(); slot++) {
|
||||||
for (int slot = 0; slot < itemHandler.getSlots(); slot++)
|
if (inventory[slot] != null && !ItemStack.areItemStacksEqual(inventory[slot], copyInventory[slot])) {
|
||||||
{
|
|
||||||
if (inventory[slot] != null && !ItemStack.areItemStacksEqual(inventory[slot], copyInventory[slot]))
|
|
||||||
{
|
|
||||||
itemHandler.extractItem(slot, inventory[slot].getCount(), false);
|
itemHandler.extractItem(slot, inventory[slot].getCount(), false);
|
||||||
if (copyInventory[slot] != null)
|
if (copyInventory[slot] != null) {
|
||||||
{
|
|
||||||
itemHandler.insertItem(slot, copyInventory[slot], false);
|
itemHandler.insertItem(slot, copyInventory[slot], false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,12 +77,9 @@ public class CompressionRegistry
|
||||||
return Pair.of(ItemStack.EMPTY, false);
|
return Pair.of(ItemStack.EMPTY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getItemThreshold(ItemStack stack)
|
public static int getItemThreshold(ItemStack stack) {
|
||||||
{
|
for (Map.Entry<ItemStack, Integer> entry : thresholdMap.entrySet()) {
|
||||||
for (Map.Entry<ItemStack, Integer> entry : thresholdMap.entrySet())
|
if (areItemStacksEqual(entry.getKey(), stack)) {
|
||||||
{
|
|
||||||
if (areItemStacksEqual(entry.getKey(), stack))
|
|
||||||
{
|
|
||||||
return entry.getValue();
|
return entry.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,8 +87,7 @@ public class CompressionRegistry
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean areItemStacksEqual(ItemStack stack, ItemStack compressedStack)
|
public static boolean areItemStacksEqual(ItemStack stack, ItemStack compressedStack) {
|
||||||
{
|
|
||||||
return stack.isItemEqual(compressedStack) && (stack.getTagCompound() == null ? !compressedStack.hasTagCompound() : stack.getTagCompound().equals(compressedStack.getTagCompound()));
|
return stack.isItemEqual(compressedStack) && (stack.getTagCompound() == null ? !compressedStack.hasTagCompound() : stack.getTagCompound().equals(compressedStack.getTagCompound()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,7 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||||
|
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public class AddToNetworkEvent extends Event
|
public class AddToNetworkEvent extends Event {
|
||||||
{
|
|
||||||
public final String ownerNetwork;
|
public final String ownerNetwork;
|
||||||
public int addedAmount;
|
public int addedAmount;
|
||||||
public int maximum;
|
public int maximum;
|
||||||
|
@ -14,16 +13,12 @@ public class AddToNetworkEvent extends Event
|
||||||
* This event is called whenever the network is added to. If cancelled, no
|
* This event is called whenever the network is added to. If cancelled, no
|
||||||
* LP will be drained from the source. If result is set to Result.DENY, the
|
* LP will be drained from the source. If result is set to Result.DENY, the
|
||||||
* LP will still be drained but the soul network will not be added to.
|
* LP will still be drained but the soul network will not be added to.
|
||||||
*
|
*
|
||||||
* @param ownerNetwork
|
* @param ownerNetwork Key used for the soul network
|
||||||
* Key used for the soul network
|
* @param addedAmount Amount added
|
||||||
* @param addedAmount
|
* @param maximum Ceiling that the network can add to
|
||||||
* Amount added
|
|
||||||
* @param maximum
|
|
||||||
* Ceiling that the network can add to
|
|
||||||
*/
|
*/
|
||||||
public AddToNetworkEvent(String ownerNetwork, int addedAmount, int maximum)
|
public AddToNetworkEvent(String ownerNetwork, int addedAmount, int maximum) {
|
||||||
{
|
|
||||||
this.ownerNetwork = ownerNetwork;
|
this.ownerNetwork = ownerNetwork;
|
||||||
this.addedAmount = addedAmount;
|
this.addedAmount = addedAmount;
|
||||||
this.maximum = maximum;
|
this.maximum = maximum;
|
||||||
|
|
|
@ -6,23 +6,19 @@ import net.minecraftforge.fml.common.eventhandler.Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired whenever a craft is completed in a BloodAltar.
|
* Fired whenever a craft is completed in a BloodAltar.
|
||||||
*
|
* <p>
|
||||||
* It is not cancelable, however you can modify the output stack.
|
* It is not cancelable, however you can modify the output stack.
|
||||||
*/
|
*/
|
||||||
public class AltarCraftedEvent extends Event
|
public class AltarCraftedEvent extends Event {
|
||||||
{
|
|
||||||
|
|
||||||
private final AltarRecipeRegistry.AltarRecipe altarRecipe;
|
private final AltarRecipeRegistry.AltarRecipe altarRecipe;
|
||||||
private final ItemStack output;
|
private final ItemStack output;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param altarRecipe
|
* @param altarRecipe - The recipe that was crafted.
|
||||||
* - The recipe that was crafted.
|
* @param output - The item obtained from the recipe
|
||||||
* @param output
|
|
||||||
* - The item obtained from the recipe
|
|
||||||
*/
|
*/
|
||||||
public AltarCraftedEvent(AltarRecipeRegistry.AltarRecipe altarRecipe, ItemStack output)
|
public AltarCraftedEvent(AltarRecipeRegistry.AltarRecipe altarRecipe, ItemStack output) {
|
||||||
{
|
|
||||||
this.altarRecipe = altarRecipe;
|
this.altarRecipe = altarRecipe;
|
||||||
this.output = output;
|
this.output = output;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,29 +5,25 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||||
|
|
||||||
public class BoundToolEvent extends Event
|
public class BoundToolEvent extends Event {
|
||||||
{
|
|
||||||
public EntityPlayer player;
|
public EntityPlayer player;
|
||||||
|
|
||||||
public BoundToolEvent(EntityPlayer player)
|
public BoundToolEvent(EntityPlayer player) {
|
||||||
{
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is called when a
|
* This event is called when a
|
||||||
* {@link WayofTime.bloodmagic.item.ItemBoundTool} is being charged.
|
* {@link WayofTime.bloodmagic.item.ItemBoundTool} is being charged.
|
||||||
*
|
* <p>
|
||||||
* If canceled, will result in the charging being canceled.
|
* If canceled, will result in the charging being canceled.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public static class Charge extends BoundToolEvent
|
public static class Charge extends BoundToolEvent {
|
||||||
{
|
|
||||||
public ItemStack result;
|
public ItemStack result;
|
||||||
|
|
||||||
public Charge(EntityPlayer player, ItemStack result)
|
public Charge(EntityPlayer player, ItemStack result) {
|
||||||
{
|
|
||||||
super(player);
|
super(player);
|
||||||
this.result = result;
|
this.result = result;
|
||||||
}
|
}
|
||||||
|
@ -36,18 +32,16 @@ public class BoundToolEvent extends Event
|
||||||
/**
|
/**
|
||||||
* This event is called when a
|
* This event is called when a
|
||||||
* {@link WayofTime.bloodmagic.item.ItemBoundTool}'s charge is released.
|
* {@link WayofTime.bloodmagic.item.ItemBoundTool}'s charge is released.
|
||||||
*
|
* <p>
|
||||||
* If canceled, will result in the charge not being released.
|
* If canceled, will result in the charge not being released.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public static class Release extends BoundToolEvent
|
public static class Release extends BoundToolEvent {
|
||||||
{
|
|
||||||
public final ItemStack boundTool;
|
public final ItemStack boundTool;
|
||||||
public int charge;
|
public int charge;
|
||||||
|
|
||||||
public Release(EntityPlayer player, ItemStack boundTool, int charge)
|
public Release(EntityPlayer player, ItemStack boundTool, int charge) {
|
||||||
{
|
|
||||||
super(player);
|
super(player);
|
||||||
this.boundTool = boundTool;
|
this.boundTool = boundTool;
|
||||||
this.charge = charge;
|
this.charge = charge;
|
||||||
|
|
|
@ -6,8 +6,7 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||||
|
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public class ItemBindEvent extends Event
|
public class ItemBindEvent extends Event {
|
||||||
{
|
|
||||||
public final EntityPlayer player;
|
public final EntityPlayer player;
|
||||||
public String key;
|
public String key;
|
||||||
public ItemStack itemStack;
|
public ItemStack itemStack;
|
||||||
|
@ -15,18 +14,14 @@ public class ItemBindEvent extends Event
|
||||||
/**
|
/**
|
||||||
* This event is called whenever a player attempts to bind a
|
* This event is called whenever a player attempts to bind a
|
||||||
* {@link WayofTime.bloodmagic.api.iface.IBindable} item.
|
* {@link WayofTime.bloodmagic.api.iface.IBindable} item.
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player The player doing the binding
|
||||||
* The player doing the binding
|
* @param key The UUID of the player doing the binding
|
||||||
* @param key
|
* @param itemStack The {@link ItemStack} that the player is binding
|
||||||
* The UUID of the player doing the binding
|
* <p>
|
||||||
* @param itemStack
|
* This event is {@link Cancelable}.<br>
|
||||||
* The {@link ItemStack} that the player is binding
|
|
||||||
*
|
|
||||||
* This event is {@link Cancelable}.<br>
|
|
||||||
*/
|
*/
|
||||||
public ItemBindEvent(EntityPlayer player, String key, ItemStack itemStack)
|
public ItemBindEvent(EntityPlayer player, String key, ItemStack itemStack) {
|
||||||
{
|
|
||||||
super();
|
super();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
|
|
@ -10,14 +10,12 @@ import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||||
|
|
||||||
public class RitualEvent extends Event
|
public class RitualEvent extends Event {
|
||||||
{
|
|
||||||
public final IMasterRitualStone mrs;
|
public final IMasterRitualStone mrs;
|
||||||
public final String ownerName;
|
public final String ownerName;
|
||||||
public final Ritual ritual;
|
public final Ritual ritual;
|
||||||
|
|
||||||
private RitualEvent(IMasterRitualStone mrs, String ownerName, Ritual ritual)
|
private RitualEvent(IMasterRitualStone mrs, String ownerName, Ritual ritual) {
|
||||||
{
|
|
||||||
this.mrs = mrs;
|
this.mrs = mrs;
|
||||||
this.ownerName = ownerName;
|
this.ownerName = ownerName;
|
||||||
this.ritual = ritual;
|
this.ritual = ritual;
|
||||||
|
@ -26,18 +24,16 @@ public class RitualEvent extends Event
|
||||||
/**
|
/**
|
||||||
* This event is called when a ritual is activated. If cancelled, it will
|
* This event is called when a ritual is activated. If cancelled, it will
|
||||||
* not activate.
|
* not activate.
|
||||||
*
|
* <p>
|
||||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#activateRitual(ItemStack, EntityPlayer, Ritual)}
|
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#activateRitual(ItemStack, EntityPlayer, Ritual)}
|
||||||
*/
|
*/
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public static class RitualActivatedEvent extends RitualEvent
|
public static class RitualActivatedEvent extends RitualEvent {
|
||||||
{
|
|
||||||
public final EntityPlayer player;
|
public final EntityPlayer player;
|
||||||
public final ItemStack crystalStack;
|
public final ItemStack crystalStack;
|
||||||
public int crystalTier;
|
public int crystalTier;
|
||||||
|
|
||||||
public RitualActivatedEvent(IMasterRitualStone mrs, String owner, Ritual ritual, EntityPlayer player, ItemStack activationCrystal, int crystalTier)
|
public RitualActivatedEvent(IMasterRitualStone mrs, String owner, Ritual ritual, EntityPlayer player, ItemStack activationCrystal, int crystalTier) {
|
||||||
{
|
|
||||||
super(mrs, owner, ritual);
|
super(mrs, owner, ritual);
|
||||||
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
@ -49,14 +45,12 @@ public class RitualEvent extends Event
|
||||||
/**
|
/**
|
||||||
* This event is called when a Ritual effect is performed. If cancelled, the
|
* This event is called when a Ritual effect is performed. If cancelled, the
|
||||||
* effect will not happen.
|
* effect will not happen.
|
||||||
*
|
* <p>
|
||||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, net.minecraft.util.math.BlockPos)}
|
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, net.minecraft.util.math.BlockPos)}
|
||||||
*/
|
*/
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public static class RitualRunEvent extends RitualEvent
|
public static class RitualRunEvent extends RitualEvent {
|
||||||
{
|
public RitualRunEvent(IMasterRitualStone mrs, String owner, Ritual ritual) {
|
||||||
public RitualRunEvent(IMasterRitualStone mrs, String owner, Ritual ritual)
|
|
||||||
{
|
|
||||||
super(mrs, owner, ritual);
|
super(mrs, owner, ritual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,16 +58,14 @@ public class RitualEvent extends Event
|
||||||
/**
|
/**
|
||||||
* This event is called when a Ritual is stopped by a
|
* This event is called when a Ritual is stopped by a
|
||||||
* {@link Ritual.BreakType}.
|
* {@link Ritual.BreakType}.
|
||||||
*
|
* <p>
|
||||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(Ritual.BreakType)}
|
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(Ritual.BreakType)}
|
||||||
* */
|
*/
|
||||||
public static class RitualStopEvent extends RitualEvent
|
public static class RitualStopEvent extends RitualEvent {
|
||||||
{
|
|
||||||
|
|
||||||
public final Ritual.BreakType method;
|
public final Ritual.BreakType method;
|
||||||
|
|
||||||
public RitualStopEvent(IMasterRitualStone mrs, String owner, Ritual ritual, Ritual.BreakType method)
|
public RitualStopEvent(IMasterRitualStone mrs, String owner, Ritual ritual, Ritual.BreakType method) {
|
||||||
{
|
|
||||||
super(mrs, owner, ritual);
|
super(mrs, owner, ritual);
|
||||||
|
|
||||||
this.method = method;
|
this.method = method;
|
||||||
|
@ -81,15 +73,13 @@ public class RitualEvent extends Event
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public static class ImperfectRitualActivatedEvent extends Event
|
public static class ImperfectRitualActivatedEvent extends Event {
|
||||||
{
|
|
||||||
|
|
||||||
public final IImperfectRitualStone ims;
|
public final IImperfectRitualStone ims;
|
||||||
public final String ownerName;
|
public final String ownerName;
|
||||||
public final ImperfectRitual imperfectRitual;
|
public final ImperfectRitual imperfectRitual;
|
||||||
|
|
||||||
public ImperfectRitualActivatedEvent(IImperfectRitualStone ims, String ownerName, ImperfectRitual imperfectRitual)
|
public ImperfectRitualActivatedEvent(IImperfectRitualStone ims, String ownerName, ImperfectRitual imperfectRitual) {
|
||||||
{
|
|
||||||
this.ims = ims;
|
this.ims = ims;
|
||||||
this.ownerName = ownerName;
|
this.ownerName = ownerName;
|
||||||
this.imperfectRitual = imperfectRitual;
|
this.imperfectRitual = imperfectRitual;
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package WayofTime.bloodmagic.api.event;
|
package WayofTime.bloodmagic.api.event;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||||
|
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public class SacrificeKnifeUsedEvent extends Event
|
public class SacrificeKnifeUsedEvent extends Event {
|
||||||
{
|
|
||||||
public final EntityPlayer player;
|
public final EntityPlayer player;
|
||||||
public final int healthDrained;
|
public final int healthDrained;
|
||||||
public int lpAdded;
|
public int lpAdded;
|
||||||
|
@ -18,22 +16,16 @@ public class SacrificeKnifeUsedEvent extends Event
|
||||||
* This event is called whenever a player attempts to use a
|
* This event is called whenever a player attempts to use a
|
||||||
* {@link WayofTime.bloodmagic.item.ItemSacrificialDagger} to self-sacrifice
|
* {@link WayofTime.bloodmagic.item.ItemSacrificialDagger} to self-sacrifice
|
||||||
* near an altar.
|
* near an altar.
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player The player doing the sacrificing
|
||||||
* The player doing the sacrificing
|
* @param shouldDrainHealth Determines whether or not health is lost
|
||||||
* @param shouldDrainHealth
|
* @param shouldFillAltar Determines whether or not an altar should be filled
|
||||||
* Determines whether or not health is lost
|
* @param hp Amount of health lost
|
||||||
* @param shouldFillAltar
|
* @param lpAdded Amount of LP added to the altar
|
||||||
* Determines whether or not an altar should be filled
|
* <p>
|
||||||
* @param hp
|
* This event is {@link Cancelable}.<br>
|
||||||
* Amount of health lost
|
|
||||||
* @param lpAdded
|
|
||||||
* Amount of LP added to the altar
|
|
||||||
*
|
|
||||||
* This event is {@link Cancelable}.<br>
|
|
||||||
*/
|
*/
|
||||||
public SacrificeKnifeUsedEvent(EntityPlayer player, boolean shouldDrainHealth, boolean shouldFillAltar, int hp, int lpAdded)
|
public SacrificeKnifeUsedEvent(EntityPlayer player, boolean shouldDrainHealth, boolean shouldFillAltar, int hp, int lpAdded) {
|
||||||
{
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.shouldDrainHealth = shouldDrainHealth;
|
this.shouldDrainHealth = shouldDrainHealth;
|
||||||
this.shouldFillAltar = shouldFillAltar;
|
this.shouldFillAltar = shouldFillAltar;
|
||||||
|
|
|
@ -9,17 +9,15 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base event class for Soul Network related events.
|
* Base event class for Soul Network related events.
|
||||||
*
|
* <p>
|
||||||
* {@link #ownerUUID} contains the owner's UUID {@link #syphon} contains the
|
* {@link #ownerUUID} contains the owner's UUID {@link #syphon} contains the
|
||||||
* amount of LP to be drained
|
* amount of LP to be drained
|
||||||
*/
|
*/
|
||||||
public class SoulNetworkEvent extends Event
|
public class SoulNetworkEvent extends Event {
|
||||||
{
|
|
||||||
public final String ownerUUID;
|
public final String ownerUUID;
|
||||||
public int syphon;
|
public int syphon;
|
||||||
|
|
||||||
public SoulNetworkEvent(String ownerUUID, int syphon)
|
public SoulNetworkEvent(String ownerUUID, int syphon) {
|
||||||
{
|
|
||||||
this.ownerUUID = ownerUUID;
|
this.ownerUUID = ownerUUID;
|
||||||
this.syphon = syphon;
|
this.syphon = syphon;
|
||||||
}
|
}
|
||||||
|
@ -28,16 +26,14 @@ public class SoulNetworkEvent extends Event
|
||||||
* This event is called when an
|
* This event is called when an
|
||||||
* {@link WayofTime.bloodmagic.api.impl.ItemBindable} is being drained
|
* {@link WayofTime.bloodmagic.api.impl.ItemBindable} is being drained
|
||||||
* inside of a {@link net.minecraft.tileentity.TileEntity}.
|
* inside of a {@link net.minecraft.tileentity.TileEntity}.
|
||||||
*
|
* <p>
|
||||||
* If canceled, the drain will not be executed.
|
* If canceled, the drain will not be executed.
|
||||||
*/
|
*/
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public static class ItemDrainInContainerEvent extends SoulNetworkEvent
|
public static class ItemDrainInContainerEvent extends SoulNetworkEvent {
|
||||||
{
|
|
||||||
public ItemStack stack;
|
public ItemStack stack;
|
||||||
|
|
||||||
public ItemDrainInContainerEvent(ItemStack stack, String ownerName, int syphon)
|
public ItemDrainInContainerEvent(ItemStack stack, String ownerName, int syphon) {
|
||||||
{
|
|
||||||
super(ownerName, syphon);
|
super(ownerName, syphon);
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
}
|
}
|
||||||
|
@ -45,18 +41,16 @@ public class SoulNetworkEvent extends Event
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is called when a {@link EntityPlayer} drains the Soul Network
|
* This event is called when a {@link EntityPlayer} drains the Soul Network
|
||||||
*
|
* <p>
|
||||||
* If canceled, the drain will not be executed.
|
* If canceled, the drain will not be executed.
|
||||||
*/
|
*/
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public static class PlayerDrainNetworkEvent extends SoulNetworkEvent
|
public static class PlayerDrainNetworkEvent extends SoulNetworkEvent {
|
||||||
{
|
|
||||||
public final EntityPlayer player;
|
public final EntityPlayer player;
|
||||||
// If true, will damage regardless of if the network had enough inside it
|
// If true, will damage regardless of if the network had enough inside it
|
||||||
public boolean shouldDamage;
|
public boolean shouldDamage;
|
||||||
|
|
||||||
public PlayerDrainNetworkEvent(EntityPlayer player, String ownerNetwork, int drainAmount)
|
public PlayerDrainNetworkEvent(EntityPlayer player, String ownerNetwork, int drainAmount) {
|
||||||
{
|
|
||||||
super(ownerNetwork, drainAmount);
|
super(ownerNetwork, drainAmount);
|
||||||
this.shouldDamage = false;
|
this.shouldDamage = false;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
@ -64,8 +58,7 @@ public class SoulNetworkEvent extends Event
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public static class ItemDrainNetworkEvent extends PlayerDrainNetworkEvent
|
public static class ItemDrainNetworkEvent extends PlayerDrainNetworkEvent {
|
||||||
{
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public final ItemStack itemStack;
|
public final ItemStack itemStack;
|
||||||
/**
|
/**
|
||||||
|
@ -77,18 +70,13 @@ public class SoulNetworkEvent extends Event
|
||||||
/**
|
/**
|
||||||
* Set result to deny the action i.e. damage/drain anyways. Cancelling
|
* Set result to deny the action i.e. damage/drain anyways. Cancelling
|
||||||
* event prevents action without penalties
|
* event prevents action without penalties
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player Player using the item
|
||||||
* Player using the item
|
* @param ownerNetwork Network that the item is tied to
|
||||||
* @param ownerNetwork
|
* @param itemStack Item used
|
||||||
* Network that the item is tied to
|
* @param drainAmount Original drain amount - change to alter cost
|
||||||
* @param itemStack
|
|
||||||
* Item used
|
|
||||||
* @param drainAmount
|
|
||||||
* Original drain amount - change to alter cost
|
|
||||||
*/
|
*/
|
||||||
public ItemDrainNetworkEvent(EntityPlayer player, String ownerNetwork, @Nullable ItemStack itemStack, int drainAmount)
|
public ItemDrainNetworkEvent(EntityPlayer player, String ownerNetwork, @Nullable ItemStack itemStack, int drainAmount) {
|
||||||
{
|
|
||||||
super(player, ownerNetwork, drainAmount);
|
super(player, ownerNetwork, drainAmount);
|
||||||
this.itemStack = itemStack;
|
this.itemStack = itemStack;
|
||||||
this.damageAmount = (float) (drainAmount) / 100.0f;
|
this.damageAmount = (float) (drainAmount) / 100.0f;
|
||||||
|
|
|
@ -14,8 +14,7 @@ import net.minecraftforge.fml.common.eventhandler.Event;
|
||||||
* transposition.
|
* transposition.
|
||||||
*/
|
*/
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public class TeleposeEvent extends Event
|
public class TeleposeEvent extends Event {
|
||||||
{
|
|
||||||
public final World initalWorld;
|
public final World initalWorld;
|
||||||
public final BlockPos initialBlockPos;
|
public final BlockPos initialBlockPos;
|
||||||
public final IBlockState initialState;
|
public final IBlockState initialState;
|
||||||
|
@ -24,8 +23,7 @@ public class TeleposeEvent extends Event
|
||||||
public final BlockPos finalBlockPos;
|
public final BlockPos finalBlockPos;
|
||||||
public final IBlockState finalState;
|
public final IBlockState finalState;
|
||||||
|
|
||||||
public TeleposeEvent(World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos)
|
public TeleposeEvent(World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos) {
|
||||||
{
|
|
||||||
this.initalWorld = initialWorld;
|
this.initalWorld = initialWorld;
|
||||||
this.initialBlockPos = initialBlockPos;
|
this.initialBlockPos = initialBlockPos;
|
||||||
this.initialState = initialWorld.getBlockState(initialBlockPos);
|
this.initialState = initialWorld.getBlockState(initialBlockPos);
|
||||||
|
@ -35,13 +33,11 @@ public class TeleposeEvent extends Event
|
||||||
this.finalState = finalWorld.getBlockState(finalBlockPos);
|
this.finalState = finalWorld.getBlockState(finalBlockPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TileEntity getInitialTile()
|
public TileEntity getInitialTile() {
|
||||||
{
|
|
||||||
return initalWorld.getTileEntity(initialBlockPos);
|
return initalWorld.getTileEntity(initialBlockPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TileEntity getFinalTile()
|
public TileEntity getFinalTile() {
|
||||||
{
|
|
||||||
return finalWorld.getTileEntity(finalBlockPos);
|
return finalWorld.getTileEntity(finalBlockPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,37 +46,31 @@ public class TeleposeEvent extends Event
|
||||||
* be cancelled to stop transposition.
|
* be cancelled to stop transposition.
|
||||||
*/
|
*/
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public static class Ent extends TeleposeEvent
|
public static class Ent extends TeleposeEvent {
|
||||||
{
|
|
||||||
public final Entity entity;
|
public final Entity entity;
|
||||||
|
|
||||||
public Ent(Entity entity, World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos)
|
public Ent(Entity entity, World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos) {
|
||||||
{
|
|
||||||
super(initialWorld, initialBlockPos, finalWorld, finalBlockPos);
|
super(initialWorld, initialBlockPos, finalWorld, finalBlockPos);
|
||||||
|
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileEntity getInitialTile() throws IllegalArgumentException
|
public TileEntity getInitialTile() throws IllegalArgumentException {
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Attempted to get a TileEntity from an Entity Telepose Event.");
|
throw new IllegalArgumentException("Attempted to get a TileEntity from an Entity Telepose Event.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileEntity getFinalTile() throws IllegalArgumentException
|
public TileEntity getFinalTile() throws IllegalArgumentException {
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Attempted to get a TileEntity from an Entity Telepose Event.");
|
throw new IllegalArgumentException("Attempted to get a TileEntity from an Entity Telepose Event.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after the entity has been transposed.
|
* Called after the entity has been transposed.
|
||||||
*/
|
*/
|
||||||
public static class Post extends Ent
|
public static class Post extends Ent {
|
||||||
{
|
|
||||||
|
|
||||||
public Post(Entity entity, World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos)
|
public Post(Entity entity, World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos) {
|
||||||
{
|
|
||||||
super(entity, initialWorld, initialBlockPos, finalWorld, finalBlockPos);
|
super(entity, initialWorld, initialBlockPos, finalWorld, finalBlockPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,7 @@ package WayofTime.bloodmagic.api.iface;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public interface IActivatable
|
public interface IActivatable {
|
||||||
{
|
|
||||||
boolean getActivated(ItemStack stack);
|
boolean getActivated(ItemStack stack);
|
||||||
|
|
||||||
ItemStack setActivatedState(ItemStack stack, boolean activated);
|
ItemStack setActivatedState(ItemStack stack, boolean activated);
|
||||||
|
|
|
@ -2,7 +2,6 @@ package WayofTime.bloodmagic.api.iface;
|
||||||
|
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
|
||||||
public interface IAlchemyArray
|
public interface IAlchemyArray {
|
||||||
{
|
|
||||||
EnumFacing getRotation();
|
EnumFacing getRotation();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ package WayofTime.bloodmagic.api.iface;
|
||||||
* Any item that implements this interface will not be pulled into the Altar on
|
* Any item that implements this interface will not be pulled into the Altar on
|
||||||
* right click.
|
* right click.
|
||||||
*/
|
*/
|
||||||
public interface IAltarReader
|
public interface IAltarReader {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,41 +6,33 @@ import net.minecraft.item.ItemStack;
|
||||||
/**
|
/**
|
||||||
* Implement this interface on any Item that can be bound to a player.
|
* Implement this interface on any Item that can be bound to a player.
|
||||||
*/
|
*/
|
||||||
public interface IBindable
|
public interface IBindable {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Gets the username of the Item's owner. Usually for display, such as in
|
* Gets the username of the Item's owner. Usually for display, such as in
|
||||||
* the tooltip.
|
* the tooltip.
|
||||||
*
|
* <p>
|
||||||
* If the item is not bound, this will be null.
|
* If the item is not bound, this will be null.
|
||||||
*
|
*
|
||||||
* @param stack
|
* @param stack - The owned ItemStack
|
||||||
* - The owned ItemStack
|
|
||||||
*
|
|
||||||
* @return - The username of the Item's owner
|
* @return - The username of the Item's owner
|
||||||
*/
|
*/
|
||||||
String getOwnerName(ItemStack stack);
|
String getOwnerName(ItemStack stack);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the UUID of the Item's owner.
|
* Gets the UUID of the Item's owner.
|
||||||
*
|
* <p>
|
||||||
* If the item is not bound, this will be null.
|
* If the item is not bound, this will be null.
|
||||||
*
|
*
|
||||||
* @param stack
|
* @param stack - The owned ItemStack
|
||||||
* - The owned ItemStack
|
|
||||||
*
|
|
||||||
* @return - The UUID of the Item's owner
|
* @return - The UUID of the Item's owner
|
||||||
*/
|
*/
|
||||||
String getOwnerUUID(ItemStack stack);
|
String getOwnerUUID(ItemStack stack);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the player attempts to bind the item.
|
* Called when the player attempts to bind the item.
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player - The Player attempting to bind the item
|
||||||
* - The Player attempting to bind the item
|
* @param stack - The ItemStack to attempt binding
|
||||||
* @param stack
|
|
||||||
* - The ItemStack to attempt binding
|
|
||||||
*
|
|
||||||
* @return If binding was successful.
|
* @return If binding was successful.
|
||||||
*/
|
*/
|
||||||
boolean onBind(EntityPlayer player, ItemStack stack);
|
boolean onBind(EntityPlayer player, ItemStack stack);
|
||||||
|
|
|
@ -6,7 +6,6 @@ import net.minecraft.item.ItemStack;
|
||||||
* An interface for items that have custom drainage behaviour when used in
|
* An interface for items that have custom drainage behaviour when used in
|
||||||
* certain alchemy recipes.
|
* certain alchemy recipes.
|
||||||
*/
|
*/
|
||||||
public interface ICustomAlchemyConsumable
|
public interface ICustomAlchemyConsumable {
|
||||||
{
|
|
||||||
ItemStack drainUseOnAlchemyCraft(ItemStack stack);
|
ItemStack drainUseOnAlchemyCraft(ItemStack stack);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public interface IDemonWillViewer
|
public interface IDemonWillViewer {
|
||||||
{
|
|
||||||
boolean canSeeDemonWillAura(World world, ItemStack stack, EntityPlayer player);
|
boolean canSeeDemonWillAura(World world, ItemStack stack, EntityPlayer player);
|
||||||
|
|
||||||
int getDemonWillAuraResolution(World world, ItemStack stack, EntityPlayer player);
|
int getDemonWillAuraResolution(World world, ItemStack stack, EntityPlayer player);
|
||||||
|
|
|
@ -11,27 +11,21 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks blocks as one that is documented.
|
* Marks blocks as one that is documented.
|
||||||
*
|
* <p>
|
||||||
* This documentation can be read by an
|
* This documentation can be read by an
|
||||||
* {@link WayofTime.bloodmagic.item.ItemSanguineBook} (or child)
|
* {@link WayofTime.bloodmagic.item.ItemSanguineBook} (or child)
|
||||||
*/
|
*/
|
||||||
public interface IDocumentedBlock
|
public interface IDocumentedBlock {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Provides the documentation to provide to the player. Usually a
|
* Provides the documentation to provide to the player. Usually a
|
||||||
* short'n'sweet description about basic usage.
|
* short'n'sweet description about basic usage.
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player - The EntityPlayer attempting to view the Documentation.
|
||||||
* - The EntityPlayer attempting to view the Documentation.
|
* @param world - The World interaction is happening in.
|
||||||
* @param world
|
* @param pos - The BlockPos being interacted at.
|
||||||
* - The World interaction is happening in.
|
* @param state - The IBlockState of the interacted Block.
|
||||||
* @param pos
|
|
||||||
* - The BlockPos being interacted at.
|
|
||||||
* @param state
|
|
||||||
* - The IBlockState of the interacted Block.
|
|
||||||
*
|
|
||||||
* @return - A list of formatted ITextComponent to provide to the player.
|
* @return - A list of formatted ITextComponent to provide to the player.
|
||||||
* Provide an empty list if there is no available documentation.
|
* Provide an empty list if there is no available documentation.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
List<ITextComponent> getDocumentation(EntityPlayer player, World world, BlockPos pos, IBlockState state);
|
List<ITextComponent> getDocumentation(EntityPlayer player, World world, BlockPos pos, IBlockState state);
|
||||||
|
|
|
@ -7,23 +7,18 @@ import net.minecraft.world.World;
|
||||||
/**
|
/**
|
||||||
* Used to define a HarvestHandler for the Harvest Ritual.
|
* Used to define a HarvestHandler for the Harvest Ritual.
|
||||||
*/
|
*/
|
||||||
public interface IHarvestHandler
|
public interface IHarvestHandler {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Called whenever the Harvest Ritual attempts to harvest a block. <br>
|
* Called whenever the Harvest Ritual attempts to harvest a block. <br>
|
||||||
* Use this to break the block, plant a new one, and drop the produced
|
* Use this to break the block, plant a new one, and drop the produced
|
||||||
* items. <br>
|
* items. <br>
|
||||||
* Make sure to do checks so you are certain the blocks being handled are
|
* Make sure to do checks so you are certain the blocks being handled are
|
||||||
* the block types you want.
|
* the block types you want.
|
||||||
*
|
*
|
||||||
* @param world
|
* @param world - The world the
|
||||||
* - The world the
|
* {@link WayofTime.bloodmagic.api.ritual.IMasterRitualStone} is in.
|
||||||
* {@link WayofTime.bloodmagic.api.ritual.IMasterRitualStone} is in.
|
* @param pos - The position of the Block being checked
|
||||||
* @param pos
|
* @param blockStack - The Block being checked
|
||||||
* - The position of the Block being checked
|
|
||||||
* @param blockStack
|
|
||||||
* - The Block being checked
|
|
||||||
*
|
|
||||||
* @return If the block was successfully harvested.
|
* @return If the block was successfully harvested.
|
||||||
*/
|
*/
|
||||||
boolean harvestAndPlant(World world, BlockPos pos, BlockStack blockStack);
|
boolean harvestAndPlant(World world, BlockPos pos, BlockStack blockStack);
|
||||||
|
|
|
@ -5,8 +5,7 @@ import net.minecraft.item.ItemStack;
|
||||||
/**
|
/**
|
||||||
* Interface used for any item that can store LP in itself
|
* Interface used for any item that can store LP in itself
|
||||||
*/
|
*/
|
||||||
public interface IItemLPContainer
|
public interface IItemLPContainer {
|
||||||
{
|
|
||||||
int getCapacity();
|
int getCapacity();
|
||||||
|
|
||||||
void setStoredLP(ItemStack stack, int lp);
|
void setStoredLP(ItemStack stack, int lp);
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package WayofTime.bloodmagic.api.iface;
|
package WayofTime.bloodmagic.api.iface;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public interface IMultiWillTool
|
public interface IMultiWillTool {
|
||||||
{
|
|
||||||
EnumDemonWillType getCurrentType(ItemStack stack);
|
EnumDemonWillType getCurrentType(ItemStack stack);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,5 @@ package WayofTime.bloodmagic.api.iface;
|
||||||
* Held items that implement this will cause the beams between routing nodes to
|
* Held items that implement this will cause the beams between routing nodes to
|
||||||
* render.
|
* render.
|
||||||
*/
|
*/
|
||||||
public interface INodeRenderer
|
public interface INodeRenderer {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,7 @@ package WayofTime.bloodmagic.api.iface;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public interface IPurificationAsh
|
public interface IPurificationAsh {
|
||||||
{
|
|
||||||
double getTotalPurity(ItemStack stack);
|
double getTotalPurity(ItemStack stack);
|
||||||
|
|
||||||
double getMaxPurity(ItemStack stack);
|
double getMaxPurity(ItemStack stack);
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
package WayofTime.bloodmagic.api.iface;
|
package WayofTime.bloodmagic.api.iface;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
|
||||||
|
|
||||||
public interface ISentientSwordEffectProvider
|
public interface ISentientSwordEffectProvider {
|
||||||
{
|
|
||||||
boolean applyOnHitEffect(EnumDemonWillType type, ItemStack swordStack, ItemStack providerStack, EntityLivingBase attacker, EntityLivingBase target);
|
boolean applyOnHitEffect(EnumDemonWillType type, ItemStack swordStack, ItemStack providerStack, EntityLivingBase attacker, EntityLivingBase target);
|
||||||
|
|
||||||
boolean providesEffectForWill(EnumDemonWillType type);
|
boolean providesEffectForWill(EnumDemonWillType type);
|
||||||
|
|
|
@ -3,7 +3,6 @@ package WayofTime.bloodmagic.api.iface;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public interface ISentientTool
|
public interface ISentientTool {
|
||||||
{
|
|
||||||
boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player);
|
boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,14 +11,12 @@ import javax.annotation.Nonnull;
|
||||||
* Used for all {@link WayofTime.bloodmagic.api.impl.ItemSigil} <b>EXCEPT</b>
|
* Used for all {@link WayofTime.bloodmagic.api.impl.ItemSigil} <b>EXCEPT</b>
|
||||||
* Sigils of Holdings.
|
* Sigils of Holdings.
|
||||||
*/
|
*/
|
||||||
public interface ISigil
|
public interface ISigil {
|
||||||
{
|
|
||||||
boolean performArrayEffect(World world, BlockPos pos);
|
boolean performArrayEffect(World world, BlockPos pos);
|
||||||
|
|
||||||
boolean hasArrayEffect();
|
boolean hasArrayEffect();
|
||||||
|
|
||||||
interface Holding
|
interface Holding {
|
||||||
{
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
ItemStack getHeldItem(ItemStack holdingStack, EntityPlayer player);
|
ItemStack getHeldItem(ItemStack holdingStack, EntityPlayer player);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,7 @@ import java.util.List;
|
||||||
* This interface is used for items intended to train specific upgrades while
|
* This interface is used for items intended to train specific upgrades while
|
||||||
* held in the player's inventory.
|
* held in the player's inventory.
|
||||||
*/
|
*/
|
||||||
public interface IUpgradeTrainer
|
public interface IUpgradeTrainer {
|
||||||
{
|
|
||||||
List<String> getTrainedUpgrades(ItemStack stack);
|
List<String> getTrainedUpgrades(ItemStack stack);
|
||||||
|
|
||||||
boolean setTrainedUpgrades(ItemStack stack, List<String> keys);
|
boolean setTrainedUpgrades(ItemStack stack, List<String> keys);
|
||||||
|
|
|
@ -1,19 +1,16 @@
|
||||||
package WayofTime.bloodmagic.api.impl;
|
package WayofTime.bloodmagic.api.impl;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
|
import WayofTime.bloodmagic.api.iface.IBindable;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
|
||||||
import WayofTime.bloodmagic.api.iface.IBindable;
|
|
||||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for all bindable items.
|
* Base class for all bindable items.
|
||||||
*/
|
*/
|
||||||
public class ItemBindable extends Item implements IBindable
|
public class ItemBindable extends Item implements IBindable {
|
||||||
{
|
public ItemBindable() {
|
||||||
public ItemBindable()
|
|
||||||
{
|
|
||||||
super();
|
super();
|
||||||
|
|
||||||
setMaxStackSize(1);
|
setMaxStackSize(1);
|
||||||
|
@ -22,20 +19,17 @@ public class ItemBindable extends Item implements IBindable
|
||||||
// IBindable
|
// IBindable
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBind(EntityPlayer player, ItemStack stack)
|
public boolean onBind(EntityPlayer player, ItemStack stack) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnerName(ItemStack stack)
|
public String getOwnerName(ItemStack stack) {
|
||||||
{
|
|
||||||
return !stack.isEmpty() ? stack.getTagCompound().getString(Constants.NBT.OWNER_NAME) : null;
|
return !stack.isEmpty() ? stack.getTagCompound().getString(Constants.NBT.OWNER_NAME) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnerUUID(ItemStack stack)
|
public String getOwnerUUID(ItemStack stack) {
|
||||||
{
|
|
||||||
return !stack.isEmpty() ? stack.getTagCompound().getString(Constants.NBT.OWNER_UUID) : null;
|
return !stack.isEmpty() ? stack.getTagCompound().getString(Constants.NBT.OWNER_UUID) : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,26 +10,22 @@ import net.minecraft.world.World;
|
||||||
/**
|
/**
|
||||||
* Base class for all (static) sigils.
|
* Base class for all (static) sigils.
|
||||||
*/
|
*/
|
||||||
public class ItemSigil extends ItemBindable implements ISigil
|
public class ItemSigil extends ItemBindable implements ISigil {
|
||||||
{
|
|
||||||
private int lpUsed;
|
private int lpUsed;
|
||||||
|
|
||||||
public ItemSigil(int lpUsed)
|
public ItemSigil(int lpUsed) {
|
||||||
{
|
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.lpUsed = lpUsed;
|
this.lpUsed = lpUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUnusable(ItemStack stack)
|
public boolean isUnusable(ItemStack stack) {
|
||||||
{
|
|
||||||
NBTHelper.checkNBT(stack);
|
NBTHelper.checkNBT(stack);
|
||||||
|
|
||||||
return stack.getTagCompound().getBoolean(Constants.NBT.UNUSABLE);
|
return stack.getTagCompound().getBoolean(Constants.NBT.UNUSABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack setUnusable(ItemStack stack, boolean unusable)
|
public ItemStack setUnusable(ItemStack stack, boolean unusable) {
|
||||||
{
|
|
||||||
NBTHelper.checkNBT(stack);
|
NBTHelper.checkNBT(stack);
|
||||||
|
|
||||||
stack.getTagCompound().setBoolean(Constants.NBT.UNUSABLE, unusable);
|
stack.getTagCompound().setBoolean(Constants.NBT.UNUSABLE, unusable);
|
||||||
|
@ -37,14 +33,12 @@ public class ItemSigil extends ItemBindable implements ISigil
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean performArrayEffect(World world, BlockPos pos)
|
public boolean performArrayEffect(World world, BlockPos pos) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasArrayEffect()
|
public boolean hasArrayEffect() {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,24 +21,19 @@ import net.minecraft.world.World;
|
||||||
/**
|
/**
|
||||||
* Base class for all toggleable sigils.
|
* Base class for all toggleable sigils.
|
||||||
*/
|
*/
|
||||||
public class ItemSigilToggleable extends ItemSigil implements IActivatable
|
public class ItemSigilToggleable extends ItemSigil implements IActivatable {
|
||||||
{
|
public ItemSigilToggleable(int lpUsed) {
|
||||||
public ItemSigilToggleable(int lpUsed)
|
|
||||||
{
|
|
||||||
super(lpUsed);
|
super(lpUsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getActivated(ItemStack stack)
|
public boolean getActivated(ItemStack stack) {
|
||||||
{
|
|
||||||
return !stack.isEmpty() && NBTHelper.checkNBT(stack).getTagCompound().getBoolean(Constants.NBT.ACTIVATED);
|
return !stack.isEmpty() && NBTHelper.checkNBT(stack).getTagCompound().getBoolean(Constants.NBT.ACTIVATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack setActivatedState(ItemStack stack, boolean activated)
|
public ItemStack setActivatedState(ItemStack stack, boolean activated) {
|
||||||
{
|
if (!stack.isEmpty()) {
|
||||||
if (!stack.isEmpty())
|
|
||||||
{
|
|
||||||
NBTHelper.checkNBT(stack).getTagCompound().setBoolean(Constants.NBT.ACTIVATED, activated);
|
NBTHelper.checkNBT(stack).getTagCompound().setBoolean(Constants.NBT.ACTIVATED, activated);
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
@ -47,16 +42,14 @@ public class ItemSigilToggleable extends ItemSigil implements IActivatable
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||||
{
|
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
if (stack.getItem() instanceof ISigil.Holding)
|
if (stack.getItem() instanceof ISigil.Holding)
|
||||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||||
if (PlayerHelper.isFakePlayer(player))
|
if (PlayerHelper.isFakePlayer(player))
|
||||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||||
|
|
||||||
if (!world.isRemote && !isUnusable(stack))
|
if (!world.isRemote && !isUnusable(stack)) {
|
||||||
{
|
|
||||||
if (player.isSneaking())
|
if (player.isSneaking())
|
||||||
setActivatedState(stack, !getActivated(stack));
|
setActivatedState(stack, !getActivated(stack));
|
||||||
if (getActivated(stack) && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()))
|
if (getActivated(stack) && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()))
|
||||||
|
@ -67,8 +60,7 @@ public class ItemSigilToggleable extends ItemSigil implements IActivatable
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||||
{
|
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
if (stack.getItem() instanceof ISigil.Holding)
|
if (stack.getItem() instanceof ISigil.Holding)
|
||||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||||
|
@ -78,20 +70,15 @@ public class ItemSigilToggleable extends ItemSigil implements IActivatable
|
||||||
return (NetworkHelper.getSoulNetwork(getOwnerUUID(player.getHeldItem(hand))).syphonAndDamage(player, getLpUsed()) && onSigilUse(player.getHeldItem(hand), player, world, pos, side, hitX, hitY, hitZ)) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
|
return (NetworkHelper.getSoulNetwork(getOwnerUUID(player.getHeldItem(hand))).syphonAndDamage(player, getLpUsed()) && onSigilUse(player.getHeldItem(hand), player, world, pos, side, hitX, hitY, hitZ)) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onSigilUse(ItemStack itemStack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ)
|
public boolean onSigilUse(ItemStack itemStack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
|
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
|
||||||
{
|
if (!worldIn.isRemote && entityIn instanceof EntityPlayerMP && getActivated(stack)) {
|
||||||
if (!worldIn.isRemote && entityIn instanceof EntityPlayerMP && getActivated(stack))
|
if (entityIn.ticksExisted % 100 == 0) {
|
||||||
{
|
if (!NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage((EntityPlayer) entityIn, getLpUsed())) {
|
||||||
if (entityIn.ticksExisted % 100 == 0)
|
|
||||||
{
|
|
||||||
if (!NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage((EntityPlayer) entityIn, getLpUsed()))
|
|
||||||
{
|
|
||||||
setActivatedState(stack, false);
|
setActivatedState(stack, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,7 +87,6 @@ public class ItemSigilToggleable extends ItemSigil implements IActivatable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
|
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package WayofTime.bloodmagic.api.incense;
|
package WayofTime.bloodmagic.api.incense;
|
||||||
|
|
||||||
public enum EnumTranquilityType
|
public enum EnumTranquilityType {
|
||||||
{
|
|
||||||
PLANT(),
|
PLANT(),
|
||||||
CROP(),
|
CROP(),
|
||||||
TREE(),
|
TREE(),
|
||||||
|
|
|
@ -4,8 +4,7 @@ import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public interface IIncensePath
|
public interface IIncensePath {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Goes from 0 to however far this path block can be from the altar while
|
* Goes from 0 to however far this path block can be from the altar while
|
||||||
* still functioning. 0 represents a block that can work when it is two
|
* still functioning. 0 represents a block that can work when it is two
|
||||||
|
|
|
@ -5,7 +5,6 @@ import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public interface ITranquilityHandler
|
public interface ITranquilityHandler {
|
||||||
{
|
|
||||||
TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state);
|
TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,22 +8,17 @@ import net.minecraft.world.World;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class IncenseTranquilityRegistry
|
public class IncenseTranquilityRegistry {
|
||||||
{
|
|
||||||
public static List<ITranquilityHandler> handlerList = new ArrayList<ITranquilityHandler>();
|
public static List<ITranquilityHandler> handlerList = new ArrayList<ITranquilityHandler>();
|
||||||
|
|
||||||
public static void registerTranquilityHandler(ITranquilityHandler handler)
|
public static void registerTranquilityHandler(ITranquilityHandler handler) {
|
||||||
{
|
|
||||||
handlerList.add(handler);
|
handlerList.add(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state)
|
public static TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) {
|
||||||
{
|
for (ITranquilityHandler handler : handlerList) {
|
||||||
for (ITranquilityHandler handler : handlerList)
|
|
||||||
{
|
|
||||||
TranquilityStack tranq = handler.getTranquilityOfBlock(world, pos, block, state);
|
TranquilityStack tranq = handler.getTranquilityOfBlock(world, pos, block, state);
|
||||||
if (tranq != null)
|
if (tranq != null) {
|
||||||
{
|
|
||||||
return tranq;
|
return tranq;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
package WayofTime.bloodmagic.api.incense;
|
package WayofTime.bloodmagic.api.incense;
|
||||||
|
|
||||||
public class TranquilityStack
|
public class TranquilityStack {
|
||||||
{
|
|
||||||
public final EnumTranquilityType type;
|
public final EnumTranquilityType type;
|
||||||
public double value;
|
public double value;
|
||||||
|
|
||||||
public TranquilityStack(EnumTranquilityType type, double value)
|
public TranquilityStack(EnumTranquilityType type, double value) {
|
||||||
{
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package WayofTime.bloodmagic.api.livingArmour;
|
package WayofTime.bloodmagic.api.livingArmour;
|
||||||
|
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -9,12 +8,10 @@ import net.minecraft.world.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface this is used purely for internal implementation.
|
* An interface this is used purely for internal implementation.
|
||||||
*
|
*
|
||||||
* @author WayofTime
|
* @author WayofTime
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface ILivingArmour
|
public interface ILivingArmour {
|
||||||
{
|
|
||||||
Multimap<String, AttributeModifier> getAttributeModifiers();
|
Multimap<String, AttributeModifier> getAttributeModifiers();
|
||||||
|
|
||||||
boolean canApplyUpgrade(EntityPlayer user, LivingArmourUpgrade upgrade);
|
boolean canApplyUpgrade(EntityPlayer user, LivingArmourUpgrade upgrade);
|
||||||
|
@ -28,11 +25,9 @@ public interface ILivingArmour
|
||||||
/**
|
/**
|
||||||
* Ticks the upgrades and stat trackers, passing in the world and player as
|
* Ticks the upgrades and stat trackers, passing in the world and player as
|
||||||
* well as the LivingArmour
|
* well as the LivingArmour
|
||||||
*
|
*
|
||||||
* @param world
|
* @param world - The World
|
||||||
* - The World
|
* @param player - The player wearing the Armour
|
||||||
* @param player
|
|
||||||
* - The player wearing the Armour
|
|
||||||
*/
|
*/
|
||||||
void onTick(World world, EntityPlayer player);
|
void onTick(World world, EntityPlayer player);
|
||||||
|
|
||||||
|
@ -43,9 +38,8 @@ public interface ILivingArmour
|
||||||
/**
|
/**
|
||||||
* Writes the LivingArmour to the NBTTag. This will only write the trackers
|
* Writes the LivingArmour to the NBTTag. This will only write the trackers
|
||||||
* that are dirty.
|
* that are dirty.
|
||||||
*
|
*
|
||||||
* @param tag
|
* @param tag - The NBT tag to write to
|
||||||
* - The NBT tag to write to
|
|
||||||
*/
|
*/
|
||||||
void writeDirtyToNBT(NBTTagCompound tag);
|
void writeDirtyToNBT(NBTTagCompound tag);
|
||||||
|
|
||||||
|
|
|
@ -8,66 +8,53 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class LivingArmourHandler
|
public class LivingArmourHandler {
|
||||||
{
|
|
||||||
public static List<Class<? extends StatTracker>> trackers = new ArrayList<Class<? extends StatTracker>>();
|
public static List<Class<? extends StatTracker>> trackers = new ArrayList<Class<? extends StatTracker>>();
|
||||||
public static HashMap<String, Class<? extends LivingArmourUpgrade>> upgradeMap = new HashMap<String, Class<? extends LivingArmourUpgrade>>();
|
public static HashMap<String, Class<? extends LivingArmourUpgrade>> upgradeMap = new HashMap<String, Class<? extends LivingArmourUpgrade>>();
|
||||||
public static HashMap<String, Constructor<? extends LivingArmourUpgrade>> upgradeConstructorMap = new HashMap<String, Constructor<? extends LivingArmourUpgrade>>();
|
public static HashMap<String, Constructor<? extends LivingArmourUpgrade>> upgradeConstructorMap = new HashMap<String, Constructor<? extends LivingArmourUpgrade>>();
|
||||||
public static HashMap<String, Integer> upgradeMaxLevelMap = new HashMap<String, Integer>();
|
public static HashMap<String, Integer> upgradeMaxLevelMap = new HashMap<String, Integer>();
|
||||||
|
|
||||||
public static void registerStatTracker(Class<? extends StatTracker> tracker)
|
public static void registerStatTracker(Class<? extends StatTracker> tracker) {
|
||||||
{
|
|
||||||
trackers.add(tracker);
|
trackers.add(tracker);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a LivingArmourUpgrade using its unique identifier and class.
|
* Registers a LivingArmourUpgrade using its unique identifier and class.
|
||||||
* This is done to more easily load upgrades
|
* This is done to more easily load upgrades
|
||||||
*
|
*
|
||||||
* @param upgrade
|
* @param upgrade
|
||||||
*/
|
*/
|
||||||
public static void registerArmourUpgrade(LivingArmourUpgrade upgrade)
|
public static void registerArmourUpgrade(LivingArmourUpgrade upgrade) {
|
||||||
{
|
|
||||||
Class<? extends LivingArmourUpgrade> clazz = upgrade.getClass();
|
Class<? extends LivingArmourUpgrade> clazz = upgrade.getClass();
|
||||||
upgradeMap.put(upgrade.getUniqueIdentifier(), clazz);
|
upgradeMap.put(upgrade.getUniqueIdentifier(), clazz);
|
||||||
upgradeMaxLevelMap.put(upgrade.getUniqueIdentifier(), upgrade.getMaxTier());
|
upgradeMaxLevelMap.put(upgrade.getUniqueIdentifier(), upgrade.getMaxTier());
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
Constructor<? extends LivingArmourUpgrade> ctor = clazz.getConstructor(int.class);
|
Constructor<? extends LivingArmourUpgrade> ctor = clazz.getConstructor(int.class);
|
||||||
if (ctor == null)
|
if (ctor == null) {
|
||||||
{
|
|
||||||
BloodMagicAPI.logger.error("Error adding living armour upgrade {} as it doesn't have a valid constructor.", upgrade.getUniqueIdentifier());
|
BloodMagicAPI.logger.error("Error adding living armour upgrade {} as it doesn't have a valid constructor.", upgrade.getUniqueIdentifier());
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
upgradeConstructorMap.put(upgrade.getUniqueIdentifier(), ctor);
|
upgradeConstructorMap.put(upgrade.getUniqueIdentifier(), ctor);
|
||||||
}
|
}
|
||||||
} catch (Exception e)
|
} catch (Exception e) {
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level)
|
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level) {
|
||||||
{
|
|
||||||
return generateUpgradeFromKey(key, level, null);
|
return generateUpgradeFromKey(key, level, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level, NBTTagCompound tag)
|
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level, NBTTagCompound tag) {
|
||||||
{
|
|
||||||
Constructor<? extends LivingArmourUpgrade> ctor = upgradeConstructorMap.get(key);
|
Constructor<? extends LivingArmourUpgrade> ctor = upgradeConstructorMap.get(key);
|
||||||
if (ctor != null)
|
if (ctor != null) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
LivingArmourUpgrade upgrade = ctor.newInstance(level);
|
LivingArmourUpgrade upgrade = ctor.newInstance(level);
|
||||||
if (upgrade != null && tag != null)
|
if (upgrade != null && tag != null) {
|
||||||
{
|
|
||||||
upgrade.readFromNBT(tag);
|
upgrade.readFromNBT(tag);
|
||||||
}
|
}
|
||||||
return upgrade;
|
return upgrade;
|
||||||
} catch (Exception e)
|
} catch (Exception e) {
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package WayofTime.bloodmagic.api.livingArmour;
|
||||||
|
|
||||||
import com.google.common.collect.HashMultimap;
|
import com.google.common.collect.HashMultimap;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -11,8 +10,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.DamageSource;
|
import net.minecraft.util.DamageSource;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public abstract class LivingArmourUpgrade
|
public abstract class LivingArmourUpgrade {
|
||||||
{
|
|
||||||
public static String chatBase = "chat.bloodmagic.livingArmour.upgrade.";
|
public static String chatBase = "chat.bloodmagic.livingArmour.upgrade.";
|
||||||
public static String tooltipBase = "tooltip.bloodmagic.livingArmour.upgrade.";
|
public static String tooltipBase = "tooltip.bloodmagic.livingArmour.upgrade.";
|
||||||
|
|
||||||
|
@ -26,38 +24,32 @@ public abstract class LivingArmourUpgrade
|
||||||
* The LivingArmourUpgrade must have a constructor that has a single integer
|
* The LivingArmourUpgrade must have a constructor that has a single integer
|
||||||
* parameter. Upgrades may have other constructors, but must have one of
|
* parameter. Upgrades may have other constructors, but must have one of
|
||||||
* these.
|
* these.
|
||||||
*
|
*
|
||||||
* @param level
|
* @param level The level of the upgrade
|
||||||
* The level of the upgrade
|
|
||||||
*/
|
*/
|
||||||
public LivingArmourUpgrade(int level)
|
public LivingArmourUpgrade(int level) {
|
||||||
{
|
|
||||||
this.level = Math.min(level, getMaxTier() - 1);
|
this.level = Math.min(level, getMaxTier() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getAdditionalDamageOnHit(double damage, EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon)
|
public double getAdditionalDamageOnHit(double damage, EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getKnockbackOnHit(EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon)
|
public double getKnockbackOnHit(EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Percentage of damage blocked. This stacks multiplicities with other
|
* Percentage of damage blocked. This stacks multiplicities with other
|
||||||
* upgrades.
|
* upgrades.
|
||||||
*
|
*
|
||||||
* @return 0 for no damage blocked, 1 for full damage blocked
|
* @return 0 for no damage blocked, 1 for full damage blocked
|
||||||
*/
|
*/
|
||||||
public double getArmourProtection(EntityLivingBase wearer, DamageSource source)
|
public double getArmourProtection(EntityLivingBase wearer, DamageSource source) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getUpgradeLevel()
|
public int getUpgradeLevel() {
|
||||||
{
|
|
||||||
return this.level;
|
return this.level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,17 +61,14 @@ public abstract class LivingArmourUpgrade
|
||||||
|
|
||||||
public abstract int getCostOfUpgrade();
|
public abstract int getCostOfUpgrade();
|
||||||
|
|
||||||
public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour)
|
public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Multimap<String, AttributeModifier> getAttributeModifiers()
|
public Multimap<String, AttributeModifier> getAttributeModifiers() {
|
||||||
{
|
|
||||||
return HashMultimap.create();
|
return HashMultimap.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMiningSpeedModifier(EntityPlayer player)
|
public double getMiningSpeedModifier(EntityPlayer player) {
|
||||||
{
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,18 +76,15 @@ public abstract class LivingArmourUpgrade
|
||||||
|
|
||||||
public abstract void readFromNBT(NBTTagCompound tag);
|
public abstract void readFromNBT(NBTTagCompound tag);
|
||||||
|
|
||||||
public int getRunicShielding()
|
public int getRunicShielding() {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean runOnClient()
|
public boolean runOnClient() {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDowngrade()
|
public boolean isDowngrade() {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
package WayofTime.bloodmagic.api.livingArmour;
|
package WayofTime.bloodmagic.api.livingArmour;
|
||||||
|
|
||||||
import java.util.List;
|
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
|
||||||
|
|
||||||
public abstract class StatTracker
|
import java.util.List;
|
||||||
{
|
|
||||||
|
public abstract class StatTracker {
|
||||||
private boolean isDirty = false;
|
private boolean isDirty = false;
|
||||||
|
|
||||||
public abstract String getUniqueIdentifier();
|
public abstract String getUniqueIdentifier();
|
||||||
|
@ -26,13 +25,10 @@ public abstract class StatTracker
|
||||||
/**
|
/**
|
||||||
* Called each tick to update the tracker's information. Called in
|
* Called each tick to update the tracker's information. Called in
|
||||||
* LivingArmour
|
* LivingArmour
|
||||||
*
|
*
|
||||||
* @param world
|
* @param world World the player is in
|
||||||
* World the player is in
|
* @param player The player that has the armour equipped
|
||||||
* @param player
|
* @param livingArmour The equipped LivingArmour
|
||||||
* The player that has the armour equipped
|
|
||||||
* @param livingArmour
|
|
||||||
* The equipped LivingArmour
|
|
||||||
* @return True if there is a new upgrade unlocked this tick.
|
* @return True if there is a new upgrade unlocked this tick.
|
||||||
*/
|
*/
|
||||||
public abstract boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour);
|
public abstract boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour);
|
||||||
|
@ -43,30 +39,25 @@ public abstract class StatTracker
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to obtain the progress from the current level to the next level.
|
* Used to obtain the progress from the current level to the next level.
|
||||||
*
|
* <p>
|
||||||
* 0.0 being 0% - 1.0 being 100%.
|
* 0.0 being 0% - 1.0 being 100%.
|
||||||
*
|
*
|
||||||
* @param livingArmour
|
* @param livingArmour The equipped LivingArmour
|
||||||
* The equipped LivingArmour
|
|
||||||
* @return the progress from the current level to the next level.
|
* @return the progress from the current level to the next level.
|
||||||
*/
|
*/
|
||||||
public double getProgress(LivingArmour livingArmour, int currentLevel)
|
public double getProgress(LivingArmour livingArmour, int currentLevel) {
|
||||||
{
|
|
||||||
return 1.0D;
|
return 1.0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isDirty()
|
public final boolean isDirty() {
|
||||||
{
|
|
||||||
return isDirty;
|
return isDirty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void markDirty()
|
public final void markDirty() {
|
||||||
{
|
|
||||||
this.isDirty = true;
|
this.isDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void resetDirty()
|
public final void resetDirty() {
|
||||||
{
|
|
||||||
this.isDirty = false;
|
this.isDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,10 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base object for all Blood Orbs. Makes Orb creation quite a bit easier.
|
* Base object for all Blood Orbs. Makes Orb creation quite a bit easier.
|
||||||
*
|
* <p>
|
||||||
* Just create a new BloodOrb instance then register it in {@link net.minecraftforge.event.RegistryEvent.Register<BloodOrb>}
|
* Just create a new BloodOrb instance then register it in {@link net.minecraftforge.event.RegistryEvent.Register<BloodOrb>}
|
||||||
*/
|
*/
|
||||||
public class BloodOrb extends IForgeRegistryEntry.Impl<BloodOrb>
|
public class BloodOrb extends IForgeRegistryEntry.Impl<BloodOrb> {
|
||||||
{
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final int tier;
|
private final int tier;
|
||||||
private final int capacity;
|
private final int capacity;
|
||||||
|
@ -22,33 +21,26 @@ public class BloodOrb extends IForgeRegistryEntry.Impl<BloodOrb>
|
||||||
/**
|
/**
|
||||||
* A base object for BloodOrbs. A bit cleaner than the old way through
|
* A base object for BloodOrbs. A bit cleaner than the old way through
|
||||||
* EnergyItems.
|
* EnergyItems.
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name - A name for the Orb. Gets put into an unlocalized name.
|
||||||
* - A name for the Orb. Gets put into an unlocalized name.
|
* @param tier - The tier of the Orb.
|
||||||
* @param tier
|
* @param capacity - The max amount of LP the Orb can store.
|
||||||
* - The tier of the Orb.
|
|
||||||
* @param capacity
|
|
||||||
* - The max amount of LP the Orb can store.
|
|
||||||
*/
|
*/
|
||||||
public BloodOrb(String name, int tier, int capacity)
|
public BloodOrb(String name, int tier, int capacity) {
|
||||||
{
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.tier = tier;
|
this.tier = tier;
|
||||||
this.capacity = capacity;
|
this.capacity = capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTier()
|
public int getTier() {
|
||||||
{
|
|
||||||
return tier;
|
return tier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCapacity()
|
public int getCapacity() {
|
||||||
{
|
|
||||||
return capacity;
|
return capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,8 +55,7 @@ public class BloodOrb extends IForgeRegistryEntry.Impl<BloodOrb>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
|
||||||
return "BloodOrb{" + "name='" + name + '\'' + ", tier=" + tier + ", capacity=" + capacity + ", owner=" + getRegistryName() + '}';
|
return "BloodOrb{" + "name='" + name + '\'' + ", tier=" + tier + ", capacity=" + capacity + ", owner=" + getRegistryName() + '}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,7 @@ import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public interface IBloodOrb
|
public interface IBloodOrb {
|
||||||
{
|
|
||||||
@Nullable
|
@Nullable
|
||||||
BloodOrb getOrb(ItemStack stack);
|
BloodOrb getOrb(ItemStack stack);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,50 +1,41 @@
|
||||||
package WayofTime.bloodmagic.api.recipe;
|
package WayofTime.bloodmagic.api.recipe;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.iface.ICustomAlchemyConsumable;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import WayofTime.bloodmagic.api.iface.ICustomAlchemyConsumable;
|
|
||||||
|
|
||||||
public class AlchemyTableCustomRecipe extends AlchemyTableRecipe
|
public class AlchemyTableCustomRecipe extends AlchemyTableRecipe {
|
||||||
{
|
public AlchemyTableCustomRecipe(Block result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) {
|
||||||
public AlchemyTableCustomRecipe(Block result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe)
|
|
||||||
{
|
|
||||||
this(new ItemStack(result), lpDrained, ticksRequired, tierRequired, recipe);
|
this(new ItemStack(result), lpDrained, ticksRequired, tierRequired, recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlchemyTableCustomRecipe(Item result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe)
|
public AlchemyTableCustomRecipe(Item result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) {
|
||||||
{
|
|
||||||
this(new ItemStack(result), lpDrained, ticksRequired, tierRequired, recipe);
|
this(new ItemStack(result), lpDrained, ticksRequired, tierRequired, recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlchemyTableCustomRecipe(ItemStack result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe)
|
public AlchemyTableCustomRecipe(ItemStack result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) {
|
||||||
{
|
|
||||||
super(result, lpDrained, ticksRequired, tierRequired, recipe);
|
super(result, lpDrained, ticksRequired, tierRequired, recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ItemStack getContainerItem(ItemStack stack)
|
protected ItemStack getContainerItem(ItemStack stack) {
|
||||||
{
|
if (stack.isEmpty()) {
|
||||||
if (stack.isEmpty())
|
|
||||||
{
|
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack copyStack = stack.copy();
|
ItemStack copyStack = stack.copy();
|
||||||
|
|
||||||
if (copyStack.getItem() instanceof ICustomAlchemyConsumable)
|
if (copyStack.getItem() instanceof ICustomAlchemyConsumable) {
|
||||||
{
|
|
||||||
return ((ICustomAlchemyConsumable) copyStack.getItem()).drainUseOnAlchemyCraft(copyStack);
|
return ((ICustomAlchemyConsumable) copyStack.getItem()).drainUseOnAlchemyCraft(copyStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (copyStack.getItem().hasContainerItem(stack))
|
if (copyStack.getItem().hasContainerItem(stack)) {
|
||||||
{
|
|
||||||
return copyStack.getItem().getContainerItem(copyStack);
|
return copyStack.getItem().getContainerItem(copyStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
copyStack.shrink(1);
|
copyStack.shrink(1);
|
||||||
if (copyStack.isEmpty())
|
if (copyStack.isEmpty()) {
|
||||||
{
|
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package WayofTime.bloodmagic.api.recipe;
|
package WayofTime.bloodmagic.api.recipe;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
@ -13,49 +9,42 @@ import net.minecraft.world.World;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
|
||||||
public class AlchemyTableRecipe
|
import java.util.ArrayList;
|
||||||
{
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AlchemyTableRecipe {
|
||||||
protected ItemStack output = ItemStack.EMPTY;
|
protected ItemStack output = ItemStack.EMPTY;
|
||||||
protected ArrayList<Object> input = new ArrayList<Object>();
|
protected ArrayList<Object> input = new ArrayList<Object>();
|
||||||
protected int lpDrained;
|
protected int lpDrained;
|
||||||
protected int ticksRequired;
|
protected int ticksRequired;
|
||||||
protected int tierRequired;
|
protected int tierRequired;
|
||||||
|
|
||||||
public AlchemyTableRecipe(Block result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe)
|
public AlchemyTableRecipe(Block result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) {
|
||||||
{
|
|
||||||
this(new ItemStack(result), lpDrained, ticksRequired, tierRequired, recipe);
|
this(new ItemStack(result), lpDrained, ticksRequired, tierRequired, recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlchemyTableRecipe(Item result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe)
|
public AlchemyTableRecipe(Item result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) {
|
||||||
{
|
|
||||||
this(new ItemStack(result), lpDrained, ticksRequired, tierRequired, recipe);
|
this(new ItemStack(result), lpDrained, ticksRequired, tierRequired, recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlchemyTableRecipe(ItemStack result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe)
|
public AlchemyTableRecipe(ItemStack result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) {
|
||||||
{
|
|
||||||
output = result.copy();
|
output = result.copy();
|
||||||
this.lpDrained = lpDrained;
|
this.lpDrained = lpDrained;
|
||||||
this.ticksRequired = ticksRequired;
|
this.ticksRequired = ticksRequired;
|
||||||
this.tierRequired = tierRequired;
|
this.tierRequired = tierRequired;
|
||||||
for (Object in : recipe)
|
for (Object in : recipe) {
|
||||||
{
|
if (in instanceof ItemStack) {
|
||||||
if (in instanceof ItemStack)
|
|
||||||
{
|
|
||||||
input.add(((ItemStack) in).copy());
|
input.add(((ItemStack) in).copy());
|
||||||
} else if (in instanceof Item)
|
} else if (in instanceof Item) {
|
||||||
{
|
|
||||||
input.add(new ItemStack((Item) in));
|
input.add(new ItemStack((Item) in));
|
||||||
} else if (in instanceof Block)
|
} else if (in instanceof Block) {
|
||||||
{
|
|
||||||
input.add(new ItemStack((Block) in));
|
input.add(new ItemStack((Block) in));
|
||||||
} else if (in instanceof String)
|
} else if (in instanceof String) {
|
||||||
{
|
|
||||||
input.add(OreDictionary.getOres((String) in));
|
input.add(OreDictionary.getOres((String) in));
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
String ret = "Invalid alchemy recipe: ";
|
String ret = "Invalid alchemy recipe: ";
|
||||||
for (Object tmp : recipe)
|
for (Object tmp : recipe) {
|
||||||
{
|
|
||||||
ret += tmp + ", ";
|
ret += tmp + ", ";
|
||||||
}
|
}
|
||||||
ret += output;
|
ret += output;
|
||||||
|
@ -67,8 +56,7 @@ public class AlchemyTableRecipe
|
||||||
/**
|
/**
|
||||||
* Returns the size of the recipe area
|
* Returns the size of the recipe area
|
||||||
*/
|
*/
|
||||||
public int getRecipeSize()
|
public int getRecipeSize() {
|
||||||
{
|
|
||||||
return input.size();
|
return input.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,12 +64,11 @@ public class AlchemyTableRecipe
|
||||||
* Returns the output of the recipe, sensitive to the input list provided.
|
* Returns the output of the recipe, sensitive to the input list provided.
|
||||||
* If the input list does not technically match, the recipe should return
|
* If the input list does not technically match, the recipe should return
|
||||||
* the default output.
|
* the default output.
|
||||||
*
|
*
|
||||||
* @param inputList
|
* @param inputList
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ItemStack getRecipeOutput(List<ItemStack> inputList)
|
public ItemStack getRecipeOutput(List<ItemStack> inputList) {
|
||||||
{
|
|
||||||
return output.copy();
|
return output.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,42 +77,33 @@ public class AlchemyTableRecipe
|
||||||
* BlockPos are for future-proofing
|
* BlockPos are for future-proofing
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public boolean matches(List<ItemStack> checkedList, World world, BlockPos pos)
|
public boolean matches(List<ItemStack> checkedList, World world, BlockPos pos) {
|
||||||
{
|
|
||||||
ArrayList<Object> required = new ArrayList<Object>(input);
|
ArrayList<Object> required = new ArrayList<Object>(input);
|
||||||
|
|
||||||
for (ItemStack slot : checkedList)
|
for (ItemStack slot : checkedList) {
|
||||||
{
|
if (!slot.isEmpty()) {
|
||||||
if (!slot.isEmpty())
|
|
||||||
{
|
|
||||||
boolean inRecipe = false;
|
boolean inRecipe = false;
|
||||||
|
|
||||||
for (Object aRequired : required)
|
for (Object aRequired : required) {
|
||||||
{
|
|
||||||
boolean match = false;
|
boolean match = false;
|
||||||
|
|
||||||
if (aRequired instanceof ItemStack)
|
if (aRequired instanceof ItemStack) {
|
||||||
{
|
|
||||||
match = OreDictionary.itemMatches((ItemStack) aRequired, slot, false);
|
match = OreDictionary.itemMatches((ItemStack) aRequired, slot, false);
|
||||||
} else if (aRequired instanceof List)
|
} else if (aRequired instanceof List) {
|
||||||
{
|
|
||||||
Iterator<ItemStack> itr = ((List<ItemStack>) aRequired).iterator();
|
Iterator<ItemStack> itr = ((List<ItemStack>) aRequired).iterator();
|
||||||
while (itr.hasNext() && !match)
|
while (itr.hasNext() && !match) {
|
||||||
{
|
|
||||||
match = OreDictionary.itemMatches(itr.next(), slot, false);
|
match = OreDictionary.itemMatches(itr.next(), slot, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match)
|
if (match) {
|
||||||
{
|
|
||||||
inRecipe = true;
|
inRecipe = true;
|
||||||
required.remove(aRequired);
|
required.remove(aRequired);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inRecipe)
|
if (!inRecipe) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,42 +116,35 @@ public class AlchemyTableRecipe
|
||||||
* Returns the input for this recipe, any mod accessing this value should
|
* Returns the input for this recipe, any mod accessing this value should
|
||||||
* never manipulate the values in this array as it will effect the recipe
|
* never manipulate the values in this array as it will effect the recipe
|
||||||
* itself.
|
* itself.
|
||||||
*
|
*
|
||||||
* @return The recipes input vales.
|
* @return The recipes input vales.
|
||||||
*/
|
*/
|
||||||
public List<Object> getInput()
|
public List<Object> getInput() {
|
||||||
{
|
|
||||||
return ImmutableList.copyOf(input);
|
return ImmutableList.copyOf(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack[] getRemainingItems(ItemStack[] inventory)
|
public ItemStack[] getRemainingItems(ItemStack[] inventory) {
|
||||||
{
|
|
||||||
ItemStack[] ret = inventory.clone();
|
ItemStack[] ret = inventory.clone();
|
||||||
for (int i = 0; i < ret.length; i++)
|
for (int i = 0; i < ret.length; i++) {
|
||||||
{
|
|
||||||
ret[i] = getContainerItem(inventory[i]);
|
ret[i] = getContainerItem(inventory[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ItemStack getContainerItem(ItemStack stack)
|
protected ItemStack getContainerItem(ItemStack stack) {
|
||||||
{
|
if (stack.isEmpty()) {
|
||||||
if (stack.isEmpty())
|
|
||||||
{
|
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack copyStack = stack.copy();
|
ItemStack copyStack = stack.copy();
|
||||||
|
|
||||||
if (copyStack.getItem().hasContainerItem(stack))
|
if (copyStack.getItem().hasContainerItem(stack)) {
|
||||||
{
|
|
||||||
return copyStack.getItem().getContainerItem(copyStack);
|
return copyStack.getItem().getContainerItem(copyStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
copyStack.shrink(1);
|
copyStack.shrink(1);
|
||||||
if (copyStack.isEmpty())
|
if (copyStack.isEmpty()) {
|
||||||
{
|
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package WayofTime.bloodmagic.api.recipe;
|
package WayofTime.bloodmagic.api.recipe;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
@ -12,37 +9,31 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
|
||||||
|
|
||||||
public class LivingArmourDowngradeRecipe
|
import java.util.ArrayList;
|
||||||
{
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class LivingArmourDowngradeRecipe {
|
||||||
protected LivingArmourUpgrade upgrade = null;
|
protected LivingArmourUpgrade upgrade = null;
|
||||||
protected ItemStack keyStack = ItemStack.EMPTY;
|
protected ItemStack keyStack = ItemStack.EMPTY;
|
||||||
protected List<Object> input = new ArrayList<Object>();
|
protected List<Object> input = new ArrayList<Object>();
|
||||||
|
|
||||||
public LivingArmourDowngradeRecipe(LivingArmourUpgrade upgrade, ItemStack keyStack, Object... recipe)
|
public LivingArmourDowngradeRecipe(LivingArmourUpgrade upgrade, ItemStack keyStack, Object... recipe) {
|
||||||
{
|
|
||||||
this.upgrade = upgrade;
|
this.upgrade = upgrade;
|
||||||
this.keyStack = keyStack;
|
this.keyStack = keyStack;
|
||||||
for (Object in : recipe)
|
for (Object in : recipe) {
|
||||||
{
|
if (in instanceof ItemStack) {
|
||||||
if (in instanceof ItemStack)
|
|
||||||
{
|
|
||||||
input.add(((ItemStack) in).copy());
|
input.add(((ItemStack) in).copy());
|
||||||
} else if (in instanceof Item)
|
} else if (in instanceof Item) {
|
||||||
{
|
|
||||||
input.add(new ItemStack((Item) in));
|
input.add(new ItemStack((Item) in));
|
||||||
} else if (in instanceof Block)
|
} else if (in instanceof Block) {
|
||||||
{
|
|
||||||
input.add(new ItemStack((Block) in));
|
input.add(new ItemStack((Block) in));
|
||||||
} else if (in instanceof String)
|
} else if (in instanceof String) {
|
||||||
{
|
|
||||||
input.add(OreDictionary.getOres((String) in));
|
input.add(OreDictionary.getOres((String) in));
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
String ret = "Invalid living armour downgrade recipe: ";
|
String ret = "Invalid living armour downgrade recipe: ";
|
||||||
for (Object tmp : recipe)
|
for (Object tmp : recipe) {
|
||||||
{
|
|
||||||
ret += tmp + ", ";
|
ret += tmp + ", ";
|
||||||
}
|
}
|
||||||
ret += upgrade.toString();
|
ret += upgrade.toString();
|
||||||
|
@ -54,13 +45,11 @@ public class LivingArmourDowngradeRecipe
|
||||||
/**
|
/**
|
||||||
* Returns the size of the recipe area
|
* Returns the size of the recipe area
|
||||||
*/
|
*/
|
||||||
public int getRecipeSize()
|
public int getRecipeSize() {
|
||||||
{
|
|
||||||
return input.size();
|
return input.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LivingArmourUpgrade getRecipeOutput()
|
public LivingArmourUpgrade getRecipeOutput() {
|
||||||
{
|
|
||||||
return upgrade;
|
return upgrade;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,49 +58,39 @@ public class LivingArmourDowngradeRecipe
|
||||||
* BlockPos are for future-proofing
|
* BlockPos are for future-proofing
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public boolean matches(ItemStack key, List<ItemStack> checkedList, World world, BlockPos pos)
|
public boolean matches(ItemStack key, List<ItemStack> checkedList, World world, BlockPos pos) {
|
||||||
{
|
if (!OreDictionary.itemMatches(keyStack, key, false)) {
|
||||||
if (!OreDictionary.itemMatches(keyStack, key, false))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Object> required = new ArrayList<Object>(input);
|
ArrayList<Object> required = new ArrayList<Object>(input);
|
||||||
|
|
||||||
for (ItemStack slot : checkedList)
|
for (ItemStack slot : checkedList) {
|
||||||
{
|
if (slot != null) {
|
||||||
if (slot != null)
|
|
||||||
{
|
|
||||||
boolean inRecipe = false;
|
boolean inRecipe = false;
|
||||||
|
|
||||||
for (Object aRequired : required)
|
for (Object aRequired : required) {
|
||||||
{
|
|
||||||
boolean match = false;
|
boolean match = false;
|
||||||
|
|
||||||
Object next = aRequired;
|
Object next = aRequired;
|
||||||
|
|
||||||
if (next instanceof ItemStack)
|
if (next instanceof ItemStack) {
|
||||||
{
|
|
||||||
match = OreDictionary.itemMatches((ItemStack) next, slot, false);
|
match = OreDictionary.itemMatches((ItemStack) next, slot, false);
|
||||||
} else if (next instanceof List)
|
} else if (next instanceof List) {
|
||||||
{
|
|
||||||
Iterator<ItemStack> itr = ((List<ItemStack>) next).iterator();
|
Iterator<ItemStack> itr = ((List<ItemStack>) next).iterator();
|
||||||
while (itr.hasNext() && !match)
|
while (itr.hasNext() && !match) {
|
||||||
{
|
|
||||||
match = OreDictionary.itemMatches(itr.next(), slot, false);
|
match = OreDictionary.itemMatches(itr.next(), slot, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match)
|
if (match) {
|
||||||
{
|
|
||||||
inRecipe = true;
|
inRecipe = true;
|
||||||
required.remove(next);
|
required.remove(next);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inRecipe)
|
if (!inRecipe) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,57 +103,46 @@ public class LivingArmourDowngradeRecipe
|
||||||
* Returns the input for this recipe, any mod accessing this value should
|
* Returns the input for this recipe, any mod accessing this value should
|
||||||
* never manipulate the values in this array as it will effect the recipe
|
* never manipulate the values in this array as it will effect the recipe
|
||||||
* itself.
|
* itself.
|
||||||
*
|
*
|
||||||
* @return The recipes input vales.
|
* @return The recipes input vales.
|
||||||
*/
|
*/
|
||||||
public List<Object> getInput()
|
public List<Object> getInput() {
|
||||||
{
|
|
||||||
return ImmutableList.copyOf(input);
|
return ImmutableList.copyOf(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getKey()
|
public ItemStack getKey() {
|
||||||
{
|
|
||||||
return this.keyStack;
|
return this.keyStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void consumeInventory(IItemHandler inv)
|
public void consumeInventory(IItemHandler inv) {
|
||||||
{
|
for (int i = 0; i < inv.getSlots(); i++) {
|
||||||
for (int i = 0; i < inv.getSlots(); i++)
|
|
||||||
{
|
|
||||||
ItemStack stack = inv.getStackInSlot(i);
|
ItemStack stack = inv.getStackInSlot(i);
|
||||||
if (stack.isEmpty())
|
if (stack.isEmpty()) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.getItem().hasContainerItem(stack))
|
if (stack.getItem().hasContainerItem(stack)) {
|
||||||
{
|
|
||||||
inv.extractItem(i, stack.getCount(), false);
|
inv.extractItem(i, stack.getCount(), false);
|
||||||
inv.insertItem(i, stack.getItem().getContainerItem(stack), false);
|
inv.insertItem(i, stack.getItem().getContainerItem(stack), false);
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
inv.extractItem(i, 1, false);
|
inv.extractItem(i, 1, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ItemStack getContainerItem(ItemStack stack)
|
protected ItemStack getContainerItem(ItemStack stack) {
|
||||||
{
|
if (stack.isEmpty()) {
|
||||||
if (stack.isEmpty())
|
|
||||||
{
|
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack copyStack = stack.copy();
|
ItemStack copyStack = stack.copy();
|
||||||
|
|
||||||
if (copyStack.getItem().hasContainerItem(stack))
|
if (copyStack.getItem().hasContainerItem(stack)) {
|
||||||
{
|
|
||||||
return copyStack.getItem().getContainerItem(copyStack);
|
return copyStack.getItem().getContainerItem(copyStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
copyStack.shrink(1);
|
copyStack.shrink(1);
|
||||||
if (copyStack.isEmpty())
|
if (copyStack.isEmpty()) {
|
||||||
{
|
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,47 +12,36 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TartaricForgeRecipe
|
public class TartaricForgeRecipe {
|
||||||
{
|
|
||||||
protected ItemStack output = null;
|
protected ItemStack output = null;
|
||||||
protected List<Object> input = new ArrayList<Object>();
|
protected List<Object> input = new ArrayList<Object>();
|
||||||
protected double minimumSouls;
|
protected double minimumSouls;
|
||||||
protected double soulsDrained;
|
protected double soulsDrained;
|
||||||
|
|
||||||
public TartaricForgeRecipe(Block result, double minSouls, double drain, Object... recipe)
|
public TartaricForgeRecipe(Block result, double minSouls, double drain, Object... recipe) {
|
||||||
{
|
|
||||||
this(new ItemStack(result), minSouls, drain, recipe);
|
this(new ItemStack(result), minSouls, drain, recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TartaricForgeRecipe(Item result, double minSouls, double drain, Object... recipe)
|
public TartaricForgeRecipe(Item result, double minSouls, double drain, Object... recipe) {
|
||||||
{
|
|
||||||
this(new ItemStack(result), minSouls, drain, recipe);
|
this(new ItemStack(result), minSouls, drain, recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TartaricForgeRecipe(ItemStack result, double minSouls, double drain, Object... recipe)
|
public TartaricForgeRecipe(ItemStack result, double minSouls, double drain, Object... recipe) {
|
||||||
{
|
|
||||||
output = result.copy();
|
output = result.copy();
|
||||||
this.minimumSouls = minSouls;
|
this.minimumSouls = minSouls;
|
||||||
this.soulsDrained = drain;
|
this.soulsDrained = drain;
|
||||||
for (Object in : recipe)
|
for (Object in : recipe) {
|
||||||
{
|
if (in instanceof ItemStack) {
|
||||||
if (in instanceof ItemStack)
|
|
||||||
{
|
|
||||||
input.add(((ItemStack) in).copy());
|
input.add(((ItemStack) in).copy());
|
||||||
} else if (in instanceof Item)
|
} else if (in instanceof Item) {
|
||||||
{
|
|
||||||
input.add(new ItemStack((Item) in));
|
input.add(new ItemStack((Item) in));
|
||||||
} else if (in instanceof Block)
|
} else if (in instanceof Block) {
|
||||||
{
|
|
||||||
input.add(new ItemStack((Block) in));
|
input.add(new ItemStack((Block) in));
|
||||||
} else if (in instanceof String)
|
} else if (in instanceof String) {
|
||||||
{
|
|
||||||
input.add(OreDictionary.getOres((String) in));
|
input.add(OreDictionary.getOres((String) in));
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
String ret = "Invalid soul forge recipe: ";
|
String ret = "Invalid soul forge recipe: ";
|
||||||
for (Object tmp : recipe)
|
for (Object tmp : recipe) {
|
||||||
{
|
|
||||||
ret += tmp + ", ";
|
ret += tmp + ", ";
|
||||||
}
|
}
|
||||||
ret += output;
|
ret += output;
|
||||||
|
@ -64,13 +53,11 @@ public class TartaricForgeRecipe
|
||||||
/**
|
/**
|
||||||
* Returns the size of the recipe area
|
* Returns the size of the recipe area
|
||||||
*/
|
*/
|
||||||
public int getRecipeSize()
|
public int getRecipeSize() {
|
||||||
{
|
|
||||||
return input.size();
|
return input.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getRecipeOutput()
|
public ItemStack getRecipeOutput() {
|
||||||
{
|
|
||||||
return output.copy();
|
return output.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,47 +66,38 @@ public class TartaricForgeRecipe
|
||||||
* BlockPos are for future-proofing
|
* BlockPos are for future-proofing
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public boolean matches(List<ItemStack> checkedList, World world, BlockPos pos)
|
public boolean matches(List<ItemStack> checkedList, World world, BlockPos pos) {
|
||||||
{
|
|
||||||
ArrayList<Object> required = new ArrayList<Object>(input);
|
ArrayList<Object> required = new ArrayList<Object>(input);
|
||||||
|
|
||||||
for (int x = 0; x < checkedList.size(); x++)
|
for (int x = 0; x < checkedList.size(); x++) {
|
||||||
{
|
|
||||||
ItemStack slot = checkedList.get(x);
|
ItemStack slot = checkedList.get(x);
|
||||||
|
|
||||||
if (slot != null)
|
if (slot != null) {
|
||||||
{
|
|
||||||
boolean inRecipe = false;
|
boolean inRecipe = false;
|
||||||
Iterator<Object> req = required.iterator();
|
Iterator<Object> req = required.iterator();
|
||||||
|
|
||||||
while (req.hasNext())
|
while (req.hasNext()) {
|
||||||
{
|
|
||||||
boolean match = false;
|
boolean match = false;
|
||||||
|
|
||||||
Object next = req.next();
|
Object next = req.next();
|
||||||
|
|
||||||
if (next instanceof ItemStack)
|
if (next instanceof ItemStack) {
|
||||||
{
|
|
||||||
match = OreDictionary.itemMatches((ItemStack) next, slot, false);
|
match = OreDictionary.itemMatches((ItemStack) next, slot, false);
|
||||||
} else if (next instanceof List)
|
} else if (next instanceof List) {
|
||||||
{
|
|
||||||
Iterator<ItemStack> itr = ((List<ItemStack>) next).iterator();
|
Iterator<ItemStack> itr = ((List<ItemStack>) next).iterator();
|
||||||
while (itr.hasNext() && !match)
|
while (itr.hasNext() && !match) {
|
||||||
{
|
|
||||||
match = OreDictionary.itemMatches(itr.next(), slot, false);
|
match = OreDictionary.itemMatches(itr.next(), slot, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match)
|
if (match) {
|
||||||
{
|
|
||||||
inRecipe = true;
|
inRecipe = true;
|
||||||
required.remove(next);
|
required.remove(next);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inRecipe)
|
if (!inRecipe) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,11 +110,10 @@ public class TartaricForgeRecipe
|
||||||
* Returns the input for this recipe, any mod accessing this value should
|
* Returns the input for this recipe, any mod accessing this value should
|
||||||
* never manipulate the values in this array as it will effect the recipe
|
* never manipulate the values in this array as it will effect the recipe
|
||||||
* itself.
|
* itself.
|
||||||
*
|
*
|
||||||
* @return The recipes input vales.
|
* @return The recipes input vales.
|
||||||
*/
|
*/
|
||||||
public List<Object> getInput()
|
public List<Object> getInput() {
|
||||||
{
|
|
||||||
return this.input;
|
return this.input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,22 @@
|
||||||
package WayofTime.bloodmagic.api.registry;
|
package WayofTime.bloodmagic.api.registry;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
||||||
|
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
||||||
|
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting;
|
||||||
|
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer;
|
||||||
|
import com.google.common.collect.BiMap;
|
||||||
|
import com.google.common.collect.HashBiMap;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
public class AlchemyArrayRecipeRegistry {
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
|
||||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
|
||||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting;
|
|
||||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer;
|
|
||||||
|
|
||||||
import com.google.common.collect.BiMap;
|
|
||||||
import com.google.common.collect.HashBiMap;
|
|
||||||
|
|
||||||
public class AlchemyArrayRecipeRegistry
|
|
||||||
{
|
|
||||||
public static final AlchemyCircleRenderer defaultRenderer = new AlchemyCircleRenderer(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BaseArray.png"));
|
public static final AlchemyCircleRenderer defaultRenderer = new AlchemyCircleRenderer(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BaseArray.png"));
|
||||||
|
|
||||||
private static BiMap<List<ItemStack>, AlchemyArrayRecipe> recipes = HashBiMap.create();
|
private static BiMap<List<ItemStack>, AlchemyArrayRecipe> recipes = HashBiMap.create();
|
||||||
|
@ -27,42 +24,30 @@ public class AlchemyArrayRecipeRegistry
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General case for creating an AlchemyArrayEffect for a given input.
|
* General case for creating an AlchemyArrayEffect for a given input.
|
||||||
*
|
*
|
||||||
* @param input
|
* @param input - Input item(s) that is used to change the Alchemy Circle into the
|
||||||
* - Input item(s) that is used to change the Alchemy Circle into the
|
* circle that you are making
|
||||||
* circle that you are making
|
* @param catalystStack - Catalyst item that, when right-clicked onto the array, will
|
||||||
* @param catalystStack
|
* cause an effect
|
||||||
* - Catalyst item that, when right-clicked onto the array, will
|
* @param arrayEffect - The effect that will be activated once the array is activated
|
||||||
* cause an effect
|
* @param circleRenderer - Circle rendered when the array is passive - can be substituted
|
||||||
* @param arrayEffect
|
* for a special renderer
|
||||||
* - The effect that will be activated once the array is activated
|
|
||||||
* @param circleRenderer
|
|
||||||
* - Circle rendered when the array is passive - can be substituted
|
|
||||||
* for a special renderer
|
|
||||||
*/
|
*/
|
||||||
public static void registerRecipe(List<ItemStack> input, @Nullable ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer)
|
public static void registerRecipe(List<ItemStack> input, @Nullable ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) {
|
||||||
{
|
|
||||||
effectMap.put(arrayEffect.getKey(), arrayEffect);
|
effectMap.put(arrayEffect.getKey(), arrayEffect);
|
||||||
|
|
||||||
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet())
|
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||||
{
|
|
||||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||||
if (arrayRecipe.doesInputMatchRecipe(input))
|
if (arrayRecipe.doesInputMatchRecipe(input)) {
|
||||||
{
|
|
||||||
AlchemyArrayEffect eff = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
AlchemyArrayEffect eff = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
||||||
if (eff != null)
|
if (eff != null) {
|
||||||
{
|
|
||||||
return; // Recipe already exists!
|
return; // Recipe already exists!
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
arrayRecipe.catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
|
arrayRecipe.catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
|
||||||
if (circleRenderer != null)
|
if (circleRenderer != null) {
|
||||||
{
|
if (arrayRecipe.defaultCircleRenderer == null) {
|
||||||
if (arrayRecipe.defaultCircleRenderer == null)
|
|
||||||
{
|
|
||||||
arrayRecipe.defaultCircleRenderer = circleRenderer;
|
arrayRecipe.defaultCircleRenderer = circleRenderer;
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
arrayRecipe.circleMap.put(ItemStackWrapper.getHolder(catalystStack), circleRenderer);
|
arrayRecipe.circleMap.put(ItemStackWrapper.getHolder(catalystStack), circleRenderer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,63 +59,48 @@ public class AlchemyArrayRecipeRegistry
|
||||||
recipes.put(input, new AlchemyArrayRecipe(input, catalystStack, arrayEffect, circleRenderer == null ? defaultRenderer : circleRenderer));
|
recipes.put(input, new AlchemyArrayRecipe(input, catalystStack, arrayEffect, circleRenderer == null ? defaultRenderer : circleRenderer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AlchemyArrayEffect getAlchemyArrayEffect(String key)
|
public static AlchemyArrayEffect getAlchemyArrayEffect(String key) {
|
||||||
{
|
|
||||||
return effectMap.get(key);
|
return effectMap.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param key
|
* @param key
|
||||||
* @return an array of two ItemStacks - first index is the input stack,
|
* @return an array of two ItemStacks - first index is the input stack,
|
||||||
* second is the catalyst stack. Returns {null, null} if no recipe
|
* second is the catalyst stack. Returns {null, null} if no recipe
|
||||||
* is valid.
|
* is valid.
|
||||||
*/
|
*/
|
||||||
public static ItemStack[] getRecipeForArrayEffect(String key)
|
public static ItemStack[] getRecipeForArrayEffect(String key) {
|
||||||
{
|
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||||
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet())
|
|
||||||
{
|
|
||||||
AlchemyArrayRecipe recipe = entry.getValue();
|
AlchemyArrayRecipe recipe = entry.getValue();
|
||||||
if (recipe != null && entry.getKey().size() > 0)
|
if (recipe != null && entry.getKey().size() > 0) {
|
||||||
{
|
for (Entry<ItemStackWrapper, AlchemyArrayEffect> effectEntry : recipe.catalystMap.entrySet()) {
|
||||||
for (Entry<ItemStackWrapper, AlchemyArrayEffect> effectEntry : recipe.catalystMap.entrySet())
|
if (effectEntry.getValue() != null && effectEntry.getValue().key.equals(key)) {
|
||||||
{
|
return new ItemStack[]{entry.getKey().get(0), effectEntry.getKey().toStack()};
|
||||||
if (effectEntry.getValue() != null && effectEntry.getValue().key.equals(key))
|
|
||||||
{
|
|
||||||
return new ItemStack[] { entry.getKey().get(0), effectEntry.getKey().toStack() };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ItemStack[] { null, null };
|
return new ItemStack[]{null, null};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param stack
|
* @param stack of the recipe
|
||||||
* of the recipe
|
|
||||||
* @return an array of two ItemStacks - first index is the input stack,
|
* @return an array of two ItemStacks - first index is the input stack,
|
||||||
* second is the catalyst stack. Returns {null, null} if no recipe
|
* second is the catalyst stack. Returns {null, null} if no recipe
|
||||||
* is valid.
|
* is valid.
|
||||||
*/
|
*/
|
||||||
public static ItemStack[] getRecipeForOutputStack(ItemStack stack)
|
public static ItemStack[] getRecipeForOutputStack(ItemStack stack) {
|
||||||
{
|
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||||
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet())
|
|
||||||
{
|
|
||||||
AlchemyArrayRecipe recipe = entry.getValue();
|
AlchemyArrayRecipe recipe = entry.getValue();
|
||||||
if (recipe != null && entry.getKey().size() > 0)
|
if (recipe != null && entry.getKey().size() > 0) {
|
||||||
{
|
for (Entry<ItemStackWrapper, AlchemyArrayEffect> effectEntry : recipe.catalystMap.entrySet()) {
|
||||||
for (Entry<ItemStackWrapper, AlchemyArrayEffect> effectEntry : recipe.catalystMap.entrySet())
|
if (effectEntry.getValue() instanceof AlchemyArrayEffectCrafting) {
|
||||||
{
|
|
||||||
if (effectEntry.getValue() instanceof AlchemyArrayEffectCrafting)
|
|
||||||
{
|
|
||||||
AlchemyArrayEffectCrafting craftingEffect = (AlchemyArrayEffectCrafting) effectEntry.getValue();
|
AlchemyArrayEffectCrafting craftingEffect = (AlchemyArrayEffectCrafting) effectEntry.getValue();
|
||||||
ItemStack resultStack = craftingEffect.outputStack;
|
ItemStack resultStack = craftingEffect.outputStack;
|
||||||
if (!resultStack.isEmpty())
|
if (!resultStack.isEmpty()) {
|
||||||
{
|
if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage()) {
|
||||||
if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage())
|
return new ItemStack[]{entry.getKey().get(0), effectEntry.getKey().toStack()};
|
||||||
{
|
|
||||||
return new ItemStack[] { entry.getKey().get(0), effectEntry.getKey().toStack() };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,123 +108,97 @@ public class AlchemyArrayRecipeRegistry
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ItemStack[] { null, null };
|
return new ItemStack[]{null, null};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerCraftingRecipe(ItemStack input, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource)
|
public static void registerCraftingRecipe(ItemStack input, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource) {
|
||||||
{
|
|
||||||
registerRecipe(input, catalystStack, new AlchemyArrayEffectCrafting(outputStack), arrayResource);
|
registerRecipe(input, catalystStack, new AlchemyArrayEffectCrafting(outputStack), arrayResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerCraftingRecipe(List<ItemStack> inputStacks, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource)
|
public static void registerCraftingRecipe(List<ItemStack> inputStacks, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource) {
|
||||||
{
|
|
||||||
registerRecipe(inputStacks, catalystStack, new AlchemyArrayEffectCrafting(outputStack), arrayResource);
|
registerRecipe(inputStacks, catalystStack, new AlchemyArrayEffectCrafting(outputStack), arrayResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerCraftingRecipe(String inputOreDict, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource)
|
public static void registerCraftingRecipe(String inputOreDict, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource) {
|
||||||
{
|
|
||||||
registerRecipe(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.<ItemStack>emptyList(), catalystStack, new AlchemyArrayEffectCrafting(outputStack), arrayResource);
|
registerRecipe(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.<ItemStack>emptyList(), catalystStack, new AlchemyArrayEffectCrafting(outputStack), arrayResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerCraftingRecipe(ItemStack input, ItemStack catalystStack, ItemStack outputStack)
|
public static void registerCraftingRecipe(ItemStack input, ItemStack catalystStack, ItemStack outputStack) {
|
||||||
{
|
|
||||||
registerRecipe(input, catalystStack, new AlchemyArrayEffectCrafting(outputStack));
|
registerRecipe(input, catalystStack, new AlchemyArrayEffectCrafting(outputStack));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerCraftingRecipe(List<ItemStack> inputStacks, ItemStack catalystStack, ItemStack outputStack)
|
public static void registerCraftingRecipe(List<ItemStack> inputStacks, ItemStack catalystStack, ItemStack outputStack) {
|
||||||
{
|
|
||||||
registerRecipe(inputStacks, catalystStack, new AlchemyArrayEffectCrafting(outputStack));
|
registerRecipe(inputStacks, catalystStack, new AlchemyArrayEffectCrafting(outputStack));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerCraftingRecipe(String inputOreDict, ItemStack catalystStack, ItemStack outputStack)
|
public static void registerCraftingRecipe(String inputOreDict, ItemStack catalystStack, ItemStack outputStack) {
|
||||||
{
|
|
||||||
registerRecipe(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.<ItemStack>emptyList(), catalystStack, new AlchemyArrayEffectCrafting(outputStack));
|
registerRecipe(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.<ItemStack>emptyList(), catalystStack, new AlchemyArrayEffectCrafting(outputStack));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerRecipe(ItemStack inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource)
|
public static void registerRecipe(ItemStack inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource) {
|
||||||
{
|
|
||||||
AlchemyCircleRenderer circleRenderer = arrayResource == null ? defaultRenderer : new AlchemyCircleRenderer(arrayResource);
|
AlchemyCircleRenderer circleRenderer = arrayResource == null ? defaultRenderer : new AlchemyCircleRenderer(arrayResource);
|
||||||
registerRecipe(Collections.singletonList(inputStacks), catalystStack, arrayEffect, circleRenderer);
|
registerRecipe(Collections.singletonList(inputStacks), catalystStack, arrayEffect, circleRenderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerRecipe(ItemStack inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer)
|
public static void registerRecipe(ItemStack inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) {
|
||||||
{
|
|
||||||
registerRecipe(Collections.singletonList(inputStacks), catalystStack, arrayEffect, circleRenderer);
|
registerRecipe(Collections.singletonList(inputStacks), catalystStack, arrayEffect, circleRenderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerRecipe(List<ItemStack> inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource)
|
public static void registerRecipe(List<ItemStack> inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource) {
|
||||||
{
|
|
||||||
AlchemyCircleRenderer circleRenderer = arrayResource == null ? defaultRenderer : new AlchemyCircleRenderer(arrayResource);
|
AlchemyCircleRenderer circleRenderer = arrayResource == null ? defaultRenderer : new AlchemyCircleRenderer(arrayResource);
|
||||||
registerRecipe(inputStacks, catalystStack, arrayEffect, circleRenderer);
|
registerRecipe(inputStacks, catalystStack, arrayEffect, circleRenderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerRecipe(String inputOreDict, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource)
|
public static void registerRecipe(String inputOreDict, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource) {
|
||||||
{
|
|
||||||
AlchemyCircleRenderer circleRenderer = arrayResource == null ? defaultRenderer : new AlchemyCircleRenderer(arrayResource);
|
AlchemyCircleRenderer circleRenderer = arrayResource == null ? defaultRenderer : new AlchemyCircleRenderer(arrayResource);
|
||||||
registerRecipe(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.<ItemStack>emptyList(), catalystStack, arrayEffect, circleRenderer);
|
registerRecipe(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.<ItemStack>emptyList(), catalystStack, arrayEffect, circleRenderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerRecipe(ItemStack input, ItemStack catalystStack, AlchemyArrayEffect arrayEffect)
|
public static void registerRecipe(ItemStack input, ItemStack catalystStack, AlchemyArrayEffect arrayEffect) {
|
||||||
{
|
|
||||||
registerRecipe(Collections.singletonList(input), catalystStack, arrayEffect, (AlchemyCircleRenderer) null);
|
registerRecipe(Collections.singletonList(input), catalystStack, arrayEffect, (AlchemyCircleRenderer) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerRecipe(List<ItemStack> inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect)
|
public static void registerRecipe(List<ItemStack> inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect) {
|
||||||
{
|
|
||||||
registerRecipe(inputStacks, catalystStack, arrayEffect, (AlchemyCircleRenderer) null);
|
registerRecipe(inputStacks, catalystStack, arrayEffect, (AlchemyCircleRenderer) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerRecipe(String inputOreDict, ItemStack catalystStack, AlchemyArrayEffect arrayEffect)
|
public static void registerRecipe(String inputOreDict, ItemStack catalystStack, AlchemyArrayEffect arrayEffect) {
|
||||||
{
|
|
||||||
registerRecipe(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.<ItemStack>emptyList(), catalystStack, arrayEffect, (AlchemyCircleRenderer) null);
|
registerRecipe(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.<ItemStack>emptyList(), catalystStack, arrayEffect, (AlchemyCircleRenderer) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void replaceAlchemyCircle(List<ItemStack> input, AlchemyCircleRenderer circleRenderer)
|
public static void replaceAlchemyCircle(List<ItemStack> input, AlchemyCircleRenderer circleRenderer) {
|
||||||
{
|
|
||||||
if (circleRenderer == null)
|
if (circleRenderer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet())
|
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||||
{
|
|
||||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||||
if (arrayRecipe.doesInputMatchRecipe(input))
|
if (arrayRecipe.doesInputMatchRecipe(input))
|
||||||
arrayRecipe.defaultCircleRenderer = circleRenderer;
|
arrayRecipe.defaultCircleRenderer = circleRenderer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AlchemyArrayRecipe getRecipeForInput(List<ItemStack> input)
|
public static AlchemyArrayRecipe getRecipeForInput(List<ItemStack> input) {
|
||||||
{
|
|
||||||
return recipes.get(input);
|
return recipes.get(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AlchemyArrayEffect getAlchemyArrayEffect(List<ItemStack> input, @Nullable ItemStack catalystStack)
|
public static AlchemyArrayEffect getAlchemyArrayEffect(List<ItemStack> input, @Nullable ItemStack catalystStack) {
|
||||||
{
|
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||||
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet())
|
|
||||||
{
|
|
||||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||||
if (input.size() == 1 && arrayRecipe.getInput().size() == 1)
|
if (input.size() == 1 && arrayRecipe.getInput().size() == 1) {
|
||||||
{
|
if (ItemStackWrapper.getHolder(arrayRecipe.getInput().get(0)).equals(ItemStackWrapper.getHolder(input.get(0)))) {
|
||||||
if (ItemStackWrapper.getHolder(arrayRecipe.getInput().get(0)).equals(ItemStackWrapper.getHolder(input.get(0))))
|
|
||||||
{
|
|
||||||
AlchemyArrayEffect effect = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
AlchemyArrayEffect effect = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
||||||
if (effect != null)
|
if (effect != null) {
|
||||||
{
|
|
||||||
return effect.getNewCopy();
|
return effect.getNewCopy();
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
{
|
if (input.equals(arrayRecipe.getInput())) {
|
||||||
if (input.equals(arrayRecipe.getInput()))
|
|
||||||
{
|
|
||||||
AlchemyArrayEffect effect = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
AlchemyArrayEffect effect = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
||||||
if (effect != null)
|
if (effect != null) {
|
||||||
{
|
|
||||||
return effect.getNewCopy();
|
return effect.getNewCopy();
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,18 +208,14 @@ public class AlchemyArrayRecipeRegistry
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AlchemyArrayEffect getAlchemyArrayEffect(ItemStack input, @Nullable ItemStack catalystStack)
|
public static AlchemyArrayEffect getAlchemyArrayEffect(ItemStack input, @Nullable ItemStack catalystStack) {
|
||||||
{
|
|
||||||
return getAlchemyArrayEffect(Collections.singletonList(input), catalystStack);
|
return getAlchemyArrayEffect(Collections.singletonList(input), catalystStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AlchemyCircleRenderer getAlchemyCircleRenderer(List<ItemStack> input, @Nullable ItemStack catalystStack)
|
public static AlchemyCircleRenderer getAlchemyCircleRenderer(List<ItemStack> input, @Nullable ItemStack catalystStack) {
|
||||||
{
|
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||||
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet())
|
|
||||||
{
|
|
||||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||||
if (arrayRecipe.doesInputMatchRecipe(input))
|
if (arrayRecipe.doesInputMatchRecipe(input)) {
|
||||||
{
|
|
||||||
return arrayRecipe.getAlchemyArrayRendererForCatalyst(catalystStack);
|
return arrayRecipe.getAlchemyArrayRendererForCatalyst(catalystStack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,20 +223,21 @@ public class AlchemyArrayRecipeRegistry
|
||||||
return defaultRenderer;
|
return defaultRenderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AlchemyCircleRenderer getAlchemyCircleRenderer(ItemStack itemStack, @Nullable ItemStack catalystStack)
|
public static AlchemyCircleRenderer getAlchemyCircleRenderer(ItemStack itemStack, @Nullable ItemStack catalystStack) {
|
||||||
{
|
|
||||||
return getAlchemyCircleRenderer(Collections.singletonList(itemStack), catalystStack);
|
return getAlchemyCircleRenderer(Collections.singletonList(itemStack), catalystStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AlchemyArrayRecipe
|
public static BiMap<List<ItemStack>, AlchemyArrayRecipe> getRecipes() {
|
||||||
{
|
return HashBiMap.create(recipes);
|
||||||
public AlchemyCircleRenderer defaultCircleRenderer;
|
}
|
||||||
|
|
||||||
|
public static class AlchemyArrayRecipe {
|
||||||
public final List<ItemStack> input;
|
public final List<ItemStack> input;
|
||||||
public final BiMap<ItemStackWrapper, AlchemyArrayEffect> catalystMap = HashBiMap.create();
|
public final BiMap<ItemStackWrapper, AlchemyArrayEffect> catalystMap = HashBiMap.create();
|
||||||
public final BiMap<ItemStackWrapper, AlchemyCircleRenderer> circleMap = HashBiMap.create();
|
public final BiMap<ItemStackWrapper, AlchemyCircleRenderer> circleMap = HashBiMap.create();
|
||||||
|
public AlchemyCircleRenderer defaultCircleRenderer;
|
||||||
|
|
||||||
private AlchemyArrayRecipe(List<ItemStack> input, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer, boolean useless)
|
private AlchemyArrayRecipe(List<ItemStack> input, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer, boolean useless) {
|
||||||
{
|
|
||||||
this.input = input;
|
this.input = input;
|
||||||
|
|
||||||
catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
|
catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
|
||||||
|
@ -304,47 +245,37 @@ public class AlchemyArrayRecipeRegistry
|
||||||
this.defaultCircleRenderer = circleRenderer;
|
this.defaultCircleRenderer = circleRenderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlchemyArrayRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer)
|
public AlchemyArrayRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) {
|
||||||
{
|
|
||||||
this(Collections.singletonList(inputStack), catalystStack, arrayEffect, circleRenderer, false);
|
this(Collections.singletonList(inputStack), catalystStack, arrayEffect, circleRenderer, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlchemyArrayRecipe(String inputOreDict, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer)
|
public AlchemyArrayRecipe(String inputOreDict, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) {
|
||||||
{
|
|
||||||
this(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.<ItemStack>emptyList(), catalystStack, arrayEffect, circleRenderer, false);
|
this(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.<ItemStack>emptyList(), catalystStack, arrayEffect, circleRenderer, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlchemyArrayRecipe(List<ItemStack> inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer)
|
public AlchemyArrayRecipe(List<ItemStack> inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) {
|
||||||
{
|
|
||||||
this(inputStacks, catalystStack, arrayEffect, circleRenderer, false);
|
this(inputStacks, catalystStack, arrayEffect, circleRenderer, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares the inputed list of ItemStacks to see if it matches with the
|
* Compares the inputed list of ItemStacks to see if it matches with the
|
||||||
* recipe's list.
|
* recipe's list.
|
||||||
*
|
*
|
||||||
* @param comparedList
|
* @param comparedList - The list to compare with
|
||||||
* - The list to compare with
|
|
||||||
*
|
|
||||||
* @return - True if the ItemStack(s) is a compatible item
|
* @return - True if the ItemStack(s) is a compatible item
|
||||||
*/
|
*/
|
||||||
public boolean doesInputMatchRecipe(List<ItemStack> comparedList)
|
public boolean doesInputMatchRecipe(List<ItemStack> comparedList) {
|
||||||
{
|
|
||||||
return !(comparedList == null || this.input == null) && (this.input.size() == 1 && comparedList.size() == 1 ? this.input.get(0).isItemEqual(comparedList.get(0)) : this.input.equals(comparedList));
|
return !(comparedList == null || this.input == null) && (this.input.size() == 1 && comparedList.size() == 1 ? this.input.get(0).isItemEqual(comparedList.get(0)) : this.input.equals(comparedList));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the actual AlchemyArrayEffect for the given catalyst.
|
* Gets the actual AlchemyArrayEffect for the given catalyst.
|
||||||
*
|
*
|
||||||
* @param comparedStack
|
* @param comparedStack The catalyst that is being checked
|
||||||
* The catalyst that is being checked
|
|
||||||
*
|
|
||||||
* @return - The effect
|
* @return - The effect
|
||||||
*/
|
*/
|
||||||
public AlchemyArrayEffect getAlchemyArrayEffectForCatalyst(@Nullable ItemStack comparedStack)
|
public AlchemyArrayEffect getAlchemyArrayEffectForCatalyst(@Nullable ItemStack comparedStack) {
|
||||||
{
|
for (Entry<ItemStackWrapper, AlchemyArrayEffect> entry : catalystMap.entrySet()) {
|
||||||
for (Entry<ItemStackWrapper, AlchemyArrayEffect> entry : catalystMap.entrySet())
|
|
||||||
{
|
|
||||||
ItemStack catalystStack = entry.getKey().toStack();
|
ItemStack catalystStack = entry.getKey().toStack();
|
||||||
|
|
||||||
if (comparedStack == null && catalystStack == null)
|
if (comparedStack == null && catalystStack == null)
|
||||||
|
@ -360,10 +291,8 @@ public class AlchemyArrayRecipeRegistry
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlchemyCircleRenderer getAlchemyArrayRendererForCatalyst(@Nullable ItemStack comparedStack)
|
public AlchemyCircleRenderer getAlchemyArrayRendererForCatalyst(@Nullable ItemStack comparedStack) {
|
||||||
{
|
for (Entry<ItemStackWrapper, AlchemyCircleRenderer> entry : circleMap.entrySet()) {
|
||||||
for (Entry<ItemStackWrapper, AlchemyCircleRenderer> entry : circleMap.entrySet())
|
|
||||||
{
|
|
||||||
ItemStack catalystStack = entry.getKey().toStack();
|
ItemStack catalystStack = entry.getKey().toStack();
|
||||||
|
|
||||||
if (comparedStack == null && catalystStack == null)
|
if (comparedStack == null && catalystStack == null)
|
||||||
|
@ -418,9 +347,4 @@ public class AlchemyArrayRecipeRegistry
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BiMap<List<ItemStack>, AlchemyArrayRecipe> getRecipes()
|
|
||||||
{
|
|
||||||
return HashBiMap.create(recipes);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +1,31 @@
|
||||||
package WayofTime.bloodmagic.api.registry;
|
package WayofTime.bloodmagic.api.registry;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
public class AlchemyTableRecipeRegistry {
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe;
|
|
||||||
|
|
||||||
public class AlchemyTableRecipeRegistry
|
|
||||||
{
|
|
||||||
private static List<AlchemyTableRecipe> recipeList = new ArrayList<AlchemyTableRecipe>();
|
private static List<AlchemyTableRecipe> recipeList = new ArrayList<AlchemyTableRecipe>();
|
||||||
|
|
||||||
public static void registerRecipe(AlchemyTableRecipe recipe)
|
public static void registerRecipe(AlchemyTableRecipe recipe) {
|
||||||
{
|
|
||||||
recipeList.add(recipe);
|
recipeList.add(recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerRecipe(ItemStack outputStack, int lpDrained, int ticksRequired, int tierRequired, Object... objects)
|
public static void registerRecipe(ItemStack outputStack, int lpDrained, int ticksRequired, int tierRequired, Object... objects) {
|
||||||
{
|
|
||||||
registerRecipe(new AlchemyTableRecipe(outputStack, lpDrained, ticksRequired, tierRequired, objects));
|
registerRecipe(new AlchemyTableRecipe(outputStack, lpDrained, ticksRequired, tierRequired, objects));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeRecipe(AlchemyTableRecipe recipe)
|
public static void removeRecipe(AlchemyTableRecipe recipe) {
|
||||||
{
|
|
||||||
recipeList.remove(recipe);
|
recipeList.remove(recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AlchemyTableRecipe getMatchingRecipe(List<ItemStack> itemList, World world, BlockPos pos)
|
public static AlchemyTableRecipe getMatchingRecipe(List<ItemStack> itemList, World world, BlockPos pos) {
|
||||||
{
|
for (AlchemyTableRecipe recipe : recipeList) {
|
||||||
for (AlchemyTableRecipe recipe : recipeList)
|
if (recipe.matches(itemList, world, pos)) {
|
||||||
{
|
|
||||||
if (recipe.matches(itemList, world, pos))
|
|
||||||
{
|
|
||||||
return recipe;
|
return recipe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,8 +33,7 @@ public class AlchemyTableRecipeRegistry
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<AlchemyTableRecipe> getRecipeList()
|
public static List<AlchemyTableRecipe> getRecipeList() {
|
||||||
{
|
|
||||||
return new ArrayList<AlchemyTableRecipe>(recipeList);
|
return new ArrayList<AlchemyTableRecipe>(recipeList);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,48 +12,41 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class AltarRecipeRegistry
|
public class AltarRecipeRegistry {
|
||||||
{
|
|
||||||
private static BiMap<List<ItemStackWrapper>, AltarRecipe> recipes = HashBiMap.create();
|
private static BiMap<List<ItemStackWrapper>, AltarRecipe> recipes = HashBiMap.create();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an {@link AltarRecipe} for the Blood Altar. This can be a
|
* Registers an {@link AltarRecipe} for the Blood Altar. This can be a
|
||||||
* {@code ItemStack}, {@code List<Itemstack>}, or {@code String}
|
* {@code ItemStack}, {@code List<Itemstack>}, or {@code String}
|
||||||
* OreDictionary entry.
|
* OreDictionary entry.
|
||||||
*
|
* <p>
|
||||||
* If the OreDictionary entry does not exist or is empty, it will not be
|
* If the OreDictionary entry does not exist or is empty, it will not be
|
||||||
* registered.
|
* registered.
|
||||||
*
|
*
|
||||||
* @param altarRecipe
|
* @param altarRecipe - The AltarRecipe to register
|
||||||
* - The AltarRecipe to register
|
|
||||||
*/
|
*/
|
||||||
public static void registerRecipe(AltarRecipe altarRecipe)
|
public static void registerRecipe(AltarRecipe altarRecipe) {
|
||||||
{
|
|
||||||
if (!recipes.containsValue(altarRecipe) && altarRecipe.getInput().size() > 0)
|
if (!recipes.containsValue(altarRecipe) && altarRecipe.getInput().size() > 0)
|
||||||
recipes.put(altarRecipe.getInput(), altarRecipe);
|
recipes.put(altarRecipe.getInput(), altarRecipe);
|
||||||
else
|
else
|
||||||
BloodMagicAPI.logger.error("Error adding altar recipe for input [{}].", altarRecipe.toString());
|
BloodMagicAPI.logger.error("Error adding altar recipe for input [{}].", altarRecipe.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerFillRecipe(ItemStack orbStack, EnumAltarTier tier, int maxForOrb, int consumeRate, int drainRate)
|
public static void registerFillRecipe(ItemStack orbStack, EnumAltarTier tier, int maxForOrb, int consumeRate, int drainRate) {
|
||||||
{
|
|
||||||
registerRecipe(new AltarRecipe(orbStack, orbStack, tier, maxForOrb, consumeRate, drainRate, true));
|
registerRecipe(new AltarRecipe(orbStack, orbStack, tier, maxForOrb, consumeRate, drainRate, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeRecipe(AltarRecipe altarRecipe)
|
public static void removeRecipe(AltarRecipe altarRecipe) {
|
||||||
{
|
|
||||||
recipes.remove(altarRecipe.getInput());
|
recipes.remove(altarRecipe.getInput());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the recipe that the provided input is registered to.
|
* Gets the recipe that the provided input is registered to.
|
||||||
*
|
*
|
||||||
* @param input
|
* @param input - The input ItemStack to get the recipe for
|
||||||
* - The input ItemStack to get the recipe for
|
|
||||||
* @return - The recipe that the provided input is registered to.
|
* @return - The recipe that the provided input is registered to.
|
||||||
*/
|
*/
|
||||||
public static AltarRecipe getRecipeForInput(List<ItemStack> input)
|
public static AltarRecipe getRecipeForInput(List<ItemStack> input) {
|
||||||
{
|
|
||||||
List<ItemStackWrapper> wrapperList = ItemStackWrapper.toWrapperList(input);
|
List<ItemStackWrapper> wrapperList = ItemStackWrapper.toWrapperList(input);
|
||||||
if (recipes.keySet().contains(wrapperList))
|
if (recipes.keySet().contains(wrapperList))
|
||||||
return recipes.get(wrapperList);
|
return recipes.get(wrapperList);
|
||||||
|
@ -62,12 +55,9 @@ public class AltarRecipeRegistry
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Determine a more time-effective method
|
//TODO: Determine a more time-effective method
|
||||||
public static AltarRecipe getRecipeForInput(ItemStack input)
|
public static AltarRecipe getRecipeForInput(ItemStack input) {
|
||||||
{
|
for (AltarRecipe recipe : recipes.values()) {
|
||||||
for (AltarRecipe recipe : recipes.values())
|
if (recipe.doesRequiredItemMatch(input, recipe.getMinTier())) {
|
||||||
{
|
|
||||||
if (recipe.doesRequiredItemMatch(input, recipe.getMinTier()))
|
|
||||||
{
|
|
||||||
return recipe;
|
return recipe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,18 +65,15 @@ public class AltarRecipeRegistry
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AltarRecipe getRecipeForInput(String input)
|
public static AltarRecipe getRecipeForInput(String input) {
|
||||||
{
|
|
||||||
return getRecipeForInput(OreDictionary.getOres(input));
|
return getRecipeForInput(OreDictionary.getOres(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BiMap<List<ItemStackWrapper>, AltarRecipe> getRecipes()
|
public static BiMap<List<ItemStackWrapper>, AltarRecipe> getRecipes() {
|
||||||
{
|
|
||||||
return HashBiMap.create(recipes);
|
return HashBiMap.create(recipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AltarRecipe
|
public static class AltarRecipe {
|
||||||
{
|
|
||||||
private final List<ItemStackWrapper> input;
|
private final List<ItemStackWrapper> input;
|
||||||
private final ItemStack output;
|
private final ItemStack output;
|
||||||
private final EnumAltarTier minTier;
|
private final EnumAltarTier minTier;
|
||||||
|
@ -99,24 +86,16 @@ public class AltarRecipeRegistry
|
||||||
* {@link WayofTime.bloodmagic.tile.TileAltar}. The output ItemStack is
|
* {@link WayofTime.bloodmagic.tile.TileAltar}. The output ItemStack is
|
||||||
* allowed to be null as some recipes do not contain an output. (Blood
|
* allowed to be null as some recipes do not contain an output. (Blood
|
||||||
* Orbs)
|
* Orbs)
|
||||||
*
|
*
|
||||||
* @param input
|
* @param input - The input ItemStack
|
||||||
* - The input ItemStack
|
* @param output - The ItemStack obtained from the recipe
|
||||||
* @param output
|
* @param minTier - The minimum tier of Altar required
|
||||||
* - The ItemStack obtained from the recipe
|
* @param syphon - The amount of LP to syphon from the Altar
|
||||||
* @param minTier
|
* @param consumeRate - The rate at which LP is consumed during crafting
|
||||||
* - The minimum tier of Altar required
|
* @param drainRate - The rate at which LP is drained during crafting
|
||||||
* @param syphon
|
* @param fillable - Whether the input item can be filled with LP. IE: Orbs
|
||||||
* - The amount of LP to syphon from the Altar
|
|
||||||
* @param consumeRate
|
|
||||||
* - The rate at which LP is consumed during crafting
|
|
||||||
* @param drainRate
|
|
||||||
* - The rate at which LP is drained during crafting
|
|
||||||
* @param fillable
|
|
||||||
* - Whether the input item can be filled with LP. IE: Orbs
|
|
||||||
*/
|
*/
|
||||||
public AltarRecipe(List<ItemStack> input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean fillable)
|
public AltarRecipe(List<ItemStack> input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean fillable) {
|
||||||
{
|
|
||||||
this.input = ItemStackWrapper.toWrapperList(input);
|
this.input = ItemStackWrapper.toWrapperList(input);
|
||||||
this.output = output;
|
this.output = output;
|
||||||
this.minTier = minTier;
|
this.minTier = minTier;
|
||||||
|
@ -126,33 +105,27 @@ public class AltarRecipeRegistry
|
||||||
this.fillable = fillable;
|
this.fillable = fillable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AltarRecipe(List<ItemStack> input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate)
|
public AltarRecipe(List<ItemStack> input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate) {
|
||||||
{
|
|
||||||
this(input, output, minTier, syphon, consumeRate, drainRate, false);
|
this(input, output, minTier, syphon, consumeRate, drainRate, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AltarRecipe(ItemStack input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean fillable)
|
public AltarRecipe(ItemStack input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean fillable) {
|
||||||
{
|
|
||||||
this(Collections.singletonList(input), output, minTier, syphon, consumeRate, drainRate, fillable);
|
this(Collections.singletonList(input), output, minTier, syphon, consumeRate, drainRate, fillable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AltarRecipe(ItemStack input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate)
|
public AltarRecipe(ItemStack input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate) {
|
||||||
{
|
|
||||||
this(Collections.singletonList(input), output, minTier, syphon, consumeRate, drainRate, false);
|
this(Collections.singletonList(input), output, minTier, syphon, consumeRate, drainRate, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AltarRecipe(String inputEntry, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean fillable)
|
public AltarRecipe(String inputEntry, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean fillable) {
|
||||||
{
|
|
||||||
this(OreDictionary.doesOreNameExist(inputEntry) && OreDictionary.getOres(inputEntry).size() > 0 ? OreDictionary.getOres(inputEntry) : Collections.<ItemStack>emptyList(), output, minTier, syphon, consumeRate, drainRate, fillable);
|
this(OreDictionary.doesOreNameExist(inputEntry) && OreDictionary.getOres(inputEntry).size() > 0 ? OreDictionary.getOres(inputEntry) : Collections.<ItemStack>emptyList(), output, minTier, syphon, consumeRate, drainRate, fillable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AltarRecipe(String inputEntry, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate)
|
public AltarRecipe(String inputEntry, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate) {
|
||||||
{
|
|
||||||
this(OreDictionary.doesOreNameExist(inputEntry) && OreDictionary.getOres(inputEntry).size() > 0 ? OreDictionary.getOres(inputEntry) : Collections.<ItemStack>emptyList(), output, minTier, syphon, consumeRate, drainRate, false);
|
this(OreDictionary.doesOreNameExist(inputEntry) && OreDictionary.getOres(inputEntry).size() > 0 ? OreDictionary.getOres(inputEntry) : Collections.<ItemStack>emptyList(), output, minTier, syphon, consumeRate, drainRate, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean doesRequiredItemMatch(ItemStack comparedStack, EnumAltarTier tierCheck)
|
public boolean doesRequiredItemMatch(ItemStack comparedStack, EnumAltarTier tierCheck) {
|
||||||
{
|
|
||||||
if (comparedStack == null || this.input == null)
|
if (comparedStack == null || this.input == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,7 @@ import net.minecraft.block.BlockStem;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class HarvestRegistry
|
public class HarvestRegistry {
|
||||||
{
|
|
||||||
private static List<IHarvestHandler> handlerList = new ArrayList<IHarvestHandler>();
|
private static List<IHarvestHandler> handlerList = new ArrayList<IHarvestHandler>();
|
||||||
private static Map<Block, Integer> standardCrops = new HashMap<Block, Integer>();
|
private static Map<Block, Integer> standardCrops = new HashMap<Block, Integer>();
|
||||||
private static Set<BlockStack> tallCrops = new HashSet<BlockStack>();
|
private static Set<BlockStack> tallCrops = new HashSet<BlockStack>();
|
||||||
|
@ -17,12 +16,10 @@ public class HarvestRegistry
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a handler for the Harvest Ritual to call.
|
* Registers a handler for the Harvest Ritual to call.
|
||||||
*
|
*
|
||||||
* @param handler
|
* @param handler - The custom handler to register
|
||||||
* - The custom handler to register
|
|
||||||
*/
|
*/
|
||||||
public static void registerHandler(IHarvestHandler handler)
|
public static void registerHandler(IHarvestHandler handler) {
|
||||||
{
|
|
||||||
if (!handlerList.contains(handler))
|
if (!handlerList.contains(handler))
|
||||||
handlerList.add(handler);
|
handlerList.add(handler);
|
||||||
}
|
}
|
||||||
|
@ -32,15 +29,12 @@ public class HarvestRegistry
|
||||||
* for the
|
* for the
|
||||||
* {@link WayofTime.bloodmagic.ritual.harvest.HarvestHandlerPlantable}
|
* {@link WayofTime.bloodmagic.ritual.harvest.HarvestHandlerPlantable}
|
||||||
* handler to handle.
|
* handler to handle.
|
||||||
*
|
*
|
||||||
* @param crop
|
* @param crop - The crop block to handle.
|
||||||
* - The crop block to handle.
|
* @param matureMeta - The meta value at which the crop is considered mature and ready
|
||||||
* @param matureMeta
|
* to be harvested.
|
||||||
* - The meta value at which the crop is considered mature and ready
|
|
||||||
* to be harvested.
|
|
||||||
*/
|
*/
|
||||||
public static void registerStandardCrop(Block crop, int matureMeta)
|
public static void registerStandardCrop(Block crop, int matureMeta) {
|
||||||
{
|
|
||||||
if (!standardCrops.containsKey(crop))
|
if (!standardCrops.containsKey(crop))
|
||||||
standardCrops.put(crop, matureMeta);
|
standardCrops.put(crop, matureMeta);
|
||||||
}
|
}
|
||||||
|
@ -49,12 +43,10 @@ public class HarvestRegistry
|
||||||
* Registers a tall crop (Sugar Cane and Cactus) for the
|
* Registers a tall crop (Sugar Cane and Cactus) for the
|
||||||
* {@link WayofTime.bloodmagic.ritual.harvest.HarvestHandlerTall} handler to
|
* {@link WayofTime.bloodmagic.ritual.harvest.HarvestHandlerTall} handler to
|
||||||
* handle.
|
* handle.
|
||||||
*
|
*
|
||||||
* @param crop
|
* @param crop - The crop block to handle.
|
||||||
* - The crop block to handle.
|
|
||||||
*/
|
*/
|
||||||
public static void registerTallCrop(BlockStack crop)
|
public static void registerTallCrop(BlockStack crop) {
|
||||||
{
|
|
||||||
if (!tallCrops.contains(crop))
|
if (!tallCrops.contains(crop))
|
||||||
tallCrops.add(crop);
|
tallCrops.add(crop);
|
||||||
}
|
}
|
||||||
|
@ -63,59 +55,48 @@ public class HarvestRegistry
|
||||||
* Registers a stem crop (Melon and Pumpkin) for the
|
* Registers a stem crop (Melon and Pumpkin) for the
|
||||||
* {@link WayofTime.bloodmagic.ritual.harvest.HarvestHandlerStem} handler to
|
* {@link WayofTime.bloodmagic.ritual.harvest.HarvestHandlerStem} handler to
|
||||||
* handle.
|
* handle.
|
||||||
*
|
* <p>
|
||||||
* Use {@link net.minecraftforge.oredict.OreDictionary#WILDCARD_VALUE} to
|
* Use {@link net.minecraftforge.oredict.OreDictionary#WILDCARD_VALUE} to
|
||||||
* accept any meta for the crop block.
|
* accept any meta for the crop block.
|
||||||
*
|
* <p>
|
||||||
* The Stem must be instanceof {@link BlockStem}
|
* The Stem must be instanceof {@link BlockStem}
|
||||||
*
|
*
|
||||||
* @param crop
|
* @param crop - The crop block to handle.
|
||||||
* - The crop block to handle.
|
* @param stem - The stem of the crop
|
||||||
* @param stem
|
|
||||||
* - The stem of the crop
|
|
||||||
*/
|
*/
|
||||||
public static void registerStemCrop(BlockStack crop, BlockStack stem)
|
public static void registerStemCrop(BlockStack crop, BlockStack stem) {
|
||||||
{
|
|
||||||
if (!stemCrops.containsKey(crop) && stem.getBlock() instanceof BlockStem)
|
if (!stemCrops.containsKey(crop) && stem.getBlock() instanceof BlockStem)
|
||||||
stemCrops.put(stem, crop);
|
stemCrops.put(stem, crop);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a range amplifier for the Harvest Ritual.
|
* Registers a range amplifier for the Harvest Ritual.
|
||||||
*
|
*
|
||||||
* @param blockStack
|
* @param blockStack - The block for the amplifier.
|
||||||
* - The block for the amplifier.
|
* @param range - The range the amplifier provides.
|
||||||
* @param range
|
|
||||||
* - The range the amplifier provides.
|
|
||||||
*/
|
*/
|
||||||
public static void registerRangeAmplifier(BlockStack blockStack, int range)
|
public static void registerRangeAmplifier(BlockStack blockStack, int range) {
|
||||||
{
|
|
||||||
if (!amplifierMap.containsKey(blockStack))
|
if (!amplifierMap.containsKey(blockStack))
|
||||||
amplifierMap.put(blockStack, range);
|
amplifierMap.put(blockStack, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<IHarvestHandler> getHandlerList()
|
public static List<IHarvestHandler> getHandlerList() {
|
||||||
{
|
|
||||||
return new ArrayList<IHarvestHandler>(handlerList);
|
return new ArrayList<IHarvestHandler>(handlerList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<Block, Integer> getStandardCrops()
|
public static Map<Block, Integer> getStandardCrops() {
|
||||||
{
|
|
||||||
return new HashMap<Block, Integer>(standardCrops);
|
return new HashMap<Block, Integer>(standardCrops);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<BlockStack> getTallCrops()
|
public static Set<BlockStack> getTallCrops() {
|
||||||
{
|
|
||||||
return new HashSet<BlockStack>(tallCrops);
|
return new HashSet<BlockStack>(tallCrops);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<BlockStack, BlockStack> getStemCrops()
|
public static Map<BlockStack, BlockStack> getStemCrops() {
|
||||||
{
|
|
||||||
return new HashMap<BlockStack, BlockStack>(stemCrops);
|
return new HashMap<BlockStack, BlockStack>(stemCrops);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<BlockStack, Integer> getAmplifierMap()
|
public static Map<BlockStack, Integer> getAmplifierMap() {
|
||||||
{
|
|
||||||
return new HashMap<BlockStack, Integer>(amplifierMap);
|
return new HashMap<BlockStack, Integer>(amplifierMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,50 +10,40 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class ImperfectRitualRegistry
|
public class ImperfectRitualRegistry {
|
||||||
{
|
|
||||||
public static final Map<ImperfectRitual, Boolean> enabledRituals = new HashMap<ImperfectRitual, Boolean>();
|
public static final Map<ImperfectRitual, Boolean> enabledRituals = new HashMap<ImperfectRitual, Boolean>();
|
||||||
private static final BiMap<String, ImperfectRitual> registry = HashBiMap.create();
|
private static final BiMap<String, ImperfectRitual> registry = HashBiMap.create();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The safe way to register a new Ritual.
|
* The safe way to register a new Ritual.
|
||||||
*
|
*
|
||||||
* @param imperfectRitual
|
* @param imperfectRitual - The imperfect ritual to register.
|
||||||
* - The imperfect ritual to register.
|
* @param id - The ID for the imperfect ritual. Cannot be duplicated.
|
||||||
* @param id
|
|
||||||
* - The ID for the imperfect ritual. Cannot be duplicated.
|
|
||||||
*/
|
*/
|
||||||
public static void registerRitual(ImperfectRitual imperfectRitual, String id, boolean enabled)
|
public static void registerRitual(ImperfectRitual imperfectRitual, String id, boolean enabled) {
|
||||||
{
|
if (imperfectRitual != null) {
|
||||||
if (imperfectRitual != null)
|
|
||||||
{
|
|
||||||
if (registry.containsKey(id))
|
if (registry.containsKey(id))
|
||||||
BloodMagicAPI.logger.error("Duplicate imperfect ritual id: %s", id);
|
BloodMagicAPI.logger.error("Duplicate imperfect ritual id: %s", id);
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
registry.put(id, imperfectRitual);
|
registry.put(id, imperfectRitual);
|
||||||
enabledRituals.put(imperfectRitual, enabled);
|
enabledRituals.put(imperfectRitual, enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerRitual(ImperfectRitual imperfectRitual, String id)
|
public static void registerRitual(ImperfectRitual imperfectRitual, String id) {
|
||||||
{
|
|
||||||
registerRitual(imperfectRitual, id, true);
|
registerRitual(imperfectRitual, id, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerRitual(ImperfectRitual imperfectRitual, boolean enabled)
|
public static void registerRitual(ImperfectRitual imperfectRitual, boolean enabled) {
|
||||||
{
|
|
||||||
registerRitual(imperfectRitual, imperfectRitual.getName(), enabled);
|
registerRitual(imperfectRitual, imperfectRitual.getName(), enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerRitual(ImperfectRitual imperfectRitual)
|
public static void registerRitual(ImperfectRitual imperfectRitual) {
|
||||||
{
|
|
||||||
registerRitual(imperfectRitual, imperfectRitual.getName());
|
registerRitual(imperfectRitual, imperfectRitual.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImperfectRitual getRitualForBlock(BlockStack blockStack)
|
public static ImperfectRitual getRitualForBlock(BlockStack blockStack) {
|
||||||
{
|
|
||||||
for (ImperfectRitual imperfectRitual : getRegistry().values())
|
for (ImperfectRitual imperfectRitual : getRegistry().values())
|
||||||
if (imperfectRitual.getRequiredBlock().equals(blockStack))
|
if (imperfectRitual.getRequiredBlock().equals(blockStack))
|
||||||
return imperfectRitual;
|
return imperfectRitual;
|
||||||
|
@ -61,60 +51,48 @@ public class ImperfectRitualRegistry
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImperfectRitual getRitualForId(String id)
|
public static ImperfectRitual getRitualForId(String id) {
|
||||||
{
|
|
||||||
return registry.get(id);
|
return registry.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getIdForRitual(ImperfectRitual imperfectRitual)
|
public static String getIdForRitual(ImperfectRitual imperfectRitual) {
|
||||||
{
|
|
||||||
return registry.inverse().get(imperfectRitual);
|
return registry.inverse().get(imperfectRitual);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isMapEmpty()
|
public static boolean isMapEmpty() {
|
||||||
{
|
|
||||||
return registry.isEmpty();
|
return registry.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getMapSize()
|
public static int getMapSize() {
|
||||||
{
|
|
||||||
return registry.size();
|
return registry.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean ritualEnabled(ImperfectRitual imperfectRitual)
|
public static boolean ritualEnabled(ImperfectRitual imperfectRitual) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
return enabledRituals.get(imperfectRitual);
|
return enabledRituals.get(imperfectRitual);
|
||||||
} catch (NullPointerException e)
|
} catch (NullPointerException e) {
|
||||||
{
|
|
||||||
BloodMagicAPI.logger.error("Invalid Imperfect Ritual was called");
|
BloodMagicAPI.logger.error("Invalid Imperfect Ritual was called");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean ritualEnabled(String id)
|
public static boolean ritualEnabled(String id) {
|
||||||
{
|
|
||||||
return ritualEnabled(getRitualForId(id));
|
return ritualEnabled(getRitualForId(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BiMap<String, ImperfectRitual> getRegistry()
|
public static BiMap<String, ImperfectRitual> getRegistry() {
|
||||||
{
|
|
||||||
return HashBiMap.create(registry);
|
return HashBiMap.create(registry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BiMap<ImperfectRitual, Boolean> getEnabledMap()
|
public static BiMap<ImperfectRitual, Boolean> getEnabledMap() {
|
||||||
{
|
|
||||||
return HashBiMap.create(enabledRituals);
|
return HashBiMap.create(enabledRituals);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<String> getIds()
|
public static ArrayList<String> getIds() {
|
||||||
{
|
|
||||||
return new ArrayList<String>(registry.keySet());
|
return new ArrayList<String>(registry.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<ImperfectRitual> getRituals()
|
public static ArrayList<ImperfectRitual> getRituals() {
|
||||||
{
|
|
||||||
return new ArrayList<ImperfectRitual>(registry.values());
|
return new ArrayList<ImperfectRitual>(registry.values());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,44 +1,37 @@
|
||||||
package WayofTime.bloodmagic.api.registry;
|
package WayofTime.bloodmagic.api.registry;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||||
|
import WayofTime.bloodmagic.api.recipe.LivingArmourDowngradeRecipe;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
public class LivingArmourDowngradeRecipeRegistry {
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
|
||||||
import WayofTime.bloodmagic.api.recipe.LivingArmourDowngradeRecipe;
|
|
||||||
|
|
||||||
public class LivingArmourDowngradeRecipeRegistry
|
|
||||||
{
|
|
||||||
private static List<LivingArmourDowngradeRecipe> recipeList = new ArrayList<LivingArmourDowngradeRecipe>();
|
private static List<LivingArmourDowngradeRecipe> recipeList = new ArrayList<LivingArmourDowngradeRecipe>();
|
||||||
private static Map<ItemStack, Map<Integer, List<ITextComponent>>> dialogueMap = new HashMap<ItemStack, Map<Integer, List<ITextComponent>>>();
|
private static Map<ItemStack, Map<Integer, List<ITextComponent>>> dialogueMap = new HashMap<ItemStack, Map<Integer, List<ITextComponent>>>();
|
||||||
|
|
||||||
public static void registerRecipe(LivingArmourDowngradeRecipe recipe)
|
public static void registerRecipe(LivingArmourDowngradeRecipe recipe) {
|
||||||
{
|
|
||||||
recipeList.add(recipe);
|
recipeList.add(recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerDialog(ItemStack keyStack, Map<Integer, List<ITextComponent>> map)
|
public static void registerDialog(ItemStack keyStack, Map<Integer, List<ITextComponent>> map) {
|
||||||
{
|
|
||||||
dialogueMap.put(keyStack, map);
|
dialogueMap.put(keyStack, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ITextComponent> getDialogForProcessTick(ItemStack keyStack, int tick)
|
public static List<ITextComponent> getDialogForProcessTick(ItemStack keyStack, int tick) {
|
||||||
{
|
for (Entry<ItemStack, Map<Integer, List<ITextComponent>>> entry : dialogueMap.entrySet()) {
|
||||||
for (Entry<ItemStack, Map<Integer, List<ITextComponent>>> entry : dialogueMap.entrySet())
|
|
||||||
{
|
|
||||||
ItemStack key = entry.getKey();
|
ItemStack key = entry.getKey();
|
||||||
if (OreDictionary.itemMatches(key, keyStack, false))
|
if (OreDictionary.itemMatches(key, keyStack, false)) {
|
||||||
{
|
|
||||||
Map<Integer, List<ITextComponent>> map = entry.getValue();
|
Map<Integer, List<ITextComponent>> map = entry.getValue();
|
||||||
if (map.containsKey(tick))
|
if (map.containsKey(tick)) {
|
||||||
{
|
|
||||||
return map.get(tick);
|
return map.get(tick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,17 +40,13 @@ public class LivingArmourDowngradeRecipeRegistry
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerRecipe(LivingArmourUpgrade upgrade, ItemStack keyStack, Object... recipe)
|
public static void registerRecipe(LivingArmourUpgrade upgrade, ItemStack keyStack, Object... recipe) {
|
||||||
{
|
|
||||||
registerRecipe(new LivingArmourDowngradeRecipe(upgrade, keyStack, recipe));
|
registerRecipe(new LivingArmourDowngradeRecipe(upgrade, keyStack, recipe));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LivingArmourDowngradeRecipe getMatchingRecipe(ItemStack keyStack, List<ItemStack> itemList, World world, BlockPos pos)
|
public static LivingArmourDowngradeRecipe getMatchingRecipe(ItemStack keyStack, List<ItemStack> itemList, World world, BlockPos pos) {
|
||||||
{
|
for (LivingArmourDowngradeRecipe recipe : recipeList) {
|
||||||
for (LivingArmourDowngradeRecipe recipe : recipeList)
|
if (recipe.matches(keyStack, itemList, world, pos)) {
|
||||||
{
|
|
||||||
if (recipe.matches(keyStack, itemList, world, pos))
|
|
||||||
{
|
|
||||||
return recipe;
|
return recipe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,8 +54,7 @@ public class LivingArmourDowngradeRecipeRegistry
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<LivingArmourDowngradeRecipe> getRecipeList()
|
public static List<LivingArmourDowngradeRecipe> getRecipeList() {
|
||||||
{
|
|
||||||
return new ArrayList<LivingArmourDowngradeRecipe>(recipeList);
|
return new ArrayList<LivingArmourDowngradeRecipe>(recipeList);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,24 +17,20 @@ import java.util.List;
|
||||||
* custom handling, you will need your own item class.
|
* custom handling, you will need your own item class.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class OrbRegistry
|
public class OrbRegistry {
|
||||||
{
|
|
||||||
private static List<BloodOrb> orbs = new ArrayList<BloodOrb>();
|
|
||||||
public static ArrayListMultimap<Integer, ItemStack> tierMap = ArrayListMultimap.create();
|
|
||||||
|
|
||||||
@GameRegistry.ObjectHolder("bloodmagic:blood_orb")
|
@GameRegistry.ObjectHolder("bloodmagic:blood_orb")
|
||||||
private static final Item ORB_ITEM = null;
|
private static final Item ORB_ITEM = null;
|
||||||
|
public static ArrayListMultimap<Integer, ItemStack> tierMap = ArrayListMultimap.create();
|
||||||
|
private static List<BloodOrb> orbs = new ArrayList<BloodOrb>();
|
||||||
|
|
||||||
public static List<ItemStack> getOrbsForTier(int tier)
|
public static List<ItemStack> getOrbsForTier(int tier) {
|
||||||
{
|
|
||||||
if (getTierMap().containsKey(tier))
|
if (getTierMap().containsKey(tier))
|
||||||
return getTierMap().get(tier);
|
return getTierMap().get(tier);
|
||||||
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ItemStack> getOrbsUpToTier(int tier)
|
public static List<ItemStack> getOrbsUpToTier(int tier) {
|
||||||
{
|
|
||||||
List<ItemStack> ret = new ArrayList<ItemStack>();
|
List<ItemStack> ret = new ArrayList<ItemStack>();
|
||||||
|
|
||||||
for (int i = 1; i <= tier; i++)
|
for (int i = 1; i <= tier; i++)
|
||||||
|
@ -43,8 +39,7 @@ public class OrbRegistry
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ItemStack> getOrbsDownToTier(int tier)
|
public static List<ItemStack> getOrbsDownToTier(int tier) {
|
||||||
{
|
|
||||||
List<ItemStack> ret = new ArrayList<ItemStack>();
|
List<ItemStack> ret = new ArrayList<ItemStack>();
|
||||||
|
|
||||||
for (int i = EnumAltarTier.MAXTIERS; i >= tier; i--)
|
for (int i = EnumAltarTier.MAXTIERS; i >= tier; i--)
|
||||||
|
@ -53,8 +48,7 @@ public class OrbRegistry
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack getOrbStack(BloodOrb orb)
|
public static ItemStack getOrbStack(BloodOrb orb) {
|
||||||
{
|
|
||||||
ItemStack ret = new ItemStack(ORB_ITEM);
|
ItemStack ret = new ItemStack(ORB_ITEM);
|
||||||
NBTTagCompound tag = new NBTTagCompound();
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
tag.setString("orb", orb.getRegistryName().toString());
|
tag.setString("orb", orb.getRegistryName().toString());
|
||||||
|
@ -62,8 +56,7 @@ public class OrbRegistry
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayListMultimap<Integer, ItemStack> getTierMap()
|
public static ArrayListMultimap<Integer, ItemStack> getTierMap() {
|
||||||
{
|
|
||||||
return ArrayListMultimap.create(tierMap);
|
return ArrayListMultimap.create(tierMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,7 @@ import com.google.common.collect.HashBiMap;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class RitualRegistry
|
public class RitualRegistry {
|
||||||
{
|
|
||||||
public static final Map<Ritual, Boolean> enabledRituals = new HashMap<Ritual, Boolean>();
|
public static final Map<Ritual, Boolean> enabledRituals = new HashMap<Ritual, Boolean>();
|
||||||
private static final BiMap<String, Ritual> registry = HashBiMap.create();
|
private static final BiMap<String, Ritual> registry = HashBiMap.create();
|
||||||
private static final List<String> lookupList = new ArrayList<String>();
|
private static final List<String> lookupList = new ArrayList<String>();
|
||||||
|
@ -23,27 +22,21 @@ public class RitualRegistry
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The safe way to register a new Ritual.
|
* The safe way to register a new Ritual.
|
||||||
*
|
*
|
||||||
* @param ritual
|
* @param ritual - The ritual to register.
|
||||||
* - The ritual to register.
|
* @param id - The ID for the ritual. Cannot be duplicated.
|
||||||
* @param id
|
|
||||||
* - The ID for the ritual. Cannot be duplicated.
|
|
||||||
*/
|
*/
|
||||||
public static void registerRitual(Ritual ritual, String id, boolean enabled)
|
public static void registerRitual(Ritual ritual, String id, boolean enabled) {
|
||||||
{
|
if (locked) {
|
||||||
if (locked)
|
|
||||||
{
|
|
||||||
BloodMagicAPI.logger.error("This registry has been locked. Please register your ritual earlier.");
|
BloodMagicAPI.logger.error("This registry has been locked. Please register your ritual earlier.");
|
||||||
BloodMagicAPI.logger.error("If you reflect this, I will hunt you down. - TehNut");
|
BloodMagicAPI.logger.error("If you reflect this, I will hunt you down. - TehNut");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ritual != null)
|
if (ritual != null) {
|
||||||
{
|
|
||||||
if (registry.containsKey(id))
|
if (registry.containsKey(id))
|
||||||
BloodMagicAPI.logger.error("Duplicate ritual id: %s", id);
|
BloodMagicAPI.logger.error("Duplicate ritual id: %s", id);
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
registry.put(id, ritual);
|
registry.put(id, ritual);
|
||||||
enabledRituals.put(ritual, enabled);
|
enabledRituals.put(ritual, enabled);
|
||||||
orderedIdList.add(id);
|
orderedIdList.add(id);
|
||||||
|
@ -51,95 +44,76 @@ public class RitualRegistry
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerRitual(Ritual ritual, boolean enabled)
|
public static void registerRitual(Ritual ritual, boolean enabled) {
|
||||||
{
|
|
||||||
registerRitual(ritual, ritual.getName(), enabled);
|
registerRitual(ritual, ritual.getName(), enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerRitual(Ritual ritual, String id)
|
public static void registerRitual(Ritual ritual, String id) {
|
||||||
{
|
|
||||||
registerRitual(ritual, id, true);
|
registerRitual(ritual, id, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerRitual(Ritual ritual)
|
public static void registerRitual(Ritual ritual) {
|
||||||
{
|
|
||||||
registerRitual(ritual, ritual.getName());
|
registerRitual(ritual, ritual.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Ritual getRitualForId(String id)
|
public static Ritual getRitualForId(String id) {
|
||||||
{
|
|
||||||
Ritual ritual = registry.get(id);
|
Ritual ritual = registry.get(id);
|
||||||
return ritual != null ? ritual.getNewCopy() : null;
|
return ritual != null ? ritual.getNewCopy() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getIdForRitual(Ritual ritual)
|
public static String getIdForRitual(Ritual ritual) {
|
||||||
{
|
|
||||||
return registry.inverse().get(ritual);
|
return registry.inverse().get(ritual);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isMapEmpty()
|
public static boolean isMapEmpty() {
|
||||||
{
|
|
||||||
return registry.isEmpty();
|
return registry.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getMapSize()
|
public static int getMapSize() {
|
||||||
{
|
|
||||||
return registry.size();
|
return registry.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean ritualEnabled(Ritual ritual)
|
public static boolean ritualEnabled(Ritual ritual) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
return enabledRituals.get(ritual);
|
return enabledRituals.get(ritual);
|
||||||
} catch (NullPointerException e)
|
} catch (NullPointerException e) {
|
||||||
{
|
|
||||||
BloodMagicAPI.logger.error("Invalid Ritual was called");
|
BloodMagicAPI.logger.error("Invalid Ritual was called");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean ritualEnabled(String id)
|
public static boolean ritualEnabled(String id) {
|
||||||
{
|
|
||||||
return ritualEnabled(getRitualForId(id));
|
return ritualEnabled(getRitualForId(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BiMap<String, Ritual> getRegistry()
|
public static BiMap<String, Ritual> getRegistry() {
|
||||||
{
|
|
||||||
return HashBiMap.create(registry);
|
return HashBiMap.create(registry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<Ritual, Boolean> getEnabledMap()
|
public static Map<Ritual, Boolean> getEnabledMap() {
|
||||||
{
|
|
||||||
return new HashMap<Ritual, Boolean>(enabledRituals);
|
return new HashMap<Ritual, Boolean>(enabledRituals);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<String> getIds()
|
public static ArrayList<String> getIds() {
|
||||||
{
|
|
||||||
return new ArrayList<String>(lookupList);
|
return new ArrayList<String>(lookupList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<String> getOrderedIds()
|
public static ArrayList<String> getOrderedIds() {
|
||||||
{
|
|
||||||
return orderedIdList;
|
return orderedIdList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<Ritual> getRituals()
|
public static ArrayList<Ritual> getRituals() {
|
||||||
{
|
|
||||||
return new ArrayList<Ritual>(registry.values());
|
return new ArrayList<Ritual>(registry.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void orderLookupList()
|
public static void orderLookupList() {
|
||||||
{
|
|
||||||
locked = true; // Lock registry so no no rituals can be registered
|
locked = true; // Lock registry so no no rituals can be registered
|
||||||
lookupList.clear(); // Make sure it's empty
|
lookupList.clear(); // Make sure it's empty
|
||||||
lookupList.addAll(registry.keySet());
|
lookupList.addAll(registry.keySet());
|
||||||
Collections.sort(lookupList, new Comparator<String>()
|
Collections.sort(lookupList, new Comparator<String>() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(String o1, String o2)
|
public int compare(String o1, String o2) {
|
||||||
{
|
|
||||||
Ritual ritual1 = registry.get(o1);
|
Ritual ritual1 = registry.get(o1);
|
||||||
Ritual ritual2 = registry.get(o2);
|
Ritual ritual2 = registry.get(o2);
|
||||||
return ritual1.getComponents().size() > ritual2.getComponents().size() ? -1 : 0; // Put earlier if bigger
|
return ritual1.getComponents().size() > ritual2.getComponents().size() ? -1 : 0; // Put earlier if bigger
|
||||||
|
|
|
@ -8,31 +8,24 @@ import net.minecraft.world.World;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TartaricForgeRecipeRegistry
|
public class TartaricForgeRecipeRegistry {
|
||||||
{
|
|
||||||
private static List<TartaricForgeRecipe> recipeList = new ArrayList<TartaricForgeRecipe>();
|
private static List<TartaricForgeRecipe> recipeList = new ArrayList<TartaricForgeRecipe>();
|
||||||
|
|
||||||
public static void registerRecipe(TartaricForgeRecipe recipe)
|
public static void registerRecipe(TartaricForgeRecipe recipe) {
|
||||||
{
|
|
||||||
recipeList.add(recipe);
|
recipeList.add(recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerRecipe(ItemStack outputStack, double minimulSouls, double drain, Object... objects)
|
public static void registerRecipe(ItemStack outputStack, double minimulSouls, double drain, Object... objects) {
|
||||||
{
|
|
||||||
registerRecipe(new TartaricForgeRecipe(outputStack, minimulSouls, drain, objects));
|
registerRecipe(new TartaricForgeRecipe(outputStack, minimulSouls, drain, objects));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeRecipe(TartaricForgeRecipe recipe)
|
public static void removeRecipe(TartaricForgeRecipe recipe) {
|
||||||
{
|
|
||||||
recipeList.remove(recipe);
|
recipeList.remove(recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TartaricForgeRecipe getMatchingRecipe(List<ItemStack> itemList, World world, BlockPos pos)
|
public static TartaricForgeRecipe getMatchingRecipe(List<ItemStack> itemList, World world, BlockPos pos) {
|
||||||
{
|
for (TartaricForgeRecipe recipe : recipeList) {
|
||||||
for (TartaricForgeRecipe recipe : recipeList)
|
if (recipe.matches(itemList, world, pos)) {
|
||||||
{
|
|
||||||
if (recipe.matches(itemList, world, pos))
|
|
||||||
{
|
|
||||||
return recipe;
|
return recipe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,8 +33,7 @@ public class TartaricForgeRecipeRegistry
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<TartaricForgeRecipe> getRecipeList()
|
public static List<TartaricForgeRecipe> getRecipeList() {
|
||||||
{
|
|
||||||
return new ArrayList<TartaricForgeRecipe>(recipeList);
|
return new ArrayList<TartaricForgeRecipe>(recipeList);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,26 +1,23 @@
|
||||||
package WayofTime.bloodmagic.api.ritual;
|
package WayofTime.bloodmagic.api.ritual;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.gen.structure.template.PlacementSettings;
|
||||||
|
import net.minecraft.world.gen.structure.template.Template;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
public abstract class AreaDescriptor implements Iterator<BlockPos> {
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
public List<BlockPos> getContainedPositions(BlockPos pos) {
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.gen.structure.template.PlacementSettings;
|
|
||||||
import net.minecraft.world.gen.structure.template.Template;
|
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
|
||||||
|
|
||||||
public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|
||||||
{
|
|
||||||
public List<BlockPos> getContainedPositions(BlockPos pos)
|
|
||||||
{
|
|
||||||
return new ArrayList<BlockPos>();
|
return new ArrayList<BlockPos>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AxisAlignedBB getAABB(BlockPos pos)
|
public AxisAlignedBB getAABB(BlockPos pos) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,13 +27,11 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||||
|
|
||||||
public abstract void resetIterator();
|
public abstract void resetIterator();
|
||||||
|
|
||||||
public void readFromNBT(NBTTagCompound tag)
|
public void readFromNBT(NBTTagCompound tag) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeToNBT(NBTTagCompound tag)
|
public void writeToNBT(NBTTagCompound tag) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +47,7 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||||
* This method changes the area descriptor so that its range matches the two
|
* This method changes the area descriptor so that its range matches the two
|
||||||
* blocks that are selected. When implementing this method, assume that
|
* blocks that are selected. When implementing this method, assume that
|
||||||
* these positions are the blocks that are clicked by the player.
|
* these positions are the blocks that are clicked by the player.
|
||||||
*
|
*
|
||||||
* @param pos1
|
* @param pos1
|
||||||
* @param pos2
|
* @param pos2
|
||||||
*/
|
*/
|
||||||
|
@ -64,8 +59,7 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||||
|
|
||||||
public abstract AreaDescriptor rotateDescriptor(PlacementSettings settings);
|
public abstract AreaDescriptor rotateDescriptor(PlacementSettings settings);
|
||||||
|
|
||||||
public static class Rectangle extends AreaDescriptor
|
public static class Rectangle extends AreaDescriptor {
|
||||||
{
|
|
||||||
protected BlockPos minimumOffset;
|
protected BlockPos minimumOffset;
|
||||||
protected BlockPos maximumOffset; // Non-inclusive maximum offset.
|
protected BlockPos maximumOffset; // Non-inclusive maximum offset.
|
||||||
private BlockPos currentPosition;
|
private BlockPos currentPosition;
|
||||||
|
@ -79,40 +73,30 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||||
* This constructor takes in the minimum and maximum BlockPos. The
|
* This constructor takes in the minimum and maximum BlockPos. The
|
||||||
* maximum offset is non-inclusive, meaning if you pass in (0,0,0) and
|
* maximum offset is non-inclusive, meaning if you pass in (0,0,0) and
|
||||||
* (1,1,1), calling getContainedPositions() will only give (0,0,0).
|
* (1,1,1), calling getContainedPositions() will only give (0,0,0).
|
||||||
*
|
*
|
||||||
* @param minimumOffset
|
* @param minimumOffset -
|
||||||
* -
|
* @param maximumOffset -
|
||||||
* @param maximumOffset
|
|
||||||
* -
|
|
||||||
*/
|
*/
|
||||||
public Rectangle(BlockPos minimumOffset, BlockPos maximumOffset)
|
public Rectangle(BlockPos minimumOffset, BlockPos maximumOffset) {
|
||||||
{
|
|
||||||
setOffsets(minimumOffset, maximumOffset);
|
setOffsets(minimumOffset, maximumOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rectangle(BlockPos minimumOffset, int sizeX, int sizeY, int sizeZ)
|
public Rectangle(BlockPos minimumOffset, int sizeX, int sizeY, int sizeZ) {
|
||||||
{
|
|
||||||
this(minimumOffset, minimumOffset.add(sizeX, sizeY, sizeZ));
|
this(minimumOffset, minimumOffset.add(sizeX, sizeY, sizeZ));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rectangle(BlockPos minimumOffset, int size)
|
public Rectangle(BlockPos minimumOffset, int size) {
|
||||||
{
|
|
||||||
this(minimumOffset, size, size, size);
|
this(minimumOffset, size, size, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BlockPos> getContainedPositions(BlockPos pos)
|
public List<BlockPos> getContainedPositions(BlockPos pos) {
|
||||||
{
|
if (!cache || !pos.equals(cachedPosition) || blockPosCache.isEmpty()) {
|
||||||
if (!cache || !pos.equals(cachedPosition) || blockPosCache.isEmpty())
|
|
||||||
{
|
|
||||||
ArrayList<BlockPos> posList = new ArrayList<BlockPos>();
|
ArrayList<BlockPos> posList = new ArrayList<BlockPos>();
|
||||||
|
|
||||||
for (int j = minimumOffset.getY(); j < maximumOffset.getY(); j++)
|
for (int j = minimumOffset.getY(); j < maximumOffset.getY(); j++) {
|
||||||
{
|
for (int i = minimumOffset.getX(); i < maximumOffset.getX(); i++) {
|
||||||
for (int i = minimumOffset.getX(); i < maximumOffset.getX(); i++)
|
for (int k = minimumOffset.getZ(); k < maximumOffset.getZ(); k++) {
|
||||||
{
|
|
||||||
for (int k = minimumOffset.getZ(); k < maximumOffset.getZ(); k++)
|
|
||||||
{
|
|
||||||
posList.add(pos.add(i, j, k));
|
posList.add(pos.add(i, j, k));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,8 +110,7 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getAABB(BlockPos pos)
|
public AxisAlignedBB getAABB(BlockPos pos) {
|
||||||
{
|
|
||||||
AxisAlignedBB tempAABB = new AxisAlignedBB(minimumOffset, maximumOffset);
|
AxisAlignedBB tempAABB = new AxisAlignedBB(minimumOffset, maximumOffset);
|
||||||
return tempAABB.offset(pos.getX(), pos.getY(), pos.getZ());
|
return tempAABB.offset(pos.getX(), pos.getY(), pos.getZ());
|
||||||
}
|
}
|
||||||
|
@ -135,28 +118,23 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||||
/**
|
/**
|
||||||
* Sets the offsets of the AreaDescriptor in a safe way that will make
|
* Sets the offsets of the AreaDescriptor in a safe way that will make
|
||||||
* minimumOffset the lowest corner
|
* minimumOffset the lowest corner
|
||||||
*
|
*
|
||||||
* @param offset1
|
* @param offset1 -
|
||||||
* -
|
* @param offset2 -
|
||||||
* @param offset2
|
|
||||||
* -
|
|
||||||
*/
|
*/
|
||||||
public void setOffsets(BlockPos offset1, BlockPos offset2)
|
public void setOffsets(BlockPos offset1, BlockPos offset2) {
|
||||||
{
|
|
||||||
this.minimumOffset = new BlockPos(Math.min(offset1.getX(), offset2.getX()), Math.min(offset1.getY(), offset2.getY()), Math.min(offset1.getZ(), offset2.getZ()));
|
this.minimumOffset = new BlockPos(Math.min(offset1.getX(), offset2.getX()), Math.min(offset1.getY(), offset2.getY()), Math.min(offset1.getZ(), offset2.getZ()));
|
||||||
this.maximumOffset = new BlockPos(Math.max(offset1.getX(), offset2.getX()), Math.max(offset1.getY(), offset2.getY()), Math.max(offset1.getZ(), offset2.getZ()));
|
this.maximumOffset = new BlockPos(Math.max(offset1.getX(), offset2.getX()), Math.max(offset1.getY(), offset2.getY()), Math.max(offset1.getZ(), offset2.getZ()));
|
||||||
blockPosCache = new ArrayList<BlockPos>();
|
blockPosCache = new ArrayList<BlockPos>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resetCache()
|
public void resetCache() {
|
||||||
{
|
|
||||||
this.blockPosCache = new ArrayList<BlockPos>();
|
this.blockPosCache = new ArrayList<BlockPos>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWithinArea(BlockPos pos)
|
public boolean isWithinArea(BlockPos pos) {
|
||||||
{
|
|
||||||
int x = pos.getX();
|
int x = pos.getX();
|
||||||
int y = pos.getY();
|
int y = pos.getY();
|
||||||
int z = pos.getZ();
|
int z = pos.getZ();
|
||||||
|
@ -165,22 +143,18 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext()
|
public boolean hasNext() {
|
||||||
{
|
|
||||||
return currentPosition == null || !(currentPosition.getX() + 1 == maximumOffset.getX() && currentPosition.getY() + 1 == maximumOffset.getY() && currentPosition.getZ() + 1 == maximumOffset.getZ());
|
return currentPosition == null || !(currentPosition.getX() + 1 == maximumOffset.getX() && currentPosition.getY() + 1 == maximumOffset.getY() && currentPosition.getZ() + 1 == maximumOffset.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockPos next()
|
public BlockPos next() {
|
||||||
{
|
if (currentPosition != null) {
|
||||||
if (currentPosition != null)
|
|
||||||
{
|
|
||||||
int nextX = currentPosition.getX() + 1 >= maximumOffset.getX() ? minimumOffset.getX() : currentPosition.getX() + 1;
|
int nextX = currentPosition.getX() + 1 >= maximumOffset.getX() ? minimumOffset.getX() : currentPosition.getX() + 1;
|
||||||
int nextZ = nextX != minimumOffset.getX() ? currentPosition.getZ() : (currentPosition.getZ() + 1 >= maximumOffset.getZ() ? minimumOffset.getZ() : currentPosition.getZ() + 1);
|
int nextZ = nextX != minimumOffset.getX() ? currentPosition.getZ() : (currentPosition.getZ() + 1 >= maximumOffset.getZ() ? minimumOffset.getZ() : currentPosition.getZ() + 1);
|
||||||
int nextY = (nextZ != minimumOffset.getZ() || nextX != minimumOffset.getX()) ? currentPosition.getY() : (currentPosition.getY() + 1);
|
int nextY = (nextZ != minimumOffset.getZ() || nextX != minimumOffset.getX()) ? currentPosition.getY() : (currentPosition.getY() + 1);
|
||||||
currentPosition = new BlockPos(nextX, nextY, nextZ);
|
currentPosition = new BlockPos(nextX, nextY, nextZ);
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
currentPosition = minimumOffset;
|
currentPosition = minimumOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,20 +162,17 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove()
|
public void remove() {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resetIterator()
|
public void resetIterator() {
|
||||||
{
|
|
||||||
currentPosition = null;
|
currentPosition = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2)
|
public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2) {
|
||||||
{
|
|
||||||
setOffsets(pos1, pos2);
|
setOffsets(pos1, pos2);
|
||||||
maximumOffset = maximumOffset.add(1, 1, 1);
|
maximumOffset = maximumOffset.add(1, 1, 1);
|
||||||
resetIterator();
|
resetIterator();
|
||||||
|
@ -209,15 +180,13 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound tag)
|
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"));
|
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"));
|
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
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound tag)
|
public void writeToNBT(NBTTagCompound tag) {
|
||||||
{
|
|
||||||
tag.setInteger(Constants.NBT.X_COORD + "min", minimumOffset.getX());
|
tag.setInteger(Constants.NBT.X_COORD + "min", minimumOffset.getX());
|
||||||
tag.setInteger(Constants.NBT.Y_COORD + "min", minimumOffset.getY());
|
tag.setInteger(Constants.NBT.Y_COORD + "min", minimumOffset.getY());
|
||||||
tag.setInteger(Constants.NBT.Z_COORD + "min", minimumOffset.getZ());
|
tag.setInteger(Constants.NBT.Z_COORD + "min", minimumOffset.getZ());
|
||||||
|
@ -227,8 +196,7 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVolumeForOffsets(BlockPos offset1, BlockPos offset2)
|
public int getVolumeForOffsets(BlockPos offset1, BlockPos offset2) {
|
||||||
{
|
|
||||||
BlockPos minPos = new BlockPos(Math.min(offset1.getX(), offset2.getX()), Math.min(offset1.getY(), offset2.getY()), Math.min(offset1.getZ(), offset2.getZ()));
|
BlockPos minPos = new BlockPos(Math.min(offset1.getX(), offset2.getX()), Math.min(offset1.getY(), offset2.getY()), Math.min(offset1.getZ(), offset2.getZ()));
|
||||||
BlockPos maxPos = new BlockPos(Math.max(offset1.getX(), offset2.getX()), Math.max(offset1.getY(), offset2.getY()), Math.max(offset1.getZ(), offset2.getZ()));
|
BlockPos maxPos = new BlockPos(Math.max(offset1.getX(), offset2.getX()), Math.max(offset1.getY(), offset2.getY()), Math.max(offset1.getZ(), offset2.getZ()));
|
||||||
|
|
||||||
|
@ -238,8 +206,7 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit)
|
public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit) {
|
||||||
{
|
|
||||||
BlockPos minPos = new BlockPos(Math.min(offset1.getX(), offset2.getX()), Math.min(offset1.getY(), offset2.getY()), Math.min(offset1.getZ(), offset2.getZ()));
|
BlockPos minPos = new BlockPos(Math.min(offset1.getX(), offset2.getX()), Math.min(offset1.getY(), offset2.getY()), Math.min(offset1.getZ(), offset2.getZ()));
|
||||||
BlockPos maxPos = new BlockPos(Math.max(offset1.getX(), offset2.getX()), Math.max(offset1.getY(), offset2.getY()), Math.max(offset1.getZ(), offset2.getZ()));
|
BlockPos maxPos = new BlockPos(Math.max(offset1.getX(), offset2.getX()), Math.max(offset1.getY(), offset2.getY()), Math.max(offset1.getZ(), offset2.getZ()));
|
||||||
|
|
||||||
|
@ -247,22 +214,18 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVolume()
|
public int getVolume() {
|
||||||
{
|
|
||||||
return (maximumOffset.getX() - minimumOffset.getX()) * (maximumOffset.getY() - minimumOffset.getY()) * (maximumOffset.getZ() - minimumOffset.getZ());
|
return (maximumOffset.getX() - minimumOffset.getX()) * (maximumOffset.getY() - minimumOffset.getY()) * (maximumOffset.getZ() - minimumOffset.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWithinRange(int verticalLimit, int horizontalLimit)
|
public boolean isWithinRange(int verticalLimit, int horizontalLimit) {
|
||||||
{
|
|
||||||
return minimumOffset.getY() >= -verticalLimit && maximumOffset.getY() <= verticalLimit + 1 && minimumOffset.getX() >= -horizontalLimit && maximumOffset.getX() <= horizontalLimit + 1 && minimumOffset.getZ() >= -horizontalLimit && maximumOffset.getZ() <= horizontalLimit + 1;
|
return minimumOffset.getY() >= -verticalLimit && maximumOffset.getY() <= verticalLimit + 1 && minimumOffset.getX() >= -horizontalLimit && maximumOffset.getX() <= horizontalLimit + 1 && minimumOffset.getZ() >= -horizontalLimit && maximumOffset.getZ() <= horizontalLimit + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean intersects(AreaDescriptor descriptor)
|
public boolean intersects(AreaDescriptor descriptor) {
|
||||||
{
|
if (descriptor instanceof AreaDescriptor.Rectangle) {
|
||||||
if (descriptor instanceof AreaDescriptor.Rectangle)
|
|
||||||
{
|
|
||||||
AreaDescriptor.Rectangle rectangle = (AreaDescriptor.Rectangle) descriptor;
|
AreaDescriptor.Rectangle rectangle = (AreaDescriptor.Rectangle) descriptor;
|
||||||
|
|
||||||
return !(minimumOffset.getX() >= rectangle.maximumOffset.getX() || minimumOffset.getY() >= rectangle.maximumOffset.getY() || minimumOffset.getZ() >= rectangle.maximumOffset.getZ() || rectangle.minimumOffset.getX() >= maximumOffset.getX() || rectangle.minimumOffset.getY() >= maximumOffset.getY() || rectangle.minimumOffset.getZ() >= maximumOffset.getZ());
|
return !(minimumOffset.getX() >= rectangle.maximumOffset.getX() || minimumOffset.getY() >= rectangle.maximumOffset.getY() || minimumOffset.getZ() >= rectangle.maximumOffset.getZ() || rectangle.minimumOffset.getX() >= maximumOffset.getX() || rectangle.minimumOffset.getY() >= maximumOffset.getY() || rectangle.minimumOffset.getZ() >= maximumOffset.getZ());
|
||||||
|
@ -272,14 +235,12 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AreaDescriptor offset(BlockPos offset)
|
public AreaDescriptor offset(BlockPos offset) {
|
||||||
{
|
|
||||||
return new AreaDescriptor.Rectangle(this.minimumOffset.add(offset), this.maximumOffset.add(offset));
|
return new AreaDescriptor.Rectangle(this.minimumOffset.add(offset), this.maximumOffset.add(offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AreaDescriptor rotateDescriptor(PlacementSettings settings)
|
public AreaDescriptor rotateDescriptor(PlacementSettings settings) {
|
||||||
{
|
|
||||||
BlockPos rotatePos1 = Template.transformedBlockPos(settings, minimumOffset);
|
BlockPos rotatePos1 = Template.transformedBlockPos(settings, minimumOffset);
|
||||||
BlockPos rotatePos2 = Template.transformedBlockPos(settings, maximumOffset.add(-1, -1, -1)); //It works, shut up!
|
BlockPos rotatePos2 = Template.transformedBlockPos(settings, maximumOffset.add(-1, -1, -1)); //It works, shut up!
|
||||||
|
|
||||||
|
@ -290,8 +251,7 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class HemiSphere extends AreaDescriptor
|
public static class HemiSphere extends AreaDescriptor {
|
||||||
{
|
|
||||||
private BlockPos minimumOffset;
|
private BlockPos minimumOffset;
|
||||||
private int radius;
|
private int radius;
|
||||||
|
|
||||||
|
@ -300,23 +260,19 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||||
|
|
||||||
private boolean cache = true;
|
private boolean cache = true;
|
||||||
|
|
||||||
public HemiSphere(BlockPos minimumOffset, int radius)
|
public HemiSphere(BlockPos minimumOffset, int radius) {
|
||||||
{
|
|
||||||
setRadius(minimumOffset, radius);
|
setRadius(minimumOffset, radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRadius(BlockPos minimumOffset, int radius)
|
public void setRadius(BlockPos minimumOffset, int radius) {
|
||||||
{
|
|
||||||
this.minimumOffset = new BlockPos(Math.min(minimumOffset.getX(), minimumOffset.getX()), Math.min(minimumOffset.getY(), minimumOffset.getY()), Math.min(minimumOffset.getZ(), minimumOffset.getZ()));
|
this.minimumOffset = new BlockPos(Math.min(minimumOffset.getX(), minimumOffset.getX()), Math.min(minimumOffset.getY(), minimumOffset.getY()), Math.min(minimumOffset.getZ(), minimumOffset.getZ()));
|
||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
blockPosCache = new ArrayList<BlockPos>();
|
blockPosCache = new ArrayList<BlockPos>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BlockPos> getContainedPositions(BlockPos pos)
|
public List<BlockPos> getContainedPositions(BlockPos pos) {
|
||||||
{
|
if (!cache || !pos.equals(cachedPosition) || blockPosCache.isEmpty()) {
|
||||||
if (!cache || !pos.equals(cachedPosition) || blockPosCache.isEmpty())
|
|
||||||
{
|
|
||||||
ArrayList<BlockPos> posList = new ArrayList<BlockPos>();
|
ArrayList<BlockPos> posList = new ArrayList<BlockPos>();
|
||||||
|
|
||||||
int i = -radius;
|
int i = -radius;
|
||||||
|
@ -325,14 +281,10 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||||
|
|
||||||
//TODO For some reason the bottom of the hemisphere is not going up with the minOffset
|
//TODO For some reason the bottom of the hemisphere is not going up with the minOffset
|
||||||
|
|
||||||
while (i <= radius)
|
while (i <= radius) {
|
||||||
{
|
while (j <= radius) {
|
||||||
while (j <= radius)
|
while (k <= radius) {
|
||||||
{
|
if (i * i + j * j + k * k >= (radius + 0.5F) * (radius + 0.5F)) {
|
||||||
while (k <= radius)
|
|
||||||
{
|
|
||||||
if (i * i + j * j + k * k >= (radius + 0.5F) * (radius + 0.5F))
|
|
||||||
{
|
|
||||||
k++;
|
k++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -360,98 +312,82 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||||
* Since you can't make a box using a sphere, this returns null
|
* Since you can't make a box using a sphere, this returns null
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getAABB(BlockPos pos)
|
public AxisAlignedBB getAABB(BlockPos pos) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resetCache()
|
public void resetCache() {
|
||||||
{
|
|
||||||
this.blockPosCache = new ArrayList<BlockPos>();
|
this.blockPosCache = new ArrayList<BlockPos>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWithinArea(BlockPos pos)
|
public boolean isWithinArea(BlockPos pos) {
|
||||||
{
|
|
||||||
return blockPosCache.contains(pos);
|
return blockPosCache.contains(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext()
|
public boolean hasNext() {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockPos next()
|
public BlockPos next() {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove()
|
public void remove() {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resetIterator()
|
public void resetIterator() {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2)
|
public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVolumeForOffsets(BlockPos pos1, BlockPos pos2)
|
public int getVolumeForOffsets(BlockPos pos1, BlockPos pos2) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit)
|
public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVolume()
|
public int getVolume() {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWithinRange(int verticalLimit, int horizontalLimit)
|
public boolean isWithinRange(int verticalLimit, int horizontalLimit) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean intersects(AreaDescriptor descriptor)
|
public boolean intersects(AreaDescriptor descriptor) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AreaDescriptor offset(BlockPos offset)
|
public AreaDescriptor offset(BlockPos offset) {
|
||||||
{
|
|
||||||
return new AreaDescriptor.HemiSphere(minimumOffset.add(offset), radius);
|
return new AreaDescriptor.HemiSphere(minimumOffset.add(offset), radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AreaDescriptor rotateDescriptor(PlacementSettings settings)
|
public AreaDescriptor rotateDescriptor(PlacementSettings settings) {
|
||||||
{
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Cross extends AreaDescriptor
|
public static class Cross extends AreaDescriptor {
|
||||||
{
|
|
||||||
|
|
||||||
private ArrayList<BlockPos> blockPosCache;
|
private ArrayList<BlockPos> blockPosCache;
|
||||||
private BlockPos cachedPosition;
|
private BlockPos cachedPosition;
|
||||||
|
@ -461,23 +397,19 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||||
|
|
||||||
private boolean cache = true;
|
private boolean cache = true;
|
||||||
|
|
||||||
public Cross(BlockPos center, int size)
|
public Cross(BlockPos center, int size) {
|
||||||
{
|
|
||||||
this.centerPos = center;
|
this.centerPos = center;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.blockPosCache = new ArrayList<BlockPos>();
|
this.blockPosCache = new ArrayList<BlockPos>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BlockPos> getContainedPositions(BlockPos pos)
|
public List<BlockPos> getContainedPositions(BlockPos pos) {
|
||||||
{
|
if (!cache || !pos.equals(cachedPosition) || blockPosCache.isEmpty()) {
|
||||||
if (!cache || !pos.equals(cachedPosition) || blockPosCache.isEmpty())
|
|
||||||
{
|
|
||||||
resetCache();
|
resetCache();
|
||||||
|
|
||||||
blockPosCache.add(centerPos.add(pos));
|
blockPosCache.add(centerPos.add(pos));
|
||||||
for (int i = 1; i <= size; i++)
|
for (int i = 1; i <= size; i++) {
|
||||||
{
|
|
||||||
blockPosCache.add(centerPos.add(pos).add(i, 0, 0));
|
blockPosCache.add(centerPos.add(pos).add(i, 0, 0));
|
||||||
blockPosCache.add(centerPos.add(pos).add(0, 0, i));
|
blockPosCache.add(centerPos.add(pos).add(0, 0, i));
|
||||||
blockPosCache.add(centerPos.add(pos).add(-i, 0, 0));
|
blockPosCache.add(centerPos.add(pos).add(-i, 0, 0));
|
||||||
|
@ -491,86 +423,72 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resetCache()
|
public void resetCache() {
|
||||||
{
|
|
||||||
blockPosCache = new ArrayList<BlockPos>();
|
blockPosCache = new ArrayList<BlockPos>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWithinArea(BlockPos pos)
|
public boolean isWithinArea(BlockPos pos) {
|
||||||
{
|
|
||||||
return blockPosCache.contains(pos);
|
return blockPosCache.contains(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext()
|
public boolean hasNext() {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockPos next()
|
public BlockPos next() {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove()
|
public void remove() {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resetIterator()
|
public void resetIterator() {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2)
|
public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVolumeForOffsets(BlockPos pos1, BlockPos pos2)
|
public int getVolumeForOffsets(BlockPos pos1, BlockPos pos2) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit)
|
public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVolume()
|
public int getVolume() {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWithinRange(int verticalLimit, int horizontalLimit)
|
public boolean isWithinRange(int verticalLimit, int horizontalLimit) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean intersects(AreaDescriptor descriptor)
|
public boolean intersects(AreaDescriptor descriptor) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AreaDescriptor offset(BlockPos offset)
|
public AreaDescriptor offset(BlockPos offset) {
|
||||||
{
|
|
||||||
return new AreaDescriptor.Cross(centerPos.add(offset), size);
|
return new AreaDescriptor.Cross(centerPos.add(offset), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AreaDescriptor rotateDescriptor(PlacementSettings settings)
|
public AreaDescriptor rotateDescriptor(PlacementSettings settings) {
|
||||||
{
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,50 +7,40 @@ import net.minecraftforge.common.capabilities.Capability;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public final class CapabilityRuneType
|
public final class CapabilityRuneType {
|
||||||
{
|
public static class RuneTypeStorage implements Capability.IStorage<IRitualStone.Tile> {
|
||||||
public static class RuneTypeStorage implements Capability.IStorage<IRitualStone.Tile>
|
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public NBTBase writeNBT(Capability<IRitualStone.Tile> capability, IRitualStone.Tile instance, EnumFacing side)
|
public NBTBase writeNBT(Capability<IRitualStone.Tile> capability, IRitualStone.Tile instance, EnumFacing side) {
|
||||||
{
|
|
||||||
return new NBTTagByte((byte) instance.getRuneType().ordinal());
|
return new NBTTagByte((byte) instance.getRuneType().ordinal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(Capability<IRitualStone.Tile> capability, IRitualStone.Tile instance, EnumFacing side, NBTBase nbt)
|
public void readNBT(Capability<IRitualStone.Tile> capability, IRitualStone.Tile instance, EnumFacing side, NBTBase nbt) {
|
||||||
{
|
|
||||||
instance.setRuneType(EnumRuneType.byMetadata(((NBTTagByte) nbt).getByte()));
|
instance.setRuneType(EnumRuneType.byMetadata(((NBTTagByte) nbt).getByte()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RuneTypeWrapper implements IRitualStone.Tile
|
public static class RuneTypeWrapper implements IRitualStone.Tile {
|
||||||
{
|
|
||||||
private EnumRuneType type = EnumRuneType.BLANK;
|
private EnumRuneType type = EnumRuneType.BLANK;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRuneType(EnumRuneType runeType)
|
public boolean isRuneType(EnumRuneType runeType) {
|
||||||
{
|
|
||||||
return type == runeType;
|
return type == runeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumRuneType getRuneType()
|
public EnumRuneType getRuneType() {
|
||||||
{
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRuneType(EnumRuneType runeType)
|
public void setRuneType(EnumRuneType runeType) {
|
||||||
{
|
|
||||||
type = runeType;
|
type = runeType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Factory implements Callable<IRitualStone.Tile>
|
public static class Factory implements Callable<IRitualStone.Tile> {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public IRitualStone.Tile call() throws Exception
|
public IRitualStone.Tile call() throws Exception {
|
||||||
{
|
|
||||||
return new RuneTypeWrapper();
|
return new RuneTypeWrapper();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package WayofTime.bloodmagic.api.ritual;
|
package WayofTime.bloodmagic.api.ritual;
|
||||||
|
|
||||||
public enum EnumRitualReaderState
|
public enum EnumRitualReaderState {
|
||||||
{
|
|
||||||
SET_AREA,
|
SET_AREA,
|
||||||
INFORMATION,
|
INFORMATION,
|
||||||
SET_WILL_TYPES;
|
SET_WILL_TYPES;
|
||||||
|
|
|
@ -9,8 +9,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public enum EnumRuneType implements IStringSerializable
|
public enum EnumRuneType implements IStringSerializable {
|
||||||
{
|
|
||||||
BLANK(TextFormatting.GRAY),
|
BLANK(TextFormatting.GRAY),
|
||||||
WATER(TextFormatting.AQUA),
|
WATER(TextFormatting.AQUA),
|
||||||
FIRE(TextFormatting.RED),
|
FIRE(TextFormatting.RED),
|
||||||
|
@ -24,34 +23,29 @@ public enum EnumRuneType implements IStringSerializable
|
||||||
|
|
||||||
public final TextFormatting colorCode;
|
public final TextFormatting colorCode;
|
||||||
|
|
||||||
EnumRuneType(TextFormatting colorCode)
|
EnumRuneType(TextFormatting colorCode) {
|
||||||
{
|
|
||||||
this.colorCode = colorCode;
|
this.colorCode = colorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EnumRuneType byMetadata(int meta)
|
public ItemStack getScribeStack() {
|
||||||
{
|
return new ItemStack(INSCRIPTION_TOOL, 1, ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name().toLowerCase(Locale.ENGLISH);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return this.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EnumRuneType byMetadata(int meta) {
|
||||||
if (meta < 0 || meta >= values().length)
|
if (meta < 0 || meta >= values().length)
|
||||||
meta = 0;
|
meta = 0;
|
||||||
|
|
||||||
return values()[meta];
|
return values()[meta];
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getScribeStack()
|
|
||||||
{
|
|
||||||
return new ItemStack(INSCRIPTION_TOOL, 1, ordinal());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return name().toLowerCase(Locale.ENGLISH);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return this.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
package WayofTime.bloodmagic.api.ritual;
|
package WayofTime.bloodmagic.api.ritual;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import WayofTime.bloodmagic.api.saving.SoulNetwork;
|
import WayofTime.bloodmagic.api.saving.SoulNetwork;
|
||||||
|
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||||
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.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface is for internal implementation only.
|
* This interface is for internal implementation only.
|
||||||
*
|
* <p>
|
||||||
* It is provided via the API for easy obtaining of basic data.
|
* It is provided via the API for easy obtaining of basic data.
|
||||||
*/
|
*/
|
||||||
public interface IMasterRitualStone
|
public interface IMasterRitualStone {
|
||||||
{
|
|
||||||
String getOwner();
|
String getOwner();
|
||||||
|
|
||||||
SoulNetwork getOwnerNetwork();
|
SoulNetwork getOwnerNetwork();
|
||||||
|
|
|
@ -5,17 +5,15 @@ import net.minecraft.world.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface is for internal implementation only.
|
* This interface is for internal implementation only.
|
||||||
*
|
* <p>
|
||||||
* It is provided via the API for easy obtaining of basic data.
|
* It is provided via the API for easy obtaining of basic data.
|
||||||
*/
|
*/
|
||||||
public interface IRitualStone
|
public interface IRitualStone {
|
||||||
{
|
|
||||||
boolean isRuneType(World world, BlockPos pos, EnumRuneType runeType);
|
boolean isRuneType(World world, BlockPos pos, EnumRuneType runeType);
|
||||||
|
|
||||||
void setRuneType(World world, BlockPos pos, EnumRuneType runeType);
|
void setRuneType(World world, BlockPos pos, EnumRuneType runeType);
|
||||||
|
|
||||||
interface Tile
|
interface Tile {
|
||||||
{
|
|
||||||
boolean isRuneType(EnumRuneType runeType);
|
boolean isRuneType(EnumRuneType runeType);
|
||||||
|
|
||||||
EnumRuneType getRuneType();
|
EnumRuneType getRuneType();
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
package WayofTime.bloodmagic.api.ritual;
|
package WayofTime.bloodmagic.api.ritual;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import WayofTime.bloodmagic.api.soul.DemonWillHolder;
|
||||||
import java.util.HashMap;
|
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||||
import java.util.List;
|
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
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.nbt.NBTTagCompound;
|
||||||
|
@ -14,29 +11,30 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.TextComponentTranslation;
|
import net.minecraft.util.text.TextComponentTranslation;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import WayofTime.bloodmagic.api.soul.DemonWillHolder;
|
|
||||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
|
||||||
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for creating new rituals. Rituals need be registered with
|
* Abstract class for creating new rituals. Rituals need be registered with
|
||||||
* {@link WayofTime.bloodmagic.api.registry.RitualRegistry#registerRitual(Ritual, String)}
|
* {@link WayofTime.bloodmagic.api.registry.RitualRegistry#registerRitual(Ritual, String)}
|
||||||
*/
|
*/
|
||||||
public abstract class Ritual
|
public abstract class Ritual {
|
||||||
{
|
|
||||||
public final ArrayList<RitualComponent> ritualComponents = new ArrayList<RitualComponent>();
|
public final ArrayList<RitualComponent> ritualComponents = new ArrayList<RitualComponent>();
|
||||||
|
protected final Map<String, AreaDescriptor> modableRangeMap = new HashMap<String, AreaDescriptor>();
|
||||||
|
protected final Map<String, Integer> volumeRangeMap = new HashMap<String, Integer>();
|
||||||
|
protected final Map<String, Integer> horizontalRangeMap = new HashMap<String, Integer>();
|
||||||
|
protected final Map<String, Integer> verticalRangeMap = new HashMap<String, Integer>();
|
||||||
private final String name;
|
private final String name;
|
||||||
private final int crystalLevel;
|
private final int crystalLevel;
|
||||||
private final int activationCost;
|
private final int activationCost;
|
||||||
private final RitualRenderer renderer;
|
private final RitualRenderer renderer;
|
||||||
private final String unlocalizedName;
|
private final String unlocalizedName;
|
||||||
|
|
||||||
protected final Map<String, AreaDescriptor> modableRangeMap = new HashMap<String, AreaDescriptor>();
|
|
||||||
protected final Map<String, Integer> volumeRangeMap = new HashMap<String, Integer>();
|
|
||||||
protected final Map<String, Integer> horizontalRangeMap = new HashMap<String, Integer>();
|
|
||||||
protected final Map<String, Integer> verticalRangeMap = new HashMap<String, Integer>();
|
|
||||||
|
|
||||||
public Ritual(String name, int crystalLevel, int activationCost, RitualRenderer renderer, String unlocalizedName) {
|
public Ritual(String name, int crystalLevel, int activationCost, RitualRenderer renderer, String unlocalizedName) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.crystalLevel = crystalLevel;
|
this.crystalLevel = crystalLevel;
|
||||||
|
@ -46,46 +44,36 @@ public abstract class Ritual
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name - The name of the ritual
|
||||||
* - The name of the ritual
|
* @param crystalLevel - Required Activation Crystal tier
|
||||||
* @param crystalLevel
|
* @param activationCost - Base LP cost for activating the ritual
|
||||||
* - Required Activation Crystal tier
|
|
||||||
* @param activationCost
|
|
||||||
* - Base LP cost for activating the ritual
|
|
||||||
*/
|
*/
|
||||||
public Ritual(String name, int crystalLevel, int activationCost, String unlocalizedName)
|
public Ritual(String name, int crystalLevel, int activationCost, String unlocalizedName) {
|
||||||
{
|
|
||||||
this(name, crystalLevel, activationCost, null, unlocalizedName);
|
this(name, crystalLevel, activationCost, null, unlocalizedName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readFromNBT(NBTTagCompound tag)
|
public void readFromNBT(NBTTagCompound tag) {
|
||||||
{
|
|
||||||
NBTTagList tags = tag.getTagList("areas", 10);
|
NBTTagList tags = tag.getTagList("areas", 10);
|
||||||
if (tags.hasNoTags())
|
if (tags.hasNoTags()) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < tags.tagCount(); i++)
|
for (int i = 0; i < tags.tagCount(); i++) {
|
||||||
{
|
|
||||||
NBTTagCompound newTag = tags.getCompoundTagAt(i);
|
NBTTagCompound newTag = tags.getCompoundTagAt(i);
|
||||||
String rangeKey = newTag.getString("key");
|
String rangeKey = newTag.getString("key");
|
||||||
|
|
||||||
NBTTagCompound storedTag = newTag.getCompoundTag("area");
|
NBTTagCompound storedTag = newTag.getCompoundTag("area");
|
||||||
AreaDescriptor desc = this.getBlockRange(rangeKey);
|
AreaDescriptor desc = this.getBlockRange(rangeKey);
|
||||||
if (desc != null)
|
if (desc != null) {
|
||||||
{
|
|
||||||
desc.readFromNBT(storedTag);
|
desc.readFromNBT(storedTag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeToNBT(NBTTagCompound tag)
|
public void writeToNBT(NBTTagCompound tag) {
|
||||||
{
|
|
||||||
NBTTagList tags = new NBTTagList();
|
NBTTagList tags = new NBTTagList();
|
||||||
|
|
||||||
for (Entry<String, AreaDescriptor> entry : modableRangeMap.entrySet())
|
for (Entry<String, AreaDescriptor> entry : modableRangeMap.entrySet()) {
|
||||||
{
|
|
||||||
NBTTagCompound newTag = new NBTTagCompound();
|
NBTTagCompound newTag = new NBTTagCompound();
|
||||||
newTag.setString("key", entry.getKey());
|
newTag.setString("key", entry.getKey());
|
||||||
NBTTagCompound storedTag = new NBTTagCompound();
|
NBTTagCompound storedTag = new NBTTagCompound();
|
||||||
|
@ -102,52 +90,44 @@ public abstract class Ritual
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the player attempts to activate the ritual.
|
* Called when the player attempts to activate the ritual.
|
||||||
*
|
* <p>
|
||||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#activateRitual(ItemStack, EntityPlayer, Ritual)}
|
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#activateRitual(ItemStack, EntityPlayer, Ritual)}
|
||||||
*
|
*
|
||||||
* @param masterRitualStone
|
* @param masterRitualStone - The {@link IMasterRitualStone} that the ritual is bound to
|
||||||
* - The {@link IMasterRitualStone} that the ritual is bound to
|
* @param player - The activating player
|
||||||
* @param player
|
* @param owner - Owner of the crystal activating this ritual, or the current
|
||||||
* - The activating player
|
* owner of the ritual if being reactivated.
|
||||||
* @param owner
|
|
||||||
* - Owner of the crystal activating this ritual, or the current
|
|
||||||
* owner of the ritual if being reactivated.
|
|
||||||
* @return - Whether activation was successful
|
* @return - Whether activation was successful
|
||||||
*/
|
*/
|
||||||
public boolean activateRitual(IMasterRitualStone masterRitualStone, EntityPlayer player, String owner)
|
public boolean activateRitual(IMasterRitualStone masterRitualStone, EntityPlayer player, String owner) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called every {@link #getRefreshTime()} ticks while active.
|
* Called every {@link #getRefreshTime()} ticks while active.
|
||||||
*
|
* <p>
|
||||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, BlockPos)}
|
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, BlockPos)}
|
||||||
*
|
*
|
||||||
* @param masterRitualStone
|
* @param masterRitualStone - The {@link IMasterRitualStone} that the ritual is bound to
|
||||||
* - The {@link IMasterRitualStone} that the ritual is bound to
|
|
||||||
*/
|
*/
|
||||||
public abstract void performRitual(IMasterRitualStone masterRitualStone);
|
public abstract void performRitual(IMasterRitualStone masterRitualStone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the ritual is stopped for a given {@link Ritual.BreakType}.
|
* Called when the ritual is stopped for a given {@link Ritual.BreakType}.
|
||||||
*
|
* <p>
|
||||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(Ritual.BreakType)}
|
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(Ritual.BreakType)}
|
||||||
*
|
*
|
||||||
* @param masterRitualStone
|
* @param masterRitualStone - The {@link IMasterRitualStone} that the ritual is bound to
|
||||||
* - The {@link IMasterRitualStone} that the ritual is bound to
|
* @param breakType - The type of break that caused the stoppage.
|
||||||
* @param breakType
|
|
||||||
* - The type of break that caused the stoppage.
|
|
||||||
*/
|
*/
|
||||||
public void stopRitual(IMasterRitualStone masterRitualStone, BreakType breakType)
|
public void stopRitual(IMasterRitualStone masterRitualStone, BreakType breakType) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to set the amount of LP drained every {@link #getRefreshTime()}
|
* Used to set the amount of LP drained every {@link #getRefreshTime()}
|
||||||
* ticks.
|
* ticks.
|
||||||
*
|
*
|
||||||
* @return - The amount of LP drained per refresh
|
* @return - The amount of LP drained per refresh
|
||||||
*/
|
*/
|
||||||
public abstract int getRefreshCost();
|
public abstract int getRefreshCost();
|
||||||
|
@ -155,64 +135,52 @@ public abstract class Ritual
|
||||||
/**
|
/**
|
||||||
* Used to set the refresh rate of the ritual. (How often
|
* Used to set the refresh rate of the ritual. (How often
|
||||||
* {@link #performRitual(IMasterRitualStone)} is called.
|
* {@link #performRitual(IMasterRitualStone)} is called.
|
||||||
*
|
*
|
||||||
* @return - How often to perform the effect in ticks.
|
* @return - How often to perform the effect in ticks.
|
||||||
*/
|
*/
|
||||||
public int getRefreshTime()
|
public int getRefreshTime() {
|
||||||
{
|
|
||||||
return 20;
|
return 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBlockRange(String range, AreaDescriptor defaultRange)
|
public void addBlockRange(String range, AreaDescriptor defaultRange) {
|
||||||
{
|
|
||||||
modableRangeMap.put(range, defaultRange);
|
modableRangeMap.put(range, defaultRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to grab the range of a ritual for a given effect.
|
* Used to grab the range of a ritual for a given effect.
|
||||||
*
|
*
|
||||||
* @param range
|
* @param range - Range that needs to be pulled.
|
||||||
* - Range that needs to be pulled.
|
|
||||||
* @return -
|
* @return -
|
||||||
*/
|
*/
|
||||||
public AreaDescriptor getBlockRange(String range)
|
public AreaDescriptor getBlockRange(String range) {
|
||||||
{
|
if (modableRangeMap.containsKey(range)) {
|
||||||
if (modableRangeMap.containsKey(range))
|
|
||||||
{
|
|
||||||
return modableRangeMap.get(range);
|
return modableRangeMap.get(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getListOfRanges()
|
public List<String> getListOfRanges() {
|
||||||
{
|
|
||||||
return new ArrayList<String>(modableRangeMap.keySet());
|
return new ArrayList<String>(modableRangeMap.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNextBlockRange(String range)
|
public String getNextBlockRange(String range) {
|
||||||
{
|
|
||||||
List<String> rangeList = getListOfRanges();
|
List<String> rangeList = getListOfRanges();
|
||||||
|
|
||||||
if (rangeList.isEmpty())
|
if (rangeList.isEmpty()) {
|
||||||
{
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rangeList.contains(range))
|
if (!rangeList.contains(range)) {
|
||||||
{
|
|
||||||
return rangeList.get(0);
|
return rangeList.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasMatch = false;
|
boolean hasMatch = false;
|
||||||
|
|
||||||
for (String rangeCheck : rangeList)
|
for (String rangeCheck : rangeList) {
|
||||||
{
|
if (hasMatch) {
|
||||||
if (hasMatch)
|
|
||||||
{
|
|
||||||
return rangeCheck;
|
return rangeCheck;
|
||||||
} else if (rangeCheck.equals(range))
|
} else if (rangeCheck.equals(range)) {
|
||||||
{
|
|
||||||
hasMatch = true;
|
hasMatch = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,14 +188,12 @@ public abstract class Ritual
|
||||||
return rangeList.get(0);
|
return rangeList.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setBlockRangeByBounds(String range, IMasterRitualStone master, BlockPos offset1, BlockPos offset2)
|
public boolean setBlockRangeByBounds(String range, IMasterRitualStone master, BlockPos offset1, BlockPos offset2) {
|
||||||
{
|
|
||||||
AreaDescriptor descriptor = this.getBlockRange(range);
|
AreaDescriptor descriptor = this.getBlockRange(range);
|
||||||
World world = master.getWorldObj();
|
World world = master.getWorldObj();
|
||||||
BlockPos masterPos = master.getBlockPos();
|
BlockPos masterPos = master.getBlockPos();
|
||||||
DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(world, masterPos);
|
DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(world, masterPos);
|
||||||
if (canBlockRangeBeModified(range, descriptor, master, offset1, offset2, holder))
|
if (canBlockRangeBeModified(range, descriptor, master, offset1, offset2, holder)) {
|
||||||
{
|
|
||||||
descriptor.modifyAreaByBlockPositions(offset1, offset2);
|
descriptor.modifyAreaByBlockPositions(offset1, offset2);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -235,8 +201,7 @@ public abstract class Ritual
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canBlockRangeBeModified(String range, AreaDescriptor descriptor, IMasterRitualStone master, BlockPos offset1, BlockPos offset2, DemonWillHolder holder)
|
protected boolean canBlockRangeBeModified(String range, AreaDescriptor descriptor, IMasterRitualStone master, BlockPos offset1, BlockPos offset2, DemonWillHolder holder) {
|
||||||
{
|
|
||||||
List<EnumDemonWillType> willConfig = master.getActiveWillConfig();
|
List<EnumDemonWillType> willConfig = master.getActiveWillConfig();
|
||||||
int maxVolume = getMaxVolumeForRange(range, willConfig, holder);
|
int maxVolume = getMaxVolumeForRange(range, willConfig, holder);
|
||||||
int maxVertical = getMaxVerticalRadiusForRange(range, willConfig, holder);
|
int maxVertical = getMaxVerticalRadiusForRange(range, willConfig, holder);
|
||||||
|
@ -245,38 +210,31 @@ public abstract class Ritual
|
||||||
return (maxVolume <= 0 || descriptor.getVolumeForOffsets(offset1, offset2) <= maxVolume) && descriptor.isWithinRange(offset1, offset2, maxVertical, maxHorizontal);
|
return (maxVolume <= 0 || descriptor.getVolumeForOffsets(offset1, offset2) <= maxVolume) && descriptor.isWithinRange(offset1, offset2, maxVertical, maxHorizontal);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setMaximumVolumeAndDistanceOfRange(String range, int volume, int horizontalRadius, int verticalRadius)
|
protected void setMaximumVolumeAndDistanceOfRange(String range, int volume, int horizontalRadius, int verticalRadius) {
|
||||||
{
|
|
||||||
volumeRangeMap.put(range, volume);
|
volumeRangeMap.put(range, volume);
|
||||||
horizontalRangeMap.put(range, horizontalRadius);
|
horizontalRangeMap.put(range, horizontalRadius);
|
||||||
verticalRangeMap.put(range, verticalRadius);
|
verticalRangeMap.put(range, verticalRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean checkDescriptorIsWithinRange(AreaDescriptor descriptor, int maxVolume, int maxHorizontal, int maxVertical)
|
protected boolean checkDescriptorIsWithinRange(AreaDescriptor descriptor, int maxVolume, int maxHorizontal, int maxVertical) {
|
||||||
{
|
|
||||||
return descriptor.getVolume() <= maxVolume && descriptor.isWithinRange(maxVertical, maxHorizontal);
|
return descriptor.getVolume() <= maxVolume && descriptor.isWithinRange(maxVertical, maxHorizontal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxVolumeForRange(String range, List<EnumDemonWillType> activeTypes, DemonWillHolder holder)
|
public int getMaxVolumeForRange(String range, List<EnumDemonWillType> activeTypes, DemonWillHolder holder) {
|
||||||
{
|
|
||||||
return volumeRangeMap.get(range);
|
return volumeRangeMap.get(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxVerticalRadiusForRange(String range, List<EnumDemonWillType> activeTypes, DemonWillHolder holder)
|
public int getMaxVerticalRadiusForRange(String range, List<EnumDemonWillType> activeTypes, DemonWillHolder holder) {
|
||||||
{
|
|
||||||
return verticalRangeMap.get(range);
|
return verticalRangeMap.get(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxHorizontalRadiusForRange(String range, List<EnumDemonWillType> activeTypes, DemonWillHolder holder)
|
public int getMaxHorizontalRadiusForRange(String range, List<EnumDemonWillType> activeTypes, DemonWillHolder holder) {
|
||||||
{
|
|
||||||
return horizontalRangeMap.get(range);
|
return horizontalRangeMap.get(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITextComponent getErrorForBlockRangeOnFail(EntityPlayer player, String range, IMasterRitualStone master, BlockPos offset1, BlockPos offset2)
|
public ITextComponent getErrorForBlockRangeOnFail(EntityPlayer player, String range, IMasterRitualStone master, BlockPos offset1, BlockPos offset2) {
|
||||||
{
|
|
||||||
AreaDescriptor descriptor = this.getBlockRange(range);
|
AreaDescriptor descriptor = this.getBlockRange(range);
|
||||||
if (descriptor == null)
|
if (descriptor == null) {
|
||||||
{
|
|
||||||
return new TextComponentTranslation("ritual.bloodmagic.blockRange.tooBig", "?");
|
return new TextComponentTranslation("ritual.bloodmagic.blockRange.tooBig", "?");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,27 +245,21 @@ public abstract class Ritual
|
||||||
int maxVertical = this.getMaxVerticalRadiusForRange(range, willConfig, holder);
|
int maxVertical = this.getMaxVerticalRadiusForRange(range, willConfig, holder);
|
||||||
int maxHorizontal = this.getMaxHorizontalRadiusForRange(range, willConfig, holder);
|
int maxHorizontal = this.getMaxHorizontalRadiusForRange(range, willConfig, holder);
|
||||||
|
|
||||||
if (maxVolume > 0 && descriptor.getVolumeForOffsets(offset1, offset2) > maxVolume)
|
if (maxVolume > 0 && descriptor.getVolumeForOffsets(offset1, offset2) > maxVolume) {
|
||||||
{
|
|
||||||
return new TextComponentTranslation("ritual.bloodmagic.blockRange.tooBig", maxVolume);
|
return new TextComponentTranslation("ritual.bloodmagic.blockRange.tooBig", maxVolume);
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
return new TextComponentTranslation("ritual.bloodmagic.blockRange.tooFar", maxVertical, maxHorizontal);
|
return new TextComponentTranslation("ritual.bloodmagic.blockRange.tooFar", maxVertical, maxHorizontal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITextComponent[] provideInformationOfRitualToPlayer(EntityPlayer player)
|
public ITextComponent[] provideInformationOfRitualToPlayer(EntityPlayer player) {
|
||||||
{
|
return new ITextComponent[]{new TextComponentTranslation(this.getUnlocalizedName() + ".info")};
|
||||||
return new ITextComponent[] { new TextComponentTranslation(this.getUnlocalizedName() + ".info") };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITextComponent provideInformationOfRangeToPlayer(EntityPlayer player, String range)
|
public ITextComponent provideInformationOfRangeToPlayer(EntityPlayer player, String range) {
|
||||||
{
|
if (getListOfRanges().contains(range)) {
|
||||||
if (getListOfRanges().contains(range))
|
|
||||||
{
|
|
||||||
return new TextComponentTranslation(this.getUnlocalizedName() + "." + range + ".info");
|
return new TextComponentTranslation(this.getUnlocalizedName() + "." + range + ".info");
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
return new TextComponentTranslation("ritual.bloodmagic.blockRange.noRange");
|
return new TextComponentTranslation("ritual.bloodmagic.blockRange.noRange");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,13 +269,11 @@ public abstract class Ritual
|
||||||
*/
|
*/
|
||||||
public abstract ArrayList<RitualComponent> getComponents();
|
public abstract ArrayList<RitualComponent> getComponents();
|
||||||
|
|
||||||
public void addRune(ArrayList<RitualComponent> components, int offset1, int y, int offset2, EnumRuneType rune)
|
public void addRune(ArrayList<RitualComponent> components, int offset1, int y, int offset2, EnumRuneType rune) {
|
||||||
{
|
|
||||||
components.add(new RitualComponent(new BlockPos(offset1, y, offset2), rune));
|
components.add(new RitualComponent(new BlockPos(offset1, y, offset2), rune));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addOffsetRunes(ArrayList<RitualComponent> components, int offset1, int offset2, int y, EnumRuneType rune)
|
public void addOffsetRunes(ArrayList<RitualComponent> components, int offset1, int offset2, int y, EnumRuneType rune) {
|
||||||
{
|
|
||||||
addRune(components, offset1, y, offset2, rune);
|
addRune(components, offset1, y, offset2, rune);
|
||||||
addRune(components, offset2, y, offset1, rune);
|
addRune(components, offset2, y, offset1, rune);
|
||||||
addRune(components, offset1, y, -offset2, rune);
|
addRune(components, offset1, y, -offset2, rune);
|
||||||
|
@ -334,34 +284,21 @@ public abstract class Ritual
|
||||||
addRune(components, -offset2, y, -offset1, rune);
|
addRune(components, -offset2, y, -offset1, rune);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCornerRunes(ArrayList<RitualComponent> components, int offset, int y, EnumRuneType rune)
|
public void addCornerRunes(ArrayList<RitualComponent> components, int offset, int y, EnumRuneType rune) {
|
||||||
{
|
|
||||||
addRune(components, offset, y, offset, rune);
|
addRune(components, offset, y, offset, rune);
|
||||||
addRune(components, offset, y, -offset, rune);
|
addRune(components, offset, y, -offset, rune);
|
||||||
addRune(components, -offset, y, -offset, rune);
|
addRune(components, -offset, y, -offset, rune);
|
||||||
addRune(components, -offset, y, offset, rune);
|
addRune(components, -offset, y, offset, rune);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addParallelRunes(ArrayList<RitualComponent> components, int offset, int y, EnumRuneType rune)
|
public void addParallelRunes(ArrayList<RitualComponent> components, int offset, int y, EnumRuneType rune) {
|
||||||
{
|
|
||||||
addRune(components, offset, y, 0, rune);
|
addRune(components, offset, y, 0, rune);
|
||||||
addRune(components, -offset, y, 0, rune);
|
addRune(components, -offset, y, 0, rune);
|
||||||
addRune(components, 0, y, -offset, rune);
|
addRune(components, 0, y, -offset, rune);
|
||||||
addRune(components, 0, y, offset, rune);
|
addRune(components, 0, y, offset, rune);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum BreakType
|
public double getWillRespectingConfig(World world, BlockPos pos, EnumDemonWillType type, List<EnumDemonWillType> willConfig) {
|
||||||
{
|
|
||||||
REDSTONE,
|
|
||||||
BREAK_MRS,
|
|
||||||
BREAK_STONE,
|
|
||||||
ACTIVATE,
|
|
||||||
DEACTIVATE,
|
|
||||||
EXPLOSION,
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getWillRespectingConfig(World world, BlockPos pos, EnumDemonWillType type, List<EnumDemonWillType> willConfig)
|
|
||||||
{
|
|
||||||
return willConfig.contains(type) ? WorldDemonWillHandler.getCurrentWill(world, pos, type) : 0;
|
return willConfig.contains(type) ? WorldDemonWillHandler.getCurrentWill(world, pos, type) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,4 +383,13 @@ public abstract class Ritual
|
||||||
result = 31 * result + (unlocalizedName != null ? unlocalizedName.hashCode() : 0);
|
result = 31 * result + (unlocalizedName != null ? unlocalizedName.hashCode() : 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum BreakType {
|
||||||
|
REDSTONE,
|
||||||
|
BREAK_MRS,
|
||||||
|
BREAK_STONE,
|
||||||
|
ACTIVATE,
|
||||||
|
DEACTIVATE,
|
||||||
|
EXPLOSION,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,7 @@ import net.minecraft.util.math.BlockPos;
|
||||||
* Used to set a {@link EnumRuneType} type to a given {@link BlockPos} for usage
|
* Used to set a {@link EnumRuneType} type to a given {@link BlockPos} for usage
|
||||||
* in Ritual creation.
|
* in Ritual creation.
|
||||||
*/
|
*/
|
||||||
public class RitualComponent
|
public class RitualComponent {
|
||||||
{
|
|
||||||
private final BlockPos offset;
|
private final BlockPos offset;
|
||||||
private final EnumRuneType runeType;
|
private final EnumRuneType runeType;
|
||||||
|
|
||||||
|
@ -17,43 +16,37 @@ public class RitualComponent
|
||||||
this.runeType = runeType;
|
this.runeType = runeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getX(EnumFacing direction)
|
public int getX(EnumFacing direction) {
|
||||||
{
|
switch (direction) {
|
||||||
switch (direction)
|
case EAST:
|
||||||
{
|
return -this.getOffset().getZ();
|
||||||
case EAST:
|
case SOUTH:
|
||||||
return -this.getOffset().getZ();
|
return -this.getOffset().getX();
|
||||||
case SOUTH:
|
case WEST:
|
||||||
return -this.getOffset().getX();
|
return this.getOffset().getZ();
|
||||||
case WEST:
|
default:
|
||||||
return this.getOffset().getZ();
|
return this.getOffset().getX();
|
||||||
default:
|
|
||||||
return this.getOffset().getX();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getY()
|
public int getY() {
|
||||||
{
|
|
||||||
return this.getOffset().getY();
|
return this.getOffset().getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getZ(EnumFacing direction)
|
public int getZ(EnumFacing direction) {
|
||||||
{
|
switch (direction) {
|
||||||
switch (direction)
|
case EAST:
|
||||||
{
|
return this.getOffset().getX();
|
||||||
case EAST:
|
case SOUTH:
|
||||||
return this.getOffset().getX();
|
return -this.getOffset().getZ();
|
||||||
case SOUTH:
|
case WEST:
|
||||||
return -this.getOffset().getZ();
|
return -this.getOffset().getX();
|
||||||
case WEST:
|
default:
|
||||||
return -this.getOffset().getX();
|
return this.getOffset().getZ();
|
||||||
default:
|
|
||||||
return this.getOffset().getZ();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockPos getOffset(EnumFacing direction)
|
public BlockPos getOffset(EnumFacing direction) {
|
||||||
{
|
|
||||||
return new BlockPos(getX(direction), offset.getY(), getZ(direction));
|
return new BlockPos(getX(direction), offset.getY(), getZ(direction));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,10 @@ package WayofTime.bloodmagic.api.ritual;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
public abstract class RitualRenderer
|
public abstract class RitualRenderer {
|
||||||
{
|
|
||||||
public abstract void renderAt(IMasterRitualStone masterRitualStone, double x, double y, double z);
|
public abstract void renderAt(IMasterRitualStone masterRitualStone, double x, double y, double z);
|
||||||
|
|
||||||
protected void bindTexture(ResourceLocation resourceLocation)
|
protected void bindTexture(ResourceLocation resourceLocation) {
|
||||||
{
|
|
||||||
Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation);
|
Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,10 @@ import net.minecraft.world.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface is for internal implementation only.
|
* This interface is for internal implementation only.
|
||||||
*
|
* <p>
|
||||||
* It is provided via the API for easy obtaining of basic data.
|
* It is provided via the API for easy obtaining of basic data.
|
||||||
*/
|
*/
|
||||||
public interface IImperfectRitualStone
|
public interface IImperfectRitualStone {
|
||||||
{
|
|
||||||
|
|
||||||
boolean performRitual(World world, BlockPos pos, ImperfectRitual imperfectRitual, EntityPlayer player);
|
boolean performRitual(World world, BlockPos pos, ImperfectRitual imperfectRitual, EntityPlayer player);
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,7 @@ import net.minecraft.world.World;
|
||||||
* registered with
|
* registered with
|
||||||
* {@link WayofTime.bloodmagic.api.registry.ImperfectRitualRegistry#registerRitual(ImperfectRitual)}
|
* {@link WayofTime.bloodmagic.api.registry.ImperfectRitualRegistry#registerRitual(ImperfectRitual)}
|
||||||
*/
|
*/
|
||||||
public abstract class ImperfectRitual
|
public abstract class ImperfectRitual {
|
||||||
{
|
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final BlockStack requiredBlock;
|
private final BlockStack requiredBlock;
|
||||||
|
@ -27,26 +26,20 @@ public abstract class ImperfectRitual
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name - The name of the ritual
|
||||||
* - The name of the ritual
|
* @param requiredBlock - The block required above the ImperfectRitualStone
|
||||||
* @param requiredBlock
|
* @param activationCost - Base LP cost for activating the ritual
|
||||||
* - The block required above the ImperfectRitualStone
|
|
||||||
* @param activationCost
|
|
||||||
* - Base LP cost for activating the ritual
|
|
||||||
*/
|
*/
|
||||||
public ImperfectRitual(String name, BlockStack requiredBlock, int activationCost, String unlocalizedName)
|
public ImperfectRitual(String name, BlockStack requiredBlock, int activationCost, String unlocalizedName) {
|
||||||
{
|
|
||||||
this(name, requiredBlock, activationCost, false, unlocalizedName);
|
this(name, requiredBlock, activationCost, false, unlocalizedName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the player activates the ritual
|
* Called when the player activates the ritual
|
||||||
* {@link WayofTime.bloodmagic.tile.TileImperfectRitualStone#performRitual(World, net.minecraft.util.math.BlockPos, ImperfectRitual, EntityPlayer)}
|
* {@link WayofTime.bloodmagic.tile.TileImperfectRitualStone#performRitual(World, net.minecraft.util.math.BlockPos, ImperfectRitual, EntityPlayer)}
|
||||||
*
|
*
|
||||||
* @param imperfectRitualStone
|
* @param imperfectRitualStone - The {@link IImperfectRitualStone} that the ritual is bound to
|
||||||
* - The {@link IImperfectRitualStone} that the ritual is bound to
|
* @param player - The player activating the ritual
|
||||||
* @param player
|
|
||||||
* - The player activating the ritual
|
|
||||||
* @return - Whether activation was successful
|
* @return - Whether activation was successful
|
||||||
*/
|
*/
|
||||||
public abstract boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player);
|
public abstract boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player);
|
||||||
|
@ -72,8 +65,7 @@ public abstract class ImperfectRitual
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
|
||||||
return getName() + ":" + getRequiredBlock().toString() + "@" + getActivationCost();
|
return getName() + ":" + getRequiredBlock().toString() + "@" + getActivationCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,43 +6,38 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.world.storage.WorldSavedData;
|
import net.minecraft.world.storage.WorldSavedData;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class BMWorldSavedData extends WorldSavedData
|
public class BMWorldSavedData extends WorldSavedData {
|
||||||
{
|
|
||||||
public static final String ID = "BloodMagic-SoulNetworks";
|
public static final String ID = "BloodMagic-SoulNetworks";
|
||||||
|
|
||||||
private Map<UUID, SoulNetwork> soulNetworks = new HashMap<UUID, SoulNetwork>();
|
private Map<UUID, SoulNetwork> soulNetworks = new HashMap<UUID, SoulNetwork>();
|
||||||
|
|
||||||
public BMWorldSavedData(String id)
|
public BMWorldSavedData(String id) {
|
||||||
{
|
|
||||||
super(id);
|
super(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BMWorldSavedData()
|
public BMWorldSavedData() {
|
||||||
{
|
|
||||||
this(ID);
|
this(ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SoulNetwork getNetwork(EntityPlayer player)
|
public SoulNetwork getNetwork(EntityPlayer player) {
|
||||||
{
|
|
||||||
return getNetwork(PlayerHelper.getUUIDFromPlayer(player));
|
return getNetwork(PlayerHelper.getUUIDFromPlayer(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public SoulNetwork getNetwork(UUID playerId)
|
public SoulNetwork getNetwork(UUID playerId) {
|
||||||
{
|
|
||||||
if (!soulNetworks.containsKey(playerId))
|
if (!soulNetworks.containsKey(playerId))
|
||||||
soulNetworks.put(playerId, SoulNetwork.newEmpty(playerId).setParent(this));
|
soulNetworks.put(playerId, SoulNetwork.newEmpty(playerId).setParent(this));
|
||||||
return soulNetworks.get(playerId);
|
return soulNetworks.get(playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound tagCompound)
|
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||||
{
|
|
||||||
NBTTagList networkData = tagCompound.getTagList("networkData", 10);
|
NBTTagList networkData = tagCompound.getTagList("networkData", 10);
|
||||||
|
|
||||||
for (int i = 0; i < networkData.tagCount(); i++)
|
for (int i = 0; i < networkData.tagCount(); i++) {
|
||||||
{
|
|
||||||
NBTTagCompound data = networkData.getCompoundTagAt(i);
|
NBTTagCompound data = networkData.getCompoundTagAt(i);
|
||||||
SoulNetwork network = SoulNetwork.fromNBT(data);
|
SoulNetwork network = SoulNetwork.fromNBT(data);
|
||||||
network.setParent(this);
|
network.setParent(this);
|
||||||
|
@ -51,8 +46,7 @@ public class BMWorldSavedData extends WorldSavedData
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||||
{
|
|
||||||
NBTTagList networkData = new NBTTagList();
|
NBTTagList networkData = new NBTTagList();
|
||||||
for (SoulNetwork soulNetwork : soulNetworks.values())
|
for (SoulNetwork soulNetwork : soulNetworks.values())
|
||||||
networkData.appendTag(soulNetwork.serializeNBT());
|
networkData.appendTag(soulNetwork.serializeNBT());
|
||||||
|
|
|
@ -17,21 +17,18 @@ import net.minecraftforge.fml.common.eventhandler.Event;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class SoulNetwork implements INBTSerializable<NBTTagCompound>
|
public class SoulNetwork implements INBTSerializable<NBTTagCompound> {
|
||||||
{
|
|
||||||
private BMWorldSavedData parent;
|
private BMWorldSavedData parent;
|
||||||
private EntityPlayer cachedPlayer;
|
private EntityPlayer cachedPlayer;
|
||||||
private UUID playerId;
|
private UUID playerId;
|
||||||
private int currentEssence;
|
private int currentEssence;
|
||||||
private int orbTier;
|
private int orbTier;
|
||||||
|
|
||||||
private SoulNetwork()
|
private SoulNetwork() {
|
||||||
{
|
|
||||||
// No-op - For creation via NBT only
|
// No-op - For creation via NBT only
|
||||||
}
|
}
|
||||||
|
|
||||||
public int add(int toAdd, int maximum)
|
public int add(int toAdd, int maximum) {
|
||||||
{
|
|
||||||
AddToNetworkEvent event = new AddToNetworkEvent(playerId.toString(), toAdd, maximum);
|
AddToNetworkEvent event = new AddToNetworkEvent(playerId.toString(), toAdd, maximum);
|
||||||
|
|
||||||
if (MinecraftForge.EVENT_BUS.post(event))
|
if (MinecraftForge.EVENT_BUS.post(event))
|
||||||
|
@ -56,15 +53,12 @@ public class SoulNetwork implements INBTSerializable<NBTTagCompound>
|
||||||
* @deprecated - Please use {@link #add(int, int)}
|
* @deprecated - Please use {@link #add(int, int)}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public int addLifeEssence(int toAdd, int maximum)
|
public int addLifeEssence(int toAdd, int maximum) {
|
||||||
{
|
|
||||||
return add(toAdd, maximum);
|
return add(toAdd, maximum);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int syphon(int syphon)
|
public int syphon(int syphon) {
|
||||||
{
|
if (getCurrentEssence() >= syphon) {
|
||||||
if (getCurrentEssence() >= syphon)
|
|
||||||
{
|
|
||||||
setCurrentEssence(getCurrentEssence() - syphon);
|
setCurrentEssence(getCurrentEssence() - syphon);
|
||||||
return syphon;
|
return syphon;
|
||||||
}
|
}
|
||||||
|
@ -72,15 +66,12 @@ public class SoulNetwork implements INBTSerializable<NBTTagCompound>
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean syphonAndDamage(EntityPlayer user, int toSyphon)
|
public boolean syphonAndDamage(EntityPlayer user, int toSyphon) {
|
||||||
{
|
if (user != null) {
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
if (user.getEntityWorld().isRemote)
|
if (user.getEntityWorld().isRemote)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!Strings.isNullOrEmpty(playerId.toString()))
|
if (!Strings.isNullOrEmpty(playerId.toString())) {
|
||||||
{
|
|
||||||
SoulNetworkEvent.ItemDrainNetworkEvent event = new SoulNetworkEvent.ItemDrainNetworkEvent(user, playerId.toString(), null, toSyphon);
|
SoulNetworkEvent.ItemDrainNetworkEvent event = new SoulNetworkEvent.ItemDrainNetworkEvent(user, playerId.toString(), null, toSyphon);
|
||||||
|
|
||||||
if (MinecraftForge.EVENT_BUS.post(event))
|
if (MinecraftForge.EVENT_BUS.post(event))
|
||||||
|
@ -103,8 +94,7 @@ public class SoulNetwork implements INBTSerializable<NBTTagCompound>
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void causeNausea()
|
public void causeNausea() {
|
||||||
{
|
|
||||||
if (getPlayer() != null)
|
if (getPlayer() != null)
|
||||||
getPlayer().addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 99));
|
getPlayer().addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 99));
|
||||||
}
|
}
|
||||||
|
@ -113,29 +103,21 @@ public class SoulNetwork implements INBTSerializable<NBTTagCompound>
|
||||||
* @deprecated - Please use {@link #causeNausea()}
|
* @deprecated - Please use {@link #causeNausea()}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void causeNauseaToPlayer()
|
public void causeNauseaToPlayer() {
|
||||||
{
|
|
||||||
causeNausea();
|
causeNausea();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hurtPlayer(EntityPlayer user, float syphon)
|
public void hurtPlayer(EntityPlayer user, float syphon) {
|
||||||
{
|
if (user != null) {
|
||||||
if (user != null)
|
if (syphon < 100 && syphon > 0) {
|
||||||
{
|
if (!user.capabilities.isCreativeMode) {
|
||||||
if (syphon < 100 && syphon > 0)
|
|
||||||
{
|
|
||||||
if (!user.capabilities.isCreativeMode)
|
|
||||||
{
|
|
||||||
user.hurtResistantTime = 0;
|
user.hurtResistantTime = 0;
|
||||||
user.attackEntityFrom(BloodMagicAPI.damageSource, 1.0F);
|
user.attackEntityFrom(BloodMagicAPI.damageSource, 1.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (syphon >= 100)
|
} else if (syphon >= 100) {
|
||||||
{
|
if (!user.capabilities.isCreativeMode) {
|
||||||
if (!user.capabilities.isCreativeMode)
|
for (int i = 0; i < ((syphon + 99) / 100); i++) {
|
||||||
{
|
|
||||||
for (int i = 0; i < ((syphon + 99) / 100); i++)
|
|
||||||
{
|
|
||||||
user.hurtResistantTime = 0;
|
user.hurtResistantTime = 0;
|
||||||
user.attackEntityFrom(BloodMagicAPI.damageSource, 1.0F);
|
user.attackEntityFrom(BloodMagicAPI.damageSource, 1.0F);
|
||||||
}
|
}
|
||||||
|
@ -144,8 +126,7 @@ public class SoulNetwork implements INBTSerializable<NBTTagCompound>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void markDirty()
|
private void markDirty() {
|
||||||
{
|
|
||||||
if (getParent() != null)
|
if (getParent() != null)
|
||||||
getParent().markDirty();
|
getParent().markDirty();
|
||||||
else
|
else
|
||||||
|
@ -153,39 +134,23 @@ public class SoulNetwork implements INBTSerializable<NBTTagCompound>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public EntityPlayer getPlayer()
|
public EntityPlayer getPlayer() {
|
||||||
{
|
|
||||||
if (cachedPlayer == null)
|
if (cachedPlayer == null)
|
||||||
cachedPlayer = PlayerHelper.getPlayerFromUUID(playerId);
|
cachedPlayer = PlayerHelper.getPlayerFromUUID(playerId);
|
||||||
|
|
||||||
return cachedPlayer;
|
return cachedPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SoulNetwork setCurrentEssence(int currentEssence)
|
public BMWorldSavedData getParent() {
|
||||||
{
|
return parent;
|
||||||
this.currentEssence = currentEssence;
|
|
||||||
markDirty();
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SoulNetwork setOrbTier(int orbTier)
|
public SoulNetwork setParent(BMWorldSavedData parent) {
|
||||||
{
|
|
||||||
this.orbTier = orbTier;
|
|
||||||
markDirty();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SoulNetwork setParent(BMWorldSavedData parent)
|
|
||||||
{
|
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
markDirty();
|
markDirty();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BMWorldSavedData getParent() {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityPlayer getCachedPlayer() {
|
public EntityPlayer getCachedPlayer() {
|
||||||
return cachedPlayer;
|
return cachedPlayer;
|
||||||
}
|
}
|
||||||
|
@ -198,15 +163,26 @@ public class SoulNetwork implements INBTSerializable<NBTTagCompound>
|
||||||
return currentEssence;
|
return currentEssence;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SoulNetwork setCurrentEssence(int currentEssence) {
|
||||||
|
this.currentEssence = currentEssence;
|
||||||
|
markDirty();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public int getOrbTier() {
|
public int getOrbTier() {
|
||||||
return orbTier;
|
return orbTier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SoulNetwork setOrbTier(int orbTier) {
|
||||||
|
this.orbTier = orbTier;
|
||||||
|
markDirty();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
// INBTSerializable
|
// INBTSerializable
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound serializeNBT()
|
public NBTTagCompound serializeNBT() {
|
||||||
{
|
|
||||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||||
tagCompound.setString("playerId", getPlayerId().toString());
|
tagCompound.setString("playerId", getPlayerId().toString());
|
||||||
tagCompound.setInteger("currentEssence", getCurrentEssence());
|
tagCompound.setInteger("currentEssence", getCurrentEssence());
|
||||||
|
@ -215,22 +191,19 @@ public class SoulNetwork implements INBTSerializable<NBTTagCompound>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deserializeNBT(NBTTagCompound nbt)
|
public void deserializeNBT(NBTTagCompound nbt) {
|
||||||
{
|
|
||||||
this.playerId = UUID.fromString(nbt.getString("playerId"));
|
this.playerId = UUID.fromString(nbt.getString("playerId"));
|
||||||
this.currentEssence = nbt.getInteger("currentEssence");
|
this.currentEssence = nbt.getInteger("currentEssence");
|
||||||
this.orbTier = nbt.getInteger("orbTier");
|
this.orbTier = nbt.getInteger("orbTier");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SoulNetwork fromNBT(NBTTagCompound tagCompound)
|
public static SoulNetwork fromNBT(NBTTagCompound tagCompound) {
|
||||||
{
|
|
||||||
SoulNetwork soulNetwork = new SoulNetwork();
|
SoulNetwork soulNetwork = new SoulNetwork();
|
||||||
soulNetwork.deserializeNBT(tagCompound);
|
soulNetwork.deserializeNBT(tagCompound);
|
||||||
return soulNetwork;
|
return soulNetwork;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SoulNetwork newEmpty(UUID uuid)
|
public static SoulNetwork newEmpty(UUID uuid) {
|
||||||
{
|
|
||||||
SoulNetwork network = new SoulNetwork();
|
SoulNetwork network = new SoulNetwork();
|
||||||
network.playerId = uuid;
|
network.playerId = uuid;
|
||||||
return network;
|
return network;
|
||||||
|
|
|
@ -5,15 +5,12 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
public class DemonWillHolder
|
public class DemonWillHolder {
|
||||||
{
|
|
||||||
public HashMap<EnumDemonWillType, Double> willMap = new HashMap<EnumDemonWillType, Double>();
|
public HashMap<EnumDemonWillType, Double> willMap = new HashMap<EnumDemonWillType, Double>();
|
||||||
|
|
||||||
public double addWill(EnumDemonWillType type, double amount, double max)
|
public double addWill(EnumDemonWillType type, double amount, double max) {
|
||||||
{
|
|
||||||
double current = 0;
|
double current = 0;
|
||||||
if (willMap.containsKey(type))
|
if (willMap.containsKey(type)) {
|
||||||
{
|
|
||||||
current = willMap.get(type);
|
current = willMap.get(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,29 +20,22 @@ public class DemonWillHolder
|
||||||
return added;
|
return added;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addWill(EnumDemonWillType type, double amount)
|
public void addWill(EnumDemonWillType type, double amount) {
|
||||||
{
|
if (willMap.containsKey(type)) {
|
||||||
if (willMap.containsKey(type))
|
|
||||||
{
|
|
||||||
willMap.put(type, amount + willMap.get(type));
|
willMap.put(type, amount + willMap.get(type));
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
willMap.put(type, amount);
|
willMap.put(type, amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public double drainWill(EnumDemonWillType type, double amount)
|
public double drainWill(EnumDemonWillType type, double amount) {
|
||||||
{
|
if (willMap.containsKey(type)) {
|
||||||
if (willMap.containsKey(type))
|
|
||||||
{
|
|
||||||
double current = willMap.get(type);
|
double current = willMap.get(type);
|
||||||
double reduced = Math.min(current, amount);
|
double reduced = Math.min(current, amount);
|
||||||
|
|
||||||
if (reduced >= current)
|
if (reduced >= current) {
|
||||||
{
|
|
||||||
willMap.remove(type);
|
willMap.remove(type);
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
willMap.put(type, current - reduced);
|
willMap.put(type, current - reduced);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,45 +45,37 @@ public class DemonWillHolder
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getWill(EnumDemonWillType type)
|
public double getWill(EnumDemonWillType type) {
|
||||||
{
|
if (willMap.containsKey(type)) {
|
||||||
if (willMap.containsKey(type))
|
|
||||||
{
|
|
||||||
return willMap.get(type);
|
return willMap.get(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readFromNBT(NBTTagCompound tag, String key)
|
public void readFromNBT(NBTTagCompound tag, String key) {
|
||||||
{
|
|
||||||
NBTTagCompound willTag = tag.getCompoundTag(key);
|
NBTTagCompound willTag = tag.getCompoundTag(key);
|
||||||
|
|
||||||
willMap.clear();
|
willMap.clear();
|
||||||
|
|
||||||
for (EnumDemonWillType type : EnumDemonWillType.values())
|
for (EnumDemonWillType type : EnumDemonWillType.values()) {
|
||||||
{
|
|
||||||
double amount = willTag.getDouble("EnumWill" + type.getName());
|
double amount = willTag.getDouble("EnumWill" + type.getName());
|
||||||
if (amount > 0)
|
if (amount > 0) {
|
||||||
{
|
|
||||||
willMap.put(type, amount);
|
willMap.put(type, amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeToNBT(NBTTagCompound tag, String key)
|
public void writeToNBT(NBTTagCompound tag, String key) {
|
||||||
{
|
|
||||||
NBTTagCompound willTag = new NBTTagCompound();
|
NBTTagCompound willTag = new NBTTagCompound();
|
||||||
for (Entry<EnumDemonWillType, Double> entry : willMap.entrySet())
|
for (Entry<EnumDemonWillType, Double> entry : willMap.entrySet()) {
|
||||||
{
|
|
||||||
willTag.setDouble("EnumWill" + entry.getKey().getName(), entry.getValue());
|
willTag.setDouble("EnumWill" + entry.getKey().getName(), entry.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
tag.setTag(key, willTag);
|
tag.setTag(key, willTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearWill()
|
public void clearWill() {
|
||||||
{
|
|
||||||
willMap.clear();
|
willMap.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
package WayofTime.bloodmagic.api.soul;
|
package WayofTime.bloodmagic.api.soul;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import net.minecraft.util.IStringSerializable;
|
import net.minecraft.util.IStringSerializable;
|
||||||
|
|
||||||
public enum EnumDemonWillType implements IStringSerializable
|
import java.util.Locale;
|
||||||
{
|
|
||||||
|
public enum EnumDemonWillType implements IStringSerializable {
|
||||||
DEFAULT("default"),
|
DEFAULT("default"),
|
||||||
CORROSIVE("corrosive"),
|
CORROSIVE("corrosive"),
|
||||||
DESTRUCTIVE("destructive"),
|
DESTRUCTIVE("destructive"),
|
||||||
|
@ -14,20 +13,17 @@ public enum EnumDemonWillType implements IStringSerializable
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
|
|
||||||
EnumDemonWillType(String name)
|
EnumDemonWillType(String name) {
|
||||||
{
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
|
||||||
return name().toLowerCase(Locale.ENGLISH);
|
return name().toLowerCase(Locale.ENGLISH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
|
||||||
return this.toString();
|
return this.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,11 @@ package WayofTime.bloodmagic.api.soul;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public interface IDemonWill
|
public interface IDemonWill {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Obtains the amount of Will an ItemStack contains.
|
* Obtains the amount of Will an ItemStack contains.
|
||||||
*
|
*
|
||||||
* @param willStack
|
* @param willStack - The stack to retrieve the Will from
|
||||||
* - The stack to retrieve the Will from
|
|
||||||
*
|
|
||||||
* @return - The amount of Will an ItemStack contains
|
* @return - The amount of Will an ItemStack contains
|
||||||
*/
|
*/
|
||||||
double getWill(EnumDemonWillType type, ItemStack willStack);
|
double getWill(EnumDemonWillType type, ItemStack willStack);
|
||||||
|
@ -19,11 +16,9 @@ public interface IDemonWill
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the amount of Will in a given ItemStack.
|
* Sets the amount of Will in a given ItemStack.
|
||||||
*
|
*
|
||||||
* @param willStack
|
* @param willStack - The ItemStack of the Will
|
||||||
* - The ItemStack of the Will
|
* @param will - The amount of will to set the stack to
|
||||||
* @param will
|
|
||||||
* - The amount of will to set the stack to
|
|
||||||
*/
|
*/
|
||||||
void setWill(EnumDemonWillType type, ItemStack willStack, double will);
|
void setWill(EnumDemonWillType type, ItemStack willStack, double will);
|
||||||
|
|
||||||
|
@ -33,12 +28,9 @@ public interface IDemonWill
|
||||||
/**
|
/**
|
||||||
* Drains the demonic will from the willStack. If all of the will is
|
* Drains the demonic will from the willStack. If all of the will is
|
||||||
* drained, the willStack will be removed.
|
* drained, the willStack will be removed.
|
||||||
*
|
*
|
||||||
* @param willStack
|
* @param willStack - The ItemStack of the will
|
||||||
* - The ItemStack of the will
|
* @param drainAmount - The amount of Will to drain
|
||||||
* @param drainAmount
|
|
||||||
* - The amount of Will to drain
|
|
||||||
*
|
|
||||||
* @return The amount of will drained.
|
* @return The amount of will drained.
|
||||||
*/
|
*/
|
||||||
double drainWill(EnumDemonWillType type, ItemStack willStack, double drainAmount);
|
double drainWill(EnumDemonWillType type, ItemStack willStack, double drainAmount);
|
||||||
|
@ -49,12 +41,9 @@ public interface IDemonWill
|
||||||
/**
|
/**
|
||||||
* Creates a new ItemStack with the specified number of will. Implementation
|
* Creates a new ItemStack with the specified number of will. Implementation
|
||||||
* should respect the number requested.
|
* should respect the number requested.
|
||||||
*
|
*
|
||||||
* @param meta
|
* @param meta - The meta of the ItemStack to create
|
||||||
* - The meta of the ItemStack to create
|
* @param number - The amount of Will to create the Stack with.
|
||||||
* @param number
|
|
||||||
* - The amount of Will to create the Stack with.
|
|
||||||
*
|
|
||||||
* @return - An ItemStack with the set amount of Will
|
* @return - An ItemStack with the set amount of Will
|
||||||
*/
|
*/
|
||||||
ItemStack createWill(int meta, double number);
|
ItemStack createWill(int meta, double number);
|
||||||
|
|
|
@ -2,10 +2,8 @@ package WayofTime.bloodmagic.api.soul;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement this interface on a block that can accept and store Demonic Will.
|
* Implement this interface on a block that can accept and store Demonic Will.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface IDemonWillConduit
|
public interface IDemonWillConduit {
|
||||||
{
|
|
||||||
int getWeight();
|
int getWeight();
|
||||||
|
|
||||||
double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill);
|
double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill);
|
||||||
|
|
|
@ -2,23 +2,18 @@ package WayofTime.bloodmagic.api.soul;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public interface IDemonWillGem
|
public interface IDemonWillGem {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param willGemStack - The ItemStack for this demon will gem.
|
||||||
* @param willGemStack
|
* @param willStack - The ItemStack for the will. Item should extend IDemonWill
|
||||||
* - The ItemStack for this demon will gem.
|
|
||||||
* @param willStack
|
|
||||||
* - The ItemStack for the will. Item should extend IDemonWill
|
|
||||||
* @return - The remainder willStack after the will has been absorbed into
|
* @return - The remainder willStack after the will has been absorbed into
|
||||||
* the gem. Return null if there is no will left in the stack.
|
* the gem. Return null if there is no will left in the stack.
|
||||||
*/
|
*/
|
||||||
ItemStack fillDemonWillGem(ItemStack willGemStack, ItemStack willStack);
|
ItemStack fillDemonWillGem(ItemStack willGemStack, ItemStack willStack);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of souls that are left in the soul gem. Returns a
|
* Returns the number of souls that are left in the soul gem. Returns a
|
||||||
* double because souls can be fractionally drained.
|
* double because souls can be fractionally drained.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
double getWill(EnumDemonWillType type, ItemStack willGemStack);
|
double getWill(EnumDemonWillType type, ItemStack willGemStack);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface IDemonWillWeapon
|
public interface IDemonWillWeapon {
|
||||||
{
|
|
||||||
List<ItemStack> getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting);
|
List<ItemStack> getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,11 @@ package WayofTime.bloodmagic.api.soul;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public interface IDiscreteDemonWill
|
public interface IDiscreteDemonWill {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Obtains the amount of Will an ItemStack contains.
|
* Obtains the amount of Will an ItemStack contains.
|
||||||
*
|
*
|
||||||
* @param soulStack
|
* @param soulStack - The stack to retrieve the Will from
|
||||||
* - The stack to retrieve the Will from
|
|
||||||
*
|
|
||||||
* @return - The amount of Will an ItemStack contains
|
* @return - The amount of Will an ItemStack contains
|
||||||
*/
|
*/
|
||||||
double getWill(ItemStack soulStack);
|
double getWill(ItemStack soulStack);
|
||||||
|
@ -18,32 +15,25 @@ public interface IDiscreteDemonWill
|
||||||
* Drains the demonic will from the willStack. If all of the will is
|
* Drains the demonic will from the willStack. If all of the will is
|
||||||
* drained, the willStack will be removed. Will only drain in discrete
|
* drained, the willStack will be removed. Will only drain in discrete
|
||||||
* amounts, determined by getDiscretization.
|
* amounts, determined by getDiscretization.
|
||||||
*
|
*
|
||||||
* @param willStack
|
* @param willStack - The ItemStack of the will
|
||||||
* - The ItemStack of the will
|
* @param drainAmount - The amount of Will to drain
|
||||||
* @param drainAmount
|
|
||||||
* - The amount of Will to drain
|
|
||||||
*
|
|
||||||
* @return The amount of will drained.
|
* @return The amount of will drained.
|
||||||
*/
|
*/
|
||||||
double drainWill(ItemStack willStack, double drainAmount);
|
double drainWill(ItemStack willStack, double drainAmount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the discrete number for this demonic will.
|
* Gets the discrete number for this demonic will.
|
||||||
*
|
*
|
||||||
* @param willStack
|
* @param willStack - The ItemStack of the will
|
||||||
* - The ItemStack of the will
|
|
||||||
*
|
|
||||||
* @return - The discrete number for the given stack.
|
* @return - The discrete number for the given stack.
|
||||||
*/
|
*/
|
||||||
double getDiscretization(ItemStack willStack);
|
double getDiscretization(ItemStack willStack);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtains the type of will this is.
|
* Obtains the type of will this is.
|
||||||
*
|
*
|
||||||
* @param willStack
|
* @param willStack - The ItemStack of the will
|
||||||
* - The ItemStack of the will
|
|
||||||
*
|
|
||||||
* @return - The type of will this is.
|
* @return - The type of will this is.
|
||||||
*/
|
*/
|
||||||
EnumDemonWillType getType(ItemStack willStack);
|
EnumDemonWillType getType(ItemStack willStack);
|
||||||
|
|
|
@ -10,30 +10,22 @@ import net.minecraft.util.NonNullList;
|
||||||
* Monster Souls and Soul Gems, etc. The Soul Network's helper methods are found
|
* Monster Souls and Soul Gems, etc. The Soul Network's helper methods are found
|
||||||
* in {@link WayofTime.bloodmagic.api.util.helper.NetworkHelper}
|
* in {@link WayofTime.bloodmagic.api.util.helper.NetworkHelper}
|
||||||
*/
|
*/
|
||||||
public class PlayerDemonWillHandler
|
public class PlayerDemonWillHandler {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Gets the total amount of Will a player contains in their inventory
|
* Gets the total amount of Will a player contains in their inventory
|
||||||
*
|
*
|
||||||
* @param type
|
* @param type - The type of Will to check for
|
||||||
* - The type of Will to check for
|
* @param player - The player to check the will of
|
||||||
* @param player
|
|
||||||
* - The player to check the will of
|
|
||||||
*
|
|
||||||
* @return - The amount of will the player contains
|
* @return - The amount of will the player contains
|
||||||
*/
|
*/
|
||||||
public static double getTotalDemonWill(EnumDemonWillType type, EntityPlayer player)
|
public static double getTotalDemonWill(EnumDemonWillType type, EntityPlayer player) {
|
||||||
{
|
|
||||||
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
||||||
double souls = 0;
|
double souls = 0;
|
||||||
|
|
||||||
for (ItemStack stack : inventory)
|
for (ItemStack stack : inventory) {
|
||||||
{
|
if (stack.getItem() instanceof IDemonWill && ((IDemonWill) stack.getItem()).getType(stack) == type) {
|
||||||
if (stack.getItem() instanceof IDemonWill && ((IDemonWill) stack.getItem()).getType(stack) == type)
|
|
||||||
{
|
|
||||||
souls += ((IDemonWill) stack.getItem()).getWill(type, stack);
|
souls += ((IDemonWill) stack.getItem()).getWill(type, stack);
|
||||||
} else if (stack.getItem() instanceof IDemonWillGem)
|
} else if (stack.getItem() instanceof IDemonWillGem) {
|
||||||
{
|
|
||||||
souls += ((IDemonWillGem) stack.getItem()).getWill(type, stack);
|
souls += ((IDemonWillGem) stack.getItem()).getWill(type, stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,16 +33,13 @@ public class PlayerDemonWillHandler
|
||||||
return souls;
|
return souls;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EnumDemonWillType getLargestWillType(EntityPlayer player)
|
public static EnumDemonWillType getLargestWillType(EntityPlayer player) {
|
||||||
{
|
|
||||||
EnumDemonWillType type = EnumDemonWillType.DEFAULT;
|
EnumDemonWillType type = EnumDemonWillType.DEFAULT;
|
||||||
double max = getTotalDemonWill(type, player);
|
double max = getTotalDemonWill(type, player);
|
||||||
|
|
||||||
for (EnumDemonWillType testType : EnumDemonWillType.values())
|
for (EnumDemonWillType testType : EnumDemonWillType.values()) {
|
||||||
{
|
|
||||||
double value = getTotalDemonWill(testType, player);
|
double value = getTotalDemonWill(testType, player);
|
||||||
if (value > max)
|
if (value > max) {
|
||||||
{
|
|
||||||
type = testType;
|
type = testType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,23 +49,17 @@ public class PlayerDemonWillHandler
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the player's Tartaric gems are completely full.
|
* Checks if the player's Tartaric gems are completely full.
|
||||||
*
|
*
|
||||||
* @param type
|
* @param type - The type of Will to check for
|
||||||
* - The type of Will to check for
|
* @param player - The player to check the Will of
|
||||||
* @param player
|
|
||||||
* - The player to check the Will of
|
|
||||||
*
|
|
||||||
* @return - True if all Will containers are full, false if not.
|
* @return - True if all Will containers are full, false if not.
|
||||||
*/
|
*/
|
||||||
public static boolean isDemonWillFull(EnumDemonWillType type, EntityPlayer player)
|
public static boolean isDemonWillFull(EnumDemonWillType type, EntityPlayer player) {
|
||||||
{
|
|
||||||
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
||||||
|
|
||||||
boolean hasGem = false;
|
boolean hasGem = false;
|
||||||
for (ItemStack stack : inventory)
|
for (ItemStack stack : inventory) {
|
||||||
{
|
if (stack.getItem() instanceof IDemonWillGem) {
|
||||||
if (stack.getItem() instanceof IDemonWillGem)
|
|
||||||
{
|
|
||||||
hasGem = true;
|
hasGem = true;
|
||||||
if (((IDemonWillGem) stack.getItem()).getWill(type, stack) < ((IDemonWillGem) stack.getItem()).getMaxWill(type, stack))
|
if (((IDemonWillGem) stack.getItem()).getWill(type, stack) < ((IDemonWillGem) stack.getItem()).getMaxWill(type, stack))
|
||||||
return false;
|
return false;
|
||||||
|
@ -88,33 +71,26 @@ public class PlayerDemonWillHandler
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consumes Will from the inventory of a given player
|
* Consumes Will from the inventory of a given player
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player - The player to consume the will of
|
||||||
* - The player to consume the will of
|
* @param amount - The amount of will to consume
|
||||||
* @param amount
|
|
||||||
* - The amount of will to consume
|
|
||||||
*
|
|
||||||
* @return - The amount of will consumed.
|
* @return - The amount of will consumed.
|
||||||
*/
|
*/
|
||||||
public static double consumeDemonWill(EnumDemonWillType type, EntityPlayer player, double amount)
|
public static double consumeDemonWill(EnumDemonWillType type, EntityPlayer player, double amount) {
|
||||||
{
|
|
||||||
double consumed = 0;
|
double consumed = 0;
|
||||||
|
|
||||||
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
||||||
|
|
||||||
for (int i = 0; i < inventory.size(); i++)
|
for (int i = 0; i < inventory.size(); i++) {
|
||||||
{
|
|
||||||
if (consumed >= amount)
|
if (consumed >= amount)
|
||||||
return consumed;
|
return consumed;
|
||||||
|
|
||||||
ItemStack stack = inventory.get(i);
|
ItemStack stack = inventory.get(i);
|
||||||
if (stack.getItem() instanceof IDemonWill && ((IDemonWill) stack.getItem()).getType(stack) == type)
|
if (stack.getItem() instanceof IDemonWill && ((IDemonWill) stack.getItem()).getType(stack) == type) {
|
||||||
{
|
|
||||||
consumed += ((IDemonWill) stack.getItem()).drainWill(type, stack, amount - consumed);
|
consumed += ((IDemonWill) stack.getItem()).drainWill(type, stack, amount - consumed);
|
||||||
if (((IDemonWill) stack.getItem()).getWill(type, stack) <= 0)
|
if (((IDemonWill) stack.getItem()).getWill(type, stack) <= 0)
|
||||||
inventory.set(i, ItemStack.EMPTY);
|
inventory.set(i, ItemStack.EMPTY);
|
||||||
} else if (stack.getItem() instanceof IDemonWillGem)
|
} else if (stack.getItem() instanceof IDemonWillGem) {
|
||||||
{
|
|
||||||
consumed += ((IDemonWillGem) stack.getItem()).drainWill(type, stack, amount - consumed, true);
|
consumed += ((IDemonWillGem) stack.getItem()).drainWill(type, stack, amount - consumed, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,25 +101,19 @@ public class PlayerDemonWillHandler
|
||||||
/**
|
/**
|
||||||
* Adds an IDemonWill contained in an ItemStack to one of the Soul Gems in
|
* Adds an IDemonWill contained in an ItemStack to one of the Soul Gems in
|
||||||
* the player's inventory.
|
* the player's inventory.
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player - The player to add will to
|
||||||
* - The player to add will to
|
* @param willStack - ItemStack that contains an IDemonWill to be added
|
||||||
* @param willStack
|
|
||||||
* - ItemStack that contains an IDemonWill to be added
|
|
||||||
*
|
|
||||||
* @return - The modified willStack
|
* @return - The modified willStack
|
||||||
*/
|
*/
|
||||||
public static ItemStack addDemonWill(EntityPlayer player, ItemStack willStack)
|
public static ItemStack addDemonWill(EntityPlayer player, ItemStack willStack) {
|
||||||
{
|
|
||||||
if (willStack.isEmpty())
|
if (willStack.isEmpty())
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
|
|
||||||
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
||||||
|
|
||||||
for (ItemStack stack : inventory)
|
for (ItemStack stack : inventory) {
|
||||||
{
|
if (stack.getItem() instanceof IDemonWillGem) {
|
||||||
if (stack.getItem() instanceof IDemonWillGem)
|
|
||||||
{
|
|
||||||
ItemStack newStack = ((IDemonWillGem) stack.getItem()).fillDemonWillGem(stack, willStack);
|
ItemStack newStack = ((IDemonWillGem) stack.getItem()).fillDemonWillGem(stack, willStack);
|
||||||
if (newStack.isEmpty())
|
if (newStack.isEmpty())
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
|
@ -156,25 +126,18 @@ public class PlayerDemonWillHandler
|
||||||
/**
|
/**
|
||||||
* Adds an IDiscreteDemonWill contained in an ItemStack to one of the Soul
|
* Adds an IDiscreteDemonWill contained in an ItemStack to one of the Soul
|
||||||
* Gems in the player's inventory.
|
* Gems in the player's inventory.
|
||||||
*
|
*
|
||||||
* @param type
|
* @param type - The type of Will to add
|
||||||
* - The type of Will to add
|
* @param player - The player to check the Will of
|
||||||
* @param player
|
* @param amount - The amount of will to add
|
||||||
* - The player to check the Will of
|
|
||||||
* @param amount
|
|
||||||
* - The amount of will to add
|
|
||||||
*
|
|
||||||
* @return - The amount of will added
|
* @return - The amount of will added
|
||||||
*/
|
*/
|
||||||
public static double addDemonWill(EnumDemonWillType type, EntityPlayer player, double amount)
|
public static double addDemonWill(EnumDemonWillType type, EntityPlayer player, double amount) {
|
||||||
{
|
|
||||||
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
||||||
double remaining = amount;
|
double remaining = amount;
|
||||||
|
|
||||||
for (ItemStack stack : inventory)
|
for (ItemStack stack : inventory) {
|
||||||
{
|
if (stack.getItem() instanceof IDemonWillGem) {
|
||||||
if (stack.getItem() instanceof IDemonWillGem)
|
|
||||||
{
|
|
||||||
remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining, true);
|
remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining, true);
|
||||||
if (remaining <= 0)
|
if (remaining <= 0)
|
||||||
break;
|
break;
|
||||||
|
@ -187,27 +150,19 @@ public class PlayerDemonWillHandler
|
||||||
/**
|
/**
|
||||||
* Adds an IDiscreteDemonWill contained in an ItemStack to one of the Soul
|
* Adds an IDiscreteDemonWill contained in an ItemStack to one of the Soul
|
||||||
* Gems in the player's inventory while ignoring a specified stack.
|
* Gems in the player's inventory while ignoring a specified stack.
|
||||||
*
|
*
|
||||||
* @param type
|
* @param type - The type of Will to add
|
||||||
* - The type of Will to add
|
* @param player - The player to check the Will of
|
||||||
* @param player
|
* @param amount - The amount of will to add
|
||||||
* - The player to check the Will of
|
* @param ignored - A stack to ignore
|
||||||
* @param amount
|
|
||||||
* - The amount of will to add
|
|
||||||
* @param ignored
|
|
||||||
* - A stack to ignore
|
|
||||||
*
|
|
||||||
* @return - The amount of will added
|
* @return - The amount of will added
|
||||||
*/
|
*/
|
||||||
public static double addDemonWill(EnumDemonWillType type, EntityPlayer player, double amount, ItemStack ignored)
|
public static double addDemonWill(EnumDemonWillType type, EntityPlayer player, double amount, ItemStack ignored) {
|
||||||
{
|
|
||||||
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
||||||
double remaining = amount;
|
double remaining = amount;
|
||||||
|
|
||||||
for (ItemStack stack : inventory)
|
for (ItemStack stack : inventory) {
|
||||||
{
|
if (!stack.equals(ignored) && stack.getItem() instanceof IDemonWillGem) {
|
||||||
if (!stack.equals(ignored) && stack.getItem() instanceof IDemonWillGem)
|
|
||||||
{
|
|
||||||
remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining, true);
|
remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining, true);
|
||||||
|
|
||||||
if (remaining <= 0)
|
if (remaining <= 0)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue