-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
343 additions
and
235 deletions.
There are no files selected for viewing
41 changes: 25 additions & 16 deletions
41
src/main/java/me/desht/modularrouters/integration/jei/BulkFilterScreenGhost.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 |
---|---|---|
@@ -1,19 +1,28 @@ | ||
package me.desht.modularrouters.integration.jei; | ||
|
||
public class BulkFilterScreenGhost /*implements IGhostIngredientHandler<BulkItemFilterScreen>*/ { | ||
// @Override | ||
// public <I> List<Target<I>> getTargets(BulkItemFilterScreen gui, I ingredient, boolean doStart) { | ||
// List<Target<I>> res = new ArrayList<>(); | ||
// for (int i = 0; i < gui.getMenu().slots.size(); i++) { | ||
// Slot s = gui.getMenu().getSlot(i); | ||
// if (s instanceof FilterSlot) { | ||
// res.add(new GhostTarget<>(gui, s)); | ||
// } | ||
// } | ||
// return res; | ||
// } | ||
// | ||
// @Override | ||
// public void onComplete() { | ||
// } | ||
import me.desht.modularrouters.client.gui.filter.BulkItemFilterScreen; | ||
import me.desht.modularrouters.container.FilterSlot; | ||
import mezz.jei.api.gui.handlers.IGhostIngredientHandler; | ||
import mezz.jei.api.ingredients.ITypedIngredient; | ||
import net.minecraft.world.inventory.Slot; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class BulkFilterScreenGhost implements IGhostIngredientHandler<BulkItemFilterScreen> { | ||
@Override | ||
public <I> List<Target<I>> getTargetsTyped(BulkItemFilterScreen gui, ITypedIngredient<I> ingredient, boolean doStart) { | ||
List<Target<I>> res = new ArrayList<>(); | ||
for (int i = 0; i < gui.getMenu().slots.size(); i++) { | ||
Slot s = gui.getMenu().getSlot(i); | ||
if (s instanceof FilterSlot) { | ||
res.add(new GhostTarget<>(gui, s)); | ||
} | ||
} | ||
return res; | ||
} | ||
|
||
@Override | ||
public void onComplete() { | ||
} | ||
} |
41 changes: 24 additions & 17 deletions
41
src/main/java/me/desht/modularrouters/integration/jei/GhostTarget.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 |
---|---|---|
@@ -1,23 +1,30 @@ | ||
package me.desht.modularrouters.integration.jei; | ||
|
||
import me.desht.modularrouters.network.ModuleFilterMessage; | ||
import me.desht.modularrouters.network.PacketHandler; | ||
import mezz.jei.api.gui.handlers.IGhostIngredientHandler; | ||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; | ||
import net.minecraft.client.renderer.Rect2i; | ||
import net.minecraft.world.inventory.Slot; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraftforge.fluids.FluidStack; | ||
import net.minecraftforge.fluids.FluidUtil; | ||
|
||
record GhostTarget<I>(AbstractContainerScreen<?> gui, Slot slot) /*implements IGhostIngredientHandler.Target<I>*/ { | ||
// @Override | ||
// public Rect2i getArea() { | ||
// return new Rect2i(slot.x + gui.getGuiLeft(), slot.y + gui.getGuiTop(), 16, 16); | ||
// } | ||
// | ||
// @Override | ||
// public void accept(I ingredient) { | ||
// if (ingredient instanceof ItemStack stack) { | ||
// PacketHandler.NETWORK.sendToServer(new ModuleFilterMessage(slot.index, stack)); | ||
// } else if (ingredient instanceof FluidStack fluidStack) { | ||
// ItemStack bucket = FluidUtil.getFilledBucket(fluidStack); | ||
// if (!bucket.isEmpty()) { | ||
// PacketHandler.NETWORK.sendToServer(new ModuleFilterMessage(slot.index, bucket)); | ||
// } | ||
// } | ||
// } | ||
record GhostTarget<I>(AbstractContainerScreen<?> gui, Slot slot) implements IGhostIngredientHandler.Target<I> { | ||
@Override | ||
public Rect2i getArea() { | ||
return new Rect2i(slot.x + gui.getGuiLeft(), slot.y + gui.getGuiTop(), 16, 16); | ||
} | ||
|
||
@Override | ||
public void accept(I ingredient) { | ||
if (ingredient instanceof ItemStack stack) { | ||
PacketHandler.NETWORK.sendToServer(new ModuleFilterMessage(slot.index, stack)); | ||
} else if (ingredient instanceof FluidStack fluidStack) { | ||
ItemStack bucket = FluidUtil.getFilledBucket(fluidStack); | ||
if (!bucket.isEmpty()) { | ||
PacketHandler.NETWORK.sendToServer(new ModuleFilterMessage(slot.index, bucket)); | ||
} | ||
} | ||
} | ||
} |
52 changes: 33 additions & 19 deletions
52
src/main/java/me/desht/modularrouters/integration/jei/JEIModularRoutersPlugin.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 |
---|---|---|
@@ -1,22 +1,36 @@ | ||
package me.desht.modularrouters.integration.jei; | ||
|
||
//@JeiPlugin | ||
public class JEIModularRoutersPlugin /*implements IModPlugin*/ { | ||
// @Override | ||
// public ResourceLocation getPluginUid() { | ||
// return RL("default"); | ||
// } | ||
// | ||
// @Override | ||
// public void registerGuiHandlers(IGuiHandlerRegistration registration) { | ||
// registration.addGhostIngredientHandler(AbstractModuleScreen.class, new ModuleScreenGhost()); | ||
// registration.addGhostIngredientHandler(BulkItemFilterScreen.class, new BulkFilterScreenGhost()); | ||
// | ||
// registration.addGuiContainerHandler(ModularRouterScreen.class, new IGuiContainerHandler<>() { | ||
// @Override | ||
// public List<Rect2i> getGuiExtraAreas(ModularRouterScreen routerScreen) { | ||
// return routerScreen.getExtraArea(); | ||
// } | ||
// }); | ||
// } | ||
import me.desht.modularrouters.client.gui.ModularRouterScreen; | ||
import me.desht.modularrouters.client.gui.filter.BulkItemFilterScreen; | ||
import me.desht.modularrouters.client.gui.module.AbstractModuleScreen; | ||
import mezz.jei.api.IModPlugin; | ||
import mezz.jei.api.JeiPlugin; | ||
import mezz.jei.api.gui.handlers.IGuiContainerHandler; | ||
import mezz.jei.api.registration.IGuiHandlerRegistration; | ||
import net.minecraft.client.renderer.Rect2i; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
import java.util.List; | ||
|
||
import static me.desht.modularrouters.util.MiscUtil.RL; | ||
|
||
@JeiPlugin | ||
public class JEIModularRoutersPlugin implements IModPlugin { | ||
@Override | ||
public ResourceLocation getPluginUid() { | ||
return RL("default"); | ||
} | ||
|
||
@Override | ||
public void registerGuiHandlers(IGuiHandlerRegistration registration) { | ||
registration.addGhostIngredientHandler(AbstractModuleScreen.class, new ModuleScreenGhost()); | ||
registration.addGhostIngredientHandler(BulkItemFilterScreen.class, new BulkFilterScreenGhost()); | ||
|
||
registration.addGuiContainerHandler(ModularRouterScreen.class, new IGuiContainerHandler<>() { | ||
@Override | ||
public List<Rect2i> getGuiExtraAreas(ModularRouterScreen routerScreen) { | ||
return routerScreen.getExtraArea(); | ||
} | ||
}); | ||
} | ||
} |
41 changes: 25 additions & 16 deletions
41
src/main/java/me/desht/modularrouters/integration/jei/ModuleScreenGhost.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 |
---|---|---|
@@ -1,19 +1,28 @@ | ||
package me.desht.modularrouters.integration.jei; | ||
|
||
public class ModuleScreenGhost /*implements IGhostIngredientHandler<AbstractModuleScreen>*/ { | ||
// @Override | ||
// public <I> List<Target<I>> getTargets(AbstractModuleScreen gui, I ingredient, boolean doStart) { | ||
// List<Target<I>> res = new ArrayList<>(); | ||
// for (int i = 0; i < gui.getMenu().slots.size(); i++) { | ||
// Slot s = gui.getMenu().getSlot(i); | ||
// if (s instanceof FilterSlot) { | ||
// res.add(new GhostTarget<>(gui, s)); | ||
// } | ||
// } | ||
// return res; | ||
// } | ||
// | ||
// @Override | ||
// public void onComplete() { | ||
// } | ||
import me.desht.modularrouters.client.gui.module.AbstractModuleScreen; | ||
import me.desht.modularrouters.container.FilterSlot; | ||
import mezz.jei.api.gui.handlers.IGhostIngredientHandler; | ||
import mezz.jei.api.ingredients.ITypedIngredient; | ||
import net.minecraft.world.inventory.Slot; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class ModuleScreenGhost implements IGhostIngredientHandler<AbstractModuleScreen> { | ||
@Override | ||
public <I> List<Target<I>> getTargetsTyped(AbstractModuleScreen gui, ITypedIngredient<I> ingredient, boolean doStart) { | ||
List<Target<I>> res = new ArrayList<>(); | ||
for (int i = 0; i < gui.getMenu().slots.size(); i++) { | ||
Slot s = gui.getMenu().getSlot(i); | ||
if (s instanceof FilterSlot) { | ||
res.add(new GhostTarget<>(gui, s)); | ||
} | ||
} | ||
return res; | ||
} | ||
|
||
@Override | ||
public void onComplete() { | ||
} | ||
} |
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
Oops, something went wrong.