Package org.spout.vanilla.component.entity.misc

Examples of org.spout.vanilla.component.entity.misc.MetadataComponent


    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);
    metadata.addMeta(new Metadata<Integer>(Metadata.TYPE_INT, 20) {
      @Override
      public Integer getValue() {
        BlockMaterial material = getDisplayedBlock();
        if (material instanceof VanillaBlockMaterial) {
          VanillaBlockMaterial vanillaMat = (VanillaBlockMaterial) material;
          return (vanillaMat.getMinecraftId()  & 0xFFFF) | (vanillaMat.getMinecraftData(vanillaMat.getData()) << 16);
        } else {
          return 0;
        }
      }

      @Override
      public void setValue(Integer value) {
        int fullState = value.intValue();
        Material material = VanillaMaterials.getMaterial((short) (fullState & 0xFFFF), (short) (fullState >> 16));
        if (material instanceof BlockMaterial) {
          setDisplayedBlock((BlockMaterial) material);
        } else {
          setDisplayedBlock(VanillaMaterials.AIR);
        }
      }
    });
    metadata.addMeta(Metadata.TYPE_INT, 21, VanillaData.MINECART_BLOCK_OFFSET);
    metadata.addMeta(new Metadata<Byte>(Metadata.TYPE_BYTE, 22) {
      @Override
      public Byte getValue() {
        return getOwner().getData().get(VanillaData.MINECART_BLOCK_ID) == 0 ? (byte) 0 : (byte) 1;
      }
View Full Code Here


  @Override
  public void onDetached() {
    super.onDetached();

    // Unregister smoking puff metadata
    MetadataComponent metadata = getOwner().get(MetadataComponent.class);
    if (metadata != null) {
      metadata.removeMeta(16);
    }
  }
View Full Code Here

    damage.getDamageLevel(Difficulty.NORMAL).setAmount(7);
    damage.getDamageLevel(Difficulty.HARD).setAmount(10);
    damage.getDamageLevel(Difficulty.HARDCORE).setAmount(damage.getDamageLevel(Difficulty.HARD).getAmount());

    // Add metadata properties of the enderman
    MetadataComponent metadata = getOwner().add(MetadataComponent.class);
    metadata.addMeta(Metadata.TYPE_BYTE, 16, VanillaData.HELD_MATERIAL);
    metadata.addMeta(Metadata.TYPE_BYTE, 17, VanillaData.HELD_MATERIAL_DATA);
    metadata.addBoolMeta(18, VanillaData.AGGRESSIVE);
  }
View Full Code Here

    damage.getDamageLevel(Difficulty.NORMAL).setAmount(damage.getDamageLevel(Difficulty.EASY).getAmount());
    damage.getDamageLevel(Difficulty.HARD).setAmount(damage.getDamageLevel(Difficulty.NORMAL).getAmount());
    damage.getDamageLevel(Difficulty.HARDCORE).setAmount(damage.getDamageLevel(Difficulty.HARD).getAmount());

    // Add wolf metadata
    MetadataComponent metadata = getOwner().add(MetadataComponent.class);
    metadata.addMeta(new Metadata<Byte>(Metadata.TYPE_BYTE, 16) {
      @Override
      public Byte getValue() {
        byte data = 0;
        if (isSitting()) {
          data |= 0x01;
        }
        if (isAggressive()) {
          data |= 0x02;
        }
        if (isTamed()) {
          data |= 0x04;
        }
        return data;
      }

      @Override
      public void setValue(Byte value) {
        int data = value.intValue();
        setSitting((data & 0x01) == 0x01);
        setAggressive((data & 0x02) == 0x02);
        setTamed((data & 0x04) == 0x04);
      }
    });
    metadata.addMeta(Metadata.TYPE_STRING, 17, VanillaData.OWNER);
    metadata.addMeta(Metadata.TYPE_FLOAT, 18, VanillaData.HEALTH);
  }
