use of net.minecraft.util.math.Direction in project bewitchment by MoriyaShiine.
the class PoppetShelfBlockEntityRenderer method render.
@Override
public void render(PoppetShelfBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
Direction direction = entity.getCachedState().get(Properties.HORIZONTAL_FACING);
float rotation = -direction.asRotation();
matrices.translate(0.5f, 0, 0.5f);
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(rotation));
matrices.scale(1 / 5f, 1 / 5f, 1 / 5f);
renderRow(entity.clientInventory.get(0), entity.clientInventory.get(1), entity.clientInventory.get(2), 0.8f, matrices, vertexConsumers, light, overlay);
renderRow(entity.clientInventory.get(3), entity.clientInventory.get(4), entity.clientInventory.get(5), 0.5f, matrices, vertexConsumers, light, overlay);
renderRow(entity.clientInventory.get(6), entity.clientInventory.get(7), entity.clientInventory.get(8), 0.2f, matrices, vertexConsumers, light, overlay);
}
use of net.minecraft.util.math.Direction in project WK by witches-kitchen.
the class WitchesOvenBlockEntityRender method render.
@Override
public void render(WitchesOvenBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
final Direction facing = entity.getCachedState().get(WitchesOvenBlock.FACING);
final DefaultedList<ItemStack> extraInventory = entity.getStacksOnTop();
final int pos = (int) entity.getPos().asLong();
for (int i = 0; i < extraInventory.size(); i++) {
final ItemStack food = extraInventory.get(i);
if (food.isEmpty()) {
return;
}
matrices.push();
matrices.translate(0.5D, 1.02, 0.5D);
final Direction dir = Direction.fromHorizontal((i + facing.getHorizontal()) % 4);
final float rotation = -dir.asRotation();
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(rotation));
matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90.0F));
matrices.translate(-0.20D, -0.20D, 0.0D);
matrices.scale(0.375F, 0.375F, 0.375F);
MinecraftClient.getInstance().getItemRenderer().renderItem(food, ModelTransformation.Mode.FIXED, light, overlay, matrices, vertexConsumers, pos + i);
matrices.pop();
}
}
use of net.minecraft.util.math.Direction in project EdenClient by HahaOO7.
the class WorldEditReplaceHelper method registerCommand.
private void registerCommand(String command) {
LiteralArgumentBuilder<ClientCommandSource> node = literal(command);
node.then(literal("replace").then(argument("from", StringArgumentType.word()).suggests(this::suggestValidBlocks).then(argument("to", StringArgumentType.word()).suggests(this::suggestValidBlocks).executes(c -> {
Optional<Block> fromBlockOpt = Registry.BLOCK.getOrEmpty(new Identifier(c.getArgument("from", String.class)));
Optional<Block> toBlockOpt = Registry.BLOCK.getOrEmpty(new Identifier(c.getArgument("to", String.class)));
if (fromBlockOpt.isEmpty() || toBlockOpt.isEmpty()) {
sendModMessage("One of your block-inputs doesn't exist.");
return 0;
}
Block fromBlock = fromBlockOpt.get();
Block toBlock = toBlockOpt.get();
if (fromBlock.equals(toBlock)) {
sendModMessage("Both input-blocks can't be the same!");
return 0;
}
String[] currentOperation = new String[] { getBlockIDFromBlock(toBlock), getBlockIDFromBlock(fromBlock) };
undoCommandStack.add(currentOperation);
return replaceCommandRequest(fromBlock, toBlock, delay, true);
}))));
node.then(literal("undo").executes(c -> {
if (undoCommandStack.size() == 0) {
sendModMessage("Nothing left to undo.");
return 0;
}
replaceUndoRequest(Registry.BLOCK.get(new Identifier(undoCommandStack.peek()[0])), Registry.BLOCK.get(new Identifier(undoCommandStack.peek()[1])), delay);
redoCommandStack.add(new String[] { undoCommandStack.peek()[1], undoCommandStack.peek()[0] });
undoCommandStack.pop();
return 1;
}));
node.then(literal("redo").executes(c -> {
if (redoCommandStack.size() == 0) {
sendModMessage("Nothing left to redo.");
return 0;
}
replaceRedoRequest(Registry.BLOCK.get(new Identifier(redoCommandStack.peek()[0])), Registry.BLOCK.get(new Identifier(redoCommandStack.peek()[1])), delay);
undoCommandStack.add(new String[] { redoCommandStack.peek()[1], redoCommandStack.peek()[0] });
redoCommandStack.pop();
return 1;
}));
node.then(literal("delay").then(argument("delay", IntegerArgumentType.integer(0, 40)).executes(c -> {
this.delay = c.getArgument("delay", Integer.class);
sendModMessage(ChatColor.GOLD + "Set delay to " + ChatColor.AQUA + delay + ChatColor.GOLD + " ticks.");
return 1;
})));
node.then(literal("togglemessages").executes(c -> {
ClientPlayerEntity entityPlayer = PlayerUtils.getPlayer();
entityPlayer.sendChatMessage("/eignoremessage predefined worldedit");
return 1;
}));
register(node, "The WorldEditReplaceHelper helps you replace blocks that have specific properties which normal WorldEdit doesn't take into consideration when replacing blocks.", "Blocks like stairs, slabs, panes, walls, trapdoors, etc. can be replaced by other blocks of their type with their properties (waterlogged, shape, direction, etc.) unaffected.");
}
use of net.minecraft.util.math.Direction in project fabric by FabricMC.
the class ItemRenderContext method fallbackConsumer.
private void fallbackConsumer(BakedModel model) {
if (hasTransform()) {
// if there's a transform in effect, convert to mesh-based quads so that we can apply it
for (int i = 0; i < 7; i++) {
random.setSeed(42L);
final Direction cullFace = ModelHelper.faceFromIndex(i);
renderFallbackWithTransform(bufferBuilder, model.getQuads((BlockState) null, cullFace, random), color, itemStack, cullFace);
}
} else {
for (int i = 0; i < 7; i++) {
random.setSeed(42L);
vanillaHandler.accept(bufferBuilder, model.getQuads((BlockState) null, ModelHelper.faceFromIndex(i), random), color, itemStack);
}
}
}
use of net.minecraft.util.math.Direction in project fabric by FabricMC.
the class TerrainFallbackConsumer method renderQuad.
private void renderQuad(BakedQuad quad, Direction cullFace, Value defaultMaterial) {
final int[] vertexData = quad.getVertexData();
if (!CompatibilityHelper.canRender(vertexData)) {
return;
}
final MutableQuadViewImpl editorQuad = this.editorQuad;
System.arraycopy(vertexData, 0, editorBuffer, 0, 28);
editorQuad.cullFace(cullFace);
final Direction lightFace = quad.getFace();
editorQuad.lightFace(lightFace);
editorQuad.nominalFace(lightFace);
editorQuad.colorIndex(quad.getColorIndex());
editorQuad.material(defaultMaterial);
if (!transform.transform(editorQuad)) {
return;
}
if (editorQuad.material().hasAo) {
// needs to happen before offsets are applied
editorQuad.invalidateShape();
aoCalc.compute(editorQuad, true);
chunkInfo.applyOffsets(editorQuad);
tesselateSmooth(editorQuad, blockInfo.defaultLayerIndex, editorQuad.colorIndex());
} else {
// For flat lighting, cull face drives everything and light face is ignored.
if (cullFace == null) {
editorQuad.invalidateShape();
// Can't rely on lazy computation in tesselateFlat() because needs to happen before offsets are applied
editorQuad.geometryFlags();
} else {
editorQuad.geometryFlags(GeometryHelper.LIGHT_FACE_FLAG);
editorQuad.lightFace(cullFace);
}
chunkInfo.applyOffsets(editorQuad);
tesselateFlat(editorQuad, blockInfo.defaultLayerIndex, editorQuad.colorIndex());
}
}
Aggregations