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:
thatsIch
2015-01-03 02:53:14 +01:00
parent 3dd81433ac
commit 9986ffc458
385 changed files with 12477 additions and 8292 deletions
+28 -25
View File
@@ -18,9 +18,12 @@
package appeng.debug;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@@ -48,24 +51,16 @@ import appeng.parts.p2p.PartP2PTunnel;
import appeng.tile.networking.TileController;
import appeng.util.Platform;
public class ToolDebugCard extends AEBaseItem
{
public ToolDebugCard() {
super( ToolDebugCard.class );
public ToolDebugCard()
{
this.setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) );
}
public String timeMeasurement(long nanos)
{
long ms = nanos / 100000;
if ( nanos <= 100000 )
return nanos + "ns";
return (ms / 10.0f) + "ms";
}
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
{
if ( Platform.isClient() )
return false;
@@ -75,7 +70,7 @@ public class ToolDebugCard extends AEBaseItem
int grids = 0;
int totalNodes = 0;
for (Grid g : TickHandler.INSTANCE.getGridList())
for ( Grid g : TickHandler.INSTANCE.getGridList() )
{
grids++;
totalNodes += g.getNodes().size();
@@ -90,7 +85,7 @@ public class ToolDebugCard extends AEBaseItem
if ( te instanceof IGridHost )
{
GridNode node = (GridNode) ((IGridHost) te).getGridNode( ForgeDirection.getOrientation( side ) );
GridNode node = (GridNode) ( (IGridHost) te ).getGridNode( ForgeDirection.getOrientation( side ) );
if ( node != null )
{
Grid g = node.getInternalGrid();
@@ -103,14 +98,15 @@ public class ToolDebugCard extends AEBaseItem
{
int length = 0;
HashSet<IGridNode> next = new HashSet<IGridNode>();
Set<IGridNode> next = new HashSet<IGridNode>();
next.add( node );
int maxLength = 10000;
outer: while ( ! next.isEmpty() )
outer:
while ( !next.isEmpty() )
{
HashSet<IGridNode> current = next;
Iterable<IGridNode> current = next;
next = new HashSet<IGridNode>();
for ( IGridNode n : current )
@@ -133,15 +129,15 @@ public class ToolDebugCard extends AEBaseItem
if ( center.getMachine() instanceof PartP2PTunnel )
{
this.outputMsg( player, "Freq: " + ((PartP2PTunnel) center.getMachine()).freq );
this.outputMsg( player, "Freq: " + ( (PartP2PTunnel) center.getMachine() ).freq );
}
TickManagerCache tmc = g.getCache( ITickManager.class );
for (Class c : g.getMachineClasses())
for ( Class<? extends IGridHost> c : g.getMachineClasses() )
{
int o = 0;
long nanos = 0;
for (IGridNode oj : g.getMachines( c ))
for ( IGridNode oj : g.getMachines( c ) )
{
o++;
nanos += tmc.getAvgNanoTime( oj );
@@ -165,13 +161,13 @@ public class ToolDebugCard extends AEBaseItem
if ( te instanceof IPartHost )
{
IPart center = ((IPartHost) te).getPart( ForgeDirection.UNKNOWN );
((IPartHost) te).markForUpdate();
IPart center = ( (IPartHost) te ).getPart( ForgeDirection.UNKNOWN );
( (IPartHost) te ).markForUpdate();
if ( center != null )
{
GridNode n = (GridNode) center.getGridNode();
this.outputMsg( player, "Node Channels: " + n.usedChannels() );
for (IGridConnection gc : n.getConnections())
for ( IGridConnection gc : n.getConnections() )
{
ForgeDirection fd = gc.getDirection( n );
if ( fd != ForgeDirection.UNKNOWN )
@@ -187,7 +183,7 @@ public class ToolDebugCard extends AEBaseItem
if ( te instanceof IGridHost )
{
IGridNode node = ((IGridHost) te).getGridNode( ForgeDirection.getOrientation( side ) );
IGridNode node = ( (IGridHost) te ).getGridNode( ForgeDirection.getOrientation( side ) );
if ( node != null && node.getGrid() != null )
{
IEnergyGrid eg = node.getGrid().getCache( IEnergyGrid.class );
@@ -199,9 +195,16 @@ public class ToolDebugCard extends AEBaseItem
return true;
}
private void outputMsg(EntityPlayer player, String string)
private void outputMsg( ICommandSender player, String string )
{
player.addChatMessage( new ChatComponentText( string ) );
}
public String timeMeasurement( long nanos )
{
long ms = nanos / 100000;
if ( nanos <= 100000 )
return nanos + "ns";
return ( ms / 10.0f ) + "ms";
}
}
+23 -21
View File
@@ -18,6 +18,8 @@
package appeng.debug;
import java.util.Collection;
import java.util.EnumSet;
import java.util.LinkedList;
import java.util.List;
@@ -35,16 +37,25 @@ import appeng.core.features.AEFeature;
import appeng.items.AEBaseItem;
import appeng.util.Platform;
public class ToolEraser extends AEBaseItem
{
public ToolEraser() {
super( ToolEraser.class );
public static final int BLOCK_ERASE_LIMIT = 90000;
public ToolEraser()
{
this.setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) );
}
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
public void registerIcons( IIconRegister par1IconRegister )
{
this.itemIcon = new MissingIcon( this );
}
@Override
public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
{
if ( Platform.isClient() )
return false;
@@ -56,13 +67,12 @@ public class ToolEraser extends AEBaseItem
List<WorldCoord> next = new LinkedList<WorldCoord>();
next.add( new WorldCoord( x, y, z ) );
while (blocks < 90000 && !next.isEmpty())
while ( blocks < BLOCK_ERASE_LIMIT && !next.isEmpty() )
{
List<WorldCoord> c = next;
next = new LinkedList<WorldCoord>();
for (WorldCoord wc : c)
for ( WorldCoord wc : c )
{
Block c_blk = world.getBlock( wc.x, wc.y, wc.z );
int c_meta = world.getBlockMetadata( wc.x, wc.y, wc.z );
@@ -72,15 +82,14 @@ public class ToolEraser extends AEBaseItem
blocks++;
world.setBlock( wc.x, wc.y, wc.z, Platform.AIR );
this.check( world, wc.x + 1, wc.y, wc.z, next );
this.check( world, wc.x - 1, wc.y, wc.z, next );
this.check( world, wc.x, wc.y + 1, wc.z, next );
this.check( world, wc.x, wc.y - 1, wc.z, next );
this.check( world, wc.x, wc.y, wc.z + 1, next );
this.check( world, wc.x, wc.y, wc.z - 1, next );
this.wrappedAdd( world, wc.x + 1, wc.y, wc.z, next );
this.wrappedAdd( world, wc.x - 1, wc.y, wc.z, next );
this.wrappedAdd( world, wc.x, wc.y + 1, wc.z, next );
this.wrappedAdd( world, wc.x, wc.y - 1, wc.z, next );
this.wrappedAdd( world, wc.x, wc.y, wc.z + 1, next );
this.wrappedAdd( world, wc.x, wc.y, wc.z - 1, next );
}
}
}
AELog.info( "Delete " + blocks + " blocks" );
@@ -88,15 +97,8 @@ public class ToolEraser extends AEBaseItem
return true;
}
private void check(World world, int i, int y, int z, List<WorldCoord> next)
private void wrappedAdd( World world, int i, int y, int z, Collection<WorldCoord> next )
{
next.add( new WorldCoord( i, y, z ) );
}
@Override
public void registerIcons(IIconRegister par1IconRegister)
{
this.itemIcon = new MissingIcon( this );
}
}
@@ -18,6 +18,7 @@
package appeng.debug;
import java.util.EnumSet;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -28,37 +29,37 @@ import net.minecraft.world.World;
import appeng.client.texture.MissingIcon;
import appeng.core.features.AEFeature;
import appeng.helpers.MeteoritePlacer;
import appeng.worldgen.MeteoritePlacer;
import appeng.worldgen.meteorite.StandardWorld;
import appeng.items.AEBaseItem;
import appeng.util.Platform;
public class ToolMeteoritePlacer extends AEBaseItem
{
public ToolMeteoritePlacer() {
super( ToolMeteoritePlacer.class );
public ToolMeteoritePlacer()
{
this.setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) );
}
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
public void registerIcons( IIconRegister par1IconRegister )
{
this.itemIcon = new MissingIcon( this );
}
@Override
public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
{
if ( Platform.isClient() )
return false;
MeteoritePlacer mp = new MeteoritePlacer();
boolean worked = mp.spawnMeteorite( new MeteoritePlacer.StandardWorld( world ), x, y, z );
boolean worked = mp.spawnMeteorite( new StandardWorld( world ), x, y, z );
if ( !worked )
player.addChatMessage( new ChatComponentText( "Un-suitable Location." ) );
return true;
}
@Override
public void registerIcons(IIconRegister par1IconRegister)
{
this.itemIcon = new MissingIcon( this );
}
}
@@ -18,9 +18,11 @@
package appeng.debug;
import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -39,16 +41,16 @@ import appeng.core.features.AEFeature;
import appeng.items.AEBaseItem;
import appeng.util.Platform;
public class ToolReplicatorCard extends AEBaseItem
{
public ToolReplicatorCard() {
super( ToolReplicatorCard.class );
public ToolReplicatorCard()
{
this.setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) );
}
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
{
if ( Platform.isClient() )
return false;
@@ -114,9 +116,9 @@ public class ToolReplicatorCard extends AEBaseItem
int scale_y = max.y - min.y;
int scale_z = max.z - min.z;
for (int i = 1; i < scale_x; i++)
for (int j = 1; j < scale_y; j++)
for (int k = 1; k < scale_z; k++)
for ( int i = 1; i < scale_x; i++ )
for ( int j = 1; j < scale_y; j++ )
for ( int k = 1; k < scale_z; k++ )
{
Block blk = src_w.getBlock( min_x + i, min_y + j, min_z + k );
int meta = src_w.getBlockMetadata( min_x + i, min_y + j, min_z + k );
@@ -133,7 +135,6 @@ public class ToolReplicatorCard extends AEBaseItem
}
world.markBlockForUpdate( i + rel_x, j + rel_y, k + rel_z );
}
}
else
this.outputMsg( player, "requires valid spatial pylon setup." );
@@ -153,9 +154,8 @@ public class ToolReplicatorCard extends AEBaseItem
return true;
}
private void outputMsg(EntityPlayer player, String string)
private void outputMsg( ICommandSender player, String string )
{
player.addChatMessage( new ChatComponentText( string ) );
}
}