Search in sources :

Example 1 with ProjectileDispenseBehavior

use of net.glowstone.dispenser.ProjectileDispenseBehavior in project Glowstone by GlowstoneMC.

the class GlowDispenser method register.

/**
 * Registers all vanilla dispense behaviors.
 */
public static void register() {
    // register all dispense behaviors
    DefaultDispenseBehavior bucketDispenseBehavior = new BucketDispenseBehavior();
    DispenseBehaviorRegistry registry = getDispenseBehaviorRegistry();
    registry.putBehavior(Material.WATER_BUCKET, bucketDispenseBehavior);
    registry.putBehavior(Material.LAVA_BUCKET, bucketDispenseBehavior);
    registry.putBehavior(Material.BUCKET, new EmptyBucketDispenseBehavior());
    registry.putBehavior(Material.FLINT_AND_STEEL, new FlintAndSteelDispenseBehavior());
    registry.putBehavior(Material.TNT, new TntDispenseBehavior());
    ArmorDispenseBehavior armorDispenseBehavior = new ArmorDispenseBehavior();
    registry.putBehavior(Material.LEATHER_BOOTS, armorDispenseBehavior);
    registry.putBehavior(Material.LEATHER_LEGGINGS, armorDispenseBehavior);
    registry.putBehavior(Material.LEATHER_CHESTPLATE, armorDispenseBehavior);
    registry.putBehavior(Material.LEATHER_HELMET, armorDispenseBehavior);
    registry.putBehavior(Material.GOLDEN_BOOTS, armorDispenseBehavior);
    registry.putBehavior(Material.GOLDEN_LEGGINGS, armorDispenseBehavior);
    registry.putBehavior(Material.GOLDEN_CHESTPLATE, armorDispenseBehavior);
    registry.putBehavior(Material.GOLDEN_HELMET, armorDispenseBehavior);
    registry.putBehavior(Material.IRON_BOOTS, armorDispenseBehavior);
    registry.putBehavior(Material.IRON_LEGGINGS, armorDispenseBehavior);
    registry.putBehavior(Material.IRON_CHESTPLATE, armorDispenseBehavior);
    registry.putBehavior(Material.IRON_HELMET, armorDispenseBehavior);
    registry.putBehavior(Material.CHAINMAIL_BOOTS, armorDispenseBehavior);
    registry.putBehavior(Material.CHAINMAIL_LEGGINGS, armorDispenseBehavior);
    registry.putBehavior(Material.CHAINMAIL_CHESTPLATE, armorDispenseBehavior);
    registry.putBehavior(Material.CHAINMAIL_HELMET, armorDispenseBehavior);
    registry.putBehavior(Material.DIAMOND_BOOTS, armorDispenseBehavior);
    registry.putBehavior(Material.DIAMOND_LEGGINGS, armorDispenseBehavior);
    registry.putBehavior(Material.DIAMOND_CHESTPLATE, armorDispenseBehavior);
    registry.putBehavior(Material.DIAMOND_HELMET, armorDispenseBehavior);
    for (Material headType : MaterialTags.SKULLS.getValues()) {
        registry.putBehavior(headType, armorDispenseBehavior);
    }
    registry.putBehavior(Material.PUMPKIN, armorDispenseBehavior);
    registry.putBehavior(Material.EGG, new ProjectileDispenseBehavior(GlowEgg::new));
    registry.putBehavior(Material.SNOWBALL, new ProjectileDispenseBehavior(GlowSnowball::new));
    registry.putBehavior(Material.ARROW, new ProjectileDispenseBehavior(GlowArrow::new));
    registry.putBehavior(Material.EXPERIENCE_BOTTLE, new ProjectileDispenseBehavior(GlowThrownExpBottle::new));
    registry.putBehavior(Material.SPECTRAL_ARROW, new ProjectileDispenseBehavior(GlowSpectralArrow::new));
    registry.putBehavior(Material.TIPPED_ARROW, new ProjectileDispenseBehavior(((location, itemStack) -> {
        GlowTippedArrow tippedArrow = new GlowTippedArrow(location);
        tippedArrow.copyFrom((PotionMeta) itemStack.getItemMeta());
        return tippedArrow;
    })));
    registry.putBehavior(Material.FIRE_CHARGE, new ProjectileDispenseBehavior(location -> {
        Fireball fireball = new GlowFireball(location);
        fireball.setYield(0);
        fireball.setIsIncendiary(true);
        return fireball;
    }));
    registry.putBehavior(Material.SPLASH_POTION, new ProjectileDispenseBehavior((location, itemStack) -> {
        SplashPotion potion = new GlowSplashPotion(location);
        potion.setItem(itemStack);
        return potion;
    }));
    registry.putBehavior(Material.LINGERING_POTION, new ProjectileDispenseBehavior((location, itemStack) -> {
        SplashPotion potion = new GlowLingeringPotion(location);
        potion.setItem(itemStack);
        return potion;
    }));
// TODO: Firework rockets
}
Also used : GlowEgg(net.glowstone.entity.projectile.GlowEgg) GlowSplashPotion(net.glowstone.entity.projectile.GlowSplashPotion) GlowBlock(net.glowstone.block.GlowBlock) Getter(lombok.Getter) BucketDispenseBehavior(net.glowstone.dispenser.BucketDispenseBehavior) DispenseBehaviorRegistry(net.glowstone.dispenser.DispenseBehaviorRegistry) SplashPotion(org.bukkit.entity.SplashPotion) FlintAndSteelDispenseBehavior(net.glowstone.dispenser.FlintAndSteelDispenseBehavior) Projectile(org.bukkit.entity.Projectile) InventoryUtil(net.glowstone.util.InventoryUtil) Inventory(org.bukkit.inventory.Inventory) Effect(org.bukkit.Effect) EmptyBucketDispenseBehavior(net.glowstone.dispenser.EmptyBucketDispenseBehavior) GlowFireball(net.glowstone.entity.projectile.GlowFireball) GlowThrownExpBottle(net.glowstone.entity.projectile.GlowThrownExpBottle) Map(java.util.Map) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) PotionMeta(org.bukkit.inventory.meta.PotionMeta) Dispenser(org.bukkit.block.Dispenser) Material(org.bukkit.Material) BlockProjectileSource(org.bukkit.projectiles.BlockProjectileSource) GlowSpectralArrow(net.glowstone.entity.projectile.GlowSpectralArrow) MaterialTags(com.destroystokyo.paper.MaterialTags) GlowArrow(net.glowstone.entity.projectile.GlowArrow) ItemStack(org.bukkit.inventory.ItemStack) Vector(org.bukkit.util.Vector) DefaultDispenseBehavior(net.glowstone.dispenser.DefaultDispenseBehavior) GlowSnowball(net.glowstone.entity.projectile.GlowSnowball) DispenseBehavior(net.glowstone.dispenser.DispenseBehavior) ProjectileDispenseBehavior(net.glowstone.dispenser.ProjectileDispenseBehavior) GlowLingeringPotion(net.glowstone.entity.projectile.GlowLingeringPotion) ArmorDispenseBehavior(net.glowstone.dispenser.ArmorDispenseBehavior) GlowTippedArrow(net.glowstone.entity.projectile.GlowTippedArrow) DispenserEntity(net.glowstone.block.entity.DispenserEntity) Fireball(org.bukkit.entity.Fireball) TntDispenseBehavior(net.glowstone.dispenser.TntDispenseBehavior) FlintAndSteelDispenseBehavior(net.glowstone.dispenser.FlintAndSteelDispenseBehavior) ArmorDispenseBehavior(net.glowstone.dispenser.ArmorDispenseBehavior) TntDispenseBehavior(net.glowstone.dispenser.TntDispenseBehavior) Material(org.bukkit.Material) GlowSplashPotion(net.glowstone.entity.projectile.GlowSplashPotion) GlowFireball(net.glowstone.entity.projectile.GlowFireball) GlowSplashPotion(net.glowstone.entity.projectile.GlowSplashPotion) SplashPotion(org.bukkit.entity.SplashPotion) BucketDispenseBehavior(net.glowstone.dispenser.BucketDispenseBehavior) EmptyBucketDispenseBehavior(net.glowstone.dispenser.EmptyBucketDispenseBehavior) DispenseBehaviorRegistry(net.glowstone.dispenser.DispenseBehaviorRegistry) GlowFireball(net.glowstone.entity.projectile.GlowFireball) Fireball(org.bukkit.entity.Fireball) EmptyBucketDispenseBehavior(net.glowstone.dispenser.EmptyBucketDispenseBehavior) GlowTippedArrow(net.glowstone.entity.projectile.GlowTippedArrow) GlowLingeringPotion(net.glowstone.entity.projectile.GlowLingeringPotion) DefaultDispenseBehavior(net.glowstone.dispenser.DefaultDispenseBehavior) ProjectileDispenseBehavior(net.glowstone.dispenser.ProjectileDispenseBehavior)

