Jump to content

[SOLVED] Custom GUI not opening


MpB907

Recommended Posts

Link to comment
Share on other sites

Ah, I'm such a noob... Nearly everything is fixed now, except the furnace isn't working. It consumes fuel but doesn't melt any items. I am working on this with a friend of mine, and I don't know quite as much java as he does, so he does all the OpenGL stuff.

Link to comment
Share on other sites

Well take a look at net.minecraft.block.BlockFurnace, it may help you out.

Basicly if the fuel burn time isnt 0 then increase cook timer, if cook timer == 300 then reset cook timer and delete one item from the "to be cooked" slot and add x of the result items to the "already cooked" slot

Link to comment
Share on other sites

Well take a look at net.minecraft.block.BlockFurnace, it may help you out.

Basicly if the fuel burn time isnt 0 then increase cook timer, if cook timer == 300 then reset cook timer and delete one item from the "to be cooked" slot and add x of the result items to the "already cooked" slot

 

That's exactly what's written here:

 

	private static int getItemBurnTime(ItemStack itemstack) {
	if(itemstack == null){
		return 0;
	}else{
		Item item = itemstack.getItem();
		if(item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) {
			Block block = Block.getBlockFromItem(item);
			if(block == main.aniteBlock) return 216000;
		}
		if(item == main.aniteChunk) return 24000;
	}
	return GameRegistry.getFuelValue(itemstack);
}
public boolean isBurning() {
	return this.burnTime > 0;
}
public void updateEntity() {
	boolean flag = this.burnTime > 0;
	boolean flag1 = false;
	if(this.isBurning()) {
		this.burnTime--;
	}

	if(this.burnTime == 0 && this.canSmelt()) {
		this.currentItemBurnTime = this.burnTime = getItemBurnTime(this.slots[1]);
		if(this.isBurning()) {
			flag1 = true;
			if(this.slots[1] != null) {
				this.slots[1].stackSize--;
				if(this.slots[1].stackSize == 0) {
					this.slots[1] = this.slots[1].getItem().getContainerItem(this.slots[1]);
				}
			}
		}
		if(this.isBurning() && this.canSmelt()) {
			this.cookTime++;
			if(this.cookTime == this.furnaceSpeed) {
				this.cookTime = 0;
				this.smeltItem();
				flag1 = true;
			}
		}else{
			this.cookTime = 0;
		}
		if(flag != this.isBurning()) {
			flag1 = true;
			compressedBlock.updateCompressedBlockState(this.burnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
		}
	}
	if(flag1) {
		this.markDirty();
	}	
}

private boolean canSmelt() {
	if (this.slots[0] == null) {
		return false;
	} else {
		ItemStack itemstack = CompressedBlockRecipes.smelting().getSmeltingResult(this.slots[0]);
		if (itemstack == null) return false;
		if (this.slots[2] == null) return true;
		if (!this.slots[2].isItemEqual(itemstack)) return false;
		int result = slots[2].stackSize + itemstack.stackSize;
		return result <= getInventoryStackLimit() && result <= this.slots[2].getMaxStackSize();
	}
}
public void smeltItem() {
	if (this.canSmelt()) {
		ItemStack itemstack = CompressedBlockRecipes.smelting().getSmeltingResult(this.slots[0]);
		if (this.slots[2] == null) {
			this.slots[2] = itemstack.copy();
		} else if (this.slots[2].getItem() == itemstack.getItem()) {
			this.slots[2].stackSize += itemstack.stackSize;
		}
		--this.slots[0].stackSize;
		if(this.slots[0].stackSize >= 0){
			this.slots[0] = null;
		}
	}
}

 

AFAIK there is not any errors here... halp?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • You can try other builds of Quark/Zeta
    • Hello all, I recently tried to upgrade my Minecraft mod to version 1.21.3, and I seem to have a problem with the `RenderSystem#setShaderColor` method. Here is how the screen is usually supposed to look like: Here is how it looks at present: To further explain, the note labels atop of the note buttons are colored cyan (here) using `RenderSystem#setShaderColor`. The note buttons and labels get their colors from their native texture - white. This means that even though I set the coloring to apply to the label (top), it is applied to the button (bottom). What I conclude is happening then, in essence, is that this method (at least for my case) does not color the blit after - but rather the blit before..?  This also blocks me from later resetting the shader, as I need to set it back to white before the blitting is done, and not when it's done. So like... what? I've tested this further with other components that require this method, and this preceding-like behavior seems to be pretty consistent for them too.   I should mention that all the snippets I am about to show have all worked in past versions. In my class `ClientUtil`, the following methods are defined: public static void setShaderColor(final Color color, final float alpha) { RenderSystem.setShaderColor( color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, alpha ); } public static void setShaderColor(final Color color) { setShaderColor(color, 1); } public static void resetShaderColor() { setShaderColor(Color.WHITE); } //... public static RenderType guiRT(final ResourceLocation loc) { return RenderType.guiTextured(loc); } And here is the snippet from `NoteButtonRenderer#renderNote` using it: // "Note" here refers to those symbols in the middle of a note button protected void renderNote(final GuiGraphics gui, final InstrumentThemeLoader themeLoader) { final int noteWidth = noteButton.getWidth()/2, noteHeight = noteButton.getHeight()/2; ClientUtil.setShaderColor((noteButton.isPlaying() && !foreignPlaying) ? themeLoader.notePressed() : themeLoader.noteReleased() ); gui.blit(ClientUtil::guiRT, noteTextureProvider.get(), noteButton.getX() + noteWidth/2, noteButton.getY() + noteHeight/2, 0, 0, noteWidth, noteHeight, noteWidth, noteButton.getHeight()/2 ); ClientUtil.resetShaderColor(); } You may find the full source here. The odd thing is that Minecraft does seem to use this method the regular way I showed, for instance `SkyRenderer#renderSkyDisc` (not sure if I'l allowed to paste it). Could it be that I'm doing something wrong that leads to this issue..? I'm really stumped on this one.  I couldn't really find any change logs or documentation for this rendering API (even in this Fabric blog post), so I'm sorry if this seems obvious or anything.  Either way, any help would be appreciated.
    • This did work. rip Quark Thank you
    • It says Quark Requires zeta. do i just remove Quark? https://mclo.gs/cq799kI
    • It refers to the mod elenaidodge Backup the world and make a test without it
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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