fix client desync
This commit is contained in:
@@ -21,6 +21,7 @@ package appeng.container.implementations;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.container.slot.*;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
@@ -43,6 +44,9 @@ public class ContainerInterface extends ContainerUpgradeable implements IOptiona
|
||||
@GuiSync( 4 )
|
||||
public YesNo iTermMode = YesNo.YES;
|
||||
|
||||
@GuiSync( 7 )
|
||||
public int patternExpansions = 0;
|
||||
|
||||
public ContainerInterface( final InventoryPlayer ip, final IInterfaceHost te )
|
||||
{
|
||||
super( ip, te.getInterfaceDuality().getHost() );
|
||||
@@ -103,9 +107,22 @@ public class ContainerInterface extends ContainerUpgradeable implements IOptiona
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
this.verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
|
||||
if (patternExpansions != getPatternUpgrades())
|
||||
{
|
||||
patternExpansions = getPatternUpgrades();
|
||||
this.myDuality.dropExcessPatterns();
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate( final String field, final Object oldValue, final Object newValue ) {
|
||||
super.onUpdate(field, oldValue, newValue);
|
||||
if ( Platform.isClient() && field.equals("patternExpansions"))
|
||||
this.myDuality.dropExcessPatterns();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadSettingsFromHost( final IConfigManager cm )
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.*;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.integration.modules.gregtech.GTCEInventoryAdaptor;
|
||||
import appeng.util.*;
|
||||
import appeng.util.inv.*;
|
||||
@@ -34,6 +35,7 @@ import gregtech.api.metatileentity.MetaTileEntity;
|
||||
import gregtech.api.metatileentity.MetaTileEntityHolder;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -176,7 +178,6 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( inv == this.config )
|
||||
{
|
||||
this.readConfig();
|
||||
@@ -592,6 +593,28 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
return false;
|
||||
}
|
||||
|
||||
public void dropExcessPatterns()
|
||||
{
|
||||
IItemHandler patterns = getPatterns();
|
||||
|
||||
List<ItemStack> dropList = new ArrayList<>();
|
||||
for( int invSlot = 0; invSlot < patterns.getSlots(); invSlot++ )
|
||||
{
|
||||
if( invSlot >= 9 + ( this.getInstalledUpgrades( Upgrades.PATTERN_EXPANSION ) ) * 9 )
|
||||
{
|
||||
ItemStack is = patterns.getStackInSlot( invSlot );
|
||||
if( is.isEmpty() ) continue;
|
||||
dropList.add( patterns.extractItem( invSlot, Integer.MAX_VALUE, false ) );
|
||||
}
|
||||
}
|
||||
if( dropList.size() > 1 )
|
||||
{
|
||||
World world = this.getLocation().getWorld();
|
||||
BlockPos blockPos = this.getLocation().getPos();
|
||||
Platform.spawnDrops( world, blockPos, dropList );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsert( final ItemStack stack )
|
||||
{
|
||||
|
||||
@@ -20,15 +20,19 @@ package appeng.parts.automation;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.core.Api;
|
||||
import appeng.helpers.DualityInterface;
|
||||
import appeng.util.inv.ItemHandlerIterator;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
@@ -39,6 +43,9 @@ import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public abstract class UpgradeInventory extends AppEngInternalInventory implements IAEAppEngInventory
|
||||
{
|
||||
@@ -177,21 +184,6 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
|
||||
@Override
|
||||
public ItemStack extractItem( int slot, int amount, boolean simulate )
|
||||
{
|
||||
if( patternExpansionUpgrades > 0 )
|
||||
{
|
||||
if( parent instanceof DualityInterface )
|
||||
{
|
||||
IItemHandler patternInv = ( (DualityInterface) parent ).getPatterns();
|
||||
for( int invSlot = 0; invSlot < patternInv.getSlots(); invSlot++ )
|
||||
{
|
||||
ItemStack is = patternInv.getStackInSlot( invSlot );
|
||||
if( invSlot > patternExpansionUpgrades * 9 && !is.isEmpty() )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.extractItem( slot, amount, simulate );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user