Added new LocalRitualStorage methods, to allow rituals to store data more fluidly.

This commit is contained in:
WayofTime 2015-01-14 21:44:59 -05:00
parent ac5a20d5b2
commit fd330233dd
12 changed files with 361 additions and 38 deletions

View file

@ -136,6 +136,7 @@ import WayofTime.alchemicalWizardry.common.potion.PotionReciprocation;
import WayofTime.alchemicalWizardry.common.potion.PotionSoulFray;
import WayofTime.alchemicalWizardry.common.potion.PotionSoulHarden;
import WayofTime.alchemicalWizardry.common.renderer.AlchemyCircleRenderer;
import WayofTime.alchemicalWizardry.common.rituals.RitualEffectAlphaPact;
import WayofTime.alchemicalWizardry.common.rituals.RitualEffectAnimalGrowth;
import WayofTime.alchemicalWizardry.common.rituals.RitualEffectAutoAlchemy;
import WayofTime.alchemicalWizardry.common.rituals.RitualEffectBiomeChanger;
@ -159,6 +160,7 @@ import WayofTime.alchemicalWizardry.common.rituals.RitualEffectLava;
import WayofTime.alchemicalWizardry.common.rituals.RitualEffectLeap;
import WayofTime.alchemicalWizardry.common.rituals.RitualEffectLifeConduit;
import WayofTime.alchemicalWizardry.common.rituals.RitualEffectMagnetic;
import WayofTime.alchemicalWizardry.common.rituals.RitualEffectOmegaStalling;
import WayofTime.alchemicalWizardry.common.rituals.RitualEffectOmegaTest;
import WayofTime.alchemicalWizardry.common.rituals.RitualEffectSoulBound;
import WayofTime.alchemicalWizardry.common.rituals.RitualEffectSpawnWard;
@ -1278,6 +1280,8 @@ public class AlchemicalWizardry
Rituals.registerRitual("AW030FullStomach", 1, 100000, new RitualEffectFullStomach(), "Requiem of the Satiated Stomach", new AlchemyCircleRenderer(new ResourceLocation("alchemicalwizardry:textures/models/SimpleTransCircle.png"), 0, 0, 0, 255, 0, 0.501, 0.501, 0, 1.5, false));
Rituals.registerRitual("AW031Convocation",isDemonRitualCreativeOnly ? 10 : 2, 15000000, new RitualEffectDemonPortal(), "Convocation of the Damned", new AlchemyCircleRenderer(new ResourceLocation("alchemicalwizardry:textures/models/TransCircleDemon.png"), 220, 22, 22, 255, 0, 0.501, 0.501, 0, 5, false));
Rituals.registerRitual("AW032", 1, 100, new RitualEffectOmegaTest(), "Symmetry of the Omega");
Rituals.registerRitual("AW033", 2, 100, new RitualEffectOmegaStalling(), "Omega Stalling");
Rituals.registerRitual("AW034", 2, 100, new RitualEffectAlphaPact(), "Alpha Pact");
//Rituals.registerRitual(1,100,new RitualEffectApiaryOverclock(),"Apiary Overclock"));
}

View file

@ -37,4 +37,8 @@ public interface IMasterRitualStone extends ISegmentedReagentHandler
public boolean areTanksEmpty();
public int getRunningTime();
public LocalRitualStorage getLocalStorage();
public void setLocalStorage(LocalRitualStorage storage);
}

View file

@ -0,0 +1,21 @@
package WayofTime.alchemicalWizardry.api.rituals;
import net.minecraft.nbt.NBTTagCompound;
/**
* This class is used to pass ritual-specific data into the RitualEffect from the containing Master Ritual Stone. This is basically used as auxillarary storage,
* for when simply storing to NBT becomes... difficult.
*
*/
public class LocalRitualStorage
{
public void writeToNBT(NBTTagCompound tag)
{
}
public void readFromNBT(NBTTagCompound tag)
{
}
}

View file

