25w09a, broken shapes
This commit is contained in:
1 parent
1928b4f866
commit
9a62566b2a
9 files changed
+81
-80
No files matched your search
@@ -238,7 +238,7 @@ public class ShapeDispatcher
|
||||
public static ExpiringShape fromTag(CompoundTag tag, Level level)
|
||||
{
|
||||
Map<String, Value> options = new HashMap<>();
|
||||
for (String key : tag.getAllKeys())
|
||||
for (String key : tag.keySet())
|
||||
{
|
||||
Param decoder = Param.of.get(key);
|
||||
if (decoder == null)
|
||||
@@ -252,7 +252,7 @@ public class ShapeDispatcher
|
||||
Value shapeValue = options.get("shape");
|
||||
if (shapeValue == null)
|
||||
{
|
||||
CarpetScriptServer.LOG.info("Shape id missing in " + String.join(", ", tag.getAllKeys()));
|
||||
CarpetScriptServer.LOG.info("Shape id missing in " + String.join(", ", tag.keySet()));
|
||||
return null;
|
||||
}
|
||||
BiFunction<Map<String, Value>, RegistryAccess, ExpiringShape> factory = ExpiringShape.shapeProviders.get(shapeValue.getString());
|
||||
@@ -1559,11 +1559,11 @@ public class ShapeDispatcher
|
||||
{
|
||||
if (tag instanceof final ListTag list)
|
||||
{
|
||||
return ListValue.wrap(list.stream().map(x -> BooleanValue.of(((NumericTag) x).getAsNumber().doubleValue() != 0)));
|
||||
return ListValue.wrap(list.stream().map(x -> BooleanValue.of(((NumericTag) x).doubleValue() != 0)));
|
||||
}
|
||||
if (tag instanceof final ByteTag booltag)
|
||||
{
|
||||
return BooleanValue.of(booltag.getAsByte() != 0);
|
||||
return BooleanValue.of(booltag.byteValue() != 0);
|
||||
}
|
||||
return Value.NULL;
|
||||
}
|
||||
@@ -1599,7 +1599,7 @@ public class ShapeDispatcher
|
||||
@Override
|
||||
public Value decode(Tag tag, Level level)
|
||||
{
|
||||
return new StringValue(tag.getAsString());
|
||||
return new StringValue(tag.asString().get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1643,9 +1643,9 @@ public class ShapeDispatcher
|
||||
{
|
||||
BlockState bs = NbtUtils.readBlockState(level.holderLookup(Registries.BLOCK), (CompoundTag) tag);
|
||||
CompoundTag compoundTag2 = null;
|
||||
if (((CompoundTag) tag).contains("TileEntityData", 10))
|
||||
if (((CompoundTag) tag).contains("TileEntityData"))
|
||||
{
|
||||
compoundTag2 = ((CompoundTag) tag).getCompound("TileEntityData");
|
||||
compoundTag2 = ((CompoundTag) tag).getCompound("TileEntityData").get();
|
||||
}
|
||||
return new BlockValue(bs, compoundTag2);
|
||||
}
|
||||
@@ -1724,7 +1724,7 @@ public class ShapeDispatcher
|
||||
@Override
|
||||
public Value decode(Tag tag, Level level)
|
||||
{
|
||||
return FormattedTextValue.deserialize(tag.getAsString(), level.registryAccess());
|
||||
return FormattedTextValue.deserialize(tag.asString().get(), level.registryAccess());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1818,7 +1818,7 @@ public class ShapeDispatcher
|
||||
@Override
|
||||
public Value decode(Tag tag, Level level)
|
||||
{
|
||||
return BooleanValue.of(((ByteTag) tag).getAsByte() > 0);
|
||||
return BooleanValue.of(((ByteTag) tag).byteValue() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1832,7 +1832,7 @@ public class ShapeDispatcher
|
||||
@Override
|
||||
public Value decode(Tag tag, Level level)
|
||||
{
|
||||
return new NumericValue(((FloatTag) tag).getAsFloat());
|
||||
return new NumericValue(((FloatTag) tag).floatValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1871,7 +1871,7 @@ public class ShapeDispatcher
|
||||
@Override
|
||||
public Value decode(Tag tag, Level level)
|
||||
{
|
||||
return new NumericValue(((FloatTag) tag).getAsFloat());
|
||||
return new NumericValue(((FloatTag) tag).floatValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1892,7 +1892,7 @@ public class ShapeDispatcher
|
||||
@Override
|
||||
public Value decode(Tag tag, Level level)
|
||||
{
|
||||
return new NumericValue(((IntTag) tag).getAsInt());
|
||||
return new NumericValue(((IntTag) tag).intValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1913,7 +1913,7 @@ public class ShapeDispatcher
|
||||
@Override
|
||||
public Value decode(Tag tag, Level level)
|
||||
{
|
||||
return new NumericValue(((IntTag) tag).getAsInt());
|
||||
return new NumericValue(((IntTag) tag).intValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1944,7 +1944,7 @@ public class ShapeDispatcher
|
||||
@Override
|
||||
public Value decode(Tag tag, Level level)
|
||||
{
|
||||
return new NumericValue(((FloatTag) tag).getAsFloat());
|
||||
return new NumericValue(((FloatTag) tag).floatValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2036,9 +2036,9 @@ public class ShapeDispatcher
|
||||
{
|
||||
ListTag ctag = (ListTag) tag;
|
||||
return ListValue.of(
|
||||
new NumericValue(ctag.getDouble(0)),
|
||||
new NumericValue(ctag.getDouble(1)),
|
||||
new NumericValue(ctag.getDouble(2))
|
||||
new NumericValue(ctag.getDouble(0).orElseThrow()),
|
||||
new NumericValue(ctag.getDouble(1).orElseThrow()),
|
||||
new NumericValue(ctag.getDouble(2).orElseThrow())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2083,11 +2083,11 @@ public class ShapeDispatcher
|
||||
List<Value> points = new ArrayList<>();
|
||||
for (int i = 0, ll = ltag.size(); i < ll; i++)
|
||||
{
|
||||
ListTag ptag = ltag.getList(i);
|
||||
ListTag ptag = ltag.getList(i).orElseThrow();
|
||||
points.add(ListValue.of(
|
||||
new NumericValue(ptag.getDouble(0)),
|
||||
new NumericValue(ptag.getDouble(1)),
|
||||
new NumericValue(ptag.getDouble(2))
|
||||
new NumericValue(ptag.getDouble(0).orElseThrow()),
|
||||
new NumericValue(ptag.getDouble(1).orElseThrow()),
|
||||
new NumericValue(ptag.getDouble(2).orElseThrow())
|
||||
));
|
||||
}
|
||||
return ListValue.wrap(points);
|
||||
@@ -2122,7 +2122,7 @@ public class ShapeDispatcher
|
||||
@Override
|
||||
public Value decode(Tag tag, Level level)
|
||||
{
|
||||
return new NumericValue(((IntTag) tag).getAsInt());
|
||||
return new NumericValue(((IntTag) tag).intValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2164,7 +2164,7 @@ public class ShapeDispatcher
|
||||
@Override
|
||||
public Value decode(Tag tag, Level level)
|
||||
{
|
||||
return new NumericValue(((IntTag) tag).getAsInt());
|
||||
return new NumericValue(((IntTag) tag).intValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.MeshData;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import com.mojang.blaze3d.vertex.VertexBuffer;
|
||||
//import com.mojang.blaze3d.vertex.VertexBuffer;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat.Mode;
|
||||
import com.mojang.math.Axis;
|
||||
@@ -120,18 +120,18 @@ public class ShapesRenderer
|
||||
return;
|
||||
}
|
||||
long currentTime = client.level.getGameTime();
|
||||
RenderSystem.enableDepthTest();
|
||||
////RenderSystem.enableDepthTest();
|
||||
//RenderSystem.setShader(CoreShaders.POSITION_COLOR);
|
||||
RenderSystem.depthFunc(515);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
////RenderSystem.depthFunc(515);
|
||||
////RenderSystem.enableBlend();
|
||||
////RenderSystem.defaultBlendFunc();
|
||||
// too bright
|
||||
//RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO);
|
||||
// meh
|
||||
//RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
RenderSystem.disableCull();
|
||||
RenderSystem.depthMask(false);
|
||||
////RenderSystem.disableCull();
|
||||
////RenderSystem.depthMask(false);
|
||||
//RenderSystem.polygonOffset(-3f, -3f);
|
||||
//RenderSystem.enablePolygonOffset();
|
||||
|
||||
@@ -184,10 +184,10 @@ public class ShapesRenderer
|
||||
}
|
||||
});
|
||||
}
|
||||
RenderSystem.enableCull();
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
////RenderSystem.enableCull();
|
||||
////RenderSystem.depthMask(true);
|
||||
////RenderSystem.enableBlend();
|
||||
////RenderSystem.defaultBlendFunc();
|
||||
token.run();
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ public class ShapesRenderer
|
||||
Runnable token = Carpet.startProfilerSection("Scarpet client");
|
||||
for (int i = 0, count = tag.size(); i < count; i++)
|
||||
{
|
||||
addShape(tag.getCompound(i));
|
||||
addShape(tag.getCompound(i).orElseThrow());
|
||||
}
|
||||
token.run();
|
||||
}
|
||||
@@ -209,7 +209,7 @@ public class ShapesRenderer
|
||||
return;
|
||||
}
|
||||
BiFunction<Minecraft, ShapeDispatcher.ExpiringShape, RenderedShape<? extends ShapeDispatcher.ExpiringShape>> shapeFactory;
|
||||
shapeFactory = renderedShapes.get(tag.getString("shape"));
|
||||
shapeFactory = renderedShapes.get(tag.getString("shape").orElseThrow());
|
||||
if (shapeFactory == null)
|
||||
{
|
||||
CarpetScriptServer.LOG.info("Unrecognized shape: " + tag.getString("shape"));
|
||||
@@ -373,9 +373,9 @@ public class ShapesRenderer
|
||||
matrices.mulPose(Axis.YP.rotationDegrees(180));
|
||||
}
|
||||
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.enableCull();
|
||||
RenderSystem.enableDepthTest();
|
||||
////RenderSystem.depthMask(true);
|
||||
////RenderSystem.enableCull();
|
||||
////RenderSystem.enableDepthTest();
|
||||
|
||||
blockPos = BlockPos.containing(v1);
|
||||
int light = 0;
|
||||
@@ -409,7 +409,7 @@ public class ShapesRenderer
|
||||
} else {
|
||||
type = ItemBlockRenderTypes.getRenderType(blockState);
|
||||
}
|
||||
client.getBlockRenderer().getModelRenderer().renderModel(matrices.last(), immediate.getBuffer(type), blockState, bakedModel, red, green, blue, light, OverlayTexture.NO_OVERLAY);
|
||||
client.getBlockRenderer().getModelRenderer().renderModel(matrices.last(), immediate.getBuffer(type), bakedModel, red, green, blue, light, OverlayTexture.NO_OVERLAY);
|
||||
}
|
||||
|
||||
// draw the block`s entity part
|
||||
@@ -450,9 +450,9 @@ public class ShapesRenderer
|
||||
}
|
||||
matrices.popPose();
|
||||
immediate.endBatch();
|
||||
RenderSystem.disableCull();
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.depthMask(false);
|
||||
////RenderSystem.disableCull();
|
||||
////RenderSystem.disableDepthTest();
|
||||
////RenderSystem.depthMask(false);
|
||||
|
||||
}
|
||||
|
||||
@@ -484,11 +484,11 @@ public class ShapesRenderer
|
||||
Font textRenderer = client.font;
|
||||
if (shape.doublesided)
|
||||
{
|
||||
RenderSystem.disableCull();
|
||||
//// RenderSystem.disableCull(); TODO culling
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderSystem.enableCull();
|
||||
//// RenderSystem.enableCull();
|
||||
}
|
||||
matrices.pushPose();
|
||||
matrices.translate(v1.x - cx, v1.y - cy, v1.z - cz);
|
||||
@@ -527,7 +527,7 @@ public class ShapesRenderer
|
||||
textRenderer.drawInBatch(shape.value, text_x, 0.0F, shape.textcolor, false, matrices.last().pose(), immediate, Font.DisplayMode.NORMAL, shape.textbck, 15728880);
|
||||
immediate.endBatch();
|
||||
matrices.popPose();
|
||||
RenderSystem.enableCull();
|
||||
////RenderSystem.enableCull();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -617,7 +617,7 @@ public class ShapesRenderer
|
||||
}
|
||||
|
||||
private static void drawWithShader(MeshData mesh) {
|
||||
RenderType.debugTriangleFan().draw(mesh);
|
||||
RenderType.debugLineStrip(1.0).draw(mesh);
|
||||
//VertexBuffer buffre = mesh.drawState().format().getImmediateDrawVertexBuffer();
|
||||
//buffre.bind();
|
||||
//buffre.upload(mesh);
|
||||
@@ -645,11 +645,11 @@ public class ShapesRenderer
|
||||
|
||||
if (shape.doublesided)
|
||||
{
|
||||
RenderSystem.disableCull();
|
||||
////RenderSystem.disableCull(); // todo culling
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderSystem.enableCull();
|
||||
////RenderSystem.enableCull();
|
||||
}
|
||||
|
||||
BufferBuilder builder = tesselator.begin(faceIndices[shape.mode], DefaultVertexFormat.POSITION_COLOR);
|
||||
@@ -664,8 +664,8 @@ public class ShapesRenderer
|
||||
}
|
||||
drawWithShader(builder.buildOrThrow());
|
||||
|
||||
RenderSystem.disableCull();
|
||||
RenderSystem.depthMask(false);
|
||||
////RenderSystem.disableCull();
|
||||
////RenderSystem.depthMask(false);
|
||||
//RenderSystem.enableDepthTest();
|
||||
|
||||
|
||||
|
||||
@@ -587,13 +587,13 @@ public class ListValue extends AbstractListValue implements ContainerValueInterf
|
||||
{
|
||||
throw new NBTSerializableValue.IncompatibleTypeException(this);
|
||||
}
|
||||
tags.forEach(t -> tag.add(StringTag.valueOf(t.getAsString())));
|
||||
tags.forEach(t -> tag.add(StringTag.valueOf(t.asString().orElseThrow())));
|
||||
return tag;
|
||||
}
|
||||
// only numbers / mixed types
|
||||
tags.forEach(cases.contains(TagTypeCompat.DBL)
|
||||
? (t -> tag.add(DoubleTag.valueOf(((NumericTag) t).getAsDouble())))
|
||||
: (t -> tag.add(LongTag.valueOf(((NumericTag) t).getAsLong()))));
|
||||
? (t -> tag.add(DoubleTag.valueOf(((NumericTag) t).doubleValue())))
|
||||
: (t -> tag.add(LongTag.valueOf(((NumericTag) t).longValue()))));
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
|
||||
private Tag nbtTag = null;
|
||||
private Supplier<Tag> nbtSupplier = null;
|
||||
private boolean owned = false;
|
||||
private static TagParser<Tag> tagParser = TagParser.create(NbtOps.INSTANCE);
|
||||
|
||||
private NBTSerializableValue()
|
||||
{
|
||||
@@ -75,7 +76,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
|
||||
{
|
||||
try
|
||||
{
|
||||
return TagParser.parseAsArgument(NbtOps.INSTANCE, new StringReader(nbtString));
|
||||
return tagParser.parseAsArgument( new StringReader(nbtString));
|
||||
}
|
||||
catch (CommandSyntaxException e)
|
||||
{
|
||||
@@ -128,7 +129,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
|
||||
{
|
||||
try
|
||||
{
|
||||
Tag tag = TagParser.parseAsArgument(NbtOps.INSTANCE, new StringReader(nbtString));
|
||||
Tag tag = tagParser.parseAsArgument(new StringReader(nbtString));
|
||||
NBTSerializableValue value = new NBTSerializableValue(tag);
|
||||
value.nbtString = null;
|
||||
return value;
|
||||
@@ -386,11 +387,11 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
|
||||
if (t instanceof final NumericTag number)
|
||||
{
|
||||
// short and byte will never exceed float's precision, even int won't
|
||||
return t instanceof LongTag || t instanceof IntTag ? NumericValue.of(number.getAsLong()) : NumericValue.of(number.getAsNumber());
|
||||
return t instanceof LongTag || t instanceof IntTag ? NumericValue.of(number.longValue()) : NumericValue.of(number.asNumber().orElseThrow());
|
||||
}
|
||||
if (t instanceof StringTag)
|
||||
if (t instanceof StringTag stringTag)
|
||||
{
|
||||
return StringValue.of(t.getAsString());
|
||||
return StringValue.of(stringTag.value());
|
||||
}
|
||||
if (t instanceof EndTag)
|
||||
{
|
||||
@@ -409,13 +410,13 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
|
||||
if (t instanceof final CompoundTag ctag)
|
||||
{
|
||||
Map<Value, Value> pairs = new HashMap<>();
|
||||
for (String key : ctag.getAllKeys())
|
||||
for (String key : ctag.keySet())
|
||||
{
|
||||
pairs.put(new StringValue(key), decodeTagDeep(ctag.get(key)));
|
||||
}
|
||||
return MapValue.wrap(pairs);
|
||||
}
|
||||
if (t instanceof final CollectionTag<?> ltag)
|
||||
if (t instanceof final CollectionTag ltag)
|
||||
{
|
||||
List<Value> elems = new ArrayList<>();
|
||||
for (Tag elem : ltag)
|
||||
@@ -478,17 +479,17 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
|
||||
{
|
||||
return !(ctag).isEmpty();
|
||||
}
|
||||
if (tag instanceof final CollectionTag<?> ltag)
|
||||
if (tag instanceof final CollectionTag ltag)
|
||||
{
|
||||
return !(ltag).isEmpty();
|
||||
}
|
||||
if (tag instanceof final NumericTag number)
|
||||
{
|
||||
return number.getAsDouble() != 0.0;
|
||||
return number.doubleValue() != 0.0;
|
||||
}
|
||||
if (tag instanceof StringTag)
|
||||
if (tag instanceof StringTag st)
|
||||
{
|
||||
return !tag.getAsString().isEmpty();
|
||||
return !st.value().isEmpty();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -570,7 +571,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
|
||||
boolean modified = false;
|
||||
for (Tag target : targets)
|
||||
{
|
||||
if (!(target instanceof final CollectionTag<?> targetList))
|
||||
if (!(target instanceof final CollectionTag targetList))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user