-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add in more support for Curios again
Closes #603
- Loading branch information
1 parent
451c707
commit 198efe6
Showing
10 changed files
with
148 additions
and
83 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
29 changes: 29 additions & 0 deletions
29
...datagen/src/main/java/dev/compactmods/machines/datagen/base/compat/PSDCuriosProvider.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,29 @@ | ||
package dev.compactmods.machines.datagen.base.compat; | ||
|
||
import dev.compactmods.machines.api.CompactMachines; | ||
import dev.compactmods.machines.compat.curios.CuriosCompat; | ||
import net.minecraft.core.HolderLookup; | ||
import net.minecraft.data.PackOutput; | ||
import net.neoforged.neoforge.common.data.ExistingFileHelper; | ||
import top.theillusivec4.curios.api.CuriosDataProvider; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class PSDCuriosProvider extends CuriosDataProvider { | ||
|
||
public PSDCuriosProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, ExistingFileHelper existingFileHelper) { | ||
super(CompactMachines.MOD_ID, output, existingFileHelper, lookupProvider); | ||
} | ||
|
||
@Override | ||
public void generate(HolderLookup.Provider registries, ExistingFileHelper fileHelper) { | ||
this.createSlot("psd") | ||
.icon(CompactMachines.modRL("slot/empty_psd")) | ||
.size(1) | ||
.addValidator(CuriosCompat.PSD_VALIDATOR); | ||
|
||
this.createEntities("psd") | ||
.addPlayer() | ||
.addSlots("psd"); | ||
} | ||
} |
33 changes: 0 additions & 33 deletions
33
...agen/src/main/java/dev/compactmods/machines/datagen/base/curios/CurioEntityGenerator.java
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
...atagen/src/main/java/dev/compactmods/machines/datagen/base/curios/CurioSlotGenerator.java
This file was deleted.
Oops, something went wrong.
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
41 changes: 41 additions & 0 deletions
41
neoforge-main/src/main/java/dev/compactmods/machines/compat/curios/CuriosCompat.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,41 @@ | ||
package dev.compactmods.machines.compat.curios; | ||
|
||
import dev.compactmods.machines.api.CompactMachines; | ||
import dev.compactmods.machines.api.shrinking.PSDTags; | ||
import dev.compactmods.machines.shrinking.Shrinking; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import top.theillusivec4.curios.api.CuriosApi; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public class CuriosCompat { | ||
|
||
public static final ResourceLocation PSD_VALIDATOR = CompactMachines.modRL("has_shrinking_config"); | ||
|
||
public static void register() { | ||
|
||
CuriosApi.registerCurioPredicate(PSD_VALIDATOR, result -> { | ||
final var stack = result.stack(); | ||
return stack.is(PSDTags.ITEM) || stack.has(Shrinking.DataComponents.SHRINKING_CONFIG); | ||
}); | ||
} | ||
|
||
public static boolean hasPsdCurio(@Nonnull LivingEntity ent) { | ||
final var inv = CuriosApi.getCuriosInventory(ent) | ||
.flatMap(handler -> handler.getStacksHandler("psd")) | ||
.orElse(null); | ||
|
||
if(inv == null) return false; | ||
|
||
for(var slot = 0; slot < inv.getSlots(); slot++) { | ||
var slotItem = inv.getStacks().getStackInSlot(slot); | ||
if(slotItem.isEmpty()) continue; | ||
|
||
if(slotItem.has(Shrinking.DataComponents.SHRINKING_CONFIG) || slotItem.is(PSDTags.ITEM)) | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} |