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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
    • Remove Instant Massive Structures Mod from your server     Add new crash-reports with sites like https://paste.ee/  
  • Topics

×
×
  • Create New...

Important Information

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