Skip to content

Commit 21c0402

Browse files
committed
Fix #2
1 parent 4968107 commit 21c0402

File tree

3 files changed

+60
-49
lines changed

3 files changed

+60
-49
lines changed

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* It is advised that you do not edit anything in the build.gradle; unless you are sure of what you are doing
33
*/
4+
//file:noinspection unused
45
import com.gtnewhorizons.retrofuturagradle.mcp.InjectTagsTask
56
import org.jetbrains.changelog.Changelog
67
import org.jetbrains.gradle.ext.Gradle
@@ -207,7 +208,7 @@ dependencies {
207208
implementation(rfg.deobf('curse.maven:baubles-227083:2518667')) //baubles
208209
compileOnly(rfg.deobf("curse.maven:thaumic-223628:2629023"))
209210
compileOnly(rfg.deobf("curse.maven:thaumic-energistics-extended-life-849094:6321322"))
210-
implementation(rfg.deobf("curse.maven:mekanism-ce-399904:4804509")) //mek-ce
211+
compileOnly(rfg.deobf("curse.maven:mekanism-ce-399904:4804509")) //mek-ce
211212
compileOnly(rfg.deobf("curse.maven:mekanism-energistics-1027681:5389347")) //mekeng
212213
compileOnly(rfg.deobf('curse.maven:opencomputers-223008:4630537')) //oc
213214
compileOnly(rfg.deobf("curse.maven:p455w0rdslib-255232:2830265"))

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ show_testing_output = false
1515

1616
# Mod Information
1717
# HIGHLY RECOMMEND complying with SemVer for mod_version: https://semver.org/
18-
mod_version = 2.7.4-unofficial
18+
mod_version = 2.7.6-unofficial
1919
root_package = com.glodblock.github
2020
mod_id = ae2fc
2121
mod_name = AE2FluidCraft-Rework-Unofficial

src/main/java/com/glodblock/github/coremod/mixin/ae2/container/MixinContainerCellWorkbench.java

Lines changed: 57 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020
import net.minecraft.item.ItemStack;
2121
import net.minecraftforge.fluids.FluidStack;
2222
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
23+
import net.minecraftforge.fml.common.Optional;
2324
import net.minecraftforge.items.ItemHandlerHelper;
2425
import org.spongepowered.asm.mixin.Final;
2526
import org.spongepowered.asm.mixin.Intrinsic;
2627
import org.spongepowered.asm.mixin.Mixin;
2728
import org.spongepowered.asm.mixin.Shadow;
29+
import org.spongepowered.asm.mixin.Unique;
2830

2931
@Mixin(value = ContainerCellWorkbench.class, remap = false)
3032
public abstract class MixinContainerCellWorkbench extends ContainerUpgradeable {
@@ -39,58 +41,66 @@ public MixinContainerCellWorkbench(final InventoryPlayer ip, final IUpgradeableH
3941

4042
@Intrinsic
4143
public void doAction(final EntityPlayerMP player, final InventoryAction action, final int slotId, final long id) {
42-
if (this.workBench.getCell() instanceof ItemViewCell) {
43-
final Slot slot = getSlot(slotId);
44-
final ItemStack stack = player.inventory.getItemStack();
45-
if (slot instanceof SlotFake && !stack.isEmpty()
46-
&& stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null) && Util.getFluidFromItem(stack) != null) {
47-
FluidStack fluid = null;
48-
switch (action) {
49-
case PICKUP_OR_SET_DOWN:
50-
fluid = Util.getFluidFromItem(stack);
51-
slot.putStack(FakeFluids.packFluid2Drops(fluid));
52-
break;
53-
case SPLIT_OR_PLACE_SINGLE:
54-
fluid = Util.getFluidFromItem(ItemHandlerHelper.copyStackWithSize(stack, 1));
55-
final FluidStack origin = FakeItemRegister.getStack(slot.getStack());
56-
if (fluid != null && fluid.equals(origin)) {
57-
fluid.amount += origin.amount;
58-
if (fluid.amount <= 0) fluid = null;
59-
}
60-
slot.putStack(FakeFluids.packFluid2Drops(fluid));
61-
break;
44+
if (id != 0 || slotId < 0 || slotId >= this.inventorySlots.size()
45+
|| !(this.workBench.getCell() instanceof ItemViewCell)) {
46+
super.doAction(player, action, slotId, id);
47+
return;
48+
}
49+
final Slot slot = getSlot(slotId);
50+
final ItemStack stack = player.inventory.getItemStack();
51+
if (slot instanceof SlotFake && !stack.isEmpty()
52+
&& stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null) && Util.getFluidFromItem(stack) != null) {
53+
FluidStack fluid = null;
54+
switch (action) {
55+
case PICKUP_OR_SET_DOWN -> {
56+
fluid = Util.getFluidFromItem(stack);
57+
slot.putStack(FakeFluids.packFluid2Drops(fluid));
6258
}
63-
if (fluid == null) {
64-
super.doAction(player, action, slotId, id);
65-
return;
59+
case SPLIT_OR_PLACE_SINGLE -> {
60+
fluid = Util.getFluidFromItem(ItemHandlerHelper.copyStackWithSize(stack, 1));
61+
final FluidStack origin = FakeItemRegister.getStack(slot.getStack());
62+
if (fluid != null && fluid.equals(origin)) {
63+
fluid.amount += origin.amount;
64+
if (fluid.amount <= 0) fluid = null;
65+
}
66+
slot.putStack(FakeFluids.packFluid2Drops(fluid));
6667
}
67-
return;
6868
}
69-
if (ModAndClassUtil.GAS && slot instanceof SlotFake && !stack.isEmpty()
70-
&& stack.getItem() instanceof IGasItem && Util.getGasFromItem(stack) != null) {
71-
GasStack gas = null;
72-
switch (action) {
73-
case PICKUP_OR_SET_DOWN:
74-
gas = Util.getGasFromItem(stack);
75-
slot.putStack(FakeGases.packGas2Drops(gas));
76-
break;
77-
case SPLIT_OR_PLACE_SINGLE:
78-
gas = Util.getGasFromItem(ItemHandlerHelper.copyStackWithSize(stack, 1));
79-
final GasStack origin = FakeItemRegister.getStack(slot.getStack());
80-
if (gas != null && gas.equals(origin)) {
81-
gas.amount += origin.amount;
82-
if (gas.amount <= 0) gas = null;
83-
}
84-
slot.putStack(FakeGases.packGas2Drops(gas));
85-
break;
86-
}
87-
if (gas == null) {
88-
super.doAction(player, action, slotId, id);
89-
return;
90-
}
69+
if (fluid == null) {
70+
super.doAction(player, action, slotId, id);
9171
return;
9272
}
73+
return;
74+
}
75+
if (ModAndClassUtil.GAS && slot instanceof SlotFake && !stack.isEmpty()
76+
&& stack.getItem() instanceof IGasItem && Util.getGasFromItem(stack) != null) {
77+
mek$doAction(player, action, slotId, id, slot, stack);
78+
return;
9379
}
9480
super.doAction(player, action, slotId, id);
9581
}
96-
}
82+
83+
@Unique
84+
@Optional.Method(modid = "mekeng")
85+
private void mek$doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id, Slot slot, ItemStack stack) {
86+
GasStack gas = null;
87+
switch (action) {
88+
case PICKUP_OR_SET_DOWN -> {
89+
gas = Util.getGasFromItem(stack);
90+
slot.putStack(FakeGases.packGas2Drops(gas));
91+
}
92+
case SPLIT_OR_PLACE_SINGLE -> {
93+
gas = Util.getGasFromItem(ItemHandlerHelper.copyStackWithSize(stack, 1));
94+
final GasStack origin = FakeItemRegister.getStack(slot.getStack());
95+
if (gas != null && gas.equals(origin)) {
96+
gas.amount += origin.amount;
97+
if (gas.amount <= 0) gas = null;
98+
}
99+
slot.putStack(FakeGases.packGas2Drops(gas));
100+
}
101+
}
102+
if (gas == null) {
103+
super.doAction(player, action, slotId, id);
104+
}
105+
}
106+
}

0 commit comments

Comments
 (0)