Jump to content

Ammonium_

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by Ammonium_

  1. Hi all, I think the title says it all. I was using the ItemRenderer.renderGuiItem(), .renderAndDecorateFakeItem() and .blitOffset methods/properties on my mod for 1.18.2, but whilst trying to update to 1.19.4 I realized that they were no longer available, nor could I find any suitable replacements. If necessary, here is how I was using each method: - .renderGuiItem() and .blitOffset were to render fake items inside a Button subclass: //Draw item if(item.isItem()) { itemRenderer.renderGuiItem(item.getItem(), x, y); } //Highlight background and write item name if hovered or focused if(isHoveredOrFocused()){ isMouseOn = true; fill(matrix, x, y, x+width, y+height, 0xFFFFFFDF); }else{ isMouseOn = false; } //Write quantity based on buttons pressed (sneak & run) matrix.pushPose(); matrix.translate(0, 0, itemRenderer.blitOffset+201); matrix.scale(.5f, .5f, 1); Font font = Minecraft.getInstance().font; drawString(matrix, font, getQuantity()+"", 2*(x+16)- font.width(getQuantity()+""), 2*(y)+24, 0xFFFFFF); if(item.isTag()){ drawString(matrix, font, "#", 2*x+width*2-font.width("#")-1, 2*y+1, 0xFFC921); }else if(!item.isItem()){ drawString(matrix, font, "F", 2*x+1, 2*y+1, 0x6666FF); } - .renderAndDecorateFakeItem() was used to render a fake item inside a Screen subclass: private void renderItem(PoseStack matrixStack, Item item, int x, int y) { ItemRenderer itemRenderer = this.minecraft.getItemRenderer(); ItemStack itemStack = new ItemStack(item); itemRenderer.renderAndDecorateFakeItem(itemStack, x, y); } Which are the alternatives for 1.19.4?
  2. Replying to myself with the answer, you just have to switch to using a builder: public BuySellButton(int x, int y, String buyText, String sellText, boolean isBuy, OnPress listener) { super(Button.builder(Component.literal(isBuy ? buyText : sellText), listener) .pos(x, y) .size(50, 12)); this.isBuy = isBuy; }
  3. Hi all, I've been updating my mod from 1.18 to 1.19 and so far I've been able to fix the changes regarding literal/translatable Components and other minor changes, but the Button class' constructor seems to have changed, and I don't know how to update it. Here is my working constructor for 1.18: public BuySellButton(int x, int y, String buyText, String sellText, boolean isBuy, OnPress listener) { super(x, y, 50, 12, new TextComponent((isBuy ? buyText : sellText)), listener); this.isBuy = isBuy; } Simply changing the component does not work: public BuySellButton(int x, int y, String buyText, String sellText, boolean isBuy, OnPress listener) { super(x, y, 50, 12, Component.literal((isBuy ? buyText : sellText)), listener); this.isBuy = isBuy; } Cannot resolve method 'super(int, int, int, int, MutableComponent, OnPress)' Here are the available constructors/builders from the Button class: public static Button.Builder builder(Component p_254439_, Button.OnPress p_254567_) { return new Button.Builder(p_254439_, p_254567_); } protected Button(int p_259075_, int p_259271_, int p_260232_, int p_260028_, Component p_259351_, Button.OnPress p_260152_, Button.CreateNarration p_259552_) { super(p_259075_, p_259271_, p_260232_, p_260028_, p_259351_); this.onPress = p_260152_; this.createNarration = p_259552_; } protected Button(Builder builder) { this(builder.x, builder.y, builder.width, builder.height, builder.message, builder.onPress, builder.createNarration); setTooltip(builder.tooltip); // Forge: Make use of the Builder tooltip } Can someone please help me understand how to update my Button constructor?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.