Huge commit for the Pull-Request.

Added a lot of things:
- Blood Tank
- Teleposition Sigil
- Transposition Sigil
- Cobblestone/Netherrack/Obisidian generation Ritual
- Tree Cutter Ritual
- Pump Ritual
- Altar Builder Ritual
- Block Placing Ritual
- Portal Ritual
- Teleportation System and API Components
- Cross pattern Area Descriptor
- Two reagents and their textures for the sigils’ crafting

Fixed:
- Teleposer not teleporting entities correctly

And probably other things I forgot!
This commit is contained in:
Tombenpotter 2016-02-18 17:25:11 +01:00
parent d947f23696
commit 7e8aec8652
53 changed files with 3031 additions and 372 deletions

View file

@ -0,0 +1,325 @@
package WayofTime.bloodmagic.ritual;
import WayofTime.bloodmagic.api.BlockStack;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.altar.AltarComponent;
import WayofTime.bloodmagic.api.altar.EnumAltarComponent;
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
import WayofTime.bloodmagic.api.network.SoulNetwork;
import WayofTime.bloodmagic.api.ritual.EnumRuneType;
import WayofTime.bloodmagic.api.ritual.IMasterRitualStone;
import WayofTime.bloodmagic.api.ritual.Ritual;
import WayofTime.bloodmagic.api.ritual.RitualComponent;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.block.BlockBloodRune;
import WayofTime.bloodmagic.registry.ModBlocks;
import WayofTime.bloodmagic.util.Utils;
import net.minecraft.block.Block;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import java.util.ArrayList;
import java.util.Iterator;
public class RitualAltarBuilder extends Ritual
{
private Iterator<AltarComponent> altarComponentsIterator = new ArrayList<AltarComponent>(EnumAltarTier.SIX.getAltarComponents()).iterator();
private boolean cycleDone = false;
private AltarComponent currentComponent;
private BlockPos currentPos;
public RitualAltarBuilder()
{
super("ritualAltarBuilder", 0, 450, "ritual." + Constants.Mod.MODID + ".altarBuilderRitual");
}
@Override
public void performRitual(IMasterRitualStone masterRitualStone)
{
World world = masterRitualStone.getWorldObj();
SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner());
TileEntity tileEntity = world.getTileEntity(masterRitualStone.getBlockPos().up());
BlockPos altarPos = masterRitualStone.getBlockPos().up(2);
int currentEssence = network.getCurrentEssence();
if (currentEssence < getRefreshCost())
{
network.causeNauseaToPlayer();
return;
}
if (cycleDone)
{
altarComponentsIterator = new ArrayList<AltarComponent>(EnumAltarTier.SIX.getAltarComponents()).iterator();
}
if (world.getBlockState(altarPos).getBlock().isReplaceable(world, altarPos) && hasItem(tileEntity, Item.getItemFromBlock(ModBlocks.altar), 0, true))
{
world.setBlockState(altarPos, ModBlocks.altar.getDefaultState());
lightning(world, altarPos);
network.syphon(getRefreshCost());
}
if (altarComponentsIterator.hasNext())
{
currentComponent = altarComponentsIterator.next();
currentPos = altarPos.add(currentComponent.getOffset());
if (world.getBlockState(currentPos).getBlock().isReplaceable(world, currentPos))
{
switch (currentComponent.getComponent())
{
case NOTAIR:
{
BlockStack blockStack = getMundaneBlock(tileEntity);
if (blockStack != null)
{
world.setBlockState(currentPos, blockStack.getState(), 3);
lightning(world, currentPos);
network.syphon(getRefreshCost());
}
break;
}
case BLOODRUNE:
{
BlockStack blockStack = getBloodRune(tileEntity);
if (blockStack != null)
{
world.setBlockState(currentPos, blockStack.getState(), 3);
lightning(world, currentPos);
network.syphon(getRefreshCost());
}
break;
}
default:
{
BlockStack blockStack = new BlockStack(Utils.getBlockForComponent(currentComponent.getComponent()), 0);
if (hasItem(tileEntity, Item.getItemFromBlock(blockStack.getBlock()), blockStack.getMeta(), true))
{
world.setBlockState(currentPos, blockStack.getState(), 3);
lightning(world, currentPos);
network.syphon(getRefreshCost());
}
break;
}
}
}
} else
{
cycleDone = true;
}
}
@Override
public int getRefreshCost()
{
return 75;
}
@Override
public int getRefreshTime()
{
return 12;
}
@Override
public ArrayList<RitualComponent> getComponents()
{
ArrayList<RitualComponent> components = new ArrayList<RitualComponent>();
for (int i = -12; i <= -8; i++)
{
addRune(components, i, -6, 13, EnumRuneType.AIR);
addRune(components, i, -6, -13, EnumRuneType.FIRE);
addRune(components, 13, -6, i, EnumRuneType.EARTH);
addRune(components, -13, -6, i, EnumRuneType.WATER);
addRune(components, i, 5, 13, EnumRuneType.AIR);
addRune(components, i, 5, -13, EnumRuneType.FIRE);
addRune(components, 13, 5, i, EnumRuneType.EARTH);
addRune(components, -13, 5, i, EnumRuneType.WATER);
}
for (int i = 8; i <= 12; i++)
{
addRune(components, i, -6, 13, EnumRuneType.AIR);
addRune(components, i, -6, -13, EnumRuneType.FIRE);
addRune(components, 13, -6, i, EnumRuneType.EARTH);
addRune(components, -13, -6, i, EnumRuneType.WATER);
addRune(components, i, 5, 13, EnumRuneType.AIR);
addRune(components, i, 5, -13, EnumRuneType.FIRE);
addRune(components, 13, 5, i, EnumRuneType.EARTH);
addRune(components, -13, 5, i, EnumRuneType.WATER);
}
for (int i = -6; i <= -4; i++)
{
addCornerRunes(components, 13, i, EnumRuneType.DUSK);
}
for (int i = 3; i <= 5; i++)
{
addCornerRunes(components, 13, i, EnumRuneType.DUSK);
}
return components;
}
@Override
public Ritual getNewCopy()
{
return new RitualAltarBuilder();
}
public void lightning(World world, BlockPos blockPos)
{
world.addWeatherEffect(new EntityLightningBolt(world, blockPos.getX(), blockPos.getY(), blockPos.getZ()));
}
/*
*
* These methods are utilities for this ritual.
* They support both the old forge inventory system, and the new one.
*
*/
public boolean hasItem(TileEntity tileEntity, Item item, int damage, boolean consumeItem)
{
if (tileEntity != null)
{
if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN))
{
IItemHandler iItemHandler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN);
if (iItemHandler.getSlots() <= 0)
{
return false;
}
for (int i = 0; i < iItemHandler.getSlots(); i++)
{
if (iItemHandler.getStackInSlot(i) != null && iItemHandler.getStackInSlot(i).stackSize > 0 && iItemHandler.getStackInSlot(i).getItem() == item && iItemHandler.getStackInSlot(i).getItemDamage() == damage && iItemHandler.extractItem(i, 1, !consumeItem) != null)
{
return true;
}
}
} else if (tileEntity instanceof IInventory)
{
IInventory inv = (IInventory) tileEntity;
for (int i = 0; i < inv.getSizeInventory(); i++)
{
if (inv.getStackInSlot(i) != null && inv.getStackInSlot(i).stackSize > 0 && inv.getStackInSlot(i).getItem() == item && inv.getStackInSlot(i).getItemDamage() == damage)
{
if (consumeItem)
{
inv.decrStackSize(i, 1);
}
return true;
}
}
}
}
return false;
}
public BlockStack getBloodRune(TileEntity tileEntity)
{
if (tileEntity != null)
{
if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN))
{
IItemHandler iItemHandler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN);
if (iItemHandler.getSlots() <= 0)
{
return null;
}
for (int i = 0; i < iItemHandler.getSlots(); i++)
{
if (iItemHandler.getStackInSlot(i) != null && iItemHandler.getStackInSlot(i).stackSize > 0 && iItemHandler.getStackInSlot(i).getItem() instanceof ItemBlock && Block.getBlockFromItem(iItemHandler.getStackInSlot(i).getItem()) instanceof BlockBloodRune && iItemHandler.extractItem(i, 1, true) != null)
{
BlockStack blockStack = new BlockStack(Utils.getBlockForComponent(EnumAltarComponent.BLOODRUNE), iItemHandler.getStackInSlot(i).getItemDamage());
iItemHandler.extractItem(i, 1, false);
return blockStack;
}
}
} else if (tileEntity instanceof IInventory)
{
IInventory inv = (IInventory) tileEntity;
for (int i = 0; i < inv.getSizeInventory(); i++)
{
if (inv.getStackInSlot(i) != null && inv.getStackInSlot(i).stackSize > 0 && inv.getStackInSlot(i).getItem() instanceof ItemBlock && Block.getBlockFromItem(inv.getStackInSlot(i).getItem()) instanceof BlockBloodRune)
{
BlockStack blockStack = new BlockStack(Utils.getBlockForComponent(EnumAltarComponent.BLOODRUNE), inv.getStackInSlot(i).getItemDamage());
inv.decrStackSize(i, 1);
return blockStack;
}
}
}
}
return null;
}
public BlockStack getMundaneBlock(TileEntity tileEntity)
{
if (tileEntity != null)
{
if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN))
{
IItemHandler iItemHandler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN);
if (iItemHandler.getSlots() <= 0)
{
return null;
}
for (int i = 0; i < iItemHandler.getSlots(); i++)
{
if (iItemHandler.getStackInSlot(i) != null && iItemHandler.getStackInSlot(i).stackSize > 0 && iItemHandler.getStackInSlot(i).getItem() instanceof ItemBlock && !(Block.getBlockFromItem(iItemHandler.getStackInSlot(i).getItem()) instanceof BlockBloodRune) && iItemHandler.extractItem(i, 1, true) != null)
{
Block block = Block.getBlockFromItem(iItemHandler.getStackInSlot(i).getItem());
if (block != null && block != Blocks.glowstone && block != ModBlocks.bloodStoneBrick && block != ModBlocks.crystal)
{
BlockStack blockStack = new BlockStack(block, iItemHandler.getStackInSlot(i).getItemDamage());
iItemHandler.extractItem(i, 1, false);
return blockStack;
}
}
}
} else if (tileEntity instanceof IInventory)
{
IInventory inv = (IInventory) tileEntity;
for (int i = 0; i < inv.getSizeInventory(); i++)
{
if (inv.getStackInSlot(i) != null && inv.getStackInSlot(i).stackSize > 0 && inv.getStackInSlot(i).getItem() instanceof ItemBlock && !(Block.getBlockFromItem(inv.getStackInSlot(i).getItem()) instanceof BlockBloodRune))
{
Block block = Block.getBlockFromItem(inv.getStackInSlot(i).getItem());
if (block != null && block != Blocks.glowstone && block != ModBlocks.bloodStoneBrick && block != ModBlocks.crystal)
{
BlockStack blockStack = new BlockStack(block, inv.getStackInSlot(i).getItemDamage());
inv.decrStackSize(i, 1);
return blockStack;
}
}
}
}
}
return null;
}
}

