Merge branch 'master' into 1.15
# Conflicts: # src/main/java/carpet/fakes/StructureFeatureInterface.java # src/main/java/carpet/mixins/PistonBlock_movableTEMixin.java
This commit is contained in:
commit
c995716357
41 files changed
+117
-132
No files matched your search
@@ -35,7 +35,7 @@ public class CarpetServer // static for now - easier to handle all around the co
|
||||
private static CommandDispatcher<ServerCommandSource> currentCommandDispatcher;
|
||||
public static CarpetScriptServer scriptServer;
|
||||
public static SettingsManager settingsManager;
|
||||
public static List<CarpetExtension> extensions = new ArrayList<>();
|
||||
public static final List<CarpetExtension> extensions = new ArrayList<>();
|
||||
|
||||
// Separate from onServerLoaded, because a server can be loaded multiple times in singleplayer
|
||||
public static void manageExtension(CarpetExtension extension)
|
||||
|
||||
@@ -29,6 +29,7 @@ import static carpet.settings.RuleCategory.SURVIVAL;
|
||||
import static carpet.settings.RuleCategory.TNT;
|
||||
import static carpet.settings.RuleCategory.DISPENSER;
|
||||
|
||||
@SuppressWarnings("CanBeFinal")
|
||||
public class CarpetSettings
|
||||
{
|
||||
public static final String carpetVersion = "1.3.3+v200105";
|
||||
|
||||
@@ -2,5 +2,5 @@ package carpet.fakes;
|
||||
|
||||
public interface MinecraftClientInferface
|
||||
{
|
||||
public float getPausedTickDelta();
|
||||
float getPausedTickDelta();
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import java.util.Map;
|
||||
|
||||
public interface MobEntityInterface
|
||||
{
|
||||
public GoalSelector getAI(boolean target);
|
||||
GoalSelector getAI(boolean target);
|
||||
|
||||
public Map<String, Goal> getTemporaryTasks();
|
||||
Map<String, Goal> getTemporaryTasks();
|
||||
}
|
||||
@@ -7,6 +7,6 @@ import net.minecraft.world.gen.chunk.ChunkGeneratorConfig;
|
||||
|
||||
public interface StructureFeatureInterface
|
||||
{
|
||||
public boolean plopAnywhere(ServerWorld world, BlockPos pos);
|
||||
public boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator<? extends ChunkGeneratorConfig> generator);
|
||||
boolean plopAnywhere(ServerWorld world, BlockPos pos);
|
||||
boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator<? extends ChunkGeneratorConfig> generator);
|
||||
}
|
||||
@@ -24,9 +24,9 @@ import java.util.TreeMap;
|
||||
|
||||
public class EntityPlayerActionPack
|
||||
{
|
||||
private ServerPlayerEntity player;
|
||||
private final ServerPlayerEntity player;
|
||||
|
||||
private Map<ActionType, Action> actions = new TreeMap<>();
|
||||
private final Map<ActionType, Action> actions = new TreeMap<>();
|
||||
|
||||
private BlockPos currentBlock;
|
||||
private int blockHitDelay;
|
||||
|
||||
@@ -123,7 +123,7 @@ public class FeatureGenerator
|
||||
}
|
||||
public static void noop() {System.out.println("boo");}
|
||||
|
||||
private static Map<String, Thing> featureMap = new HashMap<String, Thing>() {{
|
||||
private static final Map<String, Thing> featureMap = new HashMap<String, Thing>() {{
|
||||
|
||||
|
||||
put("oak", simpleTree(DefaultBiomeFeatures.OAK_TREE_CONFIG));
|
||||
|
||||
@@ -365,7 +365,7 @@ public class OptimizedExplosion
|
||||
|
||||
private static void getAffectedPositionsOnPlaneX(Explosion e, int x, int yStart, int yEnd, int zStart, int zEnd)
|
||||
{
|
||||
if (rayCalcDone == false)
|
||||
if (!rayCalcDone)
|
||||
{
|
||||
final double xRel = (double) x / 15.0D * 2.0D - 1.0D;
|
||||
|
||||
@@ -388,7 +388,7 @@ public class OptimizedExplosion
|
||||
|
||||
private static void getAffectedPositionsOnPlaneY(Explosion e, int y, int xStart, int xEnd, int zStart, int zEnd)
|
||||
{
|
||||
if (rayCalcDone == false)
|
||||
if (!rayCalcDone)
|
||||
{
|
||||
final double yRel = (double) y / 15.0D * 2.0D - 1.0D;
|
||||
|
||||
@@ -411,7 +411,7 @@ public class OptimizedExplosion
|
||||
|
||||
private static void getAffectedPositionsOnPlaneZ(Explosion e, int z, int xStart, int xEnd, int yStart, int yEnd)
|
||||
{
|
||||
if (rayCalcDone == false)
|
||||
if (!rayCalcDone)
|
||||
{
|
||||
final double zRel = (double) z / 15.0D * 2.0D - 1.0D;
|
||||
|
||||
|
||||
@@ -8,12 +8,8 @@ public class PortalHelper
|
||||
{
|
||||
public static boolean player_holds_obsidian(PlayerEntity playerIn)
|
||||
{
|
||||
if ( (!playerIn.getMainHandStack().isEmpty()
|
||||
return (!playerIn.getMainHandStack().isEmpty()
|
||||
&& playerIn.getMainHandStack().getItem() instanceof BlockItem &&
|
||||
((BlockItem)(playerIn.getMainHandStack().getItem())).getBlock() == Blocks.OBSIDIAN ))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
((BlockItem) (playerIn.getMainHandStack().getItem())).getBlock() == Blocks.OBSIDIAN);
|
||||
}
|
||||
}
|
||||
@@ -193,7 +193,7 @@ public class RedstoneWireTurbo
|
||||
private static final int West = 3;
|
||||
|
||||
// Names for debug print statements
|
||||
private static final char dirname[] = {'N', 'E', 'S', 'W'};
|
||||
private static final char[] dirname = {'N', 'E', 'S', 'W'};
|
||||
|
||||
/*
|
||||
* These lookup tables completely remap neighbor positions into a left-to-right
|
||||
@@ -269,7 +269,7 @@ public class RedstoneWireTurbo
|
||||
* neighbors that will receive updates.
|
||||
*/
|
||||
private static class UpdateNode {
|
||||
public static enum Type {
|
||||
public enum Type {
|
||||
UNKNOWN, REDSTONE, OTHER
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public abstract class DesertPyramidFeatureMixin extends AbstractTempleFeature<De
|
||||
|
||||
static
|
||||
{
|
||||
MONSTER_SPAWNS = Lists.newArrayList(new Biome.SpawnEntry[]{new Biome.SpawnEntry(EntityType.HUSK, 1, 1, 1)});
|
||||
MONSTER_SPAWNS = Lists.newArrayList(new Biome.SpawnEntry(EntityType.HUSK, 1, 1, 1));
|
||||
}
|
||||
|
||||
public DesertPyramidFeatureMixin(Function<Dynamic<?>, ? extends DefaultFeatureConfig> function_1)
|
||||
|
||||
@@ -14,7 +14,7 @@ public abstract class Entity_scarpetEventsMixin implements EntityInterface
|
||||
{
|
||||
@Shadow public boolean removed;
|
||||
|
||||
private EntityEventsGroup events = new EntityEventsGroup();
|
||||
private final EntityEventsGroup events = new EntityEventsGroup();
|
||||
|
||||
@Override
|
||||
public EntityEventsGroup getEventContainer()
|
||||
|
||||
@@ -66,13 +66,13 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
|
||||
target = "Ljava/util/List;size()I", ordinal = 4),locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void onMove(World world_1, BlockPos blockPos_1, Direction direction_1, boolean boolean_1,
|
||||
CallbackInfoReturnable<Boolean> cir, BlockPos blockPos_2, PistonHandler pistonHandler_1, Map map_1,
|
||||
List<BlockPos> list_1, List<BlockState> list_2, List list_3, int int_2, BlockState blockStates_1[],
|
||||
List<BlockPos> list_1, List<BlockState> list_2, List list_3, int int_2, BlockState[] blockStates_1,
|
||||
Direction direction_2)
|
||||
{
|
||||
//Get the blockEntities and remove them from the world before any magic starts to happen
|
||||
if (CarpetSettings.movableBlockEntities)
|
||||
{
|
||||
list1_BlockEntities.set(Lists.<BlockEntity>newArrayList());
|
||||
list1_BlockEntities.set(Lists.newArrayList());
|
||||
for (int i = 0; i < list_1.size(); ++i)
|
||||
{
|
||||
BlockPos blockpos = list_1.get(i);
|
||||
@@ -95,7 +95,7 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
|
||||
locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void setBlockEntityWithCarried(World world_1, BlockPos blockPos_1, Direction direction_1, boolean boolean_1,
|
||||
CallbackInfoReturnable<Boolean> cir, BlockPos blockPos_2, PistonHandler pistonHandler_1, Map map_1, List list_1,
|
||||
List list_2, List list_3, int int_2, BlockState blockStates_1[], Direction direction_2,
|
||||
List list_2, List list_3, int int_2, BlockState[] blockStates_1, Direction direction_2,
|
||||
int int_3, BlockPos blockPos_4, BlockState blockState_1)
|
||||
{
|
||||
BlockEntity blockEntityPiston = PistonExtensionBlock.createBlockEntityPiston((BlockState) list_2.get(int_3),
|
||||
|
||||
@@ -72,7 +72,7 @@ public abstract class PlayerManagerMixin
|
||||
serverPlayerEntity_3.kill();
|
||||
continue;
|
||||
}
|
||||
serverPlayerEntity_3.networkHandler.disconnect(new TranslatableText("multiplayer.disconnect.duplicate_login", new Object[0]));
|
||||
serverPlayerEntity_3.networkHandler.disconnect(new TranslatableText("multiplayer.disconnect.duplicate_login"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,10 +36,10 @@ public abstract class RedstoneWireBlockMixin implements RedstoneWireBlockInterfa
|
||||
private Set<BlockPos> affectedNeighbors;
|
||||
|
||||
@Shadow
|
||||
private int increasePower(int int_1, BlockState blockState_1) { return 0; };
|
||||
private int increasePower(int int_1, BlockState blockState_1) { return 0; }
|
||||
|
||||
@Shadow
|
||||
private BlockState update(World world_1, BlockPos blockPos_1, BlockState blockState_1) { return null; };
|
||||
private BlockState update(World world_1, BlockPos blockPos_1, BlockState blockState_1) { return null; }
|
||||
|
||||
// =
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@ public abstract class ServerChunkManagerMixin
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnresolvedMixinReference")
|
||||
@Redirect(method = "method_20801", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/SpawnHelper;spawnEntitiesInChunk(Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/util/math/BlockPos;)V"
|
||||
@@ -87,6 +88,7 @@ public abstract class ServerChunkManagerMixin
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnresolvedMixinReference")
|
||||
@Redirect(method = "method_20801", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/EntityCategory;getSpawnCap()I"
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ServerPlayerInteractionManager_cactusMixin
|
||||
))
|
||||
private ActionResult activateWithOptionalCactus(BlockState blockState, World world_1, PlayerEntity playerEntity_1, Hand hand_1, BlockHitResult blockHitResult_1)
|
||||
{
|
||||
Boolean flipped = BlockRotator.flipBlockWithCactus(blockState, world_1, playerEntity_1, hand_1, blockHitResult_1);
|
||||
boolean flipped = BlockRotator.flipBlockWithCactus(blockState, world_1, playerEntity_1, hand_1, blockHitResult_1);
|
||||
if (flipped)
|
||||
return ActionResult.SUCCESS;
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@Mixin(ServerWorld.class)
|
||||
public abstract class ServerWorld_fakePlayersMixin
|
||||
{
|
||||
@Shadow private boolean ticking;
|
||||
@Shadow
|
||||
boolean ticking;
|
||||
|
||||
@Shadow /*@Nonnull*/ public abstract MinecraftServer getServer();
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class SummonCommandMixin
|
||||
world.spawnEntity(skeletonHorseEntity_1);
|
||||
}
|
||||
world.addLightning(lightningEntity_1);
|
||||
source.sendFeedback(new TranslatableText("commands.summon.success", new Object[]{lightningEntity_1.getDisplayName()}), true);
|
||||
source.sendFeedback(new TranslatableText("commands.summon.success", lightningEntity_1.getDisplayName()), true);
|
||||
cir.setReturnValue(1);
|
||||
cir.cancel();
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public abstract class World_movableTEMixin implements WorldInterface
|
||||
private Profiler profiler;
|
||||
|
||||
@Shadow
|
||||
protected abstract WorldChunk getWorldChunk(BlockPos blockPos_1);
|
||||
public abstract WorldChunk getWorldChunk(BlockPos blockPos_1);
|
||||
|
||||
@Shadow
|
||||
public abstract BlockState getBlockState(BlockPos blockPos_1);
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.minecraft.world.dimension.DimensionType;
|
||||
import carpet.fakes.ServerPlayerEntityInterface;
|
||||
import carpet.utils.Messenger;
|
||||
|
||||
@SuppressWarnings("EntityConstructor")
|
||||
public class EntityPlayerMPFake extends ServerPlayerEntity
|
||||
{
|
||||
public Runnable fixStartingPosition = () -> {};
|
||||
@@ -93,6 +94,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity
|
||||
super(server, worldIn, profile, interactionManagerIn);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void kill()
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
public class CarpetContext extends Context
|
||||
{
|
||||
public ServerCommandSource s;
|
||||
public BlockPos origin;
|
||||
public final BlockPos origin;
|
||||
public CarpetContext(ScriptHost host, ServerCommandSource source, BlockPos origin)
|
||||
{
|
||||
super(host);
|
||||
|
||||
@@ -43,12 +43,12 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class CarpetEventServer
|
||||
{
|
||||
public List<ScheduledCall> scheduledCalls = new LinkedList<>();
|
||||
public final List<ScheduledCall> scheduledCalls = new LinkedList<>();
|
||||
|
||||
public static class Callback
|
||||
{
|
||||
public String host;
|
||||
public FunctionValue function;
|
||||
public final String host;
|
||||
public final FunctionValue function;
|
||||
|
||||
public Callback(String host, FunctionValue function)
|
||||
{
|
||||
@@ -65,8 +65,8 @@ public class CarpetEventServer
|
||||
|
||||
public static class ScheduledCall extends Callback
|
||||
{
|
||||
public List<Value> args;
|
||||
private CarpetContext ctx;
|
||||
public final List<Value> args;
|
||||
private final CarpetContext ctx;
|
||||
public long dueTime;
|
||||
|
||||
public ScheduledCall(CarpetContext context, FunctionValue function, List<Value> args, long dueTime)
|
||||
@@ -103,8 +103,8 @@ public class CarpetEventServer
|
||||
public static class CallbackList
|
||||
{
|
||||
|
||||
public List<Callback> callList;
|
||||
public int reqArgs;
|
||||
public final List<Callback> callList;
|
||||
public final int reqArgs;
|
||||
|
||||
public CallbackList(int reqArgs)
|
||||
{
|
||||
@@ -454,7 +454,7 @@ public class CarpetEventServer
|
||||
{
|
||||
return stat.getType().getRegistry().getId(stat.getValue());
|
||||
}
|
||||
private Set<Identifier> skippedStats = new HashSet<Identifier>(){{
|
||||
private final Set<Identifier> skippedStats = new HashSet<Identifier>(){{
|
||||
add(Stats.TIME_SINCE_DEATH);
|
||||
add(Stats.TIME_SINCE_REST);
|
||||
add(Stats.PLAY_ONE_MINUTE);
|
||||
@@ -476,14 +476,14 @@ public class CarpetEventServer
|
||||
|
||||
// on projectile thrown (arrow from bows, crossbows, tridents, snoballs, e-pearls
|
||||
|
||||
public String name;
|
||||
public static Map<String, Event> byName = new HashMap<String, Event>(){{
|
||||
public final String name;
|
||||
public static final Map<String, Event> byName = new HashMap<String, Event>(){{
|
||||
for (Event e: Event.values())
|
||||
{
|
||||
put(e.name, e);
|
||||
}
|
||||
}};
|
||||
public CallbackList handler;
|
||||
public final CallbackList handler;
|
||||
Event(String name, CallbackList eventHandler)
|
||||
{
|
||||
this.name = name;
|
||||
|
||||
@@ -134,9 +134,9 @@ import static java.lang.Math.sqrt;
|
||||
public class CarpetExpression
|
||||
{
|
||||
|
||||
private ServerCommandSource source;
|
||||
private BlockPos origin;
|
||||
private Expression expr;
|
||||
private final ServerCommandSource source;
|
||||
private final BlockPos origin;
|
||||
private final Expression expr;
|
||||
Expression getExpr() {return expr;}
|
||||
private static long tickStart = 0L;
|
||||
|
||||
@@ -275,7 +275,7 @@ public class CarpetExpression
|
||||
return bs;
|
||||
}
|
||||
|
||||
private static Map<String, ParticleEffect> particleCache = new HashMap<>();
|
||||
private static final Map<String, ParticleEffect> particleCache = new HashMap<>();
|
||||
private ParticleEffect getParticleData(String name)
|
||||
{
|
||||
ParticleEffect particle = particleCache.get(name);
|
||||
@@ -2147,7 +2147,7 @@ public class CarpetExpression
|
||||
args = Collections.singletonList(lv.get(3).evalValue(c));
|
||||
else if (lv.size()>4)
|
||||
{
|
||||
args = new ArrayList<>(lv.subList(3, lv.size()).stream().map((vv) -> vv.evalValue(c)).collect(Collectors.toList()));
|
||||
args = lv.subList(3, lv.size()).stream().map((vv) -> vv.evalValue(c)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
((EntityValue) v).setEvent((CarpetContext)c, what, function, args);
|
||||
@@ -2379,12 +2379,12 @@ public class CarpetExpression
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
return (c_, t_) -> new LazyListValue()
|
||||
{
|
||||
int minx = cx-sminx;
|
||||
int miny = cy-sminy;
|
||||
int minz = cz-sminz;
|
||||
int maxx = cx+smaxx;
|
||||
int maxy = cy+smaxy;
|
||||
int maxz = cz+smaxz;
|
||||
final int minx = cx-sminx;
|
||||
final int miny = cy-sminy;
|
||||
final int minz = cz-sminz;
|
||||
final int maxx = cx+smaxx;
|
||||
final int maxy = cy+smaxy;
|
||||
final int maxz = cz+smaxz;
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
@@ -3190,7 +3190,7 @@ public class CarpetExpression
|
||||
this.expr.addLazyFunction("schedule", -1, (c, t, lv) -> {
|
||||
if (lv.size()<2)
|
||||
throw new InternalExpressionException("'schedule' should have at least 2 arguments, delay and call name");
|
||||
Long delay = NumericValue.asNumber(lv.get(0).evalValue(c)).getLong();
|
||||
long delay = NumericValue.asNumber(lv.get(0).evalValue(c)).getLong();
|
||||
|
||||
Value functionValue = lv.get(1).evalValue(c);
|
||||
if (!(functionValue instanceof FunctionValue))
|
||||
|
||||
@@ -31,7 +31,7 @@ import static java.lang.Math.max;
|
||||
|
||||
public class CarpetScriptHost extends ScriptHost
|
||||
{
|
||||
private CarpetScriptServer scriptServer;
|
||||
private final CarpetScriptServer scriptServer;
|
||||
|
||||
private Tag globalState;
|
||||
private int saveTimeout;
|
||||
|
||||
@@ -33,14 +33,14 @@ import static net.minecraft.server.command.CommandManager.literal;
|
||||
public class CarpetScriptServer
|
||||
{
|
||||
//make static for now, but will change that later:
|
||||
public CarpetScriptHost globalHost;
|
||||
public Map<String, CarpetScriptHost> modules;
|
||||
public final CarpetScriptHost globalHost;
|
||||
public final Map<String, CarpetScriptHost> modules;
|
||||
public long tickStart;
|
||||
public boolean stopAll;
|
||||
private Set<String> holyMoly;
|
||||
public CarpetEventServer events;
|
||||
private final Set<String> holyMoly;
|
||||
public final CarpetEventServer events;
|
||||
|
||||
private static List<ModuleInterface> bundledModuleData = new ArrayList<ModuleInterface>(){{
|
||||
private static final List<ModuleInterface> bundledModuleData = new ArrayList<ModuleInterface>(){{
|
||||
add(new BundledModule("camera"));
|
||||
add(new BundledModule("event_test"));
|
||||
add(new BundledModule("stats_test"));
|
||||
|
||||
@@ -17,9 +17,9 @@ public class Context
|
||||
public static final int LOCALIZATION = 8;
|
||||
public static final int LVALUE = 9;
|
||||
|
||||
public Map<String, LazyValue> variables = new HashMap<>();
|
||||
public final Map<String, LazyValue> variables = new HashMap<>();
|
||||
|
||||
public ScriptHost host;
|
||||
public final ScriptHost host;
|
||||
|
||||
Context(ScriptHost host)
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class EntityEventsGroup
|
||||
{
|
||||
private Map<EntityEventType, Map<String, CarpetEventServer.ScheduledCall>> actions;
|
||||
private final Map<EntityEventType, Map<String, CarpetEventServer.ScheduledCall>> actions;
|
||||
public EntityEventsGroup()
|
||||
{
|
||||
actions = new EnumMap<>(EntityEventType.class);
|
||||
@@ -96,10 +96,10 @@ public class EntityEventsGroup
|
||||
}
|
||||
};
|
||||
|
||||
public static Map<String, EntityEventType> byName = Arrays.stream(EntityEventType.values()).collect(Collectors.toMap(ev -> ev.id, ev -> ev));
|
||||
public static final Map<String, EntityEventType> byName = Arrays.stream(EntityEventType.values()).collect(Collectors.toMap(ev -> ev.id, ev -> ev));
|
||||
|
||||
public int argcount;
|
||||
public String id;
|
||||
public final int argcount;
|
||||
public final String id;
|
||||
EntityEventType(String identifier, int args)
|
||||
{
|
||||
id = identifier;
|
||||
@@ -121,6 +121,6 @@ public class EntityEventsGroup
|
||||
protected List<Value> makeArgs(Entity entity, Object ... args)
|
||||
{
|
||||
return Collections.singletonList(new EntityValue(entity));
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -357,7 +357,7 @@ public class Expression implements Cloneable
|
||||
"2.71828182845904523536028747135266249775724709369995957496696762772407663");
|
||||
|
||||
// %[argument_index$][flags][width][.precision][t]conversion
|
||||
private static Pattern formatPattern = Pattern.compile("%(\\d+\\$)?([-#+ 0,(\\<]*)?(\\d+)?(\\.\\d+)?([tT])?([a-zA-Z%])");
|
||||
private static final Pattern formatPattern = Pattern.compile("%(\\d+\\$)?([-#+ 0,(<]*)?(\\d+)?(\\.\\d+)?([tT])?([a-zA-Z%])");
|
||||
|
||||
/** The current infix expression */
|
||||
private String expression;
|
||||
@@ -387,10 +387,10 @@ public class Expression implements Cloneable
|
||||
private LazyValue ast = null;
|
||||
|
||||
/** script specific operatos and built-in functions */
|
||||
private Map<String, ILazyOperator> operators = new Object2ObjectOpenHashMap<>();
|
||||
private final Map<String, ILazyOperator> operators = new Object2ObjectOpenHashMap<>();
|
||||
boolean isAnOperator(String opname) { return operators.containsKey(opname) || operators.containsKey(opname+"u");}
|
||||
|
||||
private Map<String, ILazyFunction> functions = new Object2ObjectOpenHashMap<>();
|
||||
private final Map<String, ILazyFunction> functions = new Object2ObjectOpenHashMap<>();
|
||||
Set<String> getFunctionNames() {return functions.keySet();}
|
||||
|
||||
@Override
|
||||
@@ -2878,7 +2878,6 @@ public class Expression implements Cloneable
|
||||
else if (fmt == '%')
|
||||
{
|
||||
//skip /%%
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3128,7 +3127,7 @@ public class Expression implements Cloneable
|
||||
|
||||
}
|
||||
|
||||
static Expression none = new Expression("null");
|
||||
static final Expression none = new Expression("null");
|
||||
/**
|
||||
* @param expression .
|
||||
*/
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ExpressionInspector
|
||||
{
|
||||
Set<String> allFunctions = (new CarpetExpression("null", null, null)).getExpr().getFunctionNames();
|
||||
scarpetFunctions = new TreeSet<>(new Expression("null").getFunctionNames());
|
||||
APIFunctions = new TreeSet<>(allFunctions.stream().filter(s -> !scarpetFunctions.contains(s)).collect(Collectors.toSet()));
|
||||
APIFunctions = allFunctions.stream().filter(s -> !scarpetFunctions.contains(s)).collect(Collectors.toCollection(TreeSet::new));
|
||||
}
|
||||
|
||||
public static List<String> suggestFunctions(ScriptHost host, String previous, String prefix)
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.List;
|
||||
|
||||
public class CarpetExpressionException extends RuntimeException
|
||||
{
|
||||
public List<FunctionValue> stack;
|
||||
public final List<FunctionValue> stack;
|
||||
|
||||
public CarpetExpressionException(String message, List<FunctionValue> stack)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ import carpet.script.value.Value;
|
||||
/* Exception thrown to terminate execution mid expression (aka return statement) */
|
||||
public class ExitStatement extends RuntimeException
|
||||
{
|
||||
public Value retval;
|
||||
public final Value retval;
|
||||
public ExitStatement(Value value)
|
||||
{
|
||||
retval = value;
|
||||
|
||||
@@ -15,8 +15,8 @@ import static carpet.script.ExpressionInspector.Expression_getName;
|
||||
/* The expression evaluators exception class. */
|
||||
public class ExpressionException extends RuntimeException
|
||||
{
|
||||
public Context context;
|
||||
public List<FunctionValue> stack = new ArrayList<>();
|
||||
public final Context context;
|
||||
public final List<FunctionValue> stack = new ArrayList<>();
|
||||
public ExpressionException(Context c, String message)
|
||||
{
|
||||
super(makeMessage(c, null, null, message));
|
||||
@@ -35,7 +35,7 @@ public class ExpressionException extends RuntimeException
|
||||
context = c;
|
||||
}
|
||||
|
||||
private static Fluff.TriFunction<Expression, Tokenizer.Token, String, List<String>> errorMaker = (expr, token, errmessage) ->
|
||||
private static final Fluff.TriFunction<Expression, Tokenizer.Token, String, List<String>> errorMaker = (expr, token, errmessage) ->
|
||||
{
|
||||
|
||||
List<String> errMsg = new ArrayList<>();
|
||||
|
||||
@@ -36,8 +36,8 @@ public class BlockValue extends Value
|
||||
public static final BlockValue AIR = new BlockValue(Blocks.AIR.getDefaultState(), null, BlockPos.ORIGIN);
|
||||
public static final BlockValue NULL = new BlockValue(null, null, null);
|
||||
private BlockState blockState;
|
||||
private BlockPos pos;
|
||||
private ServerWorld world;
|
||||
private final BlockPos pos;
|
||||
private final ServerWorld world;
|
||||
private CompoundTag data;
|
||||
|
||||
public static BlockValue fromCoords(CarpetContext c, int x, int y, int z)
|
||||
@@ -46,7 +46,7 @@ public class BlockValue extends Value
|
||||
return new BlockValue(null, c.s.getWorld(), pos);
|
||||
}
|
||||
|
||||
private static Map<String, BlockValue> bvCache= new HashMap<>();
|
||||
private static final Map<String, BlockValue> bvCache= new HashMap<>();
|
||||
public static BlockValue fromString(String str)
|
||||
{
|
||||
try
|
||||
@@ -294,8 +294,8 @@ public class BlockValue extends Value
|
||||
|
||||
public static class LocatorResult
|
||||
{
|
||||
public BlockValue block;
|
||||
public int offset;
|
||||
public final BlockValue block;
|
||||
public final int offset;
|
||||
LocatorResult(BlockValue b, int o)
|
||||
{
|
||||
block = b;
|
||||
@@ -306,9 +306,9 @@ public class BlockValue extends Value
|
||||
public static class VectorLocator
|
||||
{
|
||||
public Vec3d vec;
|
||||
public int offset;
|
||||
public double yaw;
|
||||
public double pitch;
|
||||
public final int offset;
|
||||
public final double yaw;
|
||||
public final double pitch;
|
||||
public boolean fromBlock;
|
||||
VectorLocator(Vec3d v, int o)
|
||||
{
|
||||
@@ -358,9 +358,9 @@ public class BlockValue extends Value
|
||||
EASTUP("east-up", 0.0, 0.6, 0.5, Direction.EAST),
|
||||
WESTUP("west-up", 1.0, 0.6, 0.5, Direction.WEST);
|
||||
|
||||
public String name;
|
||||
public Vec3d hitOffset;
|
||||
public Direction facing;
|
||||
public final String name;
|
||||
public final Vec3d hitOffset;
|
||||
public final Direction facing;
|
||||
|
||||
private static final Map<String, SpecificDirection> DIRECTION_MAP = Arrays.stream(values()).collect(Collectors.toMap(SpecificDirection::getName, d -> d));
|
||||
|
||||
|
||||
@@ -62,14 +62,14 @@ import static carpet.script.value.NBTSerializableValue.nameFromRegistryId;
|
||||
// TODO: decide whether copy(entity) should duplicate entity in the world.
|
||||
public class EntityValue extends Value
|
||||
{
|
||||
private Entity entity;
|
||||
private final Entity entity;
|
||||
|
||||
public EntityValue(Entity e)
|
||||
{
|
||||
entity = e;
|
||||
}
|
||||
|
||||
private static Map<String, EntitySelector> selectorCache = new HashMap<>();
|
||||
private static final Map<String, EntitySelector> selectorCache = new HashMap<>();
|
||||
public static Collection<? extends Entity > getEntitiesFromSelector(ServerCommandSource source, String selector)
|
||||
{
|
||||
try
|
||||
@@ -177,7 +177,7 @@ public class EntityValue extends Value
|
||||
return res; //TODO add more here like search by tags, or type
|
||||
//if (who.startsWith('tag:'))
|
||||
}
|
||||
private static Map<String, Pair<EntityType<?>, Predicate<? super Entity>>> entityPredicates =
|
||||
private static final Map<String, Pair<EntityType<?>, Predicate<? super Entity>>> entityPredicates =
|
||||
new HashMap<String, Pair<EntityType<?>, Predicate<? super Entity>>>()
|
||||
{{
|
||||
put("*", Pair.of(null, EntityPredicates.VALID_ENTITY));
|
||||
@@ -192,7 +192,7 @@ public class EntityValue extends Value
|
||||
throw new InternalExpressionException("Unknown entity feature: "+what);
|
||||
return featureAccessors.get(what).apply(entity, arg);
|
||||
}
|
||||
private static Map<String, EquipmentSlot> inventorySlots = new HashMap<String, EquipmentSlot>(){{
|
||||
private static final Map<String, EquipmentSlot> inventorySlots = new HashMap<String, EquipmentSlot>(){{
|
||||
put("mainhand", EquipmentSlot.MAINHAND);
|
||||
put("offhand", EquipmentSlot.OFFHAND);
|
||||
put("head", EquipmentSlot.HEAD);
|
||||
@@ -200,7 +200,7 @@ public class EntityValue extends Value
|
||||
put("legs", EquipmentSlot.LEGS);
|
||||
put("feet", EquipmentSlot.FEET);
|
||||
}};
|
||||
private static Map<String, BiFunction<Entity, Value, Value>> featureAccessors = new HashMap<String, BiFunction<Entity, Value, Value>>() {{
|
||||
private static final Map<String, BiFunction<Entity, Value, Value>> featureAccessors = new HashMap<String, BiFunction<Entity, Value, Value>>() {{
|
||||
//put("test", (e, a) -> a == null ? Value.NULL : new StringValue(a.getString()));
|
||||
put("removed", (entity, arg) -> new NumericValue(entity.removed));
|
||||
put("uuid",(e, a) -> new StringValue(e.getUuidAsString()));
|
||||
@@ -440,20 +440,6 @@ public class EntityValue extends Value
|
||||
});
|
||||
}};
|
||||
|
||||
private static <Req extends Entity> Req assertEntityArgType(Class<Req> klass, Value arg)
|
||||
{
|
||||
if (!(arg instanceof EntityValue))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Entity e = ((EntityValue) arg).getEntity();
|
||||
if (!(klass.isAssignableFrom(e.getClass())))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (Req)e;
|
||||
}
|
||||
|
||||
public void set(String what, Value toWhat)
|
||||
{
|
||||
if (!(featureModifiers.containsKey(what)))
|
||||
@@ -502,7 +488,7 @@ public class EntityValue extends Value
|
||||
|
||||
|
||||
|
||||
private static Map<String, BiConsumer<Entity, Value>> featureModifiers = new HashMap<String, BiConsumer<Entity, Value>>() {{
|
||||
private static final Map<String, BiConsumer<Entity, Value>> featureModifiers = new HashMap<String, BiConsumer<Entity, Value>>() {{
|
||||
put("remove", (entity, value) -> entity.remove());
|
||||
put("health", (e, v) -> { if (e instanceof LivingEntity) ((LivingEntity) e).setHealth((float) NumericValue.asNumber(v).getDouble()); });
|
||||
put("kill", (e, v) -> e.kill());
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract class Value implements Comparable<Value>, Cloneable
|
||||
}
|
||||
public Value reboundedTo(String var)
|
||||
{
|
||||
Value copy = null;
|
||||
Value copy;
|
||||
try
|
||||
{
|
||||
copy = (Value)clone();
|
||||
@@ -202,5 +202,5 @@ public abstract class Value implements Comparable<Value>, Cloneable
|
||||
// should never happen
|
||||
throw new InternalExpressionException("Cannot make a copy of value: "+this);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -242,7 +242,7 @@ public class SettingsManager
|
||||
Map<String,String> result = new HashMap<String, String>();
|
||||
while ((line = reader.readLine()) != null)
|
||||
{
|
||||
line = line.replaceAll("\\r|\\n", "");
|
||||
line = line.replaceAll("[\\r\\n]", "");
|
||||
if ("locked".equalsIgnoreCase(line))
|
||||
{
|
||||
confLocked = true;
|
||||
@@ -286,9 +286,7 @@ public class SettingsManager
|
||||
{
|
||||
if (rule.name.toLowerCase(Locale.ROOT).contains(lcSearch)) return true; // substring match, case insensitive
|
||||
for (String c : rule.categories) if (c.equals(search)) return true; // category exactly, case sensitive
|
||||
if (Sets.newHashSet(rule.description.toLowerCase(Locale.ROOT).split("\\W+")).contains(lcSearch))
|
||||
return true; // contains full term in description, but case insensitive
|
||||
return false;
|
||||
return Sets.newHashSet(rule.description.toLowerCase(Locale.ROOT).split("\\W+")).contains(lcSearch); // contains full term in description, but case insensitive
|
||||
}).sorted().collect(ImmutableList.toImmutableList());
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.Map;
|
||||
|
||||
public class BlockInfo
|
||||
{
|
||||
public static Map<BlockSoundGroup, String> soundName = new HashMap<BlockSoundGroup, String>() {{
|
||||
public static final Map<BlockSoundGroup, String> soundName = new HashMap<BlockSoundGroup, String>() {{
|
||||
put(BlockSoundGroup.WOOD, "wood" );
|
||||
put(BlockSoundGroup.GRAVEL, "gravel");
|
||||
put(BlockSoundGroup.GRASS, "grass" );
|
||||
@@ -47,7 +47,7 @@ public class BlockInfo
|
||||
put(BlockSoundGroup.LANTERN , "lantern" );
|
||||
}};
|
||||
|
||||
public static Map<MaterialColor, String> mapColourName = new HashMap<MaterialColor, String>() {{
|
||||
public static final Map<MaterialColor, String> mapColourName = new HashMap<MaterialColor, String>() {{
|
||||
put(MaterialColor.AIR , "air" );
|
||||
put(MaterialColor.GRASS , "grass" );
|
||||
put(MaterialColor.SAND , "sand" );
|
||||
@@ -102,7 +102,7 @@ public class BlockInfo
|
||||
put(MaterialColor.BLACK_TERRACOTTA , "black_terracotta" );
|
||||
}};
|
||||
|
||||
public static Map<Material, String> materialName = new HashMap<Material, String>() {{
|
||||
public static final Map<Material, String> materialName = new HashMap<Material, String>() {{
|
||||
put(Material.AIR , "air" );
|
||||
put(Material.STRUCTURE_VOID , "void" );
|
||||
put(Material.PORTAL , "portal" );
|
||||
@@ -232,7 +232,7 @@ public class BlockInfo
|
||||
long total_time = (total_ticks)/1000/20;
|
||||
return Messenger.s(String.format(" - Wander chance above: %.1f%%\n - Average standby above: %s",
|
||||
(100.0F*success)/1000,
|
||||
((total_time>5000)?"INFINITY":(Long.toString(total_time)+" s"))
|
||||
((total_time>5000)?"INFINITY":(total_time +" s"))
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -21,9 +21,9 @@ public class CarpetProfiler
|
||||
private static int tick_health_elapsed = 0;
|
||||
private static TYPE test_type = TYPE.NONE; //1 for ticks, 2 for entities;
|
||||
private static long current_tick_start = 0;
|
||||
private static String[] GENERAL_SECTIONS = {"Network", "Autosave", "Async Tasks"};
|
||||
private static String[] DIMENSIONS = {"overworld", "the_end", "the_nether"};
|
||||
private static String[] SECTIONS = {
|
||||
private static final String[] GENERAL_SECTIONS = {"Network", "Autosave", "Async Tasks"};
|
||||
private static final String[] DIMENSIONS = {"overworld", "the_end", "the_nether"};
|
||||
private static final String[] SECTIONS = {
|
||||
"Spawning and Random Ticks", "Ticket Manager","Unloading",
|
||||
"Blocks", "Entities", "Block Entities",
|
||||
"Entities (Client)", "Block Entities (Client)",
|
||||
@@ -39,10 +39,10 @@ public class CarpetProfiler
|
||||
|
||||
public static class ProfilerToken
|
||||
{
|
||||
public TYPE type;
|
||||
public Object section;
|
||||
public long start;
|
||||
public World world;
|
||||
public final TYPE type;
|
||||
public final Object section;
|
||||
public final long start;
|
||||
public final World world;
|
||||
|
||||
public ProfilerToken(TYPE type, Object section, World world, long start)
|
||||
{
|
||||
|
||||
@@ -114,7 +114,7 @@ public class Messenger
|
||||
{
|
||||
message = "w"+message;
|
||||
}
|
||||
String parts[] = message.split("\\s", 2);
|
||||
String[] parts = message.split("\\s", 2);
|
||||
String desc = parts[0];
|
||||
String str = "";
|
||||
if (parts.length > 1) str = parts[1];
|
||||
|
||||
@@ -323,7 +323,7 @@ public class SpawnReporter
|
||||
"w ' to enable"));
|
||||
return report;
|
||||
}
|
||||
Long duration = (long) worldIn.getServer().getTicks() - track_spawns;
|
||||
long duration = (long) worldIn.getServer().getTicks() - track_spawns;
|
||||
report.add(Messenger.c("bw --------------------"));
|
||||
String simulated = mock_spawns?"[SIMULATED] ":"";
|
||||
String location = (lower_spawning_limit != null)?String.format("[in (%d, %d, %d)x(%d, %d, %d)]",
|
||||
@@ -410,8 +410,8 @@ public class SpawnReporter
|
||||
continue; // vanilla bug
|
||||
boolean canspawn = SpawnHelper.canSpawn(SpawnRestriction.getLocation(spawnEntry.type), worldIn, pos, spawnEntry.type);
|
||||
int will_spawn = -1;
|
||||
boolean fits = false;
|
||||
boolean fits1 = false;
|
||||
boolean fits;
|
||||
boolean fits1;
|
||||
|
||||
MobEntity mob;
|
||||
try
|
||||
|
||||
Reference in new issue
Block a user