mirror of
https://github.com/GTNewHorizons/Applied-Energistics-2-Unofficial.git
synced 2026-10-25 20:22:23 +00:00
Fix conflicting reshuffle access defaults (#1669)
This commit is contained in:
1 parent
031352ea48
commit
c18acef6a7
4 files changed
+97
-13
No files matched your search
@@ -13,18 +13,12 @@
|
||||
|
||||
package appeng.api.storage;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
|
||||
/**
|
||||
* Represents an {@link appeng.api.networking.IGridHost} that contributes to storage, such as a ME Chest, or ME Drive.
|
||||
*/
|
||||
public interface ICellContainer extends IActionHost, ICellProvider, ISaveProvider {
|
||||
|
||||
/** READ permits reshuffler extraction; WRITE permits reshuffler insertion. */
|
||||
default AccessRestriction getReshuffleAccess() {
|
||||
return AccessRestriction.READ_WRITE;
|
||||
}
|
||||
public interface ICellContainer extends IActionHost, ICellProvider, ISaveProvider, IReshuffleAccess {
|
||||
|
||||
@Deprecated
|
||||
default void blinkCell(int slot) {}
|
||||
|
||||
@@ -23,7 +23,7 @@ import appeng.util.item.PrioritizedNetworkItemList;
|
||||
*
|
||||
* @param <StackType>
|
||||
*/
|
||||
public interface IMEInventoryHandler<StackType extends IAEStack> extends IMEInventory<StackType> {
|
||||
public interface IMEInventoryHandler<StackType extends IAEStack> extends IMEInventory<StackType>, IReshuffleAccess {
|
||||
|
||||
/**
|
||||
* determine if items can be injected/extracted.
|
||||
@@ -95,11 +95,6 @@ public interface IMEInventoryHandler<StackType extends IAEStack> extends IMEInve
|
||||
return false;
|
||||
}
|
||||
|
||||
/** READ permits reshuffler extraction; WRITE permits reshuffler insertion. */
|
||||
default AccessRestriction getReshuffleAccess() {
|
||||
return AccessRestriction.READ_WRITE;
|
||||
}
|
||||
|
||||
/** returns internal IMEInventory if it has one */
|
||||
default IMEInventory<StackType> getInternal() {
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* The MIT License (MIT) Copyright (c) 2013 AlgorithmX2 Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software
|
||||
* without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions: The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
|
||||
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.storage;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
|
||||
/**
|
||||
* Shared reshuffler permissions for cell containers and inventory handlers.
|
||||
*/
|
||||
public interface IReshuffleAccess {
|
||||
|
||||
/**
|
||||
* READ permits reshuffler extraction; WRITE permits reshuffler insertion. Implementations without reshuffler
|
||||
* configuration allow both by default.
|
||||
*/
|
||||
default AccessRestriction getReshuffleAccess() {
|
||||
return AccessRestriction.READ_WRITE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package appeng.api.storage;
|
||||
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.me.storage.NullInventory;
|
||||
|
||||
public class ReshuffleAccessCompatibilityTest {
|
||||
|
||||
@Test
|
||||
public void combinedConsumerInheritsDefaultWithoutConfiguration() {
|
||||
final TestCellContainer consumer = new TestCellContainer();
|
||||
|
||||
assertSame(AccessRestriction.READ_WRITE, ((ICellContainer) consumer).getReshuffleAccess());
|
||||
assertSame(AccessRestriction.READ_WRITE, ((IMEInventoryHandler<IAEItemStack>) consumer).getReshuffleAccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void combinedConsumerOverrideAppliesThroughBothInterfaces() {
|
||||
for (final AccessRestriction access : AccessRestriction.values()) {
|
||||
final TestCellContainer consumer = new TestCellContainer() {
|
||||
|
||||
@Override
|
||||
public AccessRestriction getReshuffleAccess() {
|
||||
return access;
|
||||
}
|
||||
};
|
||||
|
||||
assertSame(access, ((ICellContainer) consumer).getReshuffleAccess());
|
||||
assertSame(access, ((IMEInventoryHandler<IAEItemStack>) consumer).getReshuffleAccess());
|
||||
}
|
||||
}
|
||||
|
||||
// Inherit IMEInventoryHandler through a superclass, as third-party cell containers may do.
|
||||
private static class TestCellContainer extends NullInventory<IAEItemStack> implements ICellContainer {
|
||||
|
||||
@Override
|
||||
public IGridNode getActionableNode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir) {
|
||||
return AECableType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak() {}
|
||||
|
||||
@Override
|
||||
public void saveChanges(IMEInventory cellInventory) {}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user