Jump to content

[1.8.9] How to use the substitution alias system?


Choonster

Recommended Posts

I'm trying to test the substitution alias system by replacing the

minecraft:snow_layer

block with a block that has an extra property and sends a chat message to the player when right clicked. You can see my code here.

 

Unfortunately this doesn't seem to work. The F3 debug info doesn't display the value of the extra property and none of my replacement class's methods are being called (except

Block#createBlockState

, but that's called from the constructor).

 

I added a blockstates JSON that uses the vanilla snow layer models and adds a pillar submodel in the centre, but the submodel isn't displayed in the world or in the inventory.

 

If I uncomment the item alias, it creates a new item instead of replacing the vanilla item. The new item crashes with an

ArrayIndexOutOfBoundsException

when right clicked because it doesn't have an item ID.

 

Has anyone managed to get this system working?

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

I've been trying to get this working as well without success. When I tried, Forge added all blocks, items, biomes, etc. twice to the game causing a failure in the game to load which resulted in the level.dat being reported as missing even in a brand new world and upon loading and ignoring the warning, there is nothing, just a void. Would anybody know why this would happen? You can see my code here where I attempted to make the block snow_layer affected by gravity.

Link to comment
Share on other sites

Some of the change logs have indicated there is some known problems with the substitution alias system. For example it looks like they may have made a fix for this in Build 1.8-11.14.3.1559. The changelog says "Fix substitutions for recipes and oredict recipes. Should mean that substitutions start working properly."

 

But yes others have been reporting problem with substitution alias. For example, even in 1.7.10 this was reported: http://www.minecraftforge.net/forum/index.php?topic=30675.0

 

There is an interesting thread here which I think was related to the implementation of the substitution alias: https://github.com/MinecraftForge/FML/issues/370

 

