22w42a
This commit is contained in:
1 parent
ffa4fcf2a6
commit
9f776167e3
23 files changed
+179
-136
No files matched your search
@@ -48,6 +48,7 @@ import java.util.Objects;
|
||||
|
||||
public class Experimental
|
||||
{
|
||||
/*
|
||||
public static Value reloadOne(MinecraftServer server)
|
||||
{
|
||||
LevelStorageSource.LevelStorageAccess session = ((MinecraftServerInterface) server).getCMSession();
|
||||
@@ -146,4 +147,6 @@ public class Experimental
|
||||
((MinecraftServerInterface)server).reloadAfterReload(stem.registryAccess());
|
||||
return ListValue.wrap(addeds);
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
@@ -26,10 +26,10 @@ import com.mojang.blaze3d.vertex.VertexFormat.Mode;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
||||
import net.minecraft.commands.arguments.ParticleArgument;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.nbt.ByteTag;
|
||||
@@ -69,7 +69,6 @@ import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.Map.entry;
|
||||
|
||||
@@ -180,7 +179,7 @@ public class ShapeDispatcher
|
||||
return particle;
|
||||
try
|
||||
{
|
||||
particle = ParticleArgument.readParticle(new StringReader(name));
|
||||
particle = ParticleArgument.readParticle(new StringReader(name), HolderLookup.forRegistry(Registry.PARTICLE_TYPE));
|
||||
}
|
||||
catch (CommandSyntaxException e)
|
||||
{
|
||||
@@ -220,7 +219,7 @@ public class ShapeDispatcher
|
||||
}
|
||||
|
||||
// client
|
||||
public static ExpiringShape fromTag(CompoundTag tag)
|
||||
public static ExpiringShape fromTag(CompoundTag tag, Level level)
|
||||
{
|
||||
Map<String, Value> options = new HashMap<>();
|
||||
for (String key : tag.getAllKeys())
|
||||
@@ -231,7 +230,7 @@ public class ShapeDispatcher
|
||||
CarpetSettings.LOG.info("Unknown parameter for shape: "+key);
|
||||
return null;
|
||||
}
|
||||
Value decodedValue = decoder.decode(tag.get(key));
|
||||
Value decodedValue = decoder.decode(tag.get(key), level);
|
||||
options.put(key, decodedValue);
|
||||
}
|
||||
Value shapeValue = options.get("shape");
|
||||
@@ -1257,7 +1256,7 @@ public class ShapeDispatcher
|
||||
|
||||
public abstract Tag toTag(Value value); //validates value, returning null if not necessary to keep it and serialize
|
||||
public abstract Value validate(Map<String, Value> options, MinecraftServer server, Value value); // makes sure the value is proper
|
||||
public abstract Value decode(Tag tag);
|
||||
public abstract Value decode(Tag tag, Level level);
|
||||
}
|
||||
public static class OptionalBoolListParam extends Param
|
||||
{
|
||||
@@ -1266,7 +1265,7 @@ public class ShapeDispatcher
|
||||
@Override
|
||||
public Tag toTag(Value value) { return value.toTag(true);}
|
||||
@Override
|
||||
public Value decode(Tag tag) {
|
||||
public Value decode(Tag tag, Level level) {
|
||||
if(tag instanceof ListTag){
|
||||
return ListValue.wrap(((ListTag)tag).stream().map(x->BooleanValue.of(((NumericTag)x).getAsNumber().doubleValue()!=0)));
|
||||
}
|
||||
@@ -1294,7 +1293,7 @@ public class ShapeDispatcher
|
||||
@Override
|
||||
public Tag toTag(Value value) { return StringTag.valueOf(value.getString()); }
|
||||
@Override
|
||||
public Value decode(Tag tag) { return new StringValue(tag.getAsString()); }
|
||||
public Value decode(Tag tag, Level level) { return new StringValue(tag.getAsString()); }
|
||||
}
|
||||
public static class BlockParam extends Param
|
||||
{
|
||||
@@ -1325,8 +1324,8 @@ public class ShapeDispatcher
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value decode(Tag tag) {
|
||||
BlockState bs = NbtUtils.readBlockState((CompoundTag) tag);
|
||||
public Value decode(Tag tag, Level level) {
|
||||
BlockState bs = NbtUtils.readBlockState(level.holderLookup(Registry.BLOCK_REGISTRY), (CompoundTag) tag);
|
||||
CompoundTag compoundTag2 = null;
|
||||
if (((CompoundTag) tag).contains("TileEntityData", 10)) {
|
||||
compoundTag2 = ((CompoundTag) tag).getCompound("TileEntityData");
|
||||
@@ -1351,7 +1350,7 @@ public class ShapeDispatcher
|
||||
return ((NBTSerializableValue)value).getTag();
|
||||
}
|
||||
@Override
|
||||
public Value decode(Tag tag) {
|
||||
public Value decode(Tag tag, Level level) {
|
||||
return new NBTSerializableValue(tag);
|
||||
}
|
||||
}
|
||||
@@ -1391,7 +1390,7 @@ public class ShapeDispatcher
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value decode(Tag tag)
|
||||
public Value decode(Tag tag, Level level)
|
||||
{
|
||||
return FormattedTextValue.deserialize(tag.getAsString());
|
||||
}
|
||||
@@ -1462,7 +1461,7 @@ public class ShapeDispatcher
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value decode(Tag tag)
|
||||
public Value decode(Tag tag, Level level)
|
||||
{
|
||||
return BooleanValue.of(((ByteTag) tag).getAsByte() > 0);
|
||||
}
|
||||
@@ -1471,7 +1470,7 @@ public class ShapeDispatcher
|
||||
{
|
||||
protected FloatParam(String id) { super(id); }
|
||||
@Override
|
||||
public Value decode(Tag tag) { return new NumericValue(((FloatTag)tag).getAsFloat()); }
|
||||
public Value decode(Tag tag, Level level) { return new NumericValue(((FloatTag)tag).getAsFloat()); }
|
||||
@Override
|
||||
public Tag toTag(Value value) { return FloatTag.valueOf(NumericValue.asNumber(value, id).getFloat()); }
|
||||
}
|
||||
@@ -1490,7 +1489,7 @@ public class ShapeDispatcher
|
||||
{
|
||||
protected PositiveFloatParam(String id) { super(id); }
|
||||
@Override
|
||||
public Value decode(Tag tag) { return new NumericValue(((FloatTag)tag).getAsFloat()); }
|
||||
public Value decode(Tag tag, Level level) { return new NumericValue(((FloatTag)tag).getAsFloat()); }
|
||||
@Override
|
||||
public Tag toTag(Value value) { return FloatTag.valueOf(NumericValue.asNumber(value, id).getFloat()); }
|
||||
|
||||
@@ -1499,7 +1498,7 @@ public class ShapeDispatcher
|
||||
{
|
||||
protected PositiveIntParam(String id) { super(id); }
|
||||
@Override
|
||||
public Value decode(Tag tag) { return new NumericValue(((IntTag)tag).getAsInt()); }
|
||||
public Value decode(Tag tag, Level level) { return new NumericValue(((IntTag)tag).getAsInt()); }
|
||||
@Override
|
||||
public Tag toTag(Value value) { return IntTag.valueOf(NumericValue.asNumber(value, id).getInt()); }
|
||||
|
||||
@@ -1508,7 +1507,7 @@ public class ShapeDispatcher
|
||||
{
|
||||
protected NonNegativeIntParam(String id) { super(id); }
|
||||
@Override
|
||||
public Value decode(Tag tag) { return new NumericValue(((IntTag)tag).getAsInt()); }
|
||||
public Value decode(Tag tag, Level level) { return new NumericValue(((IntTag)tag).getAsInt()); }
|
||||
@Override
|
||||
public Tag toTag(Value value) { return IntTag.valueOf(NumericValue.asNumber(value, id).getInt()); }
|
||||
@Override public Value validate(Map<String, Value> options, MinecraftServer server, Value value)
|
||||
@@ -1522,7 +1521,7 @@ public class ShapeDispatcher
|
||||
{
|
||||
protected NonNegativeFloatParam(String id) { super(id); }
|
||||
@Override
|
||||
public Value decode(Tag tag) { return new NumericValue(((FloatTag)tag).getAsFloat()); }
|
||||
public Value decode(Tag tag, Level level) { return new NumericValue(((FloatTag)tag).getAsFloat()); }
|
||||
@Override
|
||||
public Tag toTag(Value value) { return FloatTag.valueOf(NumericValue.asNumber(value, id).getFloat()); }
|
||||
@Override public Value validate(Map<String, Value> options, MinecraftServer server, Value value)
|
||||
@@ -1590,7 +1589,7 @@ public class ShapeDispatcher
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value decode(Tag tag)
|
||||
public Value decode(Tag tag, Level level)
|
||||
{
|
||||
ListTag ctag = (ListTag)tag;
|
||||
return ListValue.of(
|
||||
@@ -1629,7 +1628,7 @@ public class ShapeDispatcher
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value decode(Tag tag)
|
||||
public Value decode(Tag tag, Level level)
|
||||
{
|
||||
ListTag ltag = (ListTag)tag;
|
||||
List<Value> points = new ArrayList<>();
|
||||
@@ -1671,7 +1670,7 @@ public class ShapeDispatcher
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value decode(Tag tag) { return new NumericValue(((IntTag)tag).getAsInt()); }
|
||||
public Value decode(Tag tag, Level level) { return new NumericValue(((IntTag)tag).getAsInt()); }
|
||||
@Override
|
||||
public Tag toTag(Value value) { return IntTag.valueOf(NumericValue.asNumber(value, id).getInt()); }
|
||||
}
|
||||
@@ -1698,7 +1697,7 @@ public class ShapeDispatcher
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value decode(Tag tag) { return new NumericValue(((IntTag)tag).getAsInt()); }
|
||||
public Value decode(Tag tag, Level level) { return new NumericValue(((IntTag)tag).getAsInt()); }
|
||||
}
|
||||
|
||||
private static boolean isStraight(Vec3 from, Vec3 to, double density)
|
||||
|
||||
@@ -164,7 +164,7 @@ public class ShapesRenderer
|
||||
|
||||
public void addShape(CompoundTag tag)
|
||||
{
|
||||
ShapeDispatcher.ExpiringShape shape = ShapeDispatcher.fromTag(tag);
|
||||
ShapeDispatcher.ExpiringShape shape = ShapeDispatcher.fromTag(tag, client.level);
|
||||
if (shape == null) return;
|
||||
BiFunction<Minecraft, ShapeDispatcher.ExpiringShape, RenderedShape<? extends ShapeDispatcher.ExpiringShape >> shapeFactory;
|
||||
shapeFactory = renderedShapes.get(tag.getString("shape"));
|
||||
|
||||
@@ -44,7 +44,7 @@ public class SnoopyCommandSource extends CommandSourceStack
|
||||
{
|
||||
super(CommandSource.NULL, original.getPosition(), original.getRotation(), original.getLevel(), CarpetSettings.runPermissionLevel,
|
||||
original.getTextName(), original.getDisplayName(), original.getServer(), original.getEntity(), false,
|
||||
(ctx, succ, res) -> { }, EntityAnchorArgument.Anchor.FEET, CommandSigningContext.ANONYMOUS, TaskChainer.IMMEDIATE);
|
||||
(ctx, succ, res) -> { }, EntityAnchorArgument.Anchor.FEET, CommandSigningContext.ANONYMOUS, TaskChainer.immediate(original.getServer()));
|
||||
this.output = CommandSource.NULL;
|
||||
this.position = original.getPosition();
|
||||
this.world = original.getLevel();
|
||||
@@ -87,7 +87,7 @@ public class SnoopyCommandSource extends CommandSourceStack
|
||||
) {
|
||||
super(output, pos, rot, world, level,
|
||||
simpleName, name, server, entity, false,
|
||||
consumer, entityAnchor, context, TaskChainer.IMMEDIATE);
|
||||
consumer, entityAnchor, context, TaskChainer.immediate(server));
|
||||
this.output = output;
|
||||
this.position = pos;
|
||||
this.rotation = rot;
|
||||
|
||||
@@ -15,6 +15,7 @@ import carpet.script.value.StringValue;
|
||||
import carpet.script.value.Value;
|
||||
import carpet.script.value.ValueConversions;
|
||||
import carpet.api.settings.SettingsManager;
|
||||
import com.mojang.bridge.game.PackType;
|
||||
import com.sun.management.OperatingSystemMXBean;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
@@ -87,19 +88,19 @@ public class SystemInfo {
|
||||
put("game_view_distance", c -> new NumericValue(c.s.getServer().getPlayerList().getViewDistance()));
|
||||
put("game_mod_name", c -> StringValue.of(c.s.getServer().getServerModName()));
|
||||
put("game_version", c -> StringValue.of(c.s.getServer().getServerVersion()));
|
||||
put("game_target", c -> StringValue.of(SharedConstants.getCurrentVersion().getReleaseTarget()));
|
||||
put("game_target", c -> StringValue.of(CarpetSettings.releaseTarget));
|
||||
put("game_protocol", c -> NumericValue.of(SharedConstants.getProtocolVersion()));
|
||||
put("game_major_target", c -> {
|
||||
String [] vers = SharedConstants.getCurrentVersion().getReleaseTarget().split("\\.");
|
||||
String [] vers = CarpetSettings.releaseTarget.split("\\.");
|
||||
return NumericValue.of((vers.length > 1)?Integer.parseInt(vers[1]):0);
|
||||
});
|
||||
put("game_minor_target", c -> {
|
||||
String [] vers = SharedConstants.getCurrentVersion().getReleaseTarget().split("\\.");
|
||||
String [] vers = CarpetSettings.releaseTarget.split("\\.");
|
||||
return NumericValue.of((vers.length > 2)?Integer.parseInt(vers[2]):0);
|
||||
});
|
||||
put("game_stable", c -> BooleanValue.of(SharedConstants.getCurrentVersion().isStable()));
|
||||
put("game_data_version", c->NumericValue.of(SharedConstants.getCurrentVersion().getWorldVersion()));
|
||||
put("game_pack_version", c->NumericValue.of(SharedConstants.getCurrentVersion().getPackVersion()));
|
||||
put("game_pack_version", c->NumericValue.of(SharedConstants.getCurrentVersion().getPackVersion(PackType.DATA)));
|
||||
|
||||
put("server_ip", c -> StringValue.of(c.s.getServer().getLocalIp()));
|
||||
put("server_whitelisted", c -> BooleanValue.of(c.s.getServer().isEnforceWhitelist()));
|
||||
|
||||
Reference in new issue
Block a user