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:
@@ -21,12 +21,12 @@ package appeng.items.tools.powered;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.packets.PacketLightning;
|
||||
@@ -40,9 +40,8 @@ public class ToolChargedStaff extends AEBasePoweredItem
|
||||
|
||||
public ToolChargedStaff()
|
||||
{
|
||||
super( ToolChargedStaff.class, Optional.<String> absent() );
|
||||
super( AEConfig.instance.chargedStaffBattery, Optional.<String> absent() );
|
||||
this.setFeature( EnumSet.of( AEFeature.ChargedStaff, AEFeature.PoweredTools ) );
|
||||
this.maxStoredPower = AEConfig.instance.chargedStaffBattery;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,8 +28,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -44,6 +42,8 @@ import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
@@ -99,9 +99,8 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
||||
|
||||
public ToolColorApplicator()
|
||||
{
|
||||
super( ToolColorApplicator.class, Optional.<String> absent() );
|
||||
super( AEConfig.instance.colorApplicatorBattery, Optional.<String> absent() );
|
||||
this.setFeature( EnumSet.of( AEFeature.ColorApplicator, AEFeature.PoweredTools ) );
|
||||
this.maxStoredPower = AEConfig.instance.colorApplicatorBattery;
|
||||
if ( Platform.isClient() )
|
||||
MinecraftForgeClient.registerItemRenderer( this, new ToolColorApplicatorRender() );
|
||||
}
|
||||
|
||||
@@ -62,15 +62,13 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
|
||||
|
||||
public ToolEntropyManipulator()
|
||||
{
|
||||
super( ToolEntropyManipulator.class, Optional.<String>absent() );
|
||||
super( AEConfig.instance.entropyManipulatorBattery, Optional.<String>absent() );
|
||||
|
||||
this.setFeature( EnumSet.of( AEFeature.EntropyManipulator, AEFeature.PoweredTools ) );
|
||||
|
||||
this.heatUp = new HashMap<InWorldToolOperationIngredient, InWorldToolOperationResult>();
|
||||
this.coolDown = new HashMap<InWorldToolOperationIngredient, InWorldToolOperationResult>();
|
||||
|
||||
this.maxStoredPower = AEConfig.instance.entropyManipulatorBattery;
|
||||
|
||||
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.stone, 0 ), new InWorldToolOperationResult( new ItemStack( Blocks.cobblestone ) ) );
|
||||
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.stonebrick, 0 ), new InWorldToolOperationResult( new ItemStack( Blocks.stonebrick, 1, 2 ) ) );
|
||||
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.lava, OreDictionary.WILDCARD_VALUE ), new InWorldToolOperationResult( new ItemStack( Blocks.obsidian ) ) );
|
||||
|
||||
@@ -22,8 +22,6 @@ package appeng.items.tools.powered;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -43,6 +41,8 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
@@ -83,9 +83,8 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
|
||||
public ToolMassCannon()
|
||||
{
|
||||
super( ToolMassCannon.class, Optional.<String> absent() );
|
||||
super( AEConfig.instance.matterCannonBattery, Optional.<String> absent() );
|
||||
this.setFeature( EnumSet.of( AEFeature.MatterCannon, AEFeature.PoweredTools ) );
|
||||
this.maxStoredPower = AEConfig.instance.matterCannonBattery;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -297,7 +296,10 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
Block whatsThere = w.getBlock( x, y, z );
|
||||
if ( whatsThere.isReplaceable( w, x, y, z ) && w.isAirBlock( x, y, z ) )
|
||||
{
|
||||
w.setBlock( x, y, z, AEApi.instance().blocks().blockPaint.block(), 0, 3 );
|
||||
for ( Block paintBlock : AEApi.instance().definitions().blocks().paint().maybeBlock().asSet() )
|
||||
{
|
||||
w.setBlock( x, y, z, paintBlock, 0, 3 );
|
||||
}
|
||||
}
|
||||
|
||||
TileEntity te = w.getTileEntity( x, y, z );
|
||||
|
||||
@@ -23,8 +23,6 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -34,6 +32,8 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
@@ -61,9 +61,8 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
|
||||
{
|
||||
public ToolPortableCell()
|
||||
{
|
||||
super( ToolPortableCell.class, Optional.<String> absent() );
|
||||
super( AEConfig.instance.portableCellBattery, Optional.<String> absent() );
|
||||
this.setFeature( EnumSet.of( AEFeature.PortableCell, AEFeature.StorageCells, AEFeature.PoweredTools ) );
|
||||
this.maxStoredPower = AEConfig.instance.portableCellBattery;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -22,8 +22,6 @@ package appeng.items.tools.powered;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -33,6 +31,8 @@ import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
@@ -54,9 +54,8 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
|
||||
|
||||
public ToolWirelessTerminal()
|
||||
{
|
||||
super( ToolWirelessTerminal.class, Optional.<String> absent() );
|
||||
super( AEConfig.instance.wirelessTerminalBattery, Optional.<String> absent() );
|
||||
this.setFeature( EnumSet.of( AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools ) );
|
||||
this.maxStoredPower = AEConfig.instance.wirelessTerminalBattery;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -98,7 +97,7 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
|
||||
@Override
|
||||
public boolean canHandle( ItemStack is )
|
||||
{
|
||||
return AEApi.instance().items().itemWirelessTerminal.sameAsStack( is );
|
||||
return AEApi.instance().definitions().items().wirelessTerminal().isSameAs( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,12 +22,11 @@ package appeng.items.tools.powered.powersink;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
|
||||
public class AEBasePoweredItem extends RedstoneFlux
|
||||
public abstract class AEBasePoweredItem extends RedstoneFlux
|
||||
{
|
||||
|
||||
public AEBasePoweredItem( Class c, Optional<String> subName )
|
||||
public AEBasePoweredItem( double powerCapacity, Optional<String> subName )
|
||||
{
|
||||
super( c, subName );
|
||||
super( powerCapacity, subName );
|
||||
|
||||
this.setMaxStackSize( 1 );
|
||||
}
|
||||
|
||||
@@ -22,14 +22,14 @@ package appeng.items.tools.powered.powersink;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
@@ -38,18 +38,19 @@ import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage
|
||||
public abstract class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage
|
||||
{
|
||||
private static final String POWER_NBT_KEY = "internalCurrentPower";
|
||||
private final double powerCapacity;
|
||||
|
||||
final String EnergyVar = "internalCurrentPower";
|
||||
public double maxStoredPower = 200000;
|
||||
|
||||
public AERootPoweredItem( Class c, Optional<String> subName )
|
||||
public AERootPoweredItem( double powerCapacity, Optional<String> subName )
|
||||
{
|
||||
super( c, subName );
|
||||
super( subName );
|
||||
this.setMaxDamage( 32 );
|
||||
this.hasSubtypes = false;
|
||||
this.setFull3D();
|
||||
|
||||
this.powerCapacity = powerCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,7 +149,7 @@ public class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage
|
||||
{
|
||||
NBTTagCompound data = Platform.openNbtData( is );
|
||||
|
||||
double currentStorage = data.getDouble( this.EnergyVar );
|
||||
double currentStorage = data.getDouble( this.POWER_NBT_KEY );
|
||||
double maxStorage = this.getAEMaxPower( is );
|
||||
|
||||
switch ( op )
|
||||
@@ -158,19 +159,19 @@ public class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage
|
||||
if ( currentStorage > maxStorage )
|
||||
{
|
||||
double diff = currentStorage - maxStorage;
|
||||
data.setDouble( this.EnergyVar, maxStorage );
|
||||
data.setDouble( this.POWER_NBT_KEY, maxStorage );
|
||||
return diff;
|
||||
}
|
||||
data.setDouble( this.EnergyVar, currentStorage );
|
||||
data.setDouble( this.POWER_NBT_KEY, currentStorage );
|
||||
return 0;
|
||||
case EXTRACT:
|
||||
if ( currentStorage > adjustment )
|
||||
{
|
||||
currentStorage -= adjustment;
|
||||
data.setDouble( this.EnergyVar, currentStorage );
|
||||
data.setDouble( this.POWER_NBT_KEY, currentStorage );
|
||||
return adjustment;
|
||||
}
|
||||
data.setDouble( this.EnergyVar, 0 );
|
||||
data.setDouble( this.POWER_NBT_KEY, 0 );
|
||||
return currentStorage;
|
||||
default:
|
||||
break;
|
||||
@@ -182,7 +183,7 @@ public class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage
|
||||
@Override
|
||||
public double getAEMaxPower( ItemStack is )
|
||||
{
|
||||
return this.maxStoredPower;
|
||||
return this.powerCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,12 +19,11 @@
|
||||
package appeng.items.tools.powered.powersink;
|
||||
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import ic2.api.item.IElectricItemManager;
|
||||
import ic2.api.item.ISpecialElectricItem;
|
||||
|
||||
@@ -36,12 +35,11 @@ import appeng.transformer.annotations.Integration.Method;
|
||||
|
||||
@InterfaceList( value = { @Interface( iface = "ic2.api.item.ISpecialElectricItem", iname = "IC2" ),
|
||||
@Interface( iface = "ic2.api.item.IElectricItemManager", iname = "IC2" ) } )
|
||||
public class IC2 extends AERootPoweredItem implements IElectricItemManager, ISpecialElectricItem
|
||||
public abstract class IC2 extends AERootPoweredItem implements IElectricItemManager, ISpecialElectricItem
|
||||
{
|
||||
|
||||
public IC2( Class c, Optional<String> subName )
|
||||
public IC2( double powerCapacity, Optional<String> subName )
|
||||
{
|
||||
super( c, subName );
|
||||
super( powerCapacity, subName );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,29 +19,27 @@
|
||||
package appeng.items.tools.powered.powersink;
|
||||
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.transformer.annotations.Integration.Interface;
|
||||
|
||||
|
||||
@Interface( iface = "cofh.api.energy.IEnergyContainerItem", iname = "RFItem" )
|
||||
public class RedstoneFlux extends IC2 implements IEnergyContainerItem
|
||||
public abstract class RedstoneFlux extends IC2 implements IEnergyContainerItem
|
||||
{
|
||||
|
||||
public RedstoneFlux( Class c, Optional<String> subName )
|
||||
public RedstoneFlux( double powerCapacity, Optional<String> subName )
|
||||
{
|
||||
super( c, subName );
|
||||
super( powerCapacity, subName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy( ItemStack is, int maxReceive, boolean simulate )
|
||||
{
|
||||
return maxReceive - ( int ) this.injectExternalPower( PowerUnits.RF, is, maxReceive, simulate );
|
||||
return maxReceive - (int) this.injectExternalPower( PowerUnits.RF, is, maxReceive, simulate );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,13 +51,12 @@ public class RedstoneFlux extends IC2 implements IEnergyContainerItem
|
||||
@Override
|
||||
public int getEnergyStored( ItemStack is )
|
||||
{
|
||||
return ( int ) PowerUnits.AE.convertTo( PowerUnits.RF, this.getAECurrentPower( is ) );
|
||||
return (int) PowerUnits.AE.convertTo( PowerUnits.RF, this.getAECurrentPower( is ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored( ItemStack is )
|
||||
{
|
||||
return ( int ) PowerUnits.AE.convertTo( PowerUnits.RF, this.getAEMaxPower( is ) );
|
||||
return (int) PowerUnits.AE.convertTo( PowerUnits.RF, this.getAEMaxPower( is ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user