support for IC2 damageable items
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@ aebuild=7
|
||||
aegroup=appeng
|
||||
aebasename=appliedenergistics2
|
||||
extended=extended_life
|
||||
extendedversion=v51f
|
||||
extendedversion=v51g
|
||||
#########################################################
|
||||
# Versions #
|
||||
#########################################################
|
||||
|
||||
@@ -37,6 +37,8 @@ import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import gregtech.api.items.IToolItem;
|
||||
import ic2.api.item.IC2Items;
|
||||
import ic2.api.item.ICustomDamageItem;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -137,6 +139,7 @@ import appeng.util.prioritylist.IPartitionList;
|
||||
* @since rv0
|
||||
*/
|
||||
@Optional.Interface( iface = "gregtech.api.items.IToolItem", modid = "gregtech" )
|
||||
@Optional.Interface( iface = "ic2.api.item.ICustomDamageItem", modid = "IC2" )
|
||||
public class Platform
|
||||
{
|
||||
|
||||
@@ -1252,20 +1255,22 @@ public class Platform
|
||||
split.setStackSize( itemToAdd );
|
||||
leftover.add( cell.injectItems( split, Actionable.MODULATE, src ) );
|
||||
|
||||
src.player().ifPresent( player -> {
|
||||
final long diff = original - leftover.getStackSize();
|
||||
Stats.ItemsInserted.addToPlayer( player, (int) diff );
|
||||
} );
|
||||
src.player().ifPresent( player ->
|
||||
{
|
||||
final long diff = original - leftover.getStackSize();
|
||||
Stats.ItemsInserted.addToPlayer( player, (int) diff );
|
||||
} );
|
||||
|
||||
return leftover;
|
||||
}
|
||||
|
||||
final T ret = cell.injectItems( input, Actionable.MODULATE, src );
|
||||
|
||||
src.player().ifPresent( player -> {
|
||||
final long diff = ret == null ? input.getStackSize() : input.getStackSize() - ret.getStackSize();
|
||||
Stats.ItemsInserted.addToPlayer( player, (int) diff );
|
||||
} );
|
||||
src.player().ifPresent( player ->
|
||||
{
|
||||
final long diff = ret == null ? input.getStackSize() : input.getStackSize() - ret.getStackSize();
|
||||
Stats.ItemsInserted.addToPlayer( player, (int) diff );
|
||||
} );
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1680,4 +1685,9 @@ public class Platform
|
||||
{
|
||||
return ( isModLoaded( "gregtech" ) && item instanceof IToolItem );
|
||||
}
|
||||
|
||||
public static boolean isIC2DamageableItem( Item item )
|
||||
{
|
||||
return ( isModLoaded( "IC2" ) && item instanceof ICustomDamageItem );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
import gregtech.api.items.IToolItem;
|
||||
import ic2.api.item.ICustomDamageItem;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -377,20 +378,29 @@ public class AEItemStack extends AEStack<IAEItemStack> implements IAEItemStack
|
||||
}
|
||||
else if( mode == FuzzyMode.PERCENT_99 )
|
||||
{
|
||||
if( a.getItem().isDamageable() )
|
||||
if( Platform.isIC2DamageableItem( a.getItem() ) )
|
||||
{
|
||||
return ( (ICustomDamageItem) a.getItem() ).getCustomDamage( a ) > 1 == ( (ICustomDamageItem) b.getItem() ).getCustomDamage( b ) > 1;
|
||||
}
|
||||
else if( a.getItem().isDamageable() )
|
||||
{
|
||||
return a.getItemDamage() > 1 == b.getItemDamage() > 1;
|
||||
}
|
||||
else if( Platform.isGTDamageableItem( a.getItem() ) )
|
||||
{
|
||||
return ( (IToolItem) a.getItem() ).getItemDamage( a ) == ( (IToolItem) b.getItem() ).getItemDamage( b );
|
||||
return ( (IToolItem) a.getItem() ).getItemDamage( a ) > 1 == ( (IToolItem) b.getItem() ).getItemDamage( b ) > 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float percentDamageOfA = 0;
|
||||
float percentDamageOfB = 0;
|
||||
if( a.getItem().isDamageable() )
|
||||
if( Platform.isIC2DamageableItem( a.getItem() ) )
|
||||
{
|
||||
percentDamageOfA = (float) ( (ICustomDamageItem) a.getItem() ).getCustomDamage( a ) / ( (ICustomDamageItem) a.getItem() ).getMaxCustomDamage( a );
|
||||
percentDamageOfB = (float) ( (ICustomDamageItem) b.getItem() ).getCustomDamage( b ) / ( (ICustomDamageItem) b.getItem() ).getMaxCustomDamage( b );
|
||||
}
|
||||
else if( a.getItem().isDamageable() )
|
||||
{
|
||||
percentDamageOfA = (float) a.getItemDamage() / a.getMaxDamage();
|
||||
percentDamageOfB = (float) b.getItemDamage() / b.getMaxDamage();
|
||||
|
||||
@@ -26,6 +26,7 @@ import appeng.util.Platform;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import gregtech.api.items.IToolItem;
|
||||
import ic2.api.item.ICustomDamageItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectAVLTreeMap;
|
||||
@@ -169,7 +170,12 @@ class FuzzyItemVariantList extends ItemVariantList
|
||||
|
||||
int damage;
|
||||
int maxDamage;
|
||||
if( Platform.isGTDamageableItem( stack.getItem() ) )
|
||||
if( Platform.isIC2DamageableItem( stack.getItem() ) )
|
||||
{
|
||||
maxDamage = ( (ICustomDamageItem) stack.getItem() ).getMaxCustomDamage( stack );
|
||||
damage = ( (ICustomDamageItem) stack.getItem() ).getCustomDamage( stack );
|
||||
}
|
||||
else if( Platform.isGTDamageableItem( stack.getItem() ) )
|
||||
{
|
||||
maxDamage = ( (IToolItem) stack.getItem() ).getMaxItemDamage( stack );
|
||||
damage = ( (IToolItem) stack.getItem() ).getItemDamage( stack );
|
||||
@@ -212,7 +218,12 @@ class FuzzyItemVariantList extends ItemVariantList
|
||||
else
|
||||
{
|
||||
int maxDamage;
|
||||
if( Platform.isGTDamageableItem( stack.getItem() ) )
|
||||
if( Platform.isIC2DamageableItem( stack.getItem() ) )
|
||||
{
|
||||
maxDamage = ( (ICustomDamageItem) stack.getItem() ).getMaxCustomDamage( stack );
|
||||
damage = ( (ICustomDamageItem) stack.getItem() ).getCustomDamage( stack );
|
||||
}
|
||||
else if( Platform.isGTDamageableItem( stack.getItem() ) )
|
||||
{
|
||||
maxDamage = ( (IToolItem) stack.getItem() ).getMaxItemDamage( stack );
|
||||
damage = ( (IToolItem) stack.getItem() ).getItemDamage( stack );
|
||||
|
||||
Reference in New Issue
Block a user