Server-side compatibility changes

This commit is contained in:
luisc committed 2021-10-19 02:49:46 -05:00
1 parent c8f917d8fb
commit f88cbb8b51
9 files changed
+230 -212

No files matched your search

@@ -98,35 +98,35 @@ public class ScriptEntity<T extends Entity> implements IEntity {
public double getX(){
return entity.posX;
}
/**
* @param x The entities x position
*/
public void setX(double x){
entity.posX = x;
}
/**
* @return The entities y position
*/
public double getY(){
return entity.posY;
}
/**
* @param y The entities y position
*/
public void setY(double y){
entity.posY = y;
}
/**
* @return The entities x position
*/
public double getZ(){
return entity.posZ;
}
/**
* @param z The entities x position
*/
@@ -154,7 +154,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
public int getBlockZ(){
return MathHelper.floor_double(entity.posZ);
}
/**
* @param x The x position
* @param y The y position
@@ -164,7 +164,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
entity.setPosition(x, y, z);
}
/**
* @param range The search range for entities around this entity
* @return Array of entities within range
@@ -178,7 +178,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
}
return list.toArray(new ScriptEntity[list.size()]);
}
/**
* @param range The search range for entities around this entity
* @param type The EntityType you want to find
@@ -196,7 +196,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
cls = EntityMob.class;
else if(type == EntityType.NPC)
cls = EntityNPCInterface.class;
List<Entity> entities = entity.worldObj.getEntitiesWithinAABB(cls, entity.boundingBox.expand(range, range, range));
List<ScriptEntity> list = new ArrayList<ScriptEntity>();
for(Entity living : entities){
@@ -204,16 +204,16 @@ public class ScriptEntity<T extends Entity> implements IEntity {
list.add(ScriptController.Instance.getScriptForEntity(living));
}
return list.toArray(new ScriptEntity[list.size()]);
}
}
/**
* @return Whether the entity is alive or not
*/
public boolean isAlive(){
return entity.isEntityAlive();
}
/**
* @param key Get temp data for this key
* @return Returns the stored temp data
@@ -221,7 +221,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
public Object getTempData(String key){
return tempData.get(key);
}
/**
* Tempdata gets cleared when the entity gets unloaded or the world restarts
* @param key The key for the data stored
@@ -230,7 +230,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
public void setTempData(String key, Object value){
tempData.put(key, value);
}
/**
* @param key The key thats going to be tested against the temp data
* @return Whether or not temp data containes the key
@@ -238,21 +238,21 @@ public class ScriptEntity<T extends Entity> implements IEntity {
public boolean hasTempData(String key){
return tempData.containsKey(key);
}
/**
* @param key The key for the temp data to be removed
*/
public void removeTempData(String key){
tempData.remove(key);
}
/**
* Remove all tempdata
*/
public void clearTempData(){
tempData.clear();
}
/**
* @param key The key of the data to be returned
* @return Returns the stored data
@@ -266,7 +266,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
return ((NBTPrimitive)base).func_150286_g();
return ((NBTTagString)base).func_150285_a_();
}
/**
* Stored data persists through world restart. Unlike tempdata only Strings and Numbers can be saved
* @param key The key for the data stored
@@ -281,7 +281,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
compound.setString(key, (String)value);
saveStoredCompound(compound);
}
/**
* @param key The key of the data to be checked
* @return Returns whether or not the stored data contains the key
@@ -289,7 +289,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
public boolean hasStoredData(String key){
return getStoredCompound().hasKey(key);
}
/**
* @param key The key of the data to be removed
*/
@@ -298,74 +298,74 @@ public class ScriptEntity<T extends Entity> implements IEntity {
compound.removeTag(key);
saveStoredCompound(compound);
}
/**
* Remove all stored data
*/
public void clearStoredData(){
entity.getEntityData().removeTag("CNPCStoredData");
}
private NBTTagCompound getStoredCompound(){
NBTTagCompound compound = entity.getEntityData().getCompoundTag("CNPCStoredData");
if(compound == null)
entity.getEntityData().setTag("CNPCStoredData", compound = new NBTTagCompound());
return compound;
}
private void saveStoredCompound(NBTTagCompound compound){
entity.getEntityData().setTag("CNPCStoredData", compound);
}
/**
* @return The age of this entity in ticks
*/
public long getAge(){
return entity.ticksExisted;
}
/**
* Despawns this entity. Removes it permanently
*/
public void despawn(){
entity.isDead = true;
}
/**
* @return Return whether or not this entity is standing in water
*/
public boolean inWater(){
return entity.isInsideOfMaterial(Material.water);
}
/**
* @return Return whether or not this entity is standing in lava
*/
public boolean inLava(){
return entity.isInsideOfMaterial(Material.lava);
}
/**
* @return Return whether or not this entity is standing in fire
*/
public boolean inFire(){
return entity.isInsideOfMaterial(Material.fire);
}
/**
* @return Return whether or not this entity is on fire
*/
public boolean isBurning(){
return entity.isBurning();
}
/**
* @param ticks Amount of world ticks this entity will burn. 20 ticks equals 1 second
*/
public void setBurning(int ticks){
entity.setFire(ticks);
}
/**
* Removes fire from this entity
*/
@@ -379,7 +379,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
public String getTypeName(){
return EntityList.getEntityString(entity);
}
/**
* @param item Item to be dropped
*/
@@ -393,7 +393,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
public ScriptEntity getRider(){
return ScriptController.Instance.getScriptForEntity(entity.riddenByEntity);
}
/**
* @param entity The entity to ride this entity
*/
@@ -411,7 +411,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
public ScriptEntity getMount(){
return ScriptController.Instance.getScriptForEntity(entity.ridingEntity);
}
/**
* @param entity The entity this entity will mount
*/
@@ -429,7 +429,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
public int getType(){
return EntityType.UNKNOWN;
}
/**
* @since 1.7.10c
* @param type @EntityType to check
@@ -438,33 +438,39 @@ public class ScriptEntity<T extends Entity> implements IEntity {
public boolean typeOf(int type){
return type == EntityType.UNKNOWN;
}
/**
* @param rotation The rotation to be set (0-360)
*/
public void setRotation(float rotation){
entity.rotationYaw = rotation;
}
/**
* @return Current rotation of the npc
*/
public float getRotation(){
return entity.rotationYaw;
}
/**
* @param power How strong the knockback is
* @param direction The direction in which he flies back (0-360). Usually based on getRotation()
*/
public void knockback(int power, float direction){
float v = direction * (float)Math.PI / 180.0F;
entity.addVelocity(-MathHelper.sin(v) * (float)power, 0.1D + power * 0.04f, MathHelper.cos(v) * (float)power);
entity.motionX *= 0.6D;
entity.motionZ *= 0.6D;
entity.attackEntityFrom(DamageSource.outOfWorld, 0.0001F);
entity.addVelocity(-MathHelper.sin(v) * (float)power, 0.1D + power * 0.04f, MathHelper.cos(v) * (float)power);
entity.motionX *= 0.6D;
entity.motionZ *= 0.6D;
entity.attackEntityFrom(DamageSource.outOfWorld, 0.0001F);
}
public void knockback(int xpower, int ypower, int zpower, float direction){
float v = direction * (float)Math.PI / 180.0F;
entity.addVelocity(-MathHelper.sin(v) * (float)xpower, 0.1D + ypower * 0.04f, MathHelper.cos(v) * (float)zpower);
entity.attackEntityFrom(DamageSource.outOfWorld, 0.0001F);
}
/**
* @since 1.7.10c
* @return Returns whether or not this entity is sneaking
@@ -472,7 +478,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
public boolean isSneaking(){
return entity.isSneaking();
}
/**
* @since 1.7.10c
* @return Returns whether or not this entity is sprinting
@@ -480,7 +486,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
public boolean isSprinting(){
return entity.isSprinting();
}
/**
* @since 1.7.10c
* Expert users only
@@ -506,4 +512,4 @@ public class ScriptEntity<T extends Entity> implements IEntity {
ServerCloneController.Instance.addClone(compound, name, tab);
}
}
}
}