Skip to content

Commit 25c82b4

Browse files
committed
Add mising data values, adding Sittable and Spawner
1 parent c3d9d45 commit 25c82b4

File tree

11 files changed

+229
-129
lines changed

11 files changed

+229
-129
lines changed

src/main/java/org/spongepowered/api/block/entity/MobSpawner.java

Lines changed: 2 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,12 @@
2424
*/
2525
package org.spongepowered.api.block.entity;
2626

27-
import org.spongepowered.api.data.Keys;
28-
import org.spongepowered.api.data.value.BoundedValue;
29-
import org.spongepowered.api.data.value.Value;
30-
import org.spongepowered.api.data.value.WeightedCollectionValue;
31-
import org.spongepowered.api.entity.Entity;
32-
import org.spongepowered.api.entity.EntityArchetype;
33-
import org.spongepowered.api.entity.living.player.Player;
34-
import org.spongepowered.api.util.weighted.WeightedSerializableObject;
35-
36-
import java.util.Random;
27+
import org.spongepowered.api.spawner.Spawner;
3728

3829
/**
3930
* Represents a Monster Spawner.
4031
*/
41-
public interface MobSpawner extends BlockEntity {
32+
public interface MobSpawner extends BlockEntity, Spawner {
4233

4334
/**
4435
* Trigger an immediate spawn of a batch of entities.
@@ -49,109 +40,4 @@ public interface MobSpawner extends BlockEntity {
4940
* @param force Whether to ignore spawning restrictions
5041
*/
5142
void spawnEntityBatchImmediately(boolean force);
52-
53-
/**
54-
* Gets the {@link org.spongepowered.api.data.value.BoundedValue.Mutable} for the remaining delay before
55-
* a new attempt at spawning an {@link Entity} is made.
56-
*
57-
* @return The immutable bounded value for the remaining delay
58-
*/
59-
default BoundedValue.Mutable<Integer> remainingDelay() {
60-
return getValue(Keys.SPAWNER_REMAINING_DELAY).get().asMutable();
61-
}
62-
63-
/**
64-
* Gets the {@link org.spongepowered.api.data.value.BoundedValue.Mutable} for the minimum spawn delay
65-
* required between attempts to spawn an {@link Entity}.
66-
*
67-
* @return The bounded value of the minimum spawn delay
68-
*/
69-
default BoundedValue.Mutable<Integer> minimumSpawnDelay() {
70-
return getValue(Keys.SPAWNER_MINIMUM_DELAY).get().asMutable();
71-
}
72-
73-
/**
74-
* Gets the {@link org.spongepowered.api.data.value.BoundedValue.Mutable} for the maximum spawn delay
75-
* required between attempts to spawn an {@link Entity}.
76-
*
77-
* @return The bounded value of the maximum spawn delay
78-
*/
79-
default BoundedValue.Mutable<Integer> maximumSpawnDelay() {
80-
return getValue(Keys.SPAWNER_MAXIMUM_DELAY).get().asMutable();
81-
}
82-
83-
/**
84-
* Gets the {@link org.spongepowered.api.data.value.BoundedValue.Mutable} for the count of successful
85-
* spawns of all {@link Entity} instances from the owning spawner. This
86-
* count is simply a total count, there is no limitation on how many
87-
* attempts are made to spawn an {@link Entity}.
88-
*
89-
* @return The immutable bounded value
90-
*/
91-
default BoundedValue.Mutable<Integer> spawnCount() {
92-
return getValue(Keys.SPAWNER_SPAWN_COUNT).get().asMutable();
93-
}
94-
95-
/**
96-
* Gets the {@link org.spongepowered.api.data.value.BoundedValue.Mutable} for the limitation on the number
97-
* of nearby {@link Entity} instances can exist near the owning spawner. The
98-
* limitation is that if there are more {@link Entity} instances than the
99-
* provided value, no attempts to spawn a new {@link Entity} will be made.
100-
*
101-
* @return The bounded value of the maximum supported nearby entities
102-
*/
103-
default BoundedValue.Mutable<Integer> maximumNearbyEntities() {
104-
return getValue(Keys.SPAWNER_MAXIMUM_NEARBY_ENTITIES).get().asMutable();
105-
}
106-
107-
/**
108-
* Gets the {@link org.spongepowered.api.data.value.BoundedValue.Mutable} for the minimum range a
109-
* {@link Player} must remain in proximity of the spawner, such that if a
110-
* {@link Player} is NOT within the provided range, no attempts to spawn an
111-
* {@link Entity} is made.
112-
*
113-
* @return The value of the required player range to spawn entities
114-
*/
115-
default BoundedValue.Mutable<Integer> requiredPlayerRange() {
116-
return getValue(Keys.SPAWNER_REQUIRED_PLAYER_RANGE).get().asMutable();
117-
}
118-
119-
/**
120-
* Gets the {@link org.spongepowered.api.data.value.BoundedValue.Mutable} for the maximum range that an
121-
* {@link Entity} can be spawned from the spawner.
122-
*
123-
* @return The immutable value of the maximum spawn range an entity can be
124-
* spawned
125-
*/
126-
default BoundedValue.Mutable<Integer> spawnRange() {
127-
return getValue(Keys.SPAWNER_SPAWN_RANGE).get().asMutable();
128-
}
129-
130-
/**
131-
* Gets the {@link org.spongepowered.api.data.value.Value.Mutable}
132-
* for the overridden
133-
* {@link WeightedSerializableObject}{@code <EntitySnapshot>} to spawn
134-
* next. If possible, the next entity to spawn may be chosen from the
135-
* already provided {@link #possibleEntitiesToSpawn()}.
136-
*
137-
* @return The next possible entity to spawn
138-
*/
139-
default Value.Mutable<WeightedSerializableObject<EntityArchetype>> nextEntityToSpawn() {
140-
return getValue(Keys.SPAWNER_NEXT_ENTITY_TO_SPAWN).get().asMutable();
141-
}
142-
143-
/**
144-
* Gets the {@link org.spongepowered.api.data.value.WeightedCollectionValue.Mutable} of all possible
145-
* {@link Entity} instances that can be spawned by the spawner. As they
146-
* are all {@link WeightedSerializableObject}{@code <EntitySnapshot>}
147-
* instances, their weight is defined as a {@link Random} to determine
148-
* the next {@link Entity} that will be spawned, unless overriden by
149-
* {@link #nextEntityToSpawn()}.
150-
*
151-
* @return The immutable weighted entity collection value of entities
152-
*/
153-
default WeightedCollectionValue.Mutable<EntityArchetype> possibleEntitiesToSpawn() {
154-
return getValue(Keys.SPAWNER_ENTITIES).get().asMutable();
155-
}
156-
15743
}

src/main/java/org/spongepowered/api/entity/Entity.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,14 @@ default Value.Mutable<Boolean> gravity() {
408408
return this.getValue(Keys.HAS_GRAVITY.get()).get().asMutable();
409409
}
410410

411+
/**
412+
* {@link Keys#IS_SILENT}
413+
* @return Whether this entity is silent
414+
*/
415+
default Value.Mutable<Boolean> silent() {
416+
return this.getValue(Keys.IS_SILENT.get()).get().asMutable();
417+
}
418+
411419
/**
412420
* {@link Keys#CREATOR}
413421
* @return The unique id of the creator of this entity
@@ -423,4 +431,12 @@ default Optional<Value.Mutable<UUID>> creator() {
423431
default Optional<Value.Mutable<UUID>> notifier() {
424432
return this.getValue(Keys.NOTIFIER.get()).map(Value::asMutable);
425433
}
434+
435+
/**
436+
* {@link Keys#FIRE_TICKS}
437+
* @return The amount of time in ticks an Entity is will continue burn for.
438+
*/
439+
default Optional<Value.Mutable<Integer>> fireTicks() {
440+
return this.getValue(Keys.FIRE_TICKS).map(Value::asMutable);
441+
}
426442
}

