Skip to content

Commit

Permalink
minor spawner stuff cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Nov 18, 2021
1 parent 72aba20 commit e006c8d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,7 @@ public static void registerTags() {
// @returns ElementTag(Number)
// @description
// Returns the current spawn delay for the spawner.
// This changes over time between <@link tag LocationTag.spawner_minimum_spawn_delay> and <@link tag LocationTag.spawner_maximum_spawn_delay>.
// -->
tagProcessor.registerTag(ElementTag.class, "spawner_spawn_delay", (attribute, object) -> {
if (!(object.getBlockStateForTag(attribute) instanceof CreatureSpawner)) {
Expand Down Expand Up @@ -1342,7 +1343,7 @@ public static void registerTags() {
// @mechanism LocationTag.spawner_range
// @returns ElementTag(Number)
// @description
// Returns the spawn range for the spawner
// Returns the spawn range for the spawner (the radius mobs will spawn in).
// -->
tagProcessor.registerTag(ElementTag.class, "spawner_range", (attribute, object) -> {
if (!(object.getBlockStateForTag(attribute) instanceof CreatureSpawner)) {
Expand All @@ -1356,7 +1357,7 @@ public static void registerTags() {
// @mechanism LocationTag.spawner_max_nearby_entities
// @returns ElementTag(Number)
// @description
// Returns the maximum nearby entities for the spawner.
// Returns the maximum nearby entities for the spawner (the radius mobs will spawn in).
// -->
tagProcessor.registerTag(ElementTag.class, "spawner_max_nearby_entities", (attribute, object) -> {
if (!(object.getBlockStateForTag(attribute) instanceof CreatureSpawner)) {
Expand Down Expand Up @@ -3836,8 +3837,7 @@ public void adjust(Mechanism mechanism) {
// @tags
// <LocationTag.spawner_type>
// -->
if (mechanism.matches("spawner_type") && mechanism.requireObject(EntityTag.class)
&& getBlockState() instanceof CreatureSpawner) {
if (mechanism.matches("spawner_type") && mechanism.requireObject(EntityTag.class) && getBlockState() instanceof CreatureSpawner) {
CreatureSpawner spawner = ((CreatureSpawner) getBlockState());
spawner.setSpawnedType(mechanism.valueAsType(EntityTag.class).getBukkitEntityType());
spawner.update();
Expand Down Expand Up @@ -3885,8 +3885,7 @@ && getBlockState() instanceof CreatureSpawner) {
// @tags
// <LocationTag.spawner_max_nearby_entities>
// -->
if (mechanism.matches("spawner_max_nearby_entities") && mechanism.requireInteger()
&& getBlockState() instanceof CreatureSpawner) {
if (mechanism.matches("spawner_max_nearby_entities") && mechanism.requireInteger() && getBlockState() instanceof CreatureSpawner) {
CreatureSpawner spawner = ((CreatureSpawner) getBlockState());
spawner.setMaxNearbyEntities(mechanism.getValue().asInt());
spawner.update();
Expand All @@ -3901,8 +3900,7 @@ && getBlockState() instanceof CreatureSpawner) {
// @tags
// <LocationTag.spawner_player_range>
// -->
if (mechanism.matches("spawner_player_range") && mechanism.requireInteger()
&& getBlockState() instanceof CreatureSpawner) {
if (mechanism.matches("spawner_player_range") && mechanism.requireInteger() && getBlockState() instanceof CreatureSpawner) {
CreatureSpawner spawner = ((CreatureSpawner) getBlockState());
spawner.setRequiredPlayerRange(mechanism.getValue().asInt());
spawner.update();
Expand All @@ -3913,12 +3911,11 @@ && getBlockState() instanceof CreatureSpawner) {
// @name spawner_range
// @input ElementTag(Number)
// @description
// Sets the spawn range of the spawner.
// Sets the spawn range of the spawner (the radius mobs will spawn in).
// @tags
// <LocationTag.spawner_range>
// -->
if (mechanism.matches("spawner_range") && mechanism.requireInteger()
&& getBlockState() instanceof CreatureSpawner) {
if (mechanism.matches("spawner_range") && mechanism.requireInteger() && getBlockState() instanceof CreatureSpawner) {
CreatureSpawner spawner = ((CreatureSpawner) getBlockState());
spawner.setSpawnRange(mechanism.getValue().asInt());
spawner.update();
Expand All @@ -3933,8 +3930,7 @@ && getBlockState() instanceof CreatureSpawner) {
// @tags
// <LocationTag.spawner_count>
// -->
if (mechanism.matches("spawner_count") && mechanism.requireInteger()
&& getBlockState() instanceof CreatureSpawner) {
if (mechanism.matches("spawner_count") && mechanism.requireInteger() && getBlockState() instanceof CreatureSpawner) {
CreatureSpawner spawner = ((CreatureSpawner) getBlockState());
spawner.setSpawnCount(mechanism.getValue().asInt());
spawner.update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public ObjectTag getObjectAttribute(Attribute attribute) {
// @group properties
// @description
// Returns the current spawn delay for a spawner block item.
// This changes over time between <@link tag ItemTag.spawner_minimum_spawn_delay> and <@link tag ItemTag.spawner_maximum_spawn_delay>.
// -->
if (attribute.startsWith("spawner_spawn_delay")) {
BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public ObjectTag getObjectAttribute(Attribute attribute) {
// @mechanism ItemTag.spawner_range
// @group properties
// @description
// Returns the spawn range for a spawner block item.
// Returns the spawn range for a spawner block item (the radius mobs will spawn in).
// -->
if (attribute.startsWith("spawner_range")) {
BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
Expand Down Expand Up @@ -85,7 +85,7 @@ public void adjust(Mechanism mechanism) {
// @name spawner_range
// @input ElementTag(Number)
// @description
// Sets the spawn range of a spawner block item.
// Sets the spawn range of a spawner block item (the radius mobs will spawn in).
// @tags
// <ItemTag.spawner_range>
// -->
Expand Down

0 comments on commit e006c8d

Please sign in to comment.