Jump to content

Recommended Posts

Posted

Hi!

 

Basically, I want to replace snow and ice so they do not melt, and use the substitution alias system to avoid using ASM.

 

I have replaced the ItemBlock and Block here: https://gist.github.com/hsyyid/ae6e14b6128f5aee27d8 but to no avail.

 

Instead of replacing the snow and the ice, it appears that the ItemBlock does nothing when right clicked, and the snow and ice items DO NOT have textures anymore.

 

Any and all help would be greatly appreciated!  :D

Posted

Okay. Well anyway you have to resort to standard debugging. Are you sure the method is being called? Use a console statement to confirm it.

 

After that, in the pre-init I think your registry of your blocks and items is wrong -- I don't think you can (or at least I think it is a bad idea) to set the unlocalized name to "minecraft:snow". The "minecraft:" is for vanilla items and it should really have your mod id.

 

After that, are you sure that the instances you are passing have in fact already been constructed (not null). Again use console statement to confirm it.

 

That's the only things I can think of, otherwise it looks pretty simple.

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

  • 2 weeks later...
Posted

I just re-implemented, or at least attempted to, a block substitution into my mod.

 

The substitution alias does appear to be currently broken.

 

You can't place the block because ItemBlock.placeBlockAt eventually gets to ExtendedBlockStorage.get(int x, int y, int z) and it always returns air. It does that because Block.BLOCK_STATE_IDS.getByValue(#) always returns null.

 

Up until that point it appears to be working.

 

 

Here is a quick test mod if anyone wants to look into it.

With the exception of function names and imports changing, this is the same code works in 1.7

 

package net.minecraftforge.debug;

import net.minecraft.block.Block;
import net.minecraft.block.BlockTallGrass;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemColored;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.ExistingSubstitutionException;
import net.minecraftforge.fml.common.registry.GameRegistry;

@Mod(modid = "substitutionaliastest")
public class SubstitutionAliasTest
{
    private Block testBlock;

    @Mod.EventHandler
    public void onPreInit(FMLPreInitializationEvent event)
    {
        this.testBlock = new TestBlock();
        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();
        }
    }

    public static class TestBlock extends BlockTallGrass
    {
        public TestBlock()
        {
            super();
            super.setUnlocalizedName("tallgrass");
            setHardness(0.0F);
            setStepSound(soundTypeGrass);
            setUnlocalizedName("tallgrass");
        }
    }
}

Posted

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.

 

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

Posted

Well I've tried that test mod I posted again.

 

I've tried registering the alias in PreInit, Init, and PostInit.

Every time it the same result.

 

The block is replaced, the F3 screen shows

null

type: tall_grass

 

before replacement it shows:

minefraft:tallgrass

type: tall_grass

 

 

The original item in the creative menu has no texture and can not be placed due to failing Block.BLOCK_STATE_IDS.getByValue(#)

 

If you use pick block, you get an item with correct texture but placing it crashes the game.

java.lang.ArrayIndexOutOfBoundsException: -1

at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:151)

at net.minecraft.client.multiplayer.PlayerControllerMP.func_178890_a(PlayerControllerMP.java:442)

 

ItemStack.java:151 => playerIn.triggerAchievement(StatList.objectUseStats[item.getIdFromItem(this.item)]);

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



×
×
  • Create New...

Important Information

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