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 */ 017 018package net.tridentsdk.entity; 019 020import net.tridentsdk.base.Position; 021import net.tridentsdk.effect.entity.EntityStatusEffect; 022import net.tridentsdk.effect.entity.EntityStatusEffectType; 023import net.tridentsdk.entity.living.Player; 024import net.tridentsdk.entity.living.ProjectileLauncher; 025import net.tridentsdk.entity.living.ai.AiModule; 026import net.tridentsdk.entity.living.ai.Path; 027import net.tridentsdk.event.entity.EntityDamageEvent; 028 029/** 030 * An entity that is alive, which can be damaged and move with AI 031 * 032 * @author The TridentSDK Team 033 * @since 0.3-alpha-DP 034 */ 035public interface LivingEntity extends Entity, ProjectileLauncher { 036 /** 037 * Makes the specified entity invisible to the current entity 038 * 039 * <p>Has no effect if the current entity is not a player</p> 040 * 041 * @param entity the entity to make invisible to this entity 042 */ 043 void hide(Entity entity); 044 045 /** 046 * Un-hides the entity that was hidden from view, or does nothing of already visible 047 * 048 * <p>Has no effect if the current entity is not a player</p> 049 * 050 * @param entity the entity to make visible to this entity 051 */ 052 void show(Entity entity); 053 054 /** 055 * Returns the health of the Entity 056 * 057 * @return double health of the Entity 058 */ 059 double health(); 060 061 /** 062 * Sets the health of the Entity 063 * 064 * @param health health of the Entity 065 */ 066 void setHealth(double health); 067 068 /** 069 * Returns the maximum health of the Entity 070 * 071 * @return double maximum health of the Entity 072 */ 073 double maxHealth(); 074 075 /** 076 * Sets the maximum health of the Entity 077 * 078 * <p>maxHealth cannot be above the current health of the Entity</p> 079 * 080 * @param maxHealth maximum health of the Entity 081 */ 082 void setMaxHealth(double maxHealth); 083 084 /** 085 * Returns the amount of remaining air for the Entity 086 * 087 * @return long remaining amount of air in ticks 088 */ 089 long remainingAir(); 090 091 /** 092 * Sets the amount of remaining air for the LivingAir 093 * 094 * @param ticks long amount of remaining air in ticks 095 */ 096 void setRemainingAir(long ticks); 097 098 /** 099 * Returns the display name for the Entity 100 * 101 * @return String the display name for the Entity 102 */ 103 @Override 104 String displayName(); 105 106 /** 107 * Returns the position of the Entity's eye 108 * 109 * @return Location the position of the Entity's eye 110 */ 111 Position headLocation(); 112 113 /** 114 * Returns if the Entity can pickup items 115 * 116 * @return true if the Entity can pickup items 117 */ 118 boolean canCollectItems(); 119 120 /** 121 * Returns the last EntityDamageEvent which inflicted this Entity 122 * 123 * <p>The event may be cancelled.</p> 124 * 125 * @return EntityDamageEvent the last Entity to inflict this Entity 126 */ 127 EntityDamageEvent lastDamageEvent(); 128 129 /** 130 * Returns the player who dealt damage to this Entity since its last full heal 131 * 132 * <p>Used for death messages</p> 133 * 134 * @return Player the player who dealt damage to this entity since last full heal Returns null if no player has 135 * damaged the Entity 136 */ 137 Player lastPlayerDamager(); 138 139 /** 140 * Checks if the entity has died, or has 0 health. Should only apply to entities that are {@code instanceof} {@link 141 * net.tridentsdk.entity.LivingEntity} 142 * 143 * @return {@code true} if the entity is dead, {@code false} if it is alive 144 */ 145 boolean isDead(); 146 147 /** 148 * Gets the AI Module for this class, which will be the default if there is no special AI that has been defined for 149 * this entity 150 * 151 * @return the AI module that controls this entity 152 */ 153 AiModule aiModule(); 154 155 /** 156 * Overides defaults and previous AI Modules for this entity, assigning a new module to it 157 */ 158 void setAiModule(AiModule module); 159 160 /** 161 * Gets the path that this entity is currently following 162 */ 163 Path path(); 164 165 /** 166 * Sets a path for this entity to follow, should only be used in an AiHandler 167 */ 168 void setPath(Path path); 169 170 /** 171 * Creates a new entity status effect 172 * 173 * @param status The status to apply 174 * @return A new instance of EntityStatusEffect 175 */ 176 EntityStatusEffect createStatusEffect(EntityStatusEffectType status); 177}