Search in sources :

Example 41 with Craft

use of net.countercraft.movecraft.craft.Craft in project Movecraft by APDevTeam.

the class BlockListener method onHopperEvent.

// prevent hoppers on cruising crafts
@EventHandler(priority = EventPriority.HIGHEST)
public void onHopperEvent(InventoryMoveItemEvent event) {
    if (!(event.getSource().getHolder() instanceof Hopper)) {
        return;
    }
    Hopper block = (Hopper) event.getSource().getHolder();
    CraftManager.getInstance().getCraftsInWorld(block.getWorld());
    for (Craft tcraft : CraftManager.getInstance().getCraftsInWorld(block.getWorld())) {
        MovecraftLocation mloc = new MovecraftLocation(block.getX(), block.getY(), block.getZ());
        if (MathUtils.locIsNearCraftFast(tcraft, mloc) && tcraft.getCruising() && !tcraft.isNotProcessing()) {
            event.setCancelled(true);
            return;
        }
    }
}
Also used : Craft(net.countercraft.movecraft.craft.Craft) Hopper(org.bukkit.block.Hopper) MovecraftLocation(net.countercraft.movecraft.MovecraftLocation) EventHandler(org.bukkit.event.EventHandler)

Example 42 with Craft

use of net.countercraft.movecraft.craft.Craft in project Movecraft by APDevTeam.

the class BlockListener method onPistonEvent.

// prevent pistons on cruising crafts
@EventHandler(priority = EventPriority.HIGHEST)
public void onPistonEvent(BlockPistonExtendEvent event) {
    Block block = event.getBlock();
    CraftManager.getInstance().getCraftsInWorld(block.getWorld());
    for (Craft tcraft : CraftManager.getInstance().getCraftsInWorld(block.getWorld())) {
        MovecraftLocation mloc = new MovecraftLocation(block.getX(), block.getY(), block.getZ());
        if (MathUtils.locIsNearCraftFast(tcraft, mloc) && tcraft.getCruising() && !tcraft.isNotProcessing()) {
            event.setCancelled(true);
            return;
        }
    }
}
Also used : Craft(net.countercraft.movecraft.craft.Craft) Block(org.bukkit.block.Block) MovecraftLocation(net.countercraft.movecraft.MovecraftLocation) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Craft (net.countercraft.movecraft.craft.Craft)42 EventHandler (org.bukkit.event.EventHandler)22 MovecraftLocation (net.countercraft.movecraft.MovecraftLocation)19 Player (org.bukkit.entity.Player)14 SinkingCraft (net.countercraft.movecraft.craft.SinkingCraft)13 Sign (org.bukkit.block.Sign)12 PilotedCraft (net.countercraft.movecraft.craft.PilotedCraft)11 BlockState (org.bukkit.block.BlockState)11 PlayerCraft (net.countercraft.movecraft.craft.PlayerCraft)9 World (org.bukkit.World)9 Location (org.bukkit.Location)6 Block (org.bukkit.block.Block)6 SubCraft (net.countercraft.movecraft.craft.SubCraft)4 CraftType (net.countercraft.movecraft.craft.type.CraftType)4 HitBox (net.countercraft.movecraft.util.hitboxes.HitBox)4 Material (org.bukkit.Material)4 NotNull (org.jetbrains.annotations.NotNull)4 ArrayList (java.util.ArrayList)3 Arrays (java.util.Arrays)3 HashSet (java.util.HashSet)3