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); }