Use IItemHandler instead of IInventory internally (#2971)
* Use IItemHandler instead of IInventory internally
This commit is contained in:
@@ -713,7 +713,7 @@ public abstract class AEBaseGui extends GuiContainer
|
||||
this.itemRender.zLevel = 0.0F;
|
||||
|
||||
// Annoying but easier than trying to splice into render item
|
||||
super.drawSlot( new Size1Slot( s ) );
|
||||
super.drawSlot( new Size1Slot( (SlotME) s ) );
|
||||
|
||||
this.stackSizeRenderer.renderStackSize( this.fontRenderer, ( (SlotME) s ).getAEStack(), s.getStack(), s.xPos, s.yPos );
|
||||
|
||||
|
||||
@@ -13,20 +13,21 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
|
||||
/**
|
||||
* A proxy for a slot that will always return an itemstack with size 1, if there is an item in the slot.
|
||||
* Used to prevent the default item count from rendering.
|
||||
*/
|
||||
class Size1Slot extends Slot
|
||||
class Size1Slot extends SlotItemHandler
|
||||
{
|
||||
|
||||
private final Slot delegate;
|
||||
private final SlotItemHandler delegate;
|
||||
|
||||
public Size1Slot( Slot delegate )
|
||||
public Size1Slot( SlotItemHandler delegate )
|
||||
{
|
||||
super( delegate.inventory, delegate.getSlotIndex(), delegate.xPos, delegate.yPos );
|
||||
super( delegate.getItemHandler(), delegate.getSlotIndex(), delegate.xPos, delegate.yPos );
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.CopyMode;
|
||||
@@ -137,8 +137,8 @@ public class GuiCellWorkbench extends GuiUpgradeable
|
||||
this.copyMode.setState( this.workbench.getCopyMode() == CopyMode.CLEAR_ON_REMOVE );
|
||||
|
||||
boolean hasFuzzy = false;
|
||||
final IInventory inv = this.workbench.getCellUpgradeInventory();
|
||||
for( int x = 0; x < inv.getSizeInventory(); x++ )
|
||||
final IItemHandler inv = this.workbench.getCellUpgradeInventory();
|
||||
for( int x = 0; x < inv.getSlots(); x++ )
|
||||
{
|
||||
final ItemStack is = inv.getStackInSlot( x );
|
||||
if( !is.isEmpty() && is.getItem() instanceof IUpgradeModule )
|
||||
|
||||
@@ -119,7 +119,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||
if( lineObj instanceof ClientDCInternalInv )
|
||||
{
|
||||
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
|
||||
for( int z = 0; z < inv.getInventory().getSizeInventory(); z++ )
|
||||
for( int z = 0; z < inv.getInventory().getSlots(); z++ )
|
||||
{
|
||||
this.inventorySlots.inventorySlots.add( new SlotDisconnected( inv, z, z * 18 + 8, 1 + offset ) );
|
||||
}
|
||||
@@ -175,7 +175,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
|
||||
|
||||
GlStateManager.color( 1, 1, 1, 1 );
|
||||
final int width = inv.getInventory().getSizeInventory() * 18;
|
||||
final int width = inv.getInventory().getSlots() * 18;
|
||||
this.drawTexturedModalRect( offsetX + 7, offsetY + offset, 7, 139, width, 18 );
|
||||
}
|
||||
offset += 18;
|
||||
@@ -227,12 +227,12 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||
final NBTTagCompound invData = in.getCompoundTag( key );
|
||||
final ClientDCInternalInv current = this.getById( id, invData.getLong( "sortBy" ), invData.getString( "un" ) );
|
||||
|
||||
for( int x = 0; x < current.getInventory().getSizeInventory(); x++ )
|
||||
for( int x = 0; x < current.getInventory().getSlots(); x++ )
|
||||
{
|
||||
final String which = Integer.toString( x );
|
||||
if( invData.hasKey( which ) )
|
||||
{
|
||||
current.getInventory().setInventorySlotContents( x, new ItemStack( invData.getCompoundTag( which ) ) );
|
||||
current.getInventory().setStackInSlot( x, new ItemStack( invData.getCompoundTag( which ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,13 +21,13 @@ package appeng.client.me;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
|
||||
|
||||
public class SlotME extends Slot
|
||||
public class SlotME extends SlotItemHandler
|
||||
{
|
||||
|
||||
private final InternalSlotME mySlot;
|
||||
|
||||
@@ -200,7 +200,8 @@ class BiometricCardBakedModel implements IBakedModel
|
||||
|
||||
try
|
||||
{
|
||||
return BiometricCardBakedModel.this.modelCache.get( hash, () -> new BiometricCardBakedModel( BiometricCardBakedModel.this.format, BiometricCardBakedModel.this.baseModel, BiometricCardBakedModel.this.texture, hash, BiometricCardBakedModel.this.modelCache ) );
|
||||
return BiometricCardBakedModel.this.modelCache.get( hash,
|
||||
() -> new BiometricCardBakedModel( BiometricCardBakedModel.this.format, BiometricCardBakedModel.this.baseModel, BiometricCardBakedModel.this.texture, hash, BiometricCardBakedModel.this.modelCache ) );
|
||||
}
|
||||
catch( ExecutionException e )
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.features.IInscriberRecipe;
|
||||
import appeng.client.render.FacingToRotation;
|
||||
@@ -133,16 +134,18 @@ public class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
|
||||
// render items.
|
||||
GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
|
||||
IItemHandler tileInv = tile.getInternalInventory();
|
||||
|
||||
int items = 0;
|
||||
if( !tile.getStackInSlot( 0 ).isEmpty() )
|
||||
if( !tileInv.getStackInSlot( 0 ).isEmpty() )
|
||||
{
|
||||
items++;
|
||||
}
|
||||
if( !tile.getStackInSlot( 1 ).isEmpty() )
|
||||
if( !tileInv.getStackInSlot( 1 ).isEmpty() )
|
||||
{
|
||||
items++;
|
||||
}
|
||||
if( !tile.getStackInSlot( 2 ).isEmpty() )
|
||||
if( !tileInv.getStackInSlot( 2 ).isEmpty() )
|
||||
{
|
||||
items++;
|
||||
}
|
||||
@@ -151,7 +154,7 @@ public class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
|
||||
|
||||
if( relativeProgress > 1.0f || items == 0 )
|
||||
{
|
||||
ItemStack is = tile.getStackInSlot( 3 );
|
||||
ItemStack is = tileInv.getStackInSlot( 3 );
|
||||
|
||||
if( is.isEmpty() )
|
||||
{
|
||||
@@ -166,9 +169,9 @@ public class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
|
||||
}
|
||||
else
|
||||
{
|
||||
this.renderItem( tile.getStackInSlot( 0 ), press, tile, buffer, x, y, z );
|
||||
this.renderItem( tile.getStackInSlot( 1 ), -press, tile, buffer, x, y, z );
|
||||
this.renderItem( tile.getStackInSlot( 2 ), 0.0f, tile, buffer, x, y, z );
|
||||
this.renderItem( tileInv.getStackInSlot( 0 ), press, tile, buffer, x, y, z );
|
||||
this.renderItem( tileInv.getStackInSlot( 1 ), -press, tile, buffer, x, y, z );
|
||||
this.renderItem( tileInv.getStackInSlot( 2 ), 0.0f, tile, buffer, x, y, z );
|
||||
}
|
||||
|
||||
// Tessellator.getInstance().draw();
|
||||
|
||||
Reference in New Issue
Block a user