Merge branch 'master' into 1.16

# Conflicts:
#	src/main/java/carpet/script/utils/ShapeDispatcher.java
This commit is contained in:
gnembon committed 2020-07-18 17:03:20 -03:00
commit ca9f029996
3 files changed
+36

No files matched your search

@@ -20,6 +20,7 @@ import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.command.arguments.ParticleArgumentType;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.ByteTag;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.DoubleTag;
import net.minecraft.nbt.FloatTag;
@@ -404,6 +405,7 @@ public class ShapeDispatcher
put("align", new StringValue("center")).
put("size", new NumericValue(10)).
put("value", Value.NULL).
put("doublesided", new NumericValue(0)).
build();
@Override
protected Set<String> requiredParams() { return Sets.union(super.requiredParams(), required); }
@@ -424,6 +426,7 @@ public class ShapeDispatcher
int align;
float height;
Text value;
boolean doublesided;
@Override
protected void init(Map<String, Value> options)
@@ -458,6 +461,11 @@ public class ShapeDispatcher
else
align = -1;
}
doublesided = false;
if (options.containsKey("doublesided"))
{
doublesided = options.get("doublesided").getBoolean();
}
raise = NumericValue.asNumber(options.getOrDefault("raise", optional.get("raise"))).getFloat();
tilt = NumericValue.asNumber(options.getOrDefault("tilt", optional.get("tilt"))).getFloat();
@@ -497,6 +505,7 @@ public class ShapeDispatcher
hash ^= Float.hashCode(height); hash *= 1099511628211L;
hash ^= Float.hashCode(size); hash *= 1099511628211L;
hash ^= Integer.hashCode(align); hash *= 1099511628211L;
hash ^= Boolean.hashCode(doublesided); hash *= 1099511628211L;
return hash;
}
@@ -843,6 +852,7 @@ public class ShapeDispatcher
put("raise", new FloatParam("raise"));
put("tilt", new FloatParam("tilt"));
put("facing", new StringChoiceParam("axis", "player", "north", "south", "east", "west", "up", "down"));
put("doublesided", new BoolParam("doublesided"));
}};
protected String id;
@@ -957,6 +967,25 @@ public class ShapeDispatcher
return value;
}
}
public static class BoolParam extends NumericParam
{
protected BoolParam(String id)
{
super(id);
}
@Override
public Tag toTag(Value value)
{
return ByteTag.of(value.getBoolean());
}
@Override
public Value decode(Tag tag)
{
return new NumericValue(((ByteTag) tag).getByte() > 0);
}
}
public static class FloatParam extends NumericParam
{
protected FloatParam(String id) { super(id); }
@@ -209,6 +209,10 @@ public class ShapesRenderer
double d = camera1.getPos().x;
double e = camera1.getPos().y;
double f = camera1.getPos().z;
if (shape.doublesided)
RenderSystem.disableCull();
else
RenderSystem.enableCull();
RenderSystem.pushMatrix();
RenderSystem.translatef((float)(v1.x - d), (float)(v1.y - e), (float)(v1.z - f));
RenderSystem.normal3f(0.0F, 1.0F, 0.0F);
@@ -262,6 +266,8 @@ public class ShapesRenderer
textRenderer.draw(shape.value, text_x, 0.0F, shape.textcolor, false, AffineTransformation.identity().getMatrix(), immediate, false, shape.textbck, 15728880);
immediate.draw();
RenderSystem.popMatrix();
if (shape.doublesided)
RenderSystem.enableCull();
}
}