cleanup and tilt-lean fixes for new shapes
This commit is contained in:
1 parent
179f5a6006
commit
36aff8f9d3
3 files changed
+193
-195
No files matched your search
@@ -91,7 +91,7 @@ Optional shared shape attributes:
|
|||||||
value is `'xyz'`, meaning the shape will be drawn relatively to the entity in all three directions. Using `xz` for
|
value is `'xyz'`, meaning the shape will be drawn relatively to the entity in all three directions. Using `xz` for
|
||||||
instance makes so that the shape follows the entity, but stays at the same, absolute Y coordinate. Preceeding an axis
|
instance makes so that the shape follows the entity, but stays at the same, absolute Y coordinate. Preceeding an axis
|
||||||
with `d`, like `dxdydz` would make so that entity position is treated discretely (rounded down).
|
with `d`, like `dxdydz` would make so that entity position is treated discretely (rounded down).
|
||||||
* `toggleable` - if True, can toggle visibility by using F3+B. just like entities' hitbox.
|
* `debug` - if True, it will only be visible when F3+B entity bounding boxes is enabled.
|
||||||
|
|
||||||
Available shapes:
|
Available shapes:
|
||||||
* `'line'` - draws a straight line between two points.
|
* `'line'` - draws a straight line between two points.
|
||||||
@@ -99,28 +99,6 @@ Available shapes:
|
|||||||
* `from` - triple coordinates, entity, or block value indicating one end of the line
|
* `from` - triple coordinates, entity, or block value indicating one end of the line
|
||||||
* `to` - other end of the line, same format as `from`
|
* `to` - other end of the line, same format as `from`
|
||||||
|
|
||||||
* `'label'` - draws a text in the world. Default `line` attribute controls main font color.
|
|
||||||
`fill` controls the color of the background.
|
|
||||||
* Required attributes:
|
|
||||||
* `pos` - position
|
|
||||||
* `text` - string or formatted text to display
|
|
||||||
* Optional attributes
|
|
||||||
* `value` - string or formatted text to display instead of the main `text`. `value` unlike `text`
|
|
||||||
is not used to determine uniqueness of the drawn text so can be used to
|
|
||||||
display smoothly dynamic elements where value of an element is constantly
|
|
||||||
changing and updates to it are being sent from the server.
|
|
||||||
* `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` (1.16+)
|
|
||||||
* `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).
|
|
||||||
* `tilt`, `lean`, `turn` - additional rotations of the text on the canvas along all three axis
|
|
||||||
* `indent`, `height`, `raise` - offsets for text rendering on X (`indent`), Y (`height`), and Z axis (`raise`)
|
|
||||||
with regards to the plane of the text. One unit of these corresponds to 1 line spacing, which
|
|
||||||
can be used to display multiple lines of text bound to the same `pos`
|
|
||||||
|
|
||||||
* `'box'` - draws a box with corners in specified points
|
* `'box'` - draws a box with corners in specified points
|
||||||
* Required attributes:
|
* Required attributes:
|
||||||
* `from` - triple coordinates, entity, or block value indicating one corner of the box
|
* `from` - triple coordinates, entity, or block value indicating one corner of the box
|
||||||
@@ -152,20 +130,52 @@ Available shapes:
|
|||||||
* `inner` - if `true` it will make the inner edges be drawn as well.
|
* `inner` - if `true` it will make the inner edges be drawn as well.
|
||||||
* `doublesided` - if `true` it will make the shapes visible from the back as well. Default is `true`.
|
* `doublesided` - if `true` it will make the shapes visible from the back as well. Default is `true`.
|
||||||
|
|
||||||
* `'block'` \ `'item'`:
|
* `'label'` - draws a text in the world. Default `line` attribute controls main font color.
|
||||||
|
`fill` controls the color of the background.
|
||||||
|
* Required attributes:
|
||||||
|
* `pos` - position
|
||||||
|
* `text` - string or formatted text to display
|
||||||
|
* Optional attributes
|
||||||
|
* `value` - string or formatted text to display instead of the main `text`. `value` unlike `text`
|
||||||
|
is not used to determine uniqueness of the drawn text so can be used to
|
||||||
|
display smoothly dynamic elements where value of an element is constantly
|
||||||
|
changing and updates to it are being sent from the server.
|
||||||
|
* `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` (1.16+)
|
||||||
|
* `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).
|
||||||
|
* `tilt`, `lean`, `turn` - additional rotations of the text on the canvas along all three axis
|
||||||
|
* `indent`, `height`, `raise` - offsets for text rendering on X (`indent`), Y (`height`), and Z axis (`raise`)
|
||||||
|
with regards to the plane of the text. One unit of these corresponds to 1 line spacing, which
|
||||||
|
can be used to display multiple lines of text bound to the same `pos`
|
||||||
|
|
||||||
|
* `'block'`: draws a block at the specified position:
|
||||||
* Required attributes:
|
* Required attributes:
|
||||||
* `pos` - position of the object.
|
* `pos` - position of the object.
|
||||||
* `item` - the object to show. could have NBT. is a item tuple or a string-id (exclusive to `'item'`)
|
* `block` - the object to show. It is a block value or a name of a block with optional NBT data.
|
||||||
* `block` - the object to show. could have NBT. is a block value or a string-id (exclusive to `'block'`)
|
|
||||||
* Optional attributes:
|
* Optional attributes:
|
||||||
* `facing` - object's direction, where its facing. Possible options are: `player` (it
|
* `facing` - object's direction, where its facing. Possible options are: `player` (it
|
||||||
always rotates to face the player), `north`(default), `south`, `east`, `west`, `up`, `down`
|
rotates to face the player), `north`(default), `south`, `east`, `west`, `up`, `down`
|
||||||
|
* `tilt`, `lean`, `turn` - additional rotations along all three axis. It uses the block center as the origin.
|
||||||
|
* `scale` - scale of it in 3 axis-direction. should be a number or a list of 3 numbers (x,y,z).
|
||||||
|
* `skylight`, `blocklight` - light level. omit it to use local light level. should between 0~15.
|
||||||
|
|
||||||
|
* `'item'`: draws an item at the specified position:
|
||||||
|
* Required attributes:
|
||||||
|
* `pos` - position of the object.
|
||||||
|
* `item` - the object to show. It is an item tuple or a string identified item that may have NBT data.
|
||||||
|
* Optional attributes:
|
||||||
|
* `facing` - object's direction, where its facing. Possible options are: `player` (it
|
||||||
|
always rotates to face the player), `north`(default), `south`, `east`, `west`, `up`, `down`
|
||||||
* `tilt`, `lean`, `turn` - additional rotations along all three axis. for `block`, it use its block center as the origin.
|
* `tilt`, `lean`, `turn` - additional rotations along all three axis. for `block`, it use its block center as the origin.
|
||||||
* `scale` - scale of it in 3 axis-direction. should be a number or a list of 3 numbers (x,y,z).
|
* `scale` - scale of it in 3 axis-direction. should be a number or a list of 3 numbers (x,y,z).
|
||||||
* `skylight`, `blocklight` - light level. omit it to use local light level. should between 0~15.
|
* `skylight`, `blocklight` - light level. omit it to use local light level. should between 0~15.
|
||||||
* `variant` - one of "none","third_person_left_hand","third_person_right_hand","first_person_left_hand",
|
* `variant` - one of `'none'`, `'third_person_left_hand'`, `'third_person_right_hand'`, `'first_person_left_hand'`,
|
||||||
"first_person_right_hand","head","gui","ground","fixed". In addition to the literal meaning, it can also be used to use special models of tridents and telescopes. (exclusive to `'item'`)
|
`'first_person_right_hand'`, `'head'`, `'gui'`, `'ground'`, `'fixed'`. In addition to the literal meaning,
|
||||||
|
it can also be used to use special models of tridents and telescopes.
|
||||||
|
|
||||||
|
|
||||||
### `create_marker(text, pos, rotation?, block?, interactive?)`
|
### `create_marker(text, pos, rotation?, block?, interactive?)`
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import net.minecraft.nbt.DoubleTag;
|
|||||||
import net.minecraft.nbt.FloatTag;
|
import net.minecraft.nbt.FloatTag;
|
||||||
import net.minecraft.nbt.IntTag;
|
import net.minecraft.nbt.IntTag;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.ListTag;
|
||||||
import net.minecraft.nbt.NbtIo;
|
|
||||||
import net.minecraft.nbt.NbtUtils;
|
import net.minecraft.nbt.NbtUtils;
|
||||||
import net.minecraft.nbt.StringTag;
|
import net.minecraft.nbt.StringTag;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
@@ -289,7 +288,7 @@ public class ShapeDispatcher
|
|||||||
protected boolean snapX, snapY, snapZ;
|
protected boolean snapX, snapY, snapZ;
|
||||||
protected boolean discreteX, discreteY, discreteZ;
|
protected boolean discreteX, discreteY, discreteZ;
|
||||||
protected ResourceKey<Level> shapeDimension;
|
protected ResourceKey<Level> shapeDimension;
|
||||||
protected boolean needf3b;
|
protected boolean debug;
|
||||||
|
|
||||||
|
|
||||||
protected ExpiringShape() { }
|
protected ExpiringShape() { }
|
||||||
@@ -341,9 +340,9 @@ public class ShapeDispatcher
|
|||||||
this.b = (float)(color >> 8 & 0xFF) / 255.0F;
|
this.b = (float)(color >> 8 & 0xFF) / 255.0F;
|
||||||
this.a = (float)(color & 0xFF) / 255.0F;
|
this.a = (float)(color & 0xFF) / 255.0F;
|
||||||
|
|
||||||
needf3b = false;
|
debug = false;
|
||||||
if (options.containsKey("toggleable")) {
|
if (options.containsKey("debug")) {
|
||||||
needf3b = options.get("toggleable").getBoolean();
|
debug = options.get("debug").getBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
key = 0;
|
key = 0;
|
||||||
@@ -410,7 +409,7 @@ public class ShapeDispatcher
|
|||||||
hash ^= shapeDimension.hashCode(); hash *= 1099511628211L;
|
hash ^= shapeDimension.hashCode(); hash *= 1099511628211L;
|
||||||
hash ^= color; hash *= 1099511628211L;
|
hash ^= color; hash *= 1099511628211L;
|
||||||
hash ^= followEntity; hash *= 1099511628211L;
|
hash ^= followEntity; hash *= 1099511628211L;
|
||||||
hash ^= Boolean.hashCode(needf3b); hash *= 1099511628211L;
|
hash ^= Boolean.hashCode(debug); hash *= 1099511628211L;
|
||||||
if (followEntity >= 0)
|
if (followEntity >= 0)
|
||||||
{
|
{
|
||||||
hash ^= snapTo.hashCode(); hash *= 1099511628211L;
|
hash ^= snapTo.hashCode(); hash *= 1099511628211L;
|
||||||
@@ -433,7 +432,7 @@ public class ShapeDispatcher
|
|||||||
"color", new NumericValue(-1),
|
"color", new NumericValue(-1),
|
||||||
"follow", new NumericValue(-1),
|
"follow", new NumericValue(-1),
|
||||||
"line", new NumericValue(2.0),
|
"line", new NumericValue(2.0),
|
||||||
"toggleable", Value.FALSE,
|
"debug", Value.FALSE,
|
||||||
"fill", new NumericValue(0xffffff00),
|
"fill", new NumericValue(0xffffff00),
|
||||||
"snap", new StringValue("xyz")
|
"snap", new StringValue("xyz")
|
||||||
);
|
);
|
||||||
@@ -585,16 +584,13 @@ public class ShapeDispatcher
|
|||||||
private boolean isitem;
|
private boolean isitem;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Set<String> requiredParams() {
|
protected Set<String> requiredParams() { return Sets.union(Sets.union(super.requiredParams(), required), Set.of(isitem ? "item" : "block"));}
|
||||||
return Sets.union(Sets.union(super.requiredParams(), required), Set.of(isitem ? "item" : "block"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Set<String> optionalParams() {
|
protected Set<String> optionalParams() { return Sets.union(Sets.union(super.optionalParams(), optional.keySet()),isitem ? Set.of("variant") : Set.of()); }
|
||||||
return Sets.union(Sets.union(super.optionalParams(), optional.keySet()),isitem ? Set.of("variant") : Set.of());
|
|
||||||
}
|
|
||||||
|
|
||||||
public DisplayedSprite(boolean i) {
|
public DisplayedSprite(boolean i)
|
||||||
|
{
|
||||||
isitem = i;
|
isitem = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -605,80 +601,81 @@ public class ShapeDispatcher
|
|||||||
float tilt;
|
float tilt;
|
||||||
float lean;
|
float lean;
|
||||||
float turn;
|
float turn;
|
||||||
float scale_z = 1.0f;
|
|
||||||
int light_fromblock;
|
|
||||||
int light_fromsky;
|
|
||||||
|
|
||||||
float scale_y = 1.0f;
|
int blockLight;
|
||||||
float scale_x = 1.0f;
|
int skyLight;
|
||||||
|
|
||||||
|
float scaleX = 1.0f;
|
||||||
|
float scaleY = 1.0f;
|
||||||
|
float scaleZ = 1.0f;
|
||||||
CompoundTag blockEntity;
|
CompoundTag blockEntity;
|
||||||
BlockState blockState;
|
BlockState blockState;
|
||||||
ItemStack item = null;
|
ItemStack item = null;
|
||||||
TransformType item_transform_type;
|
String itemTransformType;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init(Map<String, Value> options) {
|
protected void init(Map<String, Value> options)
|
||||||
|
{
|
||||||
super.init(options);
|
super.init(options);
|
||||||
pos = vecFromValue(options.get("pos"));
|
pos = vecFromValue(options.get("pos"));
|
||||||
if(!this.isitem){
|
if (!this.isitem)
|
||||||
blockState = ((BlockValue) options.get("block")).getBlockState();
|
{
|
||||||
blockEntity = ((BlockValue) options.get("block")).getData();
|
final BlockValue block = (BlockValue)options.get("block");
|
||||||
}else{
|
blockState = block.getBlockState();
|
||||||
|
blockEntity = block.getData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
this.item = ItemStack.of(((NBTSerializableValue) options.get("item")).getCompoundTag());
|
this.item = ItemStack.of(((NBTSerializableValue) options.get("item")).getCompoundTag());
|
||||||
}
|
}
|
||||||
light_fromblock = NumericValue
|
blockLight = NumericValue.asNumber(options.getOrDefault("blocklight", optional.get("blocklight"))).getInt();
|
||||||
.asNumber(options.getOrDefault("blocklight", optional.get("blocklight"))).getInt();
|
if (blockLight > 15) blockLight = 15;
|
||||||
if (light_fromblock > 15)
|
skyLight = NumericValue.asNumber(options.getOrDefault("skylight", optional.get("skylight"))).getInt();
|
||||||
light_fromblock = 15;
|
if (skyLight > 15) skyLight = 15;
|
||||||
light_fromsky = NumericValue.asNumber(options.getOrDefault("skylight", optional.get("skylight")))
|
|
||||||
.getInt();
|
|
||||||
if (light_fromsky > 15)
|
|
||||||
light_fromsky = 15;
|
|
||||||
|
|
||||||
item_transform_type = TransformType.NONE;
|
itemTransformType = "none";
|
||||||
if(options.containsKey("variant")){
|
if (options.containsKey("variant"))
|
||||||
item_transform_type = TransformType.valueOf(options.get("variant").getString());
|
{
|
||||||
|
itemTransformType = options.get("variant").getString().toLowerCase(Locale.ROOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
String dir = options.getOrDefault("facing", optional.get("facing")).getString();
|
String dir = options.getOrDefault("facing", optional.get("facing")).getString();
|
||||||
facing = null;
|
facing = switch (dir) {
|
||||||
switch (dir)
|
case "north" -> Direction.NORTH;
|
||||||
{
|
case "south" -> Direction.SOUTH;
|
||||||
case "north": facing = Direction.NORTH; break;
|
case "east" -> Direction.EAST;
|
||||||
case "south": facing = Direction.SOUTH; break;
|
case "west" -> Direction.WEST;
|
||||||
case "east": facing = Direction.EAST; break;
|
case "up" -> Direction.UP;
|
||||||
case "west": facing = Direction.WEST; break;
|
case "down" -> Direction.DOWN;
|
||||||
case "up": facing = Direction.UP; break;
|
default -> null;
|
||||||
case "down": facing = Direction.DOWN; break;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
tilt = NumericValue.asNumber(options.getOrDefault("tilt", optional.get("tilt"))).getFloat();
|
tilt = NumericValue.asNumber(options.getOrDefault("tilt", optional.get("tilt"))).getFloat();
|
||||||
lean = NumericValue.asNumber(options.getOrDefault("lean", optional.get("lean"))).getFloat();
|
lean = NumericValue.asNumber(options.getOrDefault("lean", optional.get("lean"))).getFloat();
|
||||||
turn = NumericValue.asNumber(options.getOrDefault("turn", optional.get("turn"))).getFloat();
|
turn = NumericValue.asNumber(options.getOrDefault("turn", optional.get("turn"))).getFloat();
|
||||||
List<Value> scale = ((ListValue) options.getOrDefault("scale", optional.get("scale"))).unpack();
|
List<Value> scale = ((ListValue) options.getOrDefault("scale", optional.get("scale"))).unpack();
|
||||||
scale_y = NumericValue.asNumber(scale.get(1)).getFloat();
|
scaleY = NumericValue.asNumber(scale.get(1)).getFloat();
|
||||||
scale_x = NumericValue.asNumber(scale.get(0)).getFloat();
|
scaleX = NumericValue.asNumber(scale.get(0)).getFloat();
|
||||||
scale_z = NumericValue.asNumber(scale.get(2)).getFloat();
|
scaleZ = NumericValue.asNumber(scale.get(2)).getFloat();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Consumer<ServerPlayer> alternative() {
|
public Consumer<ServerPlayer> alternative() {
|
||||||
ParticleOptions locparticledata;
|
ParticleOptions particle;
|
||||||
if(this.isitem){
|
if(this.isitem)
|
||||||
if(Block.byItem(this.item.getItem()).defaultBlockState().isAir())
|
{
|
||||||
return p->{};
|
if (Block.byItem(this.item.getItem()).defaultBlockState().isAir()) return p->{};
|
||||||
locparticledata = getParticleData("block_marker "+Registry.BLOCK.getKey(Block.byItem(this.item.getItem())));
|
particle = getParticleData("block_marker "+Registry.BLOCK.getKey(Block.byItem(this.item.getItem())));
|
||||||
}else{
|
}
|
||||||
locparticledata = getParticleData("block_marker "+Registry.BLOCK.getKey(this.blockState.getBlock()));
|
else
|
||||||
|
{
|
||||||
|
particle = getParticleData("block_marker "+Registry.BLOCK.getKey(this.blockState.getBlock()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return p -> {
|
return p -> {
|
||||||
Vec3 v=relativiseRender(p.level, this.pos, 0);
|
Vec3 v = relativiseRender(p.level, this.pos, 0);
|
||||||
p.getLevel().sendParticles(p,locparticledata , true,
|
p.getLevel().sendParticles(p, particle , true, v.x, v.y, v.z, 1,0.0, 0.0, 0.0, 0.0);
|
||||||
v.x, v.y, v.z, 1,
|
|
||||||
0.0, 0.0, 0.0, 0.0);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -686,21 +683,21 @@ public class ShapeDispatcher
|
|||||||
public long calcKey() {
|
public long calcKey() {
|
||||||
long hash = super.calcKey();
|
long hash = super.calcKey();
|
||||||
hash ^= 7; hash *= 1099511628211L;
|
hash ^= 7; hash *= 1099511628211L;
|
||||||
|
hash ^= Boolean.hashCode(isitem); hash *= 1099511628211L;
|
||||||
hash ^= vec3dhash(pos); hash *= 1099511628211L;
|
hash ^= vec3dhash(pos); hash *= 1099511628211L;
|
||||||
if (facing!= null) hash ^= facing.hashCode(); hash *= 1099511628211L;
|
if (facing!= null) hash ^= facing.hashCode(); hash *= 1099511628211L;
|
||||||
hash ^= Float.hashCode(tilt); hash *= 1099511628211L;
|
hash ^= Float.hashCode(tilt); hash *= 1099511628211L;
|
||||||
hash ^= Float.hashCode(lean); hash *= 1099511628211L;
|
hash ^= Float.hashCode(lean); hash *= 1099511628211L;
|
||||||
hash ^= Float.hashCode(turn); hash *= 1099511628211L;
|
hash ^= Float.hashCode(turn); hash *= 1099511628211L;
|
||||||
hash ^= Float.hashCode(scale_y); hash *= 1099511628211L;
|
hash ^= Float.hashCode(scaleY); hash *= 1099511628211L;
|
||||||
hash ^= Float.hashCode(scale_z); hash *= 1099511628211L;
|
hash ^= Float.hashCode(scaleZ); hash *= 1099511628211L;
|
||||||
hash ^= Float.hashCode(scale_x); hash *= 1099511628211L;
|
hash ^= Float.hashCode(scaleX); hash *= 1099511628211L;
|
||||||
hash ^= Float.hashCode(light_fromsky); hash *= 1099511628211L;
|
hash ^= Float.hashCode(skyLight); hash *= 1099511628211L;
|
||||||
hash ^= Float.hashCode(light_fromblock); hash *= 1099511628211L;
|
hash ^= Float.hashCode(blockLight); hash *= 1099511628211L;
|
||||||
if (blockEntity!= null) hash ^= blockEntity.toString().hashCode(); hash *= 1099511628211L;
|
if (blockEntity!= null) hash ^= blockEntity.toString().hashCode(); hash *= 1099511628211L;
|
||||||
if (blockState!= null) hash ^= blockState.hashCode(); hash *= 1099511628211L;
|
if (blockState!= null) hash ^= blockState.hashCode(); hash *= 1099511628211L;
|
||||||
hash ^= ValueConversions.of(item).getString().hashCode(); hash *= 1099511628211L;
|
hash ^= ValueConversions.of(item).getString().hashCode(); hash *= 1099511628211L;
|
||||||
//hash ^= Boolean.hashCode(needf3b); hash *= 1099511628211L;
|
hash ^= itemTransformType.hashCode(); hash *= 1099511628211L;
|
||||||
hash ^= item_transform_type.hashCode(); hash *= 1099511628211L;
|
|
||||||
|
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
@@ -800,7 +797,6 @@ public class ShapeDispatcher
|
|||||||
hash ^= Boolean.hashCode(doublesided); hash *= 1099511628211L;
|
hash ^= Boolean.hashCode(doublesided); hash *= 1099511628211L;
|
||||||
hash ^= Integer.hashCode(vertex_list.size()); hash *= 1099511628211L;
|
hash ^= Integer.hashCode(vertex_list.size()); hash *= 1099511628211L;
|
||||||
hash ^= Boolean.hashCode(inneredges); hash *= 1099511628211L;
|
hash ^= Boolean.hashCode(inneredges); hash *= 1099511628211L;
|
||||||
//hash ^= Boolean.hashCode(needf3b); hash *= 1099511628211L;
|
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
ArrayList<Vec3> alter_point=null;
|
ArrayList<Vec3> alter_point=null;
|
||||||
@@ -859,15 +855,11 @@ public class ShapeDispatcher
|
|||||||
if(relative.get(1)){
|
if(relative.get(1)){
|
||||||
vecB=relativiseRender(p.level, vecB, 0);
|
vecB=relativiseRender(p.level, vecB, 0);
|
||||||
}
|
}
|
||||||
//ArrayList<Vec3> last = new ArrayList<Vec3>();
|
|
||||||
//last.add(vecA);last.add(vecB);
|
|
||||||
for(int i=2;i<vertex_list.size();i++){
|
for(int i=2;i<vertex_list.size();i++){
|
||||||
Vec3 vec=vertex_list.get(i);
|
Vec3 vec=vertex_list.get(i);
|
||||||
if(relative.get(i)){
|
if(relative.get(i)){
|
||||||
vec=relativiseRender(p.level, vec, 0);
|
vec=relativiseRender(p.level, vec, 0);
|
||||||
}
|
}
|
||||||
//alter_draw_triangles(last.get(0),last.get(1),vec);
|
|
||||||
//last.remove(0);last.add(vec);
|
|
||||||
alter_draw_triangles(vecA,vecB,vec);
|
alter_draw_triangles(vecA,vecB,vec);
|
||||||
vecA=vecB;vecB=vec;
|
vecA=vecB;vecB=vec;
|
||||||
}
|
}
|
||||||
@@ -927,8 +919,6 @@ public class ShapeDispatcher
|
|||||||
{
|
{
|
||||||
super.init(options);
|
super.init(options);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
doublesided=options.getOrDefault("doublesided",optional.get("doublesided")).getBoolean();
|
doublesided=options.getOrDefault("doublesided",optional.get("doublesided")).getBoolean();
|
||||||
|
|
||||||
if (options.get("points") instanceof AbstractListValue abl){
|
if (options.get("points") instanceof AbstractListValue abl){
|
||||||
@@ -1271,7 +1261,7 @@ public class ShapeDispatcher
|
|||||||
put("turn", new FloatParam("turn"));
|
put("turn", new FloatParam("turn"));
|
||||||
put("facing", new StringChoiceParam("axis", "player", "north", "south", "east", "west", "up", "down"));
|
put("facing", new StringChoiceParam("axis", "player", "north", "south", "east", "west", "up", "down"));
|
||||||
put("doublesided", new BoolParam("doublesided"));
|
put("doublesided", new BoolParam("doublesided"));
|
||||||
put("toggleable", new BoolParam("toggleable"));
|
put("debug", new BoolParam("debug"));
|
||||||
|
|
||||||
}};
|
}};
|
||||||
protected String id;
|
protected String id;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package carpet.script.utils;
|
package carpet.script.utils;
|
||||||
|
|
||||||
import carpet.CarpetSettings;
|
import carpet.CarpetSettings;
|
||||||
|
import carpet.mixins.ShulkerBoxAccessMixin;
|
||||||
import carpet.utils.CarpetProfiler;
|
import carpet.utils.CarpetProfiler;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||||
@@ -12,21 +12,17 @@ import com.mojang.blaze3d.vertex.Tesselator;
|
|||||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat.Mode;
|
import com.mojang.blaze3d.vertex.VertexFormat.Mode;
|
||||||
import com.mojang.datafixers.util.Either;
|
|
||||||
import com.mojang.math.Vector3f;
|
import com.mojang.math.Vector3f;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Predicate;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import net.minecraft.client.Camera;
|
import net.minecraft.client.Camera;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Font;
|
import net.minecraft.client.gui.Font;
|
||||||
|
import net.minecraft.client.model.ShulkerModel;
|
||||||
import net.minecraft.client.model.geom.ModelPart;
|
import net.minecraft.client.model.geom.ModelPart;
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
@@ -35,48 +31,28 @@ import net.minecraft.client.renderer.LightTexture;
|
|||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.Sheets;
|
import net.minecraft.client.renderer.Sheets;
|
||||||
|
import net.minecraft.client.renderer.block.model.ItemTransform;
|
||||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||||
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||||
|
import net.minecraft.client.renderer.blockentity.ShulkerBoxRenderer;
|
||||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.client.resources.model.Material;
|
import net.minecraft.client.resources.model.Material;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Holder;
|
|
||||||
import net.minecraft.core.Registry;
|
|
||||||
import net.minecraft.core.RegistryAccess;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.ListTag;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.sounds.SoundEvent;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
|
||||||
import net.minecraft.tags.TagKey;
|
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.item.DyeColor;
|
import net.minecraft.world.item.DyeColor;
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.item.Items;
|
|
||||||
import net.minecraft.world.item.crafting.RecipeManager;
|
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.LightLayer;
|
import net.minecraft.world.level.LightLayer;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.EntityBlock;
|
import net.minecraft.world.level.block.EntityBlock;
|
||||||
import net.minecraft.world.level.block.RenderShape;
|
import net.minecraft.world.level.block.RenderShape;
|
||||||
import net.minecraft.world.level.block.ShulkerBoxBlock;
|
import net.minecraft.world.level.block.ShulkerBoxBlock;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
|
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.chunk.ChunkSource;
|
|
||||||
import net.minecraft.world.level.dimension.DimensionType;
|
|
||||||
import net.minecraft.world.level.entity.LevelEntityGetter;
|
|
||||||
import net.minecraft.world.level.gameevent.GameEvent;
|
|
||||||
import net.minecraft.world.level.material.Fluid;
|
|
||||||
import net.minecraft.world.level.material.FluidState;
|
|
||||||
import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraft.world.scores.Scoreboard;
|
|
||||||
import net.minecraft.world.ticks.LevelTickAccess;
|
|
||||||
|
|
||||||
public class ShapesRenderer
|
public class ShapesRenderer
|
||||||
{
|
{
|
||||||
@@ -85,16 +61,15 @@ public class ShapesRenderer
|
|||||||
private Minecraft client;
|
private Minecraft client;
|
||||||
|
|
||||||
private Map<String, BiFunction<Minecraft, ShapeDispatcher.ExpiringShape, RenderedShape<? extends ShapeDispatcher.ExpiringShape >>> renderedShapes
|
private Map<String, BiFunction<Minecraft, ShapeDispatcher.ExpiringShape, RenderedShape<? extends ShapeDispatcher.ExpiringShape >>> renderedShapes
|
||||||
= new HashMap<String, BiFunction<Minecraft, ShapeDispatcher.ExpiringShape, RenderedShape<? extends ShapeDispatcher.ExpiringShape>>>()
|
= new HashMap<>() {{
|
||||||
{{
|
|
||||||
put("line", RenderedLine::new);
|
put("line", RenderedLine::new);
|
||||||
put("box", RenderedBox::new);
|
put("box", RenderedBox::new);
|
||||||
put("sphere", RenderedSphere::new);
|
put("sphere", RenderedSphere::new);
|
||||||
put("cylinder", RenderedCylinder::new);
|
put("cylinder", RenderedCylinder::new);
|
||||||
put("label", RenderedText::new);
|
put("label", RenderedText::new);
|
||||||
put("polygon",RenderedPolyface::new);
|
put("polygon", RenderedPolyface::new);
|
||||||
put("block",(c,s)->new RenderedSprite(c,s).set_isitem(false));
|
put("block", (c, s) -> new RenderedSprite(c, s, false));
|
||||||
put("item",(c,s)->new RenderedSprite(c,s).set_isitem(true));
|
put("item", (c, s) -> new RenderedSprite(c, s, true));
|
||||||
}};
|
}};
|
||||||
|
|
||||||
public ShapesRenderer(Minecraft minecraftClient)
|
public ShapesRenderer(Minecraft minecraftClient)
|
||||||
@@ -136,7 +111,7 @@ public class ShapesRenderer
|
|||||||
double cameraX = camera.getPosition().x;
|
double cameraX = camera.getPosition().x;
|
||||||
double cameraY = camera.getPosition().y;
|
double cameraY = camera.getPosition().y;
|
||||||
double cameraZ = camera.getPosition().z;
|
double cameraZ = camera.getPosition().z;
|
||||||
boolean hasf3b = client.getEntityRenderDispatcher().shouldRenderHitBoxes();
|
boolean entityBoxes = client.getEntityRenderDispatcher().shouldRenderHitBoxes();
|
||||||
|
|
||||||
if (shapes.size() != 0) { synchronized (shapes) {
|
if (shapes.size() != 0) { synchronized (shapes) {
|
||||||
shapes.get(dimensionType).long2ObjectEntrySet().removeIf(
|
shapes.get(dimensionType).long2ObjectEntrySet().removeIf(
|
||||||
@@ -150,12 +125,12 @@ public class ShapesRenderer
|
|||||||
// lines
|
// lines
|
||||||
RenderSystem.lineWidth(0.5F);
|
RenderSystem.lineWidth(0.5F);
|
||||||
shapes.get(dimensionType).values().forEach( s -> {
|
shapes.get(dimensionType).values().forEach( s -> {
|
||||||
if ( (!s.shape.needf3b ||hasf3b ) && s.shouldRender(dimensionType)) s.renderLines(matrices, tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick);
|
if ( (!s.shape.debug ||entityBoxes ) && s.shouldRender(dimensionType)) s.renderLines(matrices, tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick);
|
||||||
});
|
});
|
||||||
// faces
|
// faces
|
||||||
RenderSystem.lineWidth(0.1F);
|
RenderSystem.lineWidth(0.1F);
|
||||||
shapes.get(dimensionType).values().forEach(s -> {
|
shapes.get(dimensionType).values().forEach(s -> {
|
||||||
if ( (!s.shape.needf3b ||hasf3b ) && s.shouldRender(dimensionType)) s.renderFaces(tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick);
|
if ( (!s.shape.debug ||entityBoxes ) && s.shouldRender(dimensionType)) s.renderFaces(tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick);
|
||||||
});
|
});
|
||||||
RenderSystem.lineWidth(1.0F);
|
RenderSystem.lineWidth(1.0F);
|
||||||
matrixStack.popPose();
|
matrixStack.popPose();
|
||||||
@@ -168,7 +143,7 @@ public class ShapesRenderer
|
|||||||
entry -> entry.getValue().isExpired(currentTime)
|
entry -> entry.getValue().isExpired(currentTime)
|
||||||
);
|
);
|
||||||
labels.get(dimensionType).values().forEach(s -> {
|
labels.get(dimensionType).values().forEach(s -> {
|
||||||
if ( (!s.shape.needf3b || hasf3b) && s.shouldRender(dimensionType)) s.renderLines(matrices, tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick);
|
if ( (!s.shape.debug || entityBoxes) && s.shouldRender(dimensionType)) s.renderLines(matrices, tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
RenderSystem.enableCull();
|
RenderSystem.enableCull();
|
||||||
@@ -290,24 +265,25 @@ public class ShapesRenderer
|
|||||||
|
|
||||||
public static class RenderedSprite extends RenderedShape<ShapeDispatcher.DisplayedSprite> {
|
public static class RenderedSprite extends RenderedShape<ShapeDispatcher.DisplayedSprite> {
|
||||||
|
|
||||||
private boolean isitem;
|
private final boolean isitem;
|
||||||
|
private ItemTransforms.TransformType transformType = ItemTransforms.TransformType.NONE;
|
||||||
public RenderedSprite set_isitem(boolean isitem) {
|
|
||||||
this.isitem = isitem;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private BlockPos blockPos;
|
private BlockPos blockPos;
|
||||||
private BlockState blockState;
|
private BlockState blockState;
|
||||||
private BlockEntity BlockEntity = null;
|
private BlockEntity BlockEntity = null;
|
||||||
|
|
||||||
protected RenderedSprite(Minecraft client, ShapeDispatcher.ExpiringShape shape) {
|
protected RenderedSprite(Minecraft client, ShapeDispatcher.ExpiringShape shape, boolean isitem) {
|
||||||
super(client, (ShapeDispatcher.DisplayedSprite) shape);
|
super(client, (ShapeDispatcher.DisplayedSprite) shape);
|
||||||
|
this.isitem = isitem;
|
||||||
|
if (isitem) {
|
||||||
|
this.transformType = ItemTransforms.TransformType.valueOf(((ShapeDispatcher.DisplayedSprite) shape).itemTransformType.toUpperCase(Locale.ROOT));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderLines(PoseStack matrices, Tesselator tessellator, BufferBuilder builder, double cx, double cy,
|
public void renderLines(PoseStack matrices, Tesselator tessellator, BufferBuilder builder, double cx, double cy,
|
||||||
double cz, float partialTick) {
|
double cz, float partialTick)
|
||||||
|
{
|
||||||
if (shape.a == 0.0)
|
if (shape.a == 0.0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -316,13 +292,19 @@ public class ShapesRenderer
|
|||||||
|
|
||||||
matrices.pushPose();
|
matrices.pushPose();
|
||||||
if (!isitem)// blocks should use its center as the origin
|
if (!isitem)// blocks should use its center as the origin
|
||||||
|
{
|
||||||
matrices.translate(0.5, 0.5, 0.5);
|
matrices.translate(0.5, 0.5, 0.5);
|
||||||
|
}
|
||||||
matrices.translate(v1.x - cx, v1.y - cy, v1.z - cz);
|
matrices.translate(v1.x - cx, v1.y - cy, v1.z - cz);
|
||||||
if (shape.facing == null) {
|
if (shape.facing == null)
|
||||||
|
{
|
||||||
matrices.mulPose(camera1.rotation());
|
matrices.mulPose(camera1.rotation());
|
||||||
matrices.mulPose(Vector3f.YP.rotationDegrees(180));
|
matrices.mulPose(Vector3f.YP.rotationDegrees(180));
|
||||||
} else {
|
}
|
||||||
switch (shape.facing) {
|
else
|
||||||
|
{
|
||||||
|
switch (shape.facing)
|
||||||
|
{
|
||||||
case NORTH:
|
case NORTH:
|
||||||
break;
|
break;
|
||||||
case SOUTH:
|
case SOUTH:
|
||||||
@@ -343,30 +325,28 @@ public class ShapesRenderer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shape.tilt != 0.0f)
|
if (shape.tilt != 0.0f) matrices.mulPose(Vector3f.ZP.rotationDegrees(-shape.tilt));
|
||||||
matrices.mulPose(Vector3f.ZP.rotationDegrees(shape.tilt));
|
if (shape.lean != 0.0f) matrices.mulPose(Vector3f.XP.rotationDegrees(-shape.lean));
|
||||||
if (shape.lean != 0.0f)
|
if (shape.turn != 0.0f) matrices.mulPose(Vector3f.YP.rotationDegrees( shape.turn));
|
||||||
matrices.mulPose(Vector3f.XP.rotationDegrees(shape.lean));
|
matrices.scale(shape.scaleX, shape.scaleY, shape.scaleZ);
|
||||||
if (shape.turn != 0.0f)
|
|
||||||
matrices.mulPose(Vector3f.YP.rotationDegrees(shape.turn));
|
|
||||||
matrices.scale(shape.scale_x, shape.scale_y, shape.scale_z);
|
|
||||||
|
|
||||||
if (!isitem)// blocks should use its center as the origin
|
if (!isitem)// blocks should use its center as the origin
|
||||||
|
{
|
||||||
matrices.translate(-0.5, -0.5, -0.5);
|
matrices.translate(-0.5, -0.5, -0.5);
|
||||||
|
}
|
||||||
|
|
||||||
RenderSystem.depthMask(true);
|
RenderSystem.depthMask(true);
|
||||||
RenderSystem.enableCull();
|
RenderSystem.enableCull();
|
||||||
RenderSystem.enableDepthTest();
|
RenderSystem.enableDepthTest();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
blockPos = new BlockPos(v1);
|
blockPos = new BlockPos(v1);
|
||||||
int light;
|
int light = 0;
|
||||||
light = LightTexture.pack(
|
if (client.level != null) {
|
||||||
shape.light_fromblock < 0 ? client.level.getBrightness(LightLayer.BLOCK, blockPos)
|
light = LightTexture.pack(
|
||||||
: shape.light_fromblock,
|
shape.blockLight < 0 ? client.level.getBrightness(LightLayer.BLOCK, blockPos) : shape.blockLight,
|
||||||
shape.light_fromsky < 0 ? client.level.getBrightness(LightLayer.SKY, blockPos)
|
shape.skyLight < 0 ? client.level.getBrightness(LightLayer.SKY, blockPos) : shape.skyLight
|
||||||
: shape.light_fromsky);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
blockState = shape.blockState;
|
blockState = shape.blockState;
|
||||||
|
|
||||||
@@ -386,29 +366,43 @@ public class ShapesRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// draw the block`s entity part
|
// draw the block`s entity part
|
||||||
if (BlockEntity == null) {
|
if (BlockEntity == null)
|
||||||
if (blockState.getBlock() instanceof EntityBlock eb) {
|
{
|
||||||
|
if (blockState.getBlock() instanceof EntityBlock eb)
|
||||||
|
{
|
||||||
BlockEntity = eb.newBlockEntity(blockPos, blockState);
|
BlockEntity = eb.newBlockEntity(blockPos, blockState);
|
||||||
if (BlockEntity != null) {
|
if (BlockEntity != null)
|
||||||
|
{
|
||||||
BlockEntity.setLevel(client.level);
|
BlockEntity.setLevel(client.level);
|
||||||
if (shape.blockEntity != null)
|
if (shape.blockEntity != null) BlockEntity.load(shape.blockEntity);
|
||||||
BlockEntity.load(shape.blockEntity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (BlockEntity instanceof ShulkerBoxBlockEntity sbBlockEntity){
|
if (BlockEntity instanceof ShulkerBoxBlockEntity sbBlockEntity)
|
||||||
|
{
|
||||||
sbrender(sbBlockEntity, partialTick,
|
sbrender(sbBlockEntity, partialTick,
|
||||||
matrices, immediate, light, OverlayTexture.NO_OVERLAY);
|
matrices, immediate, light, OverlayTexture.NO_OVERLAY);
|
||||||
}else
|
|
||||||
if (BlockEntity != null && client.getBlockEntityRenderDispatcher().getRenderer(BlockEntity) != null) {
|
|
||||||
client.getBlockEntityRenderDispatcher().getRenderer(BlockEntity).render(BlockEntity, partialTick,
|
|
||||||
matrices, immediate, light, OverlayTexture.NO_OVERLAY);
|
|
||||||
}
|
}
|
||||||
} else {
|
else
|
||||||
// draw item
|
{
|
||||||
|
if (BlockEntity != null)
|
||||||
|
{
|
||||||
|
final BlockEntityRenderer<BlockEntity> blockEntityRenderer = client.getBlockEntityRenderDispatcher().getRenderer(BlockEntity);
|
||||||
|
if (blockEntityRenderer != null) {
|
||||||
|
blockEntityRenderer.render(BlockEntity, partialTick,
|
||||||
|
matrices, immediate, light, OverlayTexture.NO_OVERLAY);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (shape.item != null)
|
if (shape.item != null)
|
||||||
client.getItemRenderer().renderStatic(shape.item, shape.item_transform_type, light,
|
{
|
||||||
|
client.getItemRenderer().renderStatic(shape.item, transformType, light,
|
||||||
OverlayTexture.NO_OVERLAY, matrices, immediate, (int) shape.key());
|
OverlayTexture.NO_OVERLAY, matrices, immediate, (int) shape.key());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
matrices.popPose();
|
matrices.popPose();
|
||||||
immediate.endBatch();
|
immediate.endBatch();
|
||||||
@@ -424,34 +418,40 @@ public class ShapesRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// copy and modifiy a bit from net.minecraft.client.renderer.blockentity.ShulkerBoxRenderer.render
|
// copy and modifiy a bit from net.minecraft.client.renderer.blockentity.ShulkerBoxRenderer.render
|
||||||
public void sbrender(ShulkerBoxBlockEntity shulkerBoxBlockEntity, float f, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, int j) {
|
public void sbrender(ShulkerBoxBlockEntity shulkerBoxBlockEntity, float f, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, int j)
|
||||||
|
{
|
||||||
Direction direction = Direction.UP;
|
Direction direction = Direction.UP;
|
||||||
if (shulkerBoxBlockEntity.hasLevel()) {
|
if (shulkerBoxBlockEntity.hasLevel())
|
||||||
|
{
|
||||||
BlockState blockState = shulkerBoxBlockEntity.getBlockState();
|
BlockState blockState = shulkerBoxBlockEntity.getBlockState();
|
||||||
if (blockState.getBlock() instanceof ShulkerBoxBlock) {
|
if (blockState.getBlock() instanceof ShulkerBoxBlock)
|
||||||
|
{
|
||||||
direction = blockState.getValue(ShulkerBoxBlock.FACING);
|
direction = blockState.getValue(ShulkerBoxBlock.FACING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DyeColor dyeColor = shulkerBoxBlockEntity.getColor();
|
DyeColor dyeColor = shulkerBoxBlockEntity.getColor();
|
||||||
Material material;
|
Material material;
|
||||||
if (dyeColor == null) {
|
if (dyeColor == null)
|
||||||
|
{
|
||||||
material = Sheets.DEFAULT_SHULKER_TEXTURE_LOCATION;
|
material = Sheets.DEFAULT_SHULKER_TEXTURE_LOCATION;
|
||||||
} else {
|
}
|
||||||
material = (Material)Sheets.SHULKER_TEXTURE_LOCATION.get(dyeColor.getId());
|
else
|
||||||
|
{
|
||||||
|
material = Sheets.SHULKER_TEXTURE_LOCATION.get(dyeColor.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
poseStack.pushPose();
|
poseStack.pushPose();
|
||||||
poseStack.translate(0.5, 0.5, 0.5);
|
poseStack.translate(0.5, 0.5, 0.5);
|
||||||
float g = 0.9995F;
|
|
||||||
poseStack.scale(0.9995F, 0.9995F, 0.9995F);
|
poseStack.scale(0.9995F, 0.9995F, 0.9995F);
|
||||||
poseStack.mulPose(direction.getRotation());
|
poseStack.mulPose(direction.getRotation());
|
||||||
poseStack.scale(1.0F, -1.0F, -1.0F);
|
poseStack.scale(1.0F, -1.0F, -1.0F);
|
||||||
poseStack.translate(0.0, -1.0, 0.0);
|
poseStack.translate(0.0, -1.0, 0.0);
|
||||||
ModelPart modelPart = ((carpet.mixins.ShulkerBoxAccessMixin)(Object)(client.getBlockEntityRenderDispatcher().getRenderer(BlockEntity))).getModel().getLid();
|
ShulkerModel<?> model = ((ShulkerBoxAccessMixin) client.getBlockEntityRenderDispatcher().getRenderer(BlockEntity)).getModel();
|
||||||
|
ModelPart modelPart = model.getLid();
|
||||||
modelPart.setPos(0.0F, 24.0F - shulkerBoxBlockEntity.getProgress(f) * 0.5F * 16.0F, 0.0F);
|
modelPart.setPos(0.0F, 24.0F - shulkerBoxBlockEntity.getProgress(f) * 0.5F * 16.0F, 0.0F);
|
||||||
modelPart.yRot = 270.0F * shulkerBoxBlockEntity.getProgress(f) * (float) (Math.PI / 180.0);
|
modelPart.yRot = 270.0F * shulkerBoxBlockEntity.getProgress(f) * (float) (Math.PI / 180.0);
|
||||||
VertexConsumer vertexConsumer = material.buffer(multiBufferSource, RenderType::entityCutoutNoCull);
|
VertexConsumer vertexConsumer = material.buffer(multiBufferSource, RenderType::entityCutoutNoCull);
|
||||||
((carpet.mixins.ShulkerBoxAccessMixin)(Object)(client.getBlockEntityRenderDispatcher().getRenderer(BlockEntity))).getModel().renderToBuffer(poseStack, vertexConsumer, i, j, 1.0F, 1.0F, 1.0F, 1.0F);
|
model.renderToBuffer(poseStack, vertexConsumer, i, j, 1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
poseStack.popPose();
|
poseStack.popPose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -677,8 +677,6 @@ public class ShapesRenderer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (shape.mode==Mode.TRIANGLE_STRIP){
|
if (shape.mode==Mode.TRIANGLE_STRIP){
|
||||||
//02468
|
|
||||||
//1357*
|
|
||||||
builder.begin(VertexFormat.Mode.DEBUG_LINE_STRIP, DefaultVertexFormat.POSITION_COLOR);
|
builder.begin(VertexFormat.Mode.DEBUG_LINE_STRIP, DefaultVertexFormat.POSITION_COLOR);
|
||||||
Vec3 vec=shape.vertex_list.get(1);
|
Vec3 vec=shape.vertex_list.get(1);
|
||||||
if(shape.relative.get(1)){
|
if(shape.relative.get(1)){
|
||||||
|
|||||||
Reference in new issue
Block a user