You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am making a backpack item (TConstruct compat), which can be modified like an Actual Tinker tool. I got to an idea that renderer can render item dynamically. Code that I did, for example:
@Override
public <T extends LivingEntity, M extends EntityModel<T>> void render(ItemStack stack, SlotContext slotContext, PoseStack matrixStack, RenderLayerParent<T, M> renderLayerParent, MultiBufferSource renderTypeBuffer, int light, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
if (renderLayerParent.getModel() instanceof HumanoidModel<?> model) {
// Tool, its size and color
ToolStack tool = ToolStack.copyFrom(stack);
int size = tool.getModifierLevel(TinThruDimModifiers.backpackModifier.get()) - 1;
int colorCode = tool.getPersistentData().getInt(TConstruct.getResource("dyed"));
// Setting base and additional translate and scale.
double[] startTran = {0.0D, -0.3D, -0.2D};
float[] startScale = {0.8F, 0.8F, 0.8F};
double[] addTran = {0.0D, -0.005D, -0.001D};
float[] addScale = {0.025F, 0.025F, 0.025F};
matrixStack.pushPose();
// Getting an RGBA of a color
float colorRed = (float) (colorCode >> 16 & 255) / 255.0F;
float colorGreen = (float) (colorCode >> 8 & 255) / 255.0F;
float colorBlue = (float) (colorCode & 255) / 255.0F;
if (colorRed == 0.0F && colorRed == 0.0F && colorRed == 0.0F){ // If there isn`t a dyed modifier, set to default
colorRed = 1.0F;
colorGreen = 1.0F;
colorBlue = 1.0F;
}
// Changing matrixStack so it can grow bigger, depending on a size modifier
matrixStack.mulPose(Vector3f.XP.rotationDegrees(180.0F));
matrixStack.translate(startTran[0], startTran[1] + addTran[1] * size, startTran[2] + addTran[2] * size);
matrixStack.scale(startScale[0] + addScale[0] * size, startScale[1] + addScale[1] * size, startScale[2] + addScale[2] * size);
// Rendering an item
ItemInHandRenderer renderer = new ItemInHandRenderer(Minecraft.getInstance());
renderer.renderItem(slotContext.entity(), stack, ItemTransforms.TransformType.FIXED, false, matrixStack, renderTypeBuffer, light);
matrixStack.popPose();
}
}
And ive got how to render GUI for it (not in here, but still), but I dont know how to tint a texture depending on a color. Forge documentation doesnt really help, tutorials just do not exist, so Im trying to ask here. WIll be very grateful for a hint.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am making a backpack item (TConstruct compat), which can be modified like an Actual Tinker tool. I got to an idea that renderer can render item dynamically. Code that I did, for example:
And ive got how to render GUI for it (not in here, but still), but I dont know how to tint a texture depending on a color. Forge documentation doesnt really help, tutorials just do not exist, so Im trying to ask here. WIll be very grateful for a hint.
Beta Was this translation helpful? Give feedback.
All reactions