I need to delete specific dropped(!) items from the chunk, how can i get all dropped items in the chunk?
Chunk chunk; Collection<Entity> items = chunk.getEntities(e -> e instance Item);
While this does give a collection of entities, its actually a collection of Items. You can do a unsafe cast if you wish.
Chunk chunk = ...; chunk.getEntities() .stream() .filter(entity -> entity.getType().equals(EntityTypes.ITEM)) .filter(entity -> ...) .forEach(entity -> entity.remove());
OK, i can get all dropped items, but how can i get only Gravel or Dirt for example?
entity.getType() only give me minecraft:item
Well it would as the Item is an Entity, not a itemstack. You can get the itemType that the entity is by the following.
Item item; ItemType type = item.getItemType();
You can also use the key.
theris no such method getItemType
Its very new to Sponge, if you wish to use it make sure your targeting the latest Sponge (Im guessing your targeting 7.0.0 and the latest is 7.1/7.2). As mentioned before you can use the Key. Key will work in all Sponge 7.x builds.
You can see that it is included by the github page.
Extent extent = ...; extent.getEntities() .stream() .filter(entity -> entity.getType().equals(EntityTypes.ITEM)) .map(entity -> (Item) entity) .filter(itemEntity -> itemEntity.getItemType().equals(ItemTypes.GRAVEL)) .forEach(itemEntity -> itemEntity.remove());