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
  • 261 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
  • 261 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
  • 261 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
      [1.16.4] Getting values from config

      By diesieben07 · Posted 7 minutes ago

      Look at Forge's config for an example: https://github.com/MinecraftForge/MinecraftForge/blob/1.16.x/src/main/java/net/minecraftforge/common/ForgeConfig.java
    • BeardlessBrady
      [1.16.4] Getting values from config

      By BeardlessBrady · Posted 12 minutes ago

      How do I get access to the config instance though? Since now you register your config via "ModLoadingContext.get().registerConfig"
    • pitbox46
      Pushing Redstone

      By pitbox46 · Posted 16 minutes ago

      Well, that sucks. Then I would have to use a core mod? I'm not too knowlegeable on core modding other than it is advised to use a different apporach and 99% of the time there is some better way. Would a purely additive core mod, a mod that only adds fields and classes, still cause issues with other mods?    Also, is there a way to change the class of a minecraft block without registering an entirely new block? If I could simply make a subclass of a block's existing class, I could register the block as being a part of the new sub-class which would contain functionality for what I want to do. This would, of course, only apply the functionality to blocks that I make a new sub-class for. 
    • diesieben07
      Error: net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Advanced Machines (advanced_machines) Код завершения: -1

      By diesieben07 · Posted 43 minutes ago

      1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
    • DeadPony
      Error: net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Advanced Machines (advanced_machines) Код завершения: -1

      By DeadPony · Posted 59 minutes ago

      ? Help pls ? crash-2021-02-26_17.28.35-client.txt
  • Topics

    • BeardlessBrady
      3
      [1.16.4] Getting values from config

      By BeardlessBrady
      Started 12 hours ago

    • pitbox46
      2
      Pushing Redstone

      By pitbox46
      Started 8 hours ago

    • DeadPony
      1
      Error: net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Advanced Machines (advanced_machines) Код завершения: -1

      By DeadPony
      Started 59 minutes ago

    • IntentScarab
      1
      [1.16.4] Question on implementing recipes based on NBT data

      By IntentScarab
      Started 13 hours ago

    • than00ber1
      4
      [1.16.4] Change Biome RainType through Reflections Casting error

      By than00ber1
      Started Tuesday at 03:26 PM

  • Who's Online (See full list)

    • pitbox46
    • diesieben07
    • BeardlessBrady
    • Funyaah
    • DeadPony
    • IntentScarab
    • Leronus
    • Choonster
  • 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