Skip to content

Commit

Permalink
add beehive bee storage tags+mechs
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Mar 30, 2020
1 parent ae38976 commit f3dc84d
Showing 1 changed file with 69 additions and 4 deletions.
Expand Up @@ -37,10 +37,7 @@
import org.bukkit.*;
import org.bukkit.block.*;
import org.bukkit.block.banner.PatternType;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.*;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
Expand Down Expand Up @@ -1223,6 +1220,27 @@ else if (object.getBlockTypeForTag(attribute) == Material.FLOWER_POT) {
return null;
});

// <--[tag]
// @attribute <LocationTag.hive_bee_count>
// @returns ElementTag(Number)
// @description
// Returns the number of bees inside a hive.
// -->
registerTag("hive_bee_count", (attribute, object) -> {
return new ElementTag(((Beehive) object.getBlockStateForTag(attribute)).getEntityCount());
});

// <--[tag]
// @attribute <LocationTag.hive_max_bees>
// @returns ElementTag(Number)
// @mechanism LocationTag.hive_max_bees
// @description
// Returns the maximum number of bees allowed inside a hive.
// -->
registerTag("hive_max_bees", (attribute, object) -> {
return new ElementTag(((Beehive) object.getBlockStateForTag(attribute)).getMaxEntities());
});

// <--[tag]
// @attribute <LocationTag.skull_type>
// @returns ElementTag
Expand Down Expand Up @@ -3343,6 +3361,53 @@ else if (getBlock().getType() == Material.FLOWER_POT) {
}
}

// <--[mechanism]
// @object LocationTag
// @name hive_max_bees
// @input Element(Number)
// @description
// Sets the maximum allowed number of bees in a beehive.
// @tags
// <LocationTag.hive_max_bees>
// -->
if (mechanism.matches("hive_max_bees") && mechanism.requireInteger()) {
Beehive hive = (Beehive) getBlockState();
hive.setMaxEntities(mechanism.getValue().asInt());
hive.update();
}

// <--[mechanism]
// @object LocationTag
// @name release_bees
// @input None
// @description
// Causes a beehive to release all its bees.
// Will do nothing if the hive is empty.
// @tags
// <LocationTag.hive_bee_count>
// -->
if (mechanism.matches("release_bees")) {
Beehive hive = (Beehive) getBlockState();
hive.releaseEntities();
hive.update();
}

// <--[mechanism]
// @object LocationTag
// @name add_bee
// @input EntityTag
// @description
// Adds a bee into a beehive.
// Will do nothing if there's no room left in the hive.
// @tags
// <LocationTag.hive_bee_count>
// -->
if (mechanism.matches("add_bee") && mechanism.requireObject(EntityTag.class)) {
Beehive hive = (Beehive) getBlockState();
hive.addEntity((Bee) mechanism.valueAsType(EntityTag.class).getBukkitEntity());
hive.update();
}

// <--[mechanism]
// @object LocationTag
// @name command_block_name
Expand Down

0 comments on commit f3dc84d

Please sign in to comment.