There are a couple interesting points in that discussion. First it is not clear that you should normally register your new block (that might be creating the duplicates). Also, you might need to ensure that the substitution is fully qualified (i.e. vanilla name includes "minecraft:" as modid. However, it seems like there was still acknowledgement that it might now work in the later comments.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

I also remember trying to use substitutions, and whenever I did, the crafting recipe with the substituted block as output was messed up. And probably other problems I can't remember. And I think even after the alleged fix it didn't work.

When I tried to register the block normally it gave an error.

 

Right now I am using a hacky solution by reflecting into the registries and directly replacing everything. Would be nice if I didn't have to do that.

Link to comment
Share on other sites

  • 2 weeks later...

One thing you can do is replace blocks as they are generated -- assuming you're talking a block that gets generated in the world. If you handle the PopulateChunkEvent you can try to iterate through the block positions to check for your block and then replace it. I have an example "Replace All Generated Blocks With Different Block" on this tutorial page: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-modding-quick-tips.html

 

If you want to make it impossible to place the block in creative mode, you could further remove the block from the creative tabs and add your own to replace it.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

The alias system is the method for 'taking over' someone elses registry entry. Hacky solutions are not advised and are most likely the reason you're getting things that are broken.

According to cpw as long as you register everything correctly and register your alias any @ObjectHolders, ItemStacks, etc.. will be updated to use your object over the one you're overriding.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

The alias system is the method for 'taking over' someone elses registry entry. Hacky solutions are not advised and are most likely the reason you're getting things that are broken.

According to cpw as long as you register everything correctly and register your alias any @ObjectHolders, ItemStacks, etc.. will be updated to use your object over the one you're overriding.

 

Could you or cpw advise me if my code (in the OP) is correct?

 

Edit: Fixed typo.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

I wasn't sure if it was a bug or I was just doing something wrong, so I was hoping to find someone who managed to get the system working.

 

I may report it as a bug, since nobody seems to be able to get it working.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

I have stepped through it in the debugger a couple of times. It seems the substitution is being activated, but the

GameData.BLOCKSTATE_TO_ID

map used by

ExtendedBlockStorage

is never updated with the blockstates of the replacement block.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Is ExtendedBlockStorage.get(int x, int y, int z) still returning air due to Block.BLOCK_STATE_IDS.getByValue(#) returning null?

 

It was doing this in 1.8.0 when I attempted to use the alias system, I was told:

it is working, cpws tested it fully. Not sure what the hell you're talking about when it comes to setting the block as you should be able to do that just fine.

BLOCK_STATE_IDS will return proper values for the current world respecting aliases.

 

So at this point we know:

- What worked in 1.7.10 does not work in 1.8.x

- The system does in fact work, we are just using it wrong

- No one but cpw knows how to use it.

- The system is basically useless because no one can figure it out.

 

We need a working sample mod or detailed instructions. :(

 

Link to comment
Share on other sites

Is ExtendedBlockStorage.get(int x, int y, int z) still returning air due to Block.BLOCK_STATE_IDS.getByValue(#) returning null?

 

No, it's returning the ID of the vanilla state.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

No, it's returning the ID of the vanilla state.

 

Ran some tests with this:

    public void onPreInit(FMLPreInitializationEvent event)
    {
        this.testBlock = new TestBlock(); // this extends BlockTallGrass
        ItemBlock testItemBlock = (new ItemColored(this.testBlock, true)).setSubtypeNames(new String[] { "shrub", "grass", "fern" });

        try {
            GameRegistry.addSubstitutionAlias("minecraft:tallgrass", GameRegistry.Type.BLOCK, this.testBlock);
            GameRegistry.addSubstitutionAlias("minecraft:tallgrass", GameRegistry.Type.ITEM, testItemBlock);
        } catch (ExistingSubstitutionException e) {
            e.printStackTrace();
        }
    }

 

Replacing both block and item (doesn't matter what order you replace them in):

- Block renders correctly

- F3 has correct information (in my 1.8.0 tests this was wrong)

- Pick Block doesn't work

- ItemBlock shows up twice in creative tab (normal position, and at end)

- ItemBlock has an id of -1

- ItemBlock has no model

- FML reports it can't find the model files

- Placing Item Block crashes the game (due to having an id of -1)

 

Replacing only the block:

- Block renders correctly

- F3 has correct information (in my 1.8.0 tests this was wrong)

- Pick Block doesn't work

- ItemBlock correctly shows up once on the creative tab

- ItemBlock has the correct id

- ItemBlock has no model

- FML reports it can't find the model files

- Placing Item Block does not crash the game, but places the original (onBlockPlaced on the new block is not called)

 

Replacing only the item:

Same as replacing block and item, but pick block works.

 

I figured this would fail but I tried it anyway.

Cannot register the block to the game registry before registering it to the substitution alias.

"java.lang.IllegalArgumentException: The object substitution is already registered. This won't work"

 

Edit:

I just tried defining the itemblock after the block is registered:

GameRegistry.addSubstitutionAlias("minecraft:tallgrass", GameRegistry.Type.BLOCK, this.testBlock);
ItemBlock testItemBlock = (new ItemColored(Blocks.tallgrass, true)).setSubtypeNames(new String[] { "shrub", "grass", "fern" });
GameRegistry.addSubstitutionAlias("minecraft:tallgrass", GameRegistry.Type.ITEM, testItemBlock);

No change from the other way of replacing the block and item.

Link to comment
Share on other sites

I still can't get this working properly. Lex/cpw (or anyone else), would you be able to provide a basic example of this system to demonstrate how it should be used?

 

My latest code is here (using Forge 1.8.9-11.15.0.1718).

 

Manually adding blockstate IDs to

GameData.BLOCKSTATE_TO_ID

(which I know shouldn't be done) using the vanilla block's ID correctly replaces existing blocks in the world with the new one, but breaks

/setblock

. When the block is first placed from its item, the block model isn't rendered at all until the block receives an update from a neighbour.

 

If I don't add a substitution for the

ItemBlock

, the item uses the vanilla model. If I do, it adds a new item and both items have the missing model.

 

I decided to try replacing a basic

Item

(the stick). The substitution mostly works (the item can be taken out of the creative menu and adds a chat message when right clicked), but the model is broken (it's displaying as the missing model) and crafting it crashes the game with an

ArrayIndexOutOfBoundsException

from

ItemStack#onCrafting

because the item doesn't have an ID.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

  • 2 weeks later...

So I noticed chylex had created a test mod that helped sort out the issues in 1.7 (https://github.com/MinecraftForge/MinecraftForge/pull/2076)

 

I made the minor changes needed to run it on 1.8.9 and it failed.

 

Test: if (!BlockReplacedPlanks.class.isInstance(Blocks.planks)) throw new Exception("Block class type is incorrect: " + Blocks.planks.getClass().getName());

Error: "Test failed: Block class type is incorrect: net.minecraft.block.BlockPlanks"

 

So I decided to skip that test and run again, failed again.

 

Error: "Test failed: null"

Cause: ItemBlock ib = (ItemBlock) Item.getItemFromBlock(Blocks.planks);  < This returns null

 

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Dalam dunia perjudian online yang berkembang pesat, mencari platform yang dapat memberikan kemenangan maksimal dan hasil terbaik adalah impian setiap penjudi. OLXTOTO, dengan bangga, mempersembahkan dirinya sebagai jawaban atas pencarian itu. Sebagai platform terbesar untuk kemenangan maksimal dan hasil optimal, OLXTOTO telah menciptakan gelombang besar di komunitas perjudian online. Satu dari banyak keunggulan yang dimiliki OLXTOTO adalah koleksi permainan yang luas dan beragam. Dari togel hingga slot online, dari live casino hingga permainan kartu klasik, OLXTOTO memiliki sesuatu untuk setiap pemain. Dibangun dengan teknologi terkini dan dikembangkan oleh para ahli industri, setiap permainan di platform ini dirancang untuk memberikan pengalaman yang tak tertandingi bagi para penjudi. Namun, keunggulan OLXTOTO tidak hanya terletak pada variasi permainan yang mereka tawarkan. Mereka juga menonjol karena komitmen mereka terhadap keamanan dan keadilan. Dengan sistem keamanan tingkat tinggi dan proses audit yang ketat, OLXTOTO memastikan bahwa setiap putaran permainan berjalan dengan adil dan transparan. Para pemain dapat merasa aman dan yakin bahwa pengalaman berjudi mereka di OLXTOTO tidak akan terganggu oleh masalah keamanan atau keadilan. Tak hanya itu, OLXTOTO juga terkenal karena layanan pelanggan yang luar biasa. Tim dukungan mereka selalu siap sedia untuk membantu para pemain dengan segala pertanyaan atau masalah yang mereka hadapi. Dengan respon cepat dan solusi yang efisien, OLXTOTO memastikan bahwa pengalaman berjudi para pemain tetap mulus dan menyenangkan. Dengan semua fitur dan keunggulan yang ditawarkannya, tidak mengherankan bahwa OLXTOTO telah menjadi pilihan utama bagi jutaan penjudi online di seluruh dunia. Jika Anda mencari platform yang dapat memberikan kemenangan maksimal dan hasil optimal, tidak perlu mencari lebih jauh dari OLXTOTO. Bergabunglah dengan OLXTOTO hari ini dan mulailah petualangan Anda menuju kemenangan besar dan hasil terbaik!
    • Selamat datang di OLXTOTO, situs slot gacor terpanas yang sedang booming di industri perjudian online. Jika Anda mencari pengalaman bermain yang luar biasa, maka OLXTOTO adalah tempat yang tepat untuk Anda. Dapatkan sensasi tidak biasa dengan variasi slot online terlengkap dan peluang memenangkan jackpot slot maxwin yang sering. Di sini, Anda akan merasakan keseruan yang luar biasa dalam bermain judi slot. DAFTAR OLXTOTO DISINI LOGIN OLXTOTO DISINI AKUN PRO OLXTOTO DISINI   Jackpot Slot Maxwin Sering Untuk Peluang Besar Di OLXTOTO, kami tidak hanya memberikan hadiah slot biasa, tapi juga memberikan kesempatan kepada pemain untuk memenangkan jackpot slot maxwin yang sering. Dengan demikian, Anda dapat meraih keberuntungan besar dan memenangkan ribuan rupiah sebagai hadiah jackpot slot maxwin kami. Jackpot slot maxwin merupakan peluang besar bagi para pemain judi slot untuk meraih keuntungan yang lebih besar. Dalam permainan kami, Anda tidak harus terpaku pada kemenangan biasa saja. Kami hadir dengan jackpot slot maxwin yang sering, sehingga Anda memiliki peluang yang lebih besar untuk meraih kemenangan besar dengan hadiah yang menggiurkan. Dalam permainan judi slot, pengalaman bermain bukan hanya tentang keseruan dan hiburan semata. Kami memahami bahwa para pemain juga menginginkan kesempatan untuk meraih keberuntungan besar. Oleh karena itu, OLXTOTO hadir dengan jackpot slot maxwin yang sering untuk memberikan peluang besar kepada para pemain kami. Peluang Besar Menang Jackpot Slot Maxwin Peluang menang jackpot slot maxwin di OLXTOTO sangatlah besar. Anda tidak perlu khawatir tentang batasan atau pembatasan dalam meraih jackpot tersebut. Kami ingin memberikan kesempatan kepada semua pemain kami untuk merasakan sensasi menang dalam jumlah yang luar biasa. Jackpot slot maxwin kami dibuka untuk semua pemain judi slot di OLXTOTO. Anda memiliki peluang yang sama dengan pemain lainnya untuk memenangkan hadiah jackpot yang besar. Kami percaya bahwa semua orang memiliki kesempatan untuk meraih keberuntungan besar, dan itulah mengapa kami menyediakan jackpot slot maxwin yang sering untuk memenuhi harapan dan keinginan Anda.   Kesimpulan OLXTOTO adalah situs slot gacor terbaik yang memberikan pengalaman bermain judi slot online yang tak terlupakan. Dengan variasi slot online terlengkap dan peluang memenangkan jackpot slot maxwin yang sering, OLXTOTO menjadi pilihan terbaik bagi para pemain yang mencari kesenangan dan kemenangan besar dalam perjudian online. Di samping itu, OLXTOTO juga menawarkan layanan pelanggan yang ramah dan responsif, siap membantu setiap pemain dalam mengatasi masalah teknis atau pertanyaan seputar perjudian online. Kami menjaga integritas game dan memberikan lingkungan bermain yang adil serta menjalankan kebijakan perlindungan pelanggan yang cermat. Bergabunglah dengan OLXTOTO sekarang dan nikmati pengalaman bermain slot online yang luar biasa. Jadilah bagian dari komunitas perjudian yang mengagumkan ini dan raih kesempatan untuk meraih kemenangan besar. Dapatkan akses mudah dan praktis ke situs OLXTOTO dan rasakan sensasi bermain judi slot yang tak terlupakan.  
    • OLXTOTO: Platform Maxwin dan Gacor Terbesar Sepanjang Masa Di dunia perjudian online yang begitu kompetitif, mencari platform yang dapat memberikan kemenangan maksimal (Maxwin) dan hasil terbaik (Gacor) adalah prioritas bagi para penjudi yang cerdas. Dalam upaya ini, OLXTOTO telah muncul sebagai pemain kunci yang mengubah lanskap perjudian online dengan menawarkan pengalaman tanpa tandingan.     Sejak diluncurkan, OLXTOTO telah menjadi sorotan industri perjudian online. Dikenal sebagai "Platform Maxwin dan Gacor Terbesar Sepanjang Masa", OLXTOTO telah menarik perhatian pemain dari seluruh dunia dengan reputasinya yang solid dan kinerja yang luar biasa. Salah satu fitur utama yang membedakan OLXTOTO dari pesaingnya adalah komitmen mereka untuk memberikan pengalaman berjudi yang unik dan memuaskan. Dengan koleksi game yang luas dan beragam, termasuk togel, slot online, live casino, dan banyak lagi, OLXTOTO menawarkan sesuatu untuk semua orang. Dibangun dengan teknologi terkini dan didukung oleh tim ahli yang berdedikasi, platform ini memastikan bahwa setiap pengalaman berjudi di OLXTOTO tidak hanya menghibur, tetapi juga menguntungkan. Namun, keunggulan OLXTOTO tidak hanya terletak pada permainan yang mereka tawarkan. Mereka juga terkenal karena keamanan dan keadilan yang mereka berikan kepada para pemain mereka. Dengan sistem keamanan tingkat tinggi dan audit rutin yang dilakukan oleh otoritas regulasi independen, para pemain dapat yakin bahwa setiap putaran permainan di OLXTOTO adalah adil dan transparan. Tidak hanya itu, OLXTOTO juga dikenal karena layanan pelanggan yang luar biasa. Dengan tim dukungan yang ramah dan responsif, para pemain dapat yakin bahwa setiap pertanyaan atau masalah mereka akan ditangani dengan cepat dan efisien. Dengan semua fitur dan keunggulan yang ditawarkannya, tidak mengherankan bahwa OLXTOTO telah menjadi platform pilihan bagi para penjudi online yang mencari kemenangan maksimal dan hasil terbaik. Jadi, jika Anda ingin bergabung dengan jutaan pemain yang telah merasakan keajaiban OLXTOTO, jangan ragu untuk mendaftar dan mulai bermain hari ini!  
    • OLXTOTO adalah bandar slot yang terkenal dan terpercaya di Indonesia. Mereka menawarkan berbagai jenis permainan slot yang menarik dan menghibur. Dengan tampilan yang menarik dan grafis yang berkualitas tinggi, pemain akan merasa seperti berada di kasino sungguhan. OLXTOTO juga menyediakan layanan pelanggan yang ramah dan responsif, siap membantu pemain dengan segala pertanyaan atau masalah yang mereka hadapi. Daftar =  https://surkale.me/Olxtotodotcom1
    • DAFTAR & LOGIN BIGO4D   Bigo4D adalah situs slot online yang populer dan menarik perhatian banyak pemain slot di Indonesia. Dengan berbagai game slot yang unik dan menarik, Bigo4D menjadi tempat yang ideal untuk pemula dan pahlawan slot yang berpengalaman. Dalam artikel ini, kami akan membahas tentang Bigo4D sebagai situs slot terbesar dan menarik yang saat ini banyak dijajaki oleh pemain slot online.
  • Topics

×
×
  • Create New...

Important Information

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