Production Ready Cupboards

Today I realized that chests suck. I thought of something between a drawer and a chest. I don’t know what this thing, basically a box with a door, is properly called in English: cupboard or shelf or whatever.

I decided to copy & modify gregtech/tileentity/inventories/MultiTileEntityDrawerQuad.java. By trial and error, It took me some time to get it to work somewhat :monkey:

The problem is it works as expected only with certain inventory sizes. Here it’s 36:

Strange GUI rendering with size 54 (that’s the one I want to use). Nothing can be moved in it by dragging, but with shift-click, which causes game to crash.

45 and 72 causes this missing texture or whatever it is. Items can’t be moved in it normally either, and doing so by shift-clicking causes a crash:

Could you help me and point to what’s causing the problem?

Here is the the code on pastebin.

And I hooked it in gregtech/loaders/b/Loader_MultiTileEntities.java:

aRegistry.add("Cupboard (" + aMat.getLocal() + ")", "Storage", 4200+aID, 32751, MultiTileEntityCupboard.class, aMat.mToolQuality, 16, aMachine, UT.NBT.make(NBT_MATERIAL, aMat    , NBT_HARDNESS, aHardness  , NBT_RESISTANCE, aResistance), "CCC", "CCC", "CCC", 'T', OP.screw.dat(aMat), 'C', aRegistry.getItem(aID));

Also, where can I find those crafting codes? So I can change recipe to something more meaningful.

2 Likes

Ah yeah the problem is Greg did not account for all possible Inventory Sizes. You will have to rewrite the GUI to get any Number of Slots that I did not plan ahead for.

HOWEVER! For the Doublechest Sized Inventory, I would recommend just copypasting the GT6 Chests GUI 1:1, it should for the most part work perfectly fine. ^^

1 Like

I would like to, but I can’t even find what to copy-paste. I’m tired of this for today (having to restart MC after another compilation is time-consuming as hell); I will examine the code carefully and try it later on.

2 Likes

The MultiTileEntityChest is somewhere in the gregapi.block.multitileentity.example section. There should be somethign that returns a new GUI and something that returns Common instance, which both are needed to get it to work.

2 Likes

I’ve got it working, but I can’t manage to find the list of crafting literals (e.g. C for metal chest) to make a meaningful recipe.


image

And it still doesn’t work for sizes different from 54. I thought GUI would simply adjust to any other value. Well, that doesn’t bother me that much.

And what is ZL_IS? As in private ItemStack[] mInventory = ZL_IS;. This drives me crazy; is it OK in Java just to use identifiers out of nowhere not mentioning the class from where they’re imported :dizzy_face:

2 Likes

ZL_IS is from CS.java and is a Zero Length ItemStack Array.

And the Recipes are at the end of the very long Line that is used to initialize the Cupboards.

Yep all Inventory Sizes are hardcoded and not dynamic at all. I was lazy at the time…

Edit: Oh you mean for the Metal Chest of the same type? aRegistry.getItem(i+whatever) should be the one you look for

2 Likes

And the Recipes are at the end of the very long Line that is used to initialize the Cupboards.

I mean that P stands for a plate, S for a stick and so on. Is there the general list of these abbreviations? I’ve managed to scrape some values from other recipes for mine, but anyway.

aRegistry.add(aMat.getLocal() + " Cupboard", "Storage", 4100+aID, 32751, MultiTileEntityCupboard.class, aMat.mToolQuality, 16, aMachine, UT.NBT.make(NBT_MATERIAL, aMat, NBT_HARDNESS, aHardness, NBT_RESISTANCE, aResistance, NBT_INV_SIZE, 54), "PRP", "hSw", "PRP", 'P', OP.plate.dat(aMat), 'R', OP.ring.dat(aMat), 'S', OP.stick.dat(aMat));

2 Likes

The list is defined after the recipe, let’s break that command apart:

aRegistry.add(
  aMat.getLocal() + " Cupboard",
  "Storage",
  4100+aID,
  32751,
  MultiTileEntityCupboard.class,
  aMat.mToolQuality,
  16,
  aMachine,
  UT.NBT.make(
    NBT_MATERIAL,
    aMat,
    NBT_HARDNESS,
    aHardness,
    NBT_RESISTANCE,
    aResistance,
    NBT_INV_SIZE,
    54
  ),
  "PRP",
  "hSw",
  "PRP",
  'P', OP.plate.dat(aMat),
  'R', OP.ring.dat(aMat),
  'S', OP.stick.dat(aMat)
);

So the recipe is at the end, this part:

  "PRP",
  "hSw",
  "PRP",
  'P', OP.plate.dat(aMat),
  'R', OP.ring.dat(aMat),
  'S', OP.stick.dat(aMat)

This is not something specific to GT6, this is MC’s normal recipe format, these lines:

  'P', OP.plate.dat(aMat),
  'R', OP.ring.dat(aMat),
  'S', OP.stick.dat(aMat)

Define the mappings. GT6 defines some lower-case ones for ease of use, Greg can tell you where and what they are (but generally oredict things I think?).

2 Likes

Uh, now I finally understand what it’s all about. So it’s defined right in place, and plate could be any literal I want within the recipe, e.g. 'Y', OP.plate.dat(aMat). I feel dumb now, lol.

2 Likes

The lowercase ones like ‘h’ or ‘w’ are Hammer and Wrench in this example. There is a List of Tools somewhere at the Recipe adding Function itself (see CR.shaped), because I cant always use the obvious Letter of the Alphabet (due to overlaps).

2 Likes