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.server.entity.living; 019 020import net.tridentsdk.base.Position; 021import net.tridentsdk.entity.Entity; 022import net.tridentsdk.entity.Projectile; 023import net.tridentsdk.entity.living.Bat; 024import net.tridentsdk.entity.living.Player; 025import net.tridentsdk.entity.traits.EntityProperties; 026import net.tridentsdk.entity.types.EntityType; 027import net.tridentsdk.event.entity.EntityDamageEvent; 028import net.tridentsdk.meta.nbt.ByteTag; 029import net.tridentsdk.meta.nbt.CompoundTag; 030import net.tridentsdk.server.data.MetadataType; 031import net.tridentsdk.server.data.ProtocolMetadata; 032import net.tridentsdk.server.entity.TridentLivingEntity; 033 034import java.util.UUID; 035 036public class TridentBat extends TridentLivingEntity implements Bat { 037 private volatile boolean hanging; 038 039 public TridentBat(UUID id, Position spawnLocation) { 040 super(id, spawnLocation); 041 042 this.hanging = false; 043 } 044 045 @Override 046 protected void doEncodeMeta(ProtocolMetadata protocolMeta) { 047 protocolMeta.setMeta(16, MetadataType.BYTE, 048 hanging ? (byte) 1 : (byte) 0); 049 } 050 051 @Override 052 public void load(CompoundTag tag) { 053 this.hanging = ((ByteTag) tag.getTag("BatFlags")).value() == 1; 054 } 055 056 @Override 057 public boolean isHanging() { 058 return hanging; 059 } 060 061 @Override 062 public boolean isFlying() { 063 return !isHanging(); 064 } 065 066 @Override 067 public boolean isHostile() { 068 return false; 069 } 070 071 @Override 072 public void hide(Entity entity) { 073 } 074 075 @Override 076 public void show(Entity entity) { 077 } 078 079 @Override 080 public EntityDamageEvent lastDamageEvent() { 081 return null; 082 } 083 084 @Override 085 public Player lastPlayerDamager() { 086 return null; 087 } 088 089 @Override 090 public void applyProperties(EntityProperties properties) { 091 092 } 093 094 @Override 095 public <T extends Projectile> T launchProjectile(EntityProperties properties) { 096 return null; 097 } 098 099 @Override 100 public EntityType type() { 101 return EntityType.BAT; 102 } 103}