Java Code Examples for net.minecraft.entity.Entity#setVelocity()
The following examples show how to use
net.minecraft.entity.Entity#setVelocity() .
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: Jesus.java From bleachhack-1.14 with GNU General Public License v3.0 | 6 votes |
@Subscribe public void onTick(EventTick event) { Entity e = mc.player.getVehicle() != null ? mc.player.getVehicle() : mc.player; if (e.isSneaking() || e.fallDistance > 3f) return; if (WorldUtils.isFluid(new BlockPos(e.getPos().add(0,0.3,0)))) { e.setVelocity(e.getVelocity().x, 0.08, e.getVelocity().z); } else if (WorldUtils.isFluid(new BlockPos(e.getPos().add(0,0.1,0)))) { e.setVelocity(e.getVelocity().x, 0.05, e.getVelocity().z); } else if (WorldUtils.isFluid(new BlockPos(e.getPos().add(0,0.05,0)))) { e.setVelocity(e.getVelocity().x, 0.01, e.getVelocity().z); } else if (WorldUtils.isFluid(new BlockPos(e.getPos()))) { e.setVelocity(e.getVelocity().x, -0.005, e.getVelocity().z); e.onGround = true; } }
Example 2
Source File: Jesus.java From bleachhack-1.14 with GNU General Public License v3.0 | 6 votes |
@Subscribe public void onTick(EventTick event) { Entity e = mc.player.getVehicle() != null ? mc.player.getVehicle() : mc.player; if (e.isSneaking() || e.fallDistance > 3f) return; if (WorldUtils.isFluid(new BlockPos(e.getPos().add(0,0.3,0)))) { e.setVelocity(e.getVelocity().x, 0.08, e.getVelocity().z); } else if (WorldUtils.isFluid(new BlockPos(e.getPos().add(0,0.1,0)))) { e.setVelocity(e.getVelocity().x, 0.05, e.getVelocity().z); } else if (WorldUtils.isFluid(new BlockPos(e.getPos().add(0,0.05,0)))) { e.setVelocity(e.getVelocity().x, 0.01, e.getVelocity().z); } else if (WorldUtils.isFluid(new BlockPos(e.getPos()))) { e.setVelocity(e.getVelocity().x, -0.005, e.getVelocity().z); e.setOnGround(true); } }
Example 3
Source File: Jesus.java From bleachhack-1.14 with GNU General Public License v3.0 | 6 votes |
@Subscribe public void onTick(EventTick event) { Entity e = mc.player.getVehicle() != null ? mc.player.getVehicle() : mc.player; if (e.isSneaking() || e.fallDistance > 3f) return; if (WorldUtils.isFluid(new BlockPos(e.getPos().add(0,0.3,0)))) { e.setVelocity(e.getVelocity().x, 0.08, e.getVelocity().z); } else if (WorldUtils.isFluid(new BlockPos(e.getPos().add(0,0.1,0)))) { e.setVelocity(e.getVelocity().x, 0.05, e.getVelocity().z); } else if (WorldUtils.isFluid(new BlockPos(e.getPos().add(0,0.05,0)))) { e.setVelocity(e.getVelocity().x, 0.01, e.getVelocity().z); } else if (WorldUtils.isFluid(new BlockPos(e.getPos()))) { e.setVelocity(e.getVelocity().x, -0.005, e.getVelocity().z); e.onGround = true; } }
Example 4
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 5
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)); }
Example 6
Source File: EntityMixin.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setVelocity(Lnet/minecraft/util/math/Vec3d;)V", opcode = Opcodes.INVOKEVIRTUAL, ordinal = 0), method = {"updateMovementInFluid(Lnet/minecraft/tag/Tag;D)Z"}) private void setVelocityFromFluid(Entity entity, Vec3d velocity) { VelocityFromFluidEvent event = new VelocityFromFluidEvent(); WurstClient.INSTANCE.getEventManager().fire(event); if(!event.isCancelled()) entity.setVelocity(velocity); }
Example 7
Source File: ExplosionMixin.java From fabric-carpet with MIT License | 5 votes |
@Redirect(method = "collectBlocksAndDamageEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setVelocity(Lnet/minecraft/util/math/Vec3d;)V")) private void setVelocityAndUpdateLogging(Entity entity, Vec3d velocity) { if (eLogger != null) { eLogger.onEntityImpacted(entity, velocity.subtract(entity.getVelocity())); } entity.setVelocity(velocity); }
Example 8
Source File: PistonBlockEntity_creativeNoClipMixin.java From fabric-carpet with MIT License | 4 votes |
@Redirect(method = "pushEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setVelocity(DDD)V")) private void ignoreAccel(Entity entity, double x, double y, double z) { if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).abilities.flying) return; entity.setVelocity(x,y,z); }
Example 9
Source File: BlockDrawingHelper.java From malmo with MIT License | 4 votes |
/** Spawn a single entity at the specified position. * @param e the actual entity to be spawned. * @param w the world in which to spawn the entity. * @throws Exception */ private void DrawPrimitive( DrawEntity e, World w ) throws Exception { String oldEntityName = e.getType().getValue(); String id = null; for (EntityEntry ent : net.minecraftforge.fml.common.registry.ForgeRegistries.ENTITIES) { if (ent.getName().equals(oldEntityName)) { id = ent.getRegistryName().toString(); break; } } if (id == null) return; NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setString("id", id); nbttagcompound.setBoolean("PersistenceRequired", true); // Don't let this entity despawn Entity entity; try { entity = EntityList.createEntityFromNBT(nbttagcompound, w); if (entity != null) { positionEntity(entity, e.getX().doubleValue(), e.getY().doubleValue(), e.getZ().doubleValue(), e.getYaw().floatValue(), e.getPitch().floatValue()); entity.setVelocity(e.getXVel().doubleValue(), e.getYVel().doubleValue(), e.getZVel().doubleValue()); // Set all the yaw values imaginable: if (entity instanceof EntityLivingBase) { ((EntityLivingBase)entity).rotationYaw = e.getYaw().floatValue(); ((EntityLivingBase)entity).prevRotationYaw = e.getYaw().floatValue(); ((EntityLivingBase)entity).prevRotationYawHead = e.getYaw().floatValue(); ((EntityLivingBase)entity).rotationYawHead = e.getYaw().floatValue(); ((EntityLivingBase)entity).prevRenderYawOffset = e.getYaw().floatValue(); ((EntityLivingBase)entity).renderYawOffset = e.getYaw().floatValue(); } w.getBlockState(entity.getPosition()); // Force-load the chunk if necessary, to ensure spawnEntity will work. if (!w.spawnEntity(entity)) { System.out.println("WARNING: Failed to spawn entity! Chunk not loaded?"); } } } catch (RuntimeException runtimeexception) { // Cannot summon this entity. throw new Exception("Couldn't create entity type: " + e.getType().getValue()); } }