Search in sources :

Example 1 with GlowPainting

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

the class ItemPainting method rightClickBlock.

@Override
public void rightClickBlock(GlowPlayer player, GlowBlock target, BlockFace face, ItemStack holding, Vector clickedLoc, EquipmentSlot hand) {
    Location center = target.getRelative(face).getLocation();
    GlowPainting painting = new GlowPainting(center, face);
    for (Key key : ART_BY_SIZE.keySet()) {
        List<Art> arts = ART_BY_SIZE.get(key);
        painting.setArtInternal(arts.get(0));
        if (!painting.isObstructed()) {
            int i = ThreadLocalRandom.current().nextInt(0, arts.size());
            painting.setArtInternal(arts.get(i));
            return;
        }
    }
    player.playSound(center, Sound.ENTITY_PAINTING_PLACE, SoundCategory.NEUTRAL, 1.0f, 1.0f);
}
Also used : GlowPainting(net.glowstone.entity.objects.GlowPainting) Art(org.bukkit.Art) Key(net.glowstone.chunk.GlowChunk.Key) Location(org.bukkit.Location)

Example 2 with GlowPainting

use of net.glowstone.entity.objects.GlowPainting 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

GlowPainting (net.glowstone.entity.objects.GlowPainting)2 Location (org.bukkit.Location)2 PlayerInitialSpawnEvent (com.destroystokyo.paper.event.player.PlayerInitialSpawnEvent)1 Message (com.flowpowered.network.Message)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 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1 UUID (java.util.UUID)1 ReadWriteLock (java.util.concurrent.locks.ReadWriteLock)1 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)1 Getter (lombok.Getter)1 Setter (lombok.Setter)1