001/*
002 * Trident - A Multithreaded Server Alternative
003 * Copyright 2014 The TridentSDK Team
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *    http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package net.tridentsdk.server.entity.projectile;
018
019import net.tridentsdk.base.Position;
020import net.tridentsdk.entity.living.ProjectileLauncher;
021import net.tridentsdk.entity.projectile.Arrow;
022import net.tridentsdk.entity.traits.EntityProperties;
023import net.tridentsdk.entity.types.EntityType;
024import net.tridentsdk.server.entity.TridentEntity;
025import net.tridentsdk.server.packets.play.out.PacketPlayOutSpawnObject;
026import net.tridentsdk.server.player.TridentPlayer;
027
028import java.util.UUID;
029
030/**
031 * Represents a launchable arrow in flight
032 *
033 * @author The TridentSDK Team
034 */
035public class TridentArrow extends TridentProjectile implements Arrow {
036    public TridentArrow(UUID uuid, Position spawnPosition, ProjectileLauncher projectileLauncher) {
037        super(uuid, spawnPosition, projectileLauncher);
038    }
039
040    @Override
041    public boolean canPickup() {
042        return false;
043    }
044
045    @Override
046    public void setPickup(boolean pickup) {
047
048    }
049
050    @Override
051    public void applyProperties(EntityProperties properties) {
052
053    }
054
055    @Override
056    protected void hit() {
057
058    }
059
060    @Override
061    public EntityType type() {
062        return EntityType.ARROW;
063    }
064
065    @Override
066    public TridentEntity spawn() {
067        TridentPlayer.sendFiltered(new PacketPlayOutSpawnObject().set("entityId", entityId()).set("entity", this),
068                player -> player.world().equals(this.world()));
069        return super.spawn();
070    }
071}