@ -1,5 +1,6 @@
package WayofTime.alchemicalWizardry.api.rituals;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
@ -53,4 +54,37 @@ public abstract class RitualEffect
return false;
}
public LocalRitualStorage getNewLocalStorage()
{
return null;
}
public void addOffsetRunes(ArrayList<RitualComponent> ritualList, int off1, int off2, int y, int rune)
{
ritualList.add(new RitualComponent(off1, y, off2, rune));
ritualList.add(new RitualComponent(off2, y, off1, rune));
ritualList.add(new RitualComponent(off1, y, -off2, rune));
ritualList.add(new RitualComponent(-off2, y, off1, rune));
ritualList.add(new RitualComponent(-off1, y, off2, rune));
ritualList.add(new RitualComponent(off2, y, -off1, rune));
ritualList.add(new RitualComponent(-off1, y, -off2, rune));
ritualList.add(new RitualComponent(-off2, y, -off1, rune));
}
public void addCornerRunes(ArrayList<RitualComponent> ritualList, int off1, int y, int rune)
{
ritualList.add(new RitualComponent(off1, y, off1, rune));
ritualList.add(new RitualComponent(off1, y, -off1, rune));
ritualList.add(new RitualComponent(-off1, y, -off1, rune));
ritualList.add(new RitualComponent(-off1, y, off1, rune));
}
public void addParallelRunes(ArrayList<RitualComponent> ritualList, int off1, int y, int rune)
{
ritualList.add(new RitualComponent(off1, y, 0, rune));
ritualList.add(new RitualComponent(-off1, y, 0, rune));
ritualList.add(new RitualComponent(0, y, -off1, rune));
ritualList.add(new RitualComponent(0, y, off1, rune));
}
}

View file

@ -374,4 +374,22 @@ public class Rituals
return null;
}
public static LocalRitualStorage getLocalStorage(String ritualID)
{
if (ritualMap.containsKey(ritualID))
{
Rituals ritual = ritualMap.get(ritualID);
if (ritual != null)
{
RitualEffect eff = ritual.effect;
if(eff != null)
{
return eff.getNewLocalStorage();
}
}
}
return null;
}
}

View file

@ -130,7 +130,7 @@ public class AlchemicalWizardryEventHooks
}
@SubscribeEvent
public void omegaUpdateHpEvent(LivingUpdateEvent event)
public void omegaUpdateReagentAndHpEvent(LivingUpdateEvent event)
{
if(event.entityLiving instanceof EntityPlayer && !event.entityLiving.worldObj.isRemote)
{
@ -183,15 +183,21 @@ public class AlchemicalWizardryEventHooks
}
//Consumes the amount
float costPerTick = parad.getCostPerTickOfUse(player);
if(reagentAmount > costPerTick)
if(parad.doDrainReagent(player))
{
hasReagentChanged = true;
reagentAmount = Math.max(0, reagentAmount - costPerTick);
}else
{
hasReagentChanged = true;
reagentAmount = 0;
if(reagentAmount > costPerTick)
{
hasReagentChanged = true;
reagentAmount = Math.max(0, reagentAmount - costPerTick);
}else
{
hasReagentChanged = true;
reagentAmount = 0;
}
}
hasReagentChanged = true;
}
if(reagentAmount <= 0)

View file

@ -39,10 +39,15 @@ public abstract class OmegaArmour extends BoundArmour
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack)
{
super.onArmorTick(world, player, itemStack);
if(this.armorType == 1)
{
paradigm.onUpdate(world, player, itemStack);
int duration = this.getOmegaStallingDuration(itemStack);
if(duration > 0)
{
this.setOmegaStallingDuration(itemStack, duration - 1);
}
}
}
@ -185,4 +190,33 @@ public abstract class OmegaArmour extends BoundArmour
paradigm.onOmegaKeyPressed(player, stack);
}
}
public void setOmegaStallingDuration(ItemStack stack, int duration)
{
NBTTagCompound tag = stack.getTagCompound();
if(tag == null)
{
tag = new NBTTagCompound();
stack.setTagCompound(tag);
}
tag.setInteger("OmegaStallDuration", duration);
}
public int getOmegaStallingDuration(ItemStack stack)
{
NBTTagCompound tag = stack.getTagCompound();
if(tag == null)
{
tag = new NBTTagCompound();
stack.setTagCompound(tag);
}
return tag.getInteger("OmegaStallDuration");
}
public boolean hasOmegaStalling(ItemStack stack)
{
return this.getOmegaStallingDuration(stack) > 0;
}
}