Aggregations

MaterialTags (com.destroystokyo.paper.MaterialTags)1 Map (java.util.Map)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 Getter (lombok.Getter)1 GlowBlock (net.glowstone.block.GlowBlock)1 DispenserEntity (net.glowstone.block.entity.DispenserEntity)1 ArmorDispenseBehavior (net.glowstone.dispenser.ArmorDispenseBehavior)1 BucketDispenseBehavior (net.glowstone.dispenser.BucketDispenseBehavior)1 DefaultDispenseBehavior (net.glowstone.dispenser.DefaultDispenseBehavior)1 DispenseBehavior (net.glowstone.dispenser.DispenseBehavior)1 DispenseBehaviorRegistry (net.glowstone.dispenser.DispenseBehaviorRegistry)1 EmptyBucketDispenseBehavior (net.glowstone.dispenser.EmptyBucketDispenseBehavior)1 FlintAndSteelDispenseBehavior (net.glowstone.dispenser.FlintAndSteelDispenseBehavior)1 ProjectileDispenseBehavior (net.glowstone.dispenser.ProjectileDispenseBehavior)1 TntDispenseBehavior (net.glowstone.dispenser.TntDispenseBehavior)1 GlowArrow (net.glowstone.entity.projectile.GlowArrow)1 GlowEgg (net.glowstone.entity.projectile.GlowEgg)1 GlowFireball (net.glowstone.entity.projectile.GlowFireball)1 GlowLingeringPotion (net.glowstone.entity.projectile.GlowLingeringPotion)1 GlowSnowball (net.glowstone.entity.projectile.GlowSnowball)1