View file

@ -0,0 +1,117 @@
package WayofTime.bloodmagic.ritual;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.network.SoulNetwork;
import WayofTime.bloodmagic.api.ritual.*;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.item.ItemComponent;
import WayofTime.bloodmagic.tile.TileAlchemyArray;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import java.util.ArrayList;
public class RitualCobblestone extends Ritual
{
public static final String COBBLESTONE_RANGE = "cobblestoneRange";
public RitualCobblestone()
{
super("ritualCobblestone", 0, 500, "ritual." + Constants.Mod.MODID + ".cobblestoneRitual");
addBlockRange(COBBLESTONE_RANGE, new AreaDescriptor.Cross(new BlockPos(0, 1, 0), 1));
}
@Override
public void performRitual(IMasterRitualStone masterRitualStone)
{
World world = masterRitualStone.getWorldObj();
SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner());
int currentEssence = network.getCurrentEssence();
TileEntity tileEntity = world.getTileEntity(masterRitualStone.getBlockPos().up());
Block block = Blocks.cobblestone;
if (currentEssence < getRefreshCost())
{
network.causeNauseaToPlayer();
return;
}
int maxEffects = currentEssence / getRefreshCost();
int totalEffects = 0;
AreaDescriptor cobblestoneRange = getBlockRange(COBBLESTONE_RANGE);
if (tileEntity != null && tileEntity instanceof TileAlchemyArray)
{
TileAlchemyArray alchemyArray = (TileAlchemyArray) tileEntity;
if (alchemyArray.getStackInSlot(0) != null && alchemyArray.getStackInSlot(0).getItem() instanceof ItemComponent)
{
switch (alchemyArray.getStackInSlot(0).getItemDamage())
{
case 0:
block = Blocks.obsidian;
alchemyArray.decrStackSize(0, 1);
world.setBlockToAir(alchemyArray.getPos());
break;
case 1:
block = Blocks.netherrack;
alchemyArray.decrStackSize(0, 1);
world.setBlockToAir(alchemyArray.getPos());
break;
/*
case 4:
block = Blocks.end_stone;
alchemyArray.decrStackSize(0, 1);
world.setBlockToAir(alchemyArray.getPos());
break;
*/
default:
break;
}
}
}
for (BlockPos blockPos : cobblestoneRange.getContainedPositions(masterRitualStone.getBlockPos()))
{
if (world.isAirBlock(blockPos))
{
world.setBlockState(blockPos, block.getDefaultState());
totalEffects++;
}
if (totalEffects >= maxEffects)
{
break;
}
}
network.syphon(getRefreshCost() * totalEffects);
}
@Override
public int getRefreshCost()
{
return 25;
}
@Override
public ArrayList<RitualComponent> getComponents()
{
ArrayList<RitualComponent> components = new ArrayList<RitualComponent>();
this.addCornerRunes(components, 1, 1, EnumRuneType.FIRE);
this.addParallelRunes(components, 1, 0, EnumRuneType.WATER);
return components;
}
@Override
public Ritual getNewCopy()
{
return new RitualCobblestone();
}
}

