mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 18:44:42 +00:00
make fluid pattern terminal work like fluid encoder
This commit is contained in:
1 parent
632c0c3b8f
commit
281620f695
8 files changed
+194
-11
No files matched your search
+10
-3
@@ -15,6 +15,10 @@ buildscript {
|
||||
name 'jitpack'
|
||||
url 'https://jitpack.io'
|
||||
}
|
||||
maven {
|
||||
name "forge"
|
||||
url "http://files.minecraftforge.net/maven"
|
||||
}
|
||||
mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
@@ -37,15 +41,18 @@ compileJava {
|
||||
repositories {
|
||||
maven { url 'https://dvs1.progwml6.com/files/maven/' }
|
||||
maven { url 'https://jitpack.io/' }
|
||||
maven { url 'https://cfa2.cursemaven.com/' }
|
||||
maven { url 'https://cursemaven.com/' }
|
||||
maven { url "https://minecraft.curseforge.com/api/maven/" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.github.phantamanta44:jsr305:1.0.1'
|
||||
deobfCompile 'mezz.jei:jei_1.12.2:4.15.0.293'
|
||||
deobfCompile "curse.maven:ae2-extended-life-570458:2747063" // pae2
|
||||
deobfCompile 'mezz.jei:jei_1.12.2:4.15.0.293' //jei
|
||||
deobfCompile "curse.maven:ae2-extended-life-570458:3785381" // pae2
|
||||
deobfCompile "curse.maven:packagedauto-308380:2977147" // 1.0.3.14
|
||||
deobfCompile "curse.maven:modular-machinery-270790:2761302" // 1.11.1
|
||||
deobfCompile "curse.maven:codechicken-lib-1-8-242818:2779848" //ccl
|
||||
deobfCompile "gregtechce:gregtech:1.12.2:1.15.1.735" // gt
|
||||
}
|
||||
|
||||
minecraft {
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
systemProp.http.proxyHost=127.0.0.1
|
||||
systemProp.http.proxyPort=7890
|
||||
systemProp.https.proxyHost=127.0.0.1
|
||||
systemProp.https.proxyPort=7890
|
||||
@@ -0,0 +1,87 @@
|
||||
package yalter.mousetweaks.api;
|
||||
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
/**
|
||||
* This is the interface you want to implement in your GuiScreen to make it compatible with Mouse Tweaks.
|
||||
* If this interface is not enough (for example, you need a custom slot click function, or if you use a custom Container
|
||||
* which happens to be incompatible), check IMTModGuiContainer2Ex instead.
|
||||
* If you just need to disable Mouse Tweaks or the wheel tweak, see the MouseTweaksIgnore
|
||||
* or the MouseTweaksDisableWheelTweak annotations.
|
||||
*/
|
||||
public interface IMTModGuiContainer2 {
|
||||
/**
|
||||
* If you want to disable Mouse Tweaks in your GuiScreen, return true from this method.
|
||||
*
|
||||
* @return True if Mouse Tweaks should be disabled, false otherwise.
|
||||
*/
|
||||
boolean MT_isMouseTweaksDisabled();
|
||||
|
||||
/**
|
||||
* If you want to disable the Wheel Tweak in your GuiScreen, return true from this method.
|
||||
*
|
||||
* @return True if the Wheel Tweak should be disabled, false otherwise.
|
||||
*/
|
||||
boolean MT_isWheelTweakDisabled();
|
||||
|
||||
/**
|
||||
* Returns the Container.
|
||||
*
|
||||
* @return Container that is currently in use.
|
||||
*/
|
||||
Container MT_getContainer();
|
||||
|
||||
/**
|
||||
* Returns the Slot that is currently selected by the player, or null if no Slot is selected.
|
||||
*
|
||||
* @return Slot that is located under the mouse, or null if no Slot it currently under the mouse.
|
||||
*/
|
||||
Slot MT_getSlotUnderMouse();
|
||||
|
||||
/**
|
||||
* Return true if the given Slot behaves like the vanilla crafting output slots (inside the crafting table,
|
||||
* or the furnace output slot, or the anvil output slot, etc.). These slots are handled differently by Mouse Tweaks.
|
||||
*
|
||||
* @param slot the slot to check
|
||||
* @return True if slot is a crafting output slot.
|
||||
*/
|
||||
boolean MT_isCraftingOutput(Slot slot);
|
||||
|
||||
/**
|
||||
* Return true if the given Slot should be ignored by Mouse Tweaks. Examples of ignored slots are the item select
|
||||
* slots and the Destroy Item slot in the vanilla creative inventory.
|
||||
*
|
||||
* @param slot the slot to check
|
||||
* @return Tru if slot should be ignored by Mouse Tweaks.
|
||||
*/
|
||||
boolean MT_isIgnored(Slot slot);
|
||||
|
||||
/**
|
||||
* If your container has an RMB dragging functionality (like vanilla containers), disable it inside this method.
|
||||
* This method is called every frame (render tick), which is after all mouseClicked / mouseClickMove / mouseReleased
|
||||
* events are handled (although note these events are handled every game tick, which is far less frequent than every
|
||||
* render tick).<br><br>
|
||||
*
|
||||
* If true is returned from this method, Mouse Tweaks (after checking other conditions like isIgnored) will click
|
||||
* the slot on which the right mouse button was initially pressed (in most cases this is the slot currently under
|
||||
* mouse). This is needed because the vanilla RMB dragging functionality prevents the initial slot click.<br><br>
|
||||
*
|
||||
* For vanilla containers this method looks like this:
|
||||
* <pre>
|
||||
* this.ignoreMouseUp = true;
|
||||
*
|
||||
* if (this.dragSplitting) {
|
||||
* if (this.dragSplittingButton == 1) {
|
||||
* this.dragSplitting = false;
|
||||
* return true;
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* return false;
|
||||
* </pre>
|
||||
*
|
||||
* @return True if Mouse Tweaks should click the slot on which the RMB was pressed.
|
||||
*/
|
||||
boolean MT_disableRMBDraggingFunctionality();
|
||||
}
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
package com.glodblock.github.client.container;
|
||||
package com.glodblock.github.client;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.render.StackSizeRenderer;
|
||||
import appeng.core.localization.GuiText;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.container.ContainerFluidPatternEncoder;
|
||||
import com.glodblock.github.client.render.FluidRenderUtils;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
|
||||
+52
@@ -5,6 +5,9 @@ import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import appeng.container.slot.SlotPatternOutputs;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
|
||||
@@ -14,9 +17,14 @@ import com.glodblock.github.interfaces.PatternConsumer;
|
||||
import com.glodblock.github.loader.FCItems;
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import com.glodblock.github.util.FluidPatternDetails;
|
||||
import com.glodblock.github.util.Util;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -145,4 +153,48 @@ public class ContainerFluidPatternTerminal extends ContainerPatternTerm implemen
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
|
||||
if (this.isCraftingMode()) {
|
||||
super.doAction(player, action, slotId, id);
|
||||
return;
|
||||
}
|
||||
if (slotId < 0 || slotId >= this.inventorySlots.size()) {
|
||||
super.doAction(player, action, slotId, id);
|
||||
return;
|
||||
}
|
||||
Slot slot = getSlot(slotId);
|
||||
ItemStack stack = player.inventory.getItemStack();
|
||||
if ((slot instanceof SlotFakeCraftingMatrix || slot instanceof SlotPatternOutputs) && !stack.isEmpty()
|
||||
&& stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
|
||||
FluidStack fluid = null;
|
||||
switch (action) {
|
||||
case PICKUP_OR_SET_DOWN:
|
||||
fluid = Util.getFluidFromItem(stack);
|
||||
slot.putStack(ItemFluidPacket.newStack(fluid));
|
||||
break;
|
||||
case SPLIT_OR_PLACE_SINGLE:
|
||||
fluid = Util.getFluidFromItem(ItemHandlerHelper.copyStackWithSize(stack, 1));
|
||||
FluidStack origin = ItemFluidPacket.getFluidStack(slot.getStack());
|
||||
if (fluid != null && fluid.equals(origin)) {
|
||||
fluid.amount += origin.amount;
|
||||
if (fluid.amount <= 0) fluid = null;
|
||||
}
|
||||
slot.putStack(ItemFluidPacket.newStack(fluid));
|
||||
break;
|
||||
}
|
||||
if (fluid == null) {
|
||||
super.doAction(player, action, slotId, id);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (action == InventoryAction.SPLIT_OR_PLACE_SINGLE) {
|
||||
if (stack.isEmpty() && !slot.getStack().isEmpty() && slot.getStack().getItem() instanceof ItemFluidPacket) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.doAction(player, action, slotId, id);
|
||||
}
|
||||
|
||||
}
|
||||
+12
-7
@@ -1,6 +1,8 @@
|
||||
package com.glodblock.github.integration.jei;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.container.ContainerFluidPatternTerminal;
|
||||
import com.glodblock.github.common.part.PartFluidPatternTerminal;
|
||||
@@ -10,12 +12,11 @@ import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
|
||||
import mezz.jei.transfer.RecipeTransferErrorTooltip;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
||||
public class FluidPatternTerminalRecipeTransferHandler implements IRecipeTransferHandler<ContainerFluidPatternTerminal> {
|
||||
|
||||
@@ -35,13 +36,17 @@ public class FluidPatternTerminalRecipeTransferHandler implements IRecipeTransfe
|
||||
@Override
|
||||
public IRecipeTransferError transferRecipe(@Nonnull ContainerFluidPatternTerminal container, @Nonnull IRecipeLayout recipeLayout,
|
||||
@Nonnull EntityPlayer player, boolean maxTransfer, boolean doTransfer) {
|
||||
if (container.craftingMode) {
|
||||
if (!recipeLayout.getRecipeCategory().getUid().equals(VanillaRecipeCategoryUid.CRAFTING)) {
|
||||
return new RecipeTransferErrorTooltip(I18n.format(NameConst.TT_CRAFTING_RECIPE_ONLY));
|
||||
try {
|
||||
if (container.isCraftingMode() && !recipeLayout.getRecipeCategory().getUid().equals(VanillaRecipeCategoryUid.CRAFTING)) {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.CraftMode", "0"));
|
||||
}
|
||||
} else if (recipeLayout.getRecipeCategory().getUid().equals(VanillaRecipeCategoryUid.CRAFTING)) {
|
||||
return new RecipeTransferErrorTooltip(I18n.format(NameConst.TT_PROCESSING_RECIPE_ONLY));
|
||||
else if (!container.isCraftingMode() && recipeLayout.getRecipeCategory().getUid().equals(VanillaRecipeCategoryUid.CRAFTING)) {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.CraftMode", "1"));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (doTransfer && container.getPatternTerminal() instanceof PartFluidPatternTerminal) {
|
||||
PartFluidPatternTerminal tile = (PartFluidPatternTerminal)container.getPatternTerminal();
|
||||
IAEItemStack[] crafting = new IAEItemStack[tile.getInventoryByName("crafting").getSlots()];
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.glodblock.github.util;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public final class Util {
|
||||
|
||||
public static FluidStack getFluidFromItem(ItemStack stack) {
|
||||
if (!stack.isEmpty() && stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
|
||||
if (stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null) != null) {
|
||||
IFluidTankProperties[] tanks = Objects.requireNonNull(stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)).getTankProperties();
|
||||
for (IFluidTankProperties tank : tanks) {
|
||||
if (tank != null && tank.getContents() != null) {
|
||||
return tank.getContents().copy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
public net.minecraft.inventory.InventoryCrafting field_70465_c # eventHandler
|
||||
Reference in new issue
Block a user