net.minecraft.entity.MoverType Java Examples

The following examples show how to use net.minecraft.entity.MoverType. 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: EntityFallingBlockEU.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void updateMovement()
{
    if (this.hasNoGravity() == false)
    {
        this.motionY -= 0.04D;
    }

    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;

    this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ);

    this.motionX *= 0.98D;
    this.motionY *= 0.98D;
    this.motionZ *= 0.98D;
}
 
Example #2
Source File: BWRigidBody.java    From NOVA-Core with GNU Lesser General Public License v3.0 6 votes vote down vote up
void updateTranslation(double deltaTime) {
	//Integrate velocity to displacement
	Vector3D displacement = velocity().scalarMultiply(deltaTime);
	mcEntity().move(MoverType.SELF, displacement.getX(), displacement.getY(), displacement.getZ());

	//Integrate netForce to velocity
	setVelocity(velocity().add(netForce.scalarMultiply(1 / mass()).scalarMultiply(deltaTime)));

	//Clear net force
	netForce = Vector3D.ZERO;

	//Apply drag
	addForce(velocity().negate().scalarMultiply(drag()));
	if (!mcEntity().onGround) {
		//Apply gravity
		addForce(gravity().scalarMultiply(mass()));
	}
}
 
Example #3
Source File: EntityMoveInjectionMethods.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
public static IntermediateMovementVariableStorage handleMove(MoverType type, double dx,
    double dy, double dz, Entity this_) {
    if (this_ instanceof PhysicsWrapperEntity) {
        //Don't move at all
        return null;
    }
    if (this_ instanceof EntityPlayer && ((EntityPlayer) this_).isSpectator()) {
        return null;
    }

    double movDistSq = (dx * dx) + (dy * dy) + (dz * dz);

    if (movDistSq > 10000) {
        // Assume this_ will take us to Ship coordinates
        double newX = this_.posX + dx;
        double newY = this_.posY + dy;
        double newZ = this_.posZ + dz;
        BlockPos newPosInBlock = new BlockPos(newX, newY, newZ);
        Optional<PhysicsObject> physicsObject = ValkyrienUtils
            .getPhysicsObject(this_.world, newPosInBlock);

        if (!physicsObject.isPresent()) {
            return null;
        }

        Vector endPos = new Vector(newX, newY, newZ);
        physicsObject.get()
            .getShipTransformationManager()
            .getCurrentTickTransform()
            .transform(endPos, TransformType.GLOBAL_TO_SUBSPACE);
        dx = endPos.X - this_.posX;
        dy = endPos.Y - this_.posY;
        dz = endPos.Z - this_.posZ;
    }

    IntermediateMovementVariableStorage alteredMovement = EntityCollisionInjector
        .alterEntityMovement(this_, type, dx, dy, dz);

    return alteredMovement;
}
 
Example #4
Source File: EntityBlock.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Override
public void onUpdate() {
	if (posY < -500.0D) {
		setDead();
		return;
	}

	if (hasGravity) {
		motionY -= 0.03999999910593033D;
	}
	if (hasAirResistance) {
		motionX *= 0.98;
		motionY *= 0.98;
		motionZ *= 0.98;
	}
	prevPosX = posX;
	prevPosY = posY;
	prevPosZ = posZ;

	extinguish();
	move(MoverType.SELF, motionX, motionY, motionZ);

	final Block block = blockState.getBlock();
	if (block == null) setDead();
	// TODO missing functionality, fix (fake world access?)
	// setHeight((float)block.getBlockBoundsMaxY());

	if (world instanceof WorldServer && shouldPlaceBlock()) {
		if (!tryPlaceBlock((WorldServer)world, getDropPos())) dropBlock();

		setDead();
	}
}
 
Example #5
Source File: EntityItemAbducted.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void onUpdate() {
	ItemStack stack = this.getDataManager().get(ITEM);
	
       if (this.getEntityItem() == null)
       {
           this.setDead();
       }
       //super.onEntityUpdate();
       
       this.prevPosX = this.posX;
       this.prevPosY = this.posY;
       this.prevPosZ = this.posZ;
       
       this.move(MoverType.SELF,this.motionX, this.motionY, this.motionZ);

       ++this.age;

       if (!this.world.isRemote && this.age >= lifespan)
       {
       	this.setDead();
       }

       if (stack != null && stack.getCount() <= 0)
       {
           this.setDead();
       }
}
 
Example #6
Source File: MixinEntityIntrinsic.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Inject(method = "move", at = @At("HEAD"), cancellable = true)
public void changeMoveArgs(MoverType type, double dx, double dy, double dz,
    CallbackInfo callbackInfo) {
    if (!hasChanged) {
        alteredMovement = EntityMoveInjectionMethods
            .handleMove(type, dx, dy, dz, thisClassAsAnEntity);
        if (alteredMovement != null) {
            hasChanged = true;
            this.move(type, alteredMovement.dxyz.X, alteredMovement.dxyz.Y,
                alteredMovement.dxyz.Z);
            hasChanged = false;
            callbackInfo.cancel();
        }
    }
}
 
