-
Notifications
You must be signed in to change notification settings - Fork 151
Better idling for metatileentities and multiblocks #1554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
PrototypeTrousers
wants to merge
26
commits into
GregTechCE:master
Choose a base branch
from
PrototypeTrousers:RecipeLogic
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
c6454cc
Reworked trySearchNewRecipe and findRecipe
PrototypeTrousers 9c622be
rework logic
PrototypeTrousers 3c0e6f1
Refactor trySearchNewRecipe; add test to show issue re: lastItemOutputs
Exaxxion 2655473
Changed item merging from full inventory copy to partial stacks copy
PrototypeTrousers 27f4700
Implement notifiable item/fluid handlers
PrototypeTrousers 1146268
enable the recipe logic to make use of the notifiable handlers
PrototypeTrousers ba882ee
address issues bought up on discussion
PrototypeTrousers 5c8815d
made a declaration more obvious and with more detailed explanation
PrototypeTrousers 281cabc
reverted change due to NPE
PrototypeTrousers d2a0a7d
fix multismelter getting stuck when its output gets full
PrototypeTrousers 268a938
switched from HashSet to ArrayList.
PrototypeTrousers 3b6cd4c
switch to a linked list
PrototypeTrousers 279dd31
Simplified handler logic by only allowing one metatile to be notified
PrototypeTrousers e634951
address issues brought up
PrototypeTrousers 8d04e76
Revert "Changed item merging from full inventory copy to partial stac…
PrototypeTrousers 063a3e5
pass handlers around instead of a boolean
PrototypeTrousers 84a29ae
fix tests due to world being null
PrototypeTrousers 381d009
formatting
PrototypeTrousers 754e1b4
update javadoc
PrototypeTrousers 698d225
simplify logic
PrototypeTrousers 694d97b
match deprecated behaviour
PrototypeTrousers b424b73
fix merge conflict
PrototypeTrousers 36ac872
removed unnecesarry override and imports
PrototypeTrousers 4eaff0f
address reviewed issues
PrototypeTrousers dfd6617
Add notifiable handlers to steam variant of metaTileEntities
PrototypeTrousers c847713
make the if statements more readable
PrototypeTrousers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/main/java/gregtech/api/capability/INotifiableHandler.java
This file contains hidden or 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,33 @@ | ||
| package gregtech.api.capability; | ||
|
|
||
| import gregtech.api.metatileentity.MetaTileEntity; | ||
|
|
||
| /** | ||
| * For Item and Fluid handlers capable of notifying entities when | ||
| * their contents change | ||
| */ | ||
| public interface INotifiableHandler { | ||
|
|
||
| /** | ||
| * Adds the notified handler to the notified list | ||
| * | ||
| * @param isExport boolean specifying if a handler is an output handler | ||
| */ | ||
|
|
||
| default <T> void addToNotifiedList(MetaTileEntity metaTileEntity, T handler, boolean isExport) { | ||
| if (metaTileEntity != null && metaTileEntity.isValid()) { | ||
| if (isExport) { | ||
| metaTileEntity.addNotifiedOutput(handler); | ||
| } else { | ||
| metaTileEntity.addNotifiedInput(handler); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @param metaTileEntity MetaTileEntity to be notified | ||
| */ | ||
| default void setNotifiableMetaTileEntity(MetaTileEntity metaTileEntity) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this really be a default method? |
||
|
|
||
| } | ||
| } | ||
This file contains hidden or 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
27 changes: 27 additions & 0 deletions
27
src/main/java/gregtech/api/capability/impl/NotifiableFilteredFluidHandler.java
This file contains hidden or 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,27 @@ | ||
| package gregtech.api.capability.impl; | ||
|
|
||
| import gregtech.api.capability.INotifiableHandler; | ||
| import gregtech.api.metatileentity.MetaTileEntity; | ||
|
|
||
| public class NotifiableFilteredFluidHandler extends FilteredFluidHandler implements INotifiableHandler { | ||
|
|
||
| MetaTileEntity notifiableEntity; | ||
| private final boolean isExport; | ||
|
|
||
| public NotifiableFilteredFluidHandler(int capacity, MetaTileEntity entityToNotify, boolean isExport) { | ||
| super(capacity); | ||
| this.notifiableEntity = entityToNotify; | ||
| this.isExport = isExport; | ||
| } | ||
|
|
||
| @Override | ||
| protected void onContentsChanged() { | ||
| super.onContentsChanged(); | ||
| addToNotifiedList(notifiableEntity, this, isExport); | ||
| } | ||
|
|
||
| @Override | ||
| public void setNotifiableMetaTileEntity(MetaTileEntity metaTileEntity) { | ||
| this.notifiableEntity = metaTileEntity; | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
src/main/java/gregtech/api/capability/impl/NotifiableFluidTank.java
This file contains hidden or 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,28 @@ | ||
| package gregtech.api.capability.impl; | ||
|
|
||
| import gregtech.api.capability.INotifiableHandler; | ||
| import gregtech.api.metatileentity.MetaTileEntity; | ||
| import net.minecraftforge.fluids.FluidTank; | ||
|
|
||
| public class NotifiableFluidTank extends FluidTank implements INotifiableHandler { | ||
|
|
||
| MetaTileEntity notifiableEntity; | ||
| private final boolean isExport; | ||
|
|
||
| public NotifiableFluidTank(int capacity, MetaTileEntity entityToNotify, boolean isExport) { | ||
| super(capacity); | ||
| this.notifiableEntity = entityToNotify; | ||
| this.isExport = isExport; | ||
| } | ||
|
|
||
| @Override | ||
| protected void onContentsChanged() { | ||
| super.onContentsChanged(); | ||
| addToNotifiedList(notifiableEntity, this, isExport); | ||
| } | ||
|
|
||
| @Override | ||
| public void setNotifiableMetaTileEntity(MetaTileEntity metaTileEntity) { | ||
| this.notifiableEntity = metaTileEntity; | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
src/main/java/gregtech/api/capability/impl/NotifiableItemStackHandler.java
This file contains hidden or 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,29 @@ | ||
| package gregtech.api.capability.impl; | ||
|
|
||
| import gregtech.api.capability.INotifiableHandler; | ||
| import gregtech.api.metatileentity.MetaTileEntity; | ||
| import net.minecraftforge.items.IItemHandlerModifiable; | ||
| import net.minecraftforge.items.ItemStackHandler; | ||
|
|
||
| public class NotifiableItemStackHandler extends ItemStackHandler implements IItemHandlerModifiable, INotifiableHandler { | ||
|
|
||
| MetaTileEntity notifiableEntity; | ||
| private final boolean isExport; | ||
|
|
||
| public NotifiableItemStackHandler(int slots, MetaTileEntity entityToNotify, boolean isExport) { | ||
| super(slots); | ||
| this.notifiableEntity = entityToNotify; | ||
| this.isExport = isExport; | ||
| } | ||
|
|
||
| @Override | ||
| public void onContentsChanged(int slot) { | ||
| super.onContentsChanged(slot); | ||
| addToNotifiedList(notifiableEntity, this, isExport); | ||
| } | ||
|
|
||
| @Override | ||
| public void setNotifiableMetaTileEntity(MetaTileEntity metaTileEntity) { | ||
| this.notifiableEntity = metaTileEntity; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.