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
+122
-137
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;
|
private static CommandDispatcher<ServerCommandSource> currentCommandDispatcher;
|
||||||
public static CarpetScriptServer scriptServer;
|
public static CarpetScriptServer scriptServer;
|
||||||
public static SettingsManager settingsManager;
|
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
|
// Separate from onServerLoaded, because a server can be loaded multiple times in singleplayer
|
||||||
public static void manageExtension(CarpetExtension extension)
|
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.TNT;
|
||||||
import static carpet.settings.RuleCategory.DISPENSER;
|
import static carpet.settings.RuleCategory.DISPENSER;
|
||||||
|
|
||||||
|
@SuppressWarnings("CanBeFinal")
|
||||||
public class CarpetSettings
|
public class CarpetSettings
|
||||||
{
|
{
|
||||||
public static final String carpetVersion = "1.3.3+v200105";
|
public static final String carpetVersion = "1.3.3+v200105";
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ package carpet.fakes;
|
|||||||
|
|
||||||
public interface MinecraftClientInferface
|
public interface MinecraftClientInferface
|
||||||
{
|
{
|
||||||
public float getPausedTickDelta();
|
float getPausedTickDelta();
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
public interface MobEntityInterface
|
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 interface StructureFeatureInterface
|
||||||
{
|
{
|
||||||
public boolean plopAnywhere(ServerWorld world, BlockPos pos);
|
boolean plopAnywhere(ServerWorld world, BlockPos pos);
|
||||||
public boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator<? extends ChunkGeneratorConfig> generator);
|
boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator<? extends ChunkGeneratorConfig> generator);
|
||||||
}
|
}
|
||||||
@@ -24,9 +24,9 @@ import java.util.TreeMap;
|
|||||||
|
|
||||||
public class EntityPlayerActionPack
|
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 BlockPos currentBlock;
|
||||||
private int blockHitDelay;
|
private int blockHitDelay;
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ public class FeatureGenerator
|
|||||||
}
|
}
|
||||||
public static void noop() {System.out.println("boo");}
|
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));
|
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)
|
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;
|
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)
|
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;
|
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)
|
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;
|
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)
|
public static boolean player_holds_obsidian(PlayerEntity playerIn)
|
||||||
{
|
{
|
||||||
if ( (!playerIn.getMainHandStack().isEmpty()
|
return (!playerIn.getMainHandStack().isEmpty()
|
||||||
&& playerIn.getMainHandStack().getItem() instanceof BlockItem &&
|
&& playerIn.getMainHandStack().getItem() instanceof BlockItem &&
|
||||||
((BlockItem)(playerIn.getMainHandStack().getItem())).getBlock() == Blocks.OBSIDIAN ))
|
((BlockItem) (playerIn.getMainHandStack().getItem())).getBlock() == Blocks.OBSIDIAN);
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -193,7 +193,7 @@ public class RedstoneWireTurbo
|
|||||||
private static final int West = 3;
|
private static final int West = 3;
|
||||||
|
|
||||||
// Names for debug print statements
|
// 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
|
* These lookup tables completely remap neighbor positions into a left-to-right
|
||||||
@@ -269,7 +269,7 @@ public class RedstoneWireTurbo
|
|||||||
* neighbors that will receive updates.
|
* neighbors that will receive updates.
|
||||||
*/
|
*/
|
||||||
private static class UpdateNode {
|
private static class UpdateNode {
|
||||||
public static enum Type {
|
public enum Type {
|
||||||
UNKNOWN, REDSTONE, OTHER
|
UNKNOWN, REDSTONE, OTHER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public abstract class DesertPyramidFeatureMixin extends AbstractTempleFeature<De
|
|||||||
|
|
||||||
static
|
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)
|
public DesertPyramidFeatureMixin(Function<Dynamic<?>, ? extends DefaultFeatureConfig> function_1)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public abstract class Entity_scarpetEventsMixin implements EntityInterface
|
|||||||
{
|
{
|
||||||
@Shadow public boolean removed;
|
@Shadow public boolean removed;
|
||||||
|
|
||||||
private EntityEventsGroup events = new EntityEventsGroup();
|
private final EntityEventsGroup events = new EntityEventsGroup();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityEventsGroup getEventContainer()
|
public EntityEventsGroup getEventContainer()
|
||||||
|
|||||||
@@ -65,14 +65,14 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
|
|||||||
@Inject(method = "move", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
|
@Inject(method = "move", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
|
||||||
target = "Ljava/util/List;size()I", ordinal = 4),locals = LocalCapture.CAPTURE_FAILHARD)
|
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,
|
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,
|
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)
|
Direction direction_2)
|
||||||
{
|
{
|
||||||
//Get the blockEntities and remove them from the world before any magic starts to happen
|
//Get the blockEntities and remove them from the world before any magic starts to happen
|
||||||
if (CarpetSettings.movableBlockEntities)
|
if (CarpetSettings.movableBlockEntities)
|
||||||
{
|
{
|
||||||
list1_BlockEntities.set(Lists.<BlockEntity>newArrayList());
|
list1_BlockEntities.set(Lists.newArrayList());
|
||||||
for (int i = 0; i < list_1.size(); ++i)
|
for (int i = 0; i < list_1.size(); ++i)
|
||||||
{
|
{
|
||||||
BlockPos blockpos = list_1.get(i);
|
BlockPos blockpos = list_1.get(i);
|
||||||
@@ -94,9 +94,9 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
|
|||||||
"Lnet/minecraft/block/entity/BlockEntity;)V", ordinal = 0),
|
"Lnet/minecraft/block/entity/BlockEntity;)V", ordinal = 0),
|
||||||
locals = LocalCapture.CAPTURE_FAILHARD)
|
locals = LocalCapture.CAPTURE_FAILHARD)
|
||||||
private void setBlockEntityWithCarried(World world_1, BlockPos blockPos_1, Direction direction_1, boolean boolean_1,
|
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,
|
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)
|
int int_3, BlockPos blockPos_4, BlockState blockState_1)
|
||||||
{
|
{
|
||||||
BlockEntity blockEntityPiston = PistonExtensionBlock.createBlockEntityPiston((BlockState) list_2.get(int_3),
|
BlockEntity blockEntityPiston = PistonExtensionBlock.createBlockEntityPiston((BlockState) list_2.get(int_3),
|
||||||
direction_1, boolean_1, false);
|
direction_1, boolean_1, false);
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public abstract class PlayerManagerMixin
|
|||||||
serverPlayerEntity_3.kill();
|
serverPlayerEntity_3.kill();
|
||||||
continue;
|
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;
|
private Set<BlockPos> affectedNeighbors;
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
private int increasePower(int int_1, BlockState blockState_1) { return 0; };
|
private int increasePower(int int_1, BlockState blockState_1) { return 0; }
|
||||||
|
|
||||||
@Shadow
|
@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(
|
@Redirect(method = "method_20801", at = @At(
|
||||||
value = "INVOKE",
|
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"
|
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(
|
@Redirect(method = "method_20801", at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Lnet/minecraft/entity/EntityCategory;getSpawnCap()I"
|
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)
|
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)
|
if (flipped)
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
|||||||
@Mixin(ServerWorld.class)
|
@Mixin(ServerWorld.class)
|
||||||
public abstract class ServerWorld_fakePlayersMixin
|
public abstract class ServerWorld_fakePlayersMixin
|
||||||
{
|
{
|
||||||
@Shadow private boolean ticking;
|
@Shadow
|
||||||
|
boolean ticking;
|
||||||
|
|
||||||
@Shadow /*@Nonnull*/ public abstract MinecraftServer getServer();
|
@Shadow /*@Nonnull*/ public abstract MinecraftServer getServer();
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class SummonCommandMixin
|
|||||||
world.spawnEntity(skeletonHorseEntity_1);
|
world.spawnEntity(skeletonHorseEntity_1);
|
||||||
}
|
}
|
||||||
world.addLightning(lightningEntity_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.setReturnValue(1);
|
||||||
cir.cancel();
|
cir.cancel();
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public abstract class World_movableTEMixin implements WorldInterface
|
|||||||
private Profiler profiler;
|
private Profiler profiler;
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
protected abstract WorldChunk getWorldChunk(BlockPos blockPos_1);
|
public abstract WorldChunk getWorldChunk(BlockPos blockPos_1);
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
public abstract BlockState getBlockState(BlockPos blockPos_1);
|
public abstract BlockState getBlockState(BlockPos blockPos_1);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import net.minecraft.world.dimension.DimensionType;
|
|||||||
import carpet.fakes.ServerPlayerEntityInterface;
|
import carpet.fakes.ServerPlayerEntityInterface;
|
||||||
import carpet.utils.Messenger;
|
import carpet.utils.Messenger;
|
||||||
|
|
||||||
|
@SuppressWarnings("EntityConstructor")
|
||||||
public class EntityPlayerMPFake extends ServerPlayerEntity
|
public class EntityPlayerMPFake extends ServerPlayerEntity
|
||||||
{
|
{
|
||||||
public Runnable fixStartingPosition = () -> {};
|
public Runnable fixStartingPosition = () -> {};
|
||||||
@@ -93,6 +94,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity
|
|||||||
super(server, worldIn, profile, interactionManagerIn);
|
super(server, worldIn, profile, interactionManagerIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void kill()
|
public void kill()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
public class CarpetContext extends Context
|
public class CarpetContext extends Context
|
||||||
{
|
{
|
||||||
public ServerCommandSource s;
|
public ServerCommandSource s;
|
||||||
public BlockPos origin;
|
public final BlockPos origin;
|
||||||
public CarpetContext(ScriptHost host, ServerCommandSource source, BlockPos origin)
|
public CarpetContext(ScriptHost host, ServerCommandSource source, BlockPos origin)
|
||||||
{
|
{
|
||||||
super(host);
|
super(host);
|
||||||
|
|||||||
@@ -43,12 +43,12 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class CarpetEventServer
|
public class CarpetEventServer
|
||||||
{
|
{
|
||||||
public List<ScheduledCall> scheduledCalls = new LinkedList<>();
|
public final List<ScheduledCall> scheduledCalls = new LinkedList<>();
|
||||||
|
|
||||||
public static class Callback
|
public static class Callback
|
||||||
{
|
{
|
||||||
public String host;
|
public final String host;
|
||||||
public FunctionValue function;
|
public final FunctionValue function;
|
||||||
|
|
||||||
public Callback(String host, FunctionValue function)
|
public Callback(String host, FunctionValue function)
|
||||||
{
|
{
|
||||||
@@ -65,8 +65,8 @@ public class CarpetEventServer
|
|||||||
|
|
||||||
public static class ScheduledCall extends Callback
|
public static class ScheduledCall extends Callback
|
||||||
{
|
{
|
||||||
public List<Value> args;
|
public final List<Value> args;
|
||||||
private CarpetContext ctx;
|
private final CarpetContext ctx;
|
||||||
public long dueTime;
|
public long dueTime;
|
||||||
|
|
||||||
public ScheduledCall(CarpetContext context, FunctionValue function, List<Value> args, 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 static class CallbackList
|
||||||
{
|
{
|
||||||
|
|
||||||
public List<Callback> callList;
|
public final List<Callback> callList;
|
||||||
public int reqArgs;
|
public final int reqArgs;
|
||||||
|
|
||||||
public CallbackList(int reqArgs)
|
public CallbackList(int reqArgs)
|
||||||
{
|
{
|
||||||
@@ -454,7 +454,7 @@ public class CarpetEventServer
|
|||||||
{
|
{
|
||||||
return stat.getType().getRegistry().getId(stat.getValue());
|
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_DEATH);
|
||||||
add(Stats.TIME_SINCE_REST);
|
add(Stats.TIME_SINCE_REST);
|
||||||
add(Stats.PLAY_ONE_MINUTE);
|
add(Stats.PLAY_ONE_MINUTE);
|
||||||
@@ -476,14 +476,14 @@ public class CarpetEventServer
|
|||||||
|
|
||||||
// on projectile thrown (arrow from bows, crossbows, tridents, snoballs, e-pearls
|
// on projectile thrown (arrow from bows, crossbows, tridents, snoballs, e-pearls
|
||||||
|
|
||||||
public String name;
|
public final String name;
|
||||||
public static Map<String, Event> byName = new HashMap<String, Event>(){{
|
public static final Map<String, Event> byName = new HashMap<String, Event>(){{
|
||||||
for (Event e: Event.values())
|
for (Event e: Event.values())
|
||||||
{
|
{
|
||||||
put(e.name, e);
|
put(e.name, e);
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
public CallbackList handler;
|
public final CallbackList handler;
|
||||||
Event(String name, CallbackList eventHandler)
|
Event(String name, CallbackList eventHandler)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|||||||
@@ -134,9 +134,9 @@ import static java.lang.Math.sqrt;
|
|||||||
public class CarpetExpression
|
public class CarpetExpression
|
||||||
{
|
{
|
||||||
|
|
||||||
private ServerCommandSource source;
|
private final ServerCommandSource source;
|
||||||
private BlockPos origin;
|
private final BlockPos origin;
|
||||||
private Expression expr;
|
private final Expression expr;
|
||||||
Expression getExpr() {return expr;}
|
Expression getExpr() {return expr;}
|
||||||
private static long tickStart = 0L;
|
private static long tickStart = 0L;
|
||||||
|
|
||||||
@@ -275,7 +275,7 @@ public class CarpetExpression
|
|||||||
return bs;
|
return bs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<String, ParticleEffect> particleCache = new HashMap<>();
|
private static final Map<String, ParticleEffect> particleCache = new HashMap<>();
|
||||||
private ParticleEffect getParticleData(String name)
|
private ParticleEffect getParticleData(String name)
|
||||||
{
|
{
|
||||||
ParticleEffect particle = particleCache.get(name);
|
ParticleEffect particle = particleCache.get(name);
|
||||||
@@ -2147,7 +2147,7 @@ public class CarpetExpression
|
|||||||
args = Collections.singletonList(lv.get(3).evalValue(c));
|
args = Collections.singletonList(lv.get(3).evalValue(c));
|
||||||
else if (lv.size()>4)
|
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);
|
((EntityValue) v).setEvent((CarpetContext)c, what, function, args);
|
||||||
@@ -2379,12 +2379,12 @@ public class CarpetExpression
|
|||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
return (c_, t_) -> new LazyListValue()
|
return (c_, t_) -> new LazyListValue()
|
||||||
{
|
{
|
||||||
int minx = cx-sminx;
|
final int minx = cx-sminx;
|
||||||
int miny = cy-sminy;
|
final int miny = cy-sminy;
|
||||||
int minz = cz-sminz;
|
final int minz = cz-sminz;
|
||||||
int maxx = cx+smaxx;
|
final int maxx = cx+smaxx;
|
||||||
int maxy = cy+smaxy;
|
final int maxy = cy+smaxy;
|
||||||
int maxz = cz+smaxz;
|
final int maxz = cz+smaxz;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
int z;
|
int z;
|
||||||
@@ -3190,7 +3190,7 @@ public class CarpetExpression
|
|||||||
this.expr.addLazyFunction("schedule", -1, (c, t, lv) -> {
|
this.expr.addLazyFunction("schedule", -1, (c, t, lv) -> {
|
||||||
if (lv.size()<2)
|
if (lv.size()<2)
|
||||||
throw new InternalExpressionException("'schedule' should have at least 2 arguments, delay and call name");
|
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);
|
Value functionValue = lv.get(1).evalValue(c);
|
||||||
if (!(functionValue instanceof FunctionValue))
|
if (!(functionValue instanceof FunctionValue))
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import static java.lang.Math.max;
|
|||||||
|
|
||||||
public class CarpetScriptHost extends ScriptHost
|
public class CarpetScriptHost extends ScriptHost
|
||||||
{
|
{
|
||||||
private CarpetScriptServer scriptServer;
|
private final CarpetScriptServer scriptServer;
|
||||||
|
|
||||||
private Tag globalState;
|
private Tag globalState;
|
||||||
private int saveTimeout;
|
private int saveTimeout;
|
||||||
|
|||||||
@@ -33,14 +33,14 @@ import static net.minecraft.server.command.CommandManager.literal;
|
|||||||
public class CarpetScriptServer
|
public class CarpetScriptServer
|
||||||
{
|
{
|
||||||
//make static for now, but will change that later:
|
//make static for now, but will change that later:
|
||||||
public CarpetScriptHost globalHost;
|
public final CarpetScriptHost globalHost;
|
||||||
public Map<String, CarpetScriptHost> modules;
|
public final Map<String, CarpetScriptHost> modules;
|
||||||
public long tickStart;
|
public long tickStart;
|
||||||
public boolean stopAll;
|
public boolean stopAll;
|
||||||
private Set<String> holyMoly;
|
private final Set<String> holyMoly;
|
||||||
public CarpetEventServer events;
|
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("camera"));
|
||||||
add(new BundledModule("event_test"));
|
add(new BundledModule("event_test"));
|
||||||
add(new BundledModule("stats_test"));
|
add(new BundledModule("stats_test"));
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ public class Context
|
|||||||
public static final int LOCALIZATION = 8;
|
public static final int LOCALIZATION = 8;
|
||||||
public static final int LVALUE = 9;
|
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)
|
Context(ScriptHost host)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class EntityEventsGroup
|
public class EntityEventsGroup
|
||||||
{
|
{
|
||||||
private Map<EntityEventType, Map<String, CarpetEventServer.ScheduledCall>> actions;
|
private final Map<EntityEventType, Map<String, CarpetEventServer.ScheduledCall>> actions;
|
||||||
public EntityEventsGroup()
|
public EntityEventsGroup()
|
||||||
{
|
{
|
||||||
actions = new EnumMap<>(EntityEventType.class);
|
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 final int argcount;
|
||||||
public String id;
|
public final String id;
|
||||||
EntityEventType(String identifier, int args)
|
EntityEventType(String identifier, int args)
|
||||||
{
|
{
|
||||||
id = identifier;
|
id = identifier;
|
||||||
@@ -121,6 +121,6 @@ public class EntityEventsGroup
|
|||||||
protected List<Value> makeArgs(Entity entity, Object ... args)
|
protected List<Value> makeArgs(Entity entity, Object ... args)
|
||||||
{
|
{
|
||||||
return Collections.singletonList(new EntityValue(entity));
|
return Collections.singletonList(new EntityValue(entity));
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -357,7 +357,7 @@ public class Expression implements Cloneable
|
|||||||
"2.71828182845904523536028747135266249775724709369995957496696762772407663");
|
"2.71828182845904523536028747135266249775724709369995957496696762772407663");
|
||||||
|
|
||||||
// %[argument_index$][flags][width][.precision][t]conversion
|
// %[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 */
|
/** The current infix expression */
|
||||||
private String expression;
|
private String expression;
|
||||||
@@ -387,10 +387,10 @@ public class Expression implements Cloneable
|
|||||||
private LazyValue ast = null;
|
private LazyValue ast = null;
|
||||||
|
|
||||||
/** script specific operatos and built-in functions */
|
/** 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");}
|
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();}
|
Set<String> getFunctionNames() {return functions.keySet();}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2878,7 +2878,6 @@ public class Expression implements Cloneable
|
|||||||
else if (fmt == '%')
|
else if (fmt == '%')
|
||||||
{
|
{
|
||||||
//skip /%%
|
//skip /%%
|
||||||
;
|
|
||||||
}
|
}
|
||||||
else
|
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 .
|
* @param expression .
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class ExpressionInspector
|
|||||||
{
|
{
|
||||||
Set<String> allFunctions = (new CarpetExpression("null", null, null)).getExpr().getFunctionNames();
|
Set<String> allFunctions = (new CarpetExpression("null", null, null)).getExpr().getFunctionNames();
|
||||||
scarpetFunctions = new TreeSet<>(new Expression("null").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)
|
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 class CarpetExpressionException extends RuntimeException
|
||||||
{
|
{
|
||||||
public List<FunctionValue> stack;
|
public final List<FunctionValue> stack;
|
||||||
|
|
||||||
public CarpetExpressionException(String message, 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) */
|
/* Exception thrown to terminate execution mid expression (aka return statement) */
|
||||||
public class ExitStatement extends RuntimeException
|
public class ExitStatement extends RuntimeException
|
||||||
{
|
{
|
||||||
public Value retval;
|
public final Value retval;
|
||||||
public ExitStatement(Value value)
|
public ExitStatement(Value value)
|
||||||
{
|
{
|
||||||
retval = value;
|
retval = value;
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import static carpet.script.ExpressionInspector.Expression_getName;
|
|||||||
/* The expression evaluators exception class. */
|
/* The expression evaluators exception class. */
|
||||||
public class ExpressionException extends RuntimeException
|
public class ExpressionException extends RuntimeException
|
||||||
{
|
{
|
||||||
public Context context;
|
public final Context context;
|
||||||
public List<FunctionValue> stack = new ArrayList<>();
|
public final List<FunctionValue> stack = new ArrayList<>();
|
||||||
public ExpressionException(Context c, String message)
|
public ExpressionException(Context c, String message)
|
||||||
{
|
{
|
||||||
super(makeMessage(c, null, null, message));
|
super(makeMessage(c, null, null, message));
|
||||||
@@ -35,7 +35,7 @@ public class ExpressionException extends RuntimeException
|
|||||||
context = c;
|
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<>();
|
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 AIR = new BlockValue(Blocks.AIR.getDefaultState(), null, BlockPos.ORIGIN);
|
||||||
public static final BlockValue NULL = new BlockValue(null, null, null);
|
public static final BlockValue NULL = new BlockValue(null, null, null);
|
||||||
private BlockState blockState;
|
private BlockState blockState;
|
||||||
private BlockPos pos;
|
private final BlockPos pos;
|
||||||
private ServerWorld world;
|
private final ServerWorld world;
|
||||||
private CompoundTag data;
|
private CompoundTag data;
|
||||||
|
|
||||||
public static BlockValue fromCoords(CarpetContext c, int x, int y, int z)
|
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);
|
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)
|
public static BlockValue fromString(String str)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -294,8 +294,8 @@ public class BlockValue extends Value
|
|||||||
|
|
||||||
public static class LocatorResult
|
public static class LocatorResult
|
||||||
{
|
{
|
||||||
public BlockValue block;
|
public final BlockValue block;
|
||||||
public int offset;
|
public final int offset;
|
||||||
LocatorResult(BlockValue b, int o)
|
LocatorResult(BlockValue b, int o)
|
||||||
{
|
{
|
||||||
block = b;
|
block = b;
|
||||||
@@ -306,9 +306,9 @@ public class BlockValue extends Value
|
|||||||
public static class VectorLocator
|
public static class VectorLocator
|
||||||
{
|
{
|
||||||
public Vec3d vec;
|
public Vec3d vec;
|
||||||
public int offset;
|
public final int offset;
|
||||||
public double yaw;
|
public final double yaw;
|
||||||
public double pitch;
|
public final double pitch;
|
||||||
public boolean fromBlock;
|
public boolean fromBlock;
|
||||||
VectorLocator(Vec3d v, int o)
|
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),
|
EASTUP("east-up", 0.0, 0.6, 0.5, Direction.EAST),
|
||||||
WESTUP("west-up", 1.0, 0.6, 0.5, Direction.WEST);
|
WESTUP("west-up", 1.0, 0.6, 0.5, Direction.WEST);
|
||||||
|
|
||||||
public String name;
|
public final String name;
|
||||||
public Vec3d hitOffset;
|
public final Vec3d hitOffset;
|
||||||
public Direction facing;
|
public final Direction facing;
|
||||||
|
|
||||||
private static final Map<String, SpecificDirection> DIRECTION_MAP = Arrays.stream(values()).collect(Collectors.toMap(SpecificDirection::getName, d -> d));
|
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.
|
// TODO: decide whether copy(entity) should duplicate entity in the world.
|
||||||
public class EntityValue extends Value
|
public class EntityValue extends Value
|
||||||
{
|
{
|
||||||
private Entity entity;
|
private final Entity entity;
|
||||||
|
|
||||||
public EntityValue(Entity e)
|
public EntityValue(Entity e)
|
||||||
{
|
{
|
||||||
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)
|
public static Collection<? extends Entity > getEntitiesFromSelector(ServerCommandSource source, String selector)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -177,7 +177,7 @@ public class EntityValue extends Value
|
|||||||
return res; //TODO add more here like search by tags, or type
|
return res; //TODO add more here like search by tags, or type
|
||||||
//if (who.startsWith('tag:'))
|
//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>>>()
|
new HashMap<String, Pair<EntityType<?>, Predicate<? super Entity>>>()
|
||||||
{{
|
{{
|
||||||
put("*", Pair.of(null, EntityPredicates.VALID_ENTITY));
|
put("*", Pair.of(null, EntityPredicates.VALID_ENTITY));
|
||||||
@@ -192,7 +192,7 @@ public class EntityValue extends Value
|
|||||||
throw new InternalExpressionException("Unknown entity feature: "+what);
|
throw new InternalExpressionException("Unknown entity feature: "+what);
|
||||||
return featureAccessors.get(what).apply(entity, arg);
|
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("mainhand", EquipmentSlot.MAINHAND);
|
||||||
put("offhand", EquipmentSlot.OFFHAND);
|
put("offhand", EquipmentSlot.OFFHAND);
|
||||||
put("head", EquipmentSlot.HEAD);
|
put("head", EquipmentSlot.HEAD);
|
||||||
@@ -200,7 +200,7 @@ public class EntityValue extends Value
|
|||||||
put("legs", EquipmentSlot.LEGS);
|
put("legs", EquipmentSlot.LEGS);
|
||||||
put("feet", EquipmentSlot.FEET);
|
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("test", (e, a) -> a == null ? Value.NULL : new StringValue(a.getString()));
|
||||||
put("removed", (entity, arg) -> new NumericValue(entity.removed));
|
put("removed", (entity, arg) -> new NumericValue(entity.removed));
|
||||||
put("uuid",(e, a) -> new StringValue(e.getUuidAsString()));
|
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)
|
public void set(String what, Value toWhat)
|
||||||
{
|
{
|
||||||
if (!(featureModifiers.containsKey(what)))
|
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("remove", (entity, value) -> entity.remove());
|
||||||
put("health", (e, v) -> { if (e instanceof LivingEntity) ((LivingEntity) e).setHealth((float) NumericValue.asNumber(v).getDouble()); });
|
put("health", (e, v) -> { if (e instanceof LivingEntity) ((LivingEntity) e).setHealth((float) NumericValue.asNumber(v).getDouble()); });
|
||||||
put("kill", (e, v) -> e.kill());
|
put("kill", (e, v) -> e.kill());
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public abstract class Value implements Comparable<Value>, Cloneable
|
|||||||
}
|
}
|
||||||
public Value reboundedTo(String var)
|
public Value reboundedTo(String var)
|
||||||
{
|
{
|
||||||
Value copy = null;
|
Value copy;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
copy = (Value)clone();
|
copy = (Value)clone();
|
||||||
@@ -202,5 +202,5 @@ public abstract class Value implements Comparable<Value>, Cloneable
|
|||||||
// should never happen
|
// should never happen
|
||||||
throw new InternalExpressionException("Cannot make a copy of value: "+this);
|
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>();
|
Map<String,String> result = new HashMap<String, String>();
|
||||||
while ((line = reader.readLine()) != null)
|
while ((line = reader.readLine()) != null)
|
||||||
{
|
{
|
||||||
line = line.replaceAll("\\r|\\n", "");
|
line = line.replaceAll("[\\r\\n]", "");
|
||||||
if ("locked".equalsIgnoreCase(line))
|
if ("locked".equalsIgnoreCase(line))
|
||||||
{
|
{
|
||||||
confLocked = true;
|
confLocked = true;
|
||||||
@@ -286,9 +286,7 @@ public class SettingsManager
|
|||||||
{
|
{
|
||||||
if (rule.name.toLowerCase(Locale.ROOT).contains(lcSearch)) return true; // substring match, case insensitive
|
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
|
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 Sets.newHashSet(rule.description.toLowerCase(Locale.ROOT).split("\\W+")).contains(lcSearch); // contains full term in description, but case insensitive
|
||||||
return true; // contains full term in description, but case insensitive
|
|
||||||
return false;
|
|
||||||
}).sorted().collect(ImmutableList.toImmutableList());
|
}).sorted().collect(ImmutableList.toImmutableList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class BlockInfo
|
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.WOOD, "wood" );
|
||||||
put(BlockSoundGroup.GRAVEL, "gravel");
|
put(BlockSoundGroup.GRAVEL, "gravel");
|
||||||
put(BlockSoundGroup.GRASS, "grass" );
|
put(BlockSoundGroup.GRASS, "grass" );
|
||||||
@@ -47,7 +47,7 @@ public class BlockInfo
|
|||||||
put(BlockSoundGroup.LANTERN , "lantern" );
|
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.AIR , "air" );
|
||||||
put(MaterialColor.GRASS , "grass" );
|
put(MaterialColor.GRASS , "grass" );
|
||||||
put(MaterialColor.SAND , "sand" );
|
put(MaterialColor.SAND , "sand" );
|
||||||
@@ -102,7 +102,7 @@ public class BlockInfo
|
|||||||
put(MaterialColor.BLACK_TERRACOTTA , "black_terracotta" );
|
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.AIR , "air" );
|
||||||
put(Material.STRUCTURE_VOID , "void" );
|
put(Material.STRUCTURE_VOID , "void" );
|
||||||
put(Material.PORTAL , "portal" );
|
put(Material.PORTAL , "portal" );
|
||||||
@@ -232,7 +232,7 @@ public class BlockInfo
|
|||||||
long total_time = (total_ticks)/1000/20;
|
long total_time = (total_ticks)/1000/20;
|
||||||
return Messenger.s(String.format(" - Wander chance above: %.1f%%\n - Average standby above: %s",
|
return Messenger.s(String.format(" - Wander chance above: %.1f%%\n - Average standby above: %s",
|
||||||
(100.0F*success)/1000,
|
(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 int tick_health_elapsed = 0;
|
||||||
private static TYPE test_type = TYPE.NONE; //1 for ticks, 2 for entities;
|
private static TYPE test_type = TYPE.NONE; //1 for ticks, 2 for entities;
|
||||||
private static long current_tick_start = 0;
|
private static long current_tick_start = 0;
|
||||||
private static String[] GENERAL_SECTIONS = {"Network", "Autosave", "Async Tasks"};
|
private static final String[] GENERAL_SECTIONS = {"Network", "Autosave", "Async Tasks"};
|
||||||
private static String[] DIMENSIONS = {"overworld", "the_end", "the_nether"};
|
private static final String[] DIMENSIONS = {"overworld", "the_end", "the_nether"};
|
||||||
private static String[] SECTIONS = {
|
private static final String[] SECTIONS = {
|
||||||
"Spawning and Random Ticks", "Ticket Manager","Unloading",
|
"Spawning and Random Ticks", "Ticket Manager","Unloading",
|
||||||
"Blocks", "Entities", "Block Entities",
|
"Blocks", "Entities", "Block Entities",
|
||||||
"Entities (Client)", "Block Entities (Client)",
|
"Entities (Client)", "Block Entities (Client)",
|
||||||
@@ -39,10 +39,10 @@ public class CarpetProfiler
|
|||||||
|
|
||||||
public static class ProfilerToken
|
public static class ProfilerToken
|
||||||
{
|
{
|
||||||
public TYPE type;
|
public final TYPE type;
|
||||||
public Object section;
|
public final Object section;
|
||||||
public long start;
|
public final long start;
|
||||||
public World world;
|
public final World world;
|
||||||
|
|
||||||
public ProfilerToken(TYPE type, Object section, World world, long start)
|
public ProfilerToken(TYPE type, Object section, World world, long start)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ public class Messenger
|
|||||||
{
|
{
|
||||||
message = "w"+message;
|
message = "w"+message;
|
||||||
}
|
}
|
||||||
String parts[] = message.split("\\s", 2);
|
String[] parts = message.split("\\s", 2);
|
||||||
String desc = parts[0];
|
String desc = parts[0];
|
||||||
String str = "";
|
String str = "";
|
||||||
if (parts.length > 1) str = parts[1];
|
if (parts.length > 1) str = parts[1];
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ public class SpawnReporter
|
|||||||
"w ' to enable"));
|
"w ' to enable"));
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
Long duration = (long) worldIn.getServer().getTicks() - track_spawns;
|
long duration = (long) worldIn.getServer().getTicks() - track_spawns;
|
||||||
report.add(Messenger.c("bw --------------------"));
|
report.add(Messenger.c("bw --------------------"));
|
||||||
String simulated = mock_spawns?"[SIMULATED] ":"";
|
String simulated = mock_spawns?"[SIMULATED] ":"";
|
||||||
String location = (lower_spawning_limit != null)?String.format("[in (%d, %d, %d)x(%d, %d, %d)]",
|
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
|
continue; // vanilla bug
|
||||||
boolean canspawn = SpawnHelper.canSpawn(SpawnRestriction.getLocation(spawnEntry.type), worldIn, pos, spawnEntry.type);
|
boolean canspawn = SpawnHelper.canSpawn(SpawnRestriction.getLocation(spawnEntry.type), worldIn, pos, spawnEntry.type);
|
||||||
int will_spawn = -1;
|
int will_spawn = -1;
|
||||||
boolean fits = false;
|
boolean fits;
|
||||||
boolean fits1 = false;
|
boolean fits1;
|
||||||
|
|
||||||
MobEntity mob;
|
MobEntity mob;
|
||||||
try
|
try
|
||||||
|
|||||||
Reference in new issue
Block a user