use of com.bewitchment.common.item.ItemWaystone in project Bewitchment by Um-Mitternacht.
the class RitualTeleport method onFinished.
@Override
public void onFinished(World world, BlockPos altarPos, BlockPos effectivePos, EntityPlayer caster, ItemStackHandler inventory) {
world.playSound(null, effectivePos, SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.BLOCKS, 0.7f, 0.7f);
BlockPos pos0 = null;
int dimension = 0;
if (world.getTileEntity(effectivePos) instanceof TileEntityGlyph) {
for (int i = 0; i < inventory.getSlots(); i++) {
ItemStack stack = inventory.getStackInSlot(i);
if (stack.getItem() instanceof ItemWaystone) {
pos0 = BlockPos.fromLong(stack.getTagCompound().getLong("location"));
dimension = stack.getTagCompound().getInteger("dimension");
stack.damageItem(1, caster);
break;
}
if (stack.getItem() instanceof ItemTaglock) {
for (Entity entity : world.loadedEntityList) {
if (entity.getPersistentID().equals(UUID.fromString(stack.getTagCompound().getString("boundId")))) {
pos0 = entity.getPosition();
dimension = entity.dimension;
stack.shrink(1);
break;
}
}
}
}
}
if (pos0 == null || dimension != world.provider.getDimension())
return;
for (Entity entity : world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(effectivePos).grow(3))) {
world.playSound(null, entity.getPosition(), SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1, 1);
if (entity instanceof EntityPlayer)
Util.teleportPlayer((EntityPlayer) entity, pos0.getX() + 0.5, pos0.getY(), pos0.getZ() + 0.5);
else
entity.setPositionAndUpdate(pos0.getX() + 0.5, pos0.getY(), pos0.getZ() + 0.5);
world.playSound(null, entity.getPosition(), SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1, 1);
}
}
Aggregations