Compare commits

...

14 Commits

Author SHA1 Message Date
yueh 6f15c2921a Fixes #2561: Do not use unchecked casts for IContainerListener. 2016-11-04 09:40:21 +01:00
DeadSix27 d891e5da15 Made memory card messages more clearly. (#2511)
* Made Memory card messages more clearly and easier to understand for newcomers.
2016-11-04 09:31:52 +01:00
Alexey Krainev 6607c8cd2f Updated russion translation (#2552)
* Added "P2P Waila Text"
* Changed "NEI to JEI"
2016-11-04 09:29:25 +01:00
yueh 1e20086799 Extracts item comparison from Platform into their own helper. (#2555)
* Extracts item comparison from Platform into their own helper.

Renamed methods to be more more fitting for the actual comparison.
Added documentation about each methods behaviour.
2016-11-04 09:27:52 +01:00
Sebastian Hartte f85ab7ddc2 Fixes Macerator recipes when IC2 integration is enabled. 2016-11-02 23:45:22 +01:00
Sebastian Hartte c3700737c3 Re-enables this IF-branch for ore dictionary tokens in the recipe files, which was inactive due to the recipe files all using lower-case verbs. 2016-11-02 23:34:04 +01:00
Sebastian Hartte 2f8013a49b Fixes registration of recipes when one of the recipes throws an unexpected unchecked exception during registration. Before, the registration would simply cancel and not log any errors in this case. Fixes issues with outdated IC2 integration (Macerator recipes) causing certain recipes to become non-functional. 2016-11-02 23:32:20 +01:00
Sebastian Hartte af54883fd3 Fixes #2558: Make Sky Stone Chest TESR more robust against odd world state, as Vanilla also does. 2016-11-02 20:44:50 +01:00
thatsIch 223a210d49 Replaced reference to FMLCommonHandler EventBus through MinecraftForge.EVENT_BUS due to deprecation notice 2016-11-02 14:22:00 +01:00
thatsIch c133e4f0ef Removed tickhandler registration from FMLCommonHandler EventBus since they same to MinecraftForge.EVENT_BUS 2016-11-02 14:14:51 +01:00
thatsIch 424d27b71c Removed github tag badge because this only works with SemVer in release format v1.0.0 for example and without any trailing information like "-alpha" 2016-11-02 13:42:24 +01:00
Sebastian Hartte 2fe5a3cef8 Fixes #2557: Made facades much more robust when rendering. Facades now use string ids for the base item in NBT again to avoid issues when loading worlds with a different Item ID registry mapping. In addition, we don't store the Block metadata instead of the Item Damage anymore, since when reading a facade back in, we were using that block metadata as the item damage, which is technically incorrect. 2016-11-02 01:43:01 +01:00
yueh a3c33d5323 Fixed typo in prioritylist. 2016-11-01 16:15:05 +01:00
yueh e927c27b85 Fixes #2554: Extract identical item not any equal one. 2016-11-01 15:51:38 +01:00
79 changed files with 777 additions and 603 deletions
-1
View File
@@ -1,5 +1,4 @@
[![Travis](https://img.shields.io/travis/AppliedEnergistics/Applied-Energistics-2.svg?maxAge=2592000&style=flat-square)](https://travis-ci.org/AppliedEnergistics/Applied-Energistics-2)
[![Latest Tag](https://img.shields.io/github/tag/AppliedEnergistics/Applied-Energistics-2.svg?label=Latest Tag&style=flat-square)](https://github.com/AppliedEnergistics/Applied-Energistics-2/tags)
[![Latest Release](https://img.shields.io/github/release/AppliedEnergistics/Applied-Energistics-2.svg?label=Latest Release&style=flat-square)](https://github.com/AppliedEnergistics/Applied-Energistics-2/releases)
# Applied Energistics 2
@@ -300,7 +300,7 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements ITileEntity
for( final ItemStack ol : itemDropCandidates )
{
if( Platform.isSameItemType( ol, op ) )
if( Platform.itemComparisons().isEqualItemType( ol, op ) )
{
final NBTTagCompound tag = tile.downloadSettings( SettingsFrom.DISMANTLE_ITEM );
if( tag != null )
+1 -1
View File
@@ -41,7 +41,7 @@ import appeng.integration.modules.JEI;
import appeng.items.storage.ItemViewCell;
import appeng.util.ItemSorters;
import appeng.util.Platform;
import appeng.util.prioitylist.IPartitionList;
import appeng.util.prioritylist.IPartitionList;
public class ItemRepo
@@ -22,6 +22,7 @@ package appeng.client.render.cablebus;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -64,8 +65,11 @@ public class FacadeBuilder
private final VertexFormat format;
private final TextureAtlasSprite facadeTexture;
private final BlockRendererDispatcher blockRendererDispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
private static final Set<ResourceLocation> warnedFor = new HashSet<>();
FacadeBuilder( VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
{
this.format = format;
@@ -132,11 +136,36 @@ public class FacadeBuilder
}
}
}
catch( Exception e )
{
if( warnedFor.add( state.getBlock().getRegistryName() ) )
{
AELog.warn( "Unable to get facade sprite for blockstate %s. Supressing further warnings for this block.", state );
AELog.debug( e );
}
}
finally
{
ForgeHooksClient.setRenderLayer( orgLayer );
}
// Fall back to the particle texture, if we havent found anything else so far.
if( firstFound == null )
{
try
{
return blockModel.getParticleTexture();
}
catch( Exception e )
{
if( warnedFor.add( state.getBlock().getRegistryName() ) )
{
AELog.warn( "Unable to get facade sprite particle texture fallback for blockstate %s. Supressing further warnings for this block.", state );
AELog.debug( e );
}
}
}
return firstFound;
}
@@ -19,6 +19,7 @@
package appeng.client.render.tesr;
import net.minecraft.block.Block;
import net.minecraft.client.model.ModelChest;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
@@ -70,14 +71,8 @@ public class SkyChestTESR extends TileEntitySpecialRenderer<TileSkyChest>
}
else
{
if( te != null )
{
this.bindTexture( ( (BlockSkyChest) te.getBlockType() ).type == SkyChestType.STONE ? TEXTURE_STONE : TEXTURE_BLOCK );
}
else
{
this.bindTexture( TEXTURE_BLOCK );
}
SkyChestType chestType = getChestType( te );
this.bindTexture( chestType == SkyChestType.STONE ? TEXTURE_STONE : TEXTURE_BLOCK );
}
GlStateManager.pushMatrix();
@@ -128,4 +123,20 @@ public class SkyChestTESR extends TileEntitySpecialRenderer<TileSkyChest>
}
}
// Defensively determine the sky chest type
private static SkyChestType getChestType( TileSkyChest te )
{
if( te == null )
{
return SkyChestType.BLOCK;
}
Block blockType = te.getBlockType();
if( blockType instanceof BlockSkyChest )
{
return ( (BlockSkyChest) blockType ).type;
}
return SkyChestType.BLOCK;
}
}
@@ -227,7 +227,7 @@ public abstract class AEBaseContainer extends Container
final ItemStack a = stack == null ? null : stack.getItemStack();
final ItemStack b = this.clientRequestedTargetItem == null ? null : this.clientRequestedTargetItem.getItemStack();
if( Platform.isSameItemPrecise( a, b ) )
if( Platform.itemComparisons().isSameItem( a, b ) )
{
return;
}
@@ -438,13 +438,11 @@ public abstract class AEBaseContainer extends Container
if( Platform.isServer() )
{
for( final Object crafter : this.listeners )
for( final IContainerListener listener : this.listeners )
{
final IContainerListener IContainerListener = (IContainerListener) crafter;
for( final SyncData sd : this.syncData.values() )
{
sd.tick( IContainerListener );
sd.tick( listener );
}
}
}
@@ -545,7 +543,7 @@ public abstract class AEBaseContainer extends Container
if( !( cs.isPlayerSide() ) && cs instanceof SlotFake )
{
if( Platform.isSameItemPrecise( destination, tis ) )
if( Platform.itemComparisons().isSameItem( destination, tis ) )
{
break;
}
@@ -577,7 +575,7 @@ public abstract class AEBaseContainer extends Container
{
final ItemStack t = d.getStack();
if( Platform.isSameItemPrecise( tis, t ) ) // t.isItemEqual(tis))
if( Platform.itemComparisons().isSameItem( tis, t ) ) // t.isItemEqual(tis))
{
int maxSize = t.getMaxStackSize();
if( maxSize > d.getSlotStackLimit() )
@@ -629,7 +627,7 @@ public abstract class AEBaseContainer extends Container
{
final ItemStack t = d.getStack();
if( Platform.isSameItemPrecise( t, tis ) )
if( Platform.itemComparisons().isSameItem( t, tis ) )
{
int maxSize = t.getMaxStackSize();
if( d.getSlotStackLimit() < maxSize )
@@ -929,7 +927,7 @@ public abstract class AEBaseContainer extends Container
{
liftQty = 0;
}
if( !Platform.isSameItemPrecise( slotItem.getItemStack(), item ) )
if( !Platform.itemComparisons().isSameItem( slotItem.getItemStack(), item ) )
{
liftQty = 0;
}
@@ -26,6 +26,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IContainerListener;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
@@ -151,22 +152,24 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
this.setValidContainer( false );
}
for( final Object crafter : this.listeners )
for( final IContainerListener listener : this.listeners )
{
final IContainerListener IContainerListener = (IContainerListener) crafter;
if( this.prevStack != is )
{
// if the bars changed an item was probably made, so just send shit!
for( final Object s : this.inventorySlots )
for( final Slot s : this.inventorySlots )
{
if( s instanceof OptionalSlotRestrictedInput )
{
final OptionalSlotRestrictedInput sri = (OptionalSlotRestrictedInput) s;
IContainerListener.sendSlotContents( this, sri.slotNumber, sri.getStack() );
listener.sendSlotContents( this, sri.slotNumber, sri.getStack() );
}
}
( (EntityPlayerMP) IContainerListener ).isChangingQuantityOnly = false;
if( listener instanceof EntityPlayerMP )
{
( (EntityPlayerMP) listener ).isChangingQuantityOnly = false;
}
}
}
@@ -115,7 +115,7 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
{
for( final ItemStack optional : AEApi.instance().registries().inscriber().getOptionals() )
{
if( Platform.isSameItemPrecise( optional, is ) )
if( Platform.itemComparisons().isSameItem( optional, is ) )
{
return false;
}
@@ -126,18 +126,18 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
{
final boolean matchA = ( top == null && !recipe.getTopOptional().isPresent() ) || ( Platform.isSameItemPrecise( top, recipe.getTopOptional().orElse( null ) ) ) && // and...
( bot == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.isSameItemPrecise( bot, recipe.getBottomOptional().orElse( null ) ) );
final boolean matchA = ( top == null && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( top, recipe.getTopOptional().orElse( null ) ) ) && // and...
( bot == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( bot, recipe.getBottomOptional().orElse( null ) ) );
final boolean matchB = ( bot == null && !recipe.getTopOptional().isPresent() ) || ( Platform.isSameItemPrecise( bot, recipe.getTopOptional().orElse( null ) ) ) && // and...
( top == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.isSameItemPrecise( top, recipe.getBottomOptional().orElse( null ) ) );
final boolean matchB = ( bot == null && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( bot, recipe.getTopOptional().orElse( null ) ) ) && // and...
( top == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( top, recipe.getBottomOptional().orElse( null ) ) );
if( matchA || matchB )
{
matches = true;
for( final ItemStack option : recipe.getInputs() )
{
if( Platform.isSameItemPrecise( is, option ) )
if( Platform.itemComparisons().isSameItem( is, option ) )
{
found = true;
}
@@ -174,13 +174,13 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
boolean isValid = false;
for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
{
if( Platform.isSameItemPrecise( recipe.getTopOptional().orElse( null ), otherSlot ) )
if( Platform.itemComparisons().isSameItem( recipe.getTopOptional().orElse( null ), otherSlot ) )
{
isValid = Platform.isSameItemPrecise( is, recipe.getBottomOptional().orElse( null ) );
isValid = Platform.itemComparisons().isSameItem( is, recipe.getBottomOptional().orElse( null ) );
}
else if( Platform.isSameItemPrecise( recipe.getBottomOptional().orElse( null ), otherSlot ) )
else if( Platform.itemComparisons().isSameItem( recipe.getBottomOptional().orElse( null ), otherSlot ) )
{
isValid = Platform.isSameItemPrecise( is, recipe.getTopOptional().orElse( null ) );
isValid = Platform.itemComparisons().isSameItem( is, recipe.getTopOptional().orElse( null ) );
}
if( isValid )
@@ -67,7 +67,7 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable
{
if( currentItem != null )
{
if( Platform.isSameItem( this.civ.getItemStack(), currentItem ) )
if( Platform.itemComparisons().isEqualItem( this.civ.getItemStack(), currentItem ) )
{
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.civ.getItemStack() );
}
@@ -72,7 +72,7 @@ public class ContainerNetworkTool extends AEBaseContainer
{
if( currentItem != null )
{
if( Platform.isSameItem( this.toolInv.getItemStack(), currentItem ) )
if( Platform.itemComparisons().isEqualItem( this.toolInv.getItemStack(), currentItem ) )
{
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.toolInv.getItemStack() );
}
@@ -200,7 +200,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
if( output != null && !this.isPattern( output ) )
{
return;
}// if nothing is there we should snag a new pattern.
} // if nothing is there we should snag a new pattern.
else if( output == null )
{
output = this.patternSlotIN.getStack();
@@ -414,7 +414,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
final IRecipe rr = Platform.findMatchingRecipe( real, p.worldObj );
if( rr == r && Platform.isSameItemPrecise( rr.getCraftingResult( real ), is ) )
if( rr == r && Platform.itemComparisons().isSameItem( rr.getCraftingResult( real ), is ) )
{
final SlotCrafting sc = new SlotCrafting( p, real, this.cOut, 0, 0, 0 );
sc.onPickupFromSlot( p, is );
@@ -483,19 +483,19 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
{
if( s == this.patternSlotOUT && Platform.isServer() )
{
for( final Object crafter : this.listeners )
for( final IContainerListener listener : this.listeners )
{
final IContainerListener IContainerListener = (IContainerListener) crafter;
for( final Object g : this.inventorySlots )
for( final Slot slot : this.inventorySlots )
{
if( g instanceof OptionalSlotFake || g instanceof SlotFakeCraftingMatrix )
if( slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix )
{
final Slot sri = (Slot) g;
IContainerListener.sendSlotContents( this, sri.slotNumber, sri.getStack() );
listener.sendSlotContents( this, slot.slotNumber, slot.getStack() );
}
}
( (EntityPlayerMP) IContainerListener ).isChangingQuantityOnly = false;
if( listener instanceof EntityPlayerMP )
{
( (EntityPlayerMP) listener ).isChangingQuantityOnly = false;
}
}
this.detectAndSendChanges();
}
@@ -79,7 +79,7 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
{
if( currentItem != null )
{
if( Platform.isSameItem( this.toolInv.getItemStack(), currentItem ) )
if( Platform.itemComparisons().isEqualItem( this.toolInv.getItemStack(), currentItem ) )
{
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.toolInv.getItemStack() );
}
@@ -168,11 +168,10 @@ public class ContainerSecurityStation extends ContainerMEMonitorable implements
this.wirelessOut.putStack( term );
// update the two slots in question...
for( final Object crafter : this.listeners )
for( final IContainerListener listener : this.listeners )
{
final IContainerListener IContainerListener = (IContainerListener) crafter;
IContainerListener.sendSlotContents( this, this.wirelessIn.slotNumber, this.wirelessIn.getStack() );
IContainerListener.sendSlotContents( this, this.wirelessOut.slotNumber, this.wirelessOut.getStack() );
listener.sendSlotContents( this, this.wirelessIn.slotNumber, this.wirelessIn.getStack() );
listener.sendSlotContents( this, this.wirelessOut.slotNumber, this.wirelessOut.getStack() );
}
}
}
@@ -235,7 +235,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
{
if( currentItem != null )
{
if( Platform.isSameItem( this.tbInventory.getItemStack(), currentItem ) )
if( Platform.itemComparisons().isEqualItem( this.tbInventory.getItemStack(), currentItem ) )
{
this.getPlayerInv().setInventorySlotContents( this.tbSlot, this.tbInventory.getItemStack() );
}
@@ -158,7 +158,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
// update crafting matrix...
ItemStack is = this.getStack();
if( is != null && Platform.isSameItem( request, is ) )
if( is != null && Platform.itemComparisons().isEqualItem( request, is ) )
{
final ItemStack[] set = new ItemStack[this.getPattern().getSizeInventory()];
@@ -170,7 +170,7 @@ public class SlotRestrictedInput extends AppEngSlot
for( final ItemStack optional : AEApi.instance().registries().inscriber().getOptionals() )
{
if( Platform.isSameItemPrecise( optional, i ) )
if( Platform.itemComparisons().isSameItem( optional, i ) )
{
return true;
}
@@ -258,7 +258,7 @@ public class SlotRestrictedInput extends AppEngSlot
public static boolean isMetalIngot( final ItemStack i )
{
if( Platform.isSameItemPrecise( i, new ItemStack( Items.IRON_INGOT ) ) )
if( Platform.itemComparisons().isSameItem( i, new ItemStack( Items.IRON_INGOT ) ) )
{
return true;
}
@@ -267,7 +267,7 @@ public class SlotRestrictedInput extends AppEngSlot
{
for( final ItemStack ingot : OreDictionary.getOres( "ingot" + name ) )
{
if( Platform.isSameItemPrecise( i, ingot ) )
if( Platform.itemComparisons().isSameItem( i, ingot ) )
{
return true;
}
+2 -2
View File
@@ -25,10 +25,10 @@ import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@@ -113,7 +113,7 @@ public final class AEConfig extends Configuration implements IConfigurableObject
super( configFile );
this.configFile = configFile;
FMLCommonHandler.instance().bus().register( this );
MinecraftForge.EVENT_BUS.register( this );
final double DEFAULT_IC2_EXCHANGE = 2.0;
PowerUnits.EU.conversionRatio = this.get( "PowerRatios", "IC2", DEFAULT_IC2_EXCHANGE ).getDouble( DEFAULT_IC2_EXCHANGE );
+1 -4
View File
@@ -22,7 +22,6 @@ package appeng.core;
import java.io.File;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.Nonnull;
import com.google.common.base.Preconditions;
@@ -30,7 +29,6 @@ import com.google.common.base.Preconditions;
import net.minecraft.world.DimensionType;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
@@ -267,7 +265,6 @@ public final class Registration
// "li.cil.oc.api.network.SidedEnvironment" );
// }
FMLCommonHandler.instance().bus().register( TickHandler.INSTANCE );
MinecraftForge.EVENT_BUS.register( TickHandler.INSTANCE );
@@ -300,7 +297,7 @@ public final class Registration
this.recipeHandler.injectRecipes();
final PlayerStatsRegistration registration = new PlayerStatsRegistration( FMLCommonHandler.instance().bus(), AEConfig.instance );
final PlayerStatsRegistration registration = new PlayerStatsRegistration( MinecraftForge.EVENT_BUS, AEConfig.instance );
registration.registerAchievementHandlers();
registration.registerAchievements();
@@ -73,7 +73,7 @@ public class ItemDefinition implements IItemDefinition
@Override
public final boolean isSameAs( final ItemStack comparableStack )
{
return isEnabled() && Platform.isSameItemType( comparableStack, this.maybeStack( 1 ).get() );
return isEnabled() && Platform.itemComparisons().isEqualItemType( comparableStack, this.maybeStack( 1 ).get() );
}
}
@@ -125,7 +125,7 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
{
for( final IGrinderEntry gr : this.recipes )
{
if( Platform.isSameItemPrecise( gr.getInput(), appEngGrinderRecipe.getInput() ) )
if( Platform.itemComparisons().isSameItem( gr.getInput(), appEngGrinderRecipe.getInput() ) )
{
return;
}
@@ -151,7 +151,7 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
{
for( final IGrinderEntry r : this.recipes )
{
if( Platform.isSameItem( input, r.getInput() ) )
if( Platform.itemComparisons().isEqualItem( input, r.getInput() ) )
{
this.log( "Recipe for " + input.getUnlocalizedName() + " found " + Platform.getItemDisplayName( r.getOutput() ) );
return r;
@@ -52,7 +52,7 @@ public class MatterCannonAmmoRegistry implements IOreListener, IMatterCannonAmmo
{
for( final ItemStack o : this.DamageModifiers.keySet() )
{
if( Platform.isSameItem( o, is ) )
if( Platform.itemComparisons().isEqualItem( o, is ) )
{
return this.DamageModifiers.get( o ).floatValue();
}
@@ -146,7 +146,7 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
return this.tunnels.get( is );
}
if( Platform.isSameItem( is, trigger ) )
if( Platform.itemComparisons().isEqualItem( is, trigger ) )
{
return this.tunnels.get( is );
}
@@ -54,7 +54,7 @@ public class AchievementCraftingHandler
switch( achievement.getType() )
{
case Craft:
if( Platform.isSameItemPrecise( achievement.getStack(), event.crafting ) )
if( Platform.itemComparisons().isSameItem( achievement.getStack(), event.crafting ) )
{
achievement.addToPlayer( event.player );
return;
@@ -54,7 +54,7 @@ public class AchievementPickupHandler
for( final Achievements achievement : Achievements.values() )
{
if( achievement.getType() == AchievementType.Pickup && Platform.isSameItemPrecise( achievement.getStack(), is ) )
if( achievement.getType() == AchievementType.Pickup && Platform.itemComparisons().isSameItem( achievement.getStack(), is ) )
{
achievement.addToPlayer( event.player );
return;
@@ -59,7 +59,7 @@ import appeng.items.storage.ItemViewCell;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import appeng.util.prioitylist.IPartitionList;
import appeng.util.prioritylist.IPartitionList;
public class PacketJEIRecipe extends AppEngPacket
@@ -167,7 +167,7 @@ public class PacketJEIRecipe extends AppEngPacket
final ItemStack newItemStack = r.matches( testInv, pmp.worldObj ) ? r.getCraftingResult( testInv ) : null;
testInv.setInventorySlotContents( x, patternItem );
if( newItemStack == null || !Platform.isSameItemPrecise( newItemStack, is ) )
if( newItemStack == null || !Platform.itemComparisons().isSameItem( newItemStack, is ) )
{
final IAEItemStack in = AEItemStack.create( currentItem );
if( in != null )
@@ -119,12 +119,12 @@ public final class EntityChargedQuartz extends AEBaseEntityItem
final ItemStack other = ( (EntityItem) e ).getEntityItem();
if( other != null && other.stackSize > 0 )
{
if( Platform.isSameItem( other, new ItemStack( Items.REDSTONE ) ) )
if( Platform.itemComparisons().isEqualItem( other, new ItemStack( Items.REDSTONE ) ) )
{
redstone = (EntityItem) e;
}
if( Platform.isSameItem( other, new ItemStack( Items.QUARTZ ) ) )
if( Platform.itemComparisons().isEqualItem( other, new ItemStack( Items.QUARTZ ) ) )
{
netherQuartz = (EntityItem) e;
}
@@ -245,7 +245,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
{
final ItemStack testOutput = this.standardRecipe.getCraftingResult( this.testFrame );
if( Platform.isSameItemPrecise( this.correctOutput, testOutput ) )
if( Platform.itemComparisons().isSameItem( this.correctOutput, testOutput ) )
{
this.testFrame.setInventorySlotContents( slotIndex, this.crafting.getStackInSlot( slotIndex ) );
this.markItemAs( slotIndex, i, TestStatus.ACCEPT );
@@ -256,7 +256,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
{
final ItemStack testOutput = CraftingManager.getInstance().findMatchingRecipe( this.testFrame, w );
if( Platform.isSameItemPrecise( this.correctOutput, testOutput ) )
if( Platform.itemComparisons().isSameItem( this.correctOutput, testOutput ) )
{
this.testFrame.setInventorySlotContents( slotIndex, this.crafting.getStackInSlot( slotIndex ) );
this.markItemAs( slotIndex, i, TestStatus.ACCEPT );
@@ -20,17 +20,11 @@ package appeng.integration.abstraction;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
public interface IIC2
{
void addToEnergyNet( TileEntity appEngTile );
void removeFromEnergyNet( TileEntity appEngTile );
ItemStack getItem( String string );
void maceratorRecipe( ItemStack in, ItemStack out );
}
@@ -21,22 +21,36 @@ package appeng.integration.modules;
import java.util.function.BiFunction;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import ic2.api.recipe.RecipeInputItemStack;
import appeng.api.AEApi;
import appeng.api.config.TunnelType;
import appeng.api.features.IP2PTunnelRegistry;
import appeng.helpers.Reflected;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import appeng.integration.abstraction.IIC2;
import appeng.integration.modules.ic2.IC2PowerSink;
import appeng.integration.modules.ic2.IC2PowerSinkAdapter;
import appeng.integration.modules.ic2.IC2PowerSinkStub;
import appeng.tile.powersink.IExternalPowerSink;
public class IC2 implements IIntegrationModule
public class IC2 implements IIntegrationModule, IIC2
{
@Reflected
public static IC2 instance;
public IC2()
{
IntegrationHelper.testClassExistence( this, ic2.api.energy.tile.IEnergyTile.class );
IntegrationHelper.testClassExistence( this, ic2.api.recipe.RecipeInputItemStack.class );
}
private static BiFunction<TileEntity, IExternalPowerSink, IC2PowerSink> powerSinkFactory = ( ( te, sink ) -> IC2PowerSinkStub.INSTANCE );
@Override
@@ -48,6 +62,23 @@ public class IC2 implements IIntegrationModule
@Override
public void postInit()
{
final IP2PTunnelRegistry reg = AEApi.instance().registries().p2pTunnel();
reg.addNewAttunement( this.getItem( "copperCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "insulatedCopperCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "goldCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "insulatedGoldCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "ironCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "insulatedIronCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "insulatedTinCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "glassFiberCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "tinCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "detectorCableItem" ), TunnelType.IC2_POWER );
reg.addNewAttunement( this.getItem( "splitterCableItem" ), TunnelType.IC2_POWER );
}
public ItemStack getItem( final String name )
{
return ic2.api.item.IC2Items.getItem( name );
}
/**
@@ -57,4 +88,11 @@ public class IC2 implements IIntegrationModule
{
return powerSinkFactory.apply( tileEntity, externalSink );
}
@Override
public void maceratorRecipe( ItemStack in, ItemStack out )
{
ic2.api.recipe.Recipes.macerator.addRecipe( new RecipeInputItemStack( in, in.stackSize ), null, false, out );
}
}
@@ -38,6 +38,7 @@ import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.property.IExtendedBlockState;
@@ -57,6 +58,9 @@ import appeng.items.AEBaseItem;
public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassItem
{
private static final String TAG_ITEM_ID = "item";
private static final String TAG_DAMAGE = "damage";
private List<ItemStack> subTypes = null;
public ItemFacade()
@@ -107,6 +111,10 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
try
{
final Item item = Item.getItemFromBlock( b );
if( item == null )
{
continue;
}
final List<ItemStack> tmpList = new ArrayList<ItemStack>( 100 );
b.getSubBlocks( item, b.getCreativeTabToDisplayOn(), tmpList );
@@ -184,10 +192,8 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
final ItemStack is = new ItemStack( this );
final NBTTagCompound data = new NBTTagCompound();
final int[] ds = new int[2];
ds[0] = Item.getIdFromItem( l.getItem() );
ds[1] = metadata;
data.setIntArray( "x", ds );
data.setString( TAG_ITEM_ID, l.getItem().getRegistryName().toString() );
data.setInteger( TAG_DAMAGE, l.getItemDamage() );
is.setTagCompound( data );
return is;
}
@@ -216,22 +222,39 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
return null;
}
// First item is numeric item id, second is damage
int[] ids = nbt.getIntArray( "x" );
ResourceLocation itemId;
int itemDamage;
if( ids.length != 2 )
// Handle legacy facades
if( nbt.hasKey( "x" ) )
{
return null;
int[] data = nbt.getIntArray( "x" );
if( data.length != 2 )
{
return null;
}
Item item = Item.REGISTRY.getObjectById( data[0] );
if ( item == null ) {
return null;
}
itemId = item.getRegistryName();
itemDamage = data[1];
} else {
// First item is numeric item id, second is damage
itemId = new ResourceLocation( nbt.getString( TAG_ITEM_ID ) );
itemDamage = nbt.getInteger( TAG_DAMAGE );
}
Item baseItem = Item.REGISTRY.getObjectById( ids[0] );
Item baseItem = Item.REGISTRY.getObject( itemId );
if( baseItem == null )
{
return null;
}
return new ItemStack( baseItem, 1, ids[1] );
return new ItemStack( baseItem, 1, itemDamage );
}
@@ -253,13 +276,15 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
return Blocks.GLASS.getDefaultState();
}
int metadata = baseItemStack.getItem().getMetadata( baseItemStack );
try
{
return block.getStateFromMeta( baseItemStack.getItemDamage() );
return block.getStateFromMeta( metadata );
}
catch( Exception e )
{
AELog.warn( "Block {} has broken getStateFromMeta method for meta {}", block.getRegistryName(), baseItemStack.getItemDamage() );
AELog.warn( "Block %s has broken getStateFromMeta method for meta %d", block.getRegistryName().toString(), baseItemStack.getItemDamage() );
return Blocks.GLASS.getDefaultState();
}
@@ -286,8 +311,15 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
ItemStack facadeStack = AEApi.instance().definitions().items().facade().maybeStack( 1 )
.orElseThrow( () -> new MissingDefinition( "Tried to create a facade, while facades are being deactivated." ) );
// Convert back to a registry name...
Item item = Item.REGISTRY.getObjectById( ids[0] );
if ( item == null ) {
return null;
}
final NBTTagCompound facadeTag = new NBTTagCompound();
facadeTag.setIntArray( "x", ids.clone() );
facadeTag.setString( TAG_ITEM_ID, item.getRegistryName().toString() );
facadeTag.setInteger( TAG_DAMAGE, ids[1] );
facadeStack.setTagCompound( facadeTag );
return facadeStack;
@@ -34,10 +34,10 @@ import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import appeng.util.prioitylist.FuzzyPriorityList;
import appeng.util.prioitylist.IPartitionList;
import appeng.util.prioitylist.MergedPriorityList;
import appeng.util.prioitylist.PrecisePriorityList;
import appeng.util.prioritylist.FuzzyPriorityList;
import appeng.util.prioritylist.IPartitionList;
import appeng.util.prioritylist.MergedPriorityList;
import appeng.util.prioritylist.PrecisePriorityList;
public class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem
@@ -36,8 +36,8 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import appeng.util.prioitylist.FuzzyPriorityList;
import appeng.util.prioitylist.PrecisePriorityList;
import appeng.util.prioritylist.FuzzyPriorityList;
import appeng.util.prioritylist.PrecisePriorityList;
public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> implements ICellInventoryHandler
@@ -28,8 +28,8 @@ import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
import appeng.util.prioitylist.DefaultPriorityList;
import appeng.util.prioitylist.IPartitionList;
import appeng.util.prioritylist.DefaultPriorityList;
import appeng.util.prioritylist.IPartitionList;
public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHandler<T>
@@ -237,7 +237,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
return true;
}
return !Platform.isSameItemPrecise( a, b );
return !Platform.itemComparisons().isSameItem( a, b );
}
private void postDifference( final Iterable<IAEItemStack> a )
@@ -1066,7 +1066,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
final ItemStack current = p == null ? null : p.getItemStack( PartItemStack.WORLD );
if( Platform.isSameItemType( iss, current ) )
if( Platform.itemComparisons().isEqualItemType( iss, current ) )
{
p.readFromNBT( extra );
}
@@ -80,8 +80,8 @@ import appeng.me.storage.MEInventoryHandler;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import appeng.util.prioitylist.FuzzyPriorityList;
import appeng.util.prioitylist.PrecisePriorityList;
import appeng.util.prioritylist.FuzzyPriorityList;
import appeng.util.prioritylist.PrecisePriorityList;
public class PartFormationPlane extends PartUpgradeable implements ICellContainer, IPriorityHost, IMEInventory<IAEItemStack>
@@ -43,7 +43,7 @@ public class StackUpgradeInventory extends UpgradeInventory
for( final ItemStack is : upgrades.getSupported().keySet() )
{
if( Platform.isSameItem( this.stack, is ) )
if( Platform.itemComparisons().isEqualItem( this.stack, is ) )
{
max = upgrades.getSupported().get( is );
break;
@@ -111,7 +111,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
{
ItemStack sub = itemHandler.getStackInSlot( i );
if( !Platform.isSameItem( sub, req ) )
if( !Platform.itemComparisons().isSameItem( sub, req ) )
{
continue;
}
@@ -275,7 +275,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
return false;
}
return a == null || b == null || !Platform.isSameItemPrecise( a, b );
return a == null || b == null || !Platform.itemComparisons().isSameItem( a, b );
}
private void postDifference( Iterable<IAEItemStack> a )
@@ -88,8 +88,8 @@ import appeng.parts.automation.PartUpgradeable;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import appeng.util.prioitylist.FuzzyPriorityList;
import appeng.util.prioitylist.PrecisePriorityList;
import appeng.util.prioritylist.FuzzyPriorityList;
import appeng.util.prioritylist.PrecisePriorityList;
public class PartStorageBus extends PartUpgradeable implements IGridTickable, ICellContainer, IMEMonitorHandlerReceiver<IAEItemStack>, IPriorityHost
@@ -270,7 +270,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
break;
}
if( newType != null && !Platform.isSameItem( newType, this.getItemStack() ) )
if( newType != null && !Platform.itemComparisons().isEqualItem( newType, this.getItemStack() ) )
{
final boolean oldOutput = this.isOutput();
final long myFreq = this.getFrequency();
+1 -1
View File
@@ -79,7 +79,7 @@ public class Ingredient implements IIngredient
{
int sel = 0;
if( this.nameSpace.equals( "oreDictionary" ) )
if( this.nameSpace.equalsIgnoreCase( "oreDictionary" ) )
{
if( parts.length == 3 )
{
+30 -44
View File
@@ -32,7 +32,6 @@ import java.util.Map.Entry;
import java.util.Optional;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.annotation.Nonnull;
import com.google.common.base.Preconditions;
@@ -371,65 +370,52 @@ public class RecipeHandler implements IRecipeHandler
}
final Map<Class, Integer> processed = new HashMap<Class, Integer>();
try
for( final ICraftHandler ch : this.data.handlers )
{
for( final ICraftHandler ch : this.data.handlers )
try
{
try
{
ch.register();
ch.register();
final Class clz = ch.getClass();
final Integer i = processed.get( clz );
if( i == null )
{
processed.put( clz, 1 );
}
else
{
processed.put( clz, i + 1 );
}
}
catch( final RegistrationError e )
final Class clz = ch.getClass();
final Integer i = processed.get( clz );
if( i == null )
{
AELog.warn( "Unable to register a recipe: " + e.getMessage() );
processed.put( clz, 1 );
}
else
{
processed.put( clz, i + 1 );
}
}
catch( final MissingIngredientError e )
{
if( this.data.errorOnMissing )
{
AELog.warn( "Unable to register a recipe:" + e.getMessage() );
if( this.data.exceptions )
{
AELog.debug( e );
}
if( this.data.crash )
{
throw e;
throw new IllegalStateException( e );
}
}
catch( final MissingIngredientError e )
}
catch( final Throwable e )
{
AELog.warn( "Unable to register a recipe: " + e.getMessage() );
if( this.data.exceptions )
{
if( this.data.errorOnMissing )
{
AELog.warn( "Unable to register a recipe:" + e.getMessage() );
if( this.data.exceptions )
{
AELog.debug( e );
}
if( this.data.crash )
{
throw e;
}
}
AELog.debug( e );
}
if( this.data.crash )
{
throw new IllegalStateException( e );
}
}
}
catch( final Throwable e )
{
if( this.data.exceptions )
{
AELog.debug( e );
}
if( this.data.crash )
{
throw new IllegalStateException( e );
}
}
for( final Entry<Class, Integer> e : processed.entrySet() )
{
@@ -87,6 +87,6 @@ public class Crusher implements ICraftHandler, IWebsiteSerializer
@Override
public boolean canCraft( final ItemStack output ) throws RegistrationError, MissingIngredientError
{
return Platform.isSameItemPrecise( this.pro_output[0].getItemStack(), output );
return Platform.itemComparisons().isSameItem( this.pro_output[0].getItemStack(), output );
}
}
@@ -73,6 +73,6 @@ public class Grind implements ICraftHandler, IWebsiteSerializer
@Override
public boolean canCraft( final ItemStack output ) throws RegistrationError, MissingIngredientError
{
return Platform.isSameItemPrecise( this.pro_output[0].getItemStack(), output );
return Platform.itemComparisons().isSameItem( this.pro_output[0].getItemStack(), output );
}
}
@@ -87,6 +87,6 @@ public class GrindFZ implements ICraftHandler, IWebsiteSerializer
@Override
public boolean canCraft( final ItemStack output ) throws RegistrationError, MissingIngredientError
{
return Platform.isSameItemPrecise( this.pro_output[0].getItemStack(), output );
return Platform.itemComparisons().isSameItem( this.pro_output[0].getItemStack(), output );
}
}
@@ -96,6 +96,6 @@ public class HCCrusher implements ICraftHandler, IWebsiteSerializer
@Override
public boolean canCraft( final ItemStack output ) throws RegistrationError, MissingIngredientError
{
return Platform.isSameItemPrecise( this.pro_output[0].getItemStack(), output );
return Platform.itemComparisons().isSameItem( this.pro_output[0].getItemStack(), output );
}
}
@@ -88,7 +88,7 @@ public abstract class InscriberProcess implements ICraftHandler, IWebsiteSeriali
@Override
public boolean canCraft( final ItemStack reqOutput ) throws RegistrationError, MissingIngredientError
{
return this.output != null && Platform.isSameItemPrecise( this.output.getItemStack(), reqOutput );
return this.output != null && Platform.itemComparisons().isSameItem( this.output.getItemStack(), reqOutput );
}
@Override
@@ -87,6 +87,6 @@ public class Macerator implements ICraftHandler, IWebsiteSerializer
@Override
public boolean canCraft( final ItemStack output ) throws RegistrationError, MissingIngredientError
{
return Platform.isSameItemPrecise( this.pro_output[0].getItemStack(), output );
return Platform.itemComparisons().isSameItem( this.pro_output[0].getItemStack(), output );
}
}
@@ -88,6 +88,6 @@ public class MekCrusher implements ICraftHandler, IWebsiteSerializer
@Override
public boolean canCraft( final ItemStack output ) throws RegistrationError, MissingIngredientError
{
return Platform.isSameItemPrecise( this.pro_output[0].getItemStack(), output );
return Platform.itemComparisons().isSameItem( this.pro_output[0].getItemStack(), output );
}
}
@@ -87,6 +87,6 @@ public class MekEnrichment implements ICraftHandler, IWebsiteSerializer
@Override
public boolean canCraft( final ItemStack output ) throws RegistrationError, MissingIngredientError
{
return Platform.isSameItemPrecise( this.pro_output[0].getItemStack(), output );
return Platform.itemComparisons().isSameItem( this.pro_output[0].getItemStack(), output );
}
}
@@ -82,6 +82,6 @@ public class Pulverizer implements ICraftHandler, IWebsiteSerializer
@Override
public boolean canCraft( final ItemStack output ) throws RegistrationError, MissingIngredientError
{
return Platform.isSameItemPrecise( this.pro_output[0].getItemStack(), output );
return Platform.itemComparisons().isSameItem( this.pro_output[0].getItemStack(), output );
}
}
@@ -162,7 +162,7 @@ public class Shaped implements ICraftHandler, IWebsiteSerializer
{
for( final ItemStack r : i.getItemStackSet() )
{
if( Platform.isSameItemPrecise( r, reqOutput ) )
if( Platform.itemComparisons().isSameItem( r, reqOutput ) )
{
return false;
}
@@ -171,6 +171,6 @@ public class Shaped implements ICraftHandler, IWebsiteSerializer
}
}
return Platform.isSameItemPrecise( this.output.getItemStack(), reqOutput );
return Platform.itemComparisons().isSameItem( this.output.getItemStack(), reqOutput );
}
}
@@ -128,7 +128,7 @@ public class Shapeless implements ICraftHandler, IWebsiteSerializer
{
for( final ItemStack r : i.getItemStackSet() )
{
if( Platform.isSameItemPrecise( r, reqOutput ) )
if( Platform.itemComparisons().isSameItem( r, reqOutput ) )
{
return false;
}
@@ -136,6 +136,6 @@ public class Shapeless implements ICraftHandler, IWebsiteSerializer
}
}
return Platform.isSameItemPrecise( this.output.getItemStack(), reqOutput );
return Platform.itemComparisons().isSameItem( this.output.getItemStack(), reqOutput );
}
}
@@ -81,6 +81,6 @@ public class Smelt implements ICraftHandler, IWebsiteSerializer
@Override
public boolean canCraft( final ItemStack reqOutput ) throws RegistrationError, MissingIngredientError
{
return Platform.isSameItemPrecise( this.out.getItemStack(), reqOutput );
return Platform.itemComparisons().isSameItem( this.out.getItemStack(), reqOutput );
}
}
@@ -271,7 +271,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
if( is != null && is.getItem() instanceof ItemEncodedPattern )
{
if( !Platform.isSameItem( is, this.myPattern ) )
if( !Platform.itemComparisons().isEqualItem( is, this.myPattern ) )
{
final World w = this.getWorld();
final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
@@ -194,7 +194,7 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
ItemStack removed = oldStack;
ItemStack added = newItemStack;
if( oldStack != null && newItemStack != null && Platform.isSameItem( oldStack, newItemStack ) )
if( oldStack != null && newItemStack != null && Platform.itemComparisons().isEqualItem( oldStack, newItemStack ) )
{
if( oldStack.stackSize > newItemStack.stackSize )
{
@@ -124,7 +124,7 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
ItemStack removed = oldStack;
ItemStack added = newItemStack;
if( oldStack != null && newItemStack != null && Platform.isSameItem( oldStack, newItemStack ) )
if( oldStack != null && newItemStack != null && Platform.itemComparisons().isEqualItem( oldStack, newItemStack ) )
{
if( oldStack.stackSize > newItemStack.stackSize )
{
@@ -135,7 +135,7 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
private boolean canAddOutput( final ItemStack output )
{
final ItemStack outputStack = this.getStackInSlot( 1 );
return outputStack == null || ( Platform.isSameItem( outputStack, output ) && outputStack.stackSize < outputStack.getMaxStackSize() );
return outputStack == null || ( Platform.itemComparisons().isEqualItem( outputStack, output ) && outputStack.stackSize < outputStack.getMaxStackSize() );
}
/**
@@ -256,7 +256,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
for( final ItemStack optionals : AEApi.instance().registries().inscriber().getOptionals() )
{
if( Platform.isSameItemPrecise( optionals, itemstack ) )
if( Platform.itemComparisons().isSameItem( optionals, itemstack ) )
{
return true;
}
@@ -410,17 +410,17 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
{
final boolean matchA = ( plateA == null && !recipe.getTopOptional().isPresent() ) || ( Platform.isSameItemPrecise( plateA, recipe.getTopOptional().orElse( null ) ) ) && // and...
( plateB == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.isSameItemPrecise( plateB, recipe.getBottomOptional().orElse( null ) ) );
final boolean matchA = ( plateA == null && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateA, recipe.getTopOptional().orElse( null ) ) ) && // and...
( plateB == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( plateB, recipe.getBottomOptional().orElse( null ) ) );
final boolean matchB = ( plateB == null && !recipe.getTopOptional().isPresent() ) || ( Platform.isSameItemPrecise( plateB, recipe.getTopOptional().orElse( null ) ) ) && // and...
( plateA == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.isSameItemPrecise( plateA, recipe.getBottomOptional().orElse( null ) ) );
final boolean matchB = ( plateB == null && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateB, recipe.getTopOptional().orElse( null ) ) ) && // and...
( plateA == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( plateA, recipe.getBottomOptional().orElse( null ) ) );
if( matchA || matchB )
{
for( final ItemStack option : recipe.getInputs() )
{
if( Platform.isSameItemPrecise( option, this.getStackInSlot( 2 ) ) )
if( Platform.itemComparisons().isSameItem( option, this.getStackInSlot( 2 ) ) )
{
return recipe;
}
@@ -467,7 +467,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
this.lastStateChange = this.worldObj.getTotalWorldTime();
return oldPaintedColor != this.paintedColor || ( this.state & 0xDB6DB6DB ) != ( oldState & 0xDB6DB6DB ) || !Platform.isSameItemPrecise( oldType, this.storageType );
return oldPaintedColor != this.paintedColor || ( this.state & 0xDB6DB6DB ) != ( oldState & 0xDB6DB6DB ) || !Platform.itemComparisons().isSameItem( oldType, this.storageType );
}
@TileEvent( TileEventType.WORLD_NBT_READ )
+18 -377
View File
@@ -19,7 +19,6 @@
package appeng.util;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.security.InvalidParameterException;
import java.text.DecimalFormat;
@@ -30,8 +29,8 @@ import java.util.EnumSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.WeakHashMap;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -55,11 +54,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTPrimitive;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.network.play.server.SPacketChunkData;
import net.minecraft.server.management.PlayerChunkMap;
import net.minecraft.server.management.PlayerChunkMapEntry;
@@ -90,7 +85,6 @@ import net.minecraftforge.oredict.OreDictionary;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.PowerUnits;
import appeng.api.config.SearchBoxMode;
@@ -137,11 +131,10 @@ import appeng.integration.IntegrationType;
import appeng.me.GridAccessException;
import appeng.me.GridNode;
import appeng.me.helpers.AENetworkProxy;
import appeng.util.helpers.ItemComparisonHelper;
import appeng.util.item.AEItemStack;
import appeng.util.item.AESharedNBT;
import appeng.util.item.OreHelper;
import appeng.util.item.OreReference;
import appeng.util.prioitylist.IPartitionList;
import appeng.util.prioritylist.IPartitionList;
/**
@@ -162,9 +155,15 @@ public class Platform
*/
private static final Random RANDOM_GENERATOR = new Random();
private static final WeakHashMap<World, EntityPlayer> FAKE_PLAYERS = new WeakHashMap<World, EntityPlayer>();
private static Field tagList;
private static Method getEntry;
private static final ItemComparisonHelper ITEM_COMPARISON_HELPER = new ItemComparisonHelper();
public static ItemComparisonHelper itemComparisons()
{
return ITEM_COMPARISON_HELPER;
}
public static Random getRandom()
{
return RANDOM_GENERATOR;
@@ -423,251 +422,6 @@ public class Platform
}
}
/*
* Lots of silliness to try and account for weird tag related junk, basically requires that two tags have at least
* something in their tags before it wasts its time comparing them.
*/
private static boolean sameStackStags( final ItemStack a, final ItemStack b )
{
if( a == null && b == null )
{
return true;
}
if( a == null || b == null )
{
return false;
}
if( a == b )
{
return true;
}
final NBTTagCompound ta = a.getTagCompound();
final NBTTagCompound tb = b.getTagCompound();
if( ta == tb )
{
return true;
}
if( ( ta == null && tb == null ) || ( ta != null && ta.hasNoTags() && tb == null ) || ( tb != null && tb.hasNoTags() && ta == null ) || ( ta != null && ta.hasNoTags() && tb != null && tb.hasNoTags() ) )
{
return true;
}
if( ( ta == null && tb != null ) || ( ta != null && tb == null ) )
{
return false;
}
// if both tags are shared this is easy...
if( AESharedNBT.isShared( ta ) && AESharedNBT.isShared( tb ) )
{
return ta == tb;
}
return NBTEqualityTest( ta, tb );
}
/*
* recursive test for NBT Equality, this was faster then trying to compare / generate hashes, its also more reliable
* then the vanilla version which likes to fail when NBT Compound data changes order, it is pretty expensive
* performance wise, so try an use shared tag compounds as long as the system remains in AE.
*/
public static boolean NBTEqualityTest( final NBTBase left, final NBTBase right )
{
// same type?
final byte id = left.getId();
if( id == right.getId() )
{
switch( id )
{
case 10:
{
final NBTTagCompound ctA = (NBTTagCompound) left;
final NBTTagCompound ctB = (NBTTagCompound) right;
final Set<String> cA = ctA.getKeySet();
final Set<String> cB = ctB.getKeySet();
if( cA.size() != cB.size() )
{
return false;
}
for( final String name : cA )
{
final NBTBase tag = ctA.getTag( name );
final NBTBase aTag = ctB.getTag( name );
if( aTag == null )
{
return false;
}
if( !NBTEqualityTest( tag, aTag ) )
{
return false;
}
}
return true;
}
case 9: // ) // A instanceof NBTTagList )
{
final NBTTagList lA = (NBTTagList) left;
final NBTTagList lB = (NBTTagList) right;
if( lA.tagCount() != lB.tagCount() )
{
return false;
}
final List<NBTBase> tag = tagList( lA );
final List<NBTBase> aTag = tagList( lB );
if( tag.size() != aTag.size() )
{
return false;
}
for( int x = 0; x < tag.size(); x++ )
{
if( aTag.get( x ) == null )
{
return false;
}
if( !NBTEqualityTest( tag.get( x ), aTag.get( x ) ) )
{
return false;
}
}
return true;
}
case 1: // ( A instanceof NBTTagByte )
return ( (NBTPrimitive) left ).getByte() == ( (NBTPrimitive) right ).getByte();
case 4: // else if ( A instanceof NBTTagLong )
return ( (NBTPrimitive) left ).getLong() == ( (NBTPrimitive) right ).getLong();
case 8: // else if ( A instanceof NBTTagString )
return ( (NBTTagString) left ).getString().equals( ( (NBTTagString) right ).getString() ) || ( (NBTTagString) left ).getString().equals( ( (NBTTagString) right ).getString() );
case 6: // else if ( A instanceof NBTTagDouble )
return ( (NBTPrimitive) left ).getDouble() == ( (NBTPrimitive) right ).getDouble();
case 5: // else if ( A instanceof NBTTagFloat )
return ( (NBTPrimitive) left ).getFloat() == ( (NBTPrimitive) right ).getFloat();
case 3: // else if ( A instanceof NBTTagInt )
return ( (NBTPrimitive) left ).getInt() == ( (NBTPrimitive) right ).getInt();
default:
return left.equals( right );
}
}
return false;
}
private static List<NBTBase> tagList( final NBTTagList lB )
{
if( tagList == null )
{
try
{
tagList = lB.getClass().getDeclaredField( "tagList" );
}
catch( final Throwable t )
{
try
{
tagList = lB.getClass().getDeclaredField( "field_74747_a" );
}
catch( final Throwable z )
{
AELog.debug( t );
AELog.debug( z );
}
}
}
try
{
tagList.setAccessible( true );
return (List<NBTBase>) tagList.get( lB );
}
catch( final Throwable t )
{
AELog.debug( t );
}
return new ArrayList<NBTBase>();
}
/*
* Orderless hash on NBT Data, used to work thought huge piles fast, but ignores the order just in case MC decided
* to change it... WHICH IS BAD...
*/
public static int NBTOrderlessHash( final NBTBase nbt )
{
// same type?
int hash = 0;
final byte id = nbt.getId();
hash += id;
switch( id )
{
case 10:
{
final NBTTagCompound ctA = (NBTTagCompound) nbt;
final Set<String> cA = ctA.getKeySet();
for( final String name : cA )
{
hash += name.hashCode() ^ NBTOrderlessHash( ctA.getTag( name ) );
}
return hash;
}
case 9: // ) // A instanceof NBTTagList )
{
final NBTTagList lA = (NBTTagList) nbt;
hash += 9 * lA.tagCount();
final List<NBTBase> l = tagList( lA );
for( int x = 0; x < l.size(); x++ )
{
hash += ( (Integer) x ).hashCode() ^ NBTOrderlessHash( l.get( x ) );
}
return hash;
}
case 1: // ( A instanceof NBTTagByte )
return hash + ( (NBTPrimitive) nbt ).getByte();
case 4: // else if ( A instanceof NBTTagLong )
return hash + (int) ( (NBTPrimitive) nbt ).getLong();
case 8: // else if ( A instanceof NBTTagString )
return hash + ( (NBTTagString) nbt ).getString().hashCode();
case 6: // else if ( A instanceof NBTTagDouble )
return hash + (int) ( (NBTPrimitive) nbt ).getDouble();
case 5: // else if ( A instanceof NBTTagFloat )
return hash + (int) ( (NBTPrimitive) nbt ).getFloat();
case 3: // else if ( A instanceof NBTTagInt )
return hash + ( (NBTPrimitive) nbt ).getInt();
default:
return hash;
}
}
/*
* The usual version of this returns an ItemStack, this version returns the recipe.
*/
@@ -1127,7 +881,7 @@ public class Platform
}
return -1;
}
public static int findEmpty( final Object[] l )
{
for( int x = 0; x < l.length; x++ )
@@ -1142,6 +896,7 @@ public class Platform
/**
* Returns a random element from the given collection.
*
* @return null if the collection is empty
*/
@Nullable
@@ -1371,102 +1126,6 @@ public class Platform
return I18n.translateToLocal( string );
}
public static boolean isSameItemPrecise( @Nullable final ItemStack is, @Nullable final ItemStack filter )
{
return isSameItem( is, filter ) && sameStackStags( is, filter );
}
public static boolean isSameItemFuzzy( final ItemStack a, final ItemStack b, final FuzzyMode mode )
{
if( a == null && b == null )
{
return true;
}
if( a == null )
{
return false;
}
if( b == null )
{
return false;
}
/*
* if ( a.itemID != 0 && b.itemID != 0 && a.isItemStackDamageable() && ! a.getHasSubtypes() && a.itemID ==
* b.itemID ) { return (a.getItemDamage() > 0) == (b.getItemDamage() > 0); }
*/
// test damageable items..
if( a.getItem() != null && b.getItem() != null && a.getItem().isDamageable() && a.getItem() == b.getItem() )
{
try
{
if( mode == FuzzyMode.IGNORE_ALL )
{
return true;
}
else if( mode == FuzzyMode.PERCENT_99 )
{
final Item ai = a.getItem();
final Item bi = b.getItem();
return ( ai.getDurabilityForDisplay( a ) > 1 ) == ( bi.getDurabilityForDisplay( b ) > 1 );
}
else
{
final Item ai = a.getItem();
final Item bi = b.getItem();
final float percentDamagedOfA = 1.0f - (float) ai.getDurabilityForDisplay( a );
final float percentDamagedOfB = 1.0f - (float) bi.getDurabilityForDisplay( b );
return ( percentDamagedOfA > mode.breakPoint ) == ( percentDamagedOfB > mode.breakPoint );
}
}
catch( final Throwable e )
{
if( mode == FuzzyMode.IGNORE_ALL )
{
return true;
}
else if( mode == FuzzyMode.PERCENT_99 )
{
return ( a.getItemDamage() > 1 ) == ( b.getItemDamage() > 1 );
}
else
{
final float percentDamagedOfA = (float) a.getItemDamage() / (float) a.getMaxDamage();
final float percentDamagedOfB = (float) b.getItemDamage() / (float) b.getMaxDamage();
return ( percentDamagedOfA > mode.breakPoint ) == ( percentDamagedOfB > mode.breakPoint );
}
}
}
final OreReference aOR = OreHelper.INSTANCE.isOre( a );
final OreReference bOR = OreHelper.INSTANCE.isOre( b );
if( OreHelper.INSTANCE.sameOre( aOR, bOR ) )
{
return true;
}
/*
* // test ore dictionary.. int OreID = getOreID( a ); if ( OreID != -1 ) return OreID == getOreID( b );
* if ( Mode != FuzzyMode.IGNORE_ALL ) { if ( a.hasTagCompound() && !isShared( a.getTagCompound() ) ) { a =
* Platform.getSharedItemStack( AEItemStack.create( a ) ); }
* if ( b.hasTagCompound() && !isShared( b.getTagCompound() ) ) { b = Platform.getSharedItemStack(
* AEItemStack.create( b ) ); }
* // test regular items with damage values and what not... if ( isShared( a.getTagCompound() ) && isShared(
* b.getTagCompound() ) && a.itemID == b.itemID ) { return ((AppEngSharedNBTTagCompound)
* a.getTagCompound()).compareFuzzyWithRegistry( (AppEngSharedNBTTagCompound) b.getTagCompound() ); } }
*/
return a.isItemEqual( b );
}
public static LookDirection getPlayerRay( final EntityPlayer playerIn, final float eyeOffset )
{
double reachDistance = 5.0d;
@@ -1982,12 +1641,12 @@ public class Platform
for( final IAEItemStack x : items )
{
final ItemStack sh = x.getItemStack();
if( ( Platform.isSameItemType( providedTemplate, sh ) || ae_req.sameOre( x ) ) && !Platform.isSameItem( sh, output ) )
if( ( Platform.itemComparisons().isEqualItemType( providedTemplate, sh ) || ae_req.sameOre( x ) ) && !Platform.itemComparisons().isEqualItem( sh, output ) )
{ // Platform.isSameItemType( sh, providedTemplate )
final ItemStack cp = Platform.cloneItemStack( sh );
cp.stackSize = 1;
ci.setInventorySlotContents( slot, cp );
if( r.matches( ci, w ) && Platform.isSameItem( r.getCraftingResult( ci ), output ) )
if( r.matches( ci, w ) && Platform.itemComparisons().isEqualItem( r.getCraftingResult( ci ), output ) )
{
final IAEItemStack ax = x.copy();
ax.setStackSize( 1 );
@@ -2009,24 +1668,6 @@ public class Platform
return null;
}
public static boolean isSameItemType( final ItemStack that, final ItemStack other )
{
if( that != null && other != null && that.getItem() == other.getItem() )
{
if( that.isItemStackDamageable() )
{
return true;
}
return that.getItemDamage() == other.getItemDamage();
}
return false;
}
public static boolean isSameItem( @Nullable final ItemStack left, @Nullable final ItemStack right )
{
return left != null && right != null && left.isItemEqual( right );
}
public static ItemStack cloneItemStack( final ItemStack a )
{
return a.copy();
@@ -2097,22 +1738,22 @@ public class Platform
{
if( parts.cableGlass().sameAs( AEColor.TRANSPARENT, stack ) )
{
return Collections.singletonList(stack);
return Collections.singletonList( stack );
}
if( parts.cableCovered().sameAs( AEColor.TRANSPARENT, stack ) )
{
return Collections.singletonList(stack);
return Collections.singletonList( stack );
}
if( parts.cableSmart().sameAs( AEColor.TRANSPARENT, stack ) )
{
return Collections.singletonList(stack);
return Collections.singletonList( stack );
}
if( parts.cableDense().sameAs( AEColor.TRANSPARENT, stack ) )
{
return Collections.singletonList(stack);
return Collections.singletonList( stack );
}
}
@@ -0,0 +1,443 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.util.helpers;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javax.annotation.Nullable;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTPrimitive;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.config.FuzzyMode;
import appeng.core.AELog;
import appeng.util.item.AESharedNBT;
import appeng.util.item.OreHelper;
import appeng.util.item.OreReference;
/**
* A helper class for comparing {@link Item}, {@link ItemStack} or NBT
*
*/
public class ItemComparisonHelper
{
private static Field tagList;
/**
* Compare the two {@link ItemStack}s based on the same {@link Item} and damage value.
*
* In case of the item being damageable, only the {@link Item} will be considered.
* If not it will also compare both damage values.
*
* Ignores NBT.
*
* @return true, if both are equal.
*/
public boolean isEqualItemType( final ItemStack that, final ItemStack other )
{
if( that != null && other != null && that.getItem() == other.getItem() )
{
if( that.isItemStackDamageable() )
{
return true;
}
return that.getItemDamage() == other.getItemDamage();
}
return false;
}
/**
* A wrapper around {@link ItemStack#isItemEqual(ItemStack)}.
*
* The benefit is to compare two null item stacks, without any additional null checks.
*
* Ignores NBT.
*
* @return true, if both are equal.
*/
public boolean isEqualItem( @Nullable final ItemStack left, @Nullable final ItemStack right )
{
return left != null && right != null && left.isItemEqual( right );
}
/**
* Compares two {@link ItemStack} and their NBT tag for equality.
*
* Use this when a precise check is required and the same item is required.
* Not just something with different NBT tags.
*
* @return true, if both are identical.
*/
public boolean isSameItem( @Nullable final ItemStack is, @Nullable final ItemStack filter )
{
return isEqualItem( is, filter ) && hasSameNbtTag( is, filter );
}
/**
* Similar to {@link ItemComparisonHelper#isEqualItem(ItemStack, ItemStack)},
* but it can further check, if both match the same {@link FuzzyMode}
* or are considered equal by the {@link OreDictionary}
*
* @param mode how to compare the two {@link ItemStack}s
* @return true, if both are matching the mode or considered equal by the {@link OreDictionary}
*/
public boolean isFuzzyEqualItem( final ItemStack a, final ItemStack b, final FuzzyMode mode )
{
if( a == null && b == null )
{
return true;
}
if( a == null || b == null )
{
return false;
}
/*
* if ( a.itemID != 0 && b.itemID != 0 && a.isItemStackDamageable() && ! a.getHasSubtypes() && a.itemID ==
* b.itemID ) { return (a.getItemDamage() > 0) == (b.getItemDamage() > 0); }
*/
// test damageable items..
if( a.getItem() != null && b.getItem() != null && a.getItem().isDamageable() && a.getItem() == b.getItem() )
{
try
{
if( mode == FuzzyMode.IGNORE_ALL )
{
return true;
}
else if( mode == FuzzyMode.PERCENT_99 )
{
final Item ai = a.getItem();
final Item bi = b.getItem();
return ( ai.getDurabilityForDisplay( a ) > 1 ) == ( bi.getDurabilityForDisplay( b ) > 1 );
}
else
{
final Item ai = a.getItem();
final Item bi = b.getItem();
final float percentDamagedOfA = 1.0f - (float) ai.getDurabilityForDisplay( a );
final float percentDamagedOfB = 1.0f - (float) bi.getDurabilityForDisplay( b );
return ( percentDamagedOfA > mode.breakPoint ) == ( percentDamagedOfB > mode.breakPoint );
}
}
catch( final Throwable e )
{
if( mode == FuzzyMode.IGNORE_ALL )
{
return true;
}
else if( mode == FuzzyMode.PERCENT_99 )
{
return ( a.getItemDamage() > 1 ) == ( b.getItemDamage() > 1 );
}
else
{
final float percentDamagedOfA = (float) a.getItemDamage() / (float) a.getMaxDamage();
final float percentDamagedOfB = (float) b.getItemDamage() / (float) b.getMaxDamage();
return ( percentDamagedOfA > mode.breakPoint ) == ( percentDamagedOfB > mode.breakPoint );
}
}
}
final OreReference aOR = OreHelper.INSTANCE.isOre( a );
final OreReference bOR = OreHelper.INSTANCE.isOre( b );
if( OreHelper.INSTANCE.sameOre( aOR, bOR ) )
{
return true;
}
/*
* // test ore dictionary.. int OreID = getOreID( a ); if ( OreID != -1 ) return OreID == getOreID( b );
* if ( Mode != FuzzyMode.IGNORE_ALL ) { if ( a.hasTagCompound() && !isShared( a.getTagCompound() ) ) { a =
* Platform.getSharedItemStack( AEItemStack.create( a ) ); }
* if ( b.hasTagCompound() && !isShared( b.getTagCompound() ) ) { b = Platform.getSharedItemStack(
* AEItemStack.create( b ) ); }
* // test regular items with damage values and what not... if ( isShared( a.getTagCompound() ) && isShared(
* b.getTagCompound() ) && a.itemID == b.itemID ) { return ((AppEngSharedNBTTagCompound)
* a.getTagCompound()).compareFuzzyWithRegistry( (AppEngSharedNBTTagCompound) b.getTagCompound() ); } }
*/
return a.isItemEqual( b );
}
/**
* recursive test for NBT Equality, this was faster then trying to compare / generate hashes, its also more reliable
* then the vanilla version which likes to fail when NBT Compound data changes order, it is pretty expensive
* performance wise, so try an use shared tag compounds as long as the system remains in AE.
*/
public boolean isNbtTagEqual( final NBTBase left, final NBTBase right )
{
// same type?
final byte id = left.getId();
if( id == right.getId() )
{
switch( id )
{
case 10:
{
final NBTTagCompound ctA = (NBTTagCompound) left;
final NBTTagCompound ctB = (NBTTagCompound) right;
final Set<String> cA = ctA.getKeySet();
final Set<String> cB = ctB.getKeySet();
if( cA.size() != cB.size() )
{
return false;
}
for( final String name : cA )
{
final NBTBase tag = ctA.getTag( name );
final NBTBase aTag = ctB.getTag( name );
if( aTag == null )
{
return false;
}
if( !isNbtTagEqual( tag, aTag ) )
{
return false;
}
}
return true;
}
case 9: // ) // A instanceof NBTTagList )
{
final NBTTagList lA = (NBTTagList) left;
final NBTTagList lB = (NBTTagList) right;
if( lA.tagCount() != lB.tagCount() )
{
return false;
}
final List<NBTBase> tag = tagList( lA );
final List<NBTBase> aTag = tagList( lB );
if( tag.size() != aTag.size() )
{
return false;
}
for( int x = 0; x < tag.size(); x++ )
{
if( aTag.get( x ) == null )
{
return false;
}
if( !isNbtTagEqual( tag.get( x ), aTag.get( x ) ) )
{
return false;
}
}
return true;
}
case 1: // NBTTagByte
return ( (NBTPrimitive) left ).getByte() == ( (NBTPrimitive) right ).getByte();
case 4: // NBTTagLong
return ( (NBTPrimitive) left ).getLong() == ( (NBTPrimitive) right ).getLong();
case 8: // NBTTagString
return ( (NBTTagString) left ).getString().equals( ( (NBTTagString) right ).getString() );
case 6: // NBTTagDouble
return ( (NBTPrimitive) left ).getDouble() == ( (NBTPrimitive) right ).getDouble();
case 5: // NBTTagFloat
return ( (NBTPrimitive) left ).getFloat() == ( (NBTPrimitive) right ).getFloat();
case 3: // NBTTagInt
return ( (NBTPrimitive) left ).getInt() == ( (NBTPrimitive) right ).getInt();
default:
return left.equals( right );
}
}
return false;
}
/**
* Unordered hash of NBT Data, used to work thought huge piles fast, but ignores the order just in case MC
* decided to change it... WHICH IS BAD...
*/
public int createUnorderedNbtHash( final NBTBase nbt )
{
// same type?
int hash = 0;
final byte id = nbt.getId();
hash += id;
switch( id )
{
case 10:
{
final NBTTagCompound ctA = (NBTTagCompound) nbt;
final Set<String> cA = ctA.getKeySet();
for( final String name : cA )
{
hash += name.hashCode() ^ createUnorderedNbtHash( ctA.getTag( name ) );
}
return hash;
}
case 9: // ) // A instanceof NBTTagList )
{
final NBTTagList lA = (NBTTagList) nbt;
hash += 9 * lA.tagCount();
final List<NBTBase> l = tagList( lA );
for( int x = 0; x < l.size(); x++ )
{
hash += ( (Integer) x ).hashCode() ^ createUnorderedNbtHash( l.get( x ) );
}
return hash;
}
case 1: // NBTTagByte
return hash + ( (NBTPrimitive) nbt ).getByte();
case 4: // NBTTagLong
return hash + (int) ( (NBTPrimitive) nbt ).getLong();
case 8: // NBTTagString
return hash + ( (NBTTagString) nbt ).getString().hashCode();
case 6: // NBTTagDouble
return hash + (int) ( (NBTPrimitive) nbt ).getDouble();
case 5: // NBTTagFloat
return hash + (int) ( (NBTPrimitive) nbt ).getFloat();
case 3: // NBTTagInt
return hash + ( (NBTPrimitive) nbt ).getInt();
default:
return hash;
}
}
/**
* Lots of silliness to try and account for weird tag related junk, basically requires that two tags have at least
* something in their tags before it wastes its time comparing them.
*/
private boolean hasSameNbtTag( final ItemStack a, final ItemStack b )
{
if( a == null && b == null )
{
return true;
}
if( a == null || b == null )
{
return false;
}
if( a == b )
{
return true;
}
final NBTTagCompound ta = a.getTagCompound();
final NBTTagCompound tb = b.getTagCompound();
if( ta == tb )
{
return true;
}
if( ( ta == null && tb == null ) || ( ta != null && ta.hasNoTags() && tb == null ) || ( tb != null && tb.hasNoTags() && ta == null ) || ( ta != null && ta.hasNoTags() && tb != null && tb.hasNoTags() ) )
{
return true;
}
if( ( ta == null && tb != null ) || ( ta != null && tb == null ) )
{
return false;
}
// if both tags are shared this is easy...
if( AESharedNBT.isShared( ta ) && AESharedNBT.isShared( tb ) )
{
return ta == tb;
}
return isNbtTagEqual( ta, tb );
}
private List<NBTBase> tagList( final NBTTagList lB )
{
if( tagList == null )
{
try
{
tagList = lB.getClass().getDeclaredField( "tagList" );
}
catch( final Throwable t )
{
try
{
tagList = lB.getClass().getDeclaredField( "field_74747_a" );
}
catch( final Throwable z )
{
AELog.debug( t );
AELog.debug( z );
}
}
}
try
{
tagList.setAccessible( true );
return (List<NBTBase>) tagList.get( lB );
}
catch( final Throwable t )
{
AELog.debug( t );
}
return new ArrayList<NBTBase>();
}
}
@@ -50,7 +50,7 @@ public class AdaptorIInventory extends InventoryAdaptor
for( int x = 0; x < s && amount > 0; x++ )
{
final ItemStack is = this.i.getStackInSlot( x );
if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.isSameItemPrecise( is, filter ) ) )
if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.itemComparisons().isSameItem( is, filter ) ) )
{
int boundAmounts = amount;
if( boundAmounts > is.stackSize )
@@ -108,7 +108,7 @@ public class AdaptorIInventory extends InventoryAdaptor
for( int x = 0; x < s && amount > 0; x++ )
{
final ItemStack is = this.i.getStackInSlot( x );
if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.isSameItemPrecise( is, filter ) ) )
if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.itemComparisons().isSameItem( is, filter ) ) )
{
int boundAmount = amount;
if( boundAmount > is.stackSize )
@@ -147,7 +147,7 @@ public class AdaptorIInventory extends InventoryAdaptor
for( int x = 0; x < s; x++ )
{
final ItemStack is = this.i.getStackInSlot( x );
if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.isSameItemFuzzy( is, filter, fuzzyMode ) ) )
if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) )
{
int newAmount = amount;
if( newAmount > is.stackSize )
@@ -197,7 +197,7 @@ public class AdaptorIInventory extends InventoryAdaptor
{
final ItemStack is = this.i.getStackInSlot( x );
if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.isSameItemFuzzy( is, filter, fuzzyMode ) ) )
if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) )
{
int boundAmount = amount;
if( boundAmount > is.stackSize )
@@ -293,7 +293,7 @@ public class AdaptorIInventory extends InventoryAdaptor
return null;
}
}
else if( Platform.isSameItemPrecise( is, left ) && is.stackSize < perOperationLimit )
else if( Platform.itemComparisons().isSameItem( is, left ) && is.stackSize < perOperationLimit )
{
final int room = perOperationLimit - is.stackSize;
final int used = Math.min( left.stackSize, room );
@@ -47,7 +47,7 @@ public class AdaptorItemHandler extends InventoryAdaptor
for( int slot = 0; slot < slots && amount > 0; slot++ )
{
final ItemStack is = itemHandler.getStackInSlot( slot );
if( is == null || ( filter != null && !Platform.isSameItemPrecise( is, filter ) ) )
if( is == null || ( filter != null && !Platform.itemComparisons().isSameItem( is, filter ) ) )
{
continue;
}
@@ -101,7 +101,7 @@ public class AdaptorItemHandler extends InventoryAdaptor
for( int slot = 0; slot < slots && amount > 0; slot++ )
{
final ItemStack is = itemHandler.getStackInSlot( slot );
if( is != null && ( filter == null || Platform.isSameItemPrecise( is, filter ) ) )
if( is != null && ( filter == null || Platform.itemComparisons().isSameItem( is, filter ) ) )
{
ItemStack extracted = itemHandler.extractItem( slot, amount, true );
@@ -149,7 +149,7 @@ public class AdaptorItemHandler extends InventoryAdaptor
for( int slot = 0; slot < slots && extracted == null; slot++ )
{
final ItemStack is = itemHandler.getStackInSlot( slot );
if( is == null || ( filter != null && !Platform.isSameItemFuzzy( is, filter, fuzzyMode ) ) )
if( is == null || ( filter != null && !Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) )
{
continue;
}
@@ -184,7 +184,7 @@ public class AdaptorItemHandler extends InventoryAdaptor
for( int slot = 0; slot < slots && extracted == null; slot++ )
{
final ItemStack is = itemHandler.getStackInSlot( slot );
if( is == null || ( filter != null && !Platform.isSameItemFuzzy( is, filter, fuzzyMode ) ) )
if( is == null || ( filter != null && !Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) )
{
continue;
}
@@ -229,7 +229,7 @@ public class AdaptorItemHandler extends InventoryAdaptor
{
ItemStack is = itemHandler.getStackInSlot( slot );
if( is == null || Platform.isSameItemPrecise( is, left ) )
if( is == null || Platform.itemComparisons().isSameItem( is, left ) )
{
left = itemHandler.insertItem( slot, left, simulate );
@@ -47,7 +47,7 @@ public class AdaptorList extends InventoryAdaptor
for( int x = 0; x < s; x++ )
{
final ItemStack is = this.i.get( x );
if( is != null && ( filter == null || Platform.isSameItemPrecise( is, filter ) ) )
if( is != null && ( filter == null || Platform.itemComparisons().isSameItem( is, filter ) ) )
{
if( amount > is.stackSize )
{
@@ -82,7 +82,7 @@ public class AdaptorList extends InventoryAdaptor
{
for( final ItemStack is : this.i )
{
if( is != null && ( filter == null || Platform.isSameItemPrecise( is, filter ) ) )
if( is != null && ( filter == null || Platform.itemComparisons().isSameItem( is, filter ) ) )
{
if( amount > is.stackSize )
{
@@ -111,7 +111,7 @@ public class AdaptorList extends InventoryAdaptor
for( int x = 0; x < s; x++ )
{
final ItemStack is = this.i.get( x );
if( is != null && ( filter == null || Platform.isSameItemFuzzy( is, filter, fuzzyMode ) ) )
if( is != null && ( filter == null || Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) )
{
if( amount > is.stackSize )
{
@@ -146,7 +146,7 @@ public class AdaptorList extends InventoryAdaptor
{
for( final ItemStack is : this.i )
{
if( is != null && ( filter == null || Platform.isSameItemFuzzy( is, filter, fuzzyMode ) ) )
if( is != null && ( filter == null || Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) )
{
if( amount > is.stackSize )
{
@@ -184,7 +184,7 @@ public class AdaptorList extends InventoryAdaptor
for( final ItemStack is : this.i )
{
if( Platform.isSameItem( is, left ) )
if( Platform.itemComparisons().isEqualItem( is, left ) )
{
is.stackSize += left.stackSize;
return null;
@@ -52,7 +52,7 @@ public class AdaptorPlayerHand extends InventoryAdaptor
return null;
}
if( filter == null || Platform.isSameItemPrecise( filter, hand ) )
if( filter == null || Platform.itemComparisons().isSameItem( filter, hand ) )
{
final ItemStack result = hand.copy();
result.stackSize = hand.stackSize > amount ? amount : hand.stackSize;
@@ -77,7 +77,7 @@ public class AdaptorPlayerHand extends InventoryAdaptor
return null;
}
if( filter == null || Platform.isSameItemPrecise( filter, hand ) )
if( filter == null || Platform.itemComparisons().isSameItem( filter, hand ) )
{
final ItemStack result = hand.copy();
result.stackSize = hand.stackSize > amount ? amount : hand.stackSize;
@@ -96,7 +96,7 @@ public class AdaptorPlayerHand extends InventoryAdaptor
return null;
}
if( filter == null || Platform.isSameItemFuzzy( filter, hand, fuzzyMode ) )
if( filter == null || Platform.itemComparisons().isFuzzyEqualItem( filter, hand, fuzzyMode ) )
{
final ItemStack result = hand.copy();
result.stackSize = hand.stackSize > amount ? amount : hand.stackSize;
@@ -121,7 +121,7 @@ public class AdaptorPlayerHand extends InventoryAdaptor
return null;
}
if( filter == null || Platform.isSameItemFuzzy( filter, hand, fuzzyMode ) )
if( filter == null || Platform.itemComparisons().isFuzzyEqualItem( filter, hand, fuzzyMode ) )
{
final ItemStack result = hand.copy();
result.stackSize = hand.stackSize > amount ? amount : hand.stackSize;
@@ -154,7 +154,7 @@ public class AdaptorPlayerHand extends InventoryAdaptor
final ItemStack hand = this.player.inventory.getItemStack();
if( hand != null && !Platform.isSameItemPrecise( toBeAdded, hand ) )
if( hand != null && !Platform.itemComparisons().isSameItem( toBeAdded, hand ) )
{
return toBeAdded;
}
@@ -194,7 +194,7 @@ public class AdaptorPlayerHand extends InventoryAdaptor
return null;
}
if( hand != null && !Platform.isSameItem( toBeSimulated, hand ) )
if( hand != null && !Platform.itemComparisons().isEqualItem( toBeSimulated, hand ) )
{
return toBeSimulated;
}
@@ -327,7 +327,7 @@ public final class AEFluidStack extends AEStack<IAEFluidStack> implements IAEFlu
return ta == tb;
}
return Platform.NBTEqualityTest( ta, tb );
return Platform.itemComparisons().isNbtTagEqual( ta, tb );
}
}
return false;
@@ -100,7 +100,7 @@ public class AEItemDef
if( this.getTagCompound() != null && otherStack.hasTagCompound() )
{
return Platform.NBTEqualityTest( this.getTagCompound(), otherStack.getTagCompound() );
return Platform.itemComparisons().isNbtTagEqual( this.getTagCompound(), otherStack.getTagCompound() );
}
return true;
@@ -522,7 +522,7 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
return ta == tb;
}
return Platform.NBTEqualityTest( ta, tb );
return Platform.itemComparisons().isNbtTagEqual( ta, tb );
}
}
return false;
@@ -136,7 +136,7 @@ public class AESharedNBT extends NBTTagCompound implements IAETagCompound
x.setTag( name, c.getTag( name ).copy() );
}
x.hash = Platform.NBTOrderlessHash( c );
x.hash = Platform.itemComparisons().createUnorderedNbtHash( c );
final ItemStack isc = new ItemStack( itemID, 1, damageValue );
isc.setTagCompound( c );
@@ -36,7 +36,7 @@ public class SharedSearchObject
public SharedSearchObject( final Item itemID, final int damageValue, final NBTTagCompound tagCompound )
{
this.def = ( damageValue << Platform.DEF_OFFSET ) | Item.REGISTRY.getIDForObject( itemID );
this.hash = Platform.NBTOrderlessHash( tagCompound );
this.hash = Platform.itemComparisons().createUnorderedNbtHash( tagCompound );
this.setCompound( tagCompound );
}
@@ -60,7 +60,7 @@ public class SharedSearchObject
final SharedSearchObject other = (SharedSearchObject) obj;
if( this.def == other.def && this.hash == other.hash )
{
return Platform.NBTEqualityTest( this.getCompound(), other.getCompound() );
return Platform.itemComparisons().isNbtTagEqual( this.getCompound(), other.getCompound() );
}
return false;
}
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.util.prioitylist;
package appeng.util.prioritylist;
import java.util.ArrayList;
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.util.prioitylist;
package appeng.util.prioritylist;
import java.util.Collection;
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.util.prioitylist;
package appeng.util.prioritylist;
import appeng.api.storage.data.IAEStack;
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.util.prioitylist;
package appeng.util.prioritylist;
import java.util.ArrayList;
@@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.util.prioitylist;
package appeng.util.prioritylist;
import appeng.api.storage.data.IAEStack;
@@ -73,17 +73,17 @@ tile.appliedenergistics2.sky_stone_slab.name=Himmelssteinstufe
// Chat Messages
chat.appliedenergistics2.ChestCannotReadStorageCell=ME-Truhe kann die Speicherzelle nicht einlesen.
chat.appliedenergistics2.SettingCleared=Einstellung gelöscht.
chat.appliedenergistics2.SettingCleared=Speicherkarte geleert.
chat.appliedenergistics2.OutOfRange=Drahtloser Zugangspunkt außer Reichweite.
chat.appliedenergistics2.InvalidMachine=Ungültige Maschine.
chat.appliedenergistics2.LoadedSettings=Einstellungen erfolgreich geladen.
chat.appliedenergistics2.LoadedSettings=Geräteeinstellungen von Speicherkarte geladen.
chat.appliedenergistics2.DeviceNotPowered=Gerät hat zu wenig Energie
chat.appliedenergistics2.DeviceNotWirelessTerminal=Gerät ist keine Drahtloskonsole.
chat.appliedenergistics2.DeviceNotLinked=Gerät ist nicht verbunden.
chat.appliedenergistics2.StationCanNotBeLocated=Station kann nicht lokalisiert werden.
chat.appliedenergistics2.MachineNotPowered=Maschine bekommt keine Energie.
chat.appliedenergistics2.CommunicationError=Fehler beim Kommunizieren mit dem Netzwerk.
chat.appliedenergistics2.SavedSettings=Einstellungen erfolgreich gespeichert.
chat.appliedenergistics2.SavedSettings=Geräteeinstellungen auf Speicherkarte kopiert.
chat.appliedenergistics2.AmmoDepleted=Munition verbraucht.
chat.appliedenergistics2.isNowLocked=Monitor ist nun gesperrt.
chat.appliedenergistics2.isNowUnlocked=Monitor ist nun entsperrt.
@@ -73,17 +73,17 @@ tile.appliedenergistics2.sky_stone_slab.name=Sky Stone Slabs
// Chat Messages
chat.appliedenergistics2.ChestCannotReadStorageCell=ME Chest cannot read storage cell.
chat.appliedenergistics2.SettingCleared=Setting Cleared.
chat.appliedenergistics2.SettingCleared=Memory card cleared.
chat.appliedenergistics2.OutOfRange=Wireless Out Of Range.
chat.appliedenergistics2.InvalidMachine=Invalid Machine.
chat.appliedenergistics2.LoadedSettings=Successfully loaded settings.
chat.appliedenergistics2.LoadedSettings=Loaded device configuration from memory card.
chat.appliedenergistics2.DeviceNotPowered=Device is low on power.
chat.appliedenergistics2.DeviceNotWirelessTerminal=Device is not a wireless terminal.
chat.appliedenergistics2.DeviceNotLinked=Device is not linked.
chat.appliedenergistics2.StationCanNotBeLocated=Station can not be located.
chat.appliedenergistics2.MachineNotPowered=Machine is not powered.
chat.appliedenergistics2.CommunicationError=Error Communicating with Network.
chat.appliedenergistics2.SavedSettings=Successfully saved settings.
chat.appliedenergistics2.SavedSettings=Copied device configuration to memory card.
chat.appliedenergistics2.AmmoDepleted=Ammo Depleted.
chat.appliedenergistics2.isNowLocked=Monitor is now Locked.
chat.appliedenergistics2.isNowUnlocked=Monitor is now Unlocked.
@@ -284,8 +284,8 @@ gui.tooltips.appliedenergistics2.EmitLevelsBelow=Излучать, когда у
gui.tooltips.appliedenergistics2.EmitLevelAbove=Излучать, когда уровни выше или равны пределу.
gui.tooltips.appliedenergistics2.SearchMode_Auto=Автоматический поиск
gui.tooltips.appliedenergistics2.SearchMode_Standard=Обычный поиск
gui.tooltips.appliedenergistics2.SearchMode_NEIAuto=Автоматический NEI-синхронизированный поиск
gui.tooltips.appliedenergistics2.SearchMode_NEIStandard=Стандартный NEI-синхронизированный поиск
gui.tooltips.appliedenergistics2.SearchMode_JEIAuto=Автоматический JEI-синхронизированный поиск
gui.tooltips.appliedenergistics2.SearchMode_JEIStandard=Стандартный JEI-синхронизированный поиск
gui.tooltips.appliedenergistics2.SearchMode=Режим поля поиска
gui.tooltips.appliedenergistics2.PartitionStorageHint=Настраивает раздел на основе текущих хранящихся предметах.
gui.tooltips.appliedenergistics2.ClearSettings=Очистить настройки
@@ -360,6 +360,10 @@ waila.appliedenergistics2.Unlocked=Разблокировано
waila.appliedenergistics2.Showing=Показывает
waila.appliedenergistics2.Contains=Содержит
waila.appliedenergistics2.Channels=Каналы: %1$d из %2$d
waila.appliedenergistics2.P2PUnlinked=Не связанный
waila.appliedenergistics2.P2PInputOneOutput=Связанный (Сторона ввода)
waila.appliedenergistics2.P2PInputManyOutputs=Связанный (Сторона ввода) - %d выводов
waila.appliedenergistics2.P2POutput=Связанный (Сторона вывода)
// Items
item.appliedenergistics2.storage_cell_1k.name=1К МЭ ячейка хранения