Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

So, I was trying to add a custom crafting table but when I place it and right-click it it will for 1 frame (I think) show the gui and then close it again, I know it shows something because when I right-click I get black stripes for a short amount of time (< 1 second) and when I immediately press E it wont open my inventory, my block class:

public class CheeseBlocks {

public static Block CHEESE_BLOCK;
public static Block CHEESE_ORE;
public static Block CHEESE_ORE_NETHER;
public static Block CHEESE_ORE_END;
public static Block QUICK_CHEESE;
public static Block COMPLIMENT_MACHINE;
public static Block BELGIUM_FLAG;
public static Block CHEESE_WORKBENCH;

public CheeseBlocks() {
	init();
	register();
}

public static void init() {
	CHEESE_ORE = new CheeseOre().setCreativeTab(DeGeweldigeMod.tabCheeseStuff).setHardness(2F);
	CHEESE_ORE_NETHER = new CheeseOreNether().setCreativeTab(DeGeweldigeMod.tabCheeseStuff).setHardness(2F);
	CHEESE_ORE_END = new CheeseOreEnd().setCreativeTab(DeGeweldigeMod.tabCheeseStuff).setHardness(2F);
	CHEESE_BLOCK = new Block(Material.ROCK).setCreativeTab(DeGeweldigeMod.tabCheeseStuff).setHardness(3F);
	QUICK_CHEESE = new QuickCheese().setHardness(4F);
	COMPLIMENT_MACHINE = new ComplimentsMachine(Material.PISTON).setCreativeTab(DeGeweldigeMod.tabCheeseStuff).setHardness(3F);
	BELGIUM_FLAG = new BelgiumFlag().setCreativeTab(DeGeweldigeMod.tabCheeseStuff).setHardness(2F);
	CHEESE_WORKBENCH = new CheeseWorkbench().setCreativeTab(DeGeweldigeMod.tabCheeseStuff).setHardness(2F).setUnlocalizedName("cheese_crafting_table");

	CheeseUtils.setNames(CHEESE_ORE, "cheese_ore");
	CheeseUtils.setNames(CHEESE_ORE_NETHER, "cheese_ore_nether");
	CheeseUtils.setNames(CHEESE_ORE_END, "cheese_ore_end");
	CheeseUtils.setNames(CHEESE_BLOCK, "cheese_block");
	CheeseUtils.setNames(QUICK_CHEESE, "quick_cheese");
	CheeseUtils.setNames(COMPLIMENT_MACHINE, "compliment_machine");
	CheeseUtils.setNames(BELGIUM_FLAG, "belgium_flag");
	CheeseUtils.setNames(CHEESE_WORKBENCH, "cheese_crafting_table");
}	

public void register() {
	this.registerBlock(CHEESE_ORE);
	this.registerBlock(CHEESE_ORE_NETHER);
	this.registerBlock(CHEESE_ORE_END);
	this.registerBlock(CHEESE_BLOCK);
	this.registerBlock(QUICK_CHEESE);
	this.registerBlock(COMPLIMENT_MACHINE);
	this.registerBlock(BELGIUM_FLAG);
	this.registerBlock(CHEESE_WORKBENCH);
}	

private void registerBlock(Block block) {
	GameRegistry.register(block);
	GameRegistry.register(new ItemBlock(block).setUnlocalizedName(block.getUnlocalizedName()).setRegistryName(block.getRegistryName()));
}

}

My custom crafting table class:

public class CheeseWorkbench extends Block {
protected CheeseWorkbench() {
        super(Material.WOOD);
    }

    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
        if (worldIn.isRemote) {
            return true;
        } else {
            playerIn.displayGui(new CheeseWorkbench.InterfaceCraftingTable(worldIn, pos));
            playerIn.addStat(StatList.CRAFTING_TABLE_INTERACTION);
            return true;
        }
    }

    public static class InterfaceCraftingTable implements IInteractionObject {
    	private final World world;
    	private final BlockPos position;
    	
    	public InterfaceCraftingTable(World worldIn, BlockPos pos) {
    		this.world = worldIn;
    		this.position = pos;
    	}
    	
    	public String getName() {
    		return null;
    	}
    	
    	public boolean hasCustomName() {
    		return false;
    	}
    	
    	public ITextComponent getDisplayName() {
    		return new TextComponentTranslation(CheeseBlocks.CHEESE_WORKBENCH.getUnlocalizedName() + ".name", new Object[0]);
    	}
    	
    	public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) {
    		return new ContainerWorkbench(playerInventory, this.world, this.position);
    	}

    	public String getGuiID() {
    		return "minecraft:crafting_table";
    	}
    }
}

  • Author

Also, my ClientProxy:

public class ClientProxy extends CommonProxy {

public void registerModels() {
	registerItemModel(CheeseItems.CHEESE, 0);
	registerItemModel(CheeseItems.CHEESE_COOKED, 0);
	registerItemModel(CheeseItems.BREAD_CHEESE, 0);
	registerItemModel(CheeseItems.CHEESE_APPLE, 0);
	registerItemModel(CheeseItems.CHEESE_BUCKET, 0);
	registerItemModel(CheeseItems.CHEESE_INGOT, 0);

	registerItemModel(CheeseItems.CHEESE_SWORD, 0);
	registerItemModel(CheeseItems.CHEESE_PICKAXE, 0);
	registerItemModel(CheeseItems.CHEESE_AXE, 0);
	registerItemModel(CheeseItems.CHEESE_SHOVEL, 0);
	registerItemModel(CheeseItems.CHEESE_HOE, 0);
	registerItemModel(CheeseItems.CHEESE_FLY_STICK, 0);

	registerItemModel(CheeseItems.CHEESE_HELMET, 0);
	registerItemModel(CheeseItems.CHEESE_CHESTPLATE, 0);
	registerItemModel(CheeseItems.CHEESE_LEGGINGS, 0);
	registerItemModel(CheeseItems.CHEESE_BOOTS, 0);

	registerBlockModel(CheeseBlocks.CHEESE_ORE, 0);
	registerBlockModel(CheeseBlocks.CHEESE_ORE_NETHER, 0);
	registerBlockModel(CheeseBlocks.CHEESE_ORE_END, 0);
	registerBlockModel(CheeseBlocks.CHEESE_BLOCK, 0);
	registerBlockModel(CheeseBlocks.QUICK_CHEESE, 0);
	registerBlockModel(CheeseBlocks.COMPLIMENT_MACHINE, 0);
	registerBlockModel(CheeseBlocks.BELGIUM_FLAG, 0);
	registerBlockModel(CheeseBlocks.CHEESE_WORKBENCH, 0);
}

public void renderEntities() {
	RenderingRegistry.registerEntityRenderingHandler(EntityCheeseCow.class, new RenderingHandlerCheeseCow());
}

private void registerItemModel(Item item, int meta) {
	ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item.getRegistryName(), "inventory"));
}

private void registerBlockModel(Block block, int meta) {
	ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), meta, new ModelResourceLocation(block.getRegistryName(), "inventory"));
}
}

isRemote does opposite of what you think (and initially anyone else). illogical, but rename probably won't happen.

switch that and work from there (i honestly can't tell what else is wrong).

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.