Jump to content

[1.8.9] getStackInSlotOnClosing no longer exists for ItemStack


swordkorn

Recommended Posts

I'm trying to create a block with TileEntity and the tutorial I'm following to set up the basics for the inventory slots has brought me grinding to a halt.

 

It seems to not recognise the method getStackInSlotOnClosing anymore for ItemStack and I was just wondering if anyone knew of the new method required or if there's a better way of doing things now we're on 1.8.9?

 

    public ItemStack[] inv;
    public String name;

    public CropTilesBase() {
        this.inv = new ItemStack[this.getSizeInventory()];
    }

    public String getCustomName() {
        return this.name;
    }

    public void setCustomName(String name) {
        this.name = name;
    }

    @Override
    public String getName() {
        return this.hasCustomName() ? this.name : "container.alchemicalDuster";
    }

    @Override
    public boolean hasCustomName() {
        return this.name != null && !this.name.equals("");
    }

    @Override
    public IChatComponent getDisplayName() {
        return this.hasCustomName() ? new ChatComponentText(this.getName()) : new ChatComponentTranslation(this.getName());
    }

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

    @Override
    public ItemStack getStackInSlot(int slot) {
        if(slot < 0 || slot >= this.getSizeInventory())
            return null;
        return this.inv[slot];
    }

    @Override
    public ItemStack decrStackSize(int slot, int amt) {
        if(this.getStackInSlot(slot) != null) {
            ItemStack stack;

            if(this.getStackInSlot(slot).stackSize <= amt) {
                stack = this.getStackInSlot(slot);
                this.setInventorySlotContents(slot, null);
                this.markDirty();
                return stack;
            }else{
                stack = this.getStackInSlot(slot).splitStack(amt);

                if(this.getStackInSlot(slot).stackSize <= 0) {
                    this.setInventorySlotContents(slot, null);
                }else{
                    this.setInventorySlotContents(slot, this.getStackInSlot(slot));
                }

                this.markDirty();
                return stack;
            }
        }else{
            return null;
        }
    }

    [b]@Override
    public ItemStack getStackInSlotOnClosing(int slot) {
        ItemStack stack = this.getStackInSlot(slot);
        this.setInventorySlotContents(slot, null);
        return stack;[/b]
    }

 

It's not urgently needed as I have other things I can be getting on with in the mean time (wanting to add tool materials and custom tools and such) so it's not like I desperately need this, but I'd like to be able to come back to it at some point and get this sorted. Thanks guys!

Link to comment
Share on other sites

That method is now called

removeStackFromSlot

.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

For what I can tell, the name is the only thing that has changed, so yes, you can leave the 'returns and everything' the same.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

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

    • So the default PlayerModel contains this code here to set the players arms to slim   if (pSlim) { $$3.addOrReplaceChild("left_arm", CubeListBuilder.create().texOffs(32, 48).addBox(-1.0F, -2.0F, -2.0F, 3.0F, 12.0F, 4.0F, pCubeDeformation), PartPose.offset(5.0F, 2.5F, 0.0F)); $$3.addOrReplaceChild("right_arm", CubeListBuilder.create().texOffs(40, 16).addBox(-2.0F, -2.0F, -2.0F, 3.0F, 12.0F, 4.0F, pCubeDeformation), PartPose.offset(-5.0F, 2.5F, 0.0F)); $$3.addOrReplaceChild("left_sleeve", CubeListBuilder.create().texOffs(48, 48).addBox(-1.0F, -2.0F, -2.0F, 3.0F, 12.0F, 4.0F, pCubeDeformation.extend(0.25F)), PartPose.offset(5.0F, 2.5F, 0.0F)); $$3.addOrReplaceChild("right_sleeve", CubeListBuilder.create().texOffs(40, 32).addBox(-2.0F, -2.0F, -2.0F, 3.0F, 12.0F, 4.0F, pCubeDeformation.extend(0.25F)), PartPose.offset(-5.0F, 2.5F, 0.0F)); } else { $$3.addOrReplaceChild("left_arm", CubeListBuilder.create().texOffs(32, 48).addBox(-1.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F, pCubeDeformation), PartPose.offset(5.0F, 2.0F, 0.0F)); $$3.addOrReplaceChild("left_sleeve", CubeListBuilder.create().texOffs(48, 48).addBox(-1.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F, pCubeDeformation.extend(0.25F)), PartPose.offset(5.0F, 2.0F, 0.0F)); $$3.addOrReplaceChild("right_sleeve", CubeListBuilder.create().texOffs(40, 32).addBox(-3.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F, pCubeDeformation.extend(0.25F)), PartPose.offset(-5.0F, 2.0F, 0.0F)); } And that's got me thinking. If I can't replace the whole model in one fell swoop, what if I replaced each individual limb with my models mesh definitions? Note: It was crazy. The createMesh method in PlayerModel could not be @Overriden and addOrReplaceChild just makes changes to a new model that uses the original as a base.     However, I did render my model using this   final toatestentity idk = entities.toatest.get().create(p.level()); Minecraft.getInstance().getEntityRenderDispatcher().getRenderer(idk).render(idk, 0f, pTicks, stack, buffer, paLights); However that just uses the render from the entity I used to test getting the model to render in the first place. I don't want to do that. I want to fully replace the player model which this doesn't actually do (I don't think?).  Maybe it'd just be best to render my model as a new layer and make the base player model invisible? Maybe I'll take a look at how armor is rendered to move with the player so I won't have to make my own animations? Idk, I'm really set on figuring this out though.
    • AT Launcher works just fine
    • Make a test with another Launcher like MultiMC or AT Launcher  
    • https://mclo.gs/EZ0jeA2
  • Topics

×
×
  • Create New...

Important Information

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