Java Code Examples for net.minecraft.entity.Entity#getVelocity()
The following examples show how to use
net.minecraft.entity.Entity#getVelocity() .
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: FMLPlayMessages.java From patchwork-api with GNU Lesser General Public License v2.1 | 6 votes |
public SpawnEntity(Entity entity) { this.entity = entity; this.typeId = Registry.ENTITY_TYPE.getRawId(entity.getType()); this.entityId = entity.getEntityId(); this.uuid = entity.getUuid(); this.posX = entity.x; this.posY = entity.y; this.posZ = entity.z; this.pitch = (byte) MathHelper.floor(entity.pitch * 256.0F / 360.0F); this.yaw = (byte) MathHelper.floor(entity.yaw * 256.0F / 360.0F); this.headYaw = (byte) (entity.getHeadYaw() * 256.0F / 360.0F); Vec3d velocity = entity.getVelocity(); double clampedVelX = MathHelper.clamp(velocity.x, -3.9D, 3.9D); double clampedVelY = MathHelper.clamp(velocity.y, -3.9D, 3.9D); double clampedVelZ = MathHelper.clamp(velocity.z, -3.9D, 3.9D); this.velX = (int) (clampedVelX * 8000.0D); this.velY = (int) (clampedVelY * 8000.0D); this.velZ = (int) (clampedVelZ * 8000.0D); this.buf = null; }
Example 2
Source File: MobAI.java From fabric-carpet with MIT License | 6 votes |
/** * Not a replacement for living entity jump() - this barely is to allow other entities that can't jump in vanilla to 'jump' * @param e */ public static void genericJump(Entity e) { if (!e.onGround && !e.isInFluid(FluidTags.WATER) && !e.isInLava()) return; float m = e.world.getBlockState(new BlockPos(e)).getBlock().getJumpVelocityMultiplier(); float g = e.world.getBlockState(new BlockPos(e.getX(), e.getBoundingBox().y1 - 0.5000001D, e.getZ())).getBlock().getJumpVelocityMultiplier(); float jumpVelocityMultiplier = (double) m == 1.0D ? g : m; float jumpStrength = (0.42F * jumpVelocityMultiplier); Vec3d vec3d = e.getVelocity(); e.setVelocity(vec3d.x, jumpStrength, vec3d.z); if (e.isSprinting()) { float u = e.yaw * 0.017453292F; e.setVelocity(e.getVelocity().add((-MathHelper.sin(g) * 0.2F), 0.0D, (MathHelper.cos(u) * 0.2F))); } e.velocityDirty = true; }
Example 3
Source File: BoatFlyHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
@Override public void onUpdate() { // check if riding if(!MC.player.hasVehicle()) return; // fly Entity vehicle = MC.player.getVehicle(); Vec3d velocity = vehicle.getVelocity(); double motionY = MC.options.keyJump.isPressed() ? 0.3 : 0; vehicle.setVelocity(new Vec3d(velocity.x, motionY, velocity.z)); }