Skip to content

Commit

Permalink
Fix item rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeRNG committed Jun 12, 2023
1 parent 891a7f5 commit ba3ff4d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.SimpleInventory;
Expand Down Expand Up @@ -407,7 +406,7 @@ protected void renderTabIcon(DrawContext context, DevInventoryGroup group) {
originX += 6;
originY += 8 + (isTopRow ? 2 : -2);
ItemStack itemStack = group.getIcon();
context.drawItemInSlot(textRenderer, itemStack, originX, originY);
context.drawItem(itemStack, originX, originY);
// this.itemRenderer.zOffset = 0.0F;
}
public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import dev.dfonline.codeclient.hypercube.item.Scope;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
Expand All @@ -19,7 +18,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(DrawContext.class)
public abstract class MItemRenderer {
public abstract class MDrawContext {
@Shadow @Final private MatrixStack matrices;

@Shadow public abstract int drawText(TextRenderer textRenderer, Text text, int x, int y, int color, boolean shadow);
Expand All @@ -39,7 +38,7 @@ private void additionalItemRendering(TextRenderer textRenderer, ItemStack stack,

this.matrices.translate(0.0F, 0.0F, 200.0F);
Scope scope = Scope.valueOf(scopeName);
this.drawText(textRenderer,Text.literal(scope.shortName).formatted(scope.color),x,y,0xFFFFFF,false);
this.drawText(textRenderer,Text.literal(scope.shortName).formatted(scope.color),x,y,0xFFFFFF,true);
matrices.translate(0.0F, 0.0F, -200.0F);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.util.InputUtil;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
Expand All @@ -23,7 +22,7 @@
*/
public abstract class GenericSwitcher extends Screen {
private static final Identifier TEXTURE = new Identifier("textures/gui/container/gamemode_switcher.png");
private List<SelectableButtonWidget> buttons = new ArrayList<>();
private final List<SelectableButtonWidget> buttons = new ArrayList<>();
private boolean usingMouseToSelect = false;
private Integer lastMouseX;
private Integer lastMouseY;
Expand Down Expand Up @@ -115,6 +114,7 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
}

private boolean checkFinished() {
if(this.client == null) return false;
if(!InputUtil.isKeyPressed(this.client.getWindow().getHandle(), HOLD_KEY)) {
Option selected = getSelected();
if(selected != null) selected.run();
Expand Down Expand Up @@ -159,6 +159,7 @@ public void renderButton(DrawContext context, int mouseX, int mouseY, float delt
context.drawTexture(TEXTURE,0, 0, 0.0F, 75.0F, 26, 26, 128, 128);
context.getMatrices().pop();

context.drawItem(option.icon, this.getX() + 5, this.getY() + 5);
context.drawItemInSlot(textRenderer, option.icon, this.getX() + 5, this.getY() + 5);

if(selected) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/CodeClient.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"render.MDebugRenderer",
"render.hud.MInGameHud",
"render.hud.MInGameOverlayRenderer",
"render.hud.MItemRenderer",
"render.hud.MDrawContext",
"render.hud.MTitleScreen",
"world.ClientWorldAccessor",
"world.MWorldRenderer",
Expand Down

0 comments on commit ba3ff4d

Please sign in to comment.