Jump to content

Squander

Members
  • Posts

    89
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Squander's Achievements

Stone Miner

Stone Miner (3/8)

0

Reputation

  1. First check if you are on the server side if(!level.isClientSide()). You don't need to check if the item in the player's main hand is the same as your item, you can use the last boolean variable, its name is isSelected. If isSelected is false then flag to false, if true check if(!flag) next add absorptions and set flag to true.
  2. My custom DimensionSpecialEffects public class CustomEffects extends DimensionSpecialEffects { public CustomEffects() { super(Float.NaN, true, DimensionSpecialEffects.SkyType.NONE, false, true); } public Vec3 getBrightnessDependentFogColor(Vec3 p_108901_, float p_108902_) { return p_108901_; } public boolean isFoggyAt(int p_108898_, int p_108899_) { return true; } @Nullable public float[] getSunriseColor(float p_108888_, float p_108889_) { return null; } }
  3. @SubscribeEvent public static void onAttachToEntity(AttachCapabilitiesEvent<Entity> event){ if(event.getObject() instanceof Player player){ event.addCapability(Helper.createRL("player_data"), new PlayerData(player)); } } public PlayerData(Player player) { this.player = player; this.setCurrentEnergy(this.getMaxEnergy()); } public int getMaxEnergy() { return (int) this.player.getAttributeValue(AttributeInit.MAX_ENERGY.get()); } and console log https://gist.github.com/MatyBotStorage/138473d7c4c7a43ad4b453baa4fda529
  4. As in the topic, I am using this code. The button text is obscured by the tooltip but the button itself is not, I don't know how to fix it. public void renderButton(PoseStack poseStack, int pMouseX, int pMouseY, float pPartialTick) { Minecraft mc = Minecraft.getInstance(); int k = this.getYImage(this.isHovered); ScreenUtils.blitWithBorder(poseStack, WIDGETS_LOCATION, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset()); this.renderBg(poseStack, mc, pMouseX, pMouseY); Component buttonText = this.getMessage(); int strWidth = mc.font.width(buttonText); int ellipsisWidth = mc.font.width("..."); if (strWidth > width - 6 && strWidth > ellipsisWidth) buttonText = Component.literal(mc.font.substrByWidth(buttonText, width - 6 - ellipsisWidth).getString() + "..."); drawCenteredString(poseStack, mc.font, buttonText, this.x + this.width / 2, this.y + (this.height - 8) / 2, getFGColor()); if(this.isHoveredOrFocused()){ this.renderToolTip(poseStack, pMouseX, pMouseY); } }
  5. As in the topic, I need to send a package and send a list with my object but I don't know how to do it.
  6. So what should I do to get the current value
  7. Values in init always returning 0, this only applies to menu references
  8. Well I created an EnergyWidget in init, in the constructor calls this.menu.getEnergy(), this.menu.getMaxEnergy(), but I don't know why they return 0 all the time, but when I call these methods in renderBg method then they return correct values. @Override protected void init() { super.init(); this.xPos = (width - imageWidth) / 2; this.yPos = (height - imageHeight) / 2; this.addRenderableWidget(new EnergyWidget(this, this.menu.getEnergy(), this.menu.getMaxEnergy(), WIDGETS, this.xPos + 125, this.yPos + 20)); } @Override protected void renderBg(PoseStack poseStack, float pPartialTick, int pMouseX, int pMouseY) { ClientHelper.renderStuff(TEXTURE); this.blit(poseStack, this.xPos, this.yPos, 0, 0, imageWidth, imageHeight); if(this.menu.isWorking()){ int progress = this.menu.getFuelProgress(); this.blit(poseStack, this.xPos + 81, this.yPos + 31 + 12 - progress, 176, 12 - progress, 14, progress + 1); } }
  9. Helper.getRc returns a new ResourceLocation instance with mod id
  10. My texture path is assets/apocaalypse/textures/entity/chest/norma.png and normal_lef.png and normal_right.png And I changed the military chest render class to vanilla event.registerBlockEntityRenderer(BlockEntityInit.MILITARY_CHEST.get(), ChestRenderer::new);
  11. Well i don't see this method but i did something like this and it still doesn't work. public class MilitaryChestRender extends ChestRenderer<MilitaryChestBlockEntity> { public static final Material CHEST_LOCATION = chestMaterial("normal"); public static final Material CHEST_LOCATION_LEFT = chestMaterial("normal_left"); public static final Material CHEST_LOCATION_RIGHT = chestMaterial("normal_right"); public MilitaryChestRender(BlockEntityRendererProvider.Context pContext) { super(pContext); } @Override protected Material getMaterial(MilitaryChestBlockEntity blockEntity, ChestType chestType) { return chooseMaterial(chestType, CHEST_LOCATION, CHEST_LOCATION_LEFT, CHEST_LOCATION_RIGHT); } public static Material chooseMaterial(ChestType pChestType, Material pDoubleMaterial, Material pLeftMaterial, Material pRightMaterial) { return switch (pChestType) { case LEFT -> pLeftMaterial; case RIGHT -> pRightMaterial; default -> pDoubleMaterial; }; } public static Material chestMaterial(String chestName) { return new Material(Sheets.CHEST_SHEET, Helper.getRc("textures/entity/chest/" + chestName)); } }
  12. Okay, it worked, but I'm wondering how I can change the texture of the chest.
  13. Hi. I create a custom chest, but neither a block not an inventory item is rendered.
×
×
  • Create New...

Important Information

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