Search in sources :

Example 1 with GlowItemFrame

use of net.glowstone.entity.objects.GlowItemFrame in project Glowstone by GlowstoneMC.

the class ItemItemFrame method rightClickBlock.

@Override
public void rightClickBlock(GlowPlayer player, GlowBlock target, BlockFace face, ItemStack holding, Vector clickedLoc) {
    GlowItemFrame entity = new GlowItemFrame(player, target.getLocation().getBlock().getRelative(face).getLocation(), face);
    List<Message> spawnMessage = entity.createSpawnMessage();
    entity.getWorld().getRawPlayers().stream().filter(p -> p.canSeeEntity(entity)).forEach(p -> p.getSession().sendAll(spawnMessage.toArray(new Message[spawnMessage.size()])));
}
Also used : Vector(org.bukkit.util.Vector) GlowBlock(net.glowstone.block.GlowBlock) List(java.util.List) Message(com.flowpowered.network.Message) GlowPlayer(net.glowstone.entity.GlowPlayer) BlockFace(org.bukkit.block.BlockFace) GlowItemFrame(net.glowstone.entity.objects.GlowItemFrame) ItemStack(org.bukkit.inventory.ItemStack) Message(com.flowpowered.network.Message) GlowItemFrame(net.glowstone.entity.objects.GlowItemFrame)

Example 2 with GlowItemFrame

use of net.glowstone.entity.objects.GlowItemFrame in project Glowstone by GlowstoneMC.

the class ItemFrameStore method createEntity.

public GlowItemFrame createEntity(Location location, CompoundTag compound) {
    // item frame will be set by loading code below
    int facing = compound.getByte("Facing");
    GlowItemFrame itemFrame = new GlowItemFrame(null, location, null);
    itemFrame.setFacingDirectionNumber(facing);
    return itemFrame;
}
Also used : GlowItemFrame(net.glowstone.entity.objects.GlowItemFrame)

Example 3 with GlowItemFrame

use of net.glowstone.entity.objects.GlowItemFrame in project Glowstone by GlowstoneMC.

the class ItemItemFrame method rightClickBlock.

@Override
public void rightClickBlock(GlowPlayer player, GlowBlock target, BlockFace face, ItemStack holding, Vector clickedLoc, EquipmentSlot hand) {
    GlowItemFrame entity = new GlowItemFrame(player, target.getRelative(face).getLocation(), face);
    if (EventFactory.getInstance().callEvent(new HangingPlaceEvent(entity, player, target, face)).isCancelled()) {
        return;
    }
    List<Message> spawnMessage = entity.createSpawnMessage();
    entity.getWorld().getRawPlayers().stream().filter(p -> p.canSeeEntity(entity)).forEach(p -> p.getSession().sendAll(spawnMessage.toArray(new Message[spawnMessage.size()])));
}
Also used : Vector(org.bukkit.util.Vector) GlowBlock(net.glowstone.block.GlowBlock) List(java.util.List) EventFactory(net.glowstone.EventFactory) Message(com.flowpowered.network.Message) GlowPlayer(net.glowstone.entity.GlowPlayer) BlockFace(org.bukkit.block.BlockFace) GlowItemFrame(net.glowstone.entity.objects.GlowItemFrame) HangingPlaceEvent(org.bukkit.event.hanging.HangingPlaceEvent) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) ItemStack(org.bukkit.inventory.ItemStack) HangingPlaceEvent(org.bukkit.event.hanging.HangingPlaceEvent) Message(com.flowpowered.network.Message) GlowItemFrame(net.glowstone.entity.objects.GlowItemFrame)

Example 4 with GlowItemFrame

use of net.glowstone.entity.objects.GlowItemFrame in project Glowstone by GlowstoneMC.

the class GlowEntity method pulse.

/**
 * Called every game cycle. Subclasses should implement this to implement periodic functionality
 * e.g. mob AI.
 */
