Skip to content

Commit 1f50e1a

Browse files
committed
修复bug
1 parent 249db37 commit 1f50e1a

File tree

9 files changed

+54
-49
lines changed

9 files changed

+54
-49
lines changed

gradle.properties

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

1717
# Mod Information
1818
# HIGHLY RECOMMEND complying with SemVer for mod_version: https://semver.org/
19-
mod_version = 1.7.8
19+
mod_version = 1.7.9
2020
root_package = com.circulation
2121
mod_id = random_complement
2222
mod_name = RandomComplement

src/main/java/com/circulation/random_complement/common/network/KeyBindingHandler.java

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
4545
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
4646

47-
import java.util.Optional;
48-
4947
public class KeyBindingHandler implements Packet<KeyBindingHandler> {
5048

5149
ItemStack stack = ItemStack.EMPTY;
@@ -130,14 +128,11 @@ private void retrieveItem(EntityPlayerMP player, Container container, ItemStack
130128
IGrid grid = gridNode.getGrid();
131129
if (securityCheck(player, grid, SecurityPermissions.EXTRACT)) {
132130
IStorageGrid storageGrid = grid.getCache(IStorageGrid.class);
133-
var iItemStorageChannel = storageGrid.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
131+
var items = storageGrid.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
134132
var host = c.getTarget();
135133
if (host instanceof IActionHost h) {
136-
var aeItemO = Optional.ofNullable(iItemStorageChannel.extractItems(AEItemStack.fromItemStack(item).setStackSize(targetCount), Actionable.SIMULATE, new PlayerSource(player, h)));
137-
138-
if (aeItemO.isPresent()) {
139-
var aeItem = aeItemO.get();
140-
var aeitem = iItemStorageChannel.extractItems(AEItemStack.fromItemStack(item).setStackSize(aeItem.getStackSize()), Actionable.MODULATE, new PlayerSource(player, h));
134+
var aeitem = items.extractItems(AEItemStack.fromItemStack(item).setStackSize(targetCount), Actionable.MODULATE, new PlayerSource(player, h));
135+
if (aeitem != null) {
141136
player.inventory.placeItemBackInInventory(player.world, aeitem.createItemStack());
142137
}
143138
}
@@ -148,18 +143,14 @@ private void retrieveItem(EntityPlayerMP player, Container container, ItemStack
148143
private long wirelessRetrieve(EntityPlayerMP player, ItemStack exItem, IGridNode gridNode, long targetCount, WirelessTerminalGuiObject obj) {
149144
IGrid grid = gridNode.getGrid();
150145
if (securityCheck(player, grid, SecurityPermissions.EXTRACT)) {
151-
IStorageGrid storageGrid = grid.getCache(IStorageGrid.class);
152-
var iItemStorageChannel = storageGrid.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
153-
var aeItemO = Optional.ofNullable(iItemStorageChannel.extractItems(AEItemStack.fromItemStack(exItem).setStackSize(targetCount), Actionable.SIMULATE, new PlayerSource(player, obj)));
146+
var items = grid.<IStorageGrid>getCache(IStorageGrid.class).getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
147+
var aeitem = items.extractItems(AEItemStack.fromItemStack(exItem).setStackSize(targetCount), Actionable.MODULATE, new PlayerSource(player, obj));
154148

155-
if (aeItemO.isPresent()) {
156-
var aeItem = aeItemO.get();
157-
var aeitem = iItemStorageChannel.extractItems(AEItemStack.fromItemStack(exItem).setStackSize(aeItem.getStackSize()), Actionable.MODULATE, new PlayerSource(player, obj));
149+
if (aeitem == null) return targetCount;
158150

159-
targetCount -= aeitem.getStackSize();
151+
targetCount -= aeitem.getStackSize();
160152

161-
player.inventory.placeItemBackInInventory(player.world, aeitem.createItemStack());
162-
}
153+
player.inventory.placeItemBackInInventory(player.world, aeitem.createItemStack());
163154
}
164155
return targetCount;
165156
}
@@ -200,7 +191,6 @@ private void startCraft(EntityPlayerMP player, Container container, ItemStack it
200191
}
201192
IGrid grid = gridNode.getGrid();
202193
if (securityCheck(player, grid, SecurityPermissions.CRAFT)) {
203-
204194
RCCraftingGridCache cgc = grid.getCache(ICraftingGrid.class);
205195
IAEItemStack aeItem = AEItemStack.fromItemStack(item).setStackSize(1);
206196
boolean isCraftable = cgc.rc$getCraftableItems().containsKey(aeItem);
@@ -229,9 +219,6 @@ private void startCraft(EntityPlayerMP player, Container container, ItemStack it
229219
private void openWirelessCraft(ItemStack terminal, EntityPlayerMP player, ItemStack exItem, IGridNode gridNode, int i, boolean isBauble) {
230220
IGrid grid = gridNode.getGrid();
231221
if (securityCheck(player, grid, SecurityPermissions.CRAFT)) {
232-
IStorageGrid storageGrid = grid.getCache(IStorageGrid.class);
233-
var iItemStorageChannel = storageGrid.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
234-
235222
RCCraftingGridCache cgc = gridNode.getGrid().getCache(ICraftingGrid.class);
236223
IAEItemStack aeItem = AEItemStack.fromItemStack(exItem).setStackSize(1);
237224
boolean isCraftable = cgc.rc$getCraftableItems().containsKey(aeItem);

src/main/java/com/circulation/random_complement/common/network/WirelessPickBlock.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,9 @@ private boolean work(ItemStack item, EntityPlayerMP player, ItemStack exItem, in
138138
if (gridNode == null) return false;
139139
IGrid grid = gridNode.getGrid();
140140
if (securityCheck(player, grid, SecurityPermissions.EXTRACT)) {
141-
IStorageGrid storageGrid = grid.getCache(IStorageGrid.class);
142-
var iItemStorageChannel = storageGrid.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
143-
var aeItem = iItemStorageChannel.extractItems(AEItemStack.fromItemStack(exItem).setStackSize(exItem.getCount()), Actionable.SIMULATE, new PlayerSource(player, obj));
144-
if (aeItem != null && aeItem.getStackSize() > 0) {
145-
var aeitem = iItemStorageChannel.extractItems(AEItemStack.fromItemStack(exItem).setStackSize(aeItem.getStackSize()), Actionable.MODULATE, new PlayerSource(player, obj));
146-
141+
var items = grid.<IStorageGrid>getCache(IStorageGrid.class).getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
142+
var aeitem = items.extractItems(AEItemStack.fromItemStack(exItem).setStackSize(exItem.getCount()), Actionable.MODULATE, new PlayerSource(player, obj));
143+
if (aeitem != null) {
147144
player.inventory.setInventorySlotContents(slot, aeitem.setStackSize(aeitem.getStackSize() + handItemConnt).createItemStack());
148145
return true;
149146
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.circulation.random_complement.common.util;
2+
3+
import appeng.tile.inventory.AppEngInternalInventory;
4+
import appeng.util.inv.IAEAppEngInventory;
5+
6+
public class AppEngInternalFixedCapacityInventory extends AppEngInternalInventory {
7+
8+
public AppEngInternalFixedCapacityInventory(IAEAppEngInventory inventory, int size) {
9+
super(inventory, size);
10+
}
11+
12+
@Override
13+
public void setSize(int size) {
14+
}
15+
16+
}

src/main/java/com/circulation/random_complement/mixin/ae2/jei/MixinRecipesGui.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private void updateLayout(CallbackInfo ci) {
6565
}
6666
}
6767

68-
@Inject(method = "drawScreen", at = @At(value = "INVOKE", target = "Lmezz/jei/gui/recipes/RecipeGuiTabs;draw(Lnet/minecraft/client/Minecraft;II)V", shift = At.Shift.AFTER))
68+
@Inject(method = "drawScreen", at = @At(value = "INVOKE", target = "Lmezz/jei/gui/recipes/RecipeGuiTabs;draw(Lnet/minecraft/client/Minecraft;II)V", shift = At.Shift.AFTER, remap = false), remap = true)
6969
public void drawSlot(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) {
7070
if (r$isCraftablesGui) {
7171
MEHandler.drawXYPluses(r$slots);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.circulation.random_complement.mixin.ae2.new_patten_gui;
2+
3+
import appeng.container.implementations.ContainerWirelessCraftingTerminal;
4+
import appeng.tile.inventory.AppEngInternalInventory;
5+
import appeng.util.inv.IAEAppEngInventory;
6+
import com.circulation.random_complement.common.util.AppEngInternalFixedCapacityInventory;
7+
import org.spongepowered.asm.mixin.Mixin;
8+
import org.spongepowered.asm.mixin.injection.At;
9+
import org.spongepowered.asm.mixin.injection.Redirect;
10+
11+
@Mixin(value = ContainerWirelessCraftingTerminal.class, remap = false)
12+
public abstract class MixinContainerWirelessCraftingTerminal implements IAEAppEngInventory {
13+
14+
@Redirect(method = "loadFromNBT", at = @At(value = "NEW", target = "(Lappeng/util/inv/IAEAppEngInventory;I)Lappeng/tile/inventory/AppEngInternalInventory;"))
15+
protected AppEngInternalInventory loadFromNBT(IAEAppEngInventory inventory, int size) {
16+
return new AppEngInternalFixedCapacityInventory(this, 9);
17+
}
18+
}

src/main/java/com/circulation/random_complement/mixin/ae2/new_patten_gui/MixinContainerWirelessPatternTerminal.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import appeng.util.inv.IAEAppEngInventory;
1111
import com.circulation.random_complement.client.RCSlotFakeCraftingMatrix;
1212
import com.circulation.random_complement.client.RCSlotPatternOutputs;
13+
import com.circulation.random_complement.common.util.AppEngInternalFixedCapacityInventory;
1314
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
1415
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
1516
import net.minecraft.entity.player.InventoryPlayer;
@@ -31,20 +32,12 @@ public MixinContainerWirelessPatternTerminal(InventoryPlayer ip, ITerminalHost m
3132

3233
@Redirect(method = "<init>", at = @At(value = "NEW", target = "(Lappeng/util/inv/IAEAppEngInventory;I)Lappeng/tile/inventory/AppEngInternalInventory;", ordinal = 0, remap = false))
3334
public AppEngInternalInventory newCrafting(IAEAppEngInventory inventory, int size) {
34-
return new AppEngInternalInventory(inventory, 81) {
35-
@Override
36-
public void setSize(int size) {
37-
}
38-
};
35+
return new AppEngInternalFixedCapacityInventory(inventory, 81);
3936
}
4037

4138
@Redirect(method = "<init>", at = @At(value = "NEW", target = "(Lappeng/util/inv/IAEAppEngInventory;I)Lappeng/tile/inventory/AppEngInternalInventory;", ordinal = 1, remap = false))
4239
public AppEngInternalInventory newOutput(IAEAppEngInventory inventory, int size) {
43-
return new AppEngInternalInventory(inventory, 27) {
44-
@Override
45-
public void setSize(int size) {
46-
}
47-
};
40+
return new AppEngInternalFixedCapacityInventory(inventory, 27);
4841
}
4942

5043
@WrapOperation(method = "<init>", at = @At(value = "INVOKE", target = "Lappeng/container/implementations/ContainerWirelessPatternTerminal;addSlotToContainer(Lnet/minecraft/inventory/Slot;)Lnet/minecraft/inventory/Slot;"))

src/main/java/com/circulation/random_complement/mixin/ae2/new_patten_gui/MixinPartPatternTerminal.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import appeng.parts.reporting.PartPatternTerminal;
44
import appeng.tile.inventory.AppEngInternalInventory;
55
import appeng.util.inv.IAEAppEngInventory;
6+
import com.circulation.random_complement.common.util.AppEngInternalFixedCapacityInventory;
67
import org.spongepowered.asm.mixin.Mixin;
78
import org.spongepowered.asm.mixin.injection.At;
89
import org.spongepowered.asm.mixin.injection.Redirect;
@@ -12,19 +13,11 @@ public class MixinPartPatternTerminal {
1213

1314
@Redirect(method = "<init>", at = @At(value = "NEW", target = "(Lappeng/util/inv/IAEAppEngInventory;I)Lappeng/tile/inventory/AppEngInternalInventory;", ordinal = 0))
1415
public AppEngInternalInventory newCrafting(IAEAppEngInventory inventory, int size) {
15-
return new AppEngInternalInventory(inventory, 81) {
16-
@Override
17-
public void setSize(int size) {
18-
}
19-
};
16+
return new AppEngInternalFixedCapacityInventory(inventory, 81);
2017
}
2118

2219
@Redirect(method = "<init>", at = @At(value = "NEW", target = "(Lappeng/util/inv/IAEAppEngInventory;I)Lappeng/tile/inventory/AppEngInternalInventory;", ordinal = 1))
2320
public AppEngInternalInventory newOutput(IAEAppEngInventory inventory, int size) {
24-
return new AppEngInternalInventory(inventory, 27) {
25-
@Override
26-
public void setSize(int size) {
27-
}
28-
};
21+
return new AppEngInternalFixedCapacityInventory(inventory, 27);
2922
}
3023
}

src/main/resources/mixins.random_complement.ae2.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"container.MixinContainerMEMonitorable",
3232
"container.MixinContainerPatternEncoder",
3333
"container.MixinContainerPatternTerm",
34+
"new_patten_gui.MixinContainerWirelessCraftingTerminal",
3435
"container.MixinContainerWirelessPatternTerminal",
3536
"me.storage.MixinCreativeCellInventory",
3637
"part.MixinAbstractPartEncoder",

0 commit comments

Comments
 (0)