
DARKHAWX
Members-
Posts
129 -
Joined
-
Last visited
Everything posted by DARKHAWX
-
[1.16.5] Rendering text in GUI causes all future rendering to fail
DARKHAWX replied to DARKHAWX's topic in Modder Support
Unfortunate, thanks for looking anyway. I'll have to fiddle around with it. -
[1.16.5] Rendering text in GUI causes all future rendering to fail
DARKHAWX replied to DARKHAWX's topic in Modder Support
Whoops! Sorry about that. I've updated the code and removed the reference. The errant line (DivineFavourTabGui.java:31) is currently commented out as well. -
[1.16.5] Rendering text in GUI causes all future rendering to fail
DARKHAWX replied to DARKHAWX's topic in Modder Support
Here's the git repo: https://gitlab.com/LickBreadStudios/mesoamerica-mythology If you do clone it - K is the button to open the GUI by default. -
[1.16.5] Rendering text in GUI causes all future rendering to fail
DARKHAWX replied to DARKHAWX's topic in Modder Support
Here's the code which renders the GUI_LABEL and tab.drawIcon is called. It's called after drawWindowBackground (in code above) is called public void renderWindow(MatrixStack matrixStack, int offsetX, int offsetY) { RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.enableBlend(); this.minecraft.getTextureManager().bind(WINDOW); this.blit(matrixStack, offsetX, offsetY, 0, 0, GUI_WIDTH, GUI_HEIGHT); if (this.tabs.size() >= 1) { this.minecraft.getTextureManager().bind(TABS); for (DivineRelationshipsTabGui tab : this.tabs) { if (tab.getPage() == tabPage) { tab.renderTabSelectorBackground(matrixStack, offsetX, offsetY, tab == this.selectedTab); } } RenderSystem.enableRescaleNormal(); RenderSystem.defaultBlendFunc(); for (DivineRelationshipsTabGui tab : this.tabs) { if (tab.getPage() == tabPage) tab.drawIcon(offsetX, offsetY, this.itemRenderer); } RenderSystem.disableBlend(); } this.font.draw(matrixStack, GUI_LABEL, (float)(offsetX + 8), (float)(offsetY + 6), 4210752); } drawIcon simply looks like the following. Where index is the tab number and stack is the item to render. public void drawIcon(int offsetX, int offsetY, int index, ItemRenderer renderItemIn, ItemStack stack) { int i = offsetX + this.getX(index); int j = offsetY + this.getY(index); switch(this) { case ABOVE: i += 6; j += 9; break; case BELOW: i += 6; j += 6; break; } renderItemIn.renderGuiItem(stack, i, j); } I believe these are effectively clones of the Advancements screen code just with some code removed. -
So I've got myself a GUI similar to that of the Advancements screen or the Creative screen where I've got a main screen that renders the window, and tabs that render their own info. Everything works fine and dandy, until I have one of the tabs render text. When that happens, all other text rendered by the screen, along with the tab icon are no longer rendered. There seemingly are no errors, and when I try debugging I can see that each code path is still called so I'm not sure what's going on. So within my screen the main render function looks as follows public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { int i = (this.width - GUI_WIDTH) / 2; int j = (this.height - GUI_HEIGHT) / 2; this.renderBackground(matrixStack); if (maxPages != 0) { ITextComponent page = new StringTextComponent(String.format("%d / %d", tabPage + 1, maxPages + 1)); int width = this.font.width(page); RenderSystem.disableLighting(); this.font.draw(matrixStack, page.getString(), i + (GUI_WIDTH / 2) - (width / 2), j - 44, -1); } this.drawWindowBackground(matrixStack, mouseX, mouseY, i, j); this.renderWindow(matrixStack, i, j); this.drawWindowTooltips(matrixStack, mouseX, mouseY, i, j); } The errant line is within this.drawWindowBackground(matrixStack, mouseX, mouseY, i, j);. Here we render the tab window itself. private void drawWindowBackground(MatrixStack matrixStack, int mouseX, int mouseY, int offsetX, int offsetY) { if (this.selectedTab == null) { fill(matrixStack, offsetX + 9, offsetY + 18, offsetX + 9 + 234, offsetY + 18 + 113, -16777216); int i = offsetX + 9 + 117; drawCenteredString(matrixStack, this.font, EMPTY, i, offsetY + 18 + 56 - 9 / 2, -1); drawCenteredString(matrixStack, this.font, SAD_LABEL, i, offsetY + 18 + 113 - 9, -1); } else { RenderSystem.pushMatrix(); RenderSystem.translatef((float)(offsetX + 9), (float)(offsetY + 18), 0.0F); this.selectedTab.drawTabBackground(matrixStack); RenderSystem.popMatrix(); RenderSystem.depthFunc(515); RenderSystem.disableDepthTest(); } } From there the tab draws itself as follows: public void drawTabBackground(MatrixStack matrixStack) { if (!this.centered) { this.scrollX = 117 - (this.maxX + this.minX) / 2.0D; this.scrollY = 56 - (this.maxY + this.minY) / 2.0D; this.centered = true; } RenderSystem.pushMatrix(); RenderSystem.enableDepthTest(); RenderSystem.translatef(0.0F, 0.0F, 950.0F); RenderSystem.colorMask(false, false, false, false); fill(matrixStack, 4680, 2260, -4680, -2260, -16777216); RenderSystem.colorMask(true, true, true, true); RenderSystem.translatef(0.0F, 0.0F, -950.0F); RenderSystem.depthFunc(518); fill(matrixStack, MAX_WIDTH, MAX_HEIGHT, 0, 0, -16777216); RenderSystem.depthFunc(515); this.minecraft.getTextureManager().bind(background); int i = MathHelper.floor(this.scrollX); int j = MathHelper.floor(this.scrollY); int k = i % 16; int l = j % 16; for(int i1 = -1; i1 <= 15; ++i1) { for(int j1 = -1; j1 <= 8; ++j1) { blit(matrixStack, k + 16 * i1, l + 16 * j1, 0.0F, 0.0F, 16, 16, 16, 16); } } this.renderWindow(matrixStack); RenderSystem.depthFunc(518); RenderSystem.translatef(0.0F, 0.0F, -950.0F); RenderSystem.colorMask(false, false, false, false); fill(matrixStack, 4680, 2260, -4680, -2260, -16777216); RenderSystem.colorMask(true, true, true, true); RenderSystem.translatef(0.0F, 0.0F, 950.0F); RenderSystem.depthFunc(515); RenderSystem.popMatrix(); } And finally we get to the errant line: this.renderWindow(matrixStack);. This method is overridden by each tab and renders the content of the tab. For my tab it is simple, we render a piece of text at the center of the tab. This text renders fine, however it breaks the tab icon and window name. @Override protected void renderWindow(MatrixStack matrixStack) { ITextComponent divineFavourText = new TranslationTextComponent("screen.mesoamericamythology.divine_relationships.favour.divine_favour", this.getRelationship().getDivineFavour()); // x, y, colour // This line breaks the rendering :( drawCenteredString(matrixStack, this.minecraft.font, divineFavourText, MAX_WIDTH / 2, MAX_HEIGHT / 2, Integer.parseInt("FFFFFF", 16)); } Below I have two screenshots. The one on the left is what the UI looks like when I don't draw the string in renderWindow. The right is what happens when I do. I'm a little befuddled at the moment. Hoping someone has more pointers that would help me understand what is going on.
-
Hey there, I'm trying to setup a basic keybinding, but I can't seem to get the event to fire. Here's my code for subscribing to the event: @Mod.EventBusSubscriber public class ModKeyInputs { @SubscribeEvent public void onKeyInput(InputEvent.KeyInputEvent event) { if (ModKeyBindings.OPEN_DIVINE_FAVOUR_RELATIONSHIP.isPressed()) { Minecraft.getInstance().displayGuiScreen(new DivineFavourRelationshipsScreen(Minecraft.getInstance().player)); } } } Now I've put a breakpoint in the method there at the start, and I can never get it to fire. Am I subscribing to this event incorrectly? As a side note, is there much difference between using @Mod.EventBusSubscriber on a class versus MOD_EVENT_BUS.register(ModKeyInputs.class); in the constructor of the main mod class?
-
Didn't realise doing both was bad, thought it was required. I've commented out the MOD_EVENT_BUS registration and it worked like a charm. Thanks!
-
Hey, recently upgraded my mod from 1.15 to 1.16 and I previously had a subscription to RenderGameOverlayEvent.Post however since upgrading I now get the following exception when starting the game: Method public static void com.lickbread.mesoamericamythology.registry.event.ModGuiHandler.renderGameOverlay(net.minecraftforge.client.event.RenderGameOverlayEvent$Post) has @SubscribeEvent annotation, but takes an argument that is not a subtype of the base type interface net.minecraftforge.fml.event.lifecycle.IModBusEvent: class net.minecraftforge.client.event.RenderGameOverlayEvent$Post For reference my subscription code: @Mod.EventBusSubscriber public class ModGuiHandler { @SubscribeEvent public static void renderGameOverlay(RenderGameOverlayEvent.Post event) { if (event.getType() == RenderGameOverlayEvent.ElementType.HOTBAR) { new BloodLevelGui().render(); } } } And registration code: @Mod(MesoamericaMythologyMod.MOD_ID) public class MesoamericaMythologyMod { public static final String MOD_ID = "mesoamericamythology"; public static final Logger LOGGER = LogManager.getLogger(MOD_ID); public static IEventBus MOD_EVENT_BUS; public MesoamericaMythologyMod() { //... MOD_EVENT_BUS.register(ModGuiHandler.class); } RenderGameOverlayEvent only extends Event and not IModBusEvent. None of the events that implement this interface seem to be correct, so I'm thinking either I need to change my registration or subscription to listen to a different event bus potentially, but I'm not sure what the correct one is. I was looking at some of the places where RenderGameOverlayEvent was used and came across code like the following: MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Post(mStack, eventParent, type)); Which confuses me here as it is posting to the EVENT_BUS, although there is nothing of IEventBus that limits events sent to the IModBusEvent. Does anyone know the answer here?
-
Hi there, I have an item, that on clicked on an entity (called in itemInteractionForEntity), it would attempt to add some data to the stacks tag. When debugging, I can see that the method is called and the stack nbt is updated, but it seems like it's not persisted anywhere outside of that method call. Subsequent calls to that method show that the stack tag is empty. I've done some fiddling around, but I'm really not sure what's going on. Here's my code for the method call: public boolean itemInteractionForEntity(ItemStack stack, PlayerEntity playerIn, LivingEntity target, Hand hand) { if (target.world.isRemote || target instanceof PlayerEntity || hand != Hand.MAIN_HAND) { return false; } CompoundNBT nbt = stack.getOrCreateChildTag(VOID_POCKET_KEY); if (nbt.contains(HELD_ENTITY_KEY) || nbt.contains(HELD_INVENTORY_KEY)) { return false; } if (nbt.contains(LAST_INTERACT_TIME_KEY) && nbt.getLong(LAST_INTERACT_TIME_KEY) - target.world.getGameTime() <= MIN_INTERACT_TIME) { return false; } CompoundNBT entityNbt = new CompoundNBT(); target.writeUnlessRemoved(entityNbt); nbt.put(HELD_ENTITY_KEY, entityNbt); nbt.putString(HELD_ENTITY_NAME_KEY, target.getDisplayName().getFormattedText()); nbt.remove(LAST_INTERACT_TIME_KEY); nbt.putLong(LAST_INTERACT_TIME_KEY, target.world.getGameTime()); stack.setTagInfo(VOID_POCKET_KEY, nbt); target.remove(); return true; } Is there some additional thing I need to do to ensure my code is synced? Or do I need to do something with the player? Looking at some vanilla examples I can see that name tags and dyes don't do server checks, while shears do. None of them update the itemstack tag, but they do either damage the itemstack or reduce count.
-
Hi there, As the title states I have a TileEntityRenderer that displays a floating, rotating item or block, something I'd like to do is also render the shadow of the item I'm displaying on the block below (which would be the block that the TileEntityRenderer is for). Looking through the base code, but struggling to find a usage I could work with. I see the following, but it and things attached to it are private. renderShadow(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, Entity entityIn, float weightIn, float partialTicks, IWorldReader worldIn, float sizeIn) Does anyone know what I could do?
-
Thanks for that. I ended up just registering a block for it and loading the model like normal.
-
It's for a TileEntityRenderer. I'd like to animate the position of this extra model. Would I use modelLoader.getModelOrMissing() for this purpose? I suppose something I could do is create "nothing" blocks that use the model and then load that using block state; but I'm not sure if that's a good way to go about it.
-
Hi there, I know I can load an existing block model like: BlockRendererDispatcher blockRenderer = Minecraft.getInstance().getBlockRendererDispatcher(); IBakedModel bakedModel = blockRenderer.getBlockModelShapes().getModel(state); IModelData data = bakedModel.getModelData(world, pos, state, ModelDataManager.getModelData(world, pos)); blockRenderer.getBlockModelRenderer().renderModel(world, bakedModel, state, pos, matrixStackIn, bufferIn.getBuffer(Atlases.getSolidBlockType()), false, new Random(), 42, combinedOverlayIn, data); What I'm wondering is how I can load a model that doesn't have an associated item, block or entity?
-
Thanks worked! Code below for those that would like it: @Mod.EventBusSubscriber public class ModAtlasTextures { @SubscribeEvent public static void onTextureStitchEvent(TextureStitchEvent.Pre event) { if (event.getMap().getTextureLocation() == LOCATION_BLOCKS_TEXTURE) { event.addSprite(ModShieldItemStackTileEntityRenderer.LOCATION_SHIELD_BASE_NO_PATTERN); } } }
-
Hi there, I've been adding a custom shield to my mod. It's working fine and all, however I can't seem to get my custom textures working. I believe the problem lies in that the default way the shield is rendered uses materials that take in an AtlasTexture. Now I've tried using the same texture altas sprite that the ShieldModel, which is `AtlasTexture.LOCATION_BLOCKS_TEXTURE`, but that doesn't work. I'm going to keep searching, but asking here if someone knows the answer. Is there an existing AtlasTexture that I can use that will have my texture baked into it? Or do I need to register my own (and how to go about that)?
-
To test I would dump the capability in the logs each time writeNBT and readNBT was called. I could see that as I did actions that modified the capability the capability did indeed change. So when I created a relationship or added divine favour or met a god, it would be saved correctly in the capability attached to the player. However if I saved and quit, then reloaded the world, the capability was reset.
-
Hmm, what do you mean? All data only exists on server side, and interactions/changes to capability only happen on the server side. What part isn't happening on the server side? Are you saying the client side also needs the data?
-
As the title states, I've added a capability to the player and registered it. I can interact with it, and it's updated as normal while I play, but as soon as the player leaves the game the capability and rejoins, their capability is reset to the default - which to me seems like it's not persisting the change. I can also confirm that the attachCapabilities method is being called. I can see that the writeNBT method is being called when I open the pause menu, and it has the right data in it. But when I log in, the readNBT is always displaying null. I'm not sure what I'm doing wrong - I know for TileEntities I'd have to call markDirty to force persist data, but as far as my understanding goes, Entities don't have or require a method like that. Here is my code: CapabilityProvider: Storage File: Capability interface File: Capability implementation file: AttachCapabilities event handler OnCommonSetup registering capabilities Registration of capability Where I increment the capability data
-
What you want sounds like the capability system: https://mcforge.readthedocs.io/en/latest/datastorage/capabilities/
-
Hi there, This may come across as a dumb question, but I'm currently creating a multiblocks that will use one large model when rendering. I know that I could have each block be a tile entity, with a special renderer that hides the block model when the multiblock is complete, and then use master and slave system to progagate interactions with the slave blocks to the master block, but that doesn't feel like the best method. Something I want to avoid is having to have each block in the multiblock be its own tile entity. I currently have a master tile entity that would check on block change whether it is built and then I would like it to destroy each of the other blocks in the multiblock and then render the master itself as a large singular model. The bounding box/collision box of the multiblock to be one large connected block rather than individual blocks; which means that if a player attempted to place a block where the multiblock exists it should fail. Looking into vanilla solutions I don't think there is an example of this. So I'm wondering, if anyone knows of a good way of achieving this.
-
Well I get that, but I don't know how not to use the deprecated method... I can't seem to find a tutorial or example that works...
-
So I recently decided I would finally create an entity. I had almost finished everything including the render but as I spawn it in game it doesn't seem to render right... Its probably got to do with the fact that I'm using the old RenderingRegistry#registerEntityRenderingHandler() method that is deprecated... The entity is supposed to just be effectively a floating block... Here are the relevant files: EntityHeartFamiliar: RendererHeartFamiliar: ModEntities: ItemHeart: ModEntities#registerEntities() called in CommonProxy#preInit(). ModEntities#registerRenderers() is called in ClientProxy#init(). I don't really know what it is wrong, so if possible could someone help me. If you need any more code, let me know.
-
This is a very stupid question, but how do I spawn a potion effect particle in a world with a custom color? I'm using world.spawnParticle(EnumParticleTypes.SPELL_MOB, x, y, z, 0.0D, yVel, 0.0D); to spawn the particle but don't know how to set the color. I understand its got to do with the last optional parameter, but don't know what I'm supposed to enter to get it to work. Secondly what is the most efficient way of creating a block that spans three blocks vertically? I need to be able to interact with the blocks above the initially placed block and for it to open the tile entity associated with that block.