-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix TR compat recipes, and add automagically generated compat KubeJS …
…scripts
- Loading branch information
1 parent
6036a08
commit 8af1b6f
Showing
9 changed files
with
309 additions
and
28 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
49 changes: 49 additions & 0 deletions
49
src/main/java/aztech/modern_industrialization/compat/kubejs/RemoveItemsEntrypoint.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,49 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Azercoco & Technici4n | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package aztech.modern_industrialization.compat.kubejs; | ||
|
||
import dev.latvian.kubejs.event.EventJS; | ||
import dev.latvian.kubejs.script.ScriptType; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class RemoveItemsEntrypoint { | ||
public static Set<String> getItemsToRemove() { | ||
return MIReiEvent.gatherItemsToRemove(); | ||
} | ||
|
||
public static class MIReiEvent extends EventJS { | ||
private final Set<String> removeSet = new HashSet<>(); | ||
|
||
public void remove(String item) { | ||
removeSet.add(item); | ||
} | ||
|
||
private static Set<String> gatherItemsToRemove() { | ||
MIReiEvent event = new MIReiEvent(); | ||
event.post(ScriptType.CLIENT, "mi_rei"); | ||
return event.removeSet; | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/aztech/modern_industrialization/compat/rei/KJSRemoveItemsPlugin.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,54 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Azercoco & Technici4n | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package aztech.modern_industrialization.compat.rei; | ||
|
||
import aztech.modern_industrialization.compat.kubejs.RemoveItemsEntrypoint; | ||
import java.util.Set; | ||
import me.shedaniel.rei.api.client.plugins.REIClientPlugin; | ||
import me.shedaniel.rei.api.client.registry.entry.EntryRegistry; | ||
import net.fabricmc.loader.api.FabricLoader; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.registry.Registry; | ||
|
||
public class KJSRemoveItemsPlugin implements REIClientPlugin { | ||
@Override | ||
public double getPriority() { | ||
return 1e6; // run after other stuff | ||
} | ||
|
||
@Override | ||
public void registerEntries(EntryRegistry registry) { | ||
if (FabricLoader.getInstance().isModLoaded("kubejs")) { | ||
Set<String> itemIds = RemoveItemsEntrypoint.getItemsToRemove(); | ||
registry.removeEntryIf(entryStack -> { | ||
if (entryStack.getValue() instanceof ItemStack is) { | ||
if (itemIds.contains(Registry.ITEM.getId(is.getItem()).toString())) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}); | ||
} | ||
} | ||
} |
Oops, something went wrong.