Fixes #675 No disabled feature should log spam or crash anymore.
Deprecates the old usage of the AEItemDefinitions via the direct method access of * blocks() * parts() * items() * materials() and thus use the new re-direct via definitions(). All definitions are now initialized, no matter what. But SubItems, Items and Blocks are not registered, if by chance are disabled.
This commit is contained in:
@@ -20,6 +20,7 @@ package appeng.core.sync;
|
||||
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
@@ -32,9 +33,12 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.definitions.Materials;
|
||||
import appeng.api.definitions.IComparableDefinition;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.api.exceptions.AppEngException;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
@@ -273,12 +277,8 @@ public enum GuiBridge implements IGuiHandler
|
||||
{
|
||||
ItemStack is = ((Slot) so).getStack();
|
||||
|
||||
Materials m = AEApi.instance().materials();
|
||||
if ( m.materialLogicProcessorPress.sameAsStack( is ) || m.materialEngProcessorPress.sameAsStack( is )
|
||||
|| m.materialCalcProcessorPress.sameAsStack( is ) || m.materialSiliconPress.sameAsStack( is ) )
|
||||
{
|
||||
Achievements.Presses.addToPlayer( inventory.player );
|
||||
}
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
this.addPressAchievementToPlayer( is, materials, inventory.player );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,6 +291,26 @@ public enum GuiBridge implements IGuiHandler
|
||||
}
|
||||
}
|
||||
|
||||
private void addPressAchievementToPlayer( ItemStack newItem, IMaterials possibleMaterials, EntityPlayer player )
|
||||
{
|
||||
final IComparableDefinition logic = possibleMaterials.logicProcessorPress();
|
||||
final IComparableDefinition eng = possibleMaterials.engProcessorPress();
|
||||
final IComparableDefinition calc = possibleMaterials.calcProcessorPress();
|
||||
final IComparableDefinition silicon = possibleMaterials.siliconPress();
|
||||
|
||||
final List<IComparableDefinition> presses = Lists.newArrayList( logic, eng, calc, silicon );
|
||||
|
||||
for ( IComparableDefinition press : presses )
|
||||
{
|
||||
if ( press.isSameAs( newItem ) )
|
||||
{
|
||||
Achievements.Presses.addToPlayer( player );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Object ConstructGui(InventoryPlayer inventory, ForgeDirection side, Object tE)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -25,6 +25,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IComparableDefinition;
|
||||
import appeng.api.definitions.IItems;
|
||||
import appeng.api.implementations.items.IMemoryCard;
|
||||
import appeng.api.implementations.items.MemoryCardMessages;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
@@ -58,21 +60,30 @@ public class PacketClick extends AppEngPacket
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
ItemStack is = player.inventory.getCurrentItem();
|
||||
if ( is != null && is.getItem() instanceof ToolNetworkTool )
|
||||
final IItems items = AEApi.instance().definitions().items();
|
||||
final IComparableDefinition maybeMemoryCard = items.memoryCard();
|
||||
final IComparableDefinition maybeColorApplicator = items.colorApplicator();
|
||||
|
||||
if ( is != null )
|
||||
{
|
||||
ToolNetworkTool tnt = (ToolNetworkTool) is.getItem();
|
||||
tnt.serverSideToolLogic( is, player, player.worldObj, this.x, this.y, this.z, this.side, this.hitX, this.hitY, this.hitZ );
|
||||
}
|
||||
else if ( is != null && AEApi.instance().items().itemMemoryCard.sameAsStack( is ) )
|
||||
{
|
||||
IMemoryCard mem = (IMemoryCard) is.getItem();
|
||||
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
|
||||
is.setTagCompound( null );
|
||||
}
|
||||
else if ( is != null && AEApi.instance().items().itemColorApplicator.sameAsStack( is ) )
|
||||
{
|
||||
ToolColorApplicator mem = (ToolColorApplicator) is.getItem();
|
||||
mem.cycleColors( is, mem.getColor( is ), 1 );
|
||||
if ( is.getItem() instanceof ToolNetworkTool )
|
||||
{
|
||||
ToolNetworkTool tnt = (ToolNetworkTool) is.getItem();
|
||||
tnt.serverSideToolLogic( is, player, player.worldObj, this.x, this.y, this.z, this.side, this.hitX, this.hitY, this.hitZ );
|
||||
}
|
||||
|
||||
else if ( maybeMemoryCard.isSameAs( is ) )
|
||||
{
|
||||
IMemoryCard mem = (IMemoryCard) is.getItem();
|
||||
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
|
||||
is.setTagCompound( null );
|
||||
}
|
||||
|
||||
else if ( maybeColorApplicator.isSameAs( is ) )
|
||||
{
|
||||
ToolColorApplicator mem = (ToolColorApplicator) is.getItem();
|
||||
mem.cycleColors( is, mem.getColor( is ), 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.client.gui.implementations.GuiCraftingCPU;
|
||||
@@ -183,11 +184,11 @@ public class PacketValueConfig extends AppEngPacket
|
||||
{
|
||||
IConfigManager cm = ((IConfigurableObject) c).getConfigManager();
|
||||
|
||||
for (Enum e : cm.getSettings())
|
||||
for (Settings e : cm.getSettings())
|
||||
{
|
||||
if ( e.name().equals( this.Name ) )
|
||||
{
|
||||
Enum def = cm.getSetting( e );
|
||||
Enum<?> def = cm.getSetting( e );
|
||||
|
||||
try
|
||||
{
|
||||
@@ -228,11 +229,11 @@ public class PacketValueConfig extends AppEngPacket
|
||||
{
|
||||
IConfigManager cm = ((IConfigurableObject) c).getConfigManager();
|
||||
|
||||
for (Enum e : cm.getSettings())
|
||||
for (Settings e : cm.getSettings())
|
||||
{
|
||||
if ( e.name().equals( this.Name ) )
|
||||
{
|
||||
Enum def = cm.getSetting( e );
|
||||
Enum<?> def = cm.getSetting( e );
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user