New TFBPs=Fail?

  • I tried to make a new TFBP for my addon mod, but it isn't working! Here's the class declaration:


    And the item declaration:

    Code
    public static Item oilSpawner;


    And the implementation in public void load(FMLInitializationEvent):

    Code
    oilSpawner=new OilSpawnBpt(10004).setTextureFile(path).setIconIndex(5).setItemName("oilSpawner");


    The item is declared perfectly, but it won't enter the terraformer! What's the problem?

  • I've never tried to make this, but I think that you should register it somewhere. You just register an item and class, which implements ITerraformingBP, but IC2 doesn't know about this. It's most probably not a bug - just a not implemented feature.

  • Okay, the last couple of times I passed by this thread, I hadn't wanted to dive into terraforming to find out how it works, but this time around I finally did. Here's what I found:

    • The terraformer has no gui. This was my first misunderstanding, as a custom Slot in the Container would've checked the validity of the TFBP just by looking at whether it implemented the right interface, and it would've just worked.
    • Existing TFBPs have an onItemUse([lots of parameters]) which checks if the block you right-clicked is a terraformer, and if true, calls TileEntityTerra.insertBlueprint(ItemStack) on it.
    • The easiest way to get the same behaviour is to extend ItemTFBP, but both this class and TileEntityTerra are IC2 internals rather than API-visible, so you'll have to keep track of any namespace changes yourself (in IC2 1.112 they exist at ic2.core.item.tfbp.ItemTFBP and ic2.core.block.machine.tileentity.TileEntityTerra, respectively). You can do this just by opening the jar and looking at its directory structure, no decompiling/deobf required.


    Overall, my impression is that the terraforming blueprint API is incomplete, and the machine really should have its own single-slot GUI and do its checking there.

  • Existing TFBPs have an onItemUse([lots of parameters]) which checks if the block you right-clicked is a terraformer, and if true, calls TileEntityTerra.insertBlueprint(ItemStack) on it.


    Shouldn't the terraformer block check whether or not the item is a TFBP in the onBlockActivated() method liek so:

    Code
    public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) {
    	ItemStack current = entityplayer.inventory.getCurrentItem();
    	if (!current.getItem() instanceof ITerraformingBP) return false;
    	TileEntityTerra tileTerra = (TileEntityTerra) world.getBlockTileEntity(i, j, k);
    	tileTerra.insertBlueprint(current);
    	//change the top texture
    	return true;
    	}


    Wouldn't that be more logical?

  • ^ Of course it would, although with some changes to account for the fact that the terraformer block is also 13 other machines as well as the machine block and advanced machine block. I'm not an IC2 dev, though. I'm just telling you what I read about how it works right now (well, how it worked in 1.106; I should update my decompile).