forked from shedaniel/skyblock-rei
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated dependencies, added by-item search support for skyblock items.
- Loading branch information
1 parent
281059b
commit f4d502d
Showing
8 changed files
with
90 additions
and
7 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
53 changes: 53 additions & 0 deletions
53
src/main/java/com/cocona/skyblockrei/data/search/SkyblockFocusedStackProvider.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,53 @@ | ||
package com.cocona.skyblockrei.data.search; | ||
|
||
import com.cocona.skyblockrei.SkyblockREI; | ||
import com.cocona.skyblockrei.SkyblockREIPlugin; | ||
import com.cocona.skyblockrei.mixin.HandledScreenAccess; | ||
import com.mojang.brigadier.StringReader; | ||
import me.shedaniel.rei.api.EntryStack; | ||
import me.shedaniel.rei.api.FocusedStackProvider; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.gui.screen.ingame.HandledScreen; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.nbt.StringNbtReader; | ||
import net.minecraft.util.TypedActionResult; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class SkyblockFocusedStackProvider implements FocusedStackProvider { | ||
@Override | ||
public @NotNull TypedActionResult<EntryStack> provide(Screen screen) { | ||
if (screen instanceof HandledScreen) { | ||
HandledScreen<?> containerScreen = (HandledScreen<?>) screen; | ||
|
||
if (((HandledScreenAccess)containerScreen).getFocusedSlot() != null && !((HandledScreenAccess)containerScreen).getFocusedSlot().getStack().isEmpty()){ | ||
ItemStack focusedItem = ((HandledScreenAccess)containerScreen).getFocusedSlot().getStack(); | ||
try { | ||
CompoundTag tag = focusedItem.getTag(); | ||
CompoundTag subtag = tag.getCompound("ExtraAttributes"); | ||
String attID = subtag.getString("id"); | ||
EntryStack result = SkyblockREI.packagedDataRef.getEntryFromMap(attID); | ||
if(!result.equals(EntryStack.empty())){ | ||
return TypedActionResult.success(result.setting(EntryStack.Settings.CHECK_TAGS, () -> true)); | ||
} else { | ||
return TypedActionResult.success(EntryStack.create(((HandledScreenAccess) containerScreen).getFocusedSlot().getStack())); | ||
} | ||
|
||
} catch(Exception e){ | ||
SkyblockREI.LOG.error("Error caught while parsing item nbt for skyblock-specific data. Returning to default behavior!"); | ||
SkyblockREI.LOG.catching(e); | ||
return TypedActionResult.success(EntryStack.create(((HandledScreenAccess) containerScreen).getFocusedSlot().getStack())); | ||
} | ||
} | ||
} | ||
return TypedActionResult.pass(EntryStack.empty()); | ||
} | ||
|
||
@Override | ||
public double getPriority() { | ||
return 1000; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/cocona/skyblockrei/mixin/HandledScreenAccess.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,14 @@ | ||
package com.cocona.skyblockrei.mixin; | ||
|
||
import net.minecraft.client.gui.screen.ingame.HandledScreen; | ||
import net.minecraft.screen.slot.Slot; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(HandledScreen.class) | ||
public interface HandledScreenAccess { | ||
@Accessor("focusedSlot") | ||
public Slot getFocusedSlot(); | ||
|
||
|
||
} |
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 |
---|---|---|
|
@@ -8,5 +8,8 @@ | |
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
}, | ||
"mixins": [ | ||
"HandledScreenAccess" | ||
] | ||
} |