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.effect.particle; 018 019import net.tridentsdk.base.Position; 020import net.tridentsdk.effect.particle.ParticleEffect; 021import net.tridentsdk.effect.particle.ParticleEffectType; 022import net.tridentsdk.server.effect.TridentRemoteEffect; 023import net.tridentsdk.server.netty.packet.OutPacket; 024import net.tridentsdk.server.packets.play.out.PacketPlayOutParticle; 025import net.tridentsdk.util.Vector; 026import net.tridentsdk.world.World; 027 028/** 029 * Represents a particle effect 030 * 031 * @author The TridentSDK Team 032 */ 033public class TridentParticleEffect extends TridentRemoteEffect<ParticleEffectType> implements ParticleEffect { 034 private PacketPlayOutParticle packet = new PacketPlayOutParticle(); 035 036 public TridentParticleEffect(World world, ParticleEffectType type){ 037 packet.set("loc", new Position(world, 0, 0, 0)); 038 packet.set("particle", type); 039 packet.set("data", new int[0]); 040 } 041 042 @Override 043 public ParticleEffectType type(){ 044 return packet.particle(); 045 } 046 047 @Override 048 public void setType(ParticleEffectType type){ 049 packet.set("particle", type); 050 } 051 052 @Override 053 public void setPosition(Vector vector){ 054 packet.location().setX(vector.x()); 055 packet.location().setY(vector.y()); 056 packet.location().setZ(vector.z()); 057 } 058 059 @Override 060 public void setCount(int count){ 061 packet.set("count", count); 062 } 063 064 @Override 065 public void setLongDistance(boolean longDistance){ 066 packet.set("distance", longDistance); 067 } 068 069 @Override 070 public void setData(int[] data){ 071 packet.set("data", data); 072 } 073 074 @Override 075 public void setOffset(Vector offset){ 076 packet.set("offset", offset); 077 } 078 079 @Override 080 public int count(){ 081 return packet.count(); 082 } 083 084 @Override 085 public boolean longDistance(){ 086 return packet.isDistance(); 087 } 088 089 @Override 090 public int[] data(){ 091 return packet.data(); 092 } 093 094 @Override 095 public Vector offset(){ 096 return packet.offset(); 097 } 098 099 @Override 100 public OutPacket getPacket(){ 101 return packet; 102 } 103}