public void pulse() {
    if (!isTicking()) {
        return;
    }
    ticksLived++;
    if (fireTicks > 0) {
        --fireTicks;
    }
    metadata.setBit(MetadataIndex.STATUS, StatusFlags.ON_FIRE, fireTicks > 0);
    // to dislocate.
    if (ticksLived % (30 * 20) == 0) {
        if (!(this instanceof GlowItemFrame || this instanceof GlowPainting)) {
            teleported = true;
        }
    }
    if (this instanceof GlowLivingEntity && !isDead() && ((GlowLivingEntity) this).hasAI()) {
        GlowLivingEntity entity = (GlowLivingEntity) this;
        entity.getTaskManager().pulse();
    }
    followLead();
    pulsePhysics();
    if (hasMoved()) {
        Block currentBlock = location.getBlock();
        if (currentBlock.getType() == Material.END_PORTAL) {
            EventFactory.getInstance().callEvent(new EntityPortalEnterEvent(this, currentBlock.getLocation()));
            if (server.getAllowEnd()) {
                Location previousLocation = location.clone();
                boolean success;
                if (getWorld().getEnvironment() == Environment.THE_END) {
                    success = teleportToSpawn();
                } else {
                    success = teleportToEnd();
                }
                if (success) {
                    EntityPortalExitEvent e = EventFactory.getInstance().callEvent(new EntityPortalExitEvent(this, previousLocation, location.clone(), velocity.clone(), new Vector()));
                    if (!e.getAfter().equals(velocity)) {
                        setVelocity(e.getAfter());
                    }
                }
            }
        }
    }
    if (leashHolderUniqueId != null && ticksLived < 2) {
        Optional<GlowEntity> any = world.getEntityManager().getAll().stream().filter(e -> leashHolderUniqueId.equals(e.getUniqueId())).findAny();
        if (!any.isPresent()) {
            world.dropItemNaturally(location, new ItemStack(Material.LEAD));
        }
        setLeashHolder(any.orElse(null));
        leashHolderUniqueId = null;
    }
}
Also used : Plugin(org.bukkit.plugin.Plugin) EntityEffect(org.bukkit.EntityEffect) EntityUnleashEvent(org.bukkit.event.entity.EntityUnleashEvent) StatusFlags(net.glowstone.entity.meta.MetadataIndex.StatusFlags) UuidUtils(net.glowstone.util.UuidUtils) Projectile(org.bukkit.entity.Projectile) BlockFace(org.bukkit.block.BlockFace) Player(org.bukkit.entity.Player) EntityMountEvent(org.spigotmc.event.entity.EntityMountEvent) EntityPortalExitEvent(org.bukkit.event.entity.EntityPortalExitEvent) Block(org.bukkit.block.Block) Location(org.bukkit.Location) EntityRotationMessage(net.glowstone.net.message.play.entity.EntityRotationMessage) EntityStatusMessage(net.glowstone.net.message.play.entity.EntityStatusMessage) World(org.bukkit.World) InteractEntityMessage(net.glowstone.net.message.play.player.InteractEntityMessage) Chunk(org.bukkit.Chunk) BoundingBox(net.glowstone.entity.physics.BoundingBox) GlowWorld(net.glowstone.GlowWorld) GlowItemFrame(net.glowstone.entity.objects.GlowItemFrame) Material(org.bukkit.Material) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) Position(net.glowstone.util.Position) DamageCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause) PersistentDataContainer(org.bukkit.persistence.PersistentDataContainer) PistonMoveReaction(org.bukkit.block.PistonMoveReaction) EntityMetadataMessage(net.glowstone.net.message.play.entity.EntityMetadataMessage) Entity(org.bukkit.entity.Entity) CreatureSpawnEvent(org.bukkit.event.entity.CreatureSpawnEvent) GlowChunk(net.glowstone.chunk.GlowChunk) Set(java.util.Set) UUID(java.util.UUID) EntityType(org.bukkit.entity.EntityType) LivingEntity(org.bukkit.entity.LivingEntity) ItemStack(org.bukkit.inventory.ItemStack) EntityTeleportMessage(net.glowstone.net.message.play.entity.EntityTeleportMessage) Objects(java.util.Objects) EntityBoundingBox(net.glowstone.entity.physics.EntityBoundingBox) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) MetadataIndex(net.glowstone.entity.meta.MetadataIndex) MetadataValue(org.bukkit.metadata.MetadataValue) Entry(net.glowstone.entity.meta.MetadataMap.Entry) VehicleExitEvent(org.bukkit.event.vehicle.VehicleExitEvent) Optional(java.util.Optional) NotNull(org.jetbrains.annotations.NotNull) PlayerInitialSpawnEvent(com.destroystokyo.paper.event.player.PlayerInitialSpawnEvent) Setter(lombok.Setter) SetPassengerMessage(net.glowstone.net.message.play.entity.SetPassengerMessage) VehicleEnterEvent(org.bukkit.event.vehicle.VehicleEnterEvent) Getter(lombok.Getter) MetadataMap(net.glowstone.entity.meta.MetadataMap) Message(com.flowpowered.network.Message) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) ArrayList(java.util.ArrayList) EntityDismountEvent(org.spigotmc.event.entity.EntityDismountEvent) Lists(com.google.common.collect.Lists) Environment(org.bukkit.World.Environment) PermissionAttachment(org.bukkit.permissions.PermissionAttachment) ImmutableList(com.google.common.collect.ImmutableList) GlowLeashHitch(net.glowstone.entity.objects.GlowLeashHitch) Component(net.kyori.adventure.text.Component) Vehicle(org.bukkit.entity.Vehicle) GlowSession(net.glowstone.net.GlowSession) GlowServer(net.glowstone.GlowServer) LinkedList(java.util.LinkedList) TextMessage(net.glowstone.util.TextMessage) RelativeEntityPositionMessage(net.glowstone.net.message.play.entity.RelativeEntityPositionMessage) EntityDamageEvent(org.bukkit.event.entity.EntityDamageEvent) MetadataStore(org.bukkit.metadata.MetadataStore) PlayerSpawnLocationEvent(org.spigotmc.event.player.PlayerSpawnLocationEvent) GlowPainting(net.glowstone.entity.objects.GlowPainting) EntityPortalEvent(org.bukkit.event.entity.EntityPortalEvent) TeleportCause(org.bukkit.event.player.PlayerTeleportEvent.TeleportCause) UnleashReason(org.bukkit.event.entity.EntityUnleashEvent.UnleashReason) EventFactory(net.glowstone.EventFactory) EntityTeleportEvent(org.bukkit.event.entity.EntityTeleportEvent) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) PermissionAttachmentInfo(org.bukkit.permissions.PermissionAttachmentInfo) EntityVelocityMessage(net.glowstone.net.message.play.entity.EntityVelocityMessage) Permission(org.bukkit.permissions.Permission) Vector(org.bukkit.util.Vector) AttachEntityMessage(net.glowstone.net.message.play.entity.AttachEntityMessage) Pose(org.bukkit.entity.Pose) Preconditions(com.google.common.base.Preconditions) RelativeEntityPositionRotationMessage(net.glowstone.net.message.play.entity.RelativeEntityPositionRotationMessage) EntityPortalEnterEvent(org.bukkit.event.entity.EntityPortalEnterEvent) MetadataStoreBase(org.bukkit.metadata.MetadataStoreBase) Collections(java.util.Collections) ProjectileHitEvent(org.bukkit.event.entity.ProjectileHitEvent) GlowPainting(net.glowstone.entity.objects.GlowPainting) GlowItemFrame(net.glowstone.entity.objects.GlowItemFrame) EntityPortalEnterEvent(org.bukkit.event.entity.EntityPortalEnterEvent) Block(org.bukkit.block.Block) ItemStack(org.bukkit.inventory.ItemStack) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location) EntityPortalExitEvent(org.bukkit.event.entity.EntityPortalExitEvent)

Aggregations

GlowItemFrame (net.glowstone.entity.objects.GlowItemFrame)4 Message (com.flowpowered.network.Message)3 List (java.util.List)3 BlockFace (org.bukkit.block.BlockFace)3 ItemStack (org.bukkit.inventory.ItemStack)3 Vector (org.bukkit.util.Vector)3 EventFactory (net.glowstone.EventFactory)2 GlowBlock (net.glowstone.block.GlowBlock)2 GlowPlayer (net.glowstone.entity.GlowPlayer)2 PlayerInitialSpawnEvent (com.destroystokyo.paper.event.player.PlayerInitialSpawnEvent)1 Preconditions (com.google.common.base.Preconditions)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 ImmutableList (com.google.common.collect.ImmutableList)1 Lists (com.google.common.collect.Lists)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 LinkedList (java.util.LinkedList)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1