Merge branch 'master' into 1.16
# Conflicts: # src/main/java/carpet/script/utils/ShapeDispatcher.java
This commit is contained in:
commit
ca9f029996
3 files changed
+36
No files matched your search
@@ -96,6 +96,7 @@ Available shapes:
|
||||
* `size` - float. Default font size is 10.
|
||||
* `facing` - text direction, where its facing. Possible options are: `player` (default, text
|
||||
always rotates to face the player), `north`, `south`, `east`, `west`, `up`, `down`
|
||||
* `doublesided` - if `true` it will make the text visible from the back as well. Default is `false`
|
||||
* `align` - text alignment with regards to `pos`. Default is `center` (displayed text is
|
||||
centered with respect to `pos`), `left` (`pos` indicates beginning of text), and `right` (`pos`
|
||||
indicates the end of text).
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user