Rework AEItemStack (#3091)

* Use itemstack as itemdef
* HIGH_TAG/LOW_TAG should be compared both directions
* Remove getTagCompound
* Make Itemlist implementation independent
* Cache item id for performance reasons
* Add preconditions to saveguard against external meddling
* Chache itemDamage
* Remove IAEStackSearchKey for now, rename getDisplayStack
This commit is contained in:
fscan
2017-09-30 17:18:30 +02:00
committed by yueh
parent 2ed7a5598a
commit 1e15b23506
75 changed files with 559 additions and 1512 deletions
@@ -46,7 +46,7 @@ public interface IAEItemStack extends IAEStack<IAEItemStack>
*
* @return new ItemStack
*/
ItemStack getItemStack();
ItemStack createItemStack();
/**
* is there NBT Data for this item?
@@ -105,4 +105,11 @@ public interface IAEItemStack extends IAEStack<IAEItemStack>
* @return true if it is the same type (same item, damage, nbt)
*/
boolean isSameType( ItemStack stored );
/**
* DO NOT MODIFY THIS STACK! NEVER. If you think about it .. DON'T
*
* @return definition stack
*/
ItemStack getDefinition();
}
@@ -28,13 +28,14 @@ import java.io.IOException;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.StorageChannel;
public interface IAEStack<StackType extends IAEStack>
public interface IAEStack<StackType extends IAEStack<StackType>>
{
/**
@@ -182,13 +183,6 @@ public interface IAEStack<StackType extends IAEStack>
*/
StackType empty();
/**
* obtain the NBT Data for the item.
*
* @return nbt data
*/
IAETagCompound getTagCompound();
/**
* @return true if the stack is a {@link IAEItemStack}
*/
@@ -203,4 +197,11 @@ public interface IAEStack<StackType extends IAEStack>
* @return ITEM or FLUID
*/
StorageChannel getChannel();
/**
* Returns itemstack for display and similar purposes. Always has a count of 1.
*
* @return itemstack
*/
ItemStack asItemStackRepresentation();
}
@@ -1,59 +0,0 @@
/*
* 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.data;
import net.minecraft.nbt.NBTTagCompound;
import appeng.api.features.IItemComparison;
/**
* Don't cast this... either compare with it, or copy it.
*
* Don't Implement.
*/
public interface IAETagCompound
{
/**
* @return a copy ( the copy will not be a IAETagCompound, it will be a NBTTagCompound )
*/
NBTTagCompound getNBTTagCompoundCopy();
/**
* compare to other NBTTagCompounds or IAETagCompounds
*
* @param a compared object
*
* @return true, if they are the same.
*/
@Override
boolean equals( Object a );
/**
* @return the special comparison for this tag
*/
IItemComparison getSpecialComparison();
}