Jump to content

MC 1.11.2 Custom chests


winnetrie

Recommended Posts

Where the tileentity rendering should be updated. Like 

updateContainingBlockInfo

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

Sorry, but i have really no idea what to do with this.

Do i place it here ?:

@Override
    public void updateContainingBlockInfo()
    {
        super.updateContainingBlockInfo();
        this.adjacentChestChecked = false;
        doubleChestHandler = null;
        
        
    }

in the tileentity class?

Link to comment
Share on other sites

3 hours ago, winnetrie said:

Sorry, but i have really no idea what to do with this.

Do i place it here ?:


@Override
    public void updateContainingBlockInfo()
    {
        super.updateContainingBlockInfo();
        this.adjacentChestChecked = false;
        doubleChestHandler = null;
        
        
    }

in the tileentity class?

Yes, and everywhere else where update take in place.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

15 minutes ago, winnetrie said:

I'm wondering why i need to do this while the vanilla chest does not require it?

I'm also not sure how to get these parameters right in this:

 


markAndNotifyBlock(pos, chunk, iblockstate, newState, flags)

 

Ah, yes, you don't need that. Sorry for causing confusion. The block rendering should be updated when the neighbor is changed.

 

EDIT: Sorry, I didn't know that you extended the vanilla chest.

Edited by Abastro

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

Try checking if the method is called, and try printing the fields of the chest. Does the corresponding field changes when the adjacent chest is removed?

  • Like 1

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

Aha hehe i found the bug....and it was my fault.

Here was the problem if someone want to know btw:

private boolean isChestAt(BlockPos posIn)
    {
        if (this.world == null)
        {
            return false;
        }
        else
        {
            Block block = this.world.getBlockState(posIn).getBlock();
            return block instanceof BlockModChest ;//&& block == this.getBlockType() ;
        }
    }

the "&& block== this.getBlockType();"

 

Oh and 1 more thing. Is there a way i can prevent the game to look for blockstate variants from the blockstate.json.

it wants to have variants like facing= east / facing= south and type=sprucechest

But those are not relevant. I can ofc just fill in all the variants in the blockstate json and then do nothing with it.

Edited by winnetrie
Link to comment
Share on other sites

13 minutes ago, winnetrie said:

Aha hehe i found the bug....and it was my fault.

Here was the problem if someone want to know btw:


private boolean isChestAt(BlockPos posIn)
    {
        if (this.world == null)
        {
            return false;
        }
        else
        {
            Block block = this.world.getBlockState(posIn).getBlock();
            return block instanceof BlockModChest ;//&& block == this.getBlockType() ;
        }
    }

the "&& block== this.getBlockType();"

 

Oh and 1 more thing. Is there a way i can prevent the game to look for blockstate variants from the blockstate.json.

it wants to have variants like facing= east / facing= south and type=sprucechest

But those are not relevant. I can ofc just fill in all the variants in the blockstate json and then do nothing with it.

You can register a custom state mapper - ModelLoader.setCustomStateMapper. Take a look at BlockModelShapes.registerAllBlocks to see how vanilla implements state mappers (there's a StateMap.Builder class which has an ignore method).

Link to comment
Share on other sites

Thank you!

I have put this into my client proxy (i think it has to be in the client proxy)

 

ModelLoader.setCustomStateMapper(ModBlocks.chest, (new StateMap.Builder()).ignore(new IProperty[] {BlockModChest.FACING, BlockModChest.TYPE}).build());

This looks to work fine for me.

I still use the blockstate json for the inventory item and the particle effect. I'm pretty sure there is somehow an alternative to this. This i do not know yet.

 

You have both been very helpfull. Thank you very much. I really appreciate!

I think it's time now to make all the chests....finally

Edited by winnetrie
Link to comment
Share on other sites

I found the reason for my problem more or less, but don't know how to fix it:

 

The chest i create gives a variable (TileEntitySlots) to the TE. Then i use this here:

    @Override
    public int getSizeInventory()
    {
    	
        return TileEntitySlots;
    }

This is working fine when you place a chest down, it has the number of slots like it should have.

Yet after a restart the chest is visible but when opening the GUI/Container isn't showing up, because (i checked it) TileEntitySlots is null!!

So i tried this instead:

    @Override
    public int getSizeInventory()
    {
    	BlockModIronChest block = (BlockModIronChest) this.getBlockType();
    	TileEntitySlots = block.CHEST_SLOTS;
        return TileEntitySlots;
    }

Now when i restart the game the chests are invisible, but once you click the invisible block they turn visible and the chest opens with the right inventory size.

The chests are working fine, yet each restart they are inviseble at start.

I'm wondering why.

Link to comment
Share on other sites

I have remade all my customchests (the wooden) and they work all properly now! I tested alot of things to find any bugs.

 

I also ran into a problem with my custom metal chests. They should have a bigger inventory, but this:

@Override
    public int getSizeInventory()
    {
    	
    	if (this.getChestType()==BlockModIronChest.Type.IRON){
    		this.chestSlots=36;
    	}
    	else if (this.getChestType()==BlockModIronChest.Type.GOLD){
    		this.chestSlots=27;
    	}
    	else if (this.getChestType()==BlockModIronChest.Type.DIAMOND){
    		this.chestSlots=45;
    	}
    	else if (this.getChestType()==BlockModIronChest.Type.FELIRON){
    		this.chestSlots=54;
    	}
    	
    	
        return this.chestSlots;
    }

gives me an out of bounds error when i open 1 of those chests after a world reload/restart.

If i give the return a fixed value for example 36 i never get an error. However i want it to get that information from the chest type.

Why is it giving me an out of bounds error and how do i solve it?

EDIT:

Here it asked for the this.getSizeInventory() and i changed it to 54, the max posseble slots.

@Override
    public void readFromNBT(NBTTagCompound compound)
    {
        super.readFromNBT(compound);
        this.chestContents = NonNullList.<ItemStack>withSize(54, ItemStack.EMPTY);

        if (!this.checkLootAndRead(compound))
        {
            ItemStackHelper.loadAllItems(compound, this.chestContents);
        }

        if (compound.hasKey("CustomName", 8))
        {
            this.customName = compound.getString("CustomName");
        }
    }

I also did changed this, but didn't saw there was something a like in the readFromNBT:

private NonNullList<ItemStack> chestContents = NonNullList.<ItemStack>withSize(54, ItemStack.EMPTY);

It was defined as 27 as it is standard.

Edited by winnetrie
Solved the problem and added the solution
Link to comment
Share on other sites

I found another bug .....

Whenever my custom chest(s) is opened while a hopper is underneath it, nothing happens. It looks like the hopper can't pull the items from the chest while it is opened.

As soon as i close it the items start to transfer. Same thing whenever  the hopper is above my custom chest.

Why is this and how do i solve this?

Lol...I gave them the ability to act as a trapped chest, wich disables the hopper when opened. Forgot about that...

Edited by winnetrie
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.



×
×
  • Create New...

Important Information

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