View Full Code Here

      getOwner().add(Health.class).setSpawnHealth(DEFAULT_HEALTH);
    }
    super.onAttached();

    // Add metadata for the Horse
    MetadataComponent metadata = getOwner().add(MetadataComponent.class);

    //TODO: Implement tame/saddle/bred/chest/etc. for index 16 (see protocol page)
    metadata.addMeta(new Metadata<Integer>(Metadata.TYPE_INT, 16) {
      @Override
      public Integer getValue() {
        int value = 0;
        if (isTamed()) {
          value |= 2;
        }
        if (getInventory().hasSaddle()) {
          value |= 4;
        }
        /*
        TODO: Check if inventory is setup to have a chest or not.
        if (hasChest()) {
          value |= 8;
        }
        TODO: Check if horse has already bred.
        if (hasBred()) {
          value |= 16;
        }
          */

        if (isEatingBlocking()) {
          value |= 32;
        }
        /*
        TODO: rearing
        if (isRearing() {
          value |= 64;
        }

         */
        return value;
      }

      @Override
      public void setValue(Integer value) {
        // TODO Auto-generated method stub
      }
    });

    // Metadata for the type ID of the Horse
    metadata.addMeta(Metadata.TYPE_BYTE, TYPE_INDEX, VanillaData.ENTITY_CATEGORY);

    // Metadata for variant and marking
    metadata.addMeta(new Metadata<Integer>(Metadata.TYPE_INT, VARIANT_INDEX) {
      @Override
      public Integer getValue() {
        return (getVariant().getVariantId() & 0x00ff) | (getMarking().getMarkingId() & 0xff00);
      }

      @Override
      public void setValue(Integer value) {
        int intValue = value.intValue();
        setVariantAndMarking(Variant.fromId(intValue & 0x00ff), Marking.fromId(intValue & 0xff00));
      }
    });

    // Metadata for the owner name of the Horse
    metadata.addMeta(OWNER_INDEX, Metadata.TYPE_STRING, VanillaData.OWNER);

    // Metadata for the currently equipped Armor
    metadata.addMeta(new Metadata<Integer>(Metadata.TYPE_INT, ARMOR_TYPE_INDEX) {
      @Override
      public Integer getValue() {
        return getHorseTypeId() > 0 ? 0 : getInventory().getArmorTypeId();
      }

View Full Code Here

      getOwner().add(Health.class).setSpawnHealth(10);
    }
    getOwner().add(DeathDrops.class).addXpDrop((short) (getRandom().nextInt(3) + 1));

    // Add ocelot metadata
    MetadataComponent metadata = getOwner().add(MetadataComponent.class);
    metadata.addMeta(new Metadata<Byte>(Metadata.TYPE_BYTE, 16) {
      @Override
      public Byte getValue() {
        byte data = 0;
        if (isSitting()) {
          data |= 0x01;
        }
        if (isTamed()) {
          data |= 0x04;
        }
        return data;
      }

      @Override
      public void setValue(Byte value) {
        int data = value.intValue();
        setSitting((data & 0x01) == 0x01);
        setTamed((data & 0x04) == 0x04);
      }
    });
    metadata.addMeta(Metadata.TYPE_STRING, 17, VanillaData.OWNER);
    metadata.addMeta(Metadata.TYPE_BYTE, 18, VanillaData.OCELOT_SKIN);
  }
View Full Code Here

    getAI().registerSensor(humanSensor);
    getAI().registerGoal(new AttackPlayerGoal(getAI()));
    getAI().registerAction(new ActionAttack(getAI()));

    // Metadata values
    MetadataComponent meta = getOwner().add(MetadataComponent.class);
    meta.addMeta(Metadata.TYPE_BYTE, 16, VanillaData.STATE);
    meta.addBoolMeta(17, VanillaData.CHARGED);
  }
View Full Code Here

    if (entity == null) {
      player.getEngine().getLogger().warning("EntityMetadataHandler entity doesn't exist");
      return;
    }

    MetadataComponent metadataComponent = entity.get(MetadataComponent.class);
    if (metadataComponent != null) {
      for (Parameter<?> parameter : message.getParameters()) {
        metadataComponent.setParameter(parameter);
      }
    }
  }
View Full Code Here

    entity.add(Human.class).setName(message.getName());
    EntityPrefab humanPrefab = session.getEngine().getFileSystem().getResource("entity://Vanilla/entities/human/human.sep");
    entity = humanPrefab.createEntity(pos);

    // Load in Metadata
    MetadataComponent metadata = entity.get(MetadataComponent.class);
    if (metadata != null) {
      metadata.setParameters(message.getParameters());
    }

    w.spawnEntity(entity);
    System.out.println(message.toString());
  }
View Full Code Here

   *
   * @param entity to get it for
   * @return List of metadata Parameters
   */
  public List<Parameter<?>> getSpawnParameters(Entity entity) {
    MetadataComponent metadataComponent = entity.get(MetadataComponent.class);
    if (metadataComponent == null) {
      return Collections.emptyList();
    } else {
      return metadataComponent.getSpawnParameters();
    }
  }
View Full Code Here

TOP

Related Classes of org.spout.vanilla.component.entity.misc.MetadataComponent

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.