Java Code Examples for net.minecraft.entity.Entity#setPositionAndUpdate()

The following examples show how to use net.minecraft.entity.Entity#setPositionAndUpdate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockTofuFarmLand.java    From TofuCraftReload with MIT License 5 votes vote down vote up
protected static void turnToDirt(World p_190970_0_, BlockPos worldIn)
{
    p_190970_0_.setBlockState(worldIn, BlockLoader.tofuTerrain.getDefaultState());
    AxisAlignedBB axisalignedbb = field_194405_c.offset(worldIn);

    for (Entity entity : p_190970_0_.getEntitiesWithinAABBExcludingEntity((Entity)null, axisalignedbb))
    {
        double d0 = Math.min(axisalignedbb.maxY - axisalignedbb.minY, axisalignedbb.maxY - entity.getEntityBoundingBox().minY);
        entity.setPositionAndUpdate(entity.posX, entity.posY + d0 + 0.001D, entity.posZ);
    }
}
 
Example 2
Source File: ClipCommand.java    From ForgeHax with MIT License 5 votes vote down vote up
private void setPosition(double x, double y, double z) {
  final Entity local = Helper.getRidingOrPlayer();
  local.setPositionAndUpdate(x, y, z);
  if (local instanceof EntityPlayerSP) {
    getNetworkManager()
      .sendPacket(
        new CPacketPlayer.Position(local.posX, local.posY, local.posZ, MC.player.onGround));
  } else {
    getNetworkManager().sendPacket(new CPacketVehicleMove(local));
  }
}
 
Example 3
Source File: ModuleEffectZoom.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean run(@NotNull World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	Entity entityHit = spell.getVictim(world);
	Vec3d look = spell.getData(LOOK);
	Vec3d origin = spell.getData(ORIGIN);

	if (entityHit == null) return true;
	else {
		if (!spellRing.taxCaster(world, spell, true)) return false;

		if (look == null) return true;
		if (origin == null) return true;

		double range = spellRing.getAttributeValue(world, AttributeRegistry.RANGE, spell);
		RayTraceResult trace = new RayTrace(world, look, origin, range)
				.setEntityFilter(input -> input != entityHit)
				.setIgnoreBlocksWithoutBoundingBoxes(true)
				.setReturnLastUncollidableBlock(false)
				.trace();

		spell.addData(ORIGINAL_LOC, entityHit.getPositionVector());

		entityHit.setPositionAndUpdate(trace.hitVec.x, trace.hitVec.y, trace.hitVec.z);

		entityHit.motionX = 0;
		entityHit.motionY = 0;
		entityHit.motionZ = 0;
		entityHit.velocityChanged = true;
	}
	if (entityHit instanceof EntityLivingBase) {
		((EntityLivingBase) entityHit).addPotionEffect(new PotionEffect(ModPotions.NULLIFY_GRAVITY, 2, 1, true, false));
		((EntityLivingBase) entityHit).addPotionEffect(new PotionEffect(ModPotions.NULL_MOVEMENT, 2, 1, true, false));
	}

	return true;
}
 
Example 4
Source File: TeleportEntity.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static Entity teleportEntityInsideSameDimension(Entity entity, double x, double y, double z)
{
    // Load the chunk first
    entity.getEntityWorld().getChunk((int) Math.floor(x / 16D), (int) Math.floor(z / 16D));

    entity.setLocationAndAngles(x, y, z, entity.rotationYaw, entity.rotationPitch);
    entity.setPositionAndUpdate(x, y, z);
    return entity;
}
 
Example 5
Source File: TileEntityElevator.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void activateForEntity(Entity entity, boolean goingUp)
{
    Vec3d posDifference = this.getMoveVector(goingUp);

    if (posDifference != null)
    {
        entity.setPositionAndUpdate(entity.posX + posDifference.x, entity.posY + posDifference.y, entity.posZ + posDifference.z);
        this.getWorld().playSound(null, entity.getPosition(), SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.MASTER, 0.3f, 1.8f);
    }
}