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
@@ -0,0 +1,98 @@
package appeng.worldgen.meteorite;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import appeng.util.Platform;
public class ChunkOnly extends StandardWorld
{
final Chunk target;
final int cx, cz;
int verticalBits = 0;
public ChunkOnly( World w, int cx, int cz )
{
super( w );
this.target = w.getChunkFromChunkCoords( cx, cz );
this.cx = cx;
this.cz = cz;
}
@Override
public int minX( int in )
{
return Math.max( in, this.cx << 4 );
}
@Override
public int minZ( int in )
{
return Math.max( in, this.cz << 4 );
}
@Override
public int maxX( int in )
{
return Math.min( in, ( this.cx + 1 ) << 4 );
}
@Override
public int maxZ( int in )
{
return Math.min( in, ( this.cz + 1 ) << 4 );
}
@Override
public int getBlockMetadata( int x, int y, int z )
{
if ( this.range( x, y, z ) )
return this.target.getBlockMetadata( x & 0xF, y, z & 0xF );
return 0;
}
@Override
public Block getBlock( int x, int y, int z )
{
if ( this.range( x, y, z ) )
return this.target.getBlock( x & 0xF, y, z & 0xF );
return Platform.AIR;
}
@Override
public void setBlock( int x, int y, int z, Block blk )
{
if ( this.range( x, y, z ) )
{
this.verticalBits |= 1 << ( y >> 4 );
this.w.setBlock( x, y, z, blk, 0, 1 );
}
}
@Override
public void setBlock( int x, int y, int z, Block blk, int metadata, int flags )
{
if ( this.range( x, y, z ) )
{
this.verticalBits |= 1 << ( y >> 4 );
this.w.setBlock( x, y, z, blk, metadata, flags & ( ~2 ) );
}
}
@Override
public void done()
{
if ( this.verticalBits != 0 )
Platform.sendChunk( this.target, this.verticalBits );
}
@Override
public boolean range( int x, int y, int z )
{
return this.cx == ( x >> 4 ) && this.cz == ( z >> 4 );
}
}
@@ -0,0 +1,61 @@
package appeng.worldgen.meteorite;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import appeng.api.definitions.IBlockDefinition;
import appeng.util.Platform;
public class Fallout
{
private final MeteoriteBlockPutter putter;
private final IBlockDefinition skyStoneDefinition;
public Fallout( MeteoriteBlockPutter putter, IBlockDefinition skyStoneDefinition )
{
this.putter = putter;
this.skyStoneDefinition = skyStoneDefinition;
}
public int adjustCrater()
{
return 0;
}
public void getRandomFall( IMeteoriteWorld w, int x, int y, int z )
{
double a = Math.random();
if ( a > 0.9 )
this.putter.put( w, x, y, z, Blocks.stone );
else if ( a > 0.8 )
this.putter.put( w, x, y, z, Blocks.cobblestone );
else if ( a > 0.7 )
this.putter.put( w, x, y, z, Blocks.dirt );
else
this.putter.put( w, x, y, z, Blocks.gravel );
}
public void getRandomInset( IMeteoriteWorld w, int x, int y, int z )
{
double a = Math.random();
if ( a > 0.9 )
this.putter.put( w, x, y, z, Blocks.cobblestone );
else if ( a > 0.8 )
this.putter.put( w, x, y, z, Blocks.stone );
else if ( a > 0.7 )
this.putter.put( w, x, y, z, Blocks.grass );
else if ( a > 0.6 )
{
for ( Block skyStoneBlock : this.skyStoneDefinition.maybeBlock().asSet() )
{
this.putter.put( w, x, y, z, skyStoneBlock );
}
}
else if ( a > 0.5 )
this.putter.put( w, x, y, z, Blocks.gravel );
else
this.putter.put( w, x, y, z, Platform.AIR );
}
}
@@ -0,0 +1,64 @@
package appeng.worldgen.meteorite;
import net.minecraft.block.Block;
import appeng.api.definitions.IBlockDefinition;
import appeng.util.Platform;
public class FalloutCopy extends Fallout
{
public static final double SPECIFIED_BLOCK_THRESHOLD = 0.9;
public static final double AIR_BLOCK_THRESHOLD = 0.8;
public static final double BLOCK_THRESHOLD_STEP = 0.1;
private final Block block;
private final int meta;
private final MeteoriteBlockPutter putter;
public FalloutCopy( IMeteoriteWorld w, int x, int y, int z, MeteoriteBlockPutter putter, IBlockDefinition skyStoneDefinition )
{
super( putter, skyStoneDefinition );
this.putter = putter;
this.block = w.getBlock( x, y, z );
this.meta = w.getBlockMetadata( x, y, z );
}
@Override
public void getRandomFall( IMeteoriteWorld w, int x, int y, int z )
{
double a = Math.random();
if ( a > SPECIFIED_BLOCK_THRESHOLD )
{
this.putter.put( w, x, y, z, this.block, this.meta );
}
else
{
this.getOther( w, x, y, z, a );
}
}
public void getOther( IMeteoriteWorld w, int x, int y, int z, double a )
{
}
@Override
public void getRandomInset( IMeteoriteWorld w, int x, int y, int z )
{
double a = Math.random();
if ( a > SPECIFIED_BLOCK_THRESHOLD )
{
this.putter.put( w, x, y, z, this.block, this.meta );
}
else if ( a > AIR_BLOCK_THRESHOLD )
{
this.putter.put( w, x, y, z, Platform.AIR );
}
else
{
this.getOther( w, x, y, z, a - BLOCK_THRESHOLD_STEP );
}
}
}
@@ -0,0 +1,32 @@
package appeng.worldgen.meteorite;
import net.minecraft.init.Blocks;
import appeng.api.definitions.IBlockDefinition;
public class FalloutSand extends FalloutCopy
{
public static final double GLASS_THRESHOLD = 0.66;
private final MeteoriteBlockPutter putter;
public FalloutSand( IMeteoriteWorld w, int x, int y, int z, MeteoriteBlockPutter putter, IBlockDefinition skyStoneDefinition )
{
super( w, x, y, z, putter, skyStoneDefinition );
this.putter = putter;
}
@Override
public int adjustCrater()
{
return 2;
}
@Override
public void getOther( IMeteoriteWorld w, int x, int y, int z, double a )
{
if ( a > GLASS_THRESHOLD )
this.putter.put( w, x, y, z, Blocks.glass );
}
}
@@ -0,0 +1,39 @@
package appeng.worldgen.meteorite;
import net.minecraft.init.Blocks;
import appeng.api.definitions.IBlockDefinition;
public class FalloutSnow extends FalloutCopy
{
public static final double SNOW_THRESHOLD = 0.7;
public static final double ICE_THRESHOLD = 0.5;
private final MeteoriteBlockPutter putter;
public FalloutSnow( IMeteoriteWorld w, int x, int y, int z, MeteoriteBlockPutter putter, IBlockDefinition skyStoneDefinition )
{
super( w, x, y, z, putter, skyStoneDefinition );
this.putter = putter;
}
@Override
public int adjustCrater()
{
return 2;
}
@Override
public void getOther( IMeteoriteWorld w, int x, int y, int z, double a )
{
if ( a > SNOW_THRESHOLD )
{
this.putter.put( w, x, y, z, Blocks.snow );
}
else if ( a > ICE_THRESHOLD )
{
this.putter.put( w, x, y, z, Blocks.ice );
}
}
}
@@ -0,0 +1,36 @@
package appeng.worldgen.meteorite;
import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public interface IMeteoriteWorld
{
int minX( int in );
int minZ( int in );
int maxX( int in );
int maxZ( int in );
boolean hasNoSky();
int getBlockMetadata( int x, int y, int z );
Block getBlock( int x, int y, int z );
boolean canBlockSeeTheSky( int i, int j, int k );
TileEntity getTileEntity( int x, int y, int z );
World getWorld();
void setBlock( int i, int j, int k, Block blk );
void setBlock( int i, int j, int k, Block blk_b, int meta_b, int l );
void done();
}
@@ -0,0 +1,30 @@
package appeng.worldgen.meteorite;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
public class MeteoriteBlockPutter
{
public boolean put( IMeteoriteWorld w, int i, int j, int k, Block blk )
{
Block original = w.getBlock( i, j, k );
if ( original == Blocks.bedrock || original == blk )
return false;
w.setBlock( i, j, k, blk );
return true;
}
public void put( IMeteoriteWorld w, int i, int j, int k, Block blk, int meta )
{
if ( w.getBlock( i, j, k ) == Blocks.bedrock )
{
return;
}
w.setBlock( i, j, k, blk, meta, 3 );
}
}
@@ -0,0 +1,113 @@
package appeng.worldgen.meteorite;
import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import appeng.util.Platform;
public class StandardWorld implements IMeteoriteWorld
{
protected final World w;
public StandardWorld( World w )
{
this.w = w;
}
@Override
public int minX( int in )
{
return in;
}
@Override
public int minZ( int in )
{
return in;
}
@Override
public int maxX( int in )
{
return in;
}
@Override
public int maxZ( int in )
{
return in;
}
@Override
public boolean hasNoSky()
{
return !this.w.provider.hasNoSky;
}
@Override
public int getBlockMetadata( int x, int y, int z )
{
if ( this.range( x, y, z ) )
return this.w.getBlockMetadata( x, y, z );
return 0;
}
@Override
public Block getBlock( int x, int y, int z )
{
if ( this.range( x, y, z ) )
return this.w.getBlock( x, y, z );
return Platform.AIR;
}
@Override
public boolean canBlockSeeTheSky( int x, int y, int z )
{
if ( this.range( x, y, z ) )
return this.w.canBlockSeeTheSky( x, y, z );
return false;
}
@Override
public TileEntity getTileEntity( int x, int y, int z )
{
if ( this.range( x, y, z ) )
return this.w.getTileEntity( x, y, z );
return null;
}
@Override
public World getWorld()
{
return this.w;
}
@Override
public void setBlock( int x, int y, int z, Block blk )
{
if ( this.range( x, y, z ) )
this.w.setBlock( x, y, z, blk );
}
@Override
public void setBlock( int x, int y, int z, Block blk, int metadata, int flags )
{
if ( this.range( x, y, z ) )
this.w.setBlock( x, y, z, blk, metadata, flags );
}
@Override
public void done()
{
}
public boolean range( int x, int y, int z )
{
return true;
}
}