Compare commits

...

61 Commits

Author SHA1 Message Date
NotMyWing 26bb5986c6 Temporary OreDict bus serialization fix
Fixes #542
2025-03-25 16:57:55 +11:00
NotMyWing e175bccace Fix Color Applicator model
Closes #518
2025-03-18 20:02:51 +11:00
NotMyWing 127872b310 Fix Wireless Interface Terminal hotkey
Closes #537
2025-03-18 18:37:00 +11:00
NotMyWing b030cb9f00 Fix slot OOB indexing 2025-03-18 18:30:44 +11:00
NotMyWing f1e5a33a6e Fix ME Portable Cell voiding/dupes & disabled slot idiocy
Fixes #383, fixes #299
2025-03-18 18:22:03 +11:00
NotMyWing f42a5778d2 Display lock reason only when using the mode 2025-03-14 15:48:23 +11:00
Neeve d131e12498 Generalize ME Interface blocking logic (#531) 2025-03-14 15:33:58 +11:00
Neeve f1d9fda6ce Split injecting into CraftingGridCache into separate pass (#533) 2025-03-14 14:17:29 +11:00
zeng-git 2141ffe7f0 Update build actions (#475) 2025-03-13 17:22:09 +11:00
NotMyWing 7baf538a76 Fix stack sizes underflowing when shift-clicking into oversized slots
Fixes #519
2025-03-11 19:11:08 +11:00
zeng-git e833aa1e61 Further crafting lock improvements (#507) 2025-03-10 18:40:11 +11:00
Ghzdude 202259ef2a Make FluidHandlerAdapter Cache properly use Tank Properties (#483) 2025-03-10 18:36:31 +11:00
Yang Xizhi fabc9bd82c Fix ME Interface deadlocking (#478) 2025-03-10 18:35:31 +11:00
zeng-git 9c021867f0 Add Wireless Interface Terminal (#500) 2025-03-10 18:33:10 +11:00
Forever-178 9749faa692 Fix ME Interface Terminal localization (#522) 2025-03-10 17:06:22 +11:00
zeng-git 37e7c02c3c Fix Annihilation Plane sometimes not accepting drops (#524) 2025-03-10 16:59:04 +11:00
zeng-git 7f2318f89c Add Annihilation Plane enchantment support, deprecate Identity (#510) 2024-11-29 16:06:55 +11:00
zeng-git 925cf092be Backport colored tooltips from modern AE2 (#503) 2024-11-29 14:39:03 +11:00
RuiXuqi 7c6ceefd94 Change lock/unlock icon to fit the old style (#466) 2024-06-21 13:40:21 +11:00
NotMyWing c7ec7e0890 Hide all facades from JEI except for the first found
Closes #457
2024-06-18 20:14:33 +11:00
Yang Xizhi 0a7799a664 Allow looking up recipes in JEI with non-item slots (#451) 2024-06-18 19:14:20 +11:00
jchung01 1316f035cd Fix some MouseTweaks interactions (#455) 2024-06-18 19:12:03 +11:00
brachy84 10a0453bea Fix nullable Inscriber inputs (#464) 2024-06-18 19:11:44 +11:00
Yang Xizhi efe726ecdd Fix ME Interfaces not pulling items from storage (#454) 2024-06-13 13:57:37 +11:00
NotMyWing 9a255432f5 Publish to the GTCEu Maven 2024-06-10 18:16:12 +11:00
NotMyWing eba3e2456a Add custom TunnelType registration API 2024-06-10 18:12:02 +11:00
NotMyWing d40b9831c1 Make craftingList a hash set in DualityInterface
Improves pattern lookup times, even though I'm not sure why this check even exist
2024-06-10 15:40:28 +11:00
Yang Xizhi 6632344f87 Make ME Interfaces insert items/fluids directly into storage if possible (#448) 2024-06-09 15:53:20 +11:00
NotMyWing 724f3baf4c Improve AESharedItemStack caching
Reduces the item stack churn a little, improving overall server time taken from 6% to 2% on average
2024-06-09 13:33:33 +11:00
NotMyWing f7562db2e9 Memoize isModLoaded lookups 2024-06-07 17:09:18 +11:00
NotMyWing 68de8fa1a2 Make OreDict Storage Buses upgradeable
Closes #403
2024-05-28 17:51:07 +11:00
NotMyWing 6864f7ae07 Fix ME Interface GuiSync overlap 2024-05-28 17:15:25 +11:00
NotMyWing 7fa7b726f2 Disable extracting invisible items from Storage Buses altogether
Reverts d82cdabc6d, closes #408
Allows Cells to report/extract lingering unpartitioned items
2024-05-27 20:41:15 +11:00
zeng-git c814fe591d Update zh_cn.lang (#443) 2024-05-27 13:31:22 +11:00
NotMyWing cd0a5d631b Temporarily prevent FakePlayers from using wrenches
Closes #432
2024-05-27 13:28:48 +11:00
NotMyWing d82cdabc6d Fix crafting plan reporting invisible extractable items as available
Closes #438
2024-05-25 00:37:46 +11:00
NotMyWing 2e976a609f Make Storage Cell tooltips configurable
Closes #427
2024-05-24 23:54:05 +11:00
Zengyj a13f9955f2 Backport lock crafting function for ME Interface (#423) 2024-05-24 23:39:03 +11:00
Michael Trittin a65b5015e6 Allow View Cells to be shift-clicked into place (#388) 2024-05-24 23:13:15 +11:00
Yang Xizhi 07eb6c1238 Allow third-party addons to register custom GUIs via GuiBridge (#402) 2024-05-24 23:05:29 +11:00
Domi 529ea5e239 Small UI fixes and improvements (#398) 2024-05-24 23:03:12 +11:00
NotMyWing a9b7faa98b Fix OreDict filters not testing items without entries 2024-05-24 22:52:50 +11:00
Serenibyss 78c7235bea Improve ME Interface Terminal UI (#368)
Co-authored-by: NotMyWing <winwyv@gmail.com>
2024-05-24 22:15:15 +11:00
zeng-git 59edb38208 Add ore dictionary support for Inscriber recipes in JEI (#430) 2024-05-24 21:51:37 +11:00
NotMyWing 08a7aff600 Fix ME Export Buses oversending items
As a side effect, fixes them not sending anything at all with too many Acceleration Cards
Closes #441
2024-05-24 20:25:10 +11:00
NotMyWing 9f19e05592 Fix non-deterministic ME Interface behavior
As a side effect, allows ME Interfaces to fully utilize allowed operations instead of doing at most 1 push per cycle
Closes #440
2024-05-24 19:05:06 +11:00
zeng-git 5f20e3346c Add automatic artifact builds on push (#426) 2024-05-17 22:37:54 +11:00
NotMyWing fd188dc96c Fix stopping already stopped Stopwatches in CraftingJob
Resolves #417
Co-authored-by: frankdai320 <frankdai320@gmail.com>
2024-05-17 19:31:31 +11:00
NotMyWing e471293e60 Fix NPE when suffocating in ME Drives
And hopefully all other cases related to missing slot states
Closes #420
2024-05-17 19:08:18 +11:00
NotMyWing f28a3574df Fix rogue off-by-one OreHelper error breaking nested parens 2024-05-17 15:00:36 +11:00
zeng-git b2b21eae41 Add missing Fluid Terminal localization (#428) 2024-05-16 20:07:12 +11:00
Георгий Торопов e8a186df60 Fix missing letters in ru_ru.lang (#397) 2024-05-12 12:41:49 +11:00
Ghzdude 6425ef6ecd Fix NPE when posting changes for storage busses (#405) 2024-02-24 10:25:51 +08:00
Yang Xizhi 7ebb2a0fbb allow custom slot jei check and fix fluid color in cell workbanch (#401) 2024-02-18 23:06:07 -06:00
Neeve 20a1fec6fb Recache OreDict Buses on RegEx changes & adjust visibility logic (#395) 2024-02-05 13:05:31 +11:00
Yang Xizhi 0fffc829ab Fix invalid pattern outputs throwing NPE in crafting grid (#393) 2024-02-01 19:14:33 +11:00
NotMyWing 88635d9a8d Do not check white-/blacklist on extract
Slightly rollbacks #384, since extractables are filtered in getAvailableItems
Allows extracting inaccessible items from cells and overriding SB behavior via reporting non-extractables
2024-02-01 18:33:13 +11:00
Neeve 0fd0ed1b1c Fix Fluid Cells having no upgrades (#392) 2024-01-31 19:37:05 +11:00
Neeve 87f884228e Fix ME Storage Buses reporting contents regardless of settings (#384) 2024-01-30 16:10:52 +11:00
Serenibyss 3495d3dfd4 Use LoadingCache instead of HashMap for CableBusBakedModel (#385) 2024-01-30 14:19:50 +11:00
ZHAY10086 0acb03b83d Add zh_cn.lang entries for Sticky Card (#381) 2024-01-21 13:55:57 +11:00
139 changed files with 3581 additions and 995 deletions
+23
View File
@@ -0,0 +1,23 @@
name: Build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up OpenJDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt' # You can choose other OpenJDK distributions.
- name: Update Build Script (Before Build)
run: ./gradlew updateBuildScript
- name: Build with Gradle
run: ./gradlew build
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: AE2-UEL
path: build/libs/*.jar # Make sure this path matches the location of your build artifacts
+14
View File
@@ -52,6 +52,20 @@ jobs:
generate_release_notes: true
fail_on_unmatched_files: true
- name: Publish to Maven
uses: gradle/gradle-build-action@v2
env:
MAVEN_USER: "${{secrets.MAVEN_USER}}"
MAVEN_PASSWORD: "${{secrets.MAVEN_PASSWORD}}"
with:
arguments: 'publish --daemon'
generate-job-summary: false
gradle-home-cache-includes: |
caches
jdks
notifications
wrapper
- name: Publish to Curseforge
uses: gradle/gradle-build-action@v2
env:
+1 -1
View File
@@ -153,7 +153,7 @@ noPublishedSources = false
# For maven credentials:
# Username is set with the 'MAVEN_USER' environment variable, default to "NONE"
# Password is set with the 'MAVEN_PASSWORD' environment variable, default to "NONE"
customMavenPublishUrl =
customMavenPublishUrl = https://maven.gtceu.com
# The group for maven artifacts. Defaults to the 'project.modGroup' until the last '.' (if any).
# So 'mymod' becomes 'mymod' and 'com.myname.mymodid' 'becomes com.myname'
@@ -38,8 +38,11 @@ public enum ActionItems
DIVIDE_BY_THREE,
DECREASE_BY_ONE,
MAX_COUNT,
FREE_MOLECULAR_SLOT_SHORTCUT,
MOLECULAR_ASSEMBLERS_ON,
MOLECULAR_ASSEMBLERS_OFF,
TOGGLE_SHOW_FULL_INTERFACES_ON,
TOGGLE_SHOW_FULL_INTERFACES_OFF,
TOGGLE_SHOW_ONLY_INVALID_PATTERNS_ON,
TOGGLE_SHOW_ONLY_INVALID_PATTERNS_OFF,
HIGHLIGHT_INTERFACE
}
}
@@ -0,0 +1,26 @@
package appeng.api.config;
public enum LockCraftingMode {
/**
* Crafting is never locked.
*/
NONE,
/**
* After pushing a pattern to an adjacent machine, the interface will not accept further crafts until a
* redstone pulse is received.
*/
LOCK_UNTIL_PULSE,
/**
* Crafting is locked while the interface is receiving a redstone signal.
*/
LOCK_WHILE_HIGH,
/**
* Crafting is locked while the interface is not receiving a redstone signal.
*/
LOCK_WHILE_LOW,
/**
* After pushing a pattern to an adjacent machine, the interface will not accept further crafts until the
* primary pattern result is returned to the network through the interface.
*/
LOCK_UNTIL_RESULT
}
@@ -57,6 +57,8 @@ public enum Settings
IO_DIRECTION( EnumSet.of( RelativeDirection.LEFT, RelativeDirection.RIGHT ) ),
UNLOCK(EnumSet.allOf(LockCraftingMode.class)),
BLOCK( EnumSet.of( YesNo.YES, YesNo.NO ) ),
OPERATION_MODE( EnumSet.allOf( OperationMode.class ) ),
+61 -12
View File
@@ -24,16 +24,65 @@
package appeng.api.config;
public enum TunnelType
{
ME, // Network Tunnel
IC2_POWER, // EU Tunnel
FE_POWER, // Forge Energy tunnel
GTEU_POWER, // Forge Energy tunnel
REDSTONE, // Redstone Tunnel
FLUID, // Fluid Tunnel
ITEM, // Item Tunnel
LIGHT, // Light Tunnel
BUNDLED_REDSTONE, // Bundled Redstone Tunnel
COMPUTER_MESSAGE // Computer Message Tunnel
import appeng.api.AEApi;
import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IParts;
import appeng.api.parts.IPartItem;
import com.google.common.base.Preconditions;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.EnumHelper;
import javax.annotation.Nonnull;
import java.util.function.Function;
import java.util.function.Supplier;
public enum TunnelType {
ME(tryPartStack(IParts::p2PTunnelME)),
IC2_POWER(tryPartStack(IParts::p2PTunnelEU)),
FE_POWER(tryPartStack(IParts::p2PTunnelFE)),
GTEU_POWER(tryPartStack(IParts::p2PTunnelGTEU)),
REDSTONE(tryPartStack(IParts::p2PTunnelRedstone)),
FLUID(tryPartStack(IParts::p2PTunnelFE)),
ITEM(tryPartStack(IParts::p2PTunnelItems)),
LIGHT(tryPartStack(IParts::p2PTunnelLight));
private ItemStack partItemStack;
private Supplier<ItemStack> partItemStackSupplier;
@Deprecated
TunnelType() {
this.partItemStack = ItemStack.EMPTY;
this.partItemStackSupplier = null;
}
// Public facing.
TunnelType(ItemStack partItemStack) {
this.partItemStack = partItemStack;
this.partItemStackSupplier = null;
}
// Work around things instantiating this class too early.
TunnelType(Supplier<ItemStack> supplier) {
this.partItemStack = null;
this.partItemStackSupplier = supplier;
}
private static Supplier<ItemStack> tryPartStack(Function<IParts, IItemDefinition> supplier) {
return () -> supplier.apply(AEApi.instance().definitions().parts()).maybeStack(1).orElse(ItemStack.EMPTY);
}
public static TunnelType registerTunnelType(@Nonnull String name, @Nonnull ItemStack partItemStack) {
Preconditions.checkArgument(partItemStack.isEmpty() || partItemStack.getItem() instanceof IPartItem<?>,
"Part item must be an instance of IPartItem");
return EnumHelper.addEnum(TunnelType.class, name, new Class[]{ItemStack.class}, partItemStack);
}
public ItemStack getPartItemStack() {
if (this.partItemStackSupplier != null) {
this.partItemStack = this.partItemStackSupplier.get();
this.partItemStackSupplier = null;
}
return partItemStack;
}
}
@@ -67,6 +67,8 @@ public interface IItems {
IItemDefinition wirelessPatternTerminal();
IItemDefinition wirelessInterfaceTerminal();
IItemDefinition wirelessFluidTerminal();
IItemDefinition biometricCard();
@@ -19,12 +19,11 @@
package appeng.api.features;
import java.util.List;
import java.util.Optional;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import java.util.List;
import java.util.Optional;
/**
@@ -57,21 +56,35 @@ public interface IInscriberRecipe
@Nonnull
ItemStack getOutput();
@Nonnull
List<ItemStack> getTopInputs();
/**
* gets the top optional
*
* @return item which is used top
*/
@Deprecated
@Nonnull
Optional<ItemStack> getTopOptional();
default Optional<ItemStack> getTopOptional(){
return getTopInputs().isEmpty() ? Optional.empty() : Optional.of(getTopInputs().get(0));
}
@Nonnull
List<ItemStack> getBottomInputs();
/**
* gets the bottom optional
*
* @return item which is used bottom
*/
@Deprecated
@Nonnull
Optional<ItemStack> getBottomOptional();
default Optional<ItemStack> getBottomOptional() {
return getBottomInputs().isEmpty() ? Optional.empty() : Optional.of(getBottomInputs().get(0));
}
/**
* type of inscriber process
@@ -19,11 +19,11 @@
package appeng.api.features;
import java.util.Collection;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import java.util.Collection;
import java.util.Collections;
/**
@@ -66,7 +66,7 @@ public interface IInscriberRecipeBuilder
* @return currently used builder
*/
@Nonnull
IInscriberRecipeBuilder withTopOptional( @Nonnull ItemStack topOptional );
IInscriberRecipeBuilder withTopOptional(@Nonnull Collection<ItemStack> topOptional );
/**
* Creates an inscriber recipe with bot.
@@ -77,7 +77,7 @@ public interface IInscriberRecipeBuilder
* @return currently used builder
*/
@Nonnull
IInscriberRecipeBuilder withBottomOptional( @Nonnull ItemStack bottomOptional );
IInscriberRecipeBuilder withBottomOptional( @Nonnull Collection<ItemStack> bottomOptional );
/**
* Creates an inscriber recipe with type.
@@ -104,4 +104,14 @@ public interface IInscriberRecipeBuilder
*/
@Nonnull
IInscriberRecipe build();
@Deprecated
default IInscriberRecipeBuilder withTopOptional(@Nonnull ItemStack topOptional){
return withTopOptional(Collections.singleton(topOptional));
}
@Deprecated
default IInscriberRecipeBuilder withBottomOptional(@Nonnull ItemStack bottomOptional){
return withBottomOptional(Collections.singleton(bottomOptional));
}
}
@@ -24,13 +24,12 @@
package appeng.api.features;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import appeng.api.config.TunnelType;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.capabilities.Capability;
import appeng.api.config.TunnelType;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
@@ -59,6 +58,8 @@ public interface IP2PTunnelRegistry
*
* @return null if no attunement can be found or attunement
*/
@Nonnull
@Nullable
TunnelType getTunnelTypeByItem( ItemStack trigger );
TunnelType registerTunnelType( @Nonnull String enumName, @Nonnull ItemStack partStack );
}
@@ -77,6 +77,14 @@ public interface ICraftingPatternDetails
*/
IAEItemStack[] getCondensedOutputs();
/**
* The primary output of this pattern. The pattern will only be used to craft the primary output; the others are
* just byproducts.
*/
default IAEItemStack getPrimaryOutput() {
return getOutputs()[0];
}
/**
* @return a list of the outputs, will include nulls.
*/
@@ -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>
* <p>
* 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>
* <p>
* 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();
}
@@ -1,14 +0,0 @@
package yalter.mousetweaks.api;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Put this on your GuiScreen to disable Mouse Tweaks.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface MouseTweaksIgnore {
}
@@ -21,11 +21,10 @@ package appeng.block;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.PowerUnits;
import appeng.api.definitions.IBlockDefinition;
import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.core.Api;
import appeng.core.localization.GuiText;
import appeng.core.localization.Tooltips;
import appeng.util.Platform;
import net.minecraft.block.Block;
import net.minecraft.client.util.ITooltipFlag;
@@ -35,7 +34,6 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.text.MessageFormat;
import java.util.List;
@@ -57,10 +55,7 @@ public class AEBaseItemBlockChargeable extends AEBaseItemBlock implements IAEIte
internalCurrentPower = tag.getDouble("internalCurrentPower");
}
final double percent = internalCurrentPower / internalMaxPower;
lines.add(GuiText.StoredEnergy.getLocal() + ':' + MessageFormat.format(" {0,number,#} ", internalCurrentPower) + Platform
.gui_localize(PowerUnits.AE.unlocalizedName) + " - " + MessageFormat.format(" {0,number,#.##%} ", percent));
lines.add(Tooltips.energyStorageComponent(internalCurrentPower, internalMaxPower).getFormattedText());
}
}
@@ -25,12 +25,14 @@ import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileInterface;
import appeng.util.Platform;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
@@ -93,4 +95,12 @@ public class BlockInterface extends AEBaseTileBlock {
((TileInterface) rotatable).setSide(axis);
}
}
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
TileEntity tileEntity = this.getTileEntity(worldIn, pos);
if (tileEntity != null) {
((TileInterface) tileEntity).updateRedstoneState();
}
}
}
+4 -16
View File
@@ -46,7 +46,6 @@ import appeng.helpers.IMouseWheelItem;
import appeng.hooks.TickHandler;
import appeng.hooks.TickHandler.PlayerColor;
import appeng.items.tools.powered.Terminal;
import appeng.items.tools.powered.ToolWirelessTerminal;
import appeng.server.ServerHelper;
import appeng.util.Platform;
import net.minecraft.client.Minecraft;
@@ -54,7 +53,6 @@ import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Items;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumHand;
@@ -63,8 +61,6 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.client.event.*;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.client.settings.KeyConflictContext;
import net.minecraftforge.client.settings.KeyModifier;
import net.minecraftforge.common.ForgeModContainer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.FMLClientHandler;
@@ -73,22 +69,12 @@ import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import java.util.*;
import static appeng.client.KeyBindings.WCT;
import static appeng.client.KeyBindings.WFT;
import static appeng.client.KeyBindings.WPT;
import static appeng.client.KeyBindings.WT;
import static appeng.client.KeyBindings.*;
public class ClientHelper extends ServerHelper {
@@ -354,6 +340,8 @@ public class ClientHelper extends ServerHelper {
NetworkHandler.instance().sendToServer(new PacketTerminalUse(Terminal.WIRELESS_PATTERN_TERMINAL));
} else if (k == WFT.getKeyBinding()) {
NetworkHandler.instance().sendToServer(new PacketTerminalUse(Terminal.WIRELESS_FLUID_TERMINAL));
} else if (k == WIT.getKeyBinding()) {
NetworkHandler.instance().sendToServer(new PacketTerminalUse(Terminal.WIRELESS_INTERFACE_TERMINAL));
}
}
}
+2 -1
View File
@@ -12,7 +12,8 @@ public enum KeyBindings {
WT(new KeyBinding("key.open_wireless_terminal.desc", KeyConflictContext.UNIVERSAL, KeyModifier.SHIFT, Keyboard.KEY_T, KEY_CATEGORY)),
WCT(new KeyBinding("key.open_wireless_crafting_terminal.desc", KeyConflictContext.UNIVERSAL, KeyModifier.SHIFT, Keyboard.KEY_E, KEY_CATEGORY)),
WPT(new KeyBinding("key.open_wireless_pattern_terminal.desc", KeyConflictContext.UNIVERSAL, KeyModifier.SHIFT, Keyboard.KEY_R, KEY_CATEGORY)),
WFT(new KeyBinding("key.open_wireless_fluid_terminal.desc", KeyConflictContext.UNIVERSAL, KeyModifier.SHIFT, Keyboard.KEY_F, KEY_CATEGORY));
WFT(new KeyBinding("key.open_wireless_fluid_terminal.desc", KeyConflictContext.UNIVERSAL, KeyModifier.SHIFT, Keyboard.KEY_F, KEY_CATEGORY)),
WIT(new KeyBinding("key.open_wireless_interface_terminal.desc",KeyConflictContext.UNIVERSAL,KeyModifier.SHIFT,Keyboard.KEY_I,KEY_CATEGORY));
private KeyBinding keyBinding;
+127 -6
View File
@@ -72,7 +72,7 @@ import net.minecraftforge.fml.common.Optional;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import yalter.mousetweaks.api.MouseTweaksIgnore;
import yalter.mousetweaks.api.IMTModGuiContainer2;
import java.awt.*;
import java.io.IOException;
@@ -85,9 +85,8 @@ import java.util.concurrent.TimeUnit;
import static appeng.integration.modules.jei.JEIPlugin.aeGuiHandler;
import static appeng.integration.modules.jei.JEIPlugin.runtime;
@MouseTweaksIgnore
public abstract class AEBaseGui extends GuiContainer {
@Optional.Interface(iface = "yalter.mousetweaks.api.IMTModGuiContainer2", modid = "mousetweaks")
public abstract class AEBaseGui extends GuiContainer implements IMTModGuiContainer2 {
private final List<InternalSlotME> meSlots = new ArrayList<>();
// drag y
private final Set<Slot> drag_click = new HashSet<>();
@@ -184,6 +183,12 @@ public abstract class AEBaseGui extends GuiContainer {
this.drawTooltip((ITooltip) c, mouseX, mouseY);
}
}
for (final Object o : this.labelList) {
if (o instanceof ITooltip) {
this.drawTooltip((ITooltip) o, mouseX, mouseY);
}
}
GlStateManager.enableDepth();
if (Platform.isModLoaded("jei")) {
bookmarkedJEIghostItem(mouseX, mouseY);
@@ -258,7 +263,7 @@ public abstract class AEBaseGui extends GuiContainer {
}
}
private void drawTooltip(ITooltip tooltip, int mouseX, int mouseY) {
protected void drawTooltip(ITooltip tooltip, int mouseX, int mouseY) {
final int x = tooltip.xPos(); // ((GuiImgButton) c).x;
int y = tooltip.yPos(); // ((GuiImgButton) c).y;
@@ -950,10 +955,42 @@ public abstract class AEBaseGui extends GuiContainer {
this.zLevel = 0.0F;
this.itemRender.zLevel = 0.0F;
boolean wasDragSplitting = this.dragSplitting;
this.dragSplitting = false; // to prevent the vanilla slot renderer from rendering the stack count during drag splitting, we're re-enabling it later
// Annoying but easier than trying to splice into render item
super.drawSlot(s);
this.stackSizeRenderer.renderStackSize(this.fontRenderer, AEItemStack.fromItemStack(appEngSlot.getDisplayStack()), s.xPos, s.yPos);
ItemStack stackInSlot = ((AppEngSlot)s).getDisplayStack();
ItemStack stackUnderCursor = this.mc.player.inventory.getItemStack();
if (wasDragSplitting
&& this.dragSplittingSlots.contains(s)
&& this.dragSplittingSlots.size() > 1
&& !stackUnderCursor.isEmpty()) {
if (Container.canAddItemToSlot(s, stackUnderCursor, true) && this.inventorySlots.canDragIntoSlot(s))
{
drawRect(s.xPos, s.yPos, s.xPos + 16, s.yPos + 16, -2130706433);
stackInSlot = stackUnderCursor.copy();
Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, stackInSlot, s.getStack().isEmpty() ? 0 : s.getStack().getCount());
int k = Math.min(stackInSlot.getMaxStackSize(), s.getItemStackLimit(stackInSlot));
if (stackInSlot.getCount() > k)
{
stackInSlot.setCount(k);
}
}
else
{
this.dragSplittingSlots.remove(s);
this.updateDragSplitting();
}
}
this.dragSplitting = wasDragSplitting;
this.stackSizeRenderer.renderStackSize(this.fontRenderer, AEItemStack.fromItemStack(stackInSlot), s.xPos, s.yPos);
return;
} else {
super.drawSlot(s);
@@ -988,4 +1025,88 @@ public abstract class AEBaseGui extends GuiContainer {
protected List<InternalSlotME> getMeSlots() {
return this.meSlots;
}
// TODO: remove this when refactoring slot rendering
private void updateDragSplitting()
{
ItemStack itemstack = this.mc.player.inventory.getItemStack();
if (!itemstack.isEmpty() && this.dragSplitting)
{
if (this.dragSplittingLimit == 2)
{
this.dragSplittingRemnant = itemstack.getMaxStackSize();
}
else
{
this.dragSplittingRemnant = itemstack.getCount();
for (Slot slot : this.dragSplittingSlots)
{
ItemStack itemstack1 = itemstack.copy();
ItemStack itemstack2 = slot.getStack();
int i = itemstack2.isEmpty() ? 0 : itemstack2.getCount();
Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack1, i);
int j = Math.min(itemstack1.getMaxStackSize(), slot.getItemStackLimit(itemstack1));
if (itemstack1.getCount() > j)
{
itemstack1.setCount(j);
}
this.dragSplittingRemnant -= itemstack1.getCount() - i;
}
}
}
}
@Override
@Optional.Method(modid = "mousetweaks")
public boolean MT_isMouseTweaksDisabled() {
return false;
}
@Override
@Optional.Method(modid = "mousetweaks")
public boolean MT_isWheelTweakDisabled() {
return true;
}
@Override
@Optional.Method(modid = "mousetweaks")
public Container MT_getContainer() {
return this.inventorySlots;
}
@Override
@Optional.Method(modid = "mousetweaks")
public Slot MT_getSlotUnderMouse() {
return getSlotUnderMouse();
}
@Override
@Optional.Method(modid = "mousetweaks")
public boolean MT_isCraftingOutput(Slot slot) {
return slot instanceof SlotOutput || slot instanceof AppEngCraftingSlot;
}
@Override
@Optional.Method(modid = "mousetweaks")
public boolean MT_isIgnored(Slot slot) {
return false;
}
@Override
@Optional.Method(modid = "mousetweaks")
public boolean MT_disableRMBDraggingFunctionality() {
if (this.dragSplitting && this.dragSplittingButton == 1) {
this.dragSplitting = false;
// Don't ignoreMouseUp on slots that can't accept the item. (crafting output, ME slot, etc.)
if (this.getSlotUnderMouse() != null && this.getSlotUnderMouse().isItemValid(this.mc.player.inventory.getItemStack())) {
this.ignoreMouseUp = true;
}
return true;
}
return false;
}
}
@@ -1,13 +1,21 @@
package appeng.client.gui;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.implementations.*;
import appeng.client.gui.implementations.GuiCraftAmount;
import appeng.client.gui.implementations.GuiCraftConfirm;
import appeng.client.gui.implementations.GuiCraftingCPU;
import appeng.client.gui.implementations.GuiExpandedProcessingPatternTerm;
import appeng.client.gui.implementations.GuiPatternTerm;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.client.gui.widgets.GuiCustomSlot;
import appeng.container.interfaces.IJEIGhostIngredients;
import appeng.container.slot.SlotFake;
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
import appeng.container.interfaces.ISpecialSlotIngredient;
import appeng.container.slot.IJEITargetSlot;
import mezz.jei.api.gui.IAdvancedGuiHandler;
import mezz.jei.api.gui.IGhostIngredientHandler;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Slot;
import org.lwjgl.input.Mouse;
import javax.annotation.Nonnull;
@@ -59,11 +67,39 @@ public class AEGuiHandler implements IAdvancedGuiHandler<AEBaseGui>, IGhostIngre
if (guiContainer instanceof GuiCraftAmount) {
if (guiContainer.getSlotUnderMouse() != null) {
result = guiContainer.getSlotUnderMouse().getStack();
} else {
return null;
}
}
if (result != null) {
return result;
}
Slot slot = guiContainer.getSlotUnderMouse();
if (slot instanceof ISpecialSlotIngredient ss) {
return ss.getIngredient();
}
for (GuiCustomSlot customSlot : guiContainer.guiSlots) {
if (this.checkSlotArea(guiContainer, customSlot, mouseX, mouseY)) {
return customSlot.getIngredient();
}
}
return result;
}
private boolean checkSlotArea(GuiContainer gui, GuiCustomSlot slot, int mouseX, int mouseY) {
int i = gui.guiLeft;
int j = gui.guiTop;
mouseX = mouseX - i;
mouseY = mouseY - j;
return mouseX >= slot.xPos() - 1 &&
mouseX < slot.xPos() + slot.getWidth() + 1 &&
mouseY >= slot.yPos() - 1 &&
mouseY < slot.yPos() + slot.getHeight() + 1;
}
private int getSlotidx(AEBaseGui guiContainer, int mouseX, int mouseY, int rows) {
int guileft = guiContainer.getGuiLeft();
int guitop = guiContainer.getGuiTop();
@@ -78,12 +114,12 @@ public class AEGuiHandler implements IAdvancedGuiHandler<AEBaseGui>, IGhostIngre
return (guiSloty * 3) + guiSlotx + (currentScroll * 3);
}
@SuppressWarnings("unchecked")
@Override
@Nonnull
public <I> List<Target<I>> getTargets(@Nonnull AEBaseGui gui, @Nonnull I ingredient, boolean doStart) {
ArrayList<Target<I>> targets = new ArrayList<>();
if (gui instanceof IJEIGhostIngredients) {
IJEIGhostIngredients g = (IJEIGhostIngredients) gui;
if (gui instanceof IJEIGhostIngredients g) {
List<Target<?>> phantomTargets = g.getPhantomTargets(ingredient);
targets.addAll((List<Target<I>>) (Object) phantomTargets);
}
@@ -91,13 +127,8 @@ public class AEGuiHandler implements IAdvancedGuiHandler<AEBaseGui>, IGhostIngre
if (gui instanceof GuiUpgradeable || gui instanceof GuiPatternTerm || gui instanceof GuiExpandedProcessingPatternTerm) {
IJEIGhostIngredients ghostGui = ((IJEIGhostIngredients) gui);
for (Target<I> target : targets) {
if (ghostGui.getFakeSlotTargetMap().get(target) instanceof SlotFake) {
if (((SlotFake) ghostGui.getFakeSlotTargetMap().get(target)).getStack().isEmpty()) {
target.accept(ingredient);
break;
}
} else if (ghostGui.getFakeSlotTargetMap().get(target) instanceof GuiFluidSlot) {
if (((GuiFluidSlot) ghostGui.getFakeSlotTargetMap().get(target)).getFluidStack() == null) {
if (ghostGui.getFakeSlotTargetMap().get(target) instanceof IJEITargetSlot jeiSlot) {
if (jeiSlot.needAccept()) {
target.accept(ingredient);
break;
}
@@ -19,9 +19,11 @@
package appeng.client.gui.implementations;
import appeng.api.config.LockCraftingMode;
import appeng.api.config.Settings;
import appeng.api.config.YesNo;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiImgLabel;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.GuiToggleButton;
import appeng.container.implementations.ContainerInterface;
@@ -41,14 +43,22 @@ import java.io.IOException;
public class GuiInterface extends GuiUpgradeable {
private GuiTabButton priority;
private GuiImgButton UnlockMode;
private GuiImgButton BlockMode;
private GuiToggleButton interfaceMode;
private GuiImgLabel lockReason;
public GuiInterface(final InventoryPlayer inventoryPlayer, final IInterfaceHost te) {
super(new ContainerInterface(inventoryPlayer, te));
this.ySize = 256;
}
@Override
public void initGui() {
super.initGui();
this.addLabel();
}
@Override
protected void addButtons() {
this.priority = new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender);
@@ -57,16 +67,41 @@ public class GuiInterface extends GuiUpgradeable {
this.BlockMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO);
this.buttonList.add(this.BlockMode);
this.interfaceMode = new GuiToggleButton(this.guiLeft - 18, this.guiTop + 26, 84, 85, GuiText.InterfaceTerminal.getLocal(), GuiText.InterfaceTerminalHint.getLocal());
this.UnlockMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 26, Settings.UNLOCK, LockCraftingMode.NONE);
this.buttonList.add(this.UnlockMode);
this.interfaceMode = new GuiToggleButton(this.guiLeft - 18, this.guiTop + 44, 84, 85, GuiText.InterfaceTerminal.getLocal(), GuiText.InterfaceTerminalHint.getLocal());
this.buttonList.add(this.interfaceMode);
}
protected void addLabel() {
if (lockReason != null) {
labelList.remove(this.lockReason);
}
this.lockReason = new GuiImgLabel(this.fontRenderer, guiLeft + 40, guiTop + 12, Settings.UNLOCK, LockCraftingMode.NONE);
this.lockReason.setVisibility(false);
labelList.add(lockReason);
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
if (this.BlockMode != null) {
this.BlockMode.set(((ContainerInterface) this.cvb).getBlockingMode());
}
if (this.UnlockMode != null) {
this.UnlockMode.set(((ContainerInterface) this.cvb).getUnlockMode());
if (this.lockReason != null) {
if (this.UnlockMode.getCurrentValue() == LockCraftingMode.NONE) {
this.lockReason.setVisibility(false);
} else {
this.lockReason.setVisibility(true);
this.lockReason.set(((ContainerInterface) this.cvb).getCraftingLockedReason());
}
}
}
if (this.interfaceMode != null) {
this.interfaceMode.setState(((ContainerInterface) this.cvb).getInterfaceTerminalMode() == YesNo.YES);
}
@@ -106,6 +141,10 @@ public class GuiInterface extends GuiUpgradeable {
if (btn == this.BlockMode) {
NetworkHandler.instance().sendToServer(new PacketConfigButton(this.BlockMode.getSetting(), backwards));
}
if (btn == this.UnlockMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.UnlockMode.getSetting(), backwards));
}
}
}
@@ -27,14 +27,20 @@ import appeng.api.storage.channels.IItemStorageChannel;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.MEGuiTextField;
import appeng.client.gui.widgets.MEGuiTooltipTextField;
import appeng.client.me.ClientDCInternalInv;
import appeng.client.me.SlotDisconnected;
import appeng.container.implementations.ContainerInterfaceTerminal;
import appeng.container.implementations.ContainerWirelessInterfaceTerminal;
import appeng.container.slot.AppEngSlot;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.core.localization.ButtonToolTips;
import appeng.core.localization.GuiText;
import appeng.core.localization.PlayerMessages;
import appeng.helpers.DualityInterface;
import appeng.helpers.PatternHelper;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.parts.reporting.PartInterfaceTerminal;
import appeng.util.BlockPosUtils;
import appeng.util.Platform;
@@ -42,28 +48,20 @@ import com.google.common.collect.HashMultimap;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fml.common.Loader;
import org.lwjgl.input.Mouse;
import java.awt.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.*;
import static appeng.client.render.BlockPosHighlighter.hilightBlock;
import static appeng.helpers.ItemStackHelper.stackFromNBT;
@@ -71,15 +69,13 @@ import static appeng.helpers.ItemStackHelper.stackFromNBT;
public class GuiInterfaceTerminal extends AEBaseGui {
private int rows = 6;
protected static final int OFFSET_X = 21;
protected final GuiText guiTitle;
private static final int MAGIC_HEIGHT_NUMBER = 52 + 99;
private static final String MOLECULAR_ASSEMBLER = "tile.appliedenergistics2.molecular_assembler";
// TODO: copied from GuiMEMonitorable. It looks not changed, maybe unneeded?
private final int offsetX = 21;
private int maxRows = Integer.MAX_VALUE;
protected int jeiOffset = Loader.isModLoaded("jei") ? 24 : 0;
private int reservedSpace = 0;
private final boolean jeiEnabled;
private final int jeiButtonPadding;
private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<>();
private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
@@ -89,99 +85,139 @@ public class GuiInterfaceTerminal extends AEBaseGui {
private final ArrayList<String> names = new ArrayList<>();
private final ArrayList<Object> lines = new ArrayList<>();
private final Set<Object> matchedStacks = new HashSet<>();
private final Set<ClientDCInternalInv> matchedInterfaces = new HashSet<>();
private final Map<String, Set<Object>> cachedSearches = new WeakHashMap<>();
private final Map<ClientDCInternalInv, Integer> dimHashMap = new HashMap<>();
private final MEGuiTooltipTextField searchFieldOutputs;
private final MEGuiTooltipTextField searchFieldInputs;
private final MEGuiTooltipTextField searchFieldNames;
private final GuiImgButton guiButtonHideFull;
private final GuiImgButton guiButtonAssemblersOnly;
private final GuiImgButton guiButtonBrokenRecipes;
private final GuiImgButton terminalStyleBox;
private boolean refreshList = false;
private MEGuiTextField searchFieldOutputs;
private MEGuiTextField searchFieldInputs;
private final PartInterfaceTerminal partInterfaceTerminal;
private GuiButton guiButtonHide;
private GuiButton guiButtonNextAssembler;
private GuiImgButton terminalStyleBox;
private final HashMap<ClientDCInternalInv, Integer> dimHashMap = new HashMap<>();
private int drawnRows = 0;
/* These are worded so that the intended default is false */
private boolean onlyShowWithSpace = false;
private boolean onlyMolecularAssemblers = false;
private boolean onlyBrokenRecipes = false;
private int rows = 6;
public GuiInterfaceTerminal(final InventoryPlayer inventoryPlayer, final PartInterfaceTerminal te) {
super(new ContainerInterfaceTerminal(inventoryPlayer, te));
this.partInterfaceTerminal = te;
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar(scrollbar);
this.xSize = 208;
this.ySize = 255;
this.setReservedSpace(82);
this.jeiEnabled = Platform.isModLoaded("jei");
this.jeiButtonPadding = jeiEnabled ? 22 : 0;
searchFieldInputs = createTextField(86, 12, ButtonToolTips.SearchFieldInputs.getLocal());
searchFieldOutputs = createTextField(86, 12, ButtonToolTips.SearchFieldOutputs.getLocal());
searchFieldNames = createTextField(71, 12, ButtonToolTips.SearchFieldNames.getLocal());
searchFieldNames.setFocused(true);
guiButtonAssemblersOnly = new GuiImgButton(0, 0, Settings.ACTIONS, null);
guiButtonHideFull = new GuiImgButton(0, 0, Settings.ACTIONS, null);
guiButtonBrokenRecipes = new GuiImgButton(0, 0, Settings.ACTIONS, null);
terminalStyleBox = new GuiImgButton(0, 0, Settings.TERMINAL_STYLE, null);
guiTitle = GuiText.InterfaceTerminal;
}
public GuiInterfaceTerminal(final InventoryPlayer inventoryPlayer, final WirelessTerminalGuiObject guiObject) {
super(new ContainerWirelessInterfaceTerminal(inventoryPlayer, guiObject));
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar(scrollbar);
this.xSize = 208;
this.ySize = 255;
this.jeiEnabled = Platform.isModLoaded("jei");
this.jeiButtonPadding = jeiEnabled ? 22 : 0;
searchFieldInputs = createTextField(86, 12, ButtonToolTips.SearchFieldInputs.getLocal());
searchFieldOutputs = createTextField(86, 12, ButtonToolTips.SearchFieldOutputs.getLocal());
searchFieldNames = createTextField(71, 12, ButtonToolTips.SearchFieldNames.getLocal());
searchFieldNames.setFocused(true);
guiButtonAssemblersOnly = new GuiImgButton(0, 0, Settings.ACTIONS, null);
guiButtonHideFull = new GuiImgButton(0, 0, Settings.ACTIONS, null);
guiButtonBrokenRecipes = new GuiImgButton(0, 0, Settings.ACTIONS, null);
terminalStyleBox = new GuiImgButton(0, 0, Settings.TERMINAL_STYLE, null);
guiTitle = GuiText.WirelessTerminal;
}
private MEGuiTooltipTextField createTextField(final int width, final int height, final String tooltip) {
MEGuiTooltipTextField textField = new MEGuiTooltipTextField(width, height, tooltip) {
@Override
public void onTextChange(String oldText) {
refreshList();
}
};
textField.setEnableBackgroundDrawing(false);
textField.setMaxStringLength(25);
textField.setTextColor(0xFFFFFF);
textField.setCursorPositionZero();
return textField;
}
private void setScrollBar() {
this.getScrollBar().setTop(52).setLeft(189).setHeight(this.rows * 18 - 2);
this.getScrollBar().setRange(0, this.lines.size() - 1, 1);
}
private int calculateRowsCount() {
final int maxRows = getMaxRows();
final int jeiPadding = jeiEnabled ? 22 + 18 : 0;
final int extraSpace = this.height - MAGIC_HEIGHT_NUMBER - jeiPadding;
return Math.max(6, Math.min(maxRows, extraSpace / 18));
}
@Override
public void initGui() {
this.maxRows = AEConfig.instance()
.getConfigManager()
.getSetting(
Settings.TERMINAL_STYLE) != TerminalStyle.TALL ? 6 : Integer.MAX_VALUE;
final int magicNumber = 82 + 14;
final int extraSpace = this.height - magicNumber - this.reservedSpace;
this.rows = (int) Math.floor(extraSpace / 18);
if (this.rows > this.maxRows) {
this.rows = this.maxRows;
}
if (this.rows < 6) {
this.rows = 6;
}
this.ySize = magicNumber + this.rows * 18 + this.reservedSpace;
// this.guiTop = top;
final int unusedSpace = this.height - this.ySize;
this.guiTop = (int) Math.floor(unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f));
this.rows = calculateRowsCount();
super.initGui();
this.getScrollBar().setLeft(189);
this.getScrollBar().setHeight(106);
this.getScrollBar().setTop(51);
this.ySize = MAGIC_HEIGHT_NUMBER + this.rows * 18;
final int unusedSpace = this.height - this.ySize;
this.guiTop = (int) Math.floor(unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f));
this.searchFieldInputs = new MEGuiTextField(this.fontRenderer, this.guiLeft + Math.max(32, this.offsetX), this.guiTop + 25, 65, 12);
this.searchFieldInputs.setEnableBackgroundDrawing(false);
this.searchFieldInputs.setMaxStringLength(25);
this.searchFieldInputs.setTextColor(0xFFFFFF);
this.searchFieldInputs.setVisible(true);
this.searchFieldInputs.setFocused(false);
searchFieldInputs.x = guiLeft + 32;
searchFieldInputs.y = guiTop + 25;
searchFieldOutputs.x = guiLeft + 32;
searchFieldOutputs.y = guiTop + 38;
searchFieldNames.x = guiLeft + 32 + 99;
searchFieldNames.y = guiTop + 38;
this.searchFieldOutputs = new MEGuiTextField(this.fontRenderer, this.guiLeft + Math.max(32, this.offsetX), this.guiTop + 38, 65, 12);
this.searchFieldOutputs.setEnableBackgroundDrawing(false);
this.searchFieldOutputs.setMaxStringLength(25);
this.searchFieldOutputs.setTextColor(0xFFFFFF);
this.searchFieldOutputs.setVisible(true);
this.searchFieldOutputs.setFocused(true);
this.searchFieldInputs.setText(partInterfaceTerminal.in);
this.searchFieldOutputs.setText(partInterfaceTerminal.out);
this.fontRenderer.drawString(this.getGuiDisplayName(GuiText.InterfaceTerminal.getLocal()), 8, 6, 4210752);
this.fontRenderer.drawString(GuiText.inventory.getLocal(), this.offsetX + 2, this.ySize - 96 + 3, 4210752);
terminalStyleBox.x = guiLeft - 18;
terminalStyleBox.y = guiTop + 8 + jeiButtonPadding;
guiButtonBrokenRecipes.x = guiLeft - 18;
guiButtonBrokenRecipes.y = terminalStyleBox.y + 20;
guiButtonHideFull.x = guiLeft - 18;
guiButtonHideFull.y = guiButtonBrokenRecipes.y + 20;
guiButtonAssemblersOnly.x = guiLeft - 18;
guiButtonAssemblersOnly.y = guiButtonHideFull.y + 20;
this.setScrollBar();
this.repositionSlots();
}
protected void repositionSlot(final AppEngSlot s) {
this.ySize = 82 + 14 + this.drawnRows * 18 + this.reservedSpace;
s.yPos = s.getY() + this.ySize - 112;
s.xPos = s.getX() + 14;
}
@Override
public void onGuiClosed() {
partInterfaceTerminal.saveSearchStrings(this.searchFieldInputs.getText().toLowerCase(), this.searchFieldOutputs.getText().toLowerCase());
super.onGuiClosed();
protected void repositionSlots() {
for (final Object obj : this.inventorySlots.inventorySlots) {
if (obj instanceof AppEngSlot slot) {
slot.yPos = this.ySize + slot.getY() - 78 - 7;
slot.xPos = slot.getX() + 14;
}
}
}
@Override
public List<Rectangle> getJEIExclusionArea() {
Rectangle tallButton = new Rectangle(this.guiLeft - 18, this.guiTop + 24 + jeiOffset, 18, 18);
Rectangle tallButton = new Rectangle(this.guiLeft - 18, this.guiTop + 24 + 24, 18, 18);
List<Rectangle> area = new ArrayList<>();
area.add(tallButton);
return area;
@@ -189,93 +225,98 @@ public class GuiInterfaceTerminal extends AEBaseGui {
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.buttonList.clear();
this.fontRenderer.drawString(this.getGuiDisplayName(guiTitle.getLocal()), OFFSET_X + 2, 6, 4210752);
this.fontRenderer.drawString(GuiText.inventory.getLocal(), OFFSET_X + 2, this.ySize - 96, 4210752);
final int currentScroll = this.getScrollBar().getCurrentScroll();
this.guiButtonNextAssembler = new GuiImgButton(guiLeft + 123, guiTop + 25, Settings.ACTIONS, ActionItems.FREE_MOLECULAR_SLOT_SHORTCUT);
this.buttonList.add(guiButtonNextAssembler);
guiButtonHide = new GuiImgButton(guiLeft + 141, guiTop + 25, Settings.ACTIONS, this.partInterfaceTerminal.onlyInterfacesWithFreeSlots ? ActionItems.TOGGLE_SHOW_FULL_INTERFACES_OFF : ActionItems.TOGGLE_SHOW_FULL_INTERFACES_ON);
this.buttonList.add(guiButtonHide);
this.buttonList.add(this.terminalStyleBox = new GuiImgButton(this.guiLeft - 18, guiTop + 24 + jeiOffset, Settings.TERMINAL_STYLE, AEConfig.instance()
.getConfigManager()
.getSetting(Settings.TERMINAL_STYLE)));
this.inventorySlots.inventorySlots.removeIf(slot -> slot instanceof SlotDisconnected);
for (final Slot s : this.inventorySlots.inventorySlots) {
if (s instanceof AppEngSlot) {
if (s.xPos < 197) {
this.repositionSlot((AppEngSlot) s);
}
}
}
int offset = 52;
int offset = 51;
int linesDraw = 0;
for (int x = 0; x < rows && linesDraw < rows && currentScroll + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(currentScroll + x);
if (lineObj instanceof ClientDCInternalInv) {
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
GuiButton guiButton = new GuiImgButton(guiLeft + 4, guiTop + offset, Settings.ACTIONS, ActionItems.HIGHLIGHT_INTERFACE);
guiButtonHashMap.put(guiButton, inv);
this.buttonList.add(guiButton);
int extraLines = numUpgradesMap.get(inv);
if (lineObj instanceof ClientDCInternalInv inv) {
final int extraLines = numUpgradesMap.get(inv);
for (int row = 0; row < 1 + extraLines && linesDraw < rows; ++row) {
for (int z = 0; z < 9; z++) {
this.inventorySlots.inventorySlots.add(new SlotDisconnected(inv, z + (row * 9), (z * 18 + 22), offset));
if (this.matchedStacks.contains(inv.getInventory().getStackInSlot(z + (row * 9)))) {
drawRect(z * 18 + 22, offset, z * 18 + 22 + 16, offset + 16, 0x8A00FF00);
} else if (!matchedInterfaces.contains(inv)) {
drawRect(z * 18 + 22, offset, z * 18 + 22 + 16, offset + 16, 0x6A000000);
drawRect(z * 18 + 22, 1 + offset, z * 18 + 22 + 16, 1 + offset + 16, 0x2A00FF00);
}
}
linesDraw++;
offset += 18;
}
} else if (lineObj instanceof String) {
String name = (String) lineObj;
} else if (lineObj instanceof String name) {
final int rows = this.byName.get(name).size();
if (rows > 1) {
name = name + " (" + rows + ')';
}
while (name.length() > 2 && this.fontRenderer.getStringWidth(name) > 155) {
while (name.length() > 2 && this.fontRenderer.getStringWidth(name) > 158) {
name = name.substring(0, name.length() - 1);
}
this.fontRenderer.drawString(name, this.offsetX + 2, 5 + offset, 4210752);
this.fontRenderer.drawString(name, OFFSET_X + 3, 6 + offset, 4210752);
linesDraw++;
offset += 18;
}
}
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
buttonList.clear();
guiButtonHashMap.clear();
inventorySlots.inventorySlots.removeIf(slot -> slot instanceof SlotDisconnected);
guiButtonAssemblersOnly.set(onlyMolecularAssemblers ? ActionItems.MOLECULAR_ASSEMBLERS_ON : ActionItems.MOLECULAR_ASSEMBLERS_OFF);
guiButtonHideFull.set(onlyShowWithSpace ? ActionItems.TOGGLE_SHOW_FULL_INTERFACES_OFF : ActionItems.TOGGLE_SHOW_FULL_INTERFACES_ON);
guiButtonBrokenRecipes.set(onlyBrokenRecipes ? ActionItems.TOGGLE_SHOW_ONLY_INVALID_PATTERNS_ON : ActionItems.TOGGLE_SHOW_ONLY_INVALID_PATTERNS_OFF);
terminalStyleBox.set(AEConfig.instance().getConfigManager().getSetting(Settings.TERMINAL_STYLE));
buttonList.add(guiButtonAssemblersOnly);
buttonList.add(guiButtonHideFull);
buttonList.add(guiButtonBrokenRecipes);
buttonList.add(terminalStyleBox);
int offset = 51;
final int currentScroll = this.getScrollBar().getCurrentScroll();
int linesDraw = 0;
for (int x = 0; x < rows && linesDraw < rows && currentScroll + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(currentScroll + x);
if (lineObj instanceof ClientDCInternalInv inv) {
GuiButton guiButton = new GuiImgButton(guiLeft + 4, guiTop + offset + 1, Settings.ACTIONS, ActionItems.HIGHLIGHT_INTERFACE);
guiButtonHashMap.put(guiButton, inv);
this.buttonList.add(guiButton);
final int extraLines = numUpgradesMap.get(inv);
for (int row = 0; row < 1 + extraLines && linesDraw < rows; ++row) {
for (int z = 0; z < 9; z++) {
this.inventorySlots.inventorySlots.add(new SlotDisconnected(inv, z + (row * 9), z * 18 + 22, 1+ offset));
}
linesDraw++;
offset += 18;
}
} else if (lineObj instanceof String) {
linesDraw++;
offset += 18;
}
}
if (searchFieldInputs.isMouseIn(mouseX, mouseY)) {
drawTooltip(Mouse.getEventX() * this.width / this.mc.displayWidth - offsetX, mouseY - guiTop, "Inputs OR names");
} else if (searchFieldOutputs.isMouseIn(mouseX, mouseY)) {
drawTooltip(Mouse.getEventX() * this.width / this.mc.displayWidth - offsetX, mouseY - guiTop, "Outputs OR names");
}
super.drawScreen(mouseX, mouseY, partialTicks);
drawTooltip(searchFieldInputs, mouseX, mouseY);
drawTooltip(searchFieldOutputs, mouseX, mouseY);
drawTooltip(searchFieldNames, mouseX, mouseY);
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) throws IOException {
this.searchFieldInputs.mouseClicked(xCoord, yCoord, btn);
if (btn == 1 && this.searchFieldInputs.isMouseIn(xCoord, yCoord)) {
this.searchFieldInputs.setText("");
this.refreshList();
}
this.searchFieldOutputs.mouseClicked(xCoord, yCoord, btn);
if (btn == 1 && this.searchFieldOutputs.isMouseIn(xCoord, yCoord)) {
this.searchFieldOutputs.setText("");
this.refreshList();
}
this.searchFieldNames.mouseClicked(xCoord, yCoord, btn);
super.mouseClicked(xCoord, yCoord, btn);
}
@@ -289,54 +330,37 @@ public class GuiInterfaceTerminal extends AEBaseGui {
int interfaceDim = dimHashMap.get(guiButtonHashMap.get(this.selectedButton));
if (playerDim != interfaceDim) {
try {
mc.player.sendStatusMessage(new TextComponentString("Interface located at dimension: " + interfaceDim + " [" + DimensionManager.getWorld(interfaceDim).provider.getDimensionType().getName() + "] and cant be highlighted"), false);
mc.player.sendStatusMessage(PlayerMessages.InterfaceInOtherDimParam.get(interfaceDim, DimensionManager.getWorld(interfaceDim).provider.getDimensionType().getName()), false);
} catch (Exception e) {
mc.player.sendStatusMessage(new TextComponentString("Interface is located in another dimension and cannot be highlighted"), false);
mc.player.sendStatusMessage(PlayerMessages.InterfaceInOtherDim.get(), false);
}
} else {
hilightBlock(blockPos, System.currentTimeMillis() + 500 * BlockPosUtils.getDistance(blockPos, blockPos2), playerDim);
mc.player.sendStatusMessage(new TextComponentString("The interface is now highlighted at " + "X: " + blockPos.getX() + " Y: " + blockPos.getY() + " Z: " + blockPos.getZ()), false);
mc.player.sendStatusMessage(PlayerMessages.InterfaceHighlighted.get(blockPos.getX(), blockPos.getY(), blockPos.getZ()), false);
}
mc.player.closeScreen();
}
if (btn instanceof GuiImgButton) {
final boolean backwards = Mouse.isButtonDown(1);
final GuiImgButton iBtn = (GuiImgButton) btn;
} else if (btn == guiButtonHideFull) {
onlyShowWithSpace = !onlyShowWithSpace;
this.refreshList();
} else if (btn == guiButtonAssemblersOnly) {
onlyMolecularAssemblers = !onlyMolecularAssemblers;
this.refreshList();
} else if (btn == guiButtonBrokenRecipes) {
onlyBrokenRecipes = !onlyBrokenRecipes;
this.refreshList();
} else if (btn instanceof GuiImgButton iBtn) {
if (iBtn.getSetting() != Settings.ACTIONS) {
final Enum cv = iBtn.getCurrentValue();
final Enum next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
final Enum<?> cv = iBtn.getCurrentValue();
final boolean backwards = Mouse.isButtonDown(1);
final Enum<?> next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
if (btn == this.terminalStyleBox) {
AEConfig.instance().getConfigManager().putSetting(iBtn.getSetting(), next);
}
iBtn.set(next);
if (next.getClass() == TerminalStyle.class) {
this.reinitalize();
}
iBtn.set(next);
}
}
if (btn == guiButtonHide) {
partInterfaceTerminal.onlyInterfacesWithFreeSlots = !partInterfaceTerminal.onlyInterfacesWithFreeSlots;
this.refreshList();
}
if (btn == guiButtonNextAssembler) {
// Set Search to "Molecular Assembler" and set "Only Free Interface"
boolean currentOnlyInterfacesWithFreeSlots = this.partInterfaceTerminal.onlyInterfacesWithFreeSlots;
String currentSearchText = this.searchFieldOutputs.getText();
this.partInterfaceTerminal.onlyInterfacesWithFreeSlots = true;
this.searchFieldOutputs.setText("Molecular Assembler");
this.refreshList();
this.partInterfaceTerminal.onlyInterfacesWithFreeSlots = currentOnlyInterfacesWithFreeSlots;
this.searchFieldOutputs.setText(currentSearchText);
}
}
private void reinitalize() {
@@ -347,74 +371,66 @@ public class GuiInterfaceTerminal extends AEBaseGui {
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/newinterfaceterminal.png");
//split the texture for the top
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, 166);
// draw the top portion of the background, above the interface list
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, 53);
for (int x = 0; x < this.rows; x++) {
// draw the background of the rows in the interface list
this.drawTexturedModalRect(offsetX, offsetY + 53 + x * 18, 0, 52, this.xSize, 18);
}
int offset = 51;
final int ex = this.getScrollBar().getCurrentScroll();
int linesDraw = 0;
for (int x = 0; x < rows && linesDraw < rows && ex + x < this.lines.size(); x++) {
for (int x = 0; x < this.rows && linesDraw < rows && ex + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(ex + x);
if (lineObj instanceof ClientDCInternalInv) {
GlStateManager.color(1, 1, 1, 1);
final int width = 9 * 18;
final int extraLines = numUpgradesMap.get(lineObj);
int extraLines = numUpgradesMap.get(lineObj);
// draw the slot backgrounds
for (int row = 0; row < 1 + extraLines && linesDraw < rows; ++row) {
if (linesDraw == 6) {
this.drawTexturedModalRect(offsetX, offsetY + offset + 7, 0, 166, 190, 7);
this.drawTexturedModalRect(offsetX, offsetY + offset + 14, 0, 166, 190, 4);
} else if (linesDraw >= 7) {
this.drawTexturedModalRect(offsetX, offsetY + offset, 0, 173, 190, 18);
}
this.drawTexturedModalRect(offsetX + 20, offsetY + offset, 20, 173, width, 18);
offset += 18;
linesDraw++;
}
} else {
if (linesDraw == 6) {
this.drawTexturedModalRect(offsetX, offsetY + offset + 7, 0, 166, 190, 7);
this.drawTexturedModalRect(offsetX, offsetY + offset + 14, 0, 166, 190, 4);
this.drawTexturedModalRect(offsetX, offsetY + offset, 0, 53, 183, 18);
} else if (linesDraw >= 7) {
this.drawTexturedModalRect(offsetX, offsetY + offset, 0, 53, 183, 18);
this.drawTexturedModalRect(offsetX + 183, offsetY + offset, 183, 166, 7, 18);
}
offset += 18;
linesDraw++;
}
}
offset = 51 + Math.max(6 * 18, linesDraw * 18);
if (linesDraw > 6) {
this.drawTexturedModalRect(offsetX, offsetY + offset, 0, 166, 190, 7);
}
this.drawTexturedModalRect(offsetX, offsetY + offset + 7, 0, 166, this.xSize, 90);
this.drawnRows = Math.max(6, linesDraw);
// draw the background below the interface list
this.drawTexturedModalRect(offsetX, offsetY + 50 + this.rows * 18, 0, 158, this.xSize, 99);
if (this.searchFieldInputs != null) {
this.searchFieldInputs.drawTextBox();
}
if (this.searchFieldOutputs != null) {
this.searchFieldOutputs.drawTextBox();
}
// draw the text boxes
this.searchFieldInputs.drawTextBox();
this.searchFieldOutputs.drawTextBox();
this.searchFieldNames.drawTextBox();
}
@Override
protected void keyTyped(final char character, final int key) throws IOException {
if (!this.checkHotbarKeys(key)) {
if (character == ' ' && this.searchFieldInputs.getText().isEmpty() && this.searchFieldInputs.isFocused()) {
return;
if (character == ' ') {
if ((this.searchFieldInputs.getText().isEmpty() && this.searchFieldInputs.isFocused())
|| (this.searchFieldOutputs.getText().isEmpty() && this.searchFieldOutputs.isFocused())
|| (this.searchFieldNames.getText().isEmpty() && this.searchFieldNames.isFocused())) {
return;
}
} else if (character == '\t') {
if (handleTab()) {
return;
}
}
if (character == ' ' && this.searchFieldOutputs.getText().isEmpty() && this.searchFieldOutputs.isFocused()) {
return;
}
if (this.searchFieldInputs.textboxKeyTyped(character, key) || this.searchFieldOutputs.textboxKeyTyped(character, key)) {
if (this.searchFieldInputs.textboxKeyTyped(character, key)
|| this.searchFieldOutputs.textboxKeyTyped(character, key)
|| this.searchFieldNames.textboxKeyTyped(character, key)) {
this.refreshList();
} else {
super.keyTyped(character, key);
@@ -422,6 +438,27 @@ public class GuiInterfaceTerminal extends AEBaseGui {
}
}
/** Cycle to the next search bar if tab is pressed, going in reverse if shift is held. */
private boolean handleTab() {
if (searchFieldInputs.isFocused()) {
searchFieldInputs.setFocused(false);
if (isShiftKeyDown()) searchFieldNames.setFocused(true);
else searchFieldOutputs.setFocused(true);
return true;
} else if (searchFieldOutputs.isFocused()) {
searchFieldOutputs.setFocused(false);
if (isShiftKeyDown()) searchFieldInputs.setFocused(true);
else searchFieldNames.setFocused(true);
return true;
} else if (searchFieldNames.isFocused()) {
searchFieldNames.setFocused(false);
if (isShiftKeyDown()) searchFieldOutputs.setFocused(true);
else searchFieldInputs.setFocused(true);
return true;
}
return false;
}
public void postUpdate(final NBTTagCompound in) {
if (in.getBoolean("clear")) {
this.byId.clear();
@@ -467,12 +504,13 @@ public class GuiInterfaceTerminal extends AEBaseGui {
this.byName.clear();
this.buttonList.clear();
this.matchedStacks.clear();
this.matchedInterfaces.clear();
final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase();
final String searchFieldOutputs = this.searchFieldOutputs.getText().toLowerCase();
final String searchFieldNames = this.searchFieldNames.getText().toLowerCase();
final Set<Object> cachedSearch = this.getCacheForSearchTerm("IN:" + searchFieldInputs + " OUT:" + searchFieldOutputs + partInterfaceTerminal.onlyInterfacesWithFreeSlots);
final Set<Object> cachedSearch = this.getCacheForSearchTerm("IN:" + searchFieldInputs + " OUT:" + searchFieldOutputs
+ "NAME:" + searchFieldNames + onlyShowWithSpace + onlyMolecularAssemblers + onlyBrokenRecipes);
final boolean rebuild = cachedSearch.isEmpty();
for (final ClientDCInternalInv entry : this.byId.values()) {
@@ -483,78 +521,101 @@ public class GuiInterfaceTerminal extends AEBaseGui {
// Shortcut to skip any filter if search term is ""/empty
boolean found = (searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty() && !partInterfaceTerminal.onlyInterfacesWithFreeSlots);
boolean found = searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty();
boolean interfaceHasFreeSlots = false;
boolean interfaceHasBrokenRecipes = false;
// Search if the current inventory holds a pattern containing the search term.
if (!found) {
if (!found || onlyShowWithSpace || onlyBrokenRecipes) {
int slot = 0;
for (final ItemStack itemStack : entry.getInventory()) {
if (slot > 8 + numUpgradesMap.get(entry) * 9) {
break;
}
if (!searchFieldInputs.isEmpty() && !searchFieldOutputs.isEmpty()) {
if (this.itemStackMatchesSearchTerm(itemStack, searchFieldInputs, 0) || this.itemStackMatchesSearchTerm(itemStack, searchFieldOutputs, 1)) {
found = true;
matchedStacks.add(itemStack);
}
} else if (!searchFieldInputs.isEmpty()) {
if (this.itemStackMatchesSearchTerm(itemStack, searchFieldInputs, 0)) {
found = true;
matchedStacks.add(itemStack);
}
} else if (!searchFieldOutputs.isEmpty()) {
if (this.itemStackMatchesSearchTerm(itemStack, searchFieldOutputs, 1)) {
found = true;
matchedStacks.add(itemStack);
}
}
// If only Interfaces with empty slots should be shown, check that here
if (itemStack.isEmpty()) {
interfaceHasFreeSlots = true;
}
if (onlyBrokenRecipes && recipeIsBroken(itemStack)) {
interfaceHasBrokenRecipes = true;
}
if ((!searchFieldInputs.isEmpty() && itemStackMatchesSearchTerm(itemStack, searchFieldInputs, 0))
|| (!searchFieldOutputs.isEmpty() && itemStackMatchesSearchTerm(itemStack, searchFieldOutputs, 1))) {
found = true;
matchedStacks.add(itemStack);
}
slot++;
}
}
// if found, filter skipped or machine name matching the search term, add it
if ((searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty()) ||
!searchFieldInputs.isEmpty() && entry.getName().toLowerCase().contains(searchFieldInputs) ||
(!searchFieldOutputs.isEmpty() && entry.getName().toLowerCase().contains(searchFieldOutputs))) {
this.matchedInterfaces.add(entry);
found = true;
}
if (found) {
if (!partInterfaceTerminal.onlyInterfacesWithFreeSlots) {
this.byName.put(entry.getName(), entry);
cachedSearch.add(entry);
} else if (interfaceHasFreeSlots) {
this.byName.put(entry.getName(), entry);
cachedSearch.add(entry);
}
} else {
// Exit if not found
if (!found) {
cachedSearch.remove(entry);
continue;
}
// Exit if the interface does not match the name search
if (!entry.getName().toLowerCase().contains(searchFieldNames)) {
cachedSearch.remove(entry);
continue;
}
// Exit if molecular assembler filter is on and this is not a molecular assembler
// Forge documantation said unlocalized name shouldn't be use for logic, so we might need a better way......
if (onlyMolecularAssemblers && !entry.getUnlocalizedName().equals(MOLECULAR_ASSEMBLER)) {
cachedSearch.remove(entry);
continue;
}
// Exit if we are only showing interfaces with free slots and there are none free in this interface
if (onlyShowWithSpace && !interfaceHasFreeSlots) {
cachedSearch.remove(entry);
continue;
}
// Exit if we are only showing interfaces with broken patterns and there are no broken patterns in this interface
if (onlyBrokenRecipes && !interfaceHasBrokenRecipes) {
cachedSearch.remove(entry);
continue;
}
// Successful search
this.byName.put(entry.getName(), entry);
cachedSearch.add(entry);
}
this.names.clear();
this.names.addAll(this.byName.keySet());
Collections.sort(this.names);
this.lines.clear();
this.lines.ensureCapacity(this.getMaxRows());
this.lines.ensureCapacity(this.names.size() + this.byId.size());
for (final String n : this.names) {
this.lines.add(n);
final ArrayList<ClientDCInternalInv> clientInventories = new ArrayList<>();
clientInventories.addAll(this.byName.get(n));
final ArrayList<ClientDCInternalInv> clientInventories = new ArrayList<>(this.byName.get(n));
Collections.sort(clientInventories);
this.lines.addAll(clientInventories);
}
this.getScrollBar().setRange(0, this.lines.size() - 1, 1);
this.setScrollBar();
}
private boolean recipeIsBroken(final ItemStack stack) {
if (stack == null) return false;
if (stack.isEmpty()) return false;
final NBTTagCompound encodedValue = stack.getTagCompound();
if (encodedValue == null) return true;
final World w = AppEng.proxy.getWorld();
if (w == null) return false;
try {
new PatternHelper(stack, w);
return false;
} catch (Throwable ignored) {
return true;
}
}
private boolean itemStackMatchesSearchTerm(final ItemStack itemStack, final String searchTerm, int pass) {
@@ -624,13 +685,8 @@ public class GuiInterfaceTerminal extends AEBaseGui {
return cache;
}
/**
* The max amount of unique names and each inv row. Not affected by the filtering.
*
* @return max amount of unique names and each inv row
*/
private int getMaxRows() {
return this.names.size() + this.byId.size();
return AEConfig.instance().getConfigManager().getSetting(Settings.TERMINAL_STYLE) != TerminalStyle.TALL ? 6 : Integer.MAX_VALUE;
}
private ClientDCInternalInv getById(final long id, final long sortBy, final String string) {
@@ -643,12 +699,4 @@ public class GuiInterfaceTerminal extends AEBaseGui {
return o;
}
int getReservedSpace() {
return this.reservedSpace;
}
void setReservedSpace(final int reservedSpace) {
this.reservedSpace = reservedSpace;
}
}
@@ -31,11 +31,7 @@ import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.client.ActionKey;
import appeng.client.gui.AEBaseMEGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.ISortSource;
import appeng.client.gui.widgets.MEGuiTextField;
import appeng.client.gui.widgets.*;
import appeng.client.me.InternalSlotME;
import appeng.client.me.ItemRepo;
import appeng.client.me.SlotME;
@@ -61,7 +57,6 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Loader;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
@@ -103,7 +98,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
private int currentMouseY = 0;
private boolean delayedUpdate;
protected int jeiOffset = Loader.isModLoaded("jei") ? 24 : 0;
protected int jeiOffset = Platform.isModLoaded("jei") ? 24 : 0;
public GuiMEMonitorable(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
this(inventoryPlayer, te, new ContainerMEMonitorable(inventoryPlayer, te));
@@ -177,10 +172,9 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(GuiBridge.GUI_CRAFTING_STATUS));
}
if (btn instanceof GuiImgButton) {
if (btn instanceof GuiImgButton iBtn) {
final boolean backwards = Mouse.isButtonDown(1);
final GuiImgButton iBtn = (GuiImgButton) btn;
if (iBtn.getSetting() != Settings.ACTIONS) {
final Enum cv = iBtn.getCurrentValue();
final Enum next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
@@ -467,6 +461,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
}
final boolean mouseInGui = this.isPointInRegion(0, 0, this.xSize, this.ySize, this.currentMouseX, this.currentMouseY);
final boolean wasSearchFieldFocused = this.searchField.isFocused();
if (this.isAutoFocus && !this.searchField.isFocused() && mouseInGui) {
this.searchField.setFocused(true);
@@ -478,6 +473,10 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
// tell forge the key event is handled and should not be sent out
this.keyHandled = mouseInGui;
} else {
if (!wasSearchFieldFocused) {
// prevent unhandled keys (like shift) from focusing the search field
searchField.setFocused(false);
}
super.keyTyped(character, key);
}
}
@@ -20,13 +20,14 @@ package appeng.client.gui.implementations;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.container.implementations.ContainerMEPortableCell;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiMEPortableCell extends GuiMEMonitorable {
public GuiMEPortableCell(final InventoryPlayer inventoryPlayer, final IPortableCell te) {
super(inventoryPlayer, te);
super(inventoryPlayer, te, new ContainerMEPortableCell(inventoryPlayer, te));
}
@Override
@@ -4,7 +4,6 @@ import appeng.api.config.AccessRestriction;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.api.config.StorageFilter;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.MEGuiTextField;
@@ -27,7 +26,7 @@ import java.io.IOException;
import java.util.regex.Pattern;
public class GuiOreDictStorageBus extends AEBaseGui {
public class GuiOreDictStorageBus extends GuiUpgradeable {
private final ContainerOreDictStorageBus container;
PartOreDicStorageBus part;
private GuiTabButton priority;
@@ -41,13 +40,11 @@ public class GuiOreDictStorageBus extends AEBaseGui {
super(new ContainerOreDictStorageBus(inventoryPlayer, te));
this.container = (ContainerOreDictStorageBus) super.inventorySlots;
part = te;
this.ySize = 84;
this.ySize = 170;
}
@Override
public void initGui() {
super.initGui();
protected void addButtons() {
this.searchFieldInputs = new MEGuiTextField(this.fontRenderer, this.guiLeft + 3, this.guiTop + 22, 170, 12);
this.searchFieldInputs.setEnableBackgroundDrawing(false);
this.searchFieldInputs.setMaxStringLength(512);
@@ -66,7 +63,6 @@ public class GuiOreDictStorageBus extends AEBaseGui {
} catch (IOException e) {
e.printStackTrace();
}
}
public void fillRegex(String regex) {
@@ -143,10 +139,13 @@ public class GuiOreDictStorageBus extends AEBaseGui {
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.bindTexture("guis/oredictstoragebus.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, 175, 85);
protected String getBackground() {
return "guis/oredictstoragebus.png";
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
super.drawBG(offsetX, offsetY, mouseX, mouseY);
if (this.searchFieldInputs != null) {
this.searchFieldInputs.drawTextBox();
}
@@ -47,6 +47,7 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import org.lwjgl.input.Mouse;
import javax.annotation.Nonnull;
import java.awt.*;
import java.io.IOException;
import java.util.List;
@@ -54,7 +55,7 @@ import java.util.*;
public class GuiUpgradeable extends AEBaseGui implements IJEIGhostIngredients {
private final Map<Target<?>, Object> mapTargetSlot = new HashMap<>();
protected final Map<Target<?>, Object> mapTargetSlot = new HashMap<>();
protected final ContainerUpgradeable cvb;
protected final IUpgradeableHost bc;
@@ -218,24 +219,25 @@ public class GuiUpgradeable extends AEBaseGui implements IJEIGhostIngredients {
List<Target<?>> targets = new ArrayList<>();
List<IJEITargetSlot> slots = new ArrayList<>();
if (this.inventorySlots.inventorySlots.size() > 0) {
if (!this.inventorySlots.inventorySlots.isEmpty()) {
for (Slot slot : this.inventorySlots.inventorySlots) {
if (slot instanceof SlotFake && (!itemStack.isEmpty() || this instanceof GuiCellWorkbench && fluidStack != null)) {
slots.add((IJEITargetSlot) slot);
}
}
}
if (this.getGuiSlots().size() > 0) {
if (!this.getGuiSlots().isEmpty()) {
for (GuiCustomSlot slot : this.getGuiSlots()) {
if (slot instanceof GuiFluidSlot && fluidStack != null) {
slots.add((IJEITargetSlot) slot);
}
}
}
for (Object slot : slots) {
for (IJEITargetSlot slot : slots) {
ItemStack finalItemStack = itemStack;
FluidStack finalFluidStack = fluidStack;
Target<Object> targetItem = new Target<Object>() {
Target<Object> targetItem = new Target<>() {
@Nonnull
@Override
public Rectangle getArea() {
if (slot instanceof SlotFake && ((SlotFake) slot).isSlotEnabled()) {
@@ -247,20 +249,20 @@ public class GuiUpgradeable extends AEBaseGui implements IJEIGhostIngredients {
}
@Override
public void accept(Object ingredient) {
public void accept(@Nonnull Object ingredient) {
PacketInventoryAction p = null;
try {
if (slot instanceof SlotFake && ((SlotFake) slot).isSlotEnabled()) {
if (finalItemStack.isEmpty() && finalFluidStack != null) {
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, (IJEITargetSlot) slot, AEItemStack.fromItemStack(FluidUtil.getFilledBucket(finalFluidStack)));
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, slot, AEItemStack.fromItemStack(FluidUtil.getFilledBucket(finalFluidStack)));
} else if (!finalItemStack.isEmpty()) {
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, (IJEITargetSlot) slot, AEItemStack.fromItemStack(finalItemStack));
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, slot, AEItemStack.fromItemStack(finalItemStack));
}
} else {
if (finalFluidStack == null) {
return;
}
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, (IJEITargetSlot) slot, AEItemStack.fromItemStack(AEFluidStack.fromFluidStack(finalFluidStack).asItemStackRepresentation()));
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, slot, AEItemStack.fromItemStack(AEFluidStack.fromFluidStack(finalFluidStack).asItemStackRepresentation()));
}
NetworkHandler.instance().sendToServer(p);
@@ -0,0 +1,18 @@
package appeng.client.gui.implementations;
import appeng.helpers.WirelessTerminalGuiObject;
import net.minecraft.client.gui.Gui;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiWirelessInterfaceTerminal extends GuiInterfaceTerminal {
public GuiWirelessInterfaceTerminal(InventoryPlayer inventoryPlayer, final WirelessTerminalGuiObject te) {
super(inventoryPlayer, te);
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.bindTexture("guis/wirelessupgrades.png");
Gui.drawModalRectWithCustomSizedTexture(offsetX + 189, offsetY + 165, 0, 0, 32, 32, 32, 32);
super.drawBG(offsetX, offsetY, mouseX, mouseY);
}
}
@@ -1,13 +1,14 @@
package appeng.client.gui.widgets;
import appeng.container.interfaces.ISpecialSlotIngredient;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public abstract class GuiCustomSlot extends Gui implements ITooltip {
public abstract class GuiCustomSlot extends Gui implements ITooltip, ISpecialSlotIngredient {
protected final int x;
protected final int y;
protected final int id;
@@ -68,4 +69,9 @@ public abstract class GuiCustomSlot extends Gui implements ITooltip {
return true;
}
@Override
public Object getIngredient() {
return null;
}
}
@@ -116,10 +116,13 @@ public class GuiImgButton extends GuiButton implements ITooltip {
this.registerApp(11 + 4 * 16, Settings.ACTIONS, ActionItems.DECREASE_BY_ONE, ButtonToolTips.DecreaseByOne, ButtonToolTips.DecreaseByOneDesc);
this.registerApp(12 + 4 * 16, Settings.ACTIONS, ActionItems.MAX_COUNT, ButtonToolTips.MaxCount, ButtonToolTips.MaxCountDesc);
this.registerApp(6 + 5 * 16, Settings.ACTIONS, ActionItems.FREE_MOLECULAR_SLOT_SHORTCUT, ButtonToolTips.FreeMolecularSlotShortcut, ButtonToolTips.FreeMolecularSlotShortcutDesc);
this.registerApp(6 + 5 * 16, Settings.ACTIONS, ActionItems.MOLECULAR_ASSEMBLERS_ON, ButtonToolTips.ToggleMolecularAssemblers, ButtonToolTips.ToggleMolecularAssemblersOnDesc);
this.registerApp(7 + 5 * 16, Settings.ACTIONS, ActionItems.TOGGLE_SHOW_FULL_INTERFACES_ON, ButtonToolTips.ToggleShowFullInterfaces, ButtonToolTips.ToggleShowFullInterfacesOnDesc);
this.registerApp(8 + 5 * 16, Settings.ACTIONS, ActionItems.TOGGLE_SHOW_FULL_INTERFACES_OFF, ButtonToolTips.ToggleShowFullInterfaces, ButtonToolTips.ToggleShowFullInterfacesOffDesc);
this.registerApp(9 + 5 * 16, Settings.ACTIONS, ActionItems.MOLECULAR_ASSEMBLERS_OFF, ButtonToolTips.ToggleMolecularAssemblers, ButtonToolTips.ToggleMolecularAssemblersOffDesc);
this.registerApp(6 + 6 * 16, Settings.ACTIONS, ActionItems.HIGHLIGHT_INTERFACE, ButtonToolTips.HighlightInterface, "");
this.registerApp(4 + 5 * 16, Settings.ACTIONS, ActionItems.TOGGLE_SHOW_ONLY_INVALID_PATTERNS_OFF, ButtonToolTips.ToggleShowOnlyInvalidInterface, ButtonToolTips.ToggleShowOnlyInvalidInterfaceOffDesc);
this.registerApp(5 + 5 * 16, Settings.ACTIONS, ActionItems.TOGGLE_SHOW_ONLY_INVALID_PATTERNS_ON, ButtonToolTips.ToggleShowOnlyInvalidInterface, ButtonToolTips.ToggleShowOnlyInvalidInterfaceOnDesc);
this.registerApp(8, Settings.ACTIONS, ActionItems.ENCODE, ButtonToolTips.Encode, ButtonToolTips.EncodeDescription);
this.registerApp(4 + 3 * 16, Settings.ACTIONS, ItemSubstitution.ENABLED, ButtonToolTips.Substitutions, ButtonToolTips.SubstitutionsDescEnabled);
@@ -157,6 +160,12 @@ public class GuiImgButton extends GuiButton implements ITooltip {
this.registerApp(16 * 15, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT, ButtonToolTips.SchedulingMode, ButtonToolTips.SchedulingModeDefault);
this.registerApp(16 * 15 + 1, Settings.SCHEDULING_MODE, SchedulingMode.ROUNDROBIN, ButtonToolTips.SchedulingMode, ButtonToolTips.SchedulingModeRoundRobin);
this.registerApp(16 * 15 + 2, Settings.SCHEDULING_MODE, SchedulingMode.RANDOM, ButtonToolTips.SchedulingMode, ButtonToolTips.SchedulingModeRandom);
this.registerApp(10, Settings.UNLOCK,LockCraftingMode.NONE,ButtonToolTips.LockCraftingMode, ButtonToolTips.LockCraftingModeNone);
this.registerApp(7, Settings.UNLOCK,LockCraftingMode.LOCK_UNTIL_RESULT,ButtonToolTips.LockCraftingMode, ButtonToolTips.LockCraftingUntilResultReturned);
this.registerApp(0, Settings.UNLOCK, LockCraftingMode.LOCK_WHILE_LOW, ButtonToolTips.LockCraftingMode, ButtonToolTips.LockCraftingWhileRedstoneLow);
this.registerApp(1, Settings.UNLOCK, LockCraftingMode.LOCK_WHILE_HIGH, ButtonToolTips.LockCraftingMode, ButtonToolTips.LockCraftingWhileRedstoneHigh);
this.registerApp(2, Settings.UNLOCK, LockCraftingMode.LOCK_UNTIL_PULSE, ButtonToolTips.LockCraftingMode, ButtonToolTips.LockCraftingUntilRedstonePulse);
}
}
@@ -336,7 +345,7 @@ public class GuiImgButton extends GuiButton implements ITooltip {
this.fillVar = fillVar;
}
private static final class EnumPair {
public static final class EnumPair {
final Enum setting;
final Enum value;
@@ -0,0 +1,142 @@
package appeng.client.gui.widgets;
import appeng.api.config.LockCraftingMode;
import appeng.api.config.Settings;
import appeng.core.localization.GuiText;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiLabel;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import java.util.HashMap;
import java.util.Map;
public class GuiImgLabel extends GuiLabel implements ITooltip {
public GuiImgLabel(FontRenderer fontRendererObj, final int x, final int y, final Enum idx, final Enum val) {
super(fontRendererObj, 0, x, y, 16, 16, 0);
this.currentValue = val;
this.labelSetting = idx;
this.fontRenderer = fontRendererObj;
if (appearances == null) {
appearances = new HashMap<>();
registerApp(10, Settings.UNLOCK, LockCraftingMode.NONE, GuiText.NoneLock, null, 0x00FF00);
registerApp(9, Settings.UNLOCK, LockCraftingMode.LOCK_WHILE_LOW, GuiText.CraftingLock, GuiText.LowRedstoneLock, 0xFF0000);
registerApp(9, Settings.UNLOCK, LockCraftingMode.LOCK_WHILE_HIGH, GuiText.CraftingLock, GuiText.HighRedstoneLock, 0xFF0000);
registerApp(9, Settings.UNLOCK, LockCraftingMode.LOCK_UNTIL_PULSE, GuiText.CraftingLock, GuiText.UntilPulseUnlock, 0xFF0000);
registerApp(9, Settings.UNLOCK, LockCraftingMode.LOCK_UNTIL_RESULT, GuiText.CraftingLock, GuiText.ResultLock, 0xFF0000);
}
}
private final Enum labelSetting;
private Enum currentValue;
private static Map<GuiImgButton.EnumPair, LabelAppearance> appearances;
private final FontRenderer fontRenderer;
public void setVisibility(final boolean vis) {
this.visible = vis;
}
@Override
public void drawLabel(Minecraft mc, int mouseX, int mouseY) {
if (this.visible) {
final int iconIndex = this.getIconIndex();
if (iconIndex == -1) {
return;
}
mc.renderEngine.bindTexture(new ResourceLocation("appliedenergistics2", "textures/guis/states.png"));
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
final int uv_y = (int) Math.floor(iconIndex / 16);
final int uv_x = iconIndex - uv_y * 16;
this.drawTexturedModalRect(this.x, this.y, uv_x * 16, uv_y * 16, 16, 16);
if (labelSetting != null && currentValue != null) {
LabelAppearance labelAppearance = appearances.get(new GuiImgButton.EnumPair(this.labelSetting, this.currentValue));
String translated = I18n.translateToLocal(labelAppearance.displayLabel);
fontRenderer.drawString(translated, x + 16, y + 5, labelAppearance.color);
width = 16 + fontRenderer.getStringWidth(translated);
}
}
}
private int getIconIndex() {
if (this.labelSetting != null && this.currentValue != null) {
final LabelAppearance app = appearances.get(new GuiImgButton.EnumPair(this.labelSetting, this.currentValue));
if (app == null) {
return -1;
}
return app.index;
}
return -1;
}
private void registerApp(final int iconIndex, final Settings setting, final Enum val, final GuiText label, final Object hint, int color) {
final LabelAppearance a = new LabelAppearance();
if (hint != null) {
a.hiddenValue = (String) (hint instanceof String ? hint : ((GuiText) hint).getUnlocalized());
} else {
a.hiddenValue = null;
}
a.index = iconIndex;
a.displayLabel = label.getUnlocalized();
a.color = color;
appearances.put(new GuiImgButton.EnumPair(setting, val), a);
}
@Override
public String getMessage() {
if (labelSetting != null && this.currentValue != null) {
LabelAppearance labelAppearance = appearances.get(new GuiImgButton.EnumPair(this.labelSetting, this.currentValue));
if (labelAppearance == null) {
return "No Such Message";
}
if (labelAppearance.hiddenValue != null) {
return I18n.translateToLocal(labelAppearance.hiddenValue);
}
}
return null;
}
public void set(final Enum e) {
if (this.currentValue != e) {
this.currentValue = e;
}
}
@Override
public int xPos() {
return x;
}
@Override
public int yPos() {
return y;
}
@Override
public int getWidth() {
return width;
}
@Override
public int getHeight() {
return height;
}
@Override
public boolean isVisible() {
return visible;
}
private static class LabelAppearance {
public int index;
public String displayLabel;
public String hiddenValue;
public int color;
}
}
@@ -0,0 +1,236 @@
package appeng.client.gui.widgets;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiTextField;
import org.lwjgl.input.Keyboard;
/**
* Different implementation of a text field that wraps instead of extends
* MC's {@link GuiTextField}. This is necessary because of deobfuscated name
* collision between {@link ITooltip} and GuiTextField, which would cause
* crashes in an obfuscated environment. Additionally, since we are not extending that
* class, we can construct this object differently and allow its position to be
* mutable like most other widgets.
*/
public class MEGuiTooltipTextField implements ITooltip {
protected GuiTextField field;
private static final int PADDING = 2;
private static boolean previousKeyboardRepeatEnabled;
private static MEGuiTooltipTextField previousKeyboardRepeatEnabledField;
private String tooltip;
private int fontPad;
public int x;
public int y;
public int w;
public int h;
/**
* Uses the values to instantiate a padded version of a text field. Pays attention to the '_' caret.
*
* @param width absolute width
* @param height absolute height
* @param tooltip tooltip message
*/
public MEGuiTooltipTextField(final int width, final int height, final String tooltip) {
final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
field = new GuiTextField(0, fontRenderer, 0, 0, 0, 0);
w = width;
h = height;
setMessage(tooltip);
this.fontPad = fontRenderer.getCharWidth('_');
setDimensionsAndColor();
}
public MEGuiTooltipTextField(final int width, final int height) {
this(width, height, "");
}
public MEGuiTooltipTextField() {
this(0, 0);
}
protected void setDimensionsAndColor() {
field.x = this.x + PADDING;
field.y = this.y + PADDING;
field.width = this.w - PADDING * 2 - this.fontPad;
field.height = this.h - PADDING * 2;
}
public void onTextChange(final String oldText) {}
public void mouseClicked(final int xPos, final int yPos, final int button) {
if (!this.isMouseIn(xPos, yPos)) {
setFocused(false);
return;
}
field.setCanLoseFocus(false);
setFocused(true);
if (button == 1) {
setText("");
} else {
field.mouseClicked(xPos, yPos, button);
}
field.setCanLoseFocus(true);
}
/**
* Checks if the mouse is within the element
*
* @param xCoord current x coord of the mouse
* @param yCoord current y coord of the mouse
* @return true if mouse position is within the getText field area
*/
public boolean isMouseIn(final int xCoord, final int yCoord) {
final boolean withinXRange = this.x <= xCoord && xCoord < this.x + this.w;
final boolean withinYRange = this.y <= yCoord && yCoord < this.y + this.h;
return withinXRange && withinYRange;
}
public boolean textboxKeyTyped(final char keyChar, final int keyID) {
if (!isFocused()) {
return false;
}
final String oldText = getText();
boolean handled = field.textboxKeyTyped(keyChar, keyID);
if (!handled && (keyID == Keyboard.KEY_RETURN || keyID == Keyboard.KEY_NUMPADENTER
|| keyID == Keyboard.KEY_ESCAPE)) {
setFocused(false);
}
if (handled) {
onTextChange(oldText);
}
return handled;
}
public void drawTextBox() {
if (field.getVisible()) {
setDimensionsAndColor();
GuiTextField.drawRect(
this.x + 1,
this.y + 1,
this.x + this.w - 1,
this.y + this.h - 1,
isFocused() ? 0xFF606060 : 0xFFA8A8A8);
field.drawTextBox();
}
}
public void setText(String text, boolean ignoreTrigger) {
final String oldText = getText();
int currentCursorPos = field.getCursorPosition();
field.setText(text);
field.setCursorPosition(currentCursorPos);
if (!ignoreTrigger) {
onTextChange(oldText);
}
}
public void setText(String text) {
setText(text, false);
}
public void setCursorPositionEnd() {
field.setCursorPositionEnd();
}
public void setFocused(boolean focus) {
if (field.isFocused() == focus) {
return;
}
field.setFocused(focus);
if (focus) {
if (previousKeyboardRepeatEnabledField == null) {
previousKeyboardRepeatEnabled = Keyboard.areRepeatEventsEnabled();
}
previousKeyboardRepeatEnabledField = this;
Keyboard.enableRepeatEvents(true);
} else {
if (previousKeyboardRepeatEnabledField == this) {
previousKeyboardRepeatEnabledField = null;
Keyboard.enableRepeatEvents(previousKeyboardRepeatEnabled);
}
}
}
public void setMaxStringLength(final int size) {
field.setMaxStringLength(size);
}
public void setEnableBackgroundDrawing(final boolean b) {
field.setEnableBackgroundDrawing(b);
}
public void setTextColor(final int color) {
field.setTextColor(color);
}
public void setCursorPositionZero() {
field.setCursorPositionZero();
}
public boolean isFocused() {
return field.isFocused();
}
public String getText() {
return field.getText();
}
public void setMessage(String t) {
tooltip = t;
}
@Override
public String getMessage() {
return tooltip;
}
@Override
public boolean isVisible() {
return field.getVisible();
}
@Override
public int xPos() {
return x;
}
@Override
public int yPos() {
return y;
}
@Override
public int getWidth() {
return w;
}
@Override
public int getHeight() {
return h;
}
}
@@ -55,6 +55,10 @@ public class ClientDCInternalInv implements Comparable<ClientDCInternalInv> {
return s;
}
public String getUnlocalizedName() {
return this.unlocalizedName;
}
@Override
public int compareTo(@Nonnull final ClientDCInternalInv o) {
return Long.compare(this.sortBy, o.sortBy);
@@ -20,11 +20,13 @@ package appeng.client.me;
import appeng.api.storage.data.IAEFluidStack;
import appeng.container.interfaces.ISpecialSlotIngredient;
import appeng.fluids.container.slots.IMEFluidSlot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.SlotItemHandler;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nonnull;
@@ -34,7 +36,7 @@ import javax.annotation.Nonnull;
* @version rv6 - 22/05/2018
* @since rv6 22/05/2018
*/
public class SlotFluidME extends SlotItemHandler implements IMEFluidSlot {
public class SlotFluidME extends SlotItemHandler implements IMEFluidSlot, ISpecialSlotIngredient {
private final InternalFluidSlotME slot;
@@ -95,4 +97,11 @@ public class SlotFluidME extends SlotItemHandler implements IMEFluidSlot {
public boolean canTakeStack(final EntityPlayer par1EntityPlayer) {
return false;
}
@Nullable
@Override
public Object getIngredient() {
return this.getAEFluidStack() == null ? null : this.getAEFluidStack().getFluidStack();
}
}
@@ -24,6 +24,10 @@ import appeng.api.parts.IPartModel;
import appeng.api.util.AECableType;
import appeng.api.util.AEColor;
import appeng.block.networking.BlockCableBus;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.cache.Weigher;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.BakedQuad;
@@ -38,6 +42,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.property.IExtendedBlockState;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.*;
import java.util.Map.Entry;
@@ -45,8 +50,6 @@ import java.util.Map.Entry;
public class CableBusBakedModel implements IBakedModel {
static final Map<CableBusRenderState, List<BakedQuad>> CABLE_MODEL_CACHE = new HashMap<>();
private final CableBuilder cableBuilder;
private final FacadeBuilder facadeBuilder;
@@ -57,11 +60,24 @@ public class CableBusBakedModel implements IBakedModel {
private final TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks();
private final LoadingCache<CableBusRenderState, List<BakedQuad>> cableModelCache;
CableBusBakedModel(CableBuilder cableBuilder, FacadeBuilder facadeBuilder, Map<ResourceLocation, IBakedModel> partModels, TextureAtlasSprite particleTexture) {
this.cableBuilder = cableBuilder;
this.facadeBuilder = facadeBuilder;
this.partModels = partModels;
this.particleTexture = particleTexture;
this.cableModelCache = CacheBuilder.newBuilder()
.maximumWeight(5000)
.weigher((Weigher<CableBusRenderState, List<BakedQuad>>) (k, v) -> v.size())
.build(new CacheLoader<>() {
@Override
public List<BakedQuad> load(@Nonnull CableBusRenderState rs) {
final List<BakedQuad> model = new ArrayList<>();
addCableQuads(rs, model);
return model;
}
});
}
@Override
@@ -82,12 +98,7 @@ public class CableBusBakedModel implements IBakedModel {
if (layer == BlockRenderLayer.CUTOUT) {
// First, handle the cable at the center of the cable bus
final List<BakedQuad> cableModel = CABLE_MODEL_CACHE.computeIfAbsent(renderState, k ->
{
final List<BakedQuad> model = new ArrayList<>();
this.addCableQuads(renderState, model);
return model;
});
final List<BakedQuad> cableModel = cableModelCache.getUnchecked(renderState);
quads.addAll(cableModel);
// Then handle attachments
@@ -27,26 +27,21 @@ import com.google.common.collect.ImmutableMap;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.client.resource.IResourceType;
import net.minecraftforge.client.resource.ISelectiveResourceReloadListener;
import net.minecraftforge.client.resource.VanillaResourceType;
import net.minecraftforge.common.model.IModelState;
import net.minecraftforge.common.model.TRSRTransformation;
import java.util.Collection;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Predicate;
/**
* The built-in model for the cable bus block.
*/
public class CableBusModel implements IModel, ISelectiveResourceReloadListener {
public class CableBusModel implements IModel {
private final PartModels partModels;
@@ -106,12 +101,4 @@ public class CableBusModel implements IModel, ISelectiveResourceReloadListener {
public IModelState getDefaultState() {
return TRSRTransformation.identity();
}
@Override
public void onResourceManagerReload(IResourceManager resourceManager, Predicate<IResourceType> resourcePredicate) {
if (resourcePredicate.test(VanillaResourceType.MODELS)) {
CableBusBakedModel.CABLE_MODEL_CACHE.clear();
}
}
}
@@ -1,7 +1,6 @@
package appeng.client.render.model;
import com.google.common.collect.ImmutableMap;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
@@ -9,9 +8,8 @@ import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.client.model.PerspectiveMapWrapper;
import net.minecraftforge.common.model.TRSRTransformation;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import javax.vecmath.Matrix4f;
@@ -24,15 +22,12 @@ class ColorApplicatorBakedModel implements IBakedModel {
private final IBakedModel baseModel;
private final ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms;
private final EnumMap<EnumFacing, List<BakedQuad>> quadsBySide;
private final List<BakedQuad> generalQuads;
ColorApplicatorBakedModel(IBakedModel baseModel, ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> map, TextureAtlasSprite texDark, TextureAtlasSprite texMedium, TextureAtlasSprite texBright) {
ColorApplicatorBakedModel(IBakedModel baseModel, TextureAtlasSprite texDark, TextureAtlasSprite texMedium, TextureAtlasSprite texBright) {
this.baseModel = baseModel;
this.transforms = map;
// Put the tint indices in... Since this is an item model, we are ignoring rand
this.generalQuads = this.fixQuadTint(null, texDark, texMedium, texBright);
@@ -68,7 +63,7 @@ class ColorApplicatorBakedModel implements IBakedModel {
}
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
public @NotNull List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
if (side == null) {
return this.generalQuads;
}
@@ -91,22 +86,22 @@ class ColorApplicatorBakedModel implements IBakedModel {
}
@Override
public TextureAtlasSprite getParticleTexture() {
public @NotNull TextureAtlasSprite getParticleTexture() {
return this.baseModel.getParticleTexture();
}
@Override
public ItemCameraTransforms getItemCameraTransforms() {
public @NotNull ItemCameraTransforms getItemCameraTransforms() {
return this.baseModel.getItemCameraTransforms();
}
@Override
public ItemOverrideList getOverrides() {
public @NotNull ItemOverrideList getOverrides() {
return this.baseModel.getOverrides();
}
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType type) {
return PerspectiveMapWrapper.handlePerspective(this, this.transforms, type);
public @NotNull Pair<? extends IBakedModel, Matrix4f> handlePerspective(@NotNull ItemCameraTransforms.TransformType type) {
return this.baseModel.handlePerspective(type);
}
}
@@ -55,7 +55,7 @@ public class ColorApplicatorModel implements IModel {
ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> map = PerspectiveMapWrapper.getTransforms(state);
return new ColorApplicatorBakedModel(baseModel, map, texDark, texMedium, texBright);
return new ColorApplicatorBakedModel(baseModel, texDark, texMedium, texBright);
}
private IBakedModel getBaseModel(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
@@ -60,6 +60,9 @@ public class DriveBakedModel implements IBakedModel {
}
DriveSlotsState slotsState = extState.getValue(BlockDrive.SLOTS_STATE);
if (slotsState == null) {
return result;
}
for (int row = 0; row < 5; row++) {
for (int col = 0; col < 2; col++) {
@@ -90,6 +93,7 @@ public class DriveBakedModel implements IBakedModel {
}
}
return result;
}
@@ -399,9 +399,17 @@ public abstract class AEBaseContainer extends Container {
return ItemStack.EMPTY; // don't insert duplicate encoded patterns to interfaces
}
int maxSize = Math.min(tis.getMaxStackSize(), d.getSlotStackLimit());
final int maxSize;
if (d instanceof SlotOversized slotOversized) {
maxSize = slotOversized.getSlotStackLimit();
} else {
maxSize = Math.min(tis.getMaxStackSize(), d.getSlotStackLimit());
}
int placeAble = maxSize - t.getCount();
if (placeAble <= 0) {
continue;
}
if (tis.getCount() < placeAble) {
placeAble = tis.getCount();
@@ -953,9 +961,13 @@ public abstract class AEBaseContainer extends Container {
@Override
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, @NotNull EntityPlayer player) {
if (slotId >= 0 && clickTypeIn == ClickType.PICKUP) {
if (slotId >= 0) {
final var slot = this.getSlot(slotId);
if (slot instanceof AppEngSlot appEngSlot) {
if (slot instanceof SlotDisabled) {
return ItemStack.EMPTY;
}
if (slot instanceof AppEngSlot appEngSlot && clickTypeIn == ClickType.PICKUP) {
var slotStack = slot.getStack();
var draggedStack = this.invPlayer.getItemStack();
@@ -31,7 +31,7 @@ import appeng.api.networking.crafting.ICraftingLink;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
@@ -213,7 +213,7 @@ public class ContainerCraftConfirm extends AEBaseContainer {
p.setStackSize(out.getCountRequestable());
final IStorageGrid sg = grid.getCache(IStorageGrid.class);
final IMEInventory<IAEItemStack> items = sg.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
final IMEMonitor<IAEItemStack> items = sg.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
IAEItemStack m = null;
if (c != null && this.result.isSimulation()) {
@@ -330,8 +330,7 @@ public class ContainerCraftConfirm extends AEBaseContainer {
if (te != null) {
Platform.openGUI(this.getInventoryPlayer().player, te, this.getOpenContext().getSide(), originalGui);
} else {
if (ah instanceof IInventorySlotAware) {
IInventorySlotAware i = ((IInventorySlotAware) ah);
if (ah instanceof IInventorySlotAware i) {
Platform.openGUI(this.getInventoryPlayer().player, i.getInventorySlot(), originalGui, i.isBaubleSlot());
}
}
@@ -116,15 +116,19 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
boolean matches = false;
for (final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes()) {
final boolean matchA = !top
.isEmpty() && (Platform.itemComparisons().isSameItem(top, recipe.getTopOptional().orElse(ItemStack.EMPTY)) || Platform
.itemComparisons()
.isSameItem(top, recipe.getBottomOptional().orElse(ItemStack.EMPTY)));
final boolean matchB = !bot
.isEmpty() && (Platform.itemComparisons().isSameItem(bot, recipe.getTopOptional().orElse(ItemStack.EMPTY)) || Platform
.itemComparisons()
.isSameItem(bot, recipe.getBottomOptional().orElse(ItemStack.EMPTY)));
// Check if plateA matches any item in the list of top components of the recipe
final boolean matchA = top.isEmpty() && recipe.getTopInputs().isEmpty() ||
recipe.getTopInputs().stream().anyMatch(topItem -> Platform.itemComparisons().isSameItem(top, topItem)) &&
(bot.isEmpty() && recipe.getBottomInputs().isEmpty() ||
recipe.getBottomInputs().stream().anyMatch(bottomItem -> Platform.itemComparisons().isSameItem(bot, bottomItem)));
// Check if plateB matches any item in the list of top components of the recipe
final boolean matchB = bot.isEmpty() && recipe.getTopInputs().isEmpty() ||
recipe.getTopInputs().stream().anyMatch(topItem -> Platform.itemComparisons().isSameItem(bot, topItem)) &&
(top.isEmpty() && recipe.getBottomInputs().isEmpty() ||
recipe.getBottomInputs().stream().anyMatch(bottomItem -> Platform.itemComparisons().isSameItem(top, bottomItem)));
// If either matchA or matchB is true, iterate through the recipe's inputs
if (matchA || matchB) {
matches = true;
for (final ItemStack option : recipe.getInputs()) {
@@ -152,10 +156,22 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
// everything else
for (final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes()) {
boolean isValid = false;
if (Platform.itemComparisons().isSameItem(otherSlot, recipe.getTopOptional().orElse(ItemStack.EMPTY))) {
isValid = Platform.itemComparisons().isSameItem(is, recipe.getBottomOptional().orElse(ItemStack.EMPTY));
} else if (Platform.itemComparisons().isSameItem(otherSlot, recipe.getBottomOptional().orElse(ItemStack.EMPTY))) {
isValid = Platform.itemComparisons().isSameItem(is, recipe.getTopOptional().orElse(ItemStack.EMPTY));
// Check if otherSlot matches any item in the top component list
boolean matchTop = recipe.getTopInputs().stream()
.anyMatch(topItem -> Platform.itemComparisons().isSameItem(otherSlot, topItem));
// Check if otherSlot matches any item in the bottom component list
boolean matchBottom = recipe.getBottomInputs().stream()
.anyMatch(bottomItem -> Platform.itemComparisons().isSameItem(otherSlot, bottomItem));
if (matchTop) {
// If otherSlot matches a top component, check if 'is' matches any item in the bottom component list
isValid = recipe.getBottomInputs().stream()
.anyMatch(bottomItem -> Platform.itemComparisons().isSameItem(is, bottomItem));
} else if (matchBottom) {
// If otherSlot matches a bottom component, check if 'is' matches any item in the top component list
isValid = recipe.getTopInputs().stream()
.anyMatch(topItem -> Platform.itemComparisons().isSameItem(is, topItem));
}
if (isValid) {
@@ -19,10 +19,7 @@
package appeng.container.implementations;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
import appeng.api.config.YesNo;
import appeng.api.config.*;
import appeng.api.util.IConfigManager;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.*;
@@ -40,11 +37,17 @@ public class ContainerInterface extends ContainerUpgradeable implements IOptiona
public YesNo bMode = YesNo.NO;
@GuiSync(4)
public YesNo iTermMode = YesNo.YES;
public LockCraftingMode lMode = LockCraftingMode.NONE;
@GuiSync(7)
public int patternExpansions = 0;
@GuiSync(8)
public YesNo iTermMode = YesNo.YES;
@GuiSync(9)
public LockCraftingMode lockReason = LockCraftingMode.NONE;
public ContainerInterface(final InventoryPlayer ip, final IInterfaceHost te) {
super(ip, te.getInterfaceDuality().getHost());
@@ -94,6 +97,10 @@ public class ContainerInterface extends ContainerUpgradeable implements IOptiona
patternExpansions = getPatternUpgrades();
this.myDuality.dropExcessPatterns();
}
if (Platform.isServer()){
lockReason = myDuality.getCraftingLockedReason();
}
super.detectAndSendChanges();
}
@@ -107,9 +114,14 @@ public class ContainerInterface extends ContainerUpgradeable implements IOptiona
@Override
protected void loadSettingsFromHost(final IConfigManager cm) {
this.setBlockingMode((YesNo) cm.getSetting(Settings.BLOCK));
this.setUnlockMode((LockCraftingMode) cm.getSetting(Settings.UNLOCK));
this.setInterfaceTerminalMode((YesNo) cm.getSetting(Settings.INTERFACE_TERMINAL));
}
public LockCraftingMode getUnlockMode() {return this.lMode;}
public void setUnlockMode(final LockCraftingMode mode) {this.lMode = mode;}
public YesNo getBlockingMode() {
return this.bMode;
}
@@ -129,4 +141,8 @@ public class ContainerInterface extends ContainerUpgradeable implements IOptiona
public int getPatternUpgrades() {
return this.myDuality.getInstalledUpgrades(Upgrades.PATTERN_EXPANSION);
}
public LockCraftingMode getCraftingLockedReason() {
return lockReason;
}
}
@@ -34,6 +34,7 @@ import appeng.core.sync.packets.PacketInventoryAction;
import appeng.helpers.DualityInterface;
import appeng.helpers.IInterfaceHost;
import appeng.helpers.InventoryAction;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.items.misc.ItemEncodedPattern;
import appeng.parts.misc.PartInterface;
import appeng.parts.reporting.PartInterfaceTerminal;
@@ -65,7 +66,7 @@ import java.util.Map.Entry;
import static appeng.helpers.ItemStackHelper.stackWriteToNBT;
public final class ContainerInterfaceTerminal extends AEBaseContainer {
public class ContainerInterfaceTerminal extends AEBaseContainer {
/**
* this stuff is all server side..
@@ -87,6 +88,21 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer {
this.bindPlayerInventory(ip, 0, 0);
}
public ContainerInterfaceTerminal(final InventoryPlayer ip, final WirelessTerminalGuiObject guiObject, boolean bindInventory) {
super(ip, guiObject);
if (Platform.isServer()) {
IGridNode node = guiObject.getActionableNode();
if (node != null && node.isActive()) {
this.grid = node.getGrid();
}
}
if (bindInventory) {
this.bindPlayerInventory(ip, 0, 0);
}
}
@Override
public void detectAndSendChanges() {
if (Platform.isClient()) {
@@ -185,14 +201,16 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer {
final AppEngSlot playerSlot;
try {
playerSlot = (AppEngSlot) this.inventorySlots.get(slot);
} catch (IndexOutOfBoundsException ignored) { return; }
} catch (IndexOutOfBoundsException ignored) {
return;
}
if (!playerSlot.isPlayerSide() || !playerSlot.getHasStack()) return;
var itemStack = playerSlot.getStack();
if (!itemStack.isEmpty()) {
var handler = new WrapperFilteredItemHandler(
new WrapperRangeItemHandler(inv.server, 0, 9 * (inv.numUpgrades + 1)), new PatternSlotFilter());
new WrapperRangeItemHandler(inv.server, 0, 9 * (inv.numUpgrades + 1)), new PatternSlotFilter());
playerSlot.putStack(ItemHandlerHelper.insertItem(handler, itemStack, false));
detectAndSendChanges();
}
@@ -388,7 +406,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer {
if (slot instanceof SlotDisconnected slotDisconnected && !slot.getHasStack()) {
// Signal the server to move the pattern.
var packet = new PacketInventoryAction(InventoryAction.PLACE_SINGLE,
playerAppEngSlot.slotNumber, slotDisconnected.getSlot().getId());
playerAppEngSlot.slotNumber, slotDisconnected.getSlot().getId());
NetworkHandler.instance().sendToServer(packet);
@@ -46,6 +46,8 @@ import appeng.api.util.IConfigurableObject;
import appeng.client.gui.implementations.GuiMEMonitorable;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotPlayerHotBar;
import appeng.container.slot.SlotPlayerInv;
import appeng.container.slot.SlotRestrictedInput;
import appeng.core.AELog;
import appeng.core.sync.network.NetworkHandler;
@@ -60,9 +62,10 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IContainerListener;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nonnull;
import java.io.IOException;
@@ -84,7 +87,7 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
private IConfigManagerHost gui;
private IConfigManager serverCM;
private IGridNode networkNode;
protected int jeiOffset = Loader.isModLoaded("jei") ? 24 : 0;
protected int jeiOffset = Platform.isModLoaded("jei") ? 24 : 0;
public ContainerMEMonitorable(final InventoryPlayer ip, final ITerminalHost monitorable) {
@@ -161,6 +164,51 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
}
}
@Override
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) {
if (Platform.isClient()) {
return ItemStack.EMPTY;
}
// Below logic is all about handling shift click for view cells
if (!(this.host instanceof IViewCellStorage)) {
return super.transferStackInSlot(p, idx);
}
// Is it a view cell?
final Slot clickSlot = this.inventorySlots.get(idx);
ItemStack itemStack = clickSlot.getStack();
if (!AEApi.instance().definitions().items().viewCell().isSameAs(itemStack)) {
return super.transferStackInSlot(p, idx);
}
// Are we clicking from the player's inventory?
final boolean isPlayerInventorySlot = this.inventorySlots.get(idx) instanceof SlotPlayerInv || this.inventorySlots.get(idx) instanceof SlotPlayerHotBar;
if (!isPlayerInventorySlot) {
return super.transferStackInSlot(p, idx);
}
// Attempt to move the item into the view cell storage
final IItemHandler viewCellInv = ((IViewCellStorage) this.host).getViewCellStorage();
for (int slot = 0; slot < viewCellInv.getSlots(); slot++) {
if (viewCellInv.isItemValid(slot, itemStack) && viewCellInv.getStackInSlot(slot).isEmpty()) {
ItemStack remainder = viewCellInv.insertItem(slot, itemStack, true);
if (!remainder.isEmpty()) { // That slot can't take the item
continue;
}
remainder = viewCellInv.insertItem(slot, itemStack, false);
clickSlot.putStack(remainder);
this.detectAndSendChanges();
if (!remainder.isEmpty()) {
// How??
return super.transferStackInSlot(p, idx);
}
return ItemStack.EMPTY;
}
}
return super.transferStackInSlot(p, idx);
}
public IGridNode getNetworkNode() {
return this.networkNode;
}
@@ -1,15 +1,12 @@
package appeng.container.implementations;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings;
import appeng.api.config.StorageFilter;
import appeng.api.config.*;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotRestrictedInput;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.parts.misc.PartOreDicStorageBus;
@@ -18,6 +15,7 @@ import appeng.util.item.AEItemStack;
import appeng.util.item.OreReference;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.oredict.OreDictionary;
import java.io.IOException;
@@ -26,7 +24,7 @@ import java.util.Iterator;
import java.util.Set;
public class ContainerOreDictStorageBus extends AEBaseContainer {
public class ContainerOreDictStorageBus extends ContainerUpgradeable {
private final PartOreDicStorageBus part;
@GuiSync(3)
@@ -35,6 +33,9 @@ public class ContainerOreDictStorageBus extends AEBaseContainer {
@GuiSync(4)
public StorageFilter storageFilter = StorageFilter.EXTRACTABLE_ONLY;
@GuiSync(7)
public YesNo stickyMode = YesNo.NO;
public ContainerOreDictStorageBus(final InventoryPlayer ip, final PartOreDicStorageBus anchor) {
super(ip, anchor);
this.part = anchor;
@@ -47,9 +48,15 @@ public class ContainerOreDictStorageBus extends AEBaseContainer {
if (Platform.isServer()) {
this.setReadWriteMode((AccessRestriction) part.getConfigManager().getSetting(Settings.ACCESS));
this.setStorageFilter((StorageFilter) part.getConfigManager().getSetting(Settings.STORAGE_FILTER));
this.setStickyMode((YesNo) this.getUpgradeable().getConfigManager().getSetting(Settings.STICKY_MODE));
}
super.detectAndSendChanges();
super.standardDetectAndSendChanges();
}
@Override
protected int getHeight() {
return 170;
}
public void partition() {
@@ -116,4 +123,29 @@ public class ContainerOreDictStorageBus extends AEBaseContainer {
private void setStorageFilter(final StorageFilter storageFilter) {
this.storageFilter = storageFilter;
}
@Override
protected void setupConfig() {
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName("upgrades");
this.addSlotToContainer((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getInventoryPlayer()))
.setNotDraggable());
}
@Override
public int availableUpgrades() {
return 1;
}
@Override
protected boolean supportCapacity() {
return false;
}
public YesNo getStickyMode() {
return this.stickyMode;
}
private void setStickyMode(final YesNo stickyMode) {
this.stickyMode = stickyMode;
}
}
@@ -30,13 +30,13 @@ import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.misc.TileSecurityStation;
import appeng.util.Platform;
import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.InvOperation;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IContainerListener;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.items.IItemHandler;
@@ -53,7 +53,7 @@ public class ContainerSecurityStation extends ContainerMEMonitorable implements
@GuiSync(0)
public int permissionMode = 0;
protected int jeiOffset = Loader.isModLoaded("jei") ? 24 : 0;
protected int jeiOffset = Platform.isModLoaded("jei") ? 24 : 0;
public ContainerSecurityStation(final InventoryPlayer ip, final ITerminalHost monitorable) {
super(ip, monitorable, false);
@@ -75,8 +75,7 @@ public class ContainerSecurityStation extends ContainerMEMonitorable implements
final SecurityPermissions permission = SecurityPermissions.valueOf(value);
final ItemStack a = this.configSlot.getStack();
if (!a.isEmpty() && a.getItem() instanceof IBiometricCard) {
final IBiometricCard bc = (IBiometricCard) a.getItem();
if (!a.isEmpty() && a.getItem() instanceof IBiometricCard bc) {
if (bc.hasPermission(a, permission)) {
bc.removePermission(a, permission);
} else {
@@ -95,8 +94,7 @@ public class ContainerSecurityStation extends ContainerMEMonitorable implements
this.setPermissionMode(0);
final ItemStack a = this.configSlot.getStack();
if (!a.isEmpty() && a.getItem() instanceof IBiometricCard) {
final IBiometricCard bc = (IBiometricCard) a.getItem();
if (!a.isEmpty() && a.getItem() instanceof IBiometricCard bc) {
for (final SecurityPermissions sp : bc.getPermissions(a)) {
this.setPermissionMode(this.getPermissionMode() | (1 << sp.ordinal()));
@@ -0,0 +1,198 @@
package appeng.container.implementations;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.implementations.IUpgradeableCellContainer;
import appeng.api.networking.security.IActionHost;
import appeng.container.interfaces.IInventorySlotAware;
import appeng.container.slot.SlotRestrictedInput;
import appeng.core.AEConfig;
import appeng.core.localization.PlayerMessages;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.parts.automation.StackUpgradeInventory;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.Platform;
import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.InvOperation;
import baubles.api.BaublesApi;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ClickType;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.items.IItemHandler;
import org.jetbrains.annotations.NotNull;
public class ContainerWirelessInterfaceTerminal extends ContainerInterfaceTerminal implements IInventorySlotAware, IUpgradeableCellContainer, IAEAppEngInventory {
private final WirelessTerminalGuiObject wirelessTerminalGUIObject;
private final int slot;
private double powerMultiplier = 0.5;
private int ticks = 0;
protected AppEngInternalInventory upgrades;
protected SlotRestrictedInput magnetSlot;
public ContainerWirelessInterfaceTerminal(InventoryPlayer ip, WirelessTerminalGuiObject guiObject) {
super(ip, guiObject,false);
if (guiObject != null) {
final int slotIndex = guiObject.getInventorySlot();
if (!guiObject.isBaubleSlot()) {
this.lockPlayerInventorySlot(slotIndex);
}
this.slot = slotIndex;
} else {
this.lockPlayerInventorySlot(ip.currentItem);
this.slot = -1;
}
this.bindPlayerInventory(ip,0,0);
this.wirelessTerminalGUIObject = guiObject;
upgrades = new StackUpgradeInventory(wirelessTerminalGUIObject.getItemStack(), this, 2);
this.loadFromNBT();
setupUpgrades();
}
@Override
public void detectAndSendChanges() {
if (Platform.isServer()) {
final ItemStack currentItem;
if (wirelessTerminalGUIObject.isBaubleSlot()) {
currentItem = BaublesApi.getBaublesHandler(this.getPlayerInv().player).getStackInSlot(this.slot);
} else {
currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot(this.slot);
}
if (currentItem.isEmpty()) {
this.setValidContainer(false);
} else if (!this.wirelessTerminalGUIObject.getItemStack().isEmpty() && currentItem != this.wirelessTerminalGUIObject.getItemStack()) {
if (ItemStack.areItemsEqual(this.wirelessTerminalGUIObject.getItemStack(), currentItem)) {
if (wirelessTerminalGUIObject.isBaubleSlot()) {
BaublesApi.getBaublesHandler(this.getPlayerInv().player).setStackInSlot(this.slot, this.wirelessTerminalGUIObject.getItemStack());
} else {
this.getPlayerInv().setInventorySlotContents(this.slot, this.wirelessTerminalGUIObject.getItemStack());
}
} else {
this.setValidContainer(false);
}
}
// drain 1 ae t
this.ticks++;
if (this.ticks > 10) {
double ext = this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
if (ext < this.getPowerMultiplier() * this.ticks) {
if (Platform.isServer() && this.isValidContainer()) {
this.getPlayerInv().player.sendMessage(PlayerMessages.DeviceNotPowered.get());
}
this.setValidContainer(false);
}
this.ticks = 0;
}
if (!this.wirelessTerminalGUIObject.rangeCheck()) {
if (Platform.isServer() && this.isValidContainer()) {
this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get());
}
this.setValidContainer(false);
} else {
this.setPowerMultiplier(AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGUIObject.getRange()));
}
super.detectAndSendChanges();
}
}
@Override
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, @NotNull EntityPlayer player) {
if (slotId >= 0 && slotId < this.inventorySlots.size()) {
if (clickTypeIn == ClickType.PICKUP && dragType == 1) {
if (this.inventorySlots.get(slotId) == magnetSlot) {
ItemStack itemStack = magnetSlot.getStack();
if (!magnetSlot.getStack().isEmpty()) {
NBTTagCompound tag = itemStack.getTagCompound();
if (tag == null) {
tag = new NBTTagCompound();
}
if (tag.hasKey("enabled")) {
boolean e = tag.getBoolean("enabled");
tag.setBoolean("enabled", !e);
} else {
tag.setBoolean("enabled", false);
}
magnetSlot.getStack().setTagCompound(tag);
magnetSlot.onSlotChanged();
return ItemStack.EMPTY;
}
}
}
}
return super.slotClick(slotId, dragType, clickTypeIn, player);
}
private double getPowerMultiplier() {
return this.powerMultiplier;
}
void setPowerMultiplier(final double powerMultiplier) {
this.powerMultiplier = powerMultiplier;
}
@Override
protected IActionHost getActionHost() {
return wirelessTerminalGUIObject;
}
@Override
public int getInventorySlot() {
return wirelessTerminalGUIObject.getInventorySlot();
}
@Override
public boolean isBaubleSlot() {
return wirelessTerminalGUIObject.isBaubleSlot();
}
@Override
public int availableUpgrades() {
return 1;
}
@Override
public void setupUpgrades() {
if (wirelessTerminalGUIObject != null) {
for (int upgradeSlot = 0; upgradeSlot < availableUpgrades(); upgradeSlot++) {
this.magnetSlot = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, upgradeSlot, 183, -1 + upgradeSlot * 18, this.getInventoryPlayer());
this.magnetSlot.setNotDraggable();
this.addSlotToContainer(magnetSlot);
}
}
}
private void loadFromNBT() {
NBTTagCompound data = wirelessTerminalGUIObject.getItemStack().getTagCompound();
if (data != null) {
upgrades.readFromNBT(wirelessTerminalGUIObject.getItemStack().getTagCompound().getCompoundTag("upgrades"));
}
}
@Override
public void saveChanges() {
if (Platform.isServer()) {
NBTTagCompound tag = new NBTTagCompound();
this.upgrades.writeToNBT(tag, "upgrades");
this.wirelessTerminalGUIObject.saveChanges(tag);
}
}
@Override
public void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) {
}
}
@@ -0,0 +1,10 @@
package appeng.container.interfaces;
import javax.annotation.Nullable;
public interface ISpecialSlotIngredient {
@Nullable
Object getIngredient();
}
@@ -1,4 +1,9 @@
package appeng.container.slot;
public interface IJEITargetSlot {
default boolean needAccept() {
return false;
}
}
@@ -41,9 +41,6 @@ import appeng.util.inv.WrapperCursorItemHandler;
import appeng.util.inv.WrapperInvItemHandler;
import appeng.util.item.AEItemStack;
import com.blamejared.recipestages.recipes.RecipeStage;
import net.darkhax.gamestages.GameStageHelper;
import net.darkhax.itemstages.ItemStages;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
@@ -53,9 +50,6 @@ import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.items.IItemHandler;
import java.util.ArrayList;
@@ -157,8 +151,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot {
// TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring.
protected IRecipe findRecipe(InventoryCrafting ic, World world, EntityPlayer player) {
if (this.container instanceof ContainerCraftingTerm) {
final ContainerCraftingTerm containerTerminal = (ContainerCraftingTerm) this.container;
if (this.container instanceof ContainerCraftingTerm containerTerminal) {
final IRecipe recipe = containerTerminal.getCurrentRecipe();
if (recipe != null && recipe.matches(ic, world)) {
@@ -171,9 +164,8 @@ public class SlotCraftingTerm extends AppEngCraftingSlot {
// Returns null in case this recipe is not yet unlocked
private IRecipe handleRecipe(InventoryCrafting ic, IRecipe recipe, EntityPlayer player) {
if (Loader.isModLoaded("recipestages")) {
if (recipe instanceof RecipeStage) {
final RecipeStage staged = (RecipeStage) recipe;
if (Platform.isModLoaded("recipestages")) {
if (recipe instanceof RecipeStage staged) {
if (!staged.isGoodForCrafting(ic))
return null;
}
@@ -185,8 +177,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot {
// TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring.
@Override
protected NonNullList<ItemStack> getRemainingItems(InventoryCrafting ic, World world) {
if (this.container instanceof ContainerCraftingTerm) {
final ContainerCraftingTerm containerTerminal = (ContainerCraftingTerm) this.container;
if (this.container instanceof ContainerCraftingTerm containerTerminal) {
final IRecipe recipe = containerTerminal.getCurrentRecipe();
if (recipe != null && recipe.matches(ic, world)) {
@@ -50,7 +50,6 @@ public class SlotFake extends AppEngSlot implements IJEITargetSlot {
if (!is.isEmpty()) {
is = is.copy();
}
super.putStack(is);
}
@@ -58,4 +57,10 @@ public class SlotFake extends AppEngSlot implements IJEITargetSlot {
public boolean canTakeStack(final EntityPlayer par1EntityPlayer) {
return false;
}
@Override
public boolean needAccept() {
return this.getStack().isEmpty();
}
}
+6
View File
@@ -84,6 +84,7 @@ public final class AEConfig extends Configuration implements IConfigurableObject
private PowerUnits selectedPowerUnit = PowerUnits.AE;
private boolean showCraftableTooltip = true;
private boolean showPlacementPreview = true;
private boolean showCellContentsPreview = true;
// Spatial IO/Dimension
private int storageProviderID = -1;
@@ -259,6 +260,7 @@ public final class AEConfig extends Configuration implements IConfigurableObject
this.useColoredCraftingStatus = this.get("Client", "useColoredCraftingStatus", true).getBoolean(true);
this.showCraftableTooltip = this.get("Client", "showCraftableTooltip", true, "Whether to add \"Craftable\" to item tooltips when they can be crafted automatically.").getBoolean(true);
this.showPlacementPreview = this.get("Client", "showPlacementPreview", true, "Whether to show a preview of part and facade placement.").getBoolean(true);
this.showCellContentsPreview = this.get("Client", "showCellContentsPreview", true, "Whether to show a preview of cell contents in tooltips.").getBoolean(true);
// load buttons..
for (int btnNum = 0; btnNum < 4; btnNum++) {
@@ -520,6 +522,10 @@ public final class AEConfig extends Configuration implements IConfigurableObject
return this.showPlacementPreview;
}
public boolean showCellContentsPreview() {
return showCellContentsPreview;
}
public boolean isDisableColoredCableRecipesInJEI() {
return this.disableColoredCableRecipesInJEI;
}
+18 -1
View File
@@ -54,8 +54,8 @@ import appeng.core.stats.PartItemPredicate;
import appeng.core.stats.Stats;
import appeng.core.worlddata.SpatialDimensionManager;
import appeng.fluids.registries.BasicFluidCellGuiHandler;
import appeng.hooks.WrenchClickHook;
import appeng.hooks.TickHandler;
import appeng.hooks.WrenchClickHook;
import appeng.items.materials.ItemMaterial;
import appeng.items.parts.ItemFacade;
import appeng.items.parts.ItemPart;
@@ -387,12 +387,28 @@ final class Registration {
Upgrades.FUZZY.registerItem(AEApi.instance().definitions().materials().cardMagnet(), 1);
Upgrades.INVERTER.registerItem(AEApi.instance().definitions().materials().cardMagnet(), 1);
// Fluid Cells
Upgrades.INVERTER.registerItem(items.fluidCell1k(), 1);
Upgrades.STICKY.registerItem(items.fluidCell1k(), 1);
Upgrades.INVERTER.registerItem(items.fluidCell4k(), 1);
Upgrades.STICKY.registerItem(items.fluidCell4k(), 1);
Upgrades.INVERTER.registerItem(items.fluidCell16k(), 1);
Upgrades.STICKY.registerItem(items.fluidCell16k(), 1);
Upgrades.INVERTER.registerItem(items.fluidCell64k(), 1);
Upgrades.STICKY.registerItem(items.fluidCell64k(), 1);
// Storage Bus
Upgrades.FUZZY.registerItem(parts.storageBus(), 1);
Upgrades.INVERTER.registerItem(parts.storageBus(), 1);
Upgrades.CAPACITY.registerItem(parts.storageBus(), 5);
Upgrades.STICKY.registerItem(parts.storageBus(), 1);
// OreDict Storage Bus
Upgrades.STICKY.registerItem(parts.oreDictStorageBus(), 1);
// Storage Bus Fluids
Upgrades.INVERTER.registerItem(parts.fluidStorageBus(), 1);
Upgrades.CAPACITY.registerItem(parts.fluidStorageBus(), 5);
@@ -429,6 +445,7 @@ final class Registration {
});
}
items.wirelessFluidTerminal().maybeItem().ifPresent(terminal -> registries.wireless().registerWirelessHandler((IWirelessTermHandler) terminal));
items.wirelessInterfaceTerminal().maybeItem().ifPresent(terminal -> registries.wireless().registerWirelessHandler((IWirelessTermHandler) terminal));
// Charge Rates
items.chargedStaff().maybeItem().ifPresent(chargedStaff -> registries.charger().addChargeRate(chargedStaff, 320d));
@@ -11,7 +11,9 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
import appeng.api.util.IClientHelper;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.core.localization.Tooltips;
import appeng.fluids.items.FluidDummyItem;
import appeng.fluids.util.AEFluidStack;
import appeng.util.ReadableNumberConverter;
@@ -43,10 +45,9 @@ public class ApiClientHelper implements IClientHelper {
final ICellInventory<?> cellInventory = handler.getCellInv();
if (cellInventory != null) {
lines.add(cellInventory.getUsedBytes() + " " + GuiText.Of.getLocal() + ' ' + cellInventory.getTotalBytes() + ' ' + GuiText.BytesUsed.getLocal());
lines.add(Tooltips.bytesUsed(cellInventory.getUsedBytes(),cellInventory.getTotalBytes()).getFormattedText());
lines.add(cellInventory.getStoredItemTypes() + " " + GuiText.Of.getLocal() + ' ' + cellInventory.getTotalItemTypes() + ' ' + GuiText.Types
.getLocal());
lines.add(Tooltips.typesUsed(cellInventory.getStoredItemTypes(),cellInventory.getTotalItemTypes()).getFormattedText());
}
IItemList<?> itemList = cellInventory.getChannel().createList();
@@ -109,7 +110,10 @@ public class ApiClientHelper implements IClientHelper {
}
}
} else {
if (Minecraft.getMinecraft().gameSettings.advancedItemTooltips || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
if (!AEConfig.instance().showCellContentsPreview()) return;
if (Minecraft.getMinecraft().gameSettings.advancedItemTooltips
|| Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)
) {
cellInventory.getAvailableItems((IItemList) itemList);
for (IAEStack<?> s : itemList) {
if (s instanceof IAEItemStack) {
@@ -80,6 +80,7 @@ public final class ApiItems implements IItems {
private final IItemDefinition wirelessTerminal;
private final IItemDefinition wirelessCraftingTerminal;
private final IItemDefinition wirelessPatternTerminal;
private final IItemDefinition wirelessInterfaceTerminal;
private final IItemDefinition wirelessFluidTerminal;
private final IItemDefinition biometricCard;
private final IItemDefinition chargedStaff;
@@ -184,6 +185,7 @@ public final class ApiItems implements IItems {
this.wirelessCraftingTerminal = powerTools.item("wireless_crafting_terminal", ToolWirelessCraftingTerminal::new).addFeatures(AEFeature.WIRELESS_CRAFTING_TERMINAL).build();
this.wirelessPatternTerminal = powerTools.item("wireless_pattern_terminal", ToolWirelessPatternTerminal::new).addFeatures(AEFeature.WIRELESS_PATTERN_TERMINAL).build();
this.wirelessFluidTerminal = powerTools.item("wireless_fluid_terminal", ToolWirelessFluidTerminal::new).addFeatures(AEFeature.WIRELESS_FLUID_TERMINAL).build();
this.wirelessInterfaceTerminal = powerTools.item("wireless_interface_terminal",ToolWirelessInterfaceTerminal::new).addFeatures(AEFeature.WIRELESS_INTERFACE_TERMINAL).build();
this.chargedStaff = powerTools.item("charged_staff", ToolChargedStaff::new).addFeatures(AEFeature.CHARGED_STAFF).build();
this.massCannon = powerTools.item("matter_cannon", ToolMatterCannon::new)
@@ -365,6 +367,11 @@ public final class ApiItems implements IItems {
return wirelessPatternTerminal;
}
@Override
public IItemDefinition wirelessInterfaceTerminal() {
return wirelessInterfaceTerminal;
}
@Override
public IItemDefinition biometricCard() {
return this.biometricCard;
@@ -67,6 +67,7 @@ public enum AEFeature {
WIRELESS_CRAFTING_TERMINAL("WirelessCraftingTerminal", Constants.CATEGORY_TOOLS),
WIRELESS_PATTERN_TERMINAL("WirelessPatternTerminal", Constants.CATEGORY_TOOLS),
WIRELESS_FLUID_TERMINAL("WirelessFluidTerminal", Constants.CATEGORY_TOOLS),
WIRELESS_INTERFACE_TERMINAL("WirelessInterfaceTerminal", Constants.CATEGORY_TOOLS),
COLOR_APPLICATOR("ColorApplicator", Constants.CATEGORY_TOOLS),
METEORITE_COMPASS("MeteoriteCompass", Constants.CATEGORY_TOOLS),
@@ -37,6 +37,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.oredict.OreDictionary;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -277,4 +278,9 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry {
private void addNewAttunement(final IItemDefinition definition, final TunnelType type) {
definition.maybeStack(1).ifPresent(definitionStack -> this.addNewAttunement(definitionStack, type));
}
@Override
public TunnelType registerTunnelType(@NotNull String enumName, @NotNull ItemStack partStack) {
return TunnelType.registerTunnelType(enumName, partStack);
}
}
@@ -25,6 +25,7 @@ import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.List;
/**
@@ -35,7 +36,7 @@ import java.util.Collection;
* @since rv2
*/
public class InscriberInscribeRecipe extends InscriberRecipe {
InscriberInscribeRecipe(@Nonnull final Collection<ItemStack> inputs, @Nonnull final ItemStack output, @Nullable final ItemStack top, @Nullable final ItemStack bot) {
InscriberInscribeRecipe(@Nonnull final Collection<ItemStack> inputs, @Nonnull final ItemStack output, @Nullable final List<ItemStack> top, @Nullable final List<ItemStack> bot) {
super(inputs, output, top, bot, InscriberProcessType.INSCRIBE);
}
}
@@ -27,8 +27,8 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
/**
@@ -46,21 +46,21 @@ public class InscriberRecipe implements IInscriberRecipe {
private final ItemStack output;
@Nonnull
private final Optional<ItemStack> maybeTop;
private final List<ItemStack> maybeTop;
@Nonnull
private final Optional<ItemStack> maybeBot;
private final List<ItemStack> maybeBot;
@Nonnull
private final InscriberProcessType type;
InscriberRecipe(@Nonnull final Collection<ItemStack> inputs, @Nonnull final ItemStack output, @Nullable final ItemStack top, @Nullable final ItemStack bot, @Nonnull final InscriberProcessType type) {
InscriberRecipe(@Nonnull final Collection<ItemStack> inputs, @Nonnull final ItemStack output, @Nullable final List<ItemStack> top, @Nullable final List<ItemStack> bot, @Nonnull final InscriberProcessType type) {
this.inputs = new ArrayList<>(inputs.size());
this.inputs.addAll(inputs);
this.output = output;
this.maybeTop = Optional.ofNullable(top);
this.maybeBot = Optional.ofNullable(bot);
this.maybeTop = top == null || top.isEmpty() ? Collections.emptyList() : top;
this.maybeBot = bot == null || bot.isEmpty() ? Collections.emptyList() : bot;
this.type = type;
}
@@ -79,13 +79,13 @@ public class InscriberRecipe implements IInscriberRecipe {
@Nonnull
@Override
public final Optional<ItemStack> getTopOptional() {
public final List<ItemStack> getTopInputs() {
return this.maybeTop;
}
@Nonnull
@Override
public final Optional<ItemStack> getBottomOptional() {
public final List<ItemStack> getBottomInputs() {
return this.maybeBot;
}
@@ -112,10 +112,10 @@ public class InscriberRecipe implements IInscriberRecipe {
if (!this.output.equals(that.getOutput())) {
return false;
}
if (!this.maybeTop.equals(that.getTopOptional())) {
if (!this.maybeTop.equals(that.getTopInputs())) {
return false;
}
if (!this.maybeBot.equals(that.getBottomOptional())) {
if (!this.maybeBot.equals(that.getBottomInputs())) {
return false;
}
return this.type == that.getProcessType();
@@ -75,9 +75,8 @@ public final class InscriberRegistry implements IInscriberRegistry {
Preconditions.checkNotNull(recipe, "Tried to add (null) as inscriber recipe to the registry.");
if (this.recipes.add(recipe)) {
recipe.getTopOptional().ifPresent(this.optionals::add);
recipe.getBottomOptional().ifPresent(this.optionals::add);
this.optionals.addAll(recipe.getTopInputs());
this.optionals.addAll(recipe.getBottomInputs());
this.inputs.addAll(recipe.getInputs());
return true;
@@ -110,8 +109,8 @@ public final class InscriberRegistry implements IInscriberRegistry {
private static final class Builder implements IInscriberRecipeBuilder {
private List<ItemStack> inputs;
private ItemStack output;
private ItemStack topOptional;
private ItemStack bottomOptional;
private List<ItemStack> topOptional;
private List<ItemStack> bottomOptional;
private InscriberProcessType type;
@Nonnull
@@ -139,22 +138,22 @@ public final class InscriberRegistry implements IInscriberRegistry {
@Nonnull
@Override
public Builder withTopOptional(@Nonnull final ItemStack topOptional) {
public Builder withTopOptional(@Nonnull final Collection<ItemStack> topOptional) {
Preconditions.checkNotNull(topOptional);
Preconditions.checkArgument(!topOptional.isEmpty());
this.topOptional = topOptional;
this.topOptional = new ArrayList<>(topOptional.size());
this.topOptional.addAll(topOptional);
return this;
}
@Nonnull
@Override
public Builder withBottomOptional(@Nonnull final ItemStack bottomOptional) {
public Builder withBottomOptional(@Nonnull final Collection<ItemStack> bottomOptional) {
Preconditions.checkNotNull(bottomOptional);
Preconditions.checkArgument(!bottomOptional.isEmpty());
this.bottomOptional = bottomOptional;
this.bottomOptional = new ArrayList<>(bottomOptional.size());
this.bottomOptional.addAll(bottomOptional);
return this;
}
@@ -98,6 +98,13 @@ public enum ButtonToolTips {
Blocking,
NonBlocking,
LockCraftingMode,
LockCraftingModeNone,
LockCraftingUntilRedstonePulse,
LockCraftingWhileRedstoneHigh,
LockCraftingWhileRedstoneLow,
LockCraftingUntilResultReturned,
LevelType,
LevelType_Energy,
LevelType_Item,
@@ -150,13 +157,20 @@ public enum ButtonToolTips {
DecreaseByOneDesc,
MaxCount,
MaxCountDesc,
FreeMolecularSlotShortcut,
FreeMolecularSlotShortcutDesc,
ToggleMolecularAssemblers,
ToggleMolecularAssemblersOnDesc,
ToggleMolecularAssemblersOffDesc,
ToggleShowFullInterfaces,
ToggleShowFullInterfacesOnDesc,
ToggleShowFullInterfacesOffDesc,
ToggleShowOnlyInvalidInterface,
ToggleShowOnlyInvalidInterfaceOnDesc,
ToggleShowOnlyInvalidInterfaceOffDesc,
HighlightInterface,
HighlightInterfaceDesc,
SearchFieldInputs,
SearchFieldOutputs,
SearchFieldNames,
// Used in the tooltips of the items in the terminal, when moused over
ItemsStored,
@@ -19,6 +19,8 @@
package appeng.core.localization;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.translation.I18n;
@@ -97,6 +99,7 @@ public enum GuiText {
RedstoneTunnel,
EUTunnel,
FluidTunnel,
FluidTerminal,
OCTunnel,
LightTunnel,
FETunnel,
@@ -206,7 +209,20 @@ public enum GuiText {
// Used in Crafting Toasts
CraftingToastDone,
CraftingToastCancelled;
CraftingToastCancelled,
//Used in Lock Crafting,
CraftingLock,
NoneLock,
LowRedstoneLock,
HighRedstoneLock,
ResultLock,
UntilPulseUnlock,
// Used in Annihilation Planes
CanBeEnchanted,
IncreasedEnergyUseFromEnchants,
Deprecated;
private final String root;
@@ -222,6 +238,10 @@ public enum GuiText {
return I18n.translateToLocal(this.getUnlocalized());
}
public ITextComponent getLocalizedWithArgs(Object... args) {
return new TextComponentTranslation(this.getUnlocalized(), args);
}
public String getUnlocalized() {
return this.root + '.' + this;
}
@@ -41,7 +41,15 @@ public enum PlayerMessages {
DeviceNotLinked,
StationCanNotBeLocated,
SettingCleared,
MissingPatternsToEncode;
MissingPatternsToEncode,
InterfaceInOtherDimParam,
InterfaceInOtherDim,
InterfaceHighlighted,
;
public ITextComponent get(Object... params) {
return new TextComponentTranslation(this.getName(), params);
}
public ITextComponent get() {
return new TextComponentTranslation(this.getName());
@@ -0,0 +1,203 @@
package appeng.core.localization;
import appeng.api.config.PowerUnits;
import com.github.bsideup.jabel.Desugar;
import net.minecraft.util.text.*;
import java.text.DecimalFormat;
import java.text.MessageFormat;
import java.util.Arrays;
/**
* Static utilities for constructing tooltips in various places.
*/
public final class Tooltips {
private static final char SEP;
static {
var format = (DecimalFormat) DecimalFormat.getInstance();
var symbols = format.getDecimalFormatSymbols();
SEP = symbols.getDecimalSeparator();
}
public static final Style UNIT_TEXT = new Style().setColor(TextFormatting.YELLOW).setItalic(false);
public static final Style NORMAL_TOOLTIP_TEXT = new Style().setColor(TextFormatting.GRAY).setItalic(false);
public static final Style NUMBER_TEXT = new Style().setColor(TextFormatting.LIGHT_PURPLE).setItalic(false);
public static final String[] units = new String[] { "k", "M", "G", "T", "P", "E" };
public static final long[] DECIMAL_NUMS = new long[] { 1000L, 1000_000L, 1000_000_000L, 1000_000_000_000L,
1000_000_000_000_000L,
1000_000_000_000_000_000L };
public static ITextComponent of(ITextComponent... components) {
ITextComponent s = new TextComponentString("");
for (var c : components) {
s = s.appendSibling(c);
}
return s;
}
public static ITextComponent of(String s) {
return new TextComponentString(s);
}
public static ITextComponent ofPercent(double percent) {
return ofPercent(percent,true);
}
public static ITextComponent ofPercent(double percent, boolean oneIsGreen) {
return new TextComponentString(MessageFormat.format("{0,number,#.##%}", percent))
.setStyle(colorFromRatio(percent, oneIsGreen));
}
public static ITextComponent of(PowerUnits pU) {
return new TextComponentTranslation(pU.unlocalizedName).setStyle(UNIT_TEXT);
}
public static ITextComponent ofNumber(double number, double max) {
MaxedAmount amount = getMaxedAmount(number, max);
return ofNumber(amount);
}
public static ITextComponent of(GuiText guiText, Object... args) {
return of(guiText, NORMAL_TOOLTIP_TEXT, args);
}
public static ITextComponent of(GuiText guiText, Style style, Object... args) {
if (args.length > 0 && args[0] instanceof Integer) {
return guiText.getLocalizedWithArgs(Arrays.stream(args).map((o) -> ofUnformattedNumber((Integer) o)).toArray()).createCopy()
.setStyle(style);
} else if (args.length > 0 && args[0] instanceof Long) {
return guiText.getLocalizedWithArgs(Arrays.stream(args).map((o) -> ofUnformattedNumber((Long) o)).toArray()).createCopy()
.setStyle(style);
}
return guiText.getLocalizedWithArgs(args).createCopy().setStyle(style);
}
public static ITextComponent ofUnformattedNumber(long number) {
return new TextComponentString(String.valueOf(number)).setStyle(NUMBER_TEXT);
}
public static ITextComponent ofUnformattedNumberWithRatioColor(long number, double ratio, boolean oneIsGreen) {
return new TextComponentString(String.valueOf(number)).setStyle(colorFromRatio(ratio, oneIsGreen));
}
private static ITextComponent ofNumber(MaxedAmount number) {
boolean numberUnit = !number.digit().equals("0");
return new TextComponentString(number.digit() + (numberUnit ? number.unit() : "")).setStyle(NUMBER_TEXT)
.appendSibling(new TextComponentString("/")
.setStyle(NORMAL_TOOLTIP_TEXT))
.appendText(number.maxDigit() + number.unit()).setStyle(NUMBER_TEXT);
}
@Desugar
public record MaxedAmount(String digit, String maxDigit, String unit) {
}
@Desugar
public record Amount(String digit, String unit) {
}
public static Style colorFromRatio(double ratio, boolean oneIsGreen) {
double p = ratio;
if (!oneIsGreen) {
p = 1 - p;
}
TextFormatting colorCode = getColorCode(p);
return new Style().setItalic(false).setColor(colorCode);
}
public static String getAmount(double amount, long num) {
double fract = amount / num;
String returned;
if (fract < 10) {
returned = String.format("%.3f", fract);
} else if (fract < 100) {
returned = String.format("%.2f", fract);
} else {
returned = String.format("%.1f", fract);
}
while (returned.endsWith("0")) {
returned = returned.substring(0, returned.length() - 1);
}
if (returned.endsWith(String.valueOf(SEP))) {
returned = returned.substring(0, returned.length() - 1);
}
return returned;
}
public static Amount getAmount(double amount) {
if (amount < 10000) {
return new Amount(getAmount(amount, 1), "");
} else {
int i = 0;
while (amount / DECIMAL_NUMS[i] >= 1000) {
i++;
}
return new Amount(getAmount(amount, DECIMAL_NUMS[i]), units[i]);
}
}
public static MaxedAmount getMaxedAmount(double amount, double max) {
if (max < 10000) {
return new MaxedAmount(getAmount(amount, 1), getAmount(max, 1), "");
} else {
int i = 0;
while (max / DECIMAL_NUMS[i] >= 1000) {
i++;
}
return new MaxedAmount(getAmount(amount, DECIMAL_NUMS[i]), getAmount(max, DECIMAL_NUMS[i]), units[i]);
}
}
private static TextFormatting getColorCode(double p) {
if (p < 0.33) {
return TextFormatting.RED;
} else if (p < 0.66) {
return TextFormatting.YELLOW;
} else {
return TextFormatting.GREEN;
}
}
public static ITextComponent energyStorageComponent(double energy, double max) {
return Tooltips.of(
Tooltips.of(GuiText.StoredEnergy.getLocal()),
Tooltips.of(": "),
Tooltips.ofNumber(energy, max),
Tooltips.of(" "),
Tooltips.of(PowerUnits.AE),
Tooltips.of(" ("),
Tooltips.ofPercent(energy / max),
Tooltips.of(")"));
}
public static ITextComponent bytesUsed(long bytes, long max) {
return of(
Tooltips.of(
ofUnformattedNumberWithRatioColor(bytes, (double) bytes / max, false),
of(" "),
of(GuiText.Of),
of(" "),
ofUnformattedNumber(max),
of(" "),
of(GuiText.BytesUsed)));
}
public static ITextComponent typesUsed(long types, long max) {
return Tooltips.of(
ofUnformattedNumberWithRatioColor(types, (double) types / max, false),
of(" "),
of(GuiText.Of),
of(" "),
ofUnformattedNumber(max),
of(" "),
of(GuiText.Types));
}
}
@@ -41,7 +41,9 @@ public enum WailaText {
Showing,
Contains,
Channels;
Channels,
EnchantedWith,
IdentityDeprecated;
private final String root;
+12 -2
View File
@@ -43,7 +43,6 @@ import appeng.container.AEBaseContainer;
import appeng.container.ContainerNull;
import appeng.container.ContainerOpenContext;
import appeng.container.implementations.*;
import appeng.container.interfaces.IInventorySlotAware;
import appeng.fluids.container.*;
import appeng.fluids.helper.IFluidInterfaceHost;
import appeng.fluids.parts.PartFluidFormationPlane;
@@ -106,7 +105,7 @@ public enum GuiBridge implements IGuiHandler {
GUI_WIRELESS_CRAFTING_TERMINAL(ContainerWirelessCraftingTerminal.class, WirelessTerminalGuiObject.class, GuiHostType.ITEM, null),
GUI_WIRELESS_PATTERN_TERMINAL(ContainerWirelessPatternTerminal.class, WirelessTerminalGuiObject.class, GuiHostType.ITEM, null),
GUI_WIRELESS_FLUID_TERMINAL(ContainerWirelessFluidTerminal.class, WirelessTerminalGuiObject.class, GuiHostType.ITEM, null),
GUI_WIRELESS_INTERFACE_TERMINAL(ContainerWirelessInterfaceTerminal.class, WirelessTerminalGuiObject.class, GuiHostType.ITEM, null),
GUI_NETWORK_STATUS(ContainerNetworkStatus.class, INetworkTool.class, GuiHostType.ITEM, null),
@@ -185,6 +184,7 @@ public enum GuiBridge implements IGuiHandler {
private Class guiClass;
private GuiHostType type;
private SecurityPermissions requiredPermission;
private GuiWrapper.IExternalGui externalGui = null;
GuiBridge() {
this.tileClass = null;
@@ -192,6 +192,16 @@ public enum GuiBridge implements IGuiHandler {
this.containerClass = null;
}
GuiBridge(GuiWrapper.IExternalGui obj) {
this.tileClass = null;
this.containerClass = null;
this.externalGui = obj;
}
public GuiWrapper.IExternalGui getExternalGui() {
return this.externalGui;
}
GuiBridge(final Class containerClass, final SecurityPermissions requiredPermission) {
this.requiredPermission = requiredPermission;
this.containerClass = containerClass;
@@ -0,0 +1,90 @@
package appeng.core.sync;
import it.unimi.dsi.fastutil.Hash;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.util.EnumHelper;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* Allow to register custom GuiBridge from third-party
*/
public class GuiWrapper {
public static final GuiWrapper INSTANCE = new GuiWrapper();
private GuiWrapper() {
// NO-OP
}
private final Object2ObjectMap<ResourceLocation, Opener> openers = new Object2ObjectOpenHashMap<>();
private final Object2ObjectMap<IExternalGui, GuiBridge> externalGuis = new Object2ObjectOpenCustomHashMap<>(new Hash.Strategy<IExternalGui>() {
@Override
public int hashCode(IExternalGui o) {
return o.getID().hashCode();
}
@Override
public boolean equals(@Nullable IExternalGui a, @Nullable IExternalGui b) {
return a == b || (a != null && b != null && a.getID().equals(b.getID()));
}
});
public synchronized void registerExternalGuiHandler(@Nonnull ResourceLocation id, @Nonnull Opener opener) {
openers.put(id, opener);
}
@Nullable
public Opener getOpener(ResourceLocation id) {
return openers.get(id);
}
public GuiBridge wrap(IExternalGui obj) {
return externalGuis.computeIfAbsent(obj, this::create);
}
private GuiBridge create(IExternalGui obj) {
return EnumHelper.addEnum(GuiBridge.class, obj.getID().toString(), new Class<?>[] {IExternalGui.class}, obj);
}
@FunctionalInterface
public interface Opener {
<T extends IExternalGui> void open(T obj, GuiContext context);
}
public interface IExternalGui {
ResourceLocation getID();
}
public static class GuiContext {
public final World world;
public final EntityPlayer player;
public final BlockPos pos;
public final EnumFacing facing;
public final NBTTagCompound extra;
public GuiContext(World world, EntityPlayer player, BlockPos pos, EnumFacing face, NBTTagCompound extra) {
this.world = world;
this.player = player;
this.pos = pos;
this.facing = face;
this.extra = extra;
}
}
}
@@ -14,7 +14,6 @@ import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Optional;
public class PacketTerminalUse extends AppEngPacket {
@@ -45,7 +44,7 @@ public class PacketTerminalUse extends AppEngPacket {
}
}
if (Loader.isModLoaded("baubles")) {
if (Platform.isModLoaded("baubles")) {
tryOpenBauble(player);
}
}
+10 -6
View File
@@ -131,7 +131,7 @@ public class CraftingJob implements Runnable, ICraftingJob {
craftingInventory.ignore(this.output);
this.availableCheck = new MECraftingInventory(this.original, false, false, false);
craftingTreeWatch.start();
craftingTreeWatch.reset().start();
this.getTree().request(craftingInventory, this.output.getStackSize(), this.actionSrc);
craftingTreeWatch.stop();
this.getTree().dive(this);
@@ -170,10 +170,8 @@ public class CraftingJob implements Runnable, ICraftingJob {
} else {
this.logCraftingJob("real, failed", craftingTreeWatch);
}
} catch (final CraftBranchFailure e1) {
} catch (final CraftBranchFailure | CraftingCalculationFailure e1) {
AELog.debug(e1);
} catch (final CraftingCalculationFailure f) {
AELog.debug(f);
} catch (final InterruptedException e1) {
AELog.crafting("Crafting calculation canceled.");
this.finish();
@@ -202,8 +200,14 @@ public class CraftingJob implements Runnable, ICraftingJob {
synchronized (this.monitor) {
if (this.tickSpreadingWatch.elapsed(TimeUnit.MICROSECONDS) > this.time) {
this.running = false;
this.craftingTreeWatch.stop();
this.tickSpreadingWatch.stop();
if (this.craftingTreeWatch.isRunning()) {
this.craftingTreeWatch.stop();
}
if (this.tickSpreadingWatch.isRunning()) {
this.tickSpreadingWatch.stop();
}
this.monitor.notify();
}
@@ -127,7 +127,7 @@ public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfi
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.fontRenderer.drawString(this.getGuiDisplayName("Fluid Terminal"), 8, 6, 4210752);
this.fontRenderer.drawString(GuiText.FluidTerminal.getLocal(), 8, 6, 4210752);
this.fontRenderer.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
}
@@ -93,4 +93,15 @@ public class GuiFluidSlot extends GuiCustomSlot implements IJEITargetSlot {
this.fluids.setFluidInSlot(this.slot, stack);
NetworkHandler.instance().sendToServer(new PacketFluidSlot(Collections.singletonMap(this.getId(), this.getFluidStack())));
}
@Override
public boolean needAccept() {
return this.getFluidStack() == null;
}
@Override
public Object getIngredient() {
return this.getFluidStack() == null ? null : this.getFluidStack().getFluidStack();
}
}
@@ -147,4 +147,9 @@ public class GuiFluidTank extends GuiCustomSlot implements ITooltip {
}
}
@Override
public Object getIngredient() {
return this.getFluidStack() == null ? null : this.getFluidStack().getFluidStack();
}
}
@@ -32,6 +32,7 @@ import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
@@ -48,6 +49,8 @@ import appeng.api.util.IConfigManager;
import appeng.capabilities.Capabilities;
import appeng.core.settings.TickRates;
import appeng.fluids.util.AEFluidInventory;
import appeng.fluids.util.AEFluidStack;
import appeng.fluids.util.AENetworkFluidInventory;
import appeng.fluids.util.IAEFluidInventory;
import appeng.fluids.util.IAEFluidTank;
import appeng.helpers.ICustomNameObject;
@@ -89,6 +92,7 @@ import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.EnumSet;
import java.util.HashSet;
@@ -108,7 +112,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
private final UpgradeInventory upgrades;
private boolean hasConfig = false;
private final IStorageMonitorableAccessor accessor = this::getMonitorable;
private final AEFluidInventory tanks = new AEFluidInventory(this, NUMBER_OF_TANKS, TANK_CAPACITY);
private final AEFluidInventory tanks;
private final AEFluidInventory config = new AEFluidInventory(this, NUMBER_OF_TANKS);
private final IAEFluidStack[] requireWork;
private int isWorking = -1;
@@ -130,6 +134,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
this.mySource = new MachineSource(this.iHost);
this.interfaceRequestSource = new InterfaceRequestSource(this.iHost);
this.tanks = new AENetworkFluidInventory(this::getStorageGrid, this.mySource, this, NUMBER_OF_TANKS, TANK_CAPACITY);
this.fluids.setChangeSource(this.mySource);
this.items.setChangeSource(this.mySource);
@@ -140,6 +145,15 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
}
}
@Nullable
private IStorageGrid getStorageGrid() {
try {
return this.gridProxy.getStorage();
} catch (GridAccessException e) {
return null;
}
}
public IUpgradeableHost getHost() {
return this.iHost;
}
@@ -210,8 +224,8 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
this.items.setInternal(this.gridProxy.getStorage().getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)));
this.fluids.setInternal(this.gridProxy.getStorage().getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)));
} catch (final GridAccessException gae) {
this.items.setInternal(new NullInventory<IAEItemStack>());
this.fluids.setInternal(new NullInventory<IAEFluidStack>());
this.items.setInternal(new NullInventory<>());
this.fluids.setInternal(new NullInventory<>());
}
this.notifyNeighbors();
@@ -473,7 +487,22 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
}
@Override
public void onFluidInventoryChanged(final IAEFluidTank inventory, final int slot) {
public void onFluidInventoryChanged(IAEFluidTank inv, int slot) {
onFluidInventoryChanged(inv, slot, null, null, null);
}
@Override
public void onFluidInventoryChanged(final IAEFluidTank inventory, FluidStack added, FluidStack removed) {
if (inventory == this.tanks) {
if (added != null) {
iHost.onStackReturnNetwork(AEFluidStack.fromFluidStack(added));
}
this.saveChanges();
}
}
@Override
public void onFluidInventoryChanged(final IAEFluidTank inventory, final int slot, InvOperation operation, FluidStack added, FluidStack removed) {
if (this.isWorking == slot) {
return;
}
@@ -486,6 +515,9 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
this.notifyNeighbors();
}
} else if (inventory == this.tanks) {
if (added != null) {
iHost.onStackReturnNetwork(AEFluidStack.fromFluidStack(added));
}
this.saveChanges();
final boolean had = this.hasWorkToDo();
@@ -21,9 +21,11 @@ package appeng.fluids.helper;
import appeng.api.implementations.IUpgradeableHost;
import appeng.api.networking.security.IActionHost;
import appeng.api.storage.data.IAEFluidStack;
import appeng.me.helpers.IGridProxyable;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.FluidStack;
import java.util.EnumSet;
@@ -36,4 +38,7 @@ public interface IFluidInterfaceHost extends IActionHost, IGridProxyable, IUpgra
TileEntity getTileEntity();
void saveChanges();
default void onStackReturnNetwork(IAEFluidStack stack) {
}
}
@@ -22,6 +22,7 @@ package appeng.fluids.items;
import appeng.bootstrap.IItemRendering;
import appeng.bootstrap.ItemRenderingCustomizer;
import appeng.client.render.DummyFluidItemModel;
import net.minecraftforge.fluids.FluidStack;
/**
@@ -33,5 +34,9 @@ public class FluidDummyItemRendering extends ItemRenderingCustomizer {
@Override
public void customize(IItemRendering rendering) {
rendering.builtInModel("models/item/dummy_fluid_item", new DummyFluidItemModel());
rendering.color(((s, i) -> {
FluidStack fluid = ((FluidDummyItem) s.getItem()).getFluidStack(s);
return fluid != null ? fluid.getFluid().getColor() : 0xFFFFFFFF;
}));
}
}
@@ -194,10 +194,11 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
IItemList<IAEFluidStack> currentlyOnStorage = AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class).createList();
for (IFluidTankProperties tankProperty : tankProperties) {
if (this.mode == StorageFilter.EXTRACTABLE_ONLY && this.fluidHandler.drain(1, false) == null) {
var contents = tankProperty.getContents();
if (this.mode == StorageFilter.EXTRACTABLE_ONLY && this.fluidHandler.drain(contents, false) == null) {
continue;
}
currentlyOnStorage.add(AEFluidStack.fromFluidStack(tankProperty.getContents()));
currentlyOnStorage.add(AEFluidStack.fromFluidStack(contents));
}
for (final IAEFluidStack is : currentlyCached) {
@@ -29,6 +29,7 @@ import appeng.me.storage.MEInventoryHandler;
import appeng.parts.automation.PartAbstractFormationPlane;
import appeng.parts.automation.PlaneModels;
import appeng.util.Platform;
import appeng.util.inv.InvOperation;
import appeng.util.prioritylist.PrecisePriorityList;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
@@ -36,6 +36,7 @@ import appeng.parts.PartModel;
import appeng.parts.automation.PartUpgradeable;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import appeng.util.inv.InvOperation;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -46,6 +47,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler;
import java.util.Random;
@@ -63,6 +63,7 @@ import appeng.parts.automation.PartUpgradeable;
import appeng.tile.networking.TileCableBus;
import appeng.util.ConfigManager;
import appeng.util.Platform;
import appeng.util.inv.InvOperation;
import appeng.util.prioritylist.FuzzyPriorityList;
import appeng.util.prioritylist.PrecisePriorityList;
import net.minecraft.entity.player.EntityPlayer;
@@ -75,11 +76,13 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
@@ -220,11 +223,13 @@ public class PartFluidStorageBus extends PartUpgradeable implements IGridTickabl
@Override
public void postChange(final IBaseMonitor<IAEFluidStack> monitor, final Iterable<IAEFluidStack> change, final IActionSource source) {
if (this.getProxy().isActive()) {
var filteredChanges = this.filterChanges(change);
AccessRestriction currentAccess = (AccessRestriction) ((ConfigManager) this.getConfigManager()).getSetting(Settings.ACCESS);
if (readOncePass) {
readOncePass = false;
try {
this.getProxy().getStorage().postAlterationOfStoredItems(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class), change, this.source);
this.getProxy().getStorage().postAlterationOfStoredItems(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class), filteredChanges, this.source);
} catch (final GridAccessException e) {
// :(
}
@@ -234,7 +239,7 @@ public class PartFluidStorageBus extends PartUpgradeable implements IGridTickabl
return;
}
try {
this.getProxy().getStorage().postAlterationOfStoredItems(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class), change, source);
this.getProxy().getStorage().postAlterationOfStoredItems(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class), filteredChanges, source);
} catch (final GridAccessException e) {
// :(
}
@@ -426,6 +431,7 @@ public class PartFluidStorageBus extends PartUpgradeable implements IGridTickabl
this.handler.setBaseAccess((AccessRestriction) this.getConfigManager().getSetting(Settings.ACCESS));
this.handler.setWhitelist(this.getInstalledUpgrades(Upgrades.INVERTER) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST);
this.handler.setPriority(this.getPriority());
this.handler.setStorageFilter((StorageFilter) this.getConfigManager().getSetting(Settings.STORAGE_FILTER));
final IItemList<IAEFluidStack> priorityList = AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class).createList();
@@ -537,4 +543,27 @@ public class PartFluidStorageBus extends PartUpgradeable implements IGridTickabl
public GuiBridge getGuiBridge() {
return GuiBridge.GUI_STORAGEBUS_FLUID;
}
// TODO: 1/28/2024 Unify both methods.
/**
* Filters the changes to only include items that pass the storage filter.
* Optimally, this should be handled by the underlying monitor.
*
* @see appeng.parts.misc.PartStorageBus#filterChanges
*/
protected Iterable<IAEFluidStack> filterChanges(Iterable<IAEFluidStack> change) {
var storageFilter = this.getConfigManager().getSetting(Settings.STORAGE_FILTER);
if (storageFilter == StorageFilter.EXTRACTABLE_ONLY && handler != null) {
var filteredList = new ArrayList<IAEFluidStack>();
for (final IAEFluidStack stack : change) {
if (this.handler.passesBlackOrWhitelist(stack)) {
filteredList.add(stack);
}
}
return filteredList;
}
return change;
}
}
@@ -4,6 +4,7 @@ package appeng.fluids.util;
import appeng.api.storage.data.IAEFluidStack;
import appeng.core.AELog;
import appeng.util.Platform;
import appeng.util.inv.InvOperation;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidTankProperties;
@@ -13,7 +14,7 @@ import java.util.Objects;
public class AEFluidInventory implements IAEFluidTank {
private final IAEFluidStack[] fluids;
private final IAEFluidInventory handler;
protected final IAEFluidInventory handler;
private int capacity;
private IFluidTankProperties[] props = null;
@@ -37,24 +38,27 @@ public class AEFluidInventory implements IAEFluidTank {
if (Objects.equals(this.fluids[slot], fluid)) {
if (fluid != null && fluid.getStackSize() != this.fluids[slot].getStackSize()) {
this.fluids[slot].setStackSize(fluid.getStackSize());
this.onContentChanged(slot);
this.onContentChanged(slot, InvOperation.SET, fluid.getFluidStack(), null);
}
} else {
if (fluid == null) {
IAEFluidStack removeStack = this.fluids[slot].copy();
this.fluids[slot] = null;
this.onContentChanged(slot, InvOperation.SET, null, removeStack.getFluidStack());
} else {
IAEFluidStack removeStack = this.fluids[slot];
this.fluids[slot] = fluid.copy();
this.fluids[slot].setStackSize(fluid.getStackSize());
this.onContentChanged(slot, InvOperation.SET, fluid.getFluidStack(), removeStack == null ? null : removeStack.getFluidStack());
}
this.onContentChanged(slot);
}
}
}
private void onContentChanged(final int slot) {
private void onContentChanged(final int slot, InvOperation operation, FluidStack added, FluidStack removed) {
if (this.handler != null && Platform.isServer()) {
this.handler.onFluidInventoryChanged(this, slot);
this.handler.onFluidInventoryChanged(this, slot, operation, added, removed);
}
}
@@ -107,7 +111,7 @@ public class AEFluidInventory implements IAEFluidTank {
this.setFluidInSlot(slot, AEFluidStack.fromFluidStack(resource).setStackSize(amountToStore));
} else {
fluid.setStackSize(fluid.getStackSize() + amountToStore);
this.onContentChanged(slot);
this.onContentChanged(slot, InvOperation.INSERT, resource, null);
}
}
@@ -139,7 +143,7 @@ public class AEFluidInventory implements IAEFluidTank {
if (fluid.getStackSize() <= 0) {
this.fluids[slot] = null;
}
this.onContentChanged(slot);
this.onContentChanged(slot, InvOperation.EXTRACT, null, new FluidStack(fluid.getFluid(), drained));
}
return stack;
}
@@ -21,6 +21,7 @@ package appeng.fluids.util;
import appeng.api.storage.data.IAEFluidStack;
import appeng.util.Platform;
import appeng.util.inv.InvOperation;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.FluidTank;
@@ -0,0 +1,55 @@
package appeng.fluids.util;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import net.minecraftforge.fluids.FluidStack;
import java.util.function.Supplier;
public class AENetworkFluidInventory extends AEFluidInventory {
private final Supplier<IStorageGrid> supplier;
private final IActionSource source;
public AENetworkFluidInventory(Supplier<IStorageGrid> networkSupplier, IActionSource source, IAEFluidInventory handler, int slots, int capcity) {
super(handler, slots, capcity);
this.supplier = networkSupplier;
this.source = source;
}
@Override
public int fill(final FluidStack fluid, final boolean doFill) {
if (fluid == null || fluid.amount <= 0) {
return 0;
}
IStorageGrid storage = supplier.get();
if (storage != null) {
int originAmt = fluid.amount;
IMEInventory<IAEFluidStack> dest = storage.getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class));
IAEFluidStack overflow = dest.injectItems(AEFluidStack.fromFluidStack(fluid), doFill ? Actionable.MODULATE : Actionable.SIMULATE, this.source);
if (overflow != null && overflow.getStackSize() == originAmt) {
return super.fill(fluid, doFill);
} else if (overflow != null) {
if (doFill) {
FluidStack added = fluid.copy();
added.amount = (int) (fluid.amount - overflow.getStackSize());
this.handler.onFluidInventoryChanged(this, added, null);
}
return (int) (originAmt - overflow.getStackSize());
} else {
if (doFill) {
this.handler.onFluidInventoryChanged(this, fluid, null);
}
return originAmt;
}
} else {
return super.fill(fluid, doFill);
}
}
}
@@ -19,7 +19,17 @@
package appeng.fluids.util;
import appeng.util.inv.InvOperation;
import net.minecraftforge.fluids.FluidStack;
@FunctionalInterface
public interface IAEFluidInventory {
void onFluidInventoryChanged(final IAEFluidTank inv, final int slot);
default void onFluidInventoryChanged(final IAEFluidTank inv, final int slot, InvOperation operation, FluidStack added, FluidStack removed) {
}
default void onFluidInventoryChanged(final IAEFluidTank inv, FluidStack added, FluidStack removed) {
}
}
@@ -20,10 +20,7 @@ package appeng.helpers;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
import appeng.api.config.YesNo;
import appeng.api.config.*;
import appeng.api.implementations.ICraftingPatternItem;
import appeng.api.implementations.IUpgradeableHost;
import appeng.api.implementations.tiles.ICraftingMachine;
@@ -38,10 +35,12 @@ import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.events.MENetworkCraftingPatternChange;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartHost;
import appeng.api.storage.*;
import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel;
@@ -53,9 +52,11 @@ import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.IConfigManager;
import appeng.capabilities.Capabilities;
import appeng.core.AELog;
import appeng.core.settings.TickRates;
import appeng.me.GridAccessException;
import appeng.me.helpers.AENetworkProxy;
import appeng.me.helpers.IGridProxyable;
import appeng.me.helpers.MachineSource;
import appeng.me.storage.MEMonitorIInventory;
import appeng.me.storage.MEMonitorPassThrough;
@@ -65,7 +66,7 @@ import appeng.parts.automation.UpgradeInventory;
import appeng.parts.misc.PartInterface;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.AppEngInternalOversizedInventory;
import appeng.tile.inventory.AppEngNetworkInventory;
import appeng.tile.networking.TileCableBus;
import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
@@ -78,6 +79,7 @@ import com.google.common.primitives.Ints;
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
import gregtech.api.block.machines.BlockMachine;
import gregtech.api.metatileentity.MetaTileEntity;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Items;
@@ -93,15 +95,16 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.RangedWrapper;
import javax.annotation.Nullable;
import java.util.*;
import static appeng.helpers.ItemStackHelper.*;
import static appeng.api.config.LockCraftingMode.LOCK_UNTIL_PULSE;
import static appeng.api.config.LockCraftingMode.LOCK_UNTIL_RESULT;
import static appeng.helpers.ItemStackHelper.stackFromNBT;
import static appeng.helpers.ItemStackHelper.stackToNBT;
public class DualityInterface implements IGridTickable, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory, IConfigManagerHost, ICraftingProvider, IUpgradeableHost {
@@ -118,7 +121,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
private final IActionSource interfaceRequestSource;
private final ConfigManager cm = new ConfigManager(this);
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, NUMBER_OF_CONFIG_SLOTS, 512);
private final AppEngInternalInventory storage = new AppEngInternalOversizedInventory(this, NUMBER_OF_STORAGE_SLOTS, 512);
private final AppEngInternalInventory storage;
private final AppEngInternalInventory patterns = new AppEngInternalInventory(this, NUMBER_OF_PATTERN_SLOTS, 1);
private final MEMonitorPassThrough<IAEItemStack> items = new MEMonitorPassThrough<>(new NullInventory<IAEItemStack>(), AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
private final MEMonitorPassThrough<IAEFluidStack> fluids = new MEMonitorPassThrough<>(new NullInventory<IAEFluidStack>(), AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class));
@@ -126,7 +129,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
private final Accessor accessor = new Accessor();
private boolean hasConfig = false;
private int priority;
private List<ICraftingPatternDetails> craftingList = null;
private Set<ICraftingPatternDetails> craftingList = null;
private List<ItemStack> waitingToSend = null;
private IMEInventory<IAEItemStack> destination;
private int isWorking = -1;
@@ -135,6 +138,13 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
private boolean resetConfigCache = true;
private IMEMonitor<IAEItemStack> configCachedHandler;
private YesNo redstoneState = YesNo.UNDECIDED;
@Nullable
private UnlockCraftingEvent unlockEvent;
@Nullable
private IAEItemStack unlockStack;
public DualityInterface(final AENetworkProxy networkProxy, final IInterfaceHost ih) {
this.gridProxy = networkProxy;
this.gridProxy.setFlags(GridFlags.REQUIRE_CHANNEL);
@@ -142,18 +152,29 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
this.upgrades = new StackUpgradeInventory(this.gridProxy.getMachineRepresentation(), this, 4);
this.cm.registerSetting(Settings.BLOCK, YesNo.NO);
this.cm.registerSetting(Settings.INTERFACE_TERMINAL, YesNo.YES);
this.cm.registerSetting(Settings.UNLOCK, LockCraftingMode.NONE);
this.iHost = ih;
this.craftingTracker = new MultiCraftingTracker(this.iHost, 9);
final MachineSource actionSource = new MachineSource(this.iHost);
this.mySource = actionSource;
this.storage = new AppEngNetworkInventory(this::getStorageGrid, this.mySource, this, NUMBER_OF_STORAGE_SLOTS, 512);
this.fluids.setChangeSource(actionSource);
this.items.setChangeSource(actionSource);
this.interfaceRequestSource = new InterfaceRequestSource(this.iHost);
}
@Nullable
private IStorageGrid getStorageGrid() {
try {
return this.gridProxy.getStorage();
} catch (GridAccessException e) {
return null;
}
}
private static boolean invIsCustomBlocking(BlockingInventoryAdaptor inv) {
return (inv.containsBlockingItems());
}
@@ -168,6 +189,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
if (this.isWorking == slot) {
return;
}
if (inv == this.config && (!removed.isEmpty() || !added.isEmpty())) {
boolean cfg = hasConfig();
this.readConfig();
@@ -178,6 +200,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
} else if (inv == this.patterns && (!removed.isEmpty() || !added.isEmpty())) {
this.updateCraftingList();
} else if (inv == this.storage && slot >= 0) {
if (added != ItemStack.EMPTY){
iHost.onStackReturnNetwork(AEItemStack.fromItemStack(added));
}
final boolean had = this.hasWorkToDo();
this.updatePlan(slot);
@@ -207,6 +232,18 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
this.craftingTracker.writeToNBT(data);
data.setInteger("priority", this.priority);
if (unlockEvent == UnlockCraftingEvent.PULSE) {
data.setByte("unlockEvent", (byte) 1);
} else if (unlockEvent == UnlockCraftingEvent.RESULT) {
if (unlockStack != null) {
data.setByte("unlockEvent", (byte) 2);
NBTTagCompound unlockStackTag = new NBTTagCompound();
unlockStack.writeToNBT(unlockStackTag);
data.setTag("unlockStack", unlockStackTag);
} else {
AELog.error("Saving MEInterface {}, locked waiting for stack, but stack is null!", iHost);
}
}
final NBTTagList waitingToSend = new NBTTagList();
if (this.waitingToSend != null) {
for (final ItemStack is : this.waitingToSend) {
@@ -286,6 +323,27 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
this.cm.readFromNBT(data);
this.readConfig();
this.updateCraftingList();
var unlockEventType = data.getByte("unlockEvent");
this.unlockEvent = switch (unlockEventType) {
case 0 -> null;
case 1 -> UnlockCraftingEvent.PULSE;
case 2 -> UnlockCraftingEvent.RESULT;
default -> {
AELog.error("Unknown unlock event type {} in NBT for MEInterface: {}", unlockEventType, data);
yield null;
}
};
if (this.unlockEvent == UnlockCraftingEvent.RESULT) {
this.unlockStack = AEItemStack.fromNBT(data.getCompoundTag("unlockStack"));
if (this.unlockStack == null) {
AELog.error("Could not load unlock stack for MEInterface from NBT: {}", data);
}
} else {
this.unlockStack = null;
}
}
private void addToSendList(final ItemStack is) {
@@ -395,10 +453,13 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
this.addToCraftingList(this.patterns.getStackInSlot(x));
}
}
try {
this.gridProxy.getGrid().postEvent(new MENetworkCraftingPatternChange(this, this.gridProxy.getNode()));
} catch (GridAccessException e) {
e.printStackTrace();
if (newPattern || removed) {
try {
this.gridProxy.getGrid().postEvent(new MENetworkCraftingPatternChange(this, this.gridProxy.getNode()));
} catch (GridAccessException e) {
e.printStackTrace();
}
}
}
@@ -483,13 +544,12 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
return;
}
if (is.getItem() instanceof ICraftingPatternItem) {
final ICraftingPatternItem cpi = (ICraftingPatternItem) is.getItem();
if (is.getItem() instanceof ICraftingPatternItem cpi) {
final ICraftingPatternDetails details = cpi.getPatternForItem(is, this.iHost.getTileEntity().getWorld());
if (details != null) {
if (this.craftingList == null) {
this.craftingList = new ArrayList<>();
this.craftingList = new ObjectOpenHashSet<>();
}
this.craftingList.add(details);
@@ -822,7 +882,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
}
private InventoryAdaptor getAdaptor(final int slot) {
return new AdaptorItemHandler(new RangedWrapper(this.storage, slot, slot + 1));
return new AdaptorItemHandler(((AppEngNetworkInventory) this.storage).getBufferWrapper(slot));
}
private boolean handleCrafting(final int x, final InventoryAdaptor d, final IAEItemStack itemStack) {
@@ -903,7 +963,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
}
@Override
public appeng.api.util.IConfigManager getConfigManager() {
public IConfigManager getConfigManager() {
return this.cm;
}
@@ -912,6 +972,11 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
if (this.getInstalledUpgrades(Upgrades.CRAFTING) == 0) {
this.cancelCrafting();
}
if (newValue == LockCraftingMode.NONE) {
resetCraftingLock();
}
this.iHost.saveChanges();
}
@@ -951,53 +1016,74 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
final TileEntity tile = this.iHost.getTileEntity();
final World w = tile.getWorld();
if (getCraftingLockedReason() != LockCraftingMode.NONE) {
return false;
}
if (this.visitedFaces.isEmpty()) {
this.visitedFaces = this.iHost.getTargets();
}
for (final EnumFacing s : visitedFaces) {
final TileEntity te = w.getTileEntity(tile.getPos().offset(s));
if (te instanceof IInterfaceHost || (te instanceof TileCableBus && ((TileCableBus) te).getPart(s.getOpposite()) instanceof PartInterface)) {
if (te == null) {
visitedFaces.remove(s);
continue;
}
var mon = te.getCapability(Capabilities.STORAGE_MONITORABLE_ACCESSOR, s.getOpposite());
if (mon != null) {
visitedFaces.remove(s);
try {
IInterfaceHost targetTE;
if (te instanceof IInterfaceHost) {
targetTE = (IInterfaceHost) te;
IGridProxyable proxyable;
if (te instanceof IGridProxyable) {
proxyable = (IGridProxyable) te;
} else if (te instanceof IPartHost partHost) {
proxyable = (IGridProxyable) partHost.getPart(s.getOpposite());
} else {
targetTE = (IInterfaceHost) ((TileCableBus) te).getPart(s.getOpposite());
continue;
}
if (targetTE.getInterfaceDuality().sameGrid(this.gridProxy.getGrid())) {
if (proxyable.getProxy().getGrid() == this.gridProxy.getGrid()) {
continue;
} else {
IStorageMonitorableAccessor mon = te.getCapability(Capabilities.STORAGE_MONITORABLE_ACCESSOR, s.getOpposite());
if (mon != null) {
IStorageMonitorable sm = mon.getInventory(this.mySource);
if (sm != null && Platform.canAccess(targetTE.getInterfaceDuality().gridProxy, this.mySource)) {
if (this.isBlocking() && sm.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)).getStorageList().size() > 0) {
}
IStorageMonitorable sm = mon.getInventory(this.mySource);
if (sm != null && Platform.canAccess(proxyable.getProxy(), this.mySource)) {
if (this.isBlocking() && !sm.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)).getStorageList().isEmpty()) {
continue;
} else {
IMEMonitor<IAEItemStack> inv = sm.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
var allItemsCanBeInserted = true;
for (int x = 0; x < table.getSizeInventory(); x++) {
final ItemStack is = table.getStackInSlot(x);
if (is.isEmpty()) {
continue;
} else {
IMEMonitor<IAEItemStack> inv = sm.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
for (int x = 0; x < table.getSizeInventory(); x++) {
final ItemStack is = table.getStackInSlot(x);
if (is.isEmpty()) {
continue;
}
IAEItemStack result = inv.injectItems(AEItemStack.fromItemStack(is), Actionable.SIMULATE, this.mySource);
if (result != null) {
return false;
}
}
for (int x = 0; x < table.getSizeInventory(); x++) {
final ItemStack is = table.getStackInSlot(x);
if (!is.isEmpty()) {
addToSendListFacing(is, s);
}
}
pushItemsOut(s);
return true;
}
IAEItemStack result = inv.injectItems(AEItemStack.fromItemStack(is), Actionable.SIMULATE, this.mySource);
if (result != null) {
allItemsCanBeInserted = false;
break;
}
}
if (!allItemsCanBeInserted) {
continue;
}
this.visitedFaces.clear();
for (int x = 0; x < table.getSizeInventory(); x++) {
final ItemStack is = table.getStackInSlot(x);
if (!is.isEmpty()) {
addToSendListFacing(is, s);
}
}
onPushPatternSuccess(patternDetails);
pushItemsOut(s);
return true;
}
}
} catch (final GridAccessException e) {
@@ -1006,11 +1092,11 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
continue;
}
if (te instanceof ICraftingMachine) {
final ICraftingMachine cm = (ICraftingMachine) te;
if (te instanceof ICraftingMachine cm) {
if (cm.acceptsPlans()) {
visitedFaces.remove(s);
if (cm.pushPattern(patternDetails, table, s.getOpposite())) {
onPushPatternSuccess(patternDetails);
return true;
}
continue;
@@ -1021,7 +1107,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
if (ad != null) {
if (this.isBlocking()) {
IPhantomTile phantomTE;
if (Loader.isModLoaded("actuallyadditions") && te instanceof IPhantomTile) {
if (Platform.isModLoaded("actuallyadditions") && te instanceof IPhantomTile) {
phantomTE = ((IPhantomTile) te);
if (phantomTE.hasBoundPosition()) {
TileEntity phantom = w.getTileEntity(phantomTE.getBoundPosition());
@@ -1044,13 +1130,14 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
}
if (this.acceptsItems(ad, table)) {
visitedFaces.remove(s);
this.visitedFaces.clear();
for (int x = 0; x < table.getSizeInventory(); x++) {
final ItemStack is = table.getStackInSlot(x);
if (!is.isEmpty()) {
addToSendListFacing(is, s);
}
}
onPushPatternSuccess(patternDetails);
pushItemsOut(s);
return true;
}
@@ -1060,6 +1147,57 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
return false;
}
public void resetCraftingLock() {
if (unlockEvent != null) {
unlockEvent = null;
unlockStack = null;
saveChanges();
}
}
private void onPushPatternSuccess(ICraftingPatternDetails pattern) {
resetCraftingLock();
LockCraftingMode lockMode = (LockCraftingMode) cm.getSetting(Settings.UNLOCK);
switch (lockMode) {
case LOCK_UNTIL_PULSE -> {
unlockEvent = UnlockCraftingEvent.PULSE;
saveChanges();
}
case LOCK_UNTIL_RESULT -> {
unlockEvent = UnlockCraftingEvent.RESULT;
unlockStack = pattern.getPrimaryOutput().copy();
saveChanges();
}
}
}
/**
* Gets if the crafting lock is in effect and why.
*
* @return {@link LockCraftingMode#NONE} if the lock isn't in effect
*/
public LockCraftingMode getCraftingLockedReason() {
var lockMode = cm.getSetting(Settings.UNLOCK);
if (lockMode == LockCraftingMode.LOCK_WHILE_LOW && !getRedstoneState()) {
// Crafting locked by redstone signal
return LockCraftingMode.LOCK_WHILE_LOW;
} else if (lockMode == LockCraftingMode.LOCK_WHILE_HIGH && getRedstoneState()) {
return LockCraftingMode.LOCK_WHILE_HIGH;
} else if (unlockEvent != null) {
// Crafting locked by waiting for unlock event
switch (unlockEvent) {
case PULSE -> {
return LOCK_UNTIL_PULSE;
}
case RESULT -> {
return LOCK_UNTIL_RESULT;
}
}
}
return LockCraftingMode.NONE;
}
@Override
public boolean isBusy() {
boolean busy = false;
@@ -1109,8 +1247,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
final InventoryAdaptor ad = InventoryAdaptor.getAdaptor(te, s.getOpposite());
if (ad != null) {
if (Loader.isModLoaded("actuallyadditions") && Platform.GTLoaded && te instanceof IPhantomTile) {
IPhantomTile phantomTE = ((IPhantomTile) te);
if (Platform.isModLoaded("actuallyadditions") && Platform.GTLoaded && te instanceof IPhantomTile phantomTE) {
if (phantomTE.hasBoundPosition()) {
TileEntity phantom = w.getTileEntity(phantomTE.getBoundPosition());
if (NonBlockingItems.INSTANCE.getMap().containsKey(w.getBlockState(phantomTE.getBoundPosition()).getBlock().getRegistryName().getNamespace())) {
@@ -1323,7 +1460,13 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
}
if (what.getItem() != Items.AIR) {
return what.getItem().getItemStackDisplayName(what);
/* getTranslationKey() and getUnlocalizedNameInefficiently() have different return values in some mod
* For the Thermal Expansion
* getTranslationKey() returns complete key ending with ".name".
* getUnlocalizedNameInefficiently() returns localized name
* Because CoFH Core overrides method getTranslationKey()
*/
return what.getItem().getTranslationKey(what);
}
final Item item = Item.getItemFromBlock(directedBlock);
@@ -1338,7 +1481,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
public long getSortValue() {
final TileEntity te = this.iHost.getTileEntity();
return (te.getPos().getZ() << 24) ^ (te.getPos().getX() << 8) ^ te.getPos().getY();
return ((long) te.getPos().getZ() << 24) ^ ((long) te.getPos().getX() << 8) ^ te.getPos().getY();
}
public void initialize() {
@@ -1374,6 +1517,55 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
return null;
}
public void updateRedstoneState() {
// If we're waitingh for a pulse, update immediately
if (unlockEvent == UnlockCraftingEvent.PULSE && getRedstoneState()) {
unlockEvent = null; // Unlocked!
} else {
// Otherwise, just reset back to undecided
redstoneState = YesNo.UNDECIDED;
}
saveChanges(); // In any case, this needs to be changed since the state is now outdated
}
/**
* @return Null if {@linkplain #getCraftingLockedReason()} is not {@link LockCraftingMode#LOCK_UNTIL_RESULT}.
*/
@Nullable
public IAEItemStack getUnlockStack() {
return unlockStack;
}
public void onStackReturnedToNetwork(IAEItemStack stack) {
if (unlockEvent != UnlockCraftingEvent.RESULT) {
return; // If we're not waiting for the result, we don't care
}
if (unlockStack == null) {
// Actually an error state...
AELog.error("MEInterface was waiting for RESULT, but no result was set");
unlockEvent = null;
} else if (unlockStack.isSameType(stack)) {
var remainingAmount = unlockStack.getStackSize() - stack.getStackSize();
if (remainingAmount <= 0) {
unlockEvent = null;
unlockStack = null;
} else {
unlockStack.setStackSize(remainingAmount);
}
}
}
private boolean getRedstoneState() {
if (redstoneState == YesNo.UNDECIDED) {
var entity = this.iHost.getTileEntity();
redstoneState = entity.getWorld().getRedstonePowerFromNeighbors(entity.getPos()) > 0
? YesNo.YES
: YesNo.NO;
}
return redstoneState == YesNo.YES;
}
private class InterfaceRequestSource extends MachineSource {
private final InterfaceRequestContext context;
@@ -22,6 +22,7 @@ package appeng.helpers;
import appeng.api.implementations.IUpgradeableHost;
import appeng.api.networking.crafting.ICraftingProvider;
import appeng.api.networking.crafting.ICraftingRequester;
import appeng.api.storage.data.IAEItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
@@ -37,4 +38,8 @@ public interface IInterfaceHost extends ICraftingProvider, IUpgradeableHost, ICr
TileEntity getTileEntity();
void saveChanges();
default void onStackReturnNetwork(IAEItemStack stack) {
getInterfaceDuality().onStackReturnedToNetwork(stack);
}
}
@@ -9,7 +9,6 @@ import it.unimi.dsi.fastutil.ints.IntSet;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.OreDictionary;
@@ -24,65 +23,30 @@ public class NonBlockingItems {
private NonBlockingItems() {
String[] strings = AEConfig.instance().getNonBlockingItems();
String[] modids = new String[0];
if (strings.length > 0) {
for (String s : strings) {
if (s.startsWith("[") && s.endsWith("]")) {
modids = s.substring(1, s.length() - 1).split("\\|");
} else {
for (String modid : modids) {
if (!Loader.isModLoaded(modid)) {
continue;
}
NON_BLOCKING_MAP.putIfAbsent(modid, new Object2ObjectOpenHashMap<>());
for (String s : strings) {
if (s.startsWith("[") && s.endsWith("]")) {
modids = s.substring(1, s.length() - 1).split("\\|");
} else {
for (String modid : modids) {
if (!Platform.isModLoaded(modid)) {
continue;
}
NON_BLOCKING_MAP.putIfAbsent(modid, new Object2ObjectOpenHashMap<>());
String[] ModItemMeta = s.split(":");
String[] ModItemMeta = s.split(":");
if (ModItemMeta.length < 2 || ModItemMeta.length > 3) {
AELog.error("Invalid non blocking item entry: " + s);
continue;
}
if (ModItemMeta.length < 2 || ModItemMeta.length > 3) {
AELog.error("Invalid non blocking item entry: " + s);
continue;
}
if (ModItemMeta[0].equals("gregtech") && Platform.GTLoaded) {
boolean found = false;
for (MetaItem<?> metaItem : MetaItem.getMetaItems()) {
MetaItem<?>.MetaValueItem metaItem2 = metaItem.getItem(ModItemMeta[1]);
if (metaItem.getItem(ModItemMeta[1]) != null) {
found = true;
ItemStack itemStack = metaItem2.getStackForm();
NON_BLOCKING_MAP.get(modid).putIfAbsent(itemStack.getItem(), new IntOpenHashSet());
NON_BLOCKING_MAP.get(modid).computeIfPresent(itemStack.getItem(), (item, intSet) ->
{
intSet.add(itemStack.getItemDamage());
return intSet;
});
} else {
ItemStack itemStack = GameRegistry.makeItemStack(ModItemMeta[0] + ":" + ModItemMeta[1], ModItemMeta.length == 3 ? Integer.parseInt(ModItemMeta[2]) : 0, 1, null);
if (!itemStack.isEmpty()) {
NON_BLOCKING_MAP.get(modid).putIfAbsent(itemStack.getItem(), new IntOpenHashSet());
NON_BLOCKING_MAP.get(modid).computeIfPresent(itemStack.getItem(), (item, intSet) ->
{
intSet.add(itemStack.getItemDamage());
return intSet;
});
}
}
}
if (!found) {
AELog.error("Item not found on nonBlocking config: " + s);
}
} else if (ModItemMeta[0].equals("ore")) {
OreDictionary.getOres(ModItemMeta[1]).forEach(itemStack ->
{
NON_BLOCKING_MAP.get(modid).putIfAbsent(itemStack.getItem(), new IntOpenHashSet());
NON_BLOCKING_MAP.get(modid).computeIfPresent(itemStack.getItem(), (item, intSet) ->
{
intSet.add(itemStack.getItemDamage());
return intSet;
});
});
} else {
ItemStack itemStack = GameRegistry.makeItemStack(ModItemMeta[0] + ":" + ModItemMeta[1], ModItemMeta.length == 3 ? Integer.parseInt(ModItemMeta[2]) : 0, 1, null);
if (!itemStack.isEmpty()) {
if (ModItemMeta[0].equals("gregtech") && Platform.GTLoaded) {
boolean found = false;
for (MetaItem<?> metaItem : MetaItem.getMetaItems()) {
MetaItem<?>.MetaValueItem metaItem2 = metaItem.getItem(ModItemMeta[1]);
if (metaItem.getItem(ModItemMeta[1]) != null) {
found = true;
ItemStack itemStack = metaItem2.getStackForm();
NON_BLOCKING_MAP.get(modid).putIfAbsent(itemStack.getItem(), new IntOpenHashSet());
NON_BLOCKING_MAP.get(modid).computeIfPresent(itemStack.getItem(), (item, intSet) ->
{
@@ -90,9 +54,42 @@ public class NonBlockingItems {
return intSet;
});
} else {
AELog.error("Item not found on nonBlocking config: " + s);
ItemStack itemStack = GameRegistry.makeItemStack(ModItemMeta[0] + ":" + ModItemMeta[1], ModItemMeta.length == 3 ? Integer.parseInt(ModItemMeta[2]) : 0, 1, null);
if (!itemStack.isEmpty()) {
NON_BLOCKING_MAP.get(modid).putIfAbsent(itemStack.getItem(), new IntOpenHashSet());
NON_BLOCKING_MAP.get(modid).computeIfPresent(itemStack.getItem(), (item, intSet) ->
{
intSet.add(itemStack.getItemDamage());
return intSet;
});
}
}
}
if (!found) {
AELog.error("Item not found on nonBlocking config: " + s);
}
} else if (ModItemMeta[0].equals("ore")) {
OreDictionary.getOres(ModItemMeta[1]).forEach(itemStack ->
{
NON_BLOCKING_MAP.get(modid).putIfAbsent(itemStack.getItem(), new IntOpenHashSet());
NON_BLOCKING_MAP.get(modid).computeIfPresent(itemStack.getItem(), (item, intSet) ->
{
intSet.add(itemStack.getItemDamage());
return intSet;
});
});
} else {
ItemStack itemStack = GameRegistry.makeItemStack(ModItemMeta[0] + ":" + ModItemMeta[1], ModItemMeta.length == 3 ? Integer.parseInt(ModItemMeta[2]) : 0, 1, null);
if (!itemStack.isEmpty()) {
NON_BLOCKING_MAP.get(modid).putIfAbsent(itemStack.getItem(), new IntOpenHashSet());
NON_BLOCKING_MAP.get(modid).computeIfPresent(itemStack.getItem(), (item, intSet) ->
{
intSet.add(itemStack.getItemDamage());
return intSet;
});
} else {
AELog.error("Item not found on nonBlocking config: " + s);
}
}
}
}
@@ -0,0 +1,6 @@
package appeng.helpers;
public enum UnlockCraftingEvent {
PULSE,
RESULT
}
@@ -14,6 +14,7 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@@ -32,15 +33,13 @@ public class WrenchClickHook {
if (event instanceof PlayerInteractEvent.RightClickBlock && !event.getEntityPlayer().world.isRemote) {
EntityPlayer player = event.getEntityPlayer();
if (player instanceof FakePlayer) return;
EnumHand hand = event.getHand();
BlockPos pos = event.getPos();
World world = event.getWorld();
ItemStack held = event.getItemStack();
if (!Platform.hasPermissions(new DimensionalCoord(world, pos), player)) {
return;
}
if (player.isSneaking() && Platform.isWrench(player, held, pos)) {
Block block = world.getBlockState(pos).getBlock();
TileEntity tile = world.getTileEntity(pos);
@@ -48,6 +47,10 @@ public class WrenchClickHook {
return;
}
if (!Platform.hasPermissions(new DimensionalCoord(world, pos), player)) {
return;
}
final LookDirection dir = Platform.getPlayerRay(player, player.getEyeHeight());
final RayTraceResult mop = block.collisionRayTrace(world.getBlockState(pos), world, pos, dir.getA(), dir.getB());
if (mop != null) {
@@ -22,7 +22,7 @@ package appeng.integration;
import appeng.api.exceptions.ModNotInstalledException;
import appeng.core.AEConfig;
import appeng.core.AELog;
import net.minecraftforge.fml.common.Loader;
import appeng.util.Platform;
import net.minecraftforge.fml.common.ModAPIManager;
@@ -64,7 +64,7 @@ final class IntegrationNode {
switch (stage) {
case PRE_INIT:
final ModAPIManager apiManager = ModAPIManager.INSTANCE;
boolean enabled = this.modID == null || Loader.isModLoaded(this.modID) || apiManager.hasAPI(this.modID);
boolean enabled = this.modID == null || Platform.isModLoaded(this.modID) || apiManager.hasAPI(this.modID);
AEConfig.instance()
.addCustomCategoryComment("ModIntegration",
@@ -1,13 +1,13 @@
package appeng.integration.modules.bogosorter;
import appeng.api.storage.data.IAEItemStack;
import appeng.util.Platform;
import com.cleanroommc.bogosorter.common.sort.SortHandler;
import net.minecraftforge.fml.common.Loader;
import java.util.Comparator;
public class InventoryBogoSortModule {
private static final boolean loaded = Loader.isModLoaded("bogosorter");
private static final boolean loaded = Platform.isModLoaded("bogosorter");
public static final Comparator<IAEItemStack> COMPARATOR = (o1, o2) -> SortHandler.getClientItemComparator().compare(o1.getDefinition(), o2.getDefinition());
@@ -31,9 +31,7 @@ import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import java.util.Collection;
import java.util.Collections;
import java.util.Optional;
import java.util.*;
import java.util.stream.Collectors;
@@ -49,25 +47,15 @@ public class InscriberRecipes {
return;
}
Collection<ItemStack> topList = CTModule.toStacks(top).orElse(Collections.singleton(ItemStack.EMPTY));
Collection<ItemStack> bottomList = CTModule.toStacks(bottom).orElse(Collections.singleton(ItemStack.EMPTY));
for (ItemStack topStack : topList) {
for (ItemStack bottomStack : bottomList) {
final IInscriberRecipeBuilder builder = AEApi.instance().registries().inscriber().builder();
builder.withProcessType(inscribe ? InscriberProcessType.INSCRIBE : InscriberProcessType.PRESS)
.withOutput(CTModule.toStack(output))
.withInputs(inStacks.get());
if (!topStack.isEmpty()) {
builder.withTopOptional(topStack);
}
if (!bottomStack.isEmpty()) {
builder.withBottomOptional(bottomStack);
}
CTModule.MODIFICATIONS.add(new Add(builder.build()));
}
}
List<ItemStack> topList = new ArrayList<>(CTModule.toStacks(top).orElse(Collections.singleton(ItemStack.EMPTY)));
List<ItemStack> bottomList = new ArrayList<>(CTModule.toStacks(bottom).orElse(Collections.singleton(ItemStack.EMPTY)));
final IInscriberRecipeBuilder builder = AEApi.instance().registries().inscriber().builder();
builder.withProcessType(inscribe ? InscriberProcessType.INSCRIBE : InscriberProcessType.PRESS).
withTopOptional(topList).
withBottomOptional(bottomList).
withOutput(CTModule.toStack(output))
.withInputs(inStacks.get());
CTModule.MODIFICATIONS.add(new Add(builder.build()));
}
@ZenMethod
@@ -21,11 +21,11 @@ package appeng.integration.modules.jei;
import appeng.api.features.IInscriberRecipe;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -40,11 +40,10 @@ class InscriberRecipeWrapper implements IRecipeWrapper {
@Override
public void getIngredients(IIngredients ingredients) {
List<List<ItemStack>> inputSlots = new ArrayList<>(3);
inputSlots.add(Collections.singletonList(this.recipe.getTopOptional().orElse(ItemStack.EMPTY)));
inputSlots.add(this.recipe.getTopInputs());
inputSlots.add(this.recipe.getInputs());
inputSlots.add(Collections.singletonList(this.recipe.getBottomOptional().orElse(ItemStack.EMPTY)));
ingredients.setInputLists(ItemStack.class, inputSlots);
ingredients.setOutput(ItemStack.class, this.recipe.getOutput());
inputSlots.add(this.recipe.getBottomInputs());
ingredients.setInputLists(VanillaTypes.ITEM, inputSlots);
ingredients.setOutput(VanillaTypes.ITEM, this.recipe.getOutput());
}
}
@@ -44,9 +44,11 @@ import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import mezz.jei.config.Constants;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
@@ -185,8 +187,17 @@ public class JEIPlugin implements IModPlugin {
private void registerFacadeRecipe(IDefinitions definitions, IModRegistry registry) {
Optional<Item> itemFacade = definitions.items().facade().maybeItem();
Optional<ItemStack> cableAnchor = definitions.parts().cableAnchor().maybeStack(1);
if (itemFacade.isPresent() && cableAnchor.isPresent() && AEConfig.instance().isFeatureEnabled(AEFeature.ENABLE_FACADE_CRAFTING)) {
registry.addRecipeRegistryPlugin(new FacadeRegistryPlugin((ItemFacade) itemFacade.get(), cableAnchor.get()));
if (itemFacade.isPresent()) {
var facade = (ItemFacade)itemFacade.get();
if (cableAnchor.isPresent() && AEConfig.instance().isFeatureEnabled(AEFeature.ENABLE_FACADE_CRAFTING)){
registry.addRecipeRegistryPlugin(new FacadeRegistryPlugin(facade, cableAnchor.get()));
}
// Hide facades from JEI/HEI except for the first found.
var list = NonNullList.<ItemStack>create();
facade.getSubItems(Objects.requireNonNull(facade.getCreativeTab()), list);
list.stream().skip(1)
.forEach(registry.getJeiHelpers().getIngredientBlacklist()::addIngredientToBlacklist);
}
}
@@ -69,8 +69,9 @@ public final class PartWailaDataProvider implements IWailaDataProvider {
final IPartWailaDataProvider powerState = new PowerStateWailaDataProvider();
final IPartWailaDataProvider p2pState = new P2PStateWailaDataProvider();
final IPartWailaDataProvider partStack = new PartStackWailaDataProvider();
final IPartWailaDataProvider annihilationPlane = new AnnihilationPlaneDataProvider();
this.providers = Lists.newArrayList(channel, storageMonitor, powerState, partStack, p2pState);
this.providers = Lists.newArrayList(channel, storageMonitor, powerState, partStack, p2pState, annihilationPlane);
}
@Override
@@ -0,0 +1,47 @@
package appeng.integration.modules.waila.part;
import appeng.api.parts.IPart;
import appeng.core.localization.WailaText;
import appeng.parts.automation.PartAnnihilationPlane;
import appeng.parts.automation.PartIdentityAnnihilationPlane;
import appeng.util.EnchantmentUtil;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import java.util.List;
import java.util.Map;
public class AnnihilationPlaneDataProvider extends BasePartWailaDataProvider {
@Override
public List<String> getWailaBody(IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (part instanceof PartIdentityAnnihilationPlane) {
currentToolTip.add(WailaText.IdentityDeprecated.getLocal());
} else if (part instanceof PartAnnihilationPlane plane) {
NBTTagCompound nbtData = accessor.getNBTData();
Map<Enchantment, Integer> enchantments = EnchantmentUtil.getEnchantments(nbtData);
if (!enchantments.isEmpty()) {
currentToolTip.add(WailaText.EnchantedWith.getLocal());
for (var enchantment : enchantments.keySet()) {
currentToolTip.add(enchantment.getTranslatedName(enchantments.get(enchantment)));
}
}
}
return currentToolTip;
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (part instanceof PartAnnihilationPlane plane) {
plane.writeEnchantments(tag);
}
return tag;
}
}
@@ -57,11 +57,6 @@ public abstract class AEBaseItem extends Item {
}
}
@Override
public boolean isBookEnchantable(final ItemStack itemstack1, final ItemStack itemstack2) {
return false;
}
@SideOnly(Side.CLIENT)
protected void addCheckedInformation(final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips) {
super.addInformation(stack, world, lines, advancedTooltips);
+52 -1
View File
@@ -30,8 +30,12 @@ import appeng.core.localization.GuiText;
import appeng.items.AEBaseItem;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Enchantments;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
@@ -133,10 +137,20 @@ public final class ItemPart extends AEBaseItem implements IPartItem, IItemGroup
@Override
public EnumActionResult onItemUse(final EntityPlayer player, final World w, final BlockPos pos, final EnumHand hand, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
if (this.getTypeByStack(player.getHeldItem(hand)) == PartType.INVALID_TYPE) {
ItemStack heldItem = player.getHeldItem(hand);
PartType typeByStack = getTypeByStack(heldItem);
if (typeByStack == PartType.INVALID_TYPE) {
return EnumActionResult.FAIL;
}
if (player.isSneaking() && typeByStack == PartType.IDENTITY_ANNIHILATION_PLANE) {
ItemStack newPlane = new ItemStack(this, heldItem.getCount(), PartType.ANNIHILATION_PLANE.getBaseDamage());
newPlane.addEnchantment(Enchantments.SILK_TOUCH,1);
player.setHeldItem(hand, newPlane);
return EnumActionResult.SUCCESS;
}
return AEApi.instance().partHelper().placeBus(player.getHeldItem(hand), pos, side, player, hand, w);
}
@@ -178,6 +192,43 @@ public final class ItemPart extends AEBaseItem implements IPartItem, IItemGroup
}
}
@Override
protected void addCheckedInformation(ItemStack stack, World world, List<String> lines, ITooltipFlag advancedTooltips) {
if (getTypeByStack(stack) == PartType.ANNIHILATION_PLANE) {
var enchantments = EnchantmentHelper.getEnchantments(stack);
if (enchantments.isEmpty()) {
lines.add(GuiText.CanBeEnchanted.getLocal());
}
else {
lines.add(GuiText.IncreasedEnergyUseFromEnchants.getLocal());
}
}
if (getTypeByStack(stack) == PartType.IDENTITY_ANNIHILATION_PLANE) {
lines.add(GuiText.Deprecated.getLocal());
}
}
@Override
public int getItemEnchantability() {
return 10;
}
@Override
public boolean isEnchantable(ItemStack stack) {
return getTypeByStack(stack) == PartType.ANNIHILATION_PLANE;
}
@Override
public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) {
return enchantment == Enchantments.UNBREAKING || enchantment == Enchantments.FORTUNE || enchantment == Enchantments.SILK_TOUCH || enchantment == Enchantments.EFFICIENCY;
}
@Override
public boolean isBookEnchantable(ItemStack stack, ItemStack book) {
return getTypeByStack(stack) == PartType.ANNIHILATION_PLANE;
}
@Nonnull
public PartType getTypeByStack(final ItemStack is) {
Preconditions.checkNotNull(is);
@@ -8,7 +8,8 @@ public enum Terminal {
WIRELESS_TERMINAL(AEApi.instance().definitions().items().wirelessTerminal(), GuiBridge.GUI_WIRELESS_TERM),
WIRELESS_CRAFTING_TERMINAL(AEApi.instance().definitions().items().wirelessCraftingTerminal(), GuiBridge.GUI_WIRELESS_CRAFTING_TERMINAL),
WIRELESS_PATTERN_TERMINAL(AEApi.instance().definitions().items().wirelessPatternTerminal(), GuiBridge.GUI_WIRELESS_PATTERN_TERMINAL),
WIRELESS_FLUID_TERMINAL(AEApi.instance().definitions().items().wirelessFluidTerminal(), GuiBridge.GUI_WIRELESS_FLUID_TERMINAL);
WIRELESS_FLUID_TERMINAL(AEApi.instance().definitions().items().wirelessFluidTerminal(), GuiBridge.GUI_WIRELESS_FLUID_TERMINAL),
WIRELESS_INTERFACE_TERMINAL(AEApi.instance().definitions().items().wirelessInterfaceTerminal(),GuiBridge.GUI_WIRELESS_INTERFACE_TERMINAL);
final GuiBridge bridge;
final IItemDefinition itemDefinition;
@@ -0,0 +1,18 @@
package appeng.items.tools.powered;
import appeng.api.AEApi;
import appeng.core.sync.GuiBridge;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.network.IGuiHandler;
public class ToolWirelessInterfaceTerminal extends ToolWirelessTerminal {
@Override
public boolean canHandle(ItemStack is) {
return AEApi.instance().definitions().items().wirelessInterfaceTerminal().isSameAs(is);
}
@Override
public IGuiHandler getGuiHandler(ItemStack is) {
return GuiBridge.GUI_WIRELESS_INTERFACE_TERMINAL;
}
}
@@ -20,13 +20,7 @@ package appeng.items.tools.powered;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode;
import appeng.api.config.Settings;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
import appeng.api.config.Upgrades;
import appeng.api.config.ViewItems;
import appeng.api.config.*;
import appeng.api.features.IWirelessTermHandler;
import appeng.api.util.IConfigManager;
import appeng.core.AEConfig;
@@ -51,7 +45,7 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Optional;
@@ -95,9 +89,9 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
final String encKey = tag.getString("encryptionKey");
if (encKey == null || encKey.isEmpty()) {
lines.add(GuiText.Unlinked.getLocal());
lines.add(TextFormatting.RED + GuiText.Unlinked.getLocal());
} else {
lines.add(GuiText.Linked.getLocal());
lines.add(TextFormatting.GREEN + GuiText.Linked.getLocal());
}
}
} else {

Some files were not shown because too many files have changed in this diff Show More