net.minecraft.util.math.Vec3d Java Examples
The following examples show how to use
net.minecraft.util.math.Vec3d.
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: LibParticles.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
public static void SPIRIT_WIGHT_FLAME_FAR(World world, Vec3d pos) { ParticleBuilder glitter = new ParticleBuilder(30); glitter.setRender(new ResourceLocation(Wizardry.MODID, MISC.SPARKLE_BLURRED)); glitter.setAlphaFunction(new InterpFloatInOut(0.3f, 0.3f)); ParticleSpawner.spawn(glitter, world, new StaticInterp<>(pos), 5, 0, (i, build) -> { double radius = 0.15; double theta = 2.0f * (float) Math.PI * RandUtil.nextFloat(); double r = radius * RandUtil.nextFloat(); double x = r * MathHelper.cos((float) theta); double z = r * MathHelper.sin((float) theta); glitter.setColorFunction(new InterpColorHSV(Color.RED, 50, 20.0F)); glitter.setPositionOffset(new Vec3d(x, RandUtil.nextDouble(0, 0.5), z)); glitter.addMotion(new Vec3d(0, RandUtil.nextDouble(0, 0.02), 0)); }); }
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: LibParticles.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
public static void SPIRIT_WIGHT_HURT(World world, Vec3d pos) { ParticleBuilder glitter = new ParticleBuilder(RandUtil.nextInt(100, 150)); glitter.setColorFunction(new InterpColorHSV(Color.BLUE, 50, 20.0F)); glitter.setRender(new ResourceLocation(Wizardry.MODID, MISC.SPARKLE_BLURRED)); glitter.setAlphaFunction(new InterpFloatInOut(0.1f, 0.1f)); ParticleSpawner.spawn(glitter, world, new StaticInterp<>(pos), RandUtil.nextInt(40, 100), 0, (i, build) -> { double radius = 0.2; double theta = 2.0f * (float) Math.PI * RandUtil.nextFloat(); double r = radius * RandUtil.nextFloat(); double x = r * MathHelper.cos((float) theta); double z = r * MathHelper.sin((float) theta); glitter.setPositionOffset(new Vec3d(x, RandUtil.nextDouble(0, 0.4), z)); glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(0, 0.02), 0)); }); }
Example #4
Source File: CarpetEventServer.java From fabric-carpet with MIT License | 6 votes |
@Override public void onBlockHit(ServerPlayerEntity player, Hand enumhand, BlockHitResult hitRes)//ItemStack itemstack, Hand enumhand, BlockPos blockpos, Direction enumfacing, Vec3d vec3d) { handler.call( () -> { ItemStack itemstack = player.getStackInHand(enumhand); BlockPos blockpos = hitRes.getBlockPos(); Direction enumfacing = hitRes.getSide(); Vec3d vec3d = hitRes.getPos().subtract(blockpos.getX(), blockpos.getY(), blockpos.getZ()); return Arrays.asList( ((c, t) -> new EntityValue(player)), ((c, t) -> ListValue.fromItemStack(itemstack)), ((c, t) -> new StringValue(enumhand == Hand.MAIN_HAND ? "mainhand" : "offhand")), ((c, t) -> new BlockValue(null, player.getServerWorld(), blockpos)), ((c, t) -> new StringValue(enumfacing.getName())), ((c, t) -> ListValue.of( new NumericValue(vec3d.x), new NumericValue(vec3d.y), new NumericValue(vec3d.z) )) ); }, player::getCommandSource); }
Example #5
Source File: Nuker.java From bleachhack-1.14 with GNU General Public License v3.0 | 6 votes |
public boolean canSeeBlock(BlockPos pos) { double diffX = pos.getX() + 0.5 - mc.player.getCameraPosVec(mc.getTickDelta()).x; double diffY = pos.getY() + 0.5 - mc.player.getCameraPosVec(mc.getTickDelta()).y; double diffZ = pos.getZ() + 0.5 - mc.player.getCameraPosVec(mc.getTickDelta()).z; double diffXZ = Math.sqrt(diffX * diffX + diffZ * diffZ); float yaw = mc.player.yaw + MathHelper.wrapDegrees((float)Math.toDegrees(Math.atan2(diffZ, diffX)) - 90 - mc.player.yaw); float pitch = mc.player.pitch + MathHelper.wrapDegrees((float)-Math.toDegrees(Math.atan2(diffY, diffXZ)) - mc.player.pitch); Vec3d rotation = new Vec3d( (double)(MathHelper.sin(-yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F)), (double)(-MathHelper.sin(pitch * 0.017453292F)), (double)(MathHelper.cos(-yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F))); Vec3d rayVec = mc.player.getCameraPosVec(mc.getTickDelta()).add(rotation.x * 6, rotation.y * 6, rotation.z * 6); return mc.world.rayTrace(new RayTraceContext(mc.player.getCameraPosVec(mc.getTickDelta()), rayVec, RayTraceContext.ShapeType.OUTLINE, RayTraceContext.FluidHandling.NONE, mc.player)) .getBlockPos().equals(pos); }
Example #6
Source File: BlockPassengerChair.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (!worldIn.isRemote) { Vec3d chairPos = getPlayerMountOffset(state, pos); TileEntity chairTile = worldIn.getTileEntity(pos); if (chairTile instanceof TileEntityPassengerChair) { // Try mounting the player onto the chair if possible. ((TileEntityPassengerChair) chairTile).tryToMountPlayerToChair(playerIn, chairPos); } else { new IllegalStateException( "world.getTileEntity() returned a tile that wasn't a chair at pos " + pos) .printStackTrace(); } } return true; }
Example #7
Source File: LibParticles.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
public static void MAGIC_DOT(World world, Vec3d pos, float scale) { ParticleBuilder glitter = new ParticleBuilder(3); glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED)); glitter.setAlphaFunction(new InterpFloatInOut(1f, 1f)); glitter.enableMotionCalculation(); ParticleSpawner.spawn(glitter, world, new StaticInterp<>(pos), 1, 0, (aFloat, particleBuilder) -> { glitter.setColor(new Color(RandUtil.nextInt(0, 100), RandUtil.nextInt(0, 100), RandUtil.nextInt(50, 255))); if (scale == -1) glitter.setScale(RandUtil.nextFloat()); else { glitter.setAlphaFunction(new InterpFloatInOut(1f, 1f)); glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(0.3), 0)); glitter.setLifetime(RandUtil.nextInt(30)); glitter.setScale(scale); } }); }
Example #8
Source File: KaboomHack.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
private ArrayList<BlockPos> getBlocksByDistanceReversed(double range) { Vec3d eyesVec = RotationUtils.getEyesPos().subtract(0.5, 0.5, 0.5); double rangeSq = Math.pow(range + 0.5, 2); int rangeI = (int)Math.ceil(range); BlockPos center = new BlockPos(RotationUtils.getEyesPos()); BlockPos min = center.add(-rangeI, -rangeI, -rangeI); BlockPos max = center.add(rangeI, rangeI, rangeI); return BlockUtils.getAllInBox(min, max).stream() .filter(pos -> eyesVec.squaredDistanceTo(Vec3d.of(pos)) <= rangeSq) .sorted(Comparator.comparingDouble( pos -> -eyesVec.squaredDistanceTo(Vec3d.of(pos)))) .collect(Collectors.toCollection(() -> new ArrayList<>())); }
Example #9
Source File: BramblesBlock.java From the-hallow with MIT License | 6 votes |
@SuppressWarnings("deprecation") @Override public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { if (entity instanceof LivingEntity && entity.getType() != HallowedEntities.CROW && entity.getType() != HallowedEntities.PUMPCOWN) { entity.slowMovement(state, new Vec3d(0.800000011920929D, 0.75D, 0.800000011920929D)); if (!world.isClient && (entity.lastRenderX != entity.getX() || entity.lastRenderZ != entity.getZ())) { double entityX = Math.abs(entity.getX() - entity.lastRenderX); double entityZ = Math.abs(entity.getZ() - entity.lastRenderZ); if (entityX >= 0.003000000026077032D || entityZ >= 0.003000000026077032D) { entity.damage(DAMAGE_SOURCE, 1.0F); } } } }
Example #10
Source File: RenderUtils.java From bleachhack-1.14 with GNU General Public License v3.0 | 6 votes |
public static void drawFilledBox(AxisAlignedBB box, float r, float g, float b, float a) { gl11Setup(); Vec3d ren = renderPos(); /* Fill */ Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buffer = tessellator.getBuffer(); buffer.begin(5, DefaultVertexFormats.POSITION_COLOR); WorldRenderer.addChainedFilledBoxVertices(buffer, box.minX - ren.x, box.minY - ren.y, box.minZ - ren.z, box.maxX - ren.x, box.maxY - ren.y, box.maxZ - ren.z, r, g, b, a/2f); tessellator.draw(); /* Outline */ WorldRenderer.drawSelectionBoundingBox(new AxisAlignedBB( box.minX - ren.x, box.minY - ren.y, box.minZ - ren.z, box.maxX - ren.x, box.maxY - ren.y, box.maxZ - ren.z), r, g, b, a); gl11Cleanup(); }
Example #11
Source File: Flight.java From bleachhack-1.14 with GNU General Public License v3.0 | 6 votes |
public void onUpdate() { if (this.isToggled()) { float speed = (float) getSettings().get(1).toSlider().getValue(); if (getSettings().get(0).toMode().mode == 0) { mc.player.abilities.setFlySpeed(speed / 10); mc.player.abilities.allowFlying = true; mc.player.abilities.isFlying = true; } else if (getSettings().get(0).toMode().mode == 1) { mc.player.setMotion(0, mc.player.ticksExisted % 20 == 0 ? -0.06 : 0, 0); Vec3d forward = new Vec3d(0, 0, speed).rotateYaw(-(float) Math.toRadians(mc.player.rotationYaw)); Vec3d strafe = forward.rotateYaw((float) Math.toRadians(90)); if (mc.gameSettings.keyBindJump.isKeyDown()) mc.player.setMotion(mc.player.getMotion().add(0, speed, 0)); if (mc.gameSettings.keyBindSneak.isKeyDown()) mc.player.setMotion(mc.player.getMotion().add(0, -speed, 0)); if (mc.gameSettings.keyBindForward.isKeyDown()) mc.player.setMotion(mc.player.getMotion().add(forward.x, 0, forward.z)); if (mc.gameSettings.keyBindBack.isKeyDown()) mc.player.setMotion(mc.player.getMotion().add(-forward.x, 0, -forward.z)); if (mc.gameSettings.keyBindLeft.isKeyDown()) mc.player.setMotion(mc.player.getMotion().add(strafe.x, 0, strafe.z)); if (mc.gameSettings.keyBindRight.isKeyDown()) mc.player.setMotion(mc.player.getMotion().add(-strafe.x, 0, -strafe.z)); } else if (getSettings().get(0).toMode().mode == 2) { if (!mc.gameSettings.keyBindJump.isKeyDown()) return; mc.player.setMotion(mc.player.getMotion().x, speed / 3, mc.player.getMotion().z); } } }
Example #12
Source File: ExcavatorHack.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
private ArrayList<BlockPos> getValidBlocks(double range, Predicate<BlockPos> validator) { Vec3d eyesVec = RotationUtils.getEyesPos().subtract(0.5, 0.5, 0.5); double rangeSq = Math.pow(range + 0.5, 2); int rangeI = (int)Math.ceil(range); BlockPos center = new BlockPos(RotationUtils.getEyesPos()); BlockPos min = center.add(-rangeI, -rangeI, -rangeI); BlockPos max = center.add(rangeI, rangeI, rangeI); return BlockUtils.getAllInBox(min, max).stream() .filter(pos -> eyesVec.squaredDistanceTo(Vec3d.of(pos)) <= rangeSq) .filter(BlockUtils::canBeClicked).filter(validator) .sorted(Comparator.comparingDouble( pos -> eyesVec.squaredDistanceTo(Vec3d.of(pos)))) .collect(Collectors.toCollection(() -> new ArrayList<>())); }
Example #13
Source File: EntityMountable.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
@Override protected void writeEntityToNBT(NBTTagCompound compound) { // Try to prevent data race Vec3d mountPosLocal = mountPos; compound.setDouble("vs_mount_pos_x", mountPosLocal.x); compound.setDouble("vs_mount_pos_y", mountPosLocal.y); compound.setDouble("vs_mount_pos_z", mountPosLocal.z); compound.setInteger("vs_coord_type", mountPosSpace.ordinal()); compound.setBoolean("vs_ref_pos_present", referencePos != null); if (referencePos != null) { compound.setInteger("vs_ref_pos_x", referencePos.getX()); compound.setInteger("vs_ref_pos_y", referencePos.getY()); compound.setInteger("vs_ref_pos_z", referencePos.getZ()); } }
Example #14
Source File: Helper.java From TFC2 with GNU General Public License v3.0 | 6 votes |
/** * Rotates a Vec3d around an arbitrary rotation point along an axis with a rotation in radians */ public static Vec3d rotateVertex(Vec3d origin, Vec3d src, Vec3d axis, double rotation) { double q0 = 1; double q1 = 0; double q2 = 0; double q3 = 0; double norm = axis.lengthVector(); if (norm == 0) { throw new ArithmeticException("zero norm for rotation axis"); } double halfAngle = -0.5 * rotation; double coeff = Math.sin(halfAngle) / norm; q0 = Math.cos (halfAngle); q1 = coeff * axis.xCoord; q2 = coeff * axis.yCoord; q3 = coeff * axis.zCoord; return origin.add(applyTo(src.subtract(origin), q0, q1, q2, q3)); }
Example #15
Source File: NukerModule.java From seppuku with GNU General Public License v3.0 | 5 votes |
@Listener public void onWalkingUpdate(EventUpdateWalkingPlayer event) { if (event.getStage() == EventStageable.EventStage.PRE) { BlockPos pos = null; switch (this.mode.getValue()) { case SELECTION: pos = this.getClosestBlockSelection(); break; case ALL: pos = this.getClosestBlockAll(); break; } if (pos != null) { final Minecraft mc = Minecraft.getMinecraft(); final float[] angle = MathUtil.calcAngle(mc.player.getPositionEyes(mc.getRenderPartialTicks()), new Vec3d(pos.getX() + 0.5f, pos.getY() + 0.5f, pos.getZ() + 0.5f)); Seppuku.INSTANCE.getRotationManager().setPlayerRotations(angle[0], angle[1]); if (canBreak(pos)) { mc.playerController.onPlayerDamageBlock(pos, mc.player.getHorizontalFacing()); mc.player.swingArm(EnumHand.MAIN_HAND); } } } }
Example #16
Source File: SoundPhysics.java From Sound-Physics with GNU General Public License v3.0 | 5 votes |
private static Vec3d reflect(Vec3d dir, Vec3d normal) { //dir - 2.0 * dot(normal, dir) * normal double dot = dir.dotProduct(normal); double x = dir.xCoord - 2.0 * dot * normal.xCoord; double y = dir.yCoord - 2.0 * dot * normal.yCoord; double z = dir.zCoord - 2.0 * dot * normal.zCoord; return new Vec3d(x, y, z); }
Example #17
Source File: BreadCrumbs.java From ForgeHax with MIT License | 5 votes |
private static boolean isVisible(Anchor anchor) { if (!MC.world.isAreaLoaded(new BlockPos(anchor.pos), 1, false)) { return false; } else { Vec3d from = new Vec3d(MC.player.posX, MC.player.posY, MC.player.posZ); RayTraceResult result = MC.world.rayTraceBlocks(from, anchor.pos, false, true, true); return result == null || result.typeOfHit == RayTraceResult.Type.MISS; } }
Example #18
Source File: BaseVehicleEntity.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
public AxisAlignedBB getEncompassingBoundingBox() { Area a = getArea(); return new AxisAlignedBB( new Vec3d(a.startX, a.startY, a.startZ) .subtract(getOffset().getX(), getOffset().getY(), getOffset().getZ()).add(getPositionVector()), new Vec3d(a.endX + 1, a.endY + 1, a.endZ + 1) .subtract(getOffset().getX(), getOffset().getY(), getOffset().getZ()).add(getPositionVector())); }
Example #19
Source File: Tracers.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Subscribe public void onRender(Event3DRender event) { final float thick = (float) getSettings().get(6).toSlider().getValue(); for (Entity e: mc.world.getEntities()) { Vec3d vec = e.getPos(); Vec3d vec2 = new Vec3d(0, 0, 75).rotateX(-(float) Math.toRadians(mc.cameraEntity.pitch)) .rotateY(-(float) Math.toRadians(mc.cameraEntity.yaw)) .add(mc.cameraEntity.getPos().add(0, mc.cameraEntity.getEyeHeight(mc.cameraEntity.getPose()), 0)); if (e instanceof PlayerEntity && e != mc.player && e != mc.cameraEntity && getSettings().get(0).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f,0f,0f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f,0f,0f,thick); } else if (e instanceof Monster && getSettings().get(1).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0f,0f,0f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0f,0f,0f,thick); } else if (EntityUtils.isAnimal(e) && getSettings().get(2).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0f,1f,0f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0f,1f,0f,thick); } else if (e instanceof ItemEntity && getSettings().get(3).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f,0.7f,0f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f,0.7f,0f,thick); } else if (e instanceof EnderCrystalEntity && getSettings().get(4).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,1f, 0f, 1f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,1f, 0f, 1f,thick); } else if ((e instanceof BoatEntity || e instanceof AbstractMinecartEntity) && getSettings().get(5).toToggle().state) { RenderUtils.drawLine(vec2.x,vec2.y,vec2.z,vec.x,vec.y,vec.z,0.5f, 0.5f, 0.5f,thick); RenderUtils.drawLine(vec.x,vec.y,vec.z, vec.x,vec.y+(e.getHeight()/1.1),vec.z,0.5f, 0.5f, 0.5f,thick); } } }
Example #20
Source File: ModuleEffectFrost.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@ModuleOverride("shape_zone_run") public boolean onRunZone(World world, SpellData data, SpellRing ring, @ContextRing SpellRing childRing) { if(!world.isRemote) return false; double aoe = ring.getAttributeValue(world, AttributeRegistry.AREA, data); double range = ring.getAttributeValue(world, AttributeRegistry.RANGE, data); Vec3d targetPos = data.getTarget(world); if (targetPos == null) return false; Vec3d min = targetPos.subtract(aoe, range, aoe); Vec3d max = targetPos.add(aoe, range, aoe); List<Entity> entities = world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(min, max)); for (Entity entity : entities) { entity.extinguish(); if (entity instanceof EntityLivingBase) { if (!((EntityLivingBase) entity).isPotionActive(ModPotions.SLIPPERY) && entity.getDistanceSq(targetPos.x, targetPos.y, targetPos.z) <= aoe * aoe) { double time = childRing.getAttributeValue(world, AttributeRegistry.DURATION, data) * 10; world.playSound(null, entity.getPosition(), ModSounds.FROST_FORM, SoundCategory.NEUTRAL, 1, 1); ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(ModPotions.SLIPPERY, (int) time, 0, true, false)); } } } return false; }
Example #21
Source File: ItemPortalScaler.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
public Vec3d getDestinationPosition(ItemStack stack, EntityPlayer player, int destDimension) { ItemStack cardStack = this.getSelectedModuleStack(stack, ModuleType.TYPE_MEMORY_CARD_MISC); NBTTagCompound moduleNbt = cardStack.getTagCompound(); NBTTagCompound tag = moduleNbt.getCompoundTag("PortalScaler"); byte scaleX = tag.getByte("scaleX"); byte scaleY = tag.getByte("scaleY"); byte scaleZ = tag.getByte("scaleZ"); // Don't divide by zero on accident!! if (scaleX == 0) { scaleX = 8; } if (scaleY == 0) { scaleY = 1; } if (scaleZ == 0) { scaleZ = 8; } double dScaleX = scaleX; double dScaleY = scaleY; double dScaleZ = scaleZ; if (scaleX < 0) { dScaleX = -1.0d / (double)scaleX; } if (scaleY < 0) { dScaleY = -1.0d / (double)scaleY; } if (scaleZ < 0) { dScaleZ = -1.0d / (double)scaleZ; } // Going from the Overworld to the Nether if (destDimension == DimensionType.NETHER.getId()) { dScaleX = 1.0d / dScaleX; dScaleY = 1.0d / dScaleY; dScaleZ = 1.0d / dScaleZ; } World world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(destDimension); return PositionUtils.getScaledClampedPosition(player.getPositionVector(), world, dScaleX, dScaleY, dScaleZ, 32); }
Example #22
Source File: NoSlow.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Subscribe public void onTick(EventTick event) { if (!isToggled()) return; /* Slowness */ if (getSettings().get(0).toToggle().state && (mc.player.getStatusEffect(StatusEffects.SLOWNESS) != null || mc.player.getStatusEffect(StatusEffects.BLINDNESS) != null)) { if (mc.options.keyForward.isPressed() && mc.player.getVelocity().x > -0.15 && mc.player.getVelocity().x < 0.15 && mc.player.getVelocity().z > -0.15 && mc.player.getVelocity().z < 0.15) { mc.player.setVelocity(mc.player.getVelocity().add(addVelocity)); addVelocity = addVelocity.add(new Vec3d(0, 0, 0.05).rotateY(-(float)Math.toRadians(mc.player.yaw))); } else addVelocity = addVelocity.multiply(0.75, 0.75, 0.75); } /* Soul Sand */ if (getSettings().get(1).toToggle().state && WorldUtils.doesBoxTouchBlock(mc.player.getBoundingBox(), Blocks.SOUL_SAND)) { Vec3d m = new Vec3d(0, 0, 0.125).rotateY(-(float) Math.toRadians(mc.player.yaw)); if (!mc.player.abilities.flying && mc.options.keyForward.isPressed()) { mc.player.setVelocity(mc.player.getVelocity().add(m)); } } /* Slime Block */ if (getSettings().get(2).toToggle().state && WorldUtils.doesBoxTouchBlock(mc.player.getBoundingBox().offset(0,-0.02,0), Blocks.SLIME_BLOCK)) { Vec3d m1 = new Vec3d(0, 0, 0.1).rotateY(-(float) Math.toRadians(mc.player.yaw)); if (!mc.player.abilities.flying && mc.options.keyForward.isPressed()) { mc.player.setVelocity(mc.player.getVelocity().add(m1)); } } /* Web */ if (getSettings().get(3).toToggle().state && WorldUtils.doesBoxTouchBlock(mc.player.getBoundingBox(), Blocks.COBWEB)) { Vec3d m2 = new Vec3d(0, -1, 0.9).rotateY(-(float) Math.toRadians(mc.player.yaw)); if (!mc.player.abilities.flying && mc.options.keyForward.isPressed()) { mc.player.setVelocity(mc.player.getVelocity().add(m2)); } } }
Example #23
Source File: EntitySpiritWight.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onDeath(DamageSource cause) { ClientRunnable.run(new ClientRunnable() { @Override @SideOnly(Side.CLIENT) public void runIfClient() { ParticleBuilder glitter = new ParticleBuilder(RandUtil.nextInt(100, 150)); glitter.setColor(Color.WHITE); glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED)); glitter.setAlphaFunction(new InterpFloatInOut(0.1f, 0.1f)); glitter.setAcceleration(Vec3d.ZERO); ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector().add(0, height, 0)), 1000, 0, (i, build) -> { double radius = 0.2; build.setDeceleration(new Vec3d(RandUtil.nextDouble(0.8, 0.95), RandUtil.nextDouble(0.8, 0.95), RandUtil.nextDouble(0.8, 0.95))); build.addMotion(new Vec3d(RandUtil.nextDouble(-radius, radius), RandUtil.nextDouble(-radius, radius), RandUtil.nextDouble(-radius, radius))); build.setLifetime(RandUtil.nextInt(200, 250)); build.setScaleFunction(new InterpScale(RandUtil.nextFloat(0.6f, 1.5f), 0)); if (RandUtil.nextBoolean()) build.setColor(Color.WHITE); else build.setColor(Color.YELLOW); }); } }); playSound(ModSounds.BASS_BOOM, 3, 0.5f); playSound(ModSounds.BASS_BOOM, 1, RandUtil.nextFloat(1, 1.5f)); super.onDeath(cause); }
Example #24
Source File: OverViewComponent.java From seppuku with GNU General Public License v3.0 | 5 votes |
private double getDist(float partialTicks) { final Minecraft mc = Minecraft.getMinecraft(); final Vec3d eyes = mc.player.getPositionEyes(partialTicks); final RayTraceResult ray = mc.world.rayTraceBlocks(eyes, eyes.add(0, this.distance, 0), false); if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK) { return mc.player.getDistance(ray.hitVec.x, ray.hitVec.y, ray.hitVec.z) - 4; } return this.distance; }
Example #25
Source File: BlockHighlightModule.java From seppuku with GNU General Public License v3.0 | 5 votes |
@Listener public void render3D(EventRender3D event) { final Minecraft mc = Minecraft.getMinecraft(); final RayTraceResult ray = mc.objectMouseOver; if(ray.typeOfHit == RayTraceResult.Type.BLOCK) { final BlockPos blockpos = ray.getBlockPos(); final IBlockState iblockstate = mc.world.getBlockState(blockpos); if (iblockstate.getMaterial() != Material.AIR && mc.world.getWorldBorder().contains(blockpos)) { final Vec3d interp = MathUtil.interpolateEntity(mc.player, mc.getRenderPartialTicks()); RenderUtil.drawBoundingBox(iblockstate.getSelectedBoundingBox(mc.world, blockpos).grow(0.0020000000949949026D).offset(-interp.x, -interp.y, -interp.z), 1.5f, 0xFF9900EE); } } }
Example #26
Source File: SoundPhysics.java From Sound-Physics with GNU General Public License v3.0 | 5 votes |
private static Vec3d offsetSoundByName(Vec3d soundPos, Vec3d playerPos, String name, String soundCategory) { double offsetX = 0.0; double offsetY = 0.0; double offsetZ = 0.0; double offsetTowardsPlayer = 0.0; Vec3d toPlayerVector = playerPos.subtract(soundPos).normalize(); //names if (name.matches(".*step.*")) { offsetY = 0.1; } //categories if (soundCategory.matches("block") || soundCategory.matches("record")) { offsetTowardsPlayer = 0.89; } if (soundPos.yCoord % 1.0 < 0.001 && soundPos.yCoord > 0.01) { offsetY = 0.1; } offsetX += toPlayerVector.xCoord * offsetTowardsPlayer; offsetY += toPlayerVector.yCoord * offsetTowardsPlayer; offsetZ += toPlayerVector.zCoord * offsetTowardsPlayer; //soundPos.xCoord += offsetX; //soundPos.yCoord += offsetY; //soundPos.zCoord += offsetZ; soundPos = soundPos.addVector(offsetX, offsetY, offsetZ); //logDetailed("Offset sound by " + offsetX + ", " + offsetY + ", " + offsetZ); return soundPos; }
Example #27
Source File: FluidWrapper.java From Sandbox with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Vec3d getVelocity(BlockView blockView_1, BlockPos blockPos_1, FluidState fluidState_1) { Mono<org.sandboxpowered.sandbox.api.util.math.Vec3d> mono = fluid.getVelocity( (WorldReader) blockView_1, (Position) blockPos_1, (org.sandboxpowered.sandbox.api.state.FluidState) fluidState_1 ); return mono.map(WrappingUtil::convert).orElseGet(() -> super.getVelocity(blockView_1, blockPos_1, fluidState_1)); }
Example #28
Source File: EntityJumpPad.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void collideWithEntity(Entity entity) { if (!(entity instanceof EntityLivingBase)) return; if (entity instanceof EntityJumpPad) return; ((EntityLivingBase) entity).motionY += 0.35; entity.fallDistance = 0; Color color1 = new Color( RandUtil.nextInt(100, 255), RandUtil.nextInt(100, 255), RandUtil.nextInt(100, 255), RandUtil.nextInt(100, 255)); Color color2 = new Color( RandUtil.nextInt(100, 255), RandUtil.nextInt(100, 255), RandUtil.nextInt(100, 255), RandUtil.nextInt(100, 255)); Vec3d normal = new Vec3d(entity.motionX, entity.motionY, entity.motionZ).normalize().scale(1 / 2.0); ClientRunnable.run(new ClientRunnable() { @Override @SideOnly(Side.CLIENT) public void runIfClient() { LibParticles.AIR_THROTTLE(world, entity.getPositionVector(), normal, color1, color2, 0.5); } }); }
Example #29
Source File: PacketExplode.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
public PacketExplode(Vec3d pos, Color color1, Color color2, double strengthUpwards, double strengthSideways, int amount, int lifeTime, int lifeTimeRange, boolean bounce) { this.pos = pos; this.color1 = color1; this.color2 = color2; this.strengthUpwards = strengthUpwards; this.strengthSideways = strengthSideways; this.amount = amount; this.lifeTime = lifeTime; this.lifeTimeRange = lifeTimeRange; this.bounce = bounce; }
Example #30
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); }