View file

@ -1,9 +1,13 @@
package WayofTime.bloodmagic.ritual;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.iface.IBindable;
import WayofTime.bloodmagic.api.network.SoulNetwork;
import WayofTime.bloodmagic.api.ritual.*;
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import com.google.common.base.Strings;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@ -16,18 +20,10 @@ import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.iface.IBindable;
import WayofTime.bloodmagic.api.network.SoulNetwork;
import WayofTime.bloodmagic.api.ritual.AreaDescriptor;
import WayofTime.bloodmagic.api.ritual.EnumRuneType;
import WayofTime.bloodmagic.api.ritual.IMasterRitualStone;
import WayofTime.bloodmagic.api.ritual.Ritual;
import WayofTime.bloodmagic.api.ritual.RitualComponent;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import com.google.common.base.Strings;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class RitualExpulsion extends Ritual
{
@ -144,7 +140,8 @@ public class RitualExpulsion extends Ritual
if (block != null && block.getMaterial().blocksMovement())
{
flag1 = true;
} else
}
else
{
--entityLiving.posY;
--j;
@ -166,7 +163,8 @@ public class RitualExpulsion extends Ritual
{
moveEntityViaTeleport(entityLiving, lastX, lastY, lastZ);
return false;
} else
}
else
{
for (l = 0; l < 128; ++l)
{
@ -206,7 +204,8 @@ public class RitualExpulsion extends Ritual
}
}
}
} else if (entityLiving != null)
}
else if (entityLiving != null)
{
entityLiving.setPosition(x, y, z);
}

View file

@ -0,0 +1,125 @@
package WayofTime.bloodmagic.ritual;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.network.SoulNetwork;
import WayofTime.bloodmagic.api.ritual.*;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.util.Utils;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.Iterator;
public class RitualFelling extends Ritual
{
public static final String FELLING_RANGE = "fellingRange";
private ArrayList<BlockPos> treePartsCache;
private Iterator<BlockPos> blockPosIterator;
private boolean cached = false;
private BlockPos currentPos;
public RitualFelling()
{
super("ritualFelling", 0, 500, "ritual." + Constants.Mod.MODID + ".fellingRitual");
addBlockRange(FELLING_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-10, -3, -10), new BlockPos(11, 27, 11)));
treePartsCache = new ArrayList<BlockPos>();
}
@Override
public void performRitual(IMasterRitualStone masterRitualStone)
{
World world = masterRitualStone.getWorldObj();
SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner());
int currentEssence = network.getCurrentEssence();
if (currentEssence < getRefreshCost())
{
network.causeNauseaToPlayer();
return;
}
if (!cached || treePartsCache.isEmpty())
{
for (BlockPos blockPos : getBlockRange(FELLING_RANGE).getContainedPositions(masterRitualStone.getBlockPos()))
{
if (!treePartsCache.contains(blockPos))
if (!world.isAirBlock(blockPos) && (world.getBlockState(blockPos).getBlock().isWood(world, blockPos) || world.getBlockState(blockPos).getBlock().isLeaves(world, blockPos)))
{
treePartsCache.add(blockPos);
}
}
cached = true;
blockPosIterator = treePartsCache.iterator();
}
if (blockPosIterator.hasNext() && world.getTileEntity(masterRitualStone.getBlockPos().up()) != null && world.getTileEntity(masterRitualStone.getBlockPos().up()) instanceof IInventory)
{
network.syphon(getRefreshCost());
currentPos = blockPosIterator.next();
placeInInventory(world.getBlockState(currentPos), world, currentPos, masterRitualStone.getBlockPos().up());
world.setBlockToAir(currentPos);
blockPosIterator.remove();
}
}
@Override
public int getRefreshCost()
{
return 30;
}
@Override
public int getRefreshTime()
{
return 1;
}
@Override
public ArrayList<RitualComponent> getComponents()
{
ArrayList<RitualComponent> components = new ArrayList<RitualComponent>();
addCornerRunes(components, 1, 0, EnumRuneType.EARTH);
addCornerRunes(components, 1, 1, EnumRuneType.EARTH);
return components;
}
@Override
public Ritual getNewCopy()
{
return new RitualFelling();
}
private void placeInInventory(IBlockState blockState, World world, BlockPos blockPos, BlockPos tileEntityPos)
{
TileEntity tile = world.getTileEntity(tileEntityPos);
if (tile != null && blockState.getBlock().getDrops(world, blockPos, world.getBlockState(blockPos), 0) != null)
{
if (tile instanceof IInventory)
{
for (ItemStack stack : blockState.getBlock().getDrops(world, blockPos, world.getBlockState(blockPos), 0))
{
ItemStack copyStack = stack.copy();
Utils.insertStackIntoInventory(copyStack, (IInventory) tile, EnumFacing.DOWN);
if (copyStack.stackSize > 0)
{
world.spawnEntityInWorld(new EntityItem(world, blockPos.getX() + 0.4, blockPos.getY() + 2, blockPos.getZ() + 0.4, copyStack));
}
}
}
}
}
}

