hold your horses
This commit is contained in:
1 parent
a6f39e2d22
commit
d072ec90c3
1 file changed
+19
-14
@@ -1,5 +1,6 @@
|
|||||||
package carpet.script.value;
|
package carpet.script.value;
|
||||||
|
|
||||||
|
import carpet.CarpetServer;
|
||||||
import carpet.fakes.BrainInterface;
|
import carpet.fakes.BrainInterface;
|
||||||
import carpet.fakes.EntityInterface;
|
import carpet.fakes.EntityInterface;
|
||||||
import carpet.fakes.ItemEntityInterface;
|
import carpet.fakes.ItemEntityInterface;
|
||||||
@@ -917,9 +918,11 @@ public class EntityValue extends Value
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateVelocity(Entity e)
|
private static void updateVelocity(Entity e, double scale)
|
||||||
{
|
{
|
||||||
e.velocityModified = true;
|
e.velocityModified = true;
|
||||||
|
if (Math.abs(scale) > 10000)
|
||||||
|
CarpetServer.LOG.warn("Moved entity "+e.getEntityName()+" "+e.getName()+" at " +e.getPos()+" extremly fast: "+e.getVelocity());
|
||||||
//((ServerWorld)e.getEntityWorld()).method_14178().sendToNearbyPlayers(e, new EntityVelocityUpdateS2CPacket(e));
|
//((ServerWorld)e.getEntityWorld()).method_14178().sendToNearbyPlayers(e, new EntityVelocityUpdateS2CPacket(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1051,30 +1054,32 @@ public class EntityValue extends Value
|
|||||||
throw new InternalExpressionException("Expected a list of 3 parameters as a second argument");
|
throw new InternalExpressionException("Expected a list of 3 parameters as a second argument");
|
||||||
}
|
}
|
||||||
List<Value> coords = ((ListValue) v).getItems();
|
List<Value> coords = ((ListValue) v).getItems();
|
||||||
e.setVelocity(
|
double dx = NumericValue.asNumber(coords.get(0)).getDouble();
|
||||||
NumericValue.asNumber(coords.get(0)).getDouble(),
|
double dy = NumericValue.asNumber(coords.get(0)).getDouble();
|
||||||
NumericValue.asNumber(coords.get(1)).getDouble(),
|
double dz = NumericValue.asNumber(coords.get(2)).getDouble();
|
||||||
NumericValue.asNumber(coords.get(2)).getDouble()
|
e.setVelocity(dx, dy, dz);
|
||||||
);
|
updateVelocity(e, MathHelper.absMax(MathHelper.absMax(dx, dy), dz));
|
||||||
updateVelocity(e);
|
|
||||||
});
|
});
|
||||||
put("motion_x", (e, v) ->
|
put("motion_x", (e, v) ->
|
||||||
{
|
{
|
||||||
Vec3d velocity = e.getVelocity();
|
Vec3d velocity = e.getVelocity();
|
||||||
e.setVelocity(NumericValue.asNumber(v).getDouble(), velocity.y, velocity.z);
|
double dv = NumericValue.asNumber(v).getDouble();
|
||||||
updateVelocity(e);
|
e.setVelocity(dv, velocity.y, velocity.z);
|
||||||
|
updateVelocity(e, dv);
|
||||||
});
|
});
|
||||||
put("motion_y", (e, v) ->
|
put("motion_y", (e, v) ->
|
||||||
{
|
{
|
||||||
Vec3d velocity = e.getVelocity();
|
Vec3d velocity = e.getVelocity();
|
||||||
e.setVelocity(velocity.x, NumericValue.asNumber(v).getDouble(), velocity.z);
|
double dv = NumericValue.asNumber(v).getDouble();
|
||||||
updateVelocity(e);
|
e.setVelocity(velocity.x, dv, velocity.z);
|
||||||
|
updateVelocity(e, dv);
|
||||||
});
|
});
|
||||||
put("motion_z", (e, v) ->
|
put("motion_z", (e, v) ->
|
||||||
{
|
{
|
||||||
Vec3d velocity = e.getVelocity();
|
Vec3d velocity = e.getVelocity();
|
||||||
e.setVelocity(velocity.x, velocity.y, NumericValue.asNumber(v).getDouble());
|
double dv = NumericValue.asNumber(v).getDouble();
|
||||||
updateVelocity(e);
|
e.setVelocity(velocity.x, velocity.y, dv);
|
||||||
|
updateVelocity(e, dv);
|
||||||
});
|
});
|
||||||
|
|
||||||
put("accelerate", (e, v) ->
|
put("accelerate", (e, v) ->
|
||||||
@@ -1089,7 +1094,7 @@ public class EntityValue extends Value
|
|||||||
NumericValue.asNumber(coords.get(1)).getDouble(),
|
NumericValue.asNumber(coords.get(1)).getDouble(),
|
||||||
NumericValue.asNumber(coords.get(2)).getDouble()
|
NumericValue.asNumber(coords.get(2)).getDouble()
|
||||||
);
|
);
|
||||||
updateVelocity(e);
|
updateVelocity(e, e.getVelocity().length());
|
||||||
|
|
||||||
});
|
});
|
||||||
put("custom_name", (e, v) -> {
|
put("custom_name", (e, v) -> {
|
||||||
|
|||||||
Reference in new issue
Block a user