-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* item handling for tanks * fix capability issue with cover/pump
- Loading branch information
Showing
9 changed files
with
192 additions
and
99 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/main/java/gregtech/api/capability/impl/FilteredItemHandler.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,40 @@ | ||
package gregtech.api.capability.impl; | ||
|
||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.NonNullList; | ||
import net.minecraftforge.common.capabilities.Capability; | ||
import net.minecraftforge.items.ItemStackHandler; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.function.Predicate; | ||
|
||
public class FilteredItemHandler extends ItemStackHandler { | ||
|
||
public static Predicate<ItemStack> getCapabilityFilter(Capability<?> cap) { | ||
return stack -> stack.hasCapability(cap, null); | ||
} | ||
|
||
private Predicate<ItemStack> fillPredicate; | ||
|
||
public FilteredItemHandler() { | ||
super(1); | ||
} | ||
|
||
public FilteredItemHandler(int size) { | ||
super(size); | ||
} | ||
|
||
public FilteredItemHandler(NonNullList<ItemStack> stacks) { | ||
super(stacks); | ||
} | ||
|
||
public FilteredItemHandler setFillPredicate(Predicate<ItemStack> fillPredicate) { | ||
this.fillPredicate = fillPredicate; | ||
return this; | ||
} | ||
|
||
@Override | ||
public boolean isItemValid(int slot, @Nonnull ItemStack stack) { | ||
return fillPredicate == null || fillPredicate.test(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
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
Oops, something went wrong.