View file

@ -69,11 +69,39 @@ public class OmegaParadigm
return 50;
}
public boolean setOmegaStalling(EntityPlayer player, int duration)
{
ItemStack[] armours = player.inventory.armorInventory;
ItemStack chestStack = armours[2];
if(chestStack != null && chestStack.getItem() == this.chestPiece)
{
((OmegaArmour)chestStack.getItem()).setOmegaStallingDuration(chestStack, duration);
return true;
}
return false;
}
public float getCostPerTickOfUse(EntityPlayer player)
{
return 1;
}
public boolean doDrainReagent(EntityPlayer player)
{
ItemStack[] armours = player.inventory.armorInventory;
ItemStack chestStack = armours[2];
if(chestStack != null && chestStack.getItem() == this.chestPiece)
{
return !((OmegaArmour)chestStack.getItem()).hasOmegaStalling(chestStack);
}
return true;
}
public boolean isPlayerWearingFullSet(EntityPlayer player)
{
ItemStack[] armours = player.inventory.armorInventory;

View file

@ -0,0 +1,70 @@
package WayofTime.alchemicalWizardry.common.rituals;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
import WayofTime.alchemicalWizardry.api.rituals.RitualComponent;
import WayofTime.alchemicalWizardry.api.rituals.RitualEffect;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
public class RitualEffectAlphaPact extends RitualEffect
{
@Override
public void performEffect(IMasterRitualStone ritualStone)
{
String owner = ritualStone.getOwner();
int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
World world = ritualStone.getWorld();
int x = ritualStone.getXCoord();
int y = ritualStone.getYCoord();
int z = ritualStone.getZCoord();
if (world.getWorldTime() % 20 != 0)
{
return;
}
}
@Override
public int getCostPerRefresh()
{
return 1;
}
@Override
public List<RitualComponent> getRitualComponentList()
{
ArrayList<RitualComponent> omegaRitual = new ArrayList();
this.addCornerRunes(omegaRitual, 1, 0, RitualComponent.BLANK);
this.addOffsetRunes(omegaRitual, 2, 1, 0, RitualComponent.DUSK);
this.addParallelRunes(omegaRitual, 4, 0, RitualComponent.WATER);
this.addParallelRunes(omegaRitual, 5, 0, RitualComponent.EARTH);
this.addCornerRunes(omegaRitual, 4, 0, RitualComponent.AIR);
this.addOffsetRunes(omegaRitual, 3, 4, 0, RitualComponent.AIR);
this.addParallelRunes(omegaRitual, 5, 1, RitualComponent.WATER);
this.addParallelRunes(omegaRitual, 5, 2, RitualComponent.EARTH);
this.addParallelRunes(omegaRitual, 4, 3, RitualComponent.WATER);
this.addParallelRunes(omegaRitual, 4, 4, RitualComponent.WATER);
this.addParallelRunes(omegaRitual, 3, 5, RitualComponent.BLANK);
this.addParallelRunes(omegaRitual, 2, 5, RitualComponent.FIRE);
this.addParallelRunes(omegaRitual, 1, 5, RitualComponent.DUSK);
this.addOffsetRunes(omegaRitual, 5, 3, 1, RitualComponent.WATER);
this.addOffsetRunes(omegaRitual, 6, 3, 1, RitualComponent.DUSK);
this.addOffsetRunes(omegaRitual, 6, 4, 1, RitualComponent.FIRE);
this.addOffsetRunes(omegaRitual, 6, 5, 1, RitualComponent.BLANK);
this.addCornerRunes(omegaRitual, 4, 2, RitualComponent.FIRE);
this.addCornerRunes(omegaRitual, 4, 3, RitualComponent.AIR);
this.addCornerRunes(omegaRitual, 4, 4, RitualComponent.AIR);
this.addOffsetRunes(omegaRitual, 4, 3, 2, RitualComponent.BLANK);
this.addCornerRunes(omegaRitual, 3, 5, RitualComponent.EARTH);
this.addOffsetRunes(omegaRitual, 2, 3, 5, RitualComponent.AIR);
return omegaRitual;
}
}

View file

@ -181,32 +181,4 @@ public class RitualEffectDemonPortal extends RitualEffect
return demonRitual;
}
public void addOffsetRunes(ArrayList<RitualComponent> ritualList, int off1, int off2, int y, int rune)
{
ritualList.add(new RitualComponent(off1, y, off2, rune));
ritualList.add(new RitualComponent(off2, y, off1, rune));
ritualList.add(new RitualComponent(off1, y, -off2, rune));
ritualList.add(new RitualComponent(-off2, y, off1, rune));
ritualList.add(new RitualComponent(-off1, y, off2, rune));
ritualList.add(new RitualComponent(off2, y, -off1, rune));
ritualList.add(new RitualComponent(-off1, y, -off2, rune));
ritualList.add(new RitualComponent(-off2, y, -off1, rune));
}
public void addCornerRunes(ArrayList<RitualComponent> ritualList, int off1, int y, int rune)
{
ritualList.add(new RitualComponent(off1, y, off1, rune));
ritualList.add(new RitualComponent(off1, y, -off1, rune));
ritualList.add(new RitualComponent(-off1, y, -off1, rune));
ritualList.add(new RitualComponent(-off1, y, off1, rune));
}
public void addParallelRunes(ArrayList<RitualComponent> ritualList, int off1, int y, int rune)
{
ritualList.add(new RitualComponent(off1, y, 0, rune));
ritualList.add(new RitualComponent(-off1, y, 0, rune));
ritualList.add(new RitualComponent(0, y, -off1, rune));
ritualList.add(new RitualComponent(0, y, off1, rune));
}
}

