mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 08:17:35 +00:00
[1.19.4] Replace blitOffset parameter with PoseStack in IItemDecorator (#9409)
* Replace blitOffset with PoseStack in IItemDecorator * Circumvent breaking changes * Fix blitOffset type
This commit is contained in:
1 parent
434c1ec4f8
commit
b33efc0727
4 files changed
+39
-41
No files matched your search
@@ -5,6 +5,8 @@
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -17,13 +19,22 @@ import net.minecraftforge.client.event.RegisterItemDecorationsEvent;
|
||||
*/
|
||||
public interface IItemDecorator
|
||||
{
|
||||
/**
|
||||
* Use {@linkplain IItemDecorator#render(PoseStack, Font, ItemStack, int, int)} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
default boolean render(Font font, ItemStack stack, int xOffset, int yOffset, float blitOffset) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is called after {@linkplain ItemRenderer#renderGuiItemDecorations(Font, ItemStack, int, int, String)} is done rendering.
|
||||
* Is called after {@linkplain ItemRenderer#renderGuiItemDecorations(PoseStack, Font, ItemStack, int, int, String)} is done rendering.
|
||||
* The StackCount is rendered at blitOffset+200 so use the blitOffset with caution.
|
||||
* <p>
|
||||
* The RenderState during this call will be: enableTexture, enableDepthTest, enableBlend and defaultBlendFunc
|
||||
* @return true if you have modified the RenderState and it has to be reset for other ItemDecorators
|
||||
*/
|
||||
boolean render(Font font, ItemStack stack, int xOffset, int yOffset, float blitOffset);
|
||||
default boolean render(PoseStack poseStack, Font font, ItemStack stack, int xOffset, int yOffset) {
|
||||
return IItemDecorator.this.render(font, stack, xOffset, yOffset, 0);
|
||||
}
|
||||
}
|
||||
@@ -5,21 +5,23 @@
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.client.event.RegisterItemDecorationsEvent;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class ItemDecoratorHandler
|
||||
@@ -53,12 +55,12 @@ public final class ItemDecoratorHandler
|
||||
return DECORATOR_LOOKUP.getOrDefault(stack.getItem(), EMPTY);
|
||||
}
|
||||
|
||||
public void render(Font font, ItemStack stack, int xOffset, int yOffset, float blitOffset)
|
||||
public void render(PoseStack poseStack, Font font, ItemStack stack, int xOffset, int yOffset)
|
||||
{
|
||||
resetRenderState();
|
||||
for (IItemDecorator itemDecorator : itemDecorators)
|
||||
{
|
||||
if (itemDecorator.render(font, stack, xOffset, yOffset, blitOffset))
|
||||
if (itemDecorator.render(poseStack, font, stack, xOffset, yOffset))
|
||||
resetRenderState();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user