Merge branch 'master' into future
This commit is contained in:
commit
3312c00ee8
7 files changed
+40
-10
No files matched your search
@@ -605,7 +605,7 @@ Throws `unknown_dimension` if provided dimension can't be found.
|
|||||||
|
|
||||||
### `view_distance()`
|
### `view_distance()`
|
||||||
|
|
||||||
_**Deprecated**. Use `system_info('server_view_distance')` instead._
|
_**Deprecated**. Use `system_info('game_view_distance')` instead._
|
||||||
|
|
||||||
Returns the view distance of the server.
|
Returns the view distance of the server.
|
||||||
|
|
||||||
|
|||||||
@@ -202,11 +202,13 @@ List of entities riding the entity.
|
|||||||
|
|
||||||
Entity that `e` rides.
|
Entity that `e` rides.
|
||||||
|
|
||||||
### `query(e, 'scoreboard_tags')`, `query(e, 'tags')`(deprecated)
|
### `query(e, 'scoreboard_tags')` and
|
||||||
|
### `query(e, 'tags')`(deprecated)
|
||||||
|
|
||||||
List of entity's scoreboard tags.
|
List of entity's scoreboard tags.
|
||||||
|
|
||||||
### `query(e, 'has_scoreboard_tag',tag)`, `query(e, 'has_tag',tag)`(deprecated)
|
### `query(e, 'has_scoreboard_tag',tag)` and
|
||||||
|
### `query(e, 'has_tag',tag)`(deprecated)
|
||||||
|
|
||||||
Boolean, true if the entity is marked with a `tag` scoreboad tag.
|
Boolean, true if the entity is marked with a `tag` scoreboad tag.
|
||||||
|
|
||||||
|
|||||||
@@ -31,17 +31,23 @@ public abstract class LivingEntity_maxCollisionsMixin extends Entity
|
|||||||
@Inject(method = "tickCramming", cancellable = true, at = @At("HEAD"))
|
@Inject(method = "tickCramming", cancellable = true, at = @At("HEAD"))
|
||||||
private void tickPushingReplacement(CallbackInfo ci) {
|
private void tickPushingReplacement(CallbackInfo ci) {
|
||||||
List<Entity> entities;
|
List<Entity> entities;
|
||||||
|
int maxEntityCramming =-1;
|
||||||
if (CarpetSettings.maxEntityCollisions > 0)
|
if (CarpetSettings.maxEntityCollisions > 0)
|
||||||
|
{
|
||||||
|
maxEntityCramming = this.world.getGameRules().getInt(GameRules.MAX_ENTITY_CRAMMING);
|
||||||
entities = ((WorldInterface) this.world).getOtherEntitiesLimited(
|
entities = ((WorldInterface) this.world).getOtherEntitiesLimited(
|
||||||
this,
|
this,
|
||||||
this.getBoundingBox(),
|
this.getBoundingBox(),
|
||||||
EntityPredicates.canBePushedBy(this),
|
EntityPredicates.canBePushedBy(this),
|
||||||
CarpetSettings.maxEntityCollisions);
|
Math.max(CarpetSettings.maxEntityCollisions, maxEntityCramming));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
entities = this.world.getOtherEntities(this, this.getBoundingBox(), EntityPredicates.canBePushedBy(this));
|
entities = this.world.getOtherEntities(this, this.getBoundingBox(), EntityPredicates.canBePushedBy(this));
|
||||||
|
}
|
||||||
|
|
||||||
if (!entities.isEmpty()) {
|
if (!entities.isEmpty()) {
|
||||||
int maxEntityCramming = this.world.getGameRules().getInt(GameRules.MAX_ENTITY_CRAMMING);
|
if (maxEntityCramming < 0) maxEntityCramming = this.world.getGameRules().getInt(GameRules.MAX_ENTITY_CRAMMING);
|
||||||
if (maxEntityCramming > 0 && entities.size() > maxEntityCramming - 1 && this.random.nextInt(4) == 0) {
|
if (maxEntityCramming > 0 && entities.size() > maxEntityCramming - 1 && this.random.nextInt(4) == 0) {
|
||||||
int candidates = 0;
|
int candidates = 0;
|
||||||
|
|
||||||
@@ -55,9 +61,19 @@ public abstract class LivingEntity_maxCollisionsMixin extends Entity
|
|||||||
this.damage(DamageSource.CRAMMING, 6.0F);
|
this.damage(DamageSource.CRAMMING, 6.0F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (CarpetSettings.maxEntityCollisions > 0 && entities.size() > CarpetSettings.maxEntityCollisions)
|
||||||
for (Entity entity : entities) {
|
{
|
||||||
this.pushAway(entity);
|
for (Entity entity : entities.subList(0, CarpetSettings.maxEntityCollisions))
|
||||||
|
{
|
||||||
|
this.pushAway(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (Entity entity : entities)
|
||||||
|
{
|
||||||
|
this.pushAway(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import carpet.script.bundled.BundledModule;
|
|||||||
import carpet.CarpetServer;
|
import carpet.CarpetServer;
|
||||||
import carpet.script.bundled.FileModule;
|
import carpet.script.bundled.FileModule;
|
||||||
import carpet.script.bundled.Module;
|
import carpet.script.bundled.Module;
|
||||||
|
import carpet.script.exception.ExpressionException;
|
||||||
import carpet.script.language.Arithmetic;
|
import carpet.script.language.Arithmetic;
|
||||||
import carpet.script.language.ControlFlow;
|
import carpet.script.language.ControlFlow;
|
||||||
import carpet.script.language.DataStructures;
|
import carpet.script.language.DataStructures;
|
||||||
@@ -437,6 +438,7 @@ public class CarpetScriptServer
|
|||||||
|
|
||||||
public static void parseFunctionClasses()
|
public static void parseFunctionClasses()
|
||||||
{
|
{
|
||||||
|
ExpressionException.prepareForDoom(); // see fc-#1172
|
||||||
// Language
|
// Language
|
||||||
AnnotationParser.parseFunctionClass(Arithmetic.class);
|
AnnotationParser.parseFunctionClass(Arithmetic.class);
|
||||||
AnnotationParser.parseFunctionClass(ControlFlow.class);
|
AnnotationParser.parseFunctionClass(ControlFlow.class);
|
||||||
|
|||||||
@@ -683,6 +683,7 @@ public class Auxiliary {
|
|||||||
expression.addContextFunction("game_tick", -1, (c, t, lv) -> {
|
expression.addContextFunction("game_tick", -1, (c, t, lv) -> {
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
ServerCommandSource s = cc.s;
|
ServerCommandSource s = cc.s;
|
||||||
|
if (CarpetServer.scriptServer == null) return Value.NULL;
|
||||||
if (!s.getServer().isOnThread()) throw new InternalExpressionException("Unable to run ticks from threads");
|
if (!s.getServer().isOnThread()) throw new InternalExpressionException("Unable to run ticks from threads");
|
||||||
if (CarpetServer.scriptServer.tickDepth > 16) throw new InternalExpressionException("'game_tick' function caused other 'game_tick' functions to run. You should not allow that.");
|
if (CarpetServer.scriptServer.tickDepth > 16) throw new InternalExpressionException("'game_tick' function caused other 'game_tick' functions to run. You should not allow that.");
|
||||||
try
|
try
|
||||||
@@ -710,9 +711,10 @@ public class Auxiliary {
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
CarpetServer.scriptServer.tickDepth --;
|
if (CarpetServer.scriptServer != null)
|
||||||
|
CarpetServer.scriptServer.tickDepth --;
|
||||||
}
|
}
|
||||||
if(CarpetServer.scriptServer.stopAll)
|
if(CarpetServer.scriptServer != null && CarpetServer.scriptServer.stopAll)
|
||||||
throw new ExitStatement(Value.NULL);
|
throw new ExitStatement(Value.NULL);
|
||||||
return Value.TRUE;
|
return Value.TRUE;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import carpet.script.Expression;
|
|||||||
import carpet.script.Fluff;
|
import carpet.script.Fluff;
|
||||||
import carpet.script.Tokenizer;
|
import carpet.script.Tokenizer;
|
||||||
import carpet.script.value.FunctionValue;
|
import carpet.script.value.FunctionValue;
|
||||||
|
import carpet.utils.Messenger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -19,6 +20,9 @@ public class ExpressionException extends RuntimeException implements ResolvedExc
|
|||||||
public final List<FunctionValue> stack = new ArrayList<>();
|
public final List<FunctionValue> stack = new ArrayList<>();
|
||||||
private final Supplier<String> lazyMessage;
|
private final Supplier<String> lazyMessage;
|
||||||
private String cachedMessage = null;
|
private String cachedMessage = null;
|
||||||
|
public static void prepareForDoom(){
|
||||||
|
Messenger.c("foo bar");
|
||||||
|
}
|
||||||
|
|
||||||
public ExpressionException(Context c, Expression e, String message)
|
public ExpressionException(Context c, Expression e, String message)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ public class Arithmetic {
|
|||||||
}
|
}
|
||||||
return new NumericValue(factorial);
|
return new NumericValue(factorial);
|
||||||
}
|
}
|
||||||
|
else if (number > 170)
|
||||||
|
{
|
||||||
|
return NumericValue.of(Double.MAX_VALUE);
|
||||||
|
}
|
||||||
// values over 21 will exceed long limits
|
// values over 21 will exceed long limits
|
||||||
double factorial = 1.0;
|
double factorial = 1.0;
|
||||||
for (int i = 1; i <= number; i++)
|
for (int i = 1; i <= number; i++)
|
||||||
|
|||||||
Reference in new issue
Block a user