use of net.minecraft.client.render.item.ItemRenderer in project Skyblocker by LifeIsAParadox.
the class DummyInventory method renderPreview.
public static boolean renderPreview(MatrixStack matrices, int index, int mouseX, int mouseY) {
if (index >= 9 && index < 18)
index -= 9;
else if (index >= 27 && index < 45)
index -= 18;
else
return false;
if (storage[index] == null)
return false;
int rows = (storage[index].size() - 9) / 9;
Screen screen = MinecraftClient.getInstance().currentScreen;
int x = mouseX + 184 >= screen.width ? mouseX - 188 : mouseX + 8;
int y = Math.max(0, mouseY - 16);
RenderSystem.disableDepthTest();
RenderSystem.setShaderTexture(0, TEXTURE);
instance.drawTexture(matrices, x, y, 0, 0, 176, 7);
for (int i = 0; i < rows; ++i) instance.drawTexture(matrices, x, y + i * 18 + 7, 0, 7, 176, 18);
instance.drawTexture(matrices, x, y + rows * 18 + 7, 0, 25, 176, 7);
RenderSystem.enableDepthTest();
ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
for (int i = 9; i < storage[index].size(); ++i) {
int itemX = x + (i - 9) % 9 * 18 + 8;
int itemY = y + (i - 9) / 9 * 18 + 8;
itemRenderer.zOffset = 200.0F;
itemRenderer.renderInGui(storage[index].getStack(i), itemX, itemY);
itemRenderer.renderGuiItemOverlay(textRenderer, storage[index].getStack(i), itemX, itemY);
itemRenderer.zOffset = 0.0F;
}
return true;
}
use of net.minecraft.client.render.item.ItemRenderer in project Polymorph by TheIllusiveC4.
the class OutputWidget method renderButton.
@Override
public void renderButton(MatrixStack matrixStack, int button_1, int button_2, float button_3) {
MinecraftClient minecraft = MinecraftClient.getInstance();
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, AbstractRecipesWidget.WIDGETS);
int j = 0;
if (this.x + 25 > button_1 && this.x <= button_1 && this.y + 25 > button_2 && this.y <= button_2) {
j += 25;
}
this.drawTexture(matrixStack, this.x, this.y, this.highlighted ? 41 : 16, j, this.width, this.height);
int k = 4;
ItemRenderer renderer = minecraft.getItemRenderer();
float zLevel = renderer.zOffset;
renderer.zOffset = 700.0F;
renderer.renderGuiItemIcon(this.getOutput(), this.x + k, this.y + k);
renderer.renderGuiItemOverlay(minecraft.textRenderer, this.getOutput(), this.x + k, this.y + k);
renderer.zOffset = zLevel;
}
use of net.minecraft.client.render.item.ItemRenderer in project EdenClient by HahaOO7.
the class ContainerDisplay method renderWorld.
private void renderWorld(MatrixStack matrixStack, VertexConsumerProvider.Immediate vertexConsumerProvider, float v) {
if (!enabled)
return;
// calculate looking direction, rendering offset and rendering angle
final Direction direction = Direction.getEntityFacingOrder(PlayerUtils.getPlayer())[5];
final Vec3d offset = Vec3d.of(direction.getVector().add(1, 1, 1)).multiply(.5);
final Quaternion rotation = direction.getRotationQuaternion();
if (direction.getAxis() == Direction.Axis.Y) {
Quaternion horizontal = getPlayer().getHorizontalFacing().getRotationQuaternion();
horizontal.hamiltonProduct(Direction.NORTH.getRotationQuaternion());
rotation.hamiltonProduct(horizontal);
}
rotation.hamiltonProduct(Direction.NORTH.getRotationQuaternion());
RenderSystem.enableDepthTest();
// get the item renderer
ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
// rendering
entries.forEach((pos, items) -> {
matrixStack.push();
// move matrix to rendering position
matrixStack.translate(pos.getX() + offset.getX(), pos.getY() + offset.getY(), pos.getZ() + offset.getZ());
// rotate to look outwards
matrixStack.multiply(rotation);
// scale item down
int loopCount = Math.min(items.size(), 9);
if (loopCount > 1) {
// multiple items -> render 3x3 items
matrixStack.scale(.3f, .3f, .3f);
// loop over items, max 9 times
for (int i = 0; i < loopCount; i++) {
Item item = items.get(i);
int x = i / 3;
int y = i % 3;
matrixStack.push();
matrixStack.translate(1 - y, 1 - x, 0);
matrixStack.scale(.8f, .8f, .8f);
itemRenderer.renderItem(item.getDefaultStack(), ModelTransformation.Mode.NONE, false, matrixStack, vertexConsumerProvider, 255, OverlayTexture.DEFAULT_UV, itemRenderer.getModels().getModel(item));
matrixStack.pop();
}
} else {
// one item -> render it BIG!
matrixStack.scale(.6f, .6f, .6f);
Item item = items.get(0);
itemRenderer.renderItem(item.getDefaultStack(), ModelTransformation.Mode.NONE, false, matrixStack, vertexConsumerProvider, 255, OverlayTexture.DEFAULT_UV, itemRenderer.getModels().getModel(item));
}
matrixStack.pop();
});
}
use of net.minecraft.client.render.item.ItemRenderer in project frame-fabric by moddingplayground.
the class TabWidget method renderButtonStack.
public void renderButtonStack(GUIIcon<?> icon, boolean hovered, boolean selected, int x, int y) {
GUIIcon.optional(icon, hovered, selected, ItemStack.class).ifPresent(stack -> {
MinecraftClient client = MinecraftClient.getInstance();
ItemRenderer itemRenderer = client.getItemRenderer();
itemRenderer.renderInGui(stack, x, y);
});
}
use of net.minecraft.client.render.item.ItemRenderer in project KiwiClient by TangyKiwi.
the class InventoryViewer method onDrawOverlay.
@Subscribe
public void onDrawOverlay(DrawOverlayEvent e) {
ItemRenderer itemRenderer = mc.getItemRenderer();
ClientPlayerEntity player = mc.player;
int scaledWidth = mc.getWindow().getScaledWidth();
int scaledHeight = mc.getWindow().getScaledHeight();
ColorUtil.fillGradient(new MatrixStack(), scaledWidth - (9 * 18 + 4), scaledHeight - (3 * 18 + 4), scaledWidth, scaledHeight, -1072689136, -804253680);
for (int i = 1; i <= 4; i++) {
for (int j = 0; j < 9; j++) {
int slot = i * 9 + j;
ItemStack itemStack = player.getInventory().getStack(slot);
boolean isEmpty = itemStack.isEmpty();
if (!isEmpty) {
int x = scaledWidth - (9 * 18 + 4) + j * 18 + 2;
int y = scaledHeight - (3 * 18 + 4) + (i - 1) * 18 + 2;
itemRenderer.renderGuiItemIcon(itemStack, x, y);
itemRenderer.renderGuiItemOverlay(mc.textRenderer, itemStack, x, y);
}
}
}
}
Aggregations