src/main/java/org/spongepowered/api/entity/living/animal/Cat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
/**
3434
* Represents a Cat, meow.
3535
*/
36-
public interface Cat extends TameableAnimal {
36+
public interface Cat extends TameableAnimal, Sittable {
3737

3838
/**
3939
* {@link Keys#CAT_TYPE}

src/main/java/org/spongepowered/api/entity/living/animal/Panda.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
/**
3636
* Represents a Panda.
3737
*/
38-
public interface Panda extends Animal {
38+
public interface Panda extends Animal, Sittable {
3939

4040
/**
4141
* {@link Keys#KNOWN_GENE}
@@ -53,14 +53,6 @@ default Value.Mutable<PandaGene> hiddenGene() {
5353
return this.getValue(Keys.HIDDEN_GENE.get()).get().asMutable();
5454
}
5555

56-
/**
57-
* {@link Keys#IS_SITTING}
58-
* @return Whether this panda is sitting
59-
*/
60-
default Value.Mutable<Boolean> sitting() {
61-
return this.getValue(Keys.IS_SITTING.get()).get().asMutable();
62-
}
63-
6456
/**
6557
* {@link Keys#IS_SNEEZING}
6658
* @return Whether this panda is sneezing

src/main/java/org/spongepowered/api/entity/living/animal/Parrot.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
/**
3232
* Represents a Parrot.
3333
*/
34-
public interface Parrot extends TameableAnimal {
34+
public interface Parrot extends TameableAnimal, Sittable {
3535

3636
/**
3737
* {@link Keys#PARROT_TYPE}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.api.entity.living.animal;
26+
27+
import org.spongepowered.api.data.Keys;
28+
import org.spongepowered.api.data.value.Value;
29+
import org.spongepowered.api.entity.Entity;
30+
31+
/**
32+
* Represents an {@link Entity} which can sit.
33+
*/
34+
public interface Sittable extends Entity {
35+
36+
/**
37+
* {@link Keys#IS_SITTING}
38+
* @return Whether this entity is sitting
39+
*/
40+
default Value.Mutable<Boolean> sitting() {
41+
return this.getValue(Keys.IS_SITTING.get()).get().asMutable();
42+
}
43+
}

src/main/java/org/spongepowered/api/entity/living/animal/Wolf.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
/**
3232
* Represents a Wolf.
3333
*/
34-
public interface Wolf extends TameableAnimal {
34+
public interface Wolf extends TameableAnimal, Sittable {
3535

3636
/**
3737
* {@link Keys#IS_ANGRY}

src/main/java/org/spongepowered/api/entity/vehicle/Boat.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
package org.spongepowered.api.entity.vehicle;
2626

2727
import org.spongepowered.api.data.Keys;
28+
import org.spongepowered.api.data.type.WoodType;
2829
import org.spongepowered.api.data.value.Value;
2930

3031
/**
@@ -71,4 +72,12 @@ default Value.Mutable<Double> unoccupiedDeceleration() {
7172
default Value.Mutable<Double> occupiedDeceleration() {
7273
return this.getValue(Keys.BOAT_OCCUPIED_DECELERATION.get()).get().asMutable();
7374
}
75+
76+
/**
77+
* {@link Keys#WOOD_TYPE}
78+
* @return The wood type of the boat
79+
*/
80+
default Value.Mutable<WoodType> woodType() {
81+
return this.getValue(Keys.WOOD_TYPE.get()).get().asMutable();
82+
}
7483
}

src/main/java/org/spongepowered/api/entity/vehicle/minecart/SpawnerMinecart.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
package org.spongepowered.api.entity.vehicle.minecart;
2626

2727
import org.spongepowered.api.block.entity.MobSpawner;
28+
import org.spongepowered.api.spawner.Spawner;
2829

2930
/**
3031
* Represents a {@link Minecart} with a {@link MobSpawner} inside it.
3132
*/
32-
public interface SpawnerMinecart extends BlockOccupiedMinecart {
33+
public interface SpawnerMinecart extends BlockOccupiedMinecart, Spawner {
3334

3435
}

0 commit comments

Comments
 (0)