Example #7
Source File: EntityMoveEvent.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
public EntityMoveEvent(Entity entity, MoverType type, double x, double y, double z) {
	this.entity = entity;
	this.type = type;
	this.x = x;
	this.y = y;
	this.z = z;
}
 
Example #8
Source File: ArenaManager.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void tickBoss(LivingEvent.LivingUpdateEvent event) {
	for (Arena arena : arenas) {
		if (event.getEntityLiving().getEntityId() != arena.getBossID()) continue;

		if (event.getEntityLiving().getDistance(arena.getCenter().getX() + 0.5, arena.getCenter().getY(), arena.getCenter().getZ() + 0.5) > arena.getRadius()) {
			event.getEntityLiving().move(MoverType.SELF, arena.getCenter().getX() + 0.5, arena.getCenter().getY() + 0.5, arena.getCenter().getZ() + 0.5);
		}
	}
}
 
Example #9
Source File: EntityTofuFish.java    From TofuCraftReload with MIT License 5 votes vote down vote up
public void travel(float strafe, float vertical, float forward) {
    if (this.isServerWorld() && this.isInWater()) {
        this.moveRelative(strafe, vertical, forward, 0.01F);
        this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ);
        this.motionX *= (double)0.9F;
        this.motionY *= (double)0.9F;
        this.motionZ *= (double)0.9F;
        if (this.getAttackTarget() == null) {
            this.motionY -= 0.005D;
        }
    } else {
        super.travel(strafe, vertical, forward);
    }

}
 
Example #10
Source File: WizardryASMHooks.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static EntityMoveEvent entityPreMoveHook(Entity entity, MoverType type, double x, double y, double z) {
	EntityMoveEvent event = new EntityMoveEvent(entity, type, x, y, z);
	MinecraftForge.EVENT_BUS.post(event);
	return event;
}
 
Example #11
Source File: EntityFallTofu.java    From TofuCraftReload with MIT License 4 votes vote down vote up
@Override
public void onUpdate() {

    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    if (this.hurtEntities && this.onGround) {
        this.world.spawnParticle(EnumParticleTypes.CLOUD, this.posX, this.posY, this.posZ, 0.0F, 0.0F, 0.0F);
        this.playSound(SoundEvents.BLOCK_STONE_BREAK, 1.2F, 1.0F);
        if (!this.world.isRemote) {
            this.setDead();
            return;
        }
    }
    if (this.fallTime++ == 300) {
        this.world.spawnParticle(EnumParticleTypes.CLOUD, this.posX, this.posY, this.posZ, 0.0F, 0.0F, 0.0F);
        this.playSound(SoundEvents.BLOCK_STONE_BREAK, 1.2F, 1.0F);
        if (!this.world.isRemote) {
            this.setDead();
            return;
        }
    }


    RayTraceResult raytraceresult = ProjectileHelper.forwardsRaycast(this, true, false, this.owner);

    if (raytraceresult != null && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, raytraceresult)) {
        this.onImpact(raytraceresult);
        this.playSound(SoundEvents.BLOCK_STONE_BREAK, 1.2F, 1.0F);
        this.world.spawnParticle(EnumParticleTypes.CLOUD, this.posX, this.posY, this.posZ, 0.0F, 0.0F, 0.0F);
        if (!this.world.isRemote) {
            this.setDead();
        }
    }


    if (!this.hasNoGravity()) {
        if (this.onGround) {
            this.motionY = 0.0F;
        } else if (this.isInWater() || this.isInLava()) {
            this.motionY = (0.3 - this.motionY) * 0.3;
        } else {
            this.motionY -= 0.03999999910593033D;
        }
    }

    this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ);

    this.motionX *= 0.9800000190734863D;
    this.motionY *= 0.9800000190734863D;
    this.motionZ *= 0.9800000190734863D;
}
 
Example #12
Source File: MixinEntityIntrinsic.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Shadow
public abstract void move(MoverType type, double x, double y, double z);
 
Example #13
Source File: MixinEntity.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Shadow
public abstract void move(MoverType type, double x, double y, double z);
 
Example #14
Source File: EventMove.java    From seppuku with GNU General Public License v3.0 4 votes vote down vote up
public void setMoverType(MoverType moverType) {
    this.moverType = moverType;
}
 
Example #15
Source File: EventMove.java    From seppuku with GNU General Public License v3.0 4 votes vote down vote up
public MoverType getMoverType() {
    return moverType;
}
 
Example #16
Source File: EventMove.java    From seppuku with GNU General Public License v3.0 4 votes vote down vote up
public EventMove(MoverType moverType, double x, double y, double z) {
    this.moverType = moverType;
    this.x = x;
    this.y = y;
    this.z = z;
}
 
Example #17
Source File: IDraggable.java    From Valkyrien-Skies with Apache License 2.0 votes vote down vote up
void move(MoverType type, double dx, double dy, double dz);