Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Custom Crafting Bench bug
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
Heltrato

Custom Crafting Bench bug

By Heltrato, November 22, 2018 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Heltrato    1

Heltrato

Heltrato    1

  • Diamond Finder
  • Heltrato
  • Members
  • 1
  • 259 posts
Posted November 22, 2018

So im porting my mod to 1.12.2 fixed the errors most of it but bugs are everywhere since no reworks.

 

Right now im trying to fix my custom crafting bench that has a clickable button (craft) if the following requiredStack slot is met,

 

but two things i find out 

1.) it allows to craft even if the required quantity is not me

2.) upon finish crafting it just consumes on how many quantity the requiredstack is (even if it exceed)

 

Here is my class that has a related on it

 

https://github.com/Guild-Hall/MHFC/blob/1.12.2/src/main/java/mhfc/net/common/tile/TileHunterBench.java

 

https://github.com/Guild-Hall/MHFC/blob/1.12.2/src/main/java/mhfc/net/common/block/container/BlockHunterBench.java

 

P.S on 1.11.2 this methods are all the same, 

  • Quote

Share this post


Link to post
Share on other sites

V0idWa1k3r    391

V0idWa1k3r

V0idWa1k3r    391

  • World Shaper
  • V0idWa1k3r
  • Members
  • 391
  • 1773 posts
Posted November 22, 2018
Quote

public class TileHunterBench extends TileEntity implements ..., IInventory, ...

Don't ever implement IInventory. Use capabilities instead.

 

Quote

extends BlockContainer

Don't extend BlockContainer. It overrides a bunch of methods you do not need, like the rendering method. Just override Block#hasTileEntity and Block#createTileEntity.

 

26 minutes ago, Heltrato said:

it allows to craft even if the required quantity is not me

IIngredient by default doesn't care for the stack size since it is only used for vanilla crafting bench and that one only operates in stack sizes of one. You need to check the stack size yourself.

 

26 minutes ago, Heltrato said:

upon finish crafting it just consumes on how many quantity the requiredstack is (even if it exceed)

Well, why wouldn't it? That's what you are telling it to do:

private void finishRecipe() {
		...
		resetInputStacks();
		...
}

private void resetInputStacks() {
		Arrays.fill(inputStacks, ItemStack.EMPTY);
	}

You are telling your TE to fill all inputs with an empty stack when it is done.

 

Unrelated

Quote

package mhfc.net

Do you own mhfc.net? Because if you don't you can't name your package like that. And if you do - fix the security warning, I can't even access the site.

 

  • Quote

Share this post


Link to post
Share on other sites

Heltrato    1

Heltrato

Heltrato    1

  • Diamond Finder
  • Heltrato
  • Members
  • 1
  • 259 posts
Posted November 22, 2018 (edited)
6 minutes ago, V0idWa1k3r said:

Don't ever implement IInventory. Use capabilities instead.

 

Don't extend BlockContainer. It overrides a bunch of methods you do not need, like the rendering method. Just override Block#hasTileEntity and Block#createTileEntity.

 

IIngredient by default doesn't care for the stack size since it is only used for vanilla crafting bench and that one only operates in stack sizes of one. You need to check the stack size yourself.

 

Well, why wouldn't it? That's what you are telling it to do:


private void finishRecipe() {
		...
		resetInputStacks();
		...
}

private void resetInputStacks() {
		Arrays.fill(inputStacks, ItemStack.EMPTY);
	}

You are telling your TE to fill all inputs with an empty stack when it is done.

 

Unrelated

Do you own mhfc.net? Because if you don't you can't name your package like that. And if you do - fix the security warning, I can't even access the site.

 

Is there any code related that reduces the StackSize of the inputStacks? I haven't really found out one since then :/ thou this method works fine during 1.11.2

 

Oh yeah, mhfc.net was our package since we started from 1.4.7 i'll have to rename this soon.

Edited November 22, 2018 by Heltrato
  • Quote

Share this post


Link to post
Share on other sites

V0idWa1k3r    391

V0idWa1k3r

V0idWa1k3r    391

  • World Shaper
  • V0idWa1k3r
  • Members
  • 391
  • 1773 posts
Posted November 22, 2018
4 minutes ago, Heltrato said:

Is there any code related that reduces the StackSize of the inputStacks?

ItemStack#shrink, ItemStack#setCount

  • Quote

Share this post


Link to post
Share on other sites

Heltrato    1

Heltrato

Heltrato    1

  • Diamond Finder
  • Heltrato
  • Members
  • 1
  • 259 posts
Posted November 22, 2018
1 hour ago, V0idWa1k3r said:

ItemStack#shrink, ItemStack#setCount

last question, is there a way i can make a ItemStack[] applicable for ItemStack#shrink?

  • Quote

Share this post


Link to post
Share on other sites

V0idWa1k3r    391

V0idWa1k3r

V0idWa1k3r    391

  • World Shaper
  • V0idWa1k3r
  • Members
  • 391
  • 1773 posts
Posted November 22, 2018
1 hour ago, Heltrato said:

is there a way i can make a ItemStack[] applicable for ItemStack#shrink?

Iterate it. Or use streams.

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • diesieben07
      How to run code every time a Potion effect is applied

      By diesieben07 · Posted 4 minutes ago

      That's just the (bad) method name.
    • squidlex
      How to run code every time a Potion effect is applied

      By squidlex · Posted 13 minutes ago

      Thank you! My Potion isn't using Attribute modifiers however, is there a way I can still use this?
    • diesieben07
      How to run code every time a Potion effect is applied

      By diesieben07 · Posted 17 minutes ago

      Effect#applyAttributesModifiersToEntity will be called when the potion is applied and Effect#removeAttributesModifiersFromEntity. If the effect is applied again (i.e. it changes) Minecraft will first call the remove method, then the apply method again.
    • diesieben07
      minecraft crashes as soon as I use shaders

      By diesieben07 · Posted 19 minutes ago

      Sure, why not.
    • JoehnMama
      minecraft crashes as soon as I use shaders

      By JoehnMama · Posted 24 minutes ago

      Checked again and turns out that there's a newer driver I can install. I installed it and it still isn't working. Should I post another crash report?  
  • Topics

    • squidlex
      3
      How to run code every time a Potion effect is applied

      By squidlex
      Started 46 minutes ago

    • JoehnMama
      8
      minecraft crashes as soon as I use shaders

      By JoehnMama
      Started 8 hours ago

    • Choonster
      4
      [1.16.5] Properly using DistExecutor with arguments

      By Choonster
      Started Saturday at 06:23 PM

    • Giligameshh
      2
      Create mod keeps crashing

      By Giligameshh
      Started 18 hours ago

    • P0SCH1T0
      11
      Why my modded server keep saying: "Unexpected custom data from client"?

      By P0SCH1T0
      Started Saturday at 10:12 AM

  • Who's Online (See full list)

    • diesieben07
    • AzizD
    • squidlex
    • Dr.Foxtrot
    • MrLoop95
    • MistyMarshes
    • yungbankov
    • GermanBucket
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Custom Crafting Bench bug
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community