L2Object rework.

This commit is contained in:
MobiusDev
2018-09-08 04:13:34 +00:00
parent e5c0665db3
commit 2bb8220df2
250 changed files with 1750 additions and 5952 deletions

View File

@@ -236,7 +236,7 @@ public class L2AttackableAI extends L2CharacterAI
}
else if (npc.getSpawn() != null)
{
final Location loc = npc.getSpawn().getLocation();
final Location loc = npc.getSpawn();
final int range = Config.MAX_DRIFT_RANGE;
if (!npc.isInsideRadius3D(loc, range + range))

View File

@@ -95,9 +95,7 @@ public class DBSpawnManager
if (template != null)
{
final L2Spawn spawn = new L2Spawn(template);
spawn.setX(rset.getInt("x"));
spawn.setY(rset.getInt("y"));
spawn.setZ(rset.getInt("z"));
spawn.setXYZ(rset.getInt("x"), rset.getInt("y"), rset.getInt("z"));
spawn.setAmount(1);
spawn.setHeading(rset.getInt("heading"));

View File

@@ -261,9 +261,7 @@ public final class SiegeGuardManager
{
final L2Spawn spawn = new L2Spawn(rs.getInt("npcId"));
spawn.setAmount(1);
spawn.setX(rs.getInt("x"));
spawn.setY(rs.getInt("y"));
spawn.setZ(rs.getInt("z"));
spawn.setXYZ(rs.getInt("x"), rs.getInt("y"), rs.getInt("z"));
spawn.setHeading(rs.getInt("heading"));
spawn.setRespawnDelay(rs.getInt("respawnDelay"));
spawn.setLocationId(0);

View File

@@ -18,7 +18,6 @@ package com.l2jmobius.gameserver.model;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.handler.ActionHandler;
@@ -29,7 +28,6 @@ import com.l2jmobius.gameserver.idfactory.IdFactory;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.poly.ObjectPoly;
import com.l2jmobius.gameserver.model.events.ListenersContainer;
import com.l2jmobius.gameserver.model.instancezone.Instance;
import com.l2jmobius.gameserver.model.interfaces.IDecayable;
@@ -58,18 +56,18 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
/** World Region */
private L2WorldRegion _worldRegion;
/** Instance type */
private InstanceType _instanceType = null;
private InstanceType _instanceType;
private volatile Map<String, Object> _scripts;
/** X coordinate */
private final AtomicInteger _x = new AtomicInteger(0);
private volatile int _x = 0;
/** Y coordinate */
private final AtomicInteger _y = new AtomicInteger(0);
private volatile int _y = 0;
/** Z coordinate */
private final AtomicInteger _z = new AtomicInteger(0);
private volatile int _z = 0;
/** Orientation */
private final AtomicInteger _heading = new AtomicInteger(0);
private volatile int _heading = 0;
/** Instance id of object. 0 - Global */
private Instance _instance = null;
private Instance _instance;
private boolean _isSpawned;
private boolean _isInvisible;
private boolean _isTargetable = true;
@@ -253,12 +251,6 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
return _objectId;
}
public final ObjectPoly getPoly()
{
final ObjectPoly poly = getScript(ObjectPoly.class);
return (poly == null) ? addScript(new ObjectPoly(this)) : poly;
}
public abstract void sendInfo(L2PcInstance activeChar);
public void sendPacket(IClientOutgoingPacket... packets)
@@ -546,7 +538,7 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
@Override
public int getX()
{
return _x.get();
return _x;
}
/**
@@ -556,7 +548,7 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
@Override
public int getY()
{
return _y.get();
return _y;
}
/**
@@ -566,7 +558,7 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
@Override
public int getZ()
{
return _z.get();
return _z;
}
/**
@@ -576,7 +568,7 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
@Override
public int getHeading()
{
return _heading.get();
return _heading;
}
/**
@@ -614,37 +606,7 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
@Override
public Location getLocation()
{
return new Location(_x.get(), _y.get(), _z.get(), _heading.get());
}
/**
* Sets the X coordinate
* @param newX the X coordinate
*/
@Override
public void setX(int newX)
{
_x.set(newX);
}
/**
* Sets the Y coordinate
* @param newY the Y coordinate
*/
@Override
public void setY(int newY)
{
_y.set(newY);
}
/**
* Sets the Z coordinate
* @param newZ the Z coordinate
*/
@Override
public void setZ(int newZ)
{
_z.set(newZ);
return new Location(_x, _y, _z, _heading);
}
/**
@@ -656,9 +618,9 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
@Override
public void setXYZ(int newX, int newY, int newZ)
{
setX(newX);
setY(newY);
setZ(newZ);
_x = newX;
_y = newY;
_z = newZ;
if (_isSpawned)
{
@@ -693,7 +655,7 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
@Override
public void setHeading(int newHeading)
{
_heading.set(newHeading);
_heading = newHeading;
}
/**
@@ -745,10 +707,10 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
@Override
public void setLocation(Location loc)
{
_x.set(loc.getX());
_y.set(loc.getY());
_z.set(loc.getZ());
_heading.set(loc.getHeading());
_x = loc.getX();
_y = loc.getY();
_z = loc.getZ();
_heading = loc.getHeading();
}
/**
@@ -760,7 +722,7 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
*/
public double calculateDistance2D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x.get(), 2) + Math.pow(y - _y.get(), 2));
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2));
}
/**
@@ -782,7 +744,7 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
*/
public double calculateDistance3D(int x, int y, int z)
{
return Math.sqrt(Math.pow(x - _x.get(), 2) + Math.pow(y - _y.get(), 2) + Math.pow(z - _z.get(), 2));
return Math.sqrt(Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2));
}
/**
@@ -804,7 +766,7 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
*/
public double calculateDistanceSq2D(int x, int y, int z)
{
return Math.pow(x - _x.get(), 2) + Math.pow(y - _y.get(), 2);
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2);
}
/**
@@ -826,7 +788,7 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
*/
public double calculateDistanceSq3D(int x, int y, int z)
{
return Math.pow(x - _x.get(), 2) + Math.pow(y - _y.get(), 2) + Math.pow(z - _z.get(), 2);
return Math.pow(x - _x, 2) + Math.pow(y - _y, 2) + Math.pow(z - _z, 2);
}
/**
@@ -848,7 +810,7 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
*/
public double calculateDirectionTo(ILocational target)
{
int heading = Util.calculateHeadingFrom(this, target) - _heading.get();
int heading = Util.calculateHeadingFrom(this, target) - _heading;
if (heading < 0)
{
heading = 65535 + heading;

View File

@@ -32,9 +32,7 @@ import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
import com.l2jmobius.gameserver.model.interfaces.ILocational;
import com.l2jmobius.gameserver.model.interfaces.INamable;
import com.l2jmobius.gameserver.model.interfaces.IPositionable;
import com.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate;
import com.l2jmobius.gameserver.model.zone.ZoneId;
@@ -45,7 +43,7 @@ import com.l2jmobius.gameserver.model.zone.ZoneId;
* The heading of the L2NpcInstance can be a random heading if not defined (value= -1) or an exact heading (ex : merchant...).
* @author Nightmare
*/
public class L2Spawn implements IPositionable, IIdentifiable, INamable
public class L2Spawn extends Location implements IIdentifiable, INamable
{
protected static final Logger LOGGER = Logger.getLogger(L2Spawn.class.getName());
@@ -59,10 +57,9 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
private int _currentCount;
/** The current number of SpawnTask in progress or stand by of this L2Spawn */
protected int _scheduledCount;
/** The identifier of the location area where L2NpcInstance can be spwaned */
/** The identifier of the location area where L2NpcInstance can be spawned */
private int _locationId;
/** The Location of this NPC spawn. */
private Location _location = new Location(0, 0, 0, 0);
/** The spawn instance id */
private int _instanceId = 0;
/** Minimum respawn delay */
private int _respawnMinDelay;
@@ -121,6 +118,7 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
*/
public L2Spawn(L2NpcTemplate template) throws SecurityException, ClassNotFoundException, NoSuchMethodException, ClassCastException
{
super(0, 0, 0);
// Set the _template of the L2Spawn
_template = template;
@@ -145,6 +143,7 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
*/
public L2Spawn(int npcId) throws SecurityException, ClassNotFoundException, NoSuchMethodException, ClassCastException
{
super(0, 0, 0);
_template = Objects.requireNonNull(NpcData.getInstance().getTemplate(npcId), "NpcTemplate not found for NPC ID: " + npcId);
final String className = "com.l2jmobius.gameserver.model.actor.instance." + _template.getType() + "Instance";
@@ -187,122 +186,6 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
return _locationId;
}
@Override
public Location getLocation()
{
return _location;
}
/**
* @return the X position of the spawn point.
*/
@Override
public int getX()
{
return _location.getX();
}
/**
* Set the X position of the spawn point.
* @param x the x coordinate
*/
@Override
public void setX(int x)
{
_location.setX(x);
}
/**
* @return the Y position of the spawn point.
*/
@Override
public int getY()
{
return _location.getY();
}
/**
* Set the Y position of the spawn point.
* @param y the y coordinate
*/
@Override
public void setY(int y)
{
_location.setY(y);
}
/**
* @return the Z position of the spawn point.
*/
@Override
public int getZ()
{
return _location.getZ();
}
/**
* Set the Z position of the spawn point.
* @param z the z coordinate
*/
@Override
public void setZ(int z)
{
_location.setZ(z);
}
/**
* Set the x, y, z position of the spawn point.
* @param x The x coordinate.
* @param y The y coordinate.
* @param z The z coordinate.
*/
@Override
public void setXYZ(int x, int y, int z)
{
setX(x);
setY(y);
setZ(z);
}
/**
* Set the x, y, z position of the spawn point.
* @param loc The location.
*/
@Override
public void setXYZ(ILocational loc)
{
setXYZ(loc.getX(), loc.getY(), loc.getZ());
}
/**
* @return the heading of L2NpcInstance when they are spawned.
*/
@Override
public int getHeading()
{
return _location.getHeading();
}
/**
* Set the heading of L2NpcInstance when they are spawned.
* @param heading
*/
@Override
public void setHeading(int heading)
{
_location.setHeading(heading);
}
/**
* Set the XYZ position of the spawn point.
* @param loc
*/
@Override
public void setLocation(Location loc)
{
_location = loc;
}
/**
* Gets the NPC ID.
* @return the NPC ID
@@ -511,7 +394,7 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
newlocz = loc.getZ();
setLocation(loc);
}
else if ((_location.getX() == 0) && (_location.getY() == 0))
else if ((getX() == 0) && (getY() == 0))
{
LOGGER.warning("NPC " + npc + " doesn't have spawn location!");
return null;
@@ -519,9 +402,9 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
else
{
// The L2NpcInstance is spawned at the exact position (Lox, Locy, Locz)
newlocx = _location.getX();
newlocy = _location.getY();
newlocz = _location.getZ();
newlocx = getX();
newlocy = getY();
newlocz = getZ();
}
// If random spawn system is enabled
@@ -541,13 +424,13 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
npc.setRandomWalking(_randomWalk);
// Set the heading of the L2NpcInstance (random heading if not defined)
if (_location.getHeading() == -1)
if (getHeading() == -1)
{
npc.setHeading(Rnd.nextInt(61794));
}
else
{
npc.setHeading(_location.getHeading());
npc.setHeading(getHeading());
}
// Set custom Npc server side name and title
@@ -666,12 +549,6 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
_instanceId = instanceId;
}
@Override
public String toString()
{
return "L2Spawn ID: " + _template.getId() + " " + _location;
}
public final boolean getRandomWalking()
{
return _randomWalk;
@@ -691,4 +568,10 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
{
return _spawnTemplate;
}
@Override
public String toString()
{
return "L2Spawn ID: " + _template.getId() + " X: " + getX() + " Y: " + getY() + " Z: " + getZ() + " Heading: " + getHeading();
}
}

View File

@@ -67,16 +67,6 @@ public class Location implements IPositionable
return _x;
}
/**
* Set the x coordinate.
* @param x the x coordinate
*/
@Override
public void setX(int x)
{
_x = x;
}
/**
* Get the y coordinate.
* @return the y coordinate
@@ -87,16 +77,6 @@ public class Location implements IPositionable
return _y;
}
/**
* Set the y coordinate.
* @param y the x coordinate
*/
@Override
public void setY(int y)
{
_y = y;
}
/**
* Get the z coordinate.
* @return the z coordinate
@@ -107,16 +87,6 @@ public class Location implements IPositionable
return _z;
}
/**
* Set the z coordinate.
* @param z the z coordinate
*/
@Override
public void setZ(int z)
{
_z = z;
}
/**
* Set the x, y, z coordinates.
* @param x the x coordinate
@@ -126,9 +96,9 @@ public class Location implements IPositionable
@Override
public void setXYZ(int x, int y, int z)
{
setX(x);
setY(y);
setZ(z);
_x = x;
_y = y;
_z = z;
}
/**

View File

@@ -152,9 +152,7 @@ public final class MobGroup
final int randX = Rnd.nextInt(MobGroupTable.RANDOM_RANGE);
final int randY = Rnd.nextInt(MobGroupTable.RANDOM_RANGE);
spawn.setX(x + (signX * randX));
spawn.setY(y + (signY * randY));
spawn.setZ(z);
spawn.setXYZ(x + (signX * randX), y + (signY * randY), z);
spawn.stopRespawn();
SpawnTable.getInstance().addNewSpawn(spawn, false);

View File

@@ -1,67 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.actor.poly;
import com.l2jmobius.gameserver.model.L2Object;
public class ObjectPoly
{
private final L2Object _activeObject;
private int _polyId;
private String _polyType;
public ObjectPoly(L2Object activeObject)
{
_activeObject = activeObject;
}
public void setPolyInfo(String polyType, String polyId)
{
setPolyId(Integer.parseInt(polyId));
setPolyType(polyType);
}
public final L2Object getActiveObject()
{
return _activeObject;
}
public final boolean isMorphed()
{
return _polyType != null;
}
public final int getPolyId()
{
return _polyId;
}
public final void setPolyId(int value)
{
_polyId = value;
}
public final String getPolyType()
{
return _polyType;
}
public final void setPolyType(String value)
{
_polyType = value;
}
}

View File

@@ -258,7 +258,7 @@ public final class Transform implements IIdentifiable
}
// Get player a bit higher so he doesn't drops underground after transformation happens
creature.setZ(creature.getZ() + (int) getCollisionHeight(creature, 0));
creature.setXYZ(creature.getX(), creature.getY(), (int) (creature.getZ() + getCollisionHeight(creature, 0)));
if (creature.isPlayer())
{

View File

@@ -482,9 +482,7 @@ public final class BlockCheckerEngine
for (int i = 0; i < _numOfBoxes; i++)
{
final L2Spawn spawn = new L2Spawn(template);
spawn.setX(_arenaCoordinates[_arena][4] + Rnd.get(-400, 400));
spawn.setY(_arenaCoordinates[_arena][5] + Rnd.get(-400, 400));
spawn.setZ(_zCoord);
spawn.setXYZ(_arenaCoordinates[_arena][4] + Rnd.get(-400, 400), _arenaCoordinates[_arena][5] + Rnd.get(-400, 400), _zCoord);
spawn.setAmount(1);
spawn.setHeading(1);
spawn.setRespawnDelay(1);
@@ -517,9 +515,7 @@ public final class BlockCheckerEngine
try
{
final L2Spawn girlSpawn = new L2Spawn(18676);
girlSpawn.setX(_arenaCoordinates[_arena][4] + Rnd.get(-400, 400));
girlSpawn.setY(_arenaCoordinates[_arena][5] + Rnd.get(-400, 400));
girlSpawn.setZ(_zCoord);
girlSpawn.setXYZ(_arenaCoordinates[_arena][4] + Rnd.get(-400, 400), _arenaCoordinates[_arena][5] + Rnd.get(-400, 400), _zCoord);
girlSpawn.setAmount(1);
girlSpawn.setHeading(1);
girlSpawn.setRespawnDelay(1);

View File

@@ -1188,9 +1188,7 @@ public final class Castle extends AbstractResidence
LOGGER.warning(Castle.class.getSimpleName() + ": " + e.getMessage());
return;
}
spawn.setX(holder.getX());
spawn.setY(holder.getY());
spawn.setZ(holder.getZ());
spawn.setXYZ(holder);
spawn.setHeading(holder.getHeading());
final L2Npc npc = spawn.doSpawn(false);
npc.broadcastInfo();

View File

@@ -1141,9 +1141,7 @@ public final class Fort extends AbstractResidence
{
final L2Spawn spawnDat = new L2Spawn(rs.getInt("npcId"));
spawnDat.setAmount(1);
spawnDat.setX(rs.getInt("x"));
spawnDat.setY(rs.getInt("y"));
spawnDat.setZ(rs.getInt("z"));
spawnDat.setXYZ(rs.getInt("x"), rs.getInt("y"), rs.getInt("z"));
spawnDat.setHeading(rs.getInt("heading"));
spawnDat.setRespawnDelay(60);
SpawnTable.getInstance().addNewSpawn(spawnDat, false);
@@ -1172,9 +1170,7 @@ public final class Fort extends AbstractResidence
{
final L2Spawn spawnDat = new L2Spawn(rs.getInt("npcId"));
spawnDat.setAmount(1);
spawnDat.setX(rs.getInt("x"));
spawnDat.setY(rs.getInt("y"));
spawnDat.setZ(rs.getInt("z"));
spawnDat.setXYZ(rs.getInt("x"), rs.getInt("y"), rs.getInt("z"));
spawnDat.setHeading(rs.getInt("heading"));
spawnDat.setRespawnDelay(60);
_siegeNpcs.add(spawnDat);
@@ -1201,9 +1197,7 @@ public final class Fort extends AbstractResidence
{
final L2Spawn spawnDat = new L2Spawn(rs.getInt("npcId"));
spawnDat.setAmount(1);
spawnDat.setX(rs.getInt("x"));
spawnDat.setY(rs.getInt("y"));
spawnDat.setZ(rs.getInt("z"));
spawnDat.setXYZ(rs.getInt("x"), rs.getInt("y"), rs.getInt("z"));
spawnDat.setHeading(rs.getInt("heading"));
spawnDat.setRespawnDelay(60);
_npcCommanders.add(spawnDat);
@@ -1235,9 +1229,7 @@ public final class Fort extends AbstractResidence
final int npcId = rs.getInt("npcId");
final L2Spawn spawnDat = new L2Spawn(npcId);
spawnDat.setAmount(1);
spawnDat.setX(rs.getInt("x"));
spawnDat.setY(rs.getInt("y"));
spawnDat.setZ(rs.getInt("z"));
spawnDat.setXYZ(rs.getInt("x"), rs.getInt("y"), rs.getInt("z"));
spawnDat.setHeading(rs.getInt("heading"));
spawnDat.setRespawnDelay(60);
_specialEnvoys.add(spawnDat);

View File

@@ -1107,9 +1107,7 @@ public class FortSiege implements Siegable
{
final L2Spawn spawnDat = new L2Spawn(_sp.getId());
spawnDat.setAmount(1);
spawnDat.setX(_sp.getLocation().getX());
spawnDat.setY(_sp.getLocation().getY());
spawnDat.setZ(_sp.getLocation().getZ());
spawnDat.setXYZ(_sp.getLocation());
spawnDat.setHeading(_sp.getLocation().getHeading());
spawnDat.setRespawnDelay(60);
spawnDat.doSpawn();
@@ -1159,9 +1157,7 @@ public class FortSiege implements Siegable
{
final L2Spawn spawn = new L2Spawn(rs.getInt("npcId"));
spawn.setAmount(1);
spawn.setX(rs.getInt("x"));
spawn.setY(rs.getInt("y"));
spawn.setZ(rs.getInt("z"));
spawn.setXYZ(rs.getInt("x"), rs.getInt("y"), rs.getInt("z"));
spawn.setHeading(rs.getInt("heading"));
spawn.setRespawnDelay(rs.getInt("respawnDelay"));
spawn.setLocationId(0);

View File

@@ -165,9 +165,7 @@ public class L2Event
try
{
final L2Spawn spawn = new L2Spawn(_npcId);
spawn.setX(target.getX() + 50);
spawn.setY(target.getY() + 50);
spawn.setZ(target.getZ());
spawn.setXYZ(target.getX() + 50, target.getY() + 50, target.getZ());
spawn.setAmount(1);
spawn.setHeading(target.getHeading());
spawn.stopRespawn();
@@ -284,7 +282,6 @@ public class L2Event
player.setCurrentCp(player.getMaxCp());
}
player.getPoly().setPolyInfo(null, "1");
player.decayMe();
player.spawnMe(player.getX(), player.getY(), player.getZ());
player.broadcastUserInfo();

View File

@@ -2239,9 +2239,7 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
spawn.setInstanceId(instance);
spawn.setHeading(heading);
spawn.setX(x);
spawn.setY(y);
spawn.setZ(z);
spawn.setXYZ(x, y, z);
spawn.stopRespawn();
final L2Npc npc = spawn.doSpawn(isSummonSpawn);

View File

@@ -24,24 +24,6 @@ import com.l2jmobius.gameserver.model.Location;
*/
public interface IPositionable extends ILocational
{
/**
* Sets the X coordinate of this object.
* @param x the new X coordinate
*/
void setX(int x);
/**
* Sets the Y coordinate of this object.
* @param y the new Y coordinate
*/
void setY(int y);
/**
* Sets the Z coordinate of this object.
* @param z the new Z coordinate
*/
void setZ(int z);
/**
* Sets all three coordinates of this object.
* @param x the new X coordinate

View File

@@ -22,7 +22,6 @@ import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.serverpackets.SpawnItem;
import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
public class RequestRecordInfo implements IClientIncomingPacket
@@ -46,27 +45,20 @@ public class RequestRecordInfo implements IClientIncomingPacket
L2World.getInstance().forEachVisibleObject(activeChar, L2Object.class, object ->
{
if (object.getPoly().isMorphed() && object.getPoly().getPolyType().equals("item"))
if (object.isVisibleFor(activeChar))
{
client.sendPacket(new SpawnItem(object));
}
else
{
if (object.isVisibleFor(activeChar))
object.sendInfo(activeChar);
if (object.isCharacter())
{
object.sendInfo(activeChar);
if (object.isCharacter())
// Update the state of the L2Character object client
// side by sending Server->Client packet
// MoveToPawn/CharMoveToLocation and AutoAttackStart to
// the L2PcInstance
final L2Character obj = (L2Character) object;
if (obj.getAI() != null)
{
// Update the state of the L2Character object client
// side by sending Server->Client packet
// MoveToPawn/CharMoveToLocation and AutoAttackStart to
// the L2PcInstance
final L2Character obj = (L2Character) object;
if (obj.getAI() != null)
{
obj.getAI().describeStateToPlayer(activeChar);
}
obj.getAI().describeStateToPlayer(activeChar);
}
}
}

View File

@@ -34,13 +34,6 @@ public class DropItem implements IClientOutgoingPacket
{
_item = item;
_charObjId = playerObjId;
// Future test.
if ((_item.getX() == 0) && (_item.getY() == 0))
{
LOGGER.warning("DropItem with x=0 and y=0.");
Thread.dumpStack(); // Why? Also check SpawnItem, just in case.
}
}
@Override

View File

@@ -17,45 +17,16 @@
package com.l2jmobius.gameserver.network.serverpackets;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.OutgoingPackets;
public final class SpawnItem implements IClientOutgoingPacket
{
private final int _objectId;
private int _itemId;
private final int _x, _y, _z;
private int _stackable;
private long _count;
private final L2ItemInstance _item;
public SpawnItem(L2Object obj)
public SpawnItem(L2ItemInstance item)
{
_objectId = obj.getObjectId();
_x = obj.getX();
_y = obj.getY();
_z = obj.getZ();
// Future test.
if ((_x == 0) && (_y == 0))
{
LOGGER.warning("SpawnItem with x=0 and y=0.");
Thread.dumpStack(); // Why? Also check DropItem, just in case.
}
if (obj.isItem())
{
final L2ItemInstance item = (L2ItemInstance) obj;
_itemId = item.getDisplayId();
_stackable = item.isStackable() ? 0x01 : 0x00;
_count = item.getCount();
}
else
{
_itemId = obj.getPoly().getPolyId();
_stackable = 0;
_count = 1;
}
_item = item;
}
@Override
@@ -63,15 +34,14 @@ public final class SpawnItem implements IClientOutgoingPacket
{
OutgoingPackets.SPAWN_ITEM.writeId(packet);
packet.writeD(_objectId);
packet.writeD(_itemId);
packet.writeD(_x);
packet.writeD(_y);
packet.writeD(_z);
packet.writeD(_item.getObjectId());
packet.writeD(_item.getDisplayId());
packet.writeD(_item.getX());
packet.writeD(_item.getY());
packet.writeD(_item.getZ());
// only show item count if it is a stackable item
packet.writeD(_stackable);
packet.writeQ(_count);
packet.writeD(_item.isStackable() ? 0x01 : 0x00);
packet.writeQ(_item.getCount());
packet.writeD(0x00); // c2
return true;
}