View file

@ -0,0 +1,103 @@
package WayofTime.alchemicalWizardry.common.rituals;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityBeacon;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
import WayofTime.alchemicalWizardry.api.rituals.RitualComponent;
import WayofTime.alchemicalWizardry.api.rituals.RitualEffect;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import WayofTime.alchemicalWizardry.api.spell.APISpellHelper;
import WayofTime.alchemicalWizardry.common.omega.OmegaParadigm;
import WayofTime.alchemicalWizardry.common.omega.OmegaRegistry;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
public class RitualEffectOmegaStalling extends RitualEffect
{
@Override
public void performEffect(IMasterRitualStone ritualStone)
{
String owner = ritualStone.getOwner();
int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
World world = ritualStone.getWorld();
int x = ritualStone.getXCoord();
int y = ritualStone.getYCoord();
int z = ritualStone.getZCoord();
if (world.getWorldTime() % 20 != 0)
{
return;
}
TileEntity tile = world.getTileEntity(x, y + 5, z);
if(tile instanceof TileEntityBeacon)
{
int levels = ((TileEntityBeacon) tile).getLevels();
if(levels >= 4)
{
int horizontalRadius = 100;
int verticalRadius = 100;
List<EntityPlayer> playerList = SpellHelper.getPlayersInRange(world, x + 0.5, y + 0.5, z + 0.5, horizontalRadius, verticalRadius);
for(EntityPlayer player : playerList)
{
if(SoulNetworkHandler.canSyphonFromOnlyNetwork(owner, getCostPerRefresh()))
{
Reagent reagent = APISpellHelper.getPlayerReagentType(player);
OmegaParadigm parad = OmegaRegistry.getParadigmForReagent(reagent);
if(parad != null)
{
parad.setOmegaStalling(player, 30);
SoulNetworkHandler.syphonFromNetwork(owner, getCostPerRefresh());
}
}
}
}
}
}
@Override
public int getCostPerRefresh()
{
return 5000;
}
@Override
public List<RitualComponent> getRitualComponentList()
{
ArrayList<RitualComponent> omegaRitual = new ArrayList();
this.addCornerRunes(omegaRitual, 1, 0, RitualComponent.FIRE);
this.addOffsetRunes(omegaRitual, 2, 1, 0, RitualComponent.DUSK);
this.addParallelRunes(omegaRitual, 4, 0, RitualComponent.WATER);
this.addParallelRunes(omegaRitual, 5, 0, RitualComponent.EARTH);
this.addCornerRunes(omegaRitual, 4, 0, RitualComponent.AIR);
this.addOffsetRunes(omegaRitual, 3, 4, 0, RitualComponent.AIR);
this.addParallelRunes(omegaRitual, 5, 1, RitualComponent.WATER);
this.addParallelRunes(omegaRitual, 5, 2, RitualComponent.EARTH);
this.addParallelRunes(omegaRitual, 4, 3, RitualComponent.WATER);
this.addParallelRunes(omegaRitual, 4, 4, RitualComponent.WATER);
this.addParallelRunes(omegaRitual, 3, 5, RitualComponent.BLANK);
this.addParallelRunes(omegaRitual, 2, 5, RitualComponent.FIRE);
this.addParallelRunes(omegaRitual, 1, 5, RitualComponent.DUSK);
this.addOffsetRunes(omegaRitual, 5, 3, 1, RitualComponent.WATER);
this.addOffsetRunes(omegaRitual, 6, 3, 1, RitualComponent.DUSK);
this.addOffsetRunes(omegaRitual, 6, 4, 1, RitualComponent.FIRE);
this.addOffsetRunes(omegaRitual, 6, 5, 1, RitualComponent.BLANK);
this.addCornerRunes(omegaRitual, 4, 2, RitualComponent.FIRE);
this.addCornerRunes(omegaRitual, 4, 3, RitualComponent.AIR);
this.addCornerRunes(omegaRitual, 4, 4, RitualComponent.AIR);
this.addOffsetRunes(omegaRitual, 4, 3, 2, RitualComponent.BLANK);
this.addCornerRunes(omegaRitual, 3, 5, RitualComponent.EARTH);
this.addOffsetRunes(omegaRitual, 2, 3, 5, RitualComponent.AIR);
return omegaRitual;
}
}

View file

@ -26,6 +26,7 @@ import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack;
import WayofTime.alchemicalWizardry.api.event.RitualActivatedEvent;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
import WayofTime.alchemicalWizardry.api.rituals.LocalRitualStorage;
import WayofTime.alchemicalWizardry.api.rituals.RitualBreakMethod;
import WayofTime.alchemicalWizardry.api.rituals.Rituals;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
@ -42,6 +43,8 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
private int direction;
public boolean isRunning;
public int runningTime;
public LocalRitualStorage storage;
private NBTTagCompound customRitualTag;
@ -139,6 +142,15 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
}
customRitualTag = tag.getCompoundTag("customRitualTag");
LocalRitualStorage newStorage = Rituals.getLocalStorage(currentRitualString);
NBTTagCompound localStorageTag = tag.getCompoundTag("localStorage");
if(newStorage != null)
{
newStorage.readFromNBT(localStorageTag);
storage = newStorage;
}
}
@Override
@ -181,6 +193,10 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
tag.setTag("attunedTankMap", attunedTagList);
tag.setTag("customRitualTag", customRitualTag);
NBTTagCompound localStorageTag = new NBTTagCompound();
storage.writeToNBT(localStorageTag);
tag.setTag("localStorage", localStorageTag);
}
public void activateRitual(World world, int crystalLevel, ItemStack activationCrystal, EntityPlayer player, String crystalOwner)
@ -243,7 +259,7 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
if(drain > 0)
{
player.addChatMessage(new ChatComponentText("A rush of energy flows through the ritual!"));
for (int i = 0; i < 12; i++)
{
SpellHelper.sendIndexedParticleToAllAround(world, xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, 1, xCoord, yCoord, zCoord);
@ -265,6 +281,7 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
cooldown = Rituals.getInitialCooldown(testRitual);
var1 = 0;
currentRitualString = testRitual;
storage = Rituals.getLocalStorage(currentRitualString);
isActive = true;
isRunning = true;
direction = Rituals.getDirectionOfRitual(world, xCoord, yCoord, zCoord, testRitual);
@ -662,4 +679,16 @@ public class TEMasterStone extends TileEntity implements IMasterRitualStone
{
return this.runningTime;
}
@Override
public LocalRitualStorage getLocalStorage()
{
return storage;
}
@Override
public void setLocalStorage(LocalRitualStorage storage)
{
this.storage = storage;
}
}