Package org.spout.api.component.entity

Examples of org.spout.api.component.entity.PhysicsComponent


    if (material.equals(this.material)) {
      return;
    }
    this.material = material;
    //Physics
    PhysicsComponent physics = getOwner().getPhysics();
    physics.activate(material.getMass(), material.getShape(), false, true);
    physics.setFriction(material.getFriction());
    physics.setRestitution(material.getRestitution());
  }
View Full Code Here


      getOwner().add(DeathDrops.class).addDrop(new ItemStack(VanillaMaterials.MINECART, 1));
      // Set the displayed block
      setDisplayedBlock(getType().getDefaultDisplayedBlock());
    }

    PhysicsComponent physics = getOwner().getPhysics();
    physics.activate(1f, new BoxShape(0.98f, 0.49f, 0.7f), false, true);

    // Add metadata for the shaking of the Minecart and the displayed Block
    MetadataComponent metadata = getOwner().add(MetadataComponent.class);
    metadata.addMeta(Metadata.TYPE_INT, 17, VanillaData.MINECART_SHAKE_FORCE);
    metadata.addMeta(Metadata.TYPE_INT, 18, VanillaData.MINECART_SHAKE_DIR);
View Full Code Here

  public void onAttached() {
    super.onAttached();
    setEntityProtocol(new CreatureProtocol(CreatureType.ENDERMAN));

    //Physics
    PhysicsComponent physics = getOwner().getPhysics();
    physics.activate(2f, new BoxShape(1f, 2f, 1f), false, true);
    physics.setFriction(10f);
    physics.setRestitution(0f);

    if (getAttachedCount() == 1) {
      getOwner().add(Health.class).setSpawnHealth(40);
    }
View Full Code Here

  @Override
  public void onAttached() {
    super.onAttached();
    setEntityProtocol(new ItemEntityProtocol());
    PhysicsComponent physics = getOwner().getPhysics();
    physics.activate(1f, new BoxShape(0.27f, 0.27f, 0.27f), false, true);
    if (getAttachedCount() == 1) {
      getOwner().add(Health.class).setSpawnHealth(20);
    }

    // Add metadata for ItemStack contained
View Full Code Here

  @Override
  public void onAttached() {
    super.onAttached();
    setEntityProtocol(new CreatureProtocol(CreatureType.CREEPER));
    getOwner().add(DeathDrops.class).addDrop(new ItemStack(VanillaMaterials.GUNPOWDER, getRandom().nextInt(2))).addXpDrop((short) 5);
    PhysicsComponent physics = getOwner().getPhysics();
    physics.activate(2f, new BoxShape(1f, 2f, 1f), false, true);
    physics.setFriction(10f);
    physics.setRestitution(0f);
    if (getAttachedCount() == 1) {
      getOwner().add(Health.class).setSpawnHealth(20);
    }

    NearbyComponentsSensor humanSensor = new NearbyComponentsSensor(getAI(), Human.class);
View Full Code Here

    setEntityProtocol(new CreatureProtocol(CreatureType.SKELETON));
    getOwner().add(EntityInventory.class);
    getOwner().add(EntityItemCollector.class);

    //Physics
    PhysicsComponent physics = getOwner().getPhysics();
    physics.activate(2f, new BoxShape(1f, 2f, 1f), false, true);
    physics.setFriction(10f);
    physics.setRestitution(0f);

    DeathDrops dropComponent = getOwner().add(DeathDrops.class);
    dropComponent.addDrop(new ItemStack(VanillaMaterials.ARROW, random.nextInt(2)));
    dropComponent.addDrop(new ItemStack(VanillaMaterials.BONE, random.nextInt(2)));
    dropComponent.addXpDrop((short) 5);
View Full Code Here

    setEntityProtocol(new CreatureProtocol(CreatureType.ZOMBIE));
    getOwner().add(DeathDrops.class).addDrop(new ItemStack(VanillaMaterials.ROTTEN_FLESH, getRandom().nextInt(2))).addXpDrop((short) 5);
    getOwner().add(EntityInventory.class);
    getOwner().add(EntityItemCollector.class);

    PhysicsComponent physics = getOwner().getPhysics();
    physics.activate(2f, new BoxShape(1f, 2f, 1f), false, true);
    physics.setFriction(10f);
    physics.setRestitution(0f);

    if (getAttachedCount() == 1) {
      getOwner().add(Health.class).setSpawnHealth(20);
    }
View Full Code Here

  @Override
  public void onTick(float dt) {
    Player player = (Player) getOwner();
    Transform ts = player.getPhysics().getTransform();
    PlayerInputState inputState = player.input();
    PhysicsComponent sc = player.getPhysics();

    Vector3f offset = Vector3f.ZERO;
    float speed = 50;
    if (inputState.getForward()) {
      offset = offset.sub(ts.forwardVector().mul(speed * dt));
 
View Full Code Here

  public void onInteract(Entity entity, Action type, float mass) {
    super.onInteract(entity, type);
    if (type == Action.RIGHT_CLICK) {
      Substance item = this.spawnEntity(entity, new Vector3f(0, 1.6f, 0));
      PhysicsComponent physics = item.getOwner().getPhysics();
      physics.activate(mass, new SphereShape(1f), false, true);
      if (item instanceof Projectile) {
        ((Projectile) item).setShooter(entity);
      }
      physics.force(entity.getPhysics().getRotation().getDirection().mul(getLaunchForce()));
      this.onThrown(item, entity);
    }
  }
View Full Code Here

  public void onInteract(Entity entity, Action action) {
    if (this.isSplash()) {
      Potion item = entity.getWorld().createEntity(entity.getPhysics().getPosition().add(0, 1.6f, 0)).add(Potion.class);
      item.setShooter(entity);
      item.setPotion(this);
      PhysicsComponent physics = item.getOwner().getPhysics();
      physics.activate(1f, new SphereShape(0.3f), false, true);
      entity.getWorld().spawnEntity(item.getOwner());
      physics.impulse(entity.getPhysics().getRotation().getDirection().mul(55)); //TODO: Need real parameters
    }
  }
View Full Code Here

TOP

Related Classes of org.spout.api.component.entity.PhysicsComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.