View file

@ -0,0 +1,141 @@
package WayofTime.bloodmagic.ritual;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.network.SoulNetwork;
import WayofTime.bloodmagic.api.ritual.*;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import net.minecraft.block.Block;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemBlock;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import java.util.ArrayList;
public class RitualPlacer extends Ritual
{
public static final String PLACER_RANGE = "placerRange";
public RitualPlacer()
{
super("ritualPlacer", 0, 5000, "ritual." + Constants.Mod.MODID + ".placerRitual");
addBlockRange(PLACER_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-2, 0, -2), new BlockPos(3, 1, 3)));
}
@Override
public void performRitual(IMasterRitualStone masterRitualStone)
{
World world = masterRitualStone.getWorldObj();
SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner());
TileEntity tileEntity = world.getTileEntity(masterRitualStone.getBlockPos().up());
int currentEssence = network.getCurrentEssence();
if (currentEssence < getRefreshCost())
{
network.causeNauseaToPlayer();
return;
}
AreaDescriptor areaDescriptor = getBlockRange(PLACER_RANGE);
IInventory iInventory;
if (tileEntity != null)
{
// Using the new Forge inventory system
if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN))
{
IItemHandler iItemHandler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN);
if (iItemHandler.getSlots() <= 0)
{
return;
}
for (BlockPos blockPos : areaDescriptor.getContainedPositions(masterRitualStone.getBlockPos()))
{
for (int inv = 0; inv < iItemHandler.getSlots(); inv++)
{
if (world.getBlockState(blockPos).getBlock().isReplaceable(world, blockPos) && iItemHandler.getStackInSlot(inv) != null && iItemHandler.getStackInSlot(inv).stackSize != 0)
{
if (iItemHandler.getStackInSlot(inv).getItem() instanceof ItemBlock && world.getBlockState(blockPos.down()) != null)
{
if (iItemHandler.extractItem(inv, 1, true) != null)
{
world.setBlockState(blockPos, Block.getBlockFromItem(iItemHandler.getStackInSlot(inv).getItem()).getStateFromMeta(iItemHandler.getStackInSlot(inv).getItemDamage()));
iItemHandler.extractItem(inv, 1, false);
tileEntity.markDirty();
network.syphon(getRefreshCost());
}
}
}
}
}
//Compatibility with the old system, as it still exists
} else if (tileEntity instanceof IInventory)
{
iInventory = (IInventory) tileEntity;
if (iInventory.getSizeInventory() <= 0)
{
return;
}
for (BlockPos blockPos : areaDescriptor.getContainedPositions(masterRitualStone.getBlockPos()))
{
for (int inv = 0; inv < iInventory.getSizeInventory(); inv++)
{
if (world.getBlockState(blockPos).getBlock().isReplaceable(world, blockPos) && iInventory.getStackInSlot(inv) != null && iInventory.getStackInSlot(inv).stackSize != 0)
{
if (iInventory.getStackInSlot(inv).getItem() instanceof ItemBlock && world.getBlockState(blockPos.down()) != null)
{
world.setBlockState(blockPos, Block.getBlockFromItem(iInventory.getStackInSlot(inv).getItem()).getStateFromMeta(iInventory.getStackInSlot(inv).getItemDamage()));
iInventory.decrStackSize(inv, 1);
iInventory.markDirty();
network.syphon(getRefreshCost());
}
}
}
}
}
}
}
@Override
public int getRefreshCost()
{
return 50;
}
@Override
public ArrayList<RitualComponent> getComponents()
{
ArrayList<RitualComponent> components = new ArrayList<RitualComponent>();
addRune(components, 3, 0, 3, EnumRuneType.EARTH);
addRune(components, 3, 0, -3, EnumRuneType.EARTH);
addRune(components, -3, 0, 3, EnumRuneType.EARTH);
addRune(components, -3, 0, -3, EnumRuneType.EARTH);
addRune(components, 3, 0, 2, EnumRuneType.WATER);
addRune(components, 3, 0, -2, EnumRuneType.WATER);
addRune(components, 2, 0, 3, EnumRuneType.WATER);
addRune(components, 2, 0, -3, EnumRuneType.WATER);
addRune(components, -2, 0, 3, EnumRuneType.WATER);
addRune(components, -2, 0, -3, EnumRuneType.WATER);
addRune(components, -3, 0, 2, EnumRuneType.WATER);
addRune(components, -3, 0, -2, EnumRuneType.WATER);
return components;
}
@Override
public Ritual getNewCopy()
{
return new RitualPlacer();
}
}

View file

