-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from GrowthcraftCE/45-roaster-inputoutput-not-…
…configured-properly 45 roaster inputoutput not configured properly
- Loading branch information
Showing
14 changed files
with
166 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/main/java/growthcraft/lib/noeppi/block/entity/handler/WrappedHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package growthcraft.lib.noeppi.block.entity.handler; | ||
|
||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraftforge.items.IItemHandlerModifiable; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.function.BiPredicate; | ||
import java.util.function.Predicate; | ||
|
||
/* | ||
* WrappedHandler by noeppi_noeppi | ||
* under https://github.com/ModdingX/LibX/blob/1.19/LICENSE | ||
* | ||
*/ | ||
public class WrappedHandler implements IItemHandlerModifiable { | ||
private final IItemHandlerModifiable handler; | ||
private final Predicate<Integer> extract; | ||
private final BiPredicate<Integer, ItemStack> insert; | ||
|
||
public WrappedHandler(IItemHandlerModifiable handler, Predicate<Integer> extract, | ||
BiPredicate<Integer, ItemStack> insert) { | ||
this.handler = handler; | ||
this.extract = extract; | ||
this.insert = insert; | ||
} | ||
|
||
@Override | ||
public void setStackInSlot(int slot, @Nonnull ItemStack stack) { | ||
this.handler.setStackInSlot(slot, stack); | ||
} | ||
|
||
@Override | ||
public int getSlots() { | ||
return this.handler.getSlots(); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public ItemStack getStackInSlot(int slot) { | ||
return this.handler.getStackInSlot(slot); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { | ||
return this.insert.test(slot, stack) ? this.handler.insertItem(slot, stack, simulate) : stack; | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public ItemStack extractItem(int slot, int amount, boolean simulate) { | ||
return this.extract.test(slot) ? this.handler.extractItem(slot, amount, simulate) : ItemStack.EMPTY; | ||
} | ||
|
||
@Override | ||
public int getSlotLimit(int slot) { | ||
return this.handler.getSlotLimit(slot); | ||
} | ||
|
||
@Override | ||
public boolean isItemValid(int slot, @Nonnull ItemStack stack) { | ||
return this.insert.test(slot, stack) && this.handler.isItemValid(slot, stack); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.