-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #896 from Gu-ZT/releases/1.20.1
实现Emi拖拽设置过滤
- Loading branch information
Showing
15 changed files
with
133 additions
and
30 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
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
37 changes: 37 additions & 0 deletions
37
common/src/main/java/dev/dubhe/anvilcraft/integration/emi/GhostIngredientHandler.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,37 @@ | ||
package dev.dubhe.anvilcraft.integration.emi; | ||
|
||
import dev.dubhe.anvilcraft.client.gui.screen.inventory.IFilterScreen; | ||
import dev.dubhe.anvilcraft.network.SlotFilterChangePack; | ||
import dev.emi.emi.api.EmiDragDropHandler; | ||
import dev.emi.emi.api.stack.EmiIngredient; | ||
import dev.emi.emi.api.stack.EmiStack; | ||
import net.minecraft.client.gui.screens.Screen; | ||
import net.minecraft.client.renderer.Rect2i; | ||
import net.minecraft.world.inventory.Slot; | ||
import net.minecraft.world.item.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
public class GhostIngredientHandler<T extends Screen & IFilterScreen<?>> implements EmiDragDropHandler<T> { | ||
@Override | ||
public boolean dropStack( | ||
@NotNull T screen, @NotNull EmiIngredient ingredient, int x, int y | ||
) { | ||
if (!screen.isFilterEnabled()) return false; | ||
List<EmiStack> stacks = ingredient.getEmiStacks(); | ||
if (stacks.size() != 1) return false; | ||
ItemStack stack = stacks.get(0).getItemStack(); | ||
if (stack.isEmpty()) return false; | ||
for (Slot slot : screen.getFilterMenu().slots) { | ||
Rect2i rect2i = new Rect2i(screen.getOffsetX() + slot.x, screen.getOffsetY() + slot.y, 16, 16); | ||
if (rect2i.contains(x, y)) { | ||
if (screen.setFilter(screen.getFilterMenu().getFilterSlotIndex(slot), stack)) { | ||
new SlotFilterChangePack(screen.getFilterMenu().getFilterSlotIndex(slot), stack).send(); | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
} |
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
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