Java Code Examples for net.minecraft.entity.Entity#hasNoGravity()
The following examples show how to use
net.minecraft.entity.Entity#hasNoGravity() .
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: ModuleEffectLeap.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@Override @SideOnly(Side.CLIENT) public void renderSpell(World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) { Vec3d position = spell.getTarget(world); Entity entityHit = spell.getVictim(world); if (position == null) return; if (entityHit == null) return; if (!entityHit.hasNoGravity()) { Vec3d normal = new Vec3d(entityHit.motionX, entityHit.motionY, entityHit.motionZ).normalize().scale(1 / 2.0); LibParticles.AIR_THROTTLE(world, position, normal, instance.getPrimaryColor(), instance.getSecondaryColor(), 0.5); } }
Example 2
Source File: ModuleEffectLeap.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean run(@NotNull World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) { Vec3d lookVec = spell.getData(LOOK); Entity target = spell.getVictim(world); if (!(target instanceof EntityLivingBase)) return true; ItemStack stack = ((EntityLivingBase) target).getHeldItemMainhand(); if (stack.isEmpty()) return true; if (lookVec == null) return true; if (!target.hasNoGravity()) { double potency = spellRing.getAttributeValue(world, AttributeRegistry.POTENCY, spell); if (!spellRing.taxCaster(world, spell, true)) return false; if (!NBTHelper.hasNBTEntry(stack, "jump_count") || !NBTHelper.hasNBTEntry(stack, "max_jumps") || !NBTHelper.hasNBTEntry(stack, "jump_timer")) { NBTHelper.setInt(stack, "jump_count", (int) potency); NBTHelper.setInt(stack, "max_jumps", (int) potency); NBTHelper.setInt(stack, "jump_timer", 200); } target.motionX += lookVec.x; target.motionY += 0.65; target.motionZ += lookVec.z; target.velocityChanged = true; target.fallDistance /= (1 + MathHelper.ceil(spellRing.getAttributeValue(world, AttributeRegistry.POTENCY, spell) / 8)); if (target instanceof EntityPlayerMP) ((EntityPlayerMP) target).connection.sendPacket(new SPacketEntityVelocity(target)); world.playSound(null, target.getPosition(), ModSounds.FLY, SoundCategory.NEUTRAL, 1, 1); } return true; }
Example 3
Source File: PotionTimeSlow.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent(priority = EventPriority.HIGHEST) public static void entityPreUpdate(EntityUpdateEvent event) { Entity entity = event.getEntity(); float scale = timeScale(entity); if (!entity.hasNoGravity() && scale > 0) { double gravity = entity instanceof EntityLivingBase ? -0.08 : -0.04; entity.motionY -= gravity * (1 - scale); } }
Example 4
Source File: GravityHandler.java From AdvancedRocketry with MIT License | 4 votes |
public static void applyGravity(Entity entity) { if(entity.hasNoGravity()) return; if(!entity.isInWater() || entity instanceof EntityItem) { if(!(entity instanceof EntityPlayer) || !((EntityPlayer)entity).capabilities.isFlying) { Double d; if(entityMap.containsKey(entity) && (d = entityMap.get(entity)) != null) { double multiplier = (entity instanceof EntityItem) ? ITEM_GRAV_OFFSET*d : 0.075f*d; entity.motionY += multiplier; } else if(DimensionManager.getInstance().isDimensionCreated(entity.world.provider.getDimension()) || entity.world.provider instanceof WorldProviderSpace) { double gravMult; if(entity.world.provider instanceof IPlanetaryProvider) gravMult = ((IPlanetaryProvider)entity.world.provider).getGravitationalMultiplier(entity.getPosition()); else gravMult = DimensionManager.getInstance().getDimensionProperties(entity.world.provider.getDimension()).gravitationalMultiplier; if(entity instanceof EntityItem) entity.motionY -= gravMult*ITEM_GRAV_OFFSET; else//Not-Items are not ASMed, so they have to subtract the original gravity. entity.motionY -= (gravMult*ENTITY_OFFSET - ENTITY_OFFSET); return; } else { //GC handling if(gcWorldProvider != null && gcWorldProvider.isAssignableFrom(entity.world.provider.getClass())) { try { entity.motionY -= 0.075f - (float)gcGetGravity.invoke(entity.world.provider); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); } } else { if(entity instanceof EntityItem) entity.motionY -= ITEM_GRAV_OFFSET; //else//Without the ASM, this added extra gravity in overworld on SMP //entity.motionY -= 0.005d; } } } } }