@ -0,0 +1,288 @@
package WayofTime.bloodmagic.ritual;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.ritual.EnumRuneType;
import WayofTime.bloodmagic.api.ritual.IMasterRitualStone;
import WayofTime.bloodmagic.api.ritual.Ritual;
import WayofTime.bloodmagic.api.ritual.RitualComponent;
import WayofTime.bloodmagic.api.teleport.PortalLocation;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.registry.ModBlocks;
import WayofTime.bloodmagic.ritual.portal.LocationsHandler;
import WayofTime.bloodmagic.tile.TileDimensionalPortal;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import java.util.ArrayList;
public class RitualPortal extends Ritual
{
private NBTTagCompound portalRitualTag;
public static final String PORTAL_NBT_TAG = "PortalRitualTag";
public static final String PORTAL_ID_TAG = "PortalRitualID";
public RitualPortal()
{
super("ritualPortal", 0, 500, "ritual." + Constants.Mod.MODID + ".portalRitual");
portalRitualTag = new NBTTagCompound();
}
@Override
public boolean activateRitual(IMasterRitualStone masterRitualStone, EntityPlayer player)
{
String owner = PlayerHelper.getUUIDFromPlayer(player).toString();
World world = masterRitualStone.getWorldObj();
int x = masterRitualStone.getBlockPos().getX();
int y = masterRitualStone.getBlockPos().getY();
int z = masterRitualStone.getBlockPos().getZ();
EnumFacing direction = masterRitualStone.getDirection();
String name = owner;
IBlockState blockState;
if (!world.isRemote)
{
portalRitualTag.removeTag(PORTAL_ID_TAG);
if (direction == EnumFacing.NORTH || direction == EnumFacing.SOUTH)
{
for (int i = x - 3; i <= x + 3; i++)
{
for (int k = z - 2; k <= z + 2; k++)
{
if (!world.isAirBlock(new BlockPos(i, y, k)) && !(getBlockState(world, i, y, k).getBlock() == ModBlocks.ritualStone))
{
blockState = getBlockState(world, i, y, k);
name = addStringToEnd(name, Block.blockRegistry.getNameForObject(blockState.getBlock()) + String.valueOf(blockState.getBlock().getMetaFromState(blockState)));
}
}
}
for (int j = y + 1; j <= y + 5; j++)
{
if (!world.isAirBlock(new BlockPos(x - 3, j, z)) && !(getBlockState(world, x - 3, j, z).getBlock() == ModBlocks.ritualStone))
{
blockState = getBlockState(world, x - 3, j, z);
name = addStringToEnd(name, Block.blockRegistry.getNameForObject(blockState.getBlock()) + String.valueOf(blockState.getBlock().getMetaFromState(blockState)));
}
}
for (int j = y + 1; j <= y + 5; j++)
{
if (!world.isAirBlock(new BlockPos(x + 3, j, z)) && !(getBlockState(world, x + 3, j, z) == ModBlocks.ritualStone))
{
blockState = getBlockState(world, x + 3, j, z);
name = addStringToEnd(name, Block.blockRegistry.getNameForObject(blockState.getBlock()) + String.valueOf(blockState.getBlock().getMetaFromState(blockState)));
}
}
} else if (direction == EnumFacing.EAST || direction == EnumFacing.WEST)
{
for (int k = z - 3; k <= z + 3; k++)
{
for (int i = x - 2; i <= x + 2; i++)
{
if (!world.isAirBlock(new BlockPos(i, y, k)) && !(getBlockState(world, i, y, k).getBlock() == ModBlocks.ritualStone))
{
blockState = getBlockState(world, i, y, k);
name = addStringToEnd(name, Block.blockRegistry.getNameForObject(blockState.getBlock()) + String.valueOf(blockState.getBlock().getMetaFromState(blockState)));
}
}
}
for (int j = y + 1; j <= y + 5; j++)
{
if (!world.isAirBlock(new BlockPos(x, j, z - 3)) && !(getBlockState(world, x, j, z - 3).getBlock() == ModBlocks.ritualStone))
{
blockState = getBlockState(world, x, j, z - 3);
name = addStringToEnd(name, Block.blockRegistry.getNameForObject(blockState.getBlock()) + String.valueOf(blockState.getBlock().getMetaFromState(blockState)));
}
}
for (int j = y + 1; j <= y + 5; j++)
{
if (!world.isAirBlock(new BlockPos(x, j, z + 3)) && !(getBlockState(world, x, j, z + 3).getBlock() == ModBlocks.ritualStone))
{
blockState = getBlockState(world, x, j, z + 3);
name = addStringToEnd(name, Block.blockRegistry.getNameForObject(blockState.getBlock()) + String.valueOf(blockState.getBlock().getMetaFromState(blockState)));
}
}
}
if (LocationsHandler.getLocationsHandler() != null)
{
if (LocationsHandler.getLocationsHandler().addLocation(name, new PortalLocation(x, y + 1, z, world.provider.getDimensionId())))
{
portalRitualTag.setString(PORTAL_ID_TAG, name);
return true;
}
}
}
return false;
}
@Override
public void performRitual(IMasterRitualStone masterRitualStone)
{
World world = masterRitualStone.getWorldObj();
int x = masterRitualStone.getBlockPos().getX();
int y = masterRitualStone.getBlockPos().getY();
int z = masterRitualStone.getBlockPos().getZ();
EnumFacing direction = masterRitualStone.getDirection();
if (direction == EnumFacing.NORTH || direction == EnumFacing.SOUTH)
{
for (int i = x - 1; i <= x + 1; i++)
{
for (int j = y + 1; j <= y + 3; j++)
{
BlockPos tempPos = new BlockPos(i, j, z);
if (world.isAirBlock(tempPos))
{
IBlockState blockState = ModBlocks.dimensionalPortal.getStateFromMeta(0);
world.setBlockState(tempPos, blockState, 3);
if (world.getTileEntity(tempPos) != null && world.getTileEntity(tempPos) instanceof TileDimensionalPortal)
{
TileDimensionalPortal tile = (TileDimensionalPortal) world.getTileEntity(tempPos);
tile.setMasterStonePos(masterRitualStone.getBlockPos());
tile.portalID = portalRitualTag.getString(PORTAL_ID_TAG);
}
}
}
}
} else if (direction == EnumFacing.EAST || direction == EnumFacing.WEST)
{
for (int k = z - 1; k <= z + 1; k++)
{
for (int j = y + 1; j <= y + 3; j++)
{
BlockPos tempPos = new BlockPos(x, j, k);
if (world.isAirBlock(tempPos))
{
IBlockState blockState = ModBlocks.dimensionalPortal.getStateFromMeta(1);
world.setBlockState(tempPos, blockState, 3);
if (world.getTileEntity(tempPos) != null && world.getTileEntity(tempPos) instanceof TileDimensionalPortal)
{
TileDimensionalPortal tile = (TileDimensionalPortal) world.getTileEntity(tempPos);
tile.setMasterStonePos(masterRitualStone.getBlockPos());
tile.portalID = portalRitualTag.getString(PORTAL_ID_TAG);
}
}
}
}
}
}
@Override
public void stopRitual(IMasterRitualStone masterRitualStone, BreakType breakType)
{
World world = masterRitualStone.getWorldObj();
int x = masterRitualStone.getBlockPos().getX();
int y = masterRitualStone.getBlockPos().getY();
int z = masterRitualStone.getBlockPos().getZ();
EnumFacing direction = masterRitualStone.getDirection();
if (LocationsHandler.getLocationsHandler() != null)
{
LocationsHandler.getLocationsHandler().removeLocation(portalRitualTag.getString(PORTAL_ID_TAG), new PortalLocation(x, y + 1, z, world.provider.getDimensionId()));
}
if (direction == EnumFacing.NORTH || direction == EnumFacing.SOUTH)
{
for (int i = x - 2; i <= x + 2; i++)
{
for (int j = y + 1; j <= y + 3; j++)
{
if (getBlockState(world, i, j, z).getBlock() == ModBlocks.dimensionalPortal)
{
world.setBlockToAir(new BlockPos(i, j, z));
}
}
}
} else if (direction == EnumFacing.EAST || direction == EnumFacing.WEST)
{
for (int k = z - 2; k <= z + 2; k++)
{
for (int j = y + 1; j <= y + 3; j++)
{
if (getBlockState(world, x, j, k).getBlock() == ModBlocks.dimensionalPortal)
{
world.setBlockToAir(new BlockPos(x, j, k));
}
}
}
}
portalRitualTag.removeTag(PORTAL_ID_TAG);
}
@Override
public int getRefreshCost()
{
return 0;
}
@Override
public ArrayList<RitualComponent> getComponents()
{
ArrayList<RitualComponent> components = new ArrayList<RitualComponent>();
addRune(components, 1, 0, 0, EnumRuneType.AIR);
addRune(components, 2, 0, 0, EnumRuneType.WATER);
addRune(components, -1, 0, 0, EnumRuneType.FIRE);
addRune(components, -2, 0, 0 , EnumRuneType.EARTH);
addRune(components, 2, 1, 0, EnumRuneType.DUSK);
addRune(components, 2, 2, 0, EnumRuneType.AIR);
addRune(components, 2, 3, 0, EnumRuneType.WATER);
addRune(components, 2, 4, 0, EnumRuneType.FIRE);
addRune(components, 1, 4, 0, EnumRuneType.EARTH);
addRune(components, 0, 4, 0, EnumRuneType.DUSK);
addRune(components, -1, 4, 0, EnumRuneType.AIR);
addRune(components, -2, 4, 0, EnumRuneType.WATER);
addRune(components, -2, 3, 0, EnumRuneType.FIRE);
addRune(components, -2, 2, 0, EnumRuneType.EARTH);
addRune(components, -2, 1, 0, EnumRuneType.DUSK);
return components;
}
@Override
public Ritual getNewCopy()
{
return new RitualPortal();
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
super.readFromNBT(tag);
portalRitualTag = tag.getCompoundTag(PORTAL_NBT_TAG);
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT(tag);
tag.setTag(PORTAL_NBT_TAG, portalRitualTag);
}
public IBlockState getBlockState(World world, int x, int y, int z)
{
return world.getBlockState(new BlockPos(x, y, z));
}
public String addStringToEnd(String input, String toAdd)
{
return input + toAdd;
}
}

View file

@ -0,0 +1,113 @@
package WayofTime.bloodmagic.ritual;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.network.SoulNetwork;
import WayofTime.bloodmagic.api.ritual.*;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import net.minecraft.block.BlockLiquid;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler;
import java.util.ArrayList;
import java.util.Iterator;
public class RitualPump extends Ritual
{
public static final String PUMP_RANGE = "pumpRange";
private ArrayList<BlockPos> liquidsCache;
private Iterator<BlockPos> blockPosIterator;
private boolean cached = false;
private BlockPos currentPos;
public RitualPump()
{
super("ritualPump", 0, 500, "ritual." + Constants.Mod.MODID + ".pumpRitual");
addBlockRange(PUMP_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-16, -16, -16), new BlockPos(17, 17, 17)));
liquidsCache = new ArrayList<BlockPos>();
}
@Override
public void performRitual(IMasterRitualStone masterRitualStone)
{
World world = masterRitualStone.getWorldObj();
SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner());
int currentEssence = network.getCurrentEssence();
TileEntity tileEntity = world.getTileEntity(masterRitualStone.getBlockPos().up());
if (currentEssence < getRefreshCost())
{
network.causeNauseaToPlayer();
return;
}
if (tileEntity != null && tileEntity instanceof IFluidHandler)
{
IFluidHandler fluidHandler = (IFluidHandler) tileEntity;
if (!cached || liquidsCache.isEmpty())
{
if (fluidHandler.drain(EnumFacing.DOWN, 1000, false) != null)
{
FluidStack fluidStack = fluidHandler.drain(EnumFacing.DOWN, 1000, false);
for (BlockPos blockPos : getBlockRange(PUMP_RANGE).getContainedPositions(masterRitualStone.getBlockPos()))
{
if (!liquidsCache.contains(blockPos))
{
if (!world.isAirBlock(blockPos) && world.getBlockState(blockPos).getBlock() == fluidStack.getFluid().getBlock() && world.getBlockState(blockPos).getValue(BlockLiquid.LEVEL) == 0)
{
liquidsCache.add(blockPos);
}
}
}
}
cached = true;
blockPosIterator = liquidsCache.iterator();
}
if (blockPosIterator.hasNext())
{
network.syphon(getRefreshCost());
currentPos = blockPosIterator.next();
fluidHandler.fill(EnumFacing.DOWN, fluidHandler.drain(EnumFacing.DOWN, 1000, false), true);
world.setBlockState(currentPos, Blocks.stone.getDefaultState());
blockPosIterator.remove();
}
}
}
@Override
public int getRefreshCost()
{
return 25;
}
@Override
public ArrayList<RitualComponent> getComponents()
{
ArrayList<RitualComponent> components = new ArrayList<RitualComponent>();
addRune(components, 1, 0, 1, EnumRuneType.WATER);
addRune(components, 1, 0, -1, EnumRuneType.EARTH);
addRune(components, -1, 0, -1, EnumRuneType.AIR);
addRune(components, -1, 0, 1, EnumRuneType.FIRE);
addCornerRunes(components, 1, 1, EnumRuneType.DUSK);
return components;
}
@Override
public Ritual getNewCopy()
{
return new RitualPump();
}
}

View file

@ -1,19 +1,15 @@
package WayofTime.bloodmagic.ritual;
import java.util.ArrayList;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.network.SoulNetwork;
import WayofTime.bloodmagic.api.ritual.*;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.network.SoulNetwork;
import WayofTime.bloodmagic.api.ritual.AreaDescriptor;
import WayofTime.bloodmagic.api.ritual.EnumRuneType;
import WayofTime.bloodmagic.api.ritual.IMasterRitualStone;
import WayofTime.bloodmagic.api.ritual.Ritual;
import WayofTime.bloodmagic.api.ritual.RitualComponent;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import java.util.ArrayList;
public class RitualSpeed extends Ritual
{
@ -42,8 +38,7 @@ public class RitualSpeed extends Ritual
for (EntityLivingBase entity : world.getEntitiesWithinAABB(EntityLivingBase.class, speedRange.getAABB(masterRitualStone.getBlockPos())))
{
if (entity.isSneaking())
continue;
if (entity.isSneaking()) continue;
double motionY = 1.2;
double speed = 3;
@ -54,23 +49,21 @@ public class RitualSpeed extends Ritual
switch (direction)
{
case NORTH:
entity.setVelocity(0, motionY, -speed);
break;
case NORTH:
entity.setVelocity(0, motionY, -speed);
break;
case SOUTH:
entity.setVelocity(0, motionY, speed);
break;
case SOUTH:
entity.setVelocity(0, motionY, speed);
break;
case WEST:
entity.setVelocity(-speed, motionY, 0);
break;
case WEST:
entity.setVelocity(-speed, motionY, 0);
break;
case EAST:
entity.setVelocity(speed, motionY, 0);
break;
default:
break;
case EAST:
entity.setVelocity(speed, motionY, 0);
break;
}
}

View file

@ -0,0 +1,134 @@
package WayofTime.bloodmagic.ritual.portal;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.teleport.PortalLocation;
import net.minecraftforge.common.DimensionManager;
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
public class LocationsHandler implements Serializable
{
public static final long serialVersionUID = 10102001;
private static final String fileName = String.valueOf(DimensionManager.getCurrentSaveRootDirectory()) + "/" + Constants.Mod.MODID + "/PortalLocations.dat";
private static HashMap<String, ArrayList<PortalLocation>> portals;
private static LocationsHandler locationsHandler;
private LocationsHandler()
{
portals = new HashMap<String, ArrayList<PortalLocation>>();
}
public static LocationsHandler getLocationsHandler()
{
if (locationsHandler == null || loadFile() == null)
{
locationsHandler = new LocationsHandler();
return locationsHandler;
} else
{
portals = loadFile();
return locationsHandler;
}
}
private static HashMap<String, ArrayList<PortalLocation>> loadFile()
{
HashMap<String, ArrayList<PortalLocation>> map;
File file = new File(fileName);
try
{
if (!file.exists())
{
if (file.getParentFile().mkdir())
{
if (file.createNewFile())
{
BloodMagicAPI.getLogger().info("Creating " + fileName + " in " + String.valueOf(DimensionManager.getCurrentSaveRootDirectory()));
}
} else if (file.createNewFile())
{
BloodMagicAPI.getLogger().info("Creating " + fileName + " in " + String.valueOf(DimensionManager.getCurrentSaveRootDirectory()));
}
}
FileInputStream fileIn = new FileInputStream(file);
ObjectInputStream in = new ObjectInputStream(fileIn);
map = (HashMap<String, ArrayList<PortalLocation>>) in.readObject();
in.close();
fileIn.close();
return map;
} catch (IOException e)
{
e.printStackTrace();
return null;
} catch (ClassNotFoundException e)
{
BloodMagicAPI.getLogger().error(String.valueOf(file) + " was not found in " + String.valueOf(DimensionManager.getCurrentSaveRootDirectory()));
return null;
}
}
private static void updateFile(String file, HashMap<String, ArrayList<PortalLocation>> object)
{
try
{
FileOutputStream fos = new FileOutputStream(file);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(object);
oos.close();
} catch (IOException e)
{
e.printStackTrace();
}
}
public boolean addLocation(String name, PortalLocation location)
{
ArrayList<PortalLocation> portalLocations = portals.get(name);
if (portalLocations == null)
{
portals.put(name, new ArrayList<PortalLocation>());
updateFile(fileName, portals);
}
if (!portals.get(name).isEmpty() && portals.get(name).size() >= 2)
{
BloodMagicAPI.getLogger().info("Location " + name + " already exists.");
updateFile(fileName, portals);
return false;
} else
{
portals.get(name).add(location);
BloodMagicAPI.getLogger().info("Adding " + name);
updateFile(fileName, portals);
return true;
}
}
public boolean removeLocation(String name, PortalLocation location)
{
if (portals.get(name) != null && !portals.get(name).isEmpty())
{
if (portals.get(name).contains(location))
{
portals.get(name).remove(location);
BloodMagicAPI.getLogger().info("Removing " + name);
updateFile(fileName, portals);
return true;
} else
{
BloodMagicAPI.getLogger().info("No location matching " + name);
updateFile(fileName, portals);
return false;
}
}
return false;
}
public ArrayList<PortalLocation> getLinkedLocations(String name)
{
return portals.get(name);
}
}

View file

@ -0,0 +1,178 @@
package WayofTime.bloodmagic.ritual.portal;
import WayofTime.bloodmagic.api.network.SoulNetwork;
import WayofTime.bloodmagic.api.teleport.Teleport;
import WayofTime.bloodmagic.api.teleport.TeleporterBloodMagic;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import lombok.Getter;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.S06PacketUpdateHealth;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
public class Teleports
{
public static class TeleportSameDim extends Teleport
{
public TeleportSameDim(int x, int y, int z, Entity entity, String networkToDrain)
{
super(x, y, z, entity, networkToDrain);
}
public TeleportSameDim(BlockPos blockPos, Entity entity, String networkToDrain)
{
super(blockPos, entity, networkToDrain);
}
@Override
public void teleport()
{
if (entity != null)
{
if (entity.timeUntilPortal <= 0)
{
if (entity instanceof EntityPlayer)
{
EntityPlayerMP player = (EntityPlayerMP) entity;
player.setPositionAndUpdate(x + 0.5, y + 0.5, z + 0.5);
player.worldObj.updateEntityWithOptionalForce(player, false);
player.playerNetServerHandler.sendPacket(new S06PacketUpdateHealth(player.getHealth(), player.getFoodStats().getFoodLevel(), player.getFoodStats().getSaturationLevel()));
player.timeUntilPortal = 150;
SoulNetwork network = NetworkHelper.getSoulNetwork(networkToDrain);
if (network.getCurrentEssence() < getTeleportCost())
{
return;
}
network.syphon(getTeleportCost());
player.worldObj.playSoundEffect(x, y, z, "mob.endermen.portal", 1.0F, 1.0F);
} else
{
WorldServer world = (WorldServer) entity.worldObj;
entity.setPosition(x + 0.5, y + 0.5, z + 0.5);
entity.timeUntilPortal = 150;
world.resetUpdateEntityTick();
SoulNetwork network = NetworkHelper.getSoulNetwork(networkToDrain);
if (network.getCurrentEssence() < (getTeleportCost() / 10))
{
return;
}
network.syphon(getTeleportCost() / 10);
entity.worldObj.playSoundEffect(x, y, z, "mob.endermen.portal", 1.0F, 1.0F);
}
}
}
}
@Override
public int getTeleportCost()
{
return 1000;
}
}
public static class TeleportToDim extends Teleport
{
@Getter
private World oldWorld;
@Getter
private int newWorldID;
public TeleportToDim(int x, int y, int z, Entity entity, String networkToDrain, World oldWorld, int newWorld)
{
super(x, y, z, entity, networkToDrain);
this.oldWorld = oldWorld;
this.newWorldID = newWorld;
}
public TeleportToDim(BlockPos blockPos, Entity entity, String networkToDrain, World oldWorld, int newWorldID)
{
super(blockPos, entity, networkToDrain);
this.oldWorld = oldWorld;
this.newWorldID = newWorldID;
}
@Override
public void teleport()
{
if (entity != null)
{
if (entity.timeUntilPortal <= 0)
{
MinecraftServer server = MinecraftServer.getServer();
WorldServer oldWorldServer = server.worldServerForDimension(entity.dimension);
WorldServer newWorldServer = server.worldServerForDimension(newWorldID);
if (entity instanceof EntityPlayer)
{
EntityPlayerMP player = (EntityPlayerMP) entity;
if (!player.worldObj.isRemote)
{
server.getConfigurationManager().transferPlayerToDimension(player, newWorldID, new TeleporterBloodMagic(newWorldServer));
player.setPositionAndUpdate(x + 0.5, y + 0.5, z + 0.5);
player.worldObj.updateEntityWithOptionalForce(player, false);
player.playerNetServerHandler.sendPacket(new S06PacketUpdateHealth(player.getHealth(), player.getFoodStats().getFoodLevel(), player.getFoodStats().getSaturationLevel()));
}
SoulNetwork network = NetworkHelper.getSoulNetwork(networkToDrain);
if (network.getCurrentEssence() < getTeleportCost())
{
return;
}
network.syphon(getTeleportCost());
} else if (!entity.worldObj.isRemote)
{
NBTTagCompound tag = new NBTTagCompound();
entity.writeToNBTOptional(tag);
entity.setDead();
oldWorld.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
Entity teleportedEntity = EntityList.createEntityFromNBT(tag, newWorldServer);
if (teleportedEntity != null)
{
teleportedEntity.setLocationAndAngles(x + 0.5, y + 0.5, z + 0.5, entity.rotationYaw, entity.rotationPitch);
teleportedEntity.forceSpawn = true;
newWorldServer.spawnEntityInWorld(teleportedEntity);
teleportedEntity.setWorld(newWorldServer);
teleportedEntity.timeUntilPortal = 150;
}
oldWorldServer.resetUpdateEntityTick();
newWorldServer.resetUpdateEntityTick();
SoulNetwork network = NetworkHelper.getSoulNetwork(networkToDrain);
if (network.getCurrentEssence() < (getTeleportCost() / 10))
{
return;
}
network.syphon(getTeleportCost() / 10);
}
entity.timeUntilPortal = 150;
newWorldServer.playSoundEffect(x, y, z, "mob.endermen.portal", 1.0F, 1.0F);
}
}
}
@Override
public int getTeleportCost()
{
return 10000;
}
}
}