Refactoring
This commit is contained in:
parent
fd330233dd
commit
56ccd3188d
76 changed files with 876 additions and 433 deletions
|
@ -0,0 +1,25 @@
|
|||
package WayofTime.alchemicalWizardry.common.rituals;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.rituals.LocalRitualStorage;
|
||||
import WayofTime.alchemicalWizardry.common.Int3;
|
||||
import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardDemon;
|
||||
|
||||
public class LocalStorageAlphaPact extends LocalRitualStorage
|
||||
{
|
||||
public static Set<IHoardDemon> hoardList = new HashSet();
|
||||
|
||||
public void thrallDemon(IHoardDemon demon)
|
||||
{
|
||||
if(demon instanceof IHoardDemon)
|
||||
{
|
||||
boolean enthrall = ((IHoardDemon) demon).thrallDemon(new Int3(this.xCoord, this.yCoord, this.zCoord));
|
||||
if(enthrall)
|
||||
{
|
||||
this.hoardList.add((IHoardDemon)demon);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,15 +2,24 @@ package WayofTime.alchemicalWizardry.common.rituals;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
|
||||
import WayofTime.alchemicalWizardry.api.rituals.LocalRitualStorage;
|
||||
import WayofTime.alchemicalWizardry.api.rituals.RitualComponent;
|
||||
import WayofTime.alchemicalWizardry.api.rituals.RitualEffect;
|
||||
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
|
||||
import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.EntityMinorDemonGrunt;
|
||||
import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardDemon;
|
||||
|
||||
public class RitualEffectAlphaPact extends RitualEffect
|
||||
{
|
||||
Random rand = new Random();
|
||||
|
||||
@Override
|
||||
public void performEffect(IMasterRitualStone ritualStone)
|
||||
{
|
||||
|
@ -26,8 +35,103 @@ public class RitualEffectAlphaPact extends RitualEffect
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
LocalRitualStorage stor = ritualStone.getLocalStorage();
|
||||
if(stor instanceof LocalStorageAlphaPact)
|
||||
{
|
||||
LocalStorageAlphaPact storage = (LocalStorageAlphaPact)stor;
|
||||
|
||||
Object[] demonList = storage.hoardList.toArray();
|
||||
|
||||
for(Object demon : demonList)
|
||||
{
|
||||
if(demon instanceof EntityLivingBase)
|
||||
{
|
||||
if(!((EntityLivingBase) demon).isEntityAlive())
|
||||
{
|
||||
System.out.println(storage.hoardList.remove(demon));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Hi!");
|
||||
|
||||
int summons = 0;
|
||||
|
||||
int horizontalRange = 25;
|
||||
int verticalRange = 20;
|
||||
|
||||
if(storage.hoardList.isEmpty())
|
||||
{
|
||||
IHoardDemon demon = this.getRandomDemonForStage(world, x, y, z, horizontalRange, verticalRange);
|
||||
if(demon instanceof EntityLivingBase)
|
||||
{
|
||||
world.spawnEntityInWorld((EntityLivingBase)demon);
|
||||
storage.thrallDemon(demon);
|
||||
}
|
||||
}else
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IHoardDemon getRandomDemonForStage(World world, int x, int y, int z, int horizontalRange, int verticalRange)
|
||||
{
|
||||
EntityLivingBase entityLiving = new EntityMinorDemonGrunt(world);
|
||||
|
||||
boolean isGood = false;
|
||||
for(int n=0; n<100; n++)
|
||||
{
|
||||
double newX = x + (rand.nextInt(horizontalRange) - horizontalRange) + 0.5;
|
||||
double newY = y + (double) (rand.nextInt((int) verticalRange));
|
||||
double newZ = z + (rand.nextInt(horizontalRange) - horizontalRange) + 0.5;
|
||||
|
||||
entityLiving.posX = newX;
|
||||
entityLiving.posY = newY;
|
||||
entityLiving.posZ = newZ;
|
||||
|
||||
int i = MathHelper.floor_double(entityLiving.posX);
|
||||
int j = MathHelper.floor_double(entityLiving.posY);
|
||||
int k = MathHelper.floor_double(entityLiving.posZ);
|
||||
Block l;
|
||||
|
||||
if (entityLiving.worldObj.blockExists(i, j, k))
|
||||
{
|
||||
boolean flag1 = false;
|
||||
|
||||
while (!flag1 && j > 0)
|
||||
{
|
||||
l = entityLiving.worldObj.getBlock(i, j - 1, k);
|
||||
|
||||
if (l != null && l.getMaterial().blocksMovement())
|
||||
{
|
||||
flag1 = true;
|
||||
} else
|
||||
{
|
||||
--entityLiving.posY;
|
||||
--j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(entityLiving.worldObj.getCollidingBoundingBoxes(entityLiving, entityLiving.boundingBox).isEmpty() && !entityLiving.worldObj.isAnyLiquid(entityLiving.boundingBox))
|
||||
{
|
||||
entityLiving.setPositionAndUpdate(newX, newY, newZ);
|
||||
isGood = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(isGood = false)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (IHoardDemon)entityLiving;
|
||||
}
|
||||
|
||||
public int spawnMoreDemons(LocalStorageAlphaPact storage)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,6 +139,11 @@ public class RitualEffectAlphaPact extends RitualEffect
|
|||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public LocalRitualStorage getNewLocalStorage()
|
||||
{
|
||||
return new LocalStorageAlphaPact();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RitualComponent> getRitualComponentList()
|
||||
|
@ -42,7 +151,7 @@ public class RitualEffectAlphaPact extends RitualEffect
|
|||
ArrayList<RitualComponent> omegaRitual = new ArrayList();
|
||||
|
||||
this.addCornerRunes(omegaRitual, 1, 0, RitualComponent.BLANK);
|
||||
this.addOffsetRunes(omegaRitual, 2, 1, 0, RitualComponent.DUSK);
|
||||
this.addOffsetRunes(omegaRitual, 2, 1, 0, RitualComponent.FIRE);
|
||||
this.addParallelRunes(omegaRitual, 4, 0, RitualComponent.WATER);
|
||||
this.addParallelRunes(omegaRitual, 5, 0, RitualComponent.EARTH);
|
||||
this.addCornerRunes(omegaRitual, 4, 0, RitualComponent.AIR);
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
package WayofTime.alchemicalWizardry.common.rituals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
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;
|
||||
import WayofTime.alchemicalWizardry.common.Int3;
|
||||
|
||||
public class RitualEffectItemRouting extends RitualEffect
|
||||
{
|
||||
Random rand = new Random();
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
int xBufOffset = 0;
|
||||
int yBufOffset = 1;
|
||||
int zBufOffset = 0;
|
||||
|
||||
TileEntity bufferTile = world.getTileEntity(x + xBufOffset, y + yBufOffset, z + zBufOffset);
|
||||
|
||||
if(!(bufferTile instanceof IInventory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IInventory bufferInventory = (IInventory)bufferTile;
|
||||
|
||||
for(int i=0; i<4; i++)
|
||||
{
|
||||
Int3 inputChest = this.getInputBufferChestLocation(i);
|
||||
TileEntity inputFocusInv = world.getTileEntity(x + inputChest.xCoord, y + inputChest.yCoord, z + inputChest.zCoord);
|
||||
if(inputFocusInv instanceof IInventory)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Int3 getInputBufferChestLocation(int number)
|
||||
{
|
||||
switch(number)
|
||||
{
|
||||
case 0:
|
||||
return new Int3(1, 0, 0);
|
||||
case 1:
|
||||
return new Int3(-1, 0, 0);
|
||||
case 2:
|
||||
return new Int3(0, 0, 1);
|
||||
case 3:
|
||||
return new Int3(0, 0, -1);
|
||||
}
|
||||
return new Int3(0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCostPerRefresh()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RitualComponent> getRitualComponentList()
|
||||
{
|
||||
ArrayList<RitualComponent> omegaRitual = new ArrayList();
|
||||
|
||||
this.addCornerRunes(omegaRitual, 1, 0, RitualComponent.BLANK);
|
||||
this.addOffsetRunes(omegaRitual, 2, 1, 0, RitualComponent.FIRE);
|
||||
this.addParallelRunes(omegaRitual, 4, 0, RitualComponent.WATER);
|
||||
this.addParallelRunes(omegaRitual, 5, 0, RitualComponent.EARTH);
|
||||
this.addCornerRunes(omegaRitual, 4, 0, RitualComponent.WATER);
|
||||
|
||||
return omegaRitual;
|
||||
}
|
||||
}
|
|
@ -103,7 +103,7 @@ public class RitualEffectUnbinding extends RitualEffect
|
|||
world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z + 5));
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x - 5, y + 1, z));
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x + 5, y + 1, z));
|
||||
NBTTagCompound itemTag = itemStack.stackTagCompound;
|
||||
NBTTagCompound itemTag = itemStack.getTagCompound();
|
||||
ItemStack[] inv = ((BoundArmour) itemStack.getItem()).getInternalInventory(itemStack);
|
||||
|
||||
if (inv != null)
|
||||
|
@ -130,7 +130,7 @@ public class RitualEffectUnbinding extends RitualEffect
|
|||
world.addWeatherEffect(new EntityLightningBolt(world, x, y + 1, z + 5));
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x - 5, y + 1, z));
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x + 5, y + 1, z));
|
||||
NBTTagCompound itemTag = itemStack.stackTagCompound;
|
||||
NBTTagCompound itemTag = itemStack.getTagCompound();
|
||||
ItemStack[] inv = ((SigilOfHolding) itemStack.getItem()).getInternalInventory(itemStack);
|
||||
|
||||
if (inv != null)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue