Skip to content

Commit 0461457

Browse files
authored
Merge pull request #186 from Circulate233/test
feat:输入组设计
2 parents 90a46bd + 7adce11 commit 0461457

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1240
-369
lines changed

src/main/java/github/kasuminova/mmce/client/gui/GuiMEItemInputBus.java

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import net.minecraft.util.ResourceLocation;
2929
import net.minecraft.util.text.TextFormatting;
3030
import net.minecraftforge.fml.client.config.GuiUtils;
31-
import org.lwjgl.input.Keyboard;
3231
import org.lwjgl.input.Mouse;
3332

3433
import javax.annotation.Nonnull;
@@ -55,30 +54,33 @@ private static List<String> getAddActionInfo() {
5554
tooltip.add(TextFormatting.GRAY + I18n.format("gui.meiteminputbus.inv_action"));
5655
// Quite a sight, isn't it?
5756
// It was truly a beautiful sight...
57+
final boolean shift = isShiftKeyDown();
58+
final boolean ctrl = isCtrlKeyDown();
5859

59-
if (isShiftDown() && isControlDown()) {
60+
if (shift && ctrl) {
6061
String keyCombination =
6162
"SHIFT + CTRL";
6263
tooltip.add(TextFormatting.GRAY + I18n.format("gui.meiteminputbus.inv_action.multiply",
63-
keyCombination));
64+
keyCombination));
6465
tooltip.add(TextFormatting.GRAY + I18n.format("gui.meiteminputbus.inv_action.divide",
65-
keyCombination));
66+
keyCombination));
6667
} else {
67-
tooltip.add(TextFormatting.GRAY + I18n.format("gui.meiteminputbus.inv_action.increase.normal"));
68-
tooltip.add(TextFormatting.GRAY + I18n.format("gui.meiteminputbus.inv_action.decrease.normal"));
68+
final int i = ctrl ? 100 : shift ? 10 : 1;
69+
final String keyCombination = ctrl ? "CTRL" : shift ? "SHIFT" : null;
70+
if (keyCombination != null) {
71+
tooltip.add(TextFormatting.GRAY + I18n.format("gui.meiteminputbus.inv_action.increase",
72+
keyCombination, i));
73+
tooltip.add(TextFormatting.GRAY + I18n.format("gui.meiteminputbus.inv_action.decrease",
74+
keyCombination, i));
75+
} else {
76+
tooltip.add(TextFormatting.GRAY + I18n.format("gui.meiteminputbus.inv_action.increase.normal"));
77+
tooltip.add(TextFormatting.GRAY + I18n.format("gui.meiteminputbus.inv_action.decrease.normal"));
78+
}
6979
}
7080

7181
return tooltip;
7282
}
7383

74-
private static boolean isControlDown() {
75-
return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
76-
}
77-
78-
private static boolean isShiftDown() {
79-
return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
80-
}
81-
8284
@Override
8385
public void handleMouseInput() throws IOException {
8486
super.handleMouseInput();
@@ -124,7 +126,10 @@ private boolean isScrollingUp(int wheel) {
124126
}
125127

126128
private int getUpdatedCount(boolean isScrollingUp, int currentAmount) {
127-
if (isShiftDown() && isControlDown()) {
129+
final boolean shift = isShiftKeyDown();
130+
final boolean ctrl = isCtrlKeyDown();
131+
132+
if (shift && ctrl) {
128133
if (isScrollingUp) {
129134
// Overflow protection
130135
if (currentAmount <= Integer.MAX_VALUE / 2) {
@@ -135,14 +140,15 @@ private int getUpdatedCount(boolean isScrollingUp, int currentAmount) {
135140
return Math.max(1, currentAmount / 2);
136141
}
137142
} else {
143+
int i = ctrl ? 100 : shift ? 10 : 1;
138144
if (isScrollingUp) {
139145
// Overflow protection
140146
if (currentAmount < Integer.MAX_VALUE) {
141-
return 1 + currentAmount;
147+
return i + currentAmount;
142148
}
143149
return Integer.MAX_VALUE;
144150
} else {
145-
return Math.max(1, currentAmount - 1);
151+
return Math.max(1, currentAmount - i);
146152
}
147153
}
148154
}

src/main/java/github/kasuminova/mmce/client/gui/GuiMEPatternProvider.java

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
import github.kasuminova.mmce.common.util.InfItemFluidHandler;
1919
import hellfirepvp.modularmachinery.ModularMachinery;
2020
import hellfirepvp.modularmachinery.common.base.Mods;
21+
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
2122
import net.minecraft.client.renderer.GlStateManager;
2223
import net.minecraft.client.resources.I18n;
2324
import net.minecraft.entity.player.EntityPlayer;
2425
import net.minecraft.item.ItemStack;
26+
import net.minecraft.nbt.NBTTagCompound;
2527
import net.minecraft.util.ResourceLocation;
2628
import net.minecraftforge.fluids.FluidStack;
2729
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
@@ -38,7 +40,7 @@ public class GuiMEPatternProvider extends AEBaseGuiContainerDynamic {
3840

3941
protected final MEPatternProvider owner;
4042

41-
protected final PatternProviderIngredientList stackList = new PatternProviderIngredientList();
43+
protected final PatternProviderIngredientList stackList = new PatternProviderIngredientList();
4244
protected final ButtonElements<MEPatternProvider.WorkModeSetting> workModeSetting = new ButtonElements<>();
4345

4446
public GuiMEPatternProvider(final MEPatternProvider owner, final EntityPlayer player) {
@@ -108,6 +110,7 @@ public GuiMEPatternProvider(final MEPatternProvider owner, final EntityPlayer pl
108110
.addElement(MEPatternProvider.WorkModeSetting.CRAFTING_LOCK_MODE, TextureProperties.of(140 + 18 + 18, 196, 16, 16))
109111
// ButtonTexture 0
110112
.addElement(MEPatternProvider.WorkModeSetting.ENHANCED_BLOCKING_MODE, TextureProperties.of(140 - 18, 196, 16, 16))
113+
.addElement(MEPatternProvider.WorkModeSetting.ISOLATION_INPUT, TextureProperties.of(140 - 18 - 18, 196, 16, 16))
111114
// ButtonTexture 5
112115
.setMouseDownTexture(140 + 18 + 18 + 18 + 18 + 18, 196)
113116
// ButtonTexture 5
@@ -127,6 +130,8 @@ public GuiMEPatternProvider(final MEPatternProvider owner, final EntityPlayer pl
127130
+ I18n.format("gui.mepatternprovider.crafting_lock_mode.desc"));
128131
tooltips.add((current == MEPatternProvider.WorkModeSetting.ENHANCED_BLOCKING_MODE ? I18n.format("gui.mepatternprovider.current") : "")
129132
+ I18n.format("gui.mepatternprovider.enhanced_blocking_mode.desc"));
133+
tooltips.add((current == MEPatternProvider.WorkModeSetting.ISOLATION_INPUT ? I18n.format("gui.mepatternprovider.current") : "")
134+
+ I18n.format("gui.mepatternprovider.isolation_input.desc"));
130135
return tooltips;
131136
})
132137
.setOnClickedListener((btn) -> {
@@ -143,6 +148,8 @@ public GuiMEPatternProvider(final MEPatternProvider owner, final EntityPlayer pl
143148
ModularMachinery.NET_CHANNEL.sendToServer(new PktMEPatternProviderAction(PktMEPatternProviderAction.Action.ENABLE_CRAFTING_LOCK_MODE));
144149
case ENHANCED_BLOCKING_MODE ->
145150
ModularMachinery.NET_CHANNEL.sendToServer(new PktMEPatternProviderAction(PktMEPatternProviderAction.Action.ENABLE_ENHANCED_BLOCKING_MODE));
151+
case ISOLATION_INPUT ->
152+
ModularMachinery.NET_CHANNEL.sendToServer(new PktMEPatternProviderAction(PktMEPatternProviderAction.Action.ENABLE_ENHANCED_ISOLATION_INPUT));
146153
}
147154
})
148155
.setWidthHeight(16, 16);
@@ -222,12 +229,25 @@ public MEPatternProvider getOwner() {
222229

223230
public void updateGUIState() {
224231
InfItemFluidHandler infHandler = owner.getInfHandler();
225-
stackList.setStackList(infHandler.getItemStackList(), infHandler.getFluidStackList(), infHandler.getGasStackList());
232+
233+
List<ItemStack> itemStacks = new ObjectArrayList<>(infHandler.getItemStackList());
234+
List<FluidStack> fluids = new ObjectArrayList<>(infHandler.getFluidStackList());
235+
List<Object> gass = new ObjectArrayList<>(infHandler.getGasStackList());
236+
237+
for (var component : owner.getCombinationComponents()) {
238+
var h = (InfItemFluidHandler) component.getContainerProvider();
239+
itemStacks.addAll(h.getItemStackList());
240+
fluids.addAll(h.getFluidStackList());
241+
gass.addAll(h.getGasStackList());
242+
}
243+
244+
stackList.setStackList(itemStacks, fluids, gass);
226245
workModeSetting.setCurrentSelection(owner.getWorkMode());
227246
}
228247

229-
public void setStackList(final List<ItemStack> itemStackList, final List<FluidStack> fluidStackList, final List<?> gasStackList) {
230-
stackList.setStackList(itemStackList, fluidStackList, gasStackList);
248+
public void setStackList(final NBTTagCompound tagCompound) {
249+
owner.readProviderHandlerNBT(tagCompound, true);
250+
updateGUIState();
231251
}
232252

233-
}
253+
}

src/main/java/github/kasuminova/mmce/common/block/appeng/BlockMEFluidInputBus.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@
55
import hellfirepvp.modularmachinery.ModularMachinery;
66
import hellfirepvp.modularmachinery.common.CommonProxy;
77
import net.minecraft.block.state.IBlockState;
8+
import net.minecraft.client.resources.I18n;
9+
import net.minecraft.client.util.ITooltipFlag;
810
import net.minecraft.entity.player.EntityPlayer;
911
import net.minecraft.item.ItemStack;
1012
import net.minecraft.tileentity.TileEntity;
1113
import net.minecraft.util.EnumFacing;
1214
import net.minecraft.util.EnumHand;
1315
import net.minecraft.util.math.BlockPos;
1416
import net.minecraft.world.World;
17+
import net.minecraftforge.fml.relauncher.Side;
18+
import net.minecraftforge.fml.relauncher.SideOnly;
19+
import org.jetbrains.annotations.NotNull;
1520

1621
import javax.annotation.Nonnull;
1722
import javax.annotation.Nullable;
23+
import java.util.List;
1824

1925
public class BlockMEFluidInputBus extends BlockMEFluidBus {
2026

@@ -42,4 +48,12 @@ public boolean onBlockActivated(@Nonnull final World worldIn, @Nonnull final Blo
4248
public TileEntity createTileEntity(final World world, final IBlockState state) {
4349
return new MEFluidInputBus();
4450
}
51+
52+
@Override
53+
@SideOnly(Side.CLIENT)
54+
public void addInformation(@NotNull ItemStack stack, @Nullable World worldIn, @NotNull List<String> tooltip, @NotNull ITooltipFlag flagIn) {
55+
super.addInformation(stack, worldIn, tooltip, flagIn);
56+
tooltip.add(I18n.format("tooltip.groupinput.block"));
57+
}
58+
4559
}

src/main/java/github/kasuminova/mmce/common/block/appeng/BlockMEGasInputBus.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@
55
import hellfirepvp.modularmachinery.ModularMachinery;
66
import hellfirepvp.modularmachinery.common.CommonProxy;
77
import net.minecraft.block.state.IBlockState;
8+
import net.minecraft.client.resources.I18n;
9+
import net.minecraft.client.util.ITooltipFlag;
810
import net.minecraft.entity.player.EntityPlayer;
911
import net.minecraft.item.ItemStack;
1012
import net.minecraft.tileentity.TileEntity;
1113
import net.minecraft.util.EnumFacing;
1214
import net.minecraft.util.EnumHand;
1315
import net.minecraft.util.math.BlockPos;
1416
import net.minecraft.world.World;
17+
import net.minecraftforge.fml.relauncher.Side;
18+
import net.minecraftforge.fml.relauncher.SideOnly;
19+
import org.jetbrains.annotations.NotNull;
1520

1621
import javax.annotation.Nonnull;
1722
import javax.annotation.Nullable;
23+
import java.util.List;
1824

1925
public class BlockMEGasInputBus extends BlockMEGasBus {
2026

@@ -43,4 +49,11 @@ public TileEntity createTileEntity(final World world, final IBlockState state) {
4349
return new MEGasInputBus();
4450
}
4551

52+
@Override
53+
@SideOnly(Side.CLIENT)
54+
public void addInformation(@NotNull ItemStack stack, @Nullable World worldIn, @NotNull List<String> tooltip, @NotNull ITooltipFlag flagIn) {
55+
super.addInformation(stack, worldIn, tooltip, flagIn);
56+
tooltip.add(I18n.format("tooltip.groupinput.block"));
57+
}
58+
4659
}

src/main/java/github/kasuminova/mmce/common/block/appeng/BlockMEItemInputBus.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import hellfirepvp.modularmachinery.common.lib.ItemsMM;
88
import hellfirepvp.modularmachinery.common.util.IOInventory;
99
import net.minecraft.block.state.IBlockState;
10+
import net.minecraft.client.resources.I18n;
11+
import net.minecraft.client.util.ITooltipFlag;
1012
import net.minecraft.entity.EntityLivingBase;
1113
import net.minecraft.entity.player.EntityPlayer;
1214
import net.minecraft.item.ItemStack;
@@ -18,9 +20,13 @@
1820
import net.minecraft.util.math.BlockPos;
1921
import net.minecraft.world.IBlockAccess;
2022
import net.minecraft.world.World;
23+
import net.minecraftforge.fml.relauncher.Side;
24+
import net.minecraftforge.fml.relauncher.SideOnly;
25+
import org.jetbrains.annotations.NotNull;
2126

2227
import javax.annotation.Nonnull;
2328
import javax.annotation.Nullable;
29+
import java.util.List;
2430

2531
public class BlockMEItemInputBus extends BlockMEItemBus {
2632
@Override
@@ -118,4 +124,12 @@ public void onBlockPlacedBy(@Nonnull final World worldIn,
118124
bus.readConfigInventoryNBT(tag.getCompoundTag("configInventory"));
119125
}
120126
}
127+
128+
@Override
129+
@SideOnly(Side.CLIENT)
130+
public void addInformation(@NotNull ItemStack stack, @Nullable World worldIn, @NotNull List<String> tooltip, @NotNull ITooltipFlag flagIn) {
131+
super.addInformation(stack, worldIn, tooltip, flagIn);
132+
tooltip.add(I18n.format("tooltip.groupinput.block"));
133+
}
134+
121135
}

src/main/java/github/kasuminova/mmce/common/block/appeng/BlockMEPatternMirrorImage.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
import net.minecraft.block.SoundType;
99
import net.minecraft.block.material.Material;
1010
import net.minecraft.block.state.IBlockState;
11+
import net.minecraft.client.resources.I18n;
12+
import net.minecraft.client.util.ITooltipFlag;
1113
import net.minecraft.entity.player.EntityPlayer;
14+
import net.minecraft.item.ItemStack;
1215
import net.minecraft.nbt.NBTTagCompound;
1316
import net.minecraft.tileentity.TileEntity;
1417
import net.minecraft.util.BlockRenderLayer;
@@ -20,9 +23,11 @@
2023
import net.minecraft.world.World;
2124
import net.minecraftforge.fml.relauncher.Side;
2225
import net.minecraftforge.fml.relauncher.SideOnly;
26+
import org.jetbrains.annotations.NotNull;
2327

2428
import javax.annotation.Nonnull;
2529
import javax.annotation.Nullable;
30+
import java.util.List;
2631

2732
public class BlockMEPatternMirrorImage extends BlockMachineComponent {
2833

@@ -98,4 +103,11 @@ public BlockRenderLayer getRenderLayer() {
98103
public EnumBlockRenderType getRenderType(@Nonnull IBlockState state) {
99104
return EnumBlockRenderType.MODEL;
100105
}
106+
107+
@Override
108+
@SideOnly(Side.CLIENT)
109+
public void addInformation(@NotNull ItemStack stack, @Nullable World worldIn, @NotNull List<String> tooltip, @NotNull ITooltipFlag flagIn) {
110+
super.addInformation(stack, worldIn, tooltip, flagIn);
111+
tooltip.add(I18n.format("tooltip.mepatternmirrorimage"));
112+
}
101113
}

src/main/java/github/kasuminova/mmce/common/block/appeng/BlockMEPatternProvider.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import hellfirepvp.modularmachinery.common.CommonProxy;
1111
import hellfirepvp.modularmachinery.common.lib.ItemsMM;
1212
import net.minecraft.block.state.IBlockState;
13+
import net.minecraft.client.resources.I18n;
14+
import net.minecraft.client.util.ITooltipFlag;
1315
import net.minecraft.entity.EntityLivingBase;
1416
import net.minecraft.entity.player.EntityPlayer;
1517
import net.minecraft.item.ItemStack;
@@ -21,9 +23,13 @@
2123
import net.minecraft.util.text.TextComponentTranslation;
2224
import net.minecraft.world.World;
2325
import net.minecraftforge.event.ForgeEventFactory;
26+
import net.minecraftforge.fml.relauncher.Side;
27+
import net.minecraftforge.fml.relauncher.SideOnly;
28+
import org.jetbrains.annotations.NotNull;
2429

2530
import javax.annotation.Nonnull;
2631
import javax.annotation.Nullable;
32+
import java.util.List;
2733

2834
public class BlockMEPatternProvider extends BlockMEMachineComponent {
2935

@@ -120,4 +126,12 @@ public void onBlockPlacedBy(@Nonnull final World worldIn,
120126
provider.readProviderNBT(tag.getCompoundTag("patternProvider"));
121127
}
122128
}
123-
}
129+
130+
@Override
131+
@SideOnly(Side.CLIENT)
132+
public void addInformation(@NotNull ItemStack stack, @Nullable World worldIn, @NotNull List<String> tooltip, @NotNull ITooltipFlag flagIn) {
133+
super.addInformation(stack, worldIn, tooltip, flagIn);
134+
tooltip.add(I18n.format("tooltip.groupinput.block"));
135+
}
136+
137+
}

src/main/java/github/kasuminova/mmce/common/container/ContainerMEPatternProvider.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
import appeng.helpers.InventoryAction;
1111
import appeng.tile.inventory.AppEngInternalInventory;
1212
import appeng.util.Platform;
13+
import github.kasuminova.mmce.common.network.PktMEPatternProviderHandlerItems;
1314
import github.kasuminova.mmce.common.tile.MEPatternProvider;
1415
import github.kasuminova.mmce.common.util.AEFluidInventoryUpgradeable;
16+
import hellfirepvp.modularmachinery.ModularMachinery;
1517
import net.minecraft.entity.player.EntityPlayer;
1618
import net.minecraft.entity.player.EntityPlayerMP;
1719
import net.minecraft.inventory.IContainerListener;
@@ -32,6 +34,11 @@ public class ContainerMEPatternProvider extends AEBaseContainer implements IFlui
3234
public ContainerMEPatternProvider(final MEPatternProvider owner, final EntityPlayer player) {
3335
super(player.inventory, owner);
3436
this.owner = owner;
37+
38+
if (player instanceof EntityPlayerMP p) {
39+
ModularMachinery.NET_CHANNEL.sendTo(new PktMEPatternProviderHandlerItems(owner), p);
40+
}
41+
3542
this.tankSync = new FluidSyncHelper(owner.getSubFluidHandler(), 0);
3643

3744
this.bindPlayerInventory(getInventoryPlayer(), 0, 114);

0 commit comments

Comments
 (0)