Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


  • Posts

  • Joined

  • Last visited


  • Gender
  • URL
  • Location
  • Personal Text

Recent Profile Visitors

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

DARKHAWX's Achievements

Creeper Killer

Creeper Killer (4/8)



  1. Unfortunate, thanks for looking anyway. I'll have to fiddle around with it.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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?
  7. 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!
  8. 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?
  9. Alright worked it out. I'm pretty dumb. If you're in creative mode the item that gets used is a copy of the original item (to prevent durability loss and the like I suppose). In survival it works fine. So I guess I just need to replace the actual item when in creative.
  10. 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.
  11. 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?
  12. Thanks for that. I ended up just registering a block for it and loading the model like normal.
  13. 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.
  14. 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?
  15. 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); } } }
  • Create New...

Important Information

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