Jump to content

Recommended Posts

Posted

Hey, I'm having an issue with my custom block. When I right-click it, my GUI doesn't show up. What's the reason?

 

Main Class

GameRegistry.registerBlock(crate, crate.getUnlocalizedName().substring(5));
GameRegistry.registerTileEntity(TileEntityCrate.class, "tile_crate");
NetworkRegistry.INSTANCE.registerGuiHandler(DecorationMod.instance, new GuiHandlerCrate());

 

Block Class

package com.gwater.decorationmod.block;

import net.minecraft.block.BlockContainer;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import com.gwater.decorationmod.DecorationMod;
import com.gwater.decorationmod.handler.GuiHandlerCrate;
import com.gwater.decorationmod.tileentity.TileEntityCrate;

public class Crate extends BlockContainer {

public Crate(Material wood) {
	super(wood);
	this.setUnlocalizedName("crate");
	this.setHardness(2.5F);
	this.setHarvestLevel("axe", 0);
	this.setStepSound(SoundType.WOOD);
	this.setCreativeTab(DecorationMod.tabDecorationMod);
}

@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
	return new TileEntityCrate();
}

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
	if(!worldIn.isRemote) {
		playerIn.openGui(DecorationMod.instance, GuiHandlerCrate.getGuiID(), worldIn, pos.getX(), pos.getY(), pos.getZ());
	}
	return true;
}

@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {

	IInventory inventory = worldIn.getTileEntity(pos) instanceof IInventory ? (IInventory)worldIn.getTileEntity(pos) : null;
	if(inventory != null) {
		for(int i = 0; i < inventory.getSizeInventory(); i++) {
			if(inventory.getStackInSlot(i) != null) {
				EntityItem item = new EntityItem(worldIn, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, inventory.getStackInSlot(i));
				float multiplier = 0.1F;
				float motionX = worldIn.rand.nextFloat() - 0.5F;
				float motionY = worldIn.rand.nextFloat() - 0.5F;
				float motionZ = worldIn.rand.nextFloat() - 0.5F;
				item.motionX = motionX * multiplier;
				item.motionY = motionY * multiplier;
				item.motionZ = motionZ * multiplier;

				worldIn.spawnEntityInWorld(item);
			}
		}
		inventory.clear();
	}

	super.breakBlock(worldIn, pos, state);
}

@Override
public BlockRenderLayer getBlockLayer() {
	return BlockRenderLayer.SOLID;
}

@Override
public EnumBlockRenderType getRenderType(IBlockState state) {
	return EnumBlockRenderType.MODEL;
}

@Override
public boolean isOpaqueCube(IBlockState state) {
	return true;
}

@Override
public boolean isFullCube(IBlockState state) {
	return true;
}
}

 

Container Class

package com.gwater.decorationmod.container;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;

import com.gwater.decorationmod.tileentity.TileEntityCrate;

public class ContainerCrate extends Container {

private TileEntityCrate tileEntityCrate;

private final int HOTBAR_SLOT_COUNT = 9;
private final int PLAYER_INVENTORY_ROW_COUNT = 3;
private final int PLAYER_INVENTORY_COLUMN_COUNT = 9;
private final int PLAYER_INVENTORY_SLOT_COUNT = PLAYER_INVENTORY_COLUMN_COUNT * PLAYER_INVENTORY_ROW_COUNT;
private final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT;

private final int VANILLA_FIRST_SLOT_INDEX = 0;
private final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT;
private final int TE_INVENTORY_SLOT_COUNT = 9;

public ContainerCrate(InventoryPlayer invPlayer, TileEntityCrate tileEntityCrate) {
	this.tileEntityCrate = tileEntityCrate;
	final int SLOT_X_SPACING = 18;
	final int SLOT_Y_SPACING = 18;
	final int HOTBAR_XPOS = 8;
	final int HOTBAR_YPOS = 109;

	for(int x = 0; x < HOTBAR_SLOT_COUNT; x++) {
		int slotNumber = x;
		addSlotToContainer(new Slot(invPlayer, slotNumber, HOTBAR_XPOS + SLOT_X_SPACING * x, HOTBAR_YPOS));
	}

	final int PLAYER_INVENTORY_XPOS = 8;
	final int PLAYER_INVENTORY_YPOS = 51;

	for(int y = 0; y < PLAYER_INVENTORY_ROW_COUNT; y++) {
		for(int x = 0; x < PLAYER_INVENTORY_COLUMN_COUNT; x++) {
			int slotNumber = HOTBAR_SLOT_COUNT + y * PLAYER_INVENTORY_COLUMN_COUNT + x;
			int xpos = PLAYER_INVENTORY_XPOS + x * SLOT_X_SPACING;
			int ypos = PLAYER_INVENTORY_YPOS + y * SLOT_Y_SPACING;
			addSlotToContainer(new Slot(invPlayer, slotNumber, xpos, ypos));
		}
	}

	if(TE_INVENTORY_SLOT_COUNT != tileEntityCrate.getSizeInventory()) {
		System.err.println("Mismatched slot count in ContainerCrate(" + TE_INVENTORY_SLOT_COUNT + ") and TileEntityCrate(" + tileEntityCrate.getSizeInventory() + ")");
	}

	final int TILE_INVENTORY_XPOS = 8;
	final int TILE_INVENTORY_YPOS = 20;

	for(int x = 0; x < TE_INVENTORY_SLOT_COUNT; x++) {
		int slotNumber = x;
		addSlotToContainer(new Slot(tileEntityCrate, slotNumber, TILE_INVENTORY_XPOS + SLOT_X_SPACING * x, TILE_INVENTORY_YPOS));
	}
}

@Override
public boolean canInteractWith(EntityPlayer playerIn) {
	return tileEntityCrate.isUseableByPlayer(playerIn);
}

@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int sourceSlotIndex) {
	Slot sourceSlot = (Slot)inventorySlots.get(sourceSlotIndex);
	if (sourceSlot == null || !sourceSlot.getHasStack()) return null;
	ItemStack sourceStack = sourceSlot.getStack();
	ItemStack copyOfSourceStack = sourceStack.copy();

	// Check if the slot clicked is one of the vanilla container slots
	if (sourceSlotIndex >= VANILLA_FIRST_SLOT_INDEX && sourceSlotIndex < VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT) {
		// This is a vanilla container slot so merge the stack into the tile inventory
		if (!mergeItemStack(sourceStack, TE_INVENTORY_FIRST_SLOT_INDEX, TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT, false)){
			return null;
		}
	} else if (sourceSlotIndex >= TE_INVENTORY_FIRST_SLOT_INDEX && sourceSlotIndex < TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT) {
		// This is a TE slot so merge the stack into the players inventory
		if (!mergeItemStack(sourceStack, VANILLA_FIRST_SLOT_INDEX, VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT, false)) {
			return null;
		}
	} else {
		System.err.print("Invalid slotIndex:" + sourceSlotIndex);
		return null;
	}

	// If stack size == 0 (the entire stack was moved) set slot contents to null
	if (sourceStack.stackSize == 0) {
		sourceSlot.putStack(null);
	} else {
		sourceSlot.onSlotChanged();
	}

	sourceSlot.onPickupFromSlot(playerIn, sourceStack);
	return copyOfSourceStack;
}

@Override
public void onContainerClosed(EntityPlayer playerIn) {
	super.onContainerClosed(playerIn);
	this.tileEntityCrate.closeInventory(playerIn);
}
}

 

GUI Class

package com.gwater.decorationmod.gui;

import java.awt.Color;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;

import com.gwater.decorationmod.References;
import com.gwater.decorationmod.container.ContainerCrate;
import com.gwater.decorationmod.tileentity.TileEntityCrate;

public class GuiCrate extends GuiContainer {

private static final ResourceLocation texture = new ResourceLocation(References.MODID, "/textures/gui/crate_gui_bg.png");
private TileEntityCrate tileEntityCrate;

public GuiCrate(InventoryPlayer invPlayer, TileEntityCrate tile) {
	super(new ContainerCrate(invPlayer, tile));
	tileEntityCrate = tile;

	xSize = 176;
	ySize = 133;
}

@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
	Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
	GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
	drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
}

@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
	final int LABEL_XPOS = 5;
	final int LABEL_YPOS = 5;
	fontRendererObj.drawString(tileEntityCrate.getDisplayName().getUnformattedText(), LABEL_XPOS, LABEL_YPOS, Color.DARK_GRAY.getRGB());
}
}

 

GUI Handler Class

package com.gwater.decorationmod.handler;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler;

import com.gwater.decorationmod.container.ContainerCrate;
import com.gwater.decorationmod.tileentity.TileEntityCrate;

public class GuiHandlerCrate implements IGuiHandler {

private static final int GUI_ID = 30;
public static int getGuiID() {return GUI_ID;}

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	if(ID != getGuiID()) {
		System.err.println("Invalid ID: expected " + getGuiID() + ", received " + ID);
	}

	BlockPos xyz = new BlockPos(x, y, z);
	TileEntity tileEntity = world.getTileEntity(xyz);
	if(tileEntity instanceof TileEntityCrate) {
		TileEntityCrate tileEntityCrate = (TileEntityCrate)tileEntity;
		return new ContainerCrate(player.inventory, tileEntityCrate);
	}
	return null;
}

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	if(ID != getGuiID()) {
		System.err.println("Invalid ID: expected " + getGuiID() + ", received " + ID);
	}

	BlockPos xyz = new BlockPos(x, y, z);
	TileEntity tileEntity = world.getTileEntity(xyz);
	if(tileEntity instanceof TileEntityCrate) {
		TileEntityCrate tileEntityCrate = (TileEntityCrate)tileEntity;
		return new ContainerCrate(player.inventory, tileEntityCrate);
	}
	return null;
}
}

 

Tile Entity Class

package com.gwater.decorationmod.tileentity;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import scala.actors.threadpool.Arrays;

public class TileEntityCrate extends TileEntity implements IInventory {

final int NUMBER_OF_SLOTS = 9;
private ItemStack[] itemStacks = new ItemStack[NUMBER_OF_SLOTS];

@Override
public int getSizeInventory() {
	return itemStacks.length;
}

@Override
public ItemStack getStackInSlot(int index) {
	return itemStacks[index];
}

@Override
public ItemStack decrStackSize(int slotIndex, int count) {
	ItemStack itemStackInSlot = getStackInSlot(slotIndex);
	if(itemStackInSlot == null) return null;

	ItemStack itemStackRemoved;
	if(itemStackInSlot.stackSize <= count) {
		itemStackRemoved = itemStackInSlot;
		setInventorySlotContents(slotIndex, null);
	}
	else
	{
		itemStackRemoved = itemStackInSlot.splitStack(count);
		if(itemStackInSlot.stackSize == 0) {
			setInventorySlotContents(slotIndex, null);
		}
	}
	markDirty();
	return itemStackRemoved;
}

@Override
public void setInventorySlotContents(int slotIndex, ItemStack stack) {
	itemStacks[slotIndex] = stack;
	if(stack != null && stack.stackSize > getInventoryStackLimit()) {
		stack.stackSize = getInventoryStackLimit();
	}
	markDirty();
}

@Override
public int getInventoryStackLimit() {
	return 64;
}

@Override
public boolean isUseableByPlayer(EntityPlayer player) {
	if(this.worldObj.getTileEntity(this.pos) != this) return false;
	final double X_CENTRE_OFFSET = 0.5;
	final double Y_CENTRE_OFFSET = 0.5;
	final double Z_CENTRE_OFFSET = 0.5;
	final double MAXIMUM_DISTANCE_SQ = 8.0 * 8.0;
	return player.getDistanceSq(pos.getX() + X_CENTRE_OFFSET, pos.getY() + Y_CENTRE_OFFSET, pos.getZ() + Z_CENTRE_OFFSET) < MAXIMUM_DISTANCE_SQ;
}

@Override
public boolean isItemValidForSlot(int index, ItemStack stack) {
	return true;
}

@Override
public void writeToNBT(NBTTagCompound compound) {
	super.writeToNBT(compound);

	NBTTagList dataForAllSlots = new NBTTagList();
	for(int i = 0; i < this.itemStacks.length; i++) {
		if(this.itemStacks[i] != null) {
			NBTTagCompound dataForThisSlot = new NBTTagCompound();
			dataForThisSlot.setByte("Slot", (byte)i);
			this.itemStacks[i].writeToNBT(dataForThisSlot);
			dataForAllSlots.appendTag(dataForThisSlot);
		}
	}

	compound.setTag("Items", dataForAllSlots);
}

@Override
public void readFromNBT(NBTTagCompound compound) {
	super.readFromNBT(compound);
	final byte NBT_TYPE_COMPOUND = 10;
	NBTTagList dataForAllSlots = compound.getTagList("Items", NBT_TYPE_COMPOUND);

	Arrays.fill(itemStacks, null);
	for(int i = 0; i < dataForAllSlots.tagCount(); i++) {
		NBTTagCompound dataForOneSlot = dataForAllSlots.getCompoundTagAt(i);
		int slotIndex = dataForOneSlot.getByte("Slot") & 255;

		if(slotIndex >= 0 && slotIndex < this.itemStacks.length) {
			this.itemStacks[slotIndex] = ItemStack.loadItemStackFromNBT(dataForOneSlot);
		}
	}
}

@Override
public void clear() {
	Arrays.fill(itemStacks, null);
}

@Override
public String getName() {
	return "container.crate.name";
}

@Override
public boolean hasCustomName() {
	return false;
}

@Override
public ITextComponent getDisplayName() {
	return this.hasCustomName() ? new TextComponentString(this.getName()) : new TextComponentTranslation(this.getName());
}

@Override
public ItemStack removeStackFromSlot(int slotIndex) {
	ItemStack itemStack = getStackInSlot(slotIndex);
	if(itemStack != null) setInventorySlotContents(slotIndex, null);
	return itemStack;
}

@Override
public void openInventory(EntityPlayer player) {}

@Override
public void closeInventory(EntityPlayer player) {}

@Override
public int getField(int id) {
	return 0;
}

@Override
public void setField(int id, int value) {}

@Override
public int getFieldCount() {
	return 0;
}
}

Posted

In the GUI Handler on the client side you should be returning an instance of GuiCrate.

 

Normally you only have one GUI Handler per mod.

  Quote

  Quote
catch(Exception e)

{

 

}

Yay, Pokémon exception handling, gotta catch 'em all (and then do nothing with 'em).

Posted

Thanks for reply. Did what you said but it still doesn't open up.

 

Updated code:

@Mod(modid = References.MODID, version = References.VERSION, name = References.NAME, guiFactory="com.gwater.decorationmod.handler.GuiHandlerCrate")

 

Have a console report also:

[15:49:58] [Client thread/FATAL]: Error executing task
java.util.concurrent.ExecutionException: java.lang.ClassCastException: com.gwater.decorationmod.container.ContainerCrate cannot be cast to net.minecraft.client.gui.GuiScreen
at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_77]
at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_77]
at net.minecraft.util.Util.runTask(Util.java:24) [util.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1104) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:401) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_77]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_77]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_77]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_77]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_77]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_77]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_77]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_77]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: java.lang.ClassCastException: com.gwater.decorationmod.container.ContainerCrate cannot be cast to net.minecraft.client.gui.GuiScreen
at net.minecraftforge.fml.client.FMLClientHandler.showGuiScreen(FMLClientHandler.java:471) ~[FMLClientHandler.class:?]
at net.minecraftforge.fml.common.FMLCommonHandler.showGuiScreen(FMLCommonHandler.java:309) ~[FMLCommonHandler.class:?]
at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:103) ~[FMLNetworkHandler.class:?]
at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2694) ~[EntityPlayer.class:?]
at net.minecraftforge.fml.common.network.internal.OpenGuiHandler.process(OpenGuiHandler.java:39) ~[OpenGuiHandler.class:?]
at net.minecraftforge.fml.common.network.internal.OpenGuiHandler.access$000(OpenGuiHandler.java:15) ~[OpenGuiHandler.class:?]
at net.minecraftforge.fml.common.network.internal.OpenGuiHandler$1.run(OpenGuiHandler.java:30) ~[OpenGuiHandler$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_77]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_77]
at net.minecraft.util.Util.runTask(Util.java:23) ~[util.class:?]
... 15 more

Posted

Thanks coolAliaz. I was in fact returning container for client-side.

 

Updated code:

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	if(ID != getGuiID()) {
		System.err.println("Invalid ID: expected " + getGuiID() + ", received " + ID);
	}

	BlockPos xyz = new BlockPos(x, y, z);
	TileEntity tileEntity = world.getTileEntity(xyz);
	if(tileEntity instanceof TileEntityCrate) {
		TileEntityCrate tileEntityCrate = (TileEntityCrate)tileEntity;
		return new GuiCrate(player.inventory, tileEntityCrate);
	}
	return null;
}

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hey! I noticed you're trying to register your alexandrite item and possibly set its resource location manually with setId(...). I wanted to help clarify a few things that might simplify your code and avoid errors. ✅ The issue: You're using setId(...) inside the item registration like this:   public static final RegistryObject<Item> ALEXANDRITE = ITEMS.register("alexandrite", () -> new Item(new Item.Properties().useItemDescriptionPrefix() .setId(ResourceKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath(TutorialMod.MOD_ID, "alexandrite"))))); But: Item.Properties does not have a setId(...) method — this line will either fail or do nothing meaningful. useItemDescriptionPrefix() is mostly used for translation keys (like "item.modid.name") but isn't needed unless you have a very specific reason. 🛠 The fix: You only need to register your item like this:   public static final RegistryObject<Item> ALEXANDRITE = ITEMS.register("alexandrite", () -> new Item(new Item.Properties())); Forge automatically handles the ResourceLocation (modid:alexandrite) based on the name passed into .register(...), so there’s no need to manually assign it. 📝 For the texture: Make sure you have this file in your resources: src/main/resources/assets/tutorialmod/models/item/alexandrite.json { "parent": "item/generated", "textures": { "layer0": "tutorialmod:item/alexandrite" } } And your texture PNG goes here: src/main/resources/assets/tutorialmod/textures/item/alexandrite.png 🌍 For the name in-game: Add this to your en_us.json under: src/main/resources/assets/tutorialmod/lang/en_us.json { "item.tutorialmod.alexandrite": "Alexandrite" }   Note: if im wrong about the issues you are encountering, i apologize.
    • 🛠️ Fix for Transparent or Clipping Item Render Issues When Held in First Person (Forge 1.20+) Hey everyone! I recently ran into a frustrating bug while making a custom item (a rocket) for my Forge mod, and I’m sharing the fix because it’s a bit obscure — and it worked wonders. 💥 The Problem: My item rendered semi-transparent and see-through — but only in first person. It also clipped through nearby blocks when held, unlike default items like swords or leads. The texture file was confirmed to be fully opaque (alpha 255), so the issue wasn’t the PNG itself. Interestingly, when no texture was present and the default purple-black checkerboard appeared, the clipping issue disappeared. ✅ The Fix: I ended up resolving it by randomly trying something I found on a Forge forum post about block rendering. I added this property to my item's model JSON — even though it's typically only used for blocks: { "parent": "item/generated", "textures": { "layer0": "farbeyond:item/rocket_item" }, "render_type": "minecraft:cutout" } Boom. That single line forced the item to render using a proper opaque (cutout) layer, removing all the unwanted transparency and clipping behavior in first person. 🙌 Credit: I originally found the "render_type" trick mentioned here, in a block rendering context: 👉 https://forums.minecraftforge.net/topic/149644-1201-help-with-transparent-blocks/ Even though it was meant for blocks, I thought, why not try it on an item? And it worked! Big thanks to the poster — this fix wouldn’t have happened without that tip. Hopefully this helps anyone else stuck on a weird rendering bug like I was. This isn’t a common item solution, so feel free to share it further. I’d love to know if it works for you too.
    • Use Java 21 instead of Java 24   Also make a test without modernfix
    • Ive been on this world for 2 days now, my computer blue screens pretty often so maybe that has something to do with it. maybe just incompatible mods like a lot of people so im hoping someone more knowledgeable can help me find what i need to get rid of. thank you! paste bin
    • Should probably say that i am running minecraft 1.21.1 and with quite a lot of mods (many of which im unsure should even be on the server side)
  • Topics

×
×
  • Create New...

Important Information

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