Added new LocalRitualStorage methods, to allow rituals to store data more fluidly.
This commit is contained in:
parent
ac5a20d5b2
commit
fd330233dd
12 changed files with 361 additions and 38 deletions
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue