fix crash with GTCEu 2.2 and higher
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@ aebuild=7
|
|||||||
aegroup=appeng
|
aegroup=appeng
|
||||||
aebasename=appliedenergistics2
|
aebasename=appliedenergistics2
|
||||||
extended=extended_life
|
extended=extended_life
|
||||||
extendedversion=v51j
|
extendedversion=v51k
|
||||||
#########################################################
|
#########################################################
|
||||||
# Versions #
|
# Versions #
|
||||||
#########################################################
|
#########################################################
|
||||||
|
|||||||
@@ -98,9 +98,6 @@ import net.minecraftforge.items.wrapper.RangedWrapper;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static gregtech.api.block.machines.BlockMachine.getMetaTileEntity;
|
|
||||||
|
|
||||||
|
|
||||||
public class DualityInterface implements IGridTickable, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory, IConfigManagerHost, ICraftingProvider, IUpgradeableHost
|
public class DualityInterface implements IGridTickable, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory, IConfigManagerHost, ICraftingProvider, IUpgradeableHost
|
||||||
{
|
{
|
||||||
public static final int NUMBER_OF_STORAGE_SLOTS = 9;
|
public static final int NUMBER_OF_STORAGE_SLOTS = 9;
|
||||||
@@ -1477,8 +1474,11 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
|
|
||||||
if( Loader.isModLoaded( "gregtech" ) && directedBlock instanceof BlockMachine )
|
if( Loader.isModLoaded( "gregtech" ) && directedBlock instanceof BlockMachine )
|
||||||
{
|
{
|
||||||
MetaTileEntity metaTileEntity = getMetaTileEntity( hostWorld, targ );
|
MetaTileEntity metaTileEntity = Platform.getMetaTileEntity( directedTile.getWorld(), directedTile.getPos() );
|
||||||
return metaTileEntity.getMetaFullName();
|
if( metaTileEntity != null )
|
||||||
|
{
|
||||||
|
return metaTileEntity.getMetaFullName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -1506,7 +1506,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
|
|
||||||
if( what.getItem() != Items.AIR )
|
if( what.getItem() != Items.AIR )
|
||||||
{
|
{
|
||||||
return what.getUnlocalizedName();
|
return what.getItem().getItemStackDisplayName( what );
|
||||||
}
|
}
|
||||||
|
|
||||||
final Item item = Item.getItemFromBlock( directedBlock );
|
final Item item = Item.getItemFromBlock( directedBlock );
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
package appeng.util;
|
package appeng.util;
|
||||||
|
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.security.InvalidParameterException;
|
import java.security.InvalidParameterException;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -36,8 +38,10 @@ import com.google.common.base.Preconditions;
|
|||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
import gregtech.api.block.machines.BlockMachine;
|
||||||
import gregtech.api.items.IToolItem;
|
import gregtech.api.items.IToolItem;
|
||||||
import ic2.api.item.IC2Items;
|
import gregtech.api.metatileentity.MetaTileEntity;
|
||||||
|
import gregtech.api.util.GTUtility;
|
||||||
import ic2.api.item.ICustomDamageItem;
|
import ic2.api.item.ICustomDamageItem;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
@@ -67,6 +71,7 @@ import net.minecraft.util.math.RayTraceResult;
|
|||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.registry.RegistryNamespaced;
|
import net.minecraft.util.registry.RegistryNamespaced;
|
||||||
import net.minecraft.util.text.translation.I18n;
|
import net.minecraft.util.text.translation.I18n;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
@@ -77,6 +82,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
|
|||||||
import net.minecraftforge.fml.common.Loader;
|
import net.minecraftforge.fml.common.Loader;
|
||||||
import net.minecraftforge.fml.common.ModContainer;
|
import net.minecraftforge.fml.common.ModContainer;
|
||||||
import net.minecraftforge.fml.common.Optional;
|
import net.minecraftforge.fml.common.Optional;
|
||||||
|
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
@@ -158,6 +164,7 @@ public class Platform
|
|||||||
|
|
||||||
private static final ItemComparisonHelper ITEM_COMPARISON_HELPER = new ItemComparisonHelper();
|
private static final ItemComparisonHelper ITEM_COMPARISON_HELPER = new ItemComparisonHelper();
|
||||||
private static final P2PHelper P2P_HELPER = new P2PHelper();
|
private static final P2PHelper P2P_HELPER = new P2PHelper();
|
||||||
|
private static Method reflectGTgetMTE;
|
||||||
|
|
||||||
public static ItemComparisonHelper itemComparisons()
|
public static ItemComparisonHelper itemComparisons()
|
||||||
{
|
{
|
||||||
@@ -1681,11 +1688,39 @@ public class Platform
|
|||||||
return isPurified;
|
return isPurified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//consider methods below moving to a compability class
|
||||||
public static boolean isGTDamageableItem( Item item )
|
public static boolean isGTDamageableItem( Item item )
|
||||||
{
|
{
|
||||||
return ( isModLoaded( "gregtech" ) && item instanceof IToolItem );
|
return ( isModLoaded( "gregtech" ) && item instanceof IToolItem );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MetaTileEntity getMetaTileEntity( IBlockAccess world, BlockPos pos )
|
||||||
|
{
|
||||||
|
if( reflectGTgetMTE == null )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
reflectGTgetMTE = ReflectionHelper.findMethod( BlockMachine.class, "getMetaTileEntity", null, IBlockAccess.class, BlockPos.class );
|
||||||
|
}
|
||||||
|
catch( ReflectionHelper.UnableToFindMethodException e )
|
||||||
|
{
|
||||||
|
reflectGTgetMTE = ReflectionHelper.findMethod( GTUtility.class, "getMetaTileEntity", null, IBlockAccess.class, BlockPos.class );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return (MetaTileEntity) reflectGTgetMTE.invoke( reflectGTgetMTE, world, pos );
|
||||||
|
}
|
||||||
|
catch( IllegalAccessException | InvocationTargetException e )
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isIC2DamageableItem( Item item )
|
public static boolean isIC2DamageableItem( Item item )
|
||||||
{
|
{
|
||||||
return ( isModLoaded( "IC2" ) && item instanceof ICustomDamageItem );
|
return ( isModLoaded( "IC2" ) && item instanceof ICustomDamageItem );
|
||||||
|
|||||||
Reference in New Issue
Block a user