Updated the books, worked more on the new self-sacrifice mechanics, allowed the teleposer to telepose entities across dimensions, changed the Focus of the Ellipsoid so that it now places blocks from a chest underneath the MRS.

This commit is contained in:
WayofTime 2015-05-04 14:16:58 -04:00
parent c71edfb937
commit f74e4993cf
15 changed files with 371 additions and 61 deletions

View file

@ -1,22 +1,24 @@
package WayofTime.alchemicalWizardry.common.rituals;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.api.Int3;
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.spell.complex.effect.SpellHelper;
import WayofTime.alchemicalWizardry.common.tileEntity.TESpectralBlock;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
public class RitualEffectEllipsoid extends RitualEffect
{
@ -60,42 +62,131 @@ public class RitualEffectEllipsoid extends RitualEffect
entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
} else
{
int refresh = 1000;
int j = (int) (world.getWorldTime() % (ySize * 2 + 1)) - ySize;
for (int i = -xSize; i <= xSize; i++)
tile = world.getTileEntity(x, y-1, z);
if(!(tile instanceof IInventory))
{
return;
}
ItemBlock placedBlock = null;
ItemStack stack = null;
int slot = 0;
IInventory inv = (IInventory)tile;
while(slot < inv.getSizeInventory())
{
stack = inv.getStackInSlot(slot);
if(stack == null)
{
slot++;
continue;
}
if(stack.getItem() instanceof ItemBlock)
{
placedBlock = (ItemBlock)stack.getItem();
break;
}
slot++;
}
if(placedBlock == null || stack == null || slot >= inv.getSizeInventory())
{
return;
}
int count = 10;
Int3 lastPos = this.getLastPosition(ritualStone.getCustomRitualTag());
int i = -xSize;
int j = -ySize;
int k = -zSize;
if(lastPos != null)
{
i = Math.min(xSize, Math.max(-xSize, lastPos.xCoord));
j = Math.min(ySize, Math.max(-ySize, lastPos.yCoord));
k = Math.min(zSize, Math.max(-zSize, lastPos.zCoord));
}
boolean incrementNext = false;
while(j <= ySize)
{
if(y + j < 0)
{
j++;
continue;
}
while(i <= xSize)
{
for (int k = -zSize; k <= zSize; k++)
while(k <= zSize)
{
if (Math.pow(i * (ySize - 0.50f) * (zSize - 0.50f), 2) + Math.pow(j * (xSize - 0.50f) * (zSize - 0.50f), 2) + Math.pow(k * (xSize - 0.50f) * (ySize - 0.50f), 2) <= Math.pow((xSize - 1 + 0.50f) * (ySize - 1 + 0.50f) * (zSize - 1 + 0.50f), 2))
{
k++;
continue;
}
if (Math.pow(i * (ySize + 0.50f) * (zSize + 0.50f), 2) + Math.pow(j * (xSize + 0.50f) * (zSize + 0.50f), 2) + Math.pow(k * (xSize + 0.50f) * (ySize + 0.50f), 2) >= Math.pow((xSize + 0.50f) * (ySize + 0.50f) * (zSize + 0.50f), 2))
{
k++;
continue;
}
if(incrementNext || count <= 0)
{
this.setLastPosition(ritualStone.getCustomRitualTag(), new Int3(i, j, k));
return;
}
count--;
Block block = world.getBlock(x + i, y + j, z + k);
if (block.isAir(world, x + i, y + j, z + k))
if (!block.isAir(world, x + i, y + j, z + k))
{
TESpectralBlock.createSpectralBlockAtLocation(world, x + i, y + j, z + k, refresh);
k++;
continue;
} else
{
TileEntity tile1 = world.getTileEntity(x + i, y + j, z + k);
if (tile instanceof TESpectralBlock)
//This is pulled from the ItemBlock's placing calls
int i1 = placedBlock.getMetadata(stack.getItemDamage());
int j1 = placedBlock.field_150939_a.onBlockPlaced(world, x + i, y + j, z + k, 0, 0, 0, 0, i1);
if (placedBlock.placeBlockAt(stack, null, world, x + i, y + j, z + k, 0, 0, 0, 0, j1))
{
((TESpectralBlock) tile1).resetDuration(refresh);
world.playSoundEffect((double)(x + i + 0.5F), (double)(y + j + 0.5F), (double)(z + k + 0.5F), placedBlock.field_150939_a.stepSound.func_150496_b(), (placedBlock.field_150939_a.stepSound.getVolume() + 1.0F) / 2.0F, placedBlock.field_150939_a.stepSound.getPitch() * 0.8F);
--stack.stackSize;
if(stack.stackSize <= 0)
{
inv.setInventorySlotContents(slot, null);
}
this.setLastPosition(ritualStone.getCustomRitualTag(), new Int3(i, j, k));
incrementNext = true;
SoulNetworkHandler.syphonFromNetwork(owner, cost);
}
}
// world.setBlock(x + i, y + j, z + k, Blocks.stone);
k++;
}
}
k = -zSize;
i++;
}
i = -xSize;
j++;
this.setLastPosition(ritualStone.getCustomRitualTag(), new Int3(i, j, k));
return;
}
SoulNetworkHandler.syphonFromNetwork(owner, cost);
this.setLastPosition(ritualStone.getCustomRitualTag(), new Int3(-xSize, -ySize, -zSize));
}
}
@ -153,4 +244,23 @@ public class RitualEffectEllipsoid extends RitualEffect
return ellipsoidRitual;
}
public Int3 getLastPosition(NBTTagCompound tag)
{
if(tag != null && tag.getBoolean("hasWorked"))
{
return Int3.readFromNBT(tag);
}
return null;
}
public void setLastPosition(NBTTagCompound tag, Int3 pos)
{
if(tag != null)
{
pos.writeToNBT(tag);
tag.setBoolean("hasWorked", true);
}
}
}