1.15 port
This commit is contained in:
@@ -25,17 +25,16 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
@@ -67,7 +66,7 @@ public final class MeteoritePlacer
|
||||
private double realCrater = this.meteoriteSize * 2 + 5;
|
||||
private double squaredMeteoriteSize = this.meteoriteSize * this.meteoriteSize;
|
||||
private double crater = this.realCrater * this.realCrater;
|
||||
private NBTTagCompound settings;
|
||||
private CompoundNBT settings;
|
||||
private Fallout type;
|
||||
|
||||
public MeteoritePlacer()
|
||||
@@ -88,13 +87,10 @@ public final class MeteoritePlacer
|
||||
this.validSpawn.add( Blocks.GOLD_ORE );
|
||||
this.validSpawn.add( Blocks.DIAMOND_ORE );
|
||||
this.validSpawn.add( Blocks.REDSTONE_ORE );
|
||||
this.validSpawn.add( Blocks.HARDENED_CLAY );
|
||||
this.validSpawn.add( Blocks.ICE );
|
||||
this.validSpawn.add( Blocks.SNOW );
|
||||
this.validSpawn.add( Blocks.STAINED_HARDENED_CLAY );
|
||||
|
||||
this.skyStoneDefinition.maybeBlock().ifPresent( this.invalidSpawn::add );
|
||||
this.invalidSpawn.add( Blocks.PLANKS );
|
||||
this.invalidSpawn.add( Blocks.IRON_DOOR );
|
||||
this.invalidSpawn.add( Blocks.IRON_BARS );
|
||||
this.invalidSpawn.add( Blocks.OAK_DOOR );
|
||||
@@ -104,29 +100,27 @@ public final class MeteoritePlacer
|
||||
this.invalidSpawn.add( Blocks.IRON_DOOR );
|
||||
this.invalidSpawn.add( Blocks.JUNGLE_DOOR );
|
||||
this.invalidSpawn.add( Blocks.SPRUCE_DOOR );
|
||||
this.invalidSpawn.add( Blocks.BRICK_BLOCK );
|
||||
this.invalidSpawn.add( Blocks.BRICKS );
|
||||
this.invalidSpawn.add( Blocks.CLAY );
|
||||
this.invalidSpawn.add( Blocks.WATER );
|
||||
this.invalidSpawn.add( Blocks.LOG );
|
||||
this.invalidSpawn.add( Blocks.LOG2 );
|
||||
|
||||
this.type = new Fallout( this.putter, this.skyStoneDefinition );
|
||||
}
|
||||
|
||||
boolean spawnMeteorite( final IMeteoriteWorld w, final NBTTagCompound meteoriteBlob )
|
||||
boolean spawnMeteorite( final IMeteoriteWorld w, final CompoundNBT meteoriteBlob )
|
||||
{
|
||||
this.settings = meteoriteBlob;
|
||||
|
||||
final int x = this.settings.getInteger( "x" );
|
||||
final int y = this.settings.getInteger( "y" );
|
||||
final int z = this.settings.getInteger( "z" );
|
||||
final int x = this.settings.getInt( "x" );
|
||||
final int y = this.settings.getInt( "y" );
|
||||
final int z = this.settings.getInt( "z" );
|
||||
|
||||
this.meteoriteSize = this.settings.getDouble( "real_sizeOfMeteorite" );
|
||||
this.realCrater = this.settings.getDouble( "realCrater" );
|
||||
this.squaredMeteoriteSize = this.settings.getDouble( "sizeOfMeteorite" );
|
||||
this.crater = this.settings.getDouble( "crater" );
|
||||
|
||||
final Block blk = Block.getBlockById( this.settings.getInteger( "blk" ) );
|
||||
final Block blk = Block.getBlockById( this.settings.getInt( "blk" ) );
|
||||
|
||||
if( blk == Blocks.SAND )
|
||||
{
|
||||
@@ -141,7 +135,7 @@ public final class MeteoritePlacer
|
||||
this.type = new FalloutSnow( w, x, y, z, this.putter, this.skyStoneDefinition );
|
||||
}
|
||||
|
||||
final int skyMode = this.settings.getInteger( "skyMode" );
|
||||
final int skyMode = this.settings.getInt( "skyMode" );
|
||||
|
||||
// creator
|
||||
if( skyMode > 10 )
|
||||
@@ -204,11 +198,11 @@ public final class MeteoritePlacer
|
||||
}
|
||||
|
||||
for( final Object o : w.getWorld()
|
||||
.getEntitiesWithinAABB( EntityItem.class,
|
||||
.getEntitiesWithinAABB( ItemEntity.class,
|
||||
new AxisAlignedBB( w.minX( x - 30 ), y - 5, w.minZ( z - 30 ), w.maxX( x + 30 ), y + 30, w.maxZ( z + 30 ) ) ) )
|
||||
{
|
||||
final Entity e = (Entity) o;
|
||||
e.setDead();
|
||||
e.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +217,7 @@ public final class MeteoritePlacer
|
||||
this.skyChestDefinition.maybeBlock().ifPresent( block -> this.putter.put( w, x, y, z, block ) );
|
||||
|
||||
final TileEntity te = w.getTileEntity( x, y, z );
|
||||
final InventoryAdaptor ap = InventoryAdaptor.getAdaptor( te, EnumFacing.UP );
|
||||
final InventoryAdaptor ap = InventoryAdaptor.getAdaptor( te, Direction.UP );
|
||||
if( ap != null )
|
||||
{
|
||||
int primary = Math.max( 1, (int) ( Math.random() * 4 ) );
|
||||
@@ -297,16 +291,7 @@ public final class MeteoritePlacer
|
||||
break;
|
||||
case 1:
|
||||
final List<ItemStack> possibles = new ArrayList<>();
|
||||
possibles.addAll( OreDictionary.getOres( "nuggetIron" ) );
|
||||
possibles.addAll( OreDictionary.getOres( "nuggetCopper" ) );
|
||||
possibles.addAll( OreDictionary.getOres( "nuggetTin" ) );
|
||||
possibles.addAll( OreDictionary.getOres( "nuggetSilver" ) );
|
||||
possibles.addAll( OreDictionary.getOres( "nuggetLead" ) );
|
||||
possibles.addAll( OreDictionary.getOres( "nuggetPlatinum" ) );
|
||||
possibles.addAll( OreDictionary.getOres( "nuggetNickel" ) );
|
||||
possibles.addAll( OreDictionary.getOres( "nuggetAluminium" ) );
|
||||
possibles.addAll( OreDictionary.getOres( "nuggetElectrum" ) );
|
||||
possibles.add( new ItemStack( net.minecraft.init.Items.GOLD_NUGGET ) );
|
||||
possibles.add( new ItemStack( net.minecraft.item.Items.GOLD_NUGGET ) );
|
||||
|
||||
ItemStack nugget = Platform.pickRandom( possibles );
|
||||
if( !nugget.isEmpty() )
|
||||
@@ -376,7 +361,7 @@ public final class MeteoritePlacer
|
||||
|
||||
if( blk_b != blk )
|
||||
{
|
||||
final IBlockState meta_b = w.getBlockState( i, j + 1, k );
|
||||
final BlockState meta_b = w.getBlockState( i, j + 1, k );
|
||||
|
||||
w.setBlock( i, j, k, meta_b, 3 );
|
||||
}
|
||||
@@ -427,8 +412,8 @@ public final class MeteoritePlacer
|
||||
|
||||
double getSqDistance( final int x, final int z )
|
||||
{
|
||||
final int chunkX = this.settings.getInteger( "x" ) - x;
|
||||
final int chunkZ = this.settings.getInteger( "z" ) - z;
|
||||
final int chunkX = this.settings.getInt( "x" ) - x;
|
||||
final int chunkZ = this.settings.getInt( "z" ) - z;
|
||||
|
||||
return chunkX * chunkX + chunkZ * chunkZ;
|
||||
}
|
||||
@@ -447,24 +432,24 @@ public final class MeteoritePlacer
|
||||
return false; // must spawn on a valid block..
|
||||
}
|
||||
|
||||
this.settings = new NBTTagCompound();
|
||||
this.settings.setInteger( "x", x );
|
||||
this.settings.setInteger( "y", y );
|
||||
this.settings.setInteger( "z", z );
|
||||
this.settings.setInteger( "blk", Block.getIdFromBlock( blk ) );
|
||||
this.settings = new CompoundNBT();
|
||||
this.settings.putInt( "x", x );
|
||||
this.settings.putInt( "y", y );
|
||||
this.settings.putInt( "z", z );
|
||||
this.settings.putString( "blk", blk.getRegistryName().toString() );
|
||||
|
||||
this.settings.setDouble( "real_sizeOfMeteorite", this.meteoriteSize );
|
||||
this.settings.setDouble( "realCrater", this.realCrater );
|
||||
this.settings.setDouble( "sizeOfMeteorite", this.squaredMeteoriteSize );
|
||||
this.settings.setDouble( "crater", this.crater );
|
||||
this.settings.putDouble( "real_sizeOfMeteorite", this.meteoriteSize );
|
||||
this.settings.putDouble( "realCrater", this.realCrater );
|
||||
this.settings.putDouble( "sizeOfMeteorite", this.squaredMeteoriteSize );
|
||||
this.settings.putDouble( "crater", this.crater );
|
||||
|
||||
this.settings.setBoolean( "lava", Math.random() > 0.9 );
|
||||
this.settings.putBoolean( "lava", Math.random() > 0.9 );
|
||||
|
||||
if( blk == Blocks.SAND )
|
||||
{
|
||||
this.type = new FalloutSand( w, x, y, z, this.putter, this.skyStoneDefinition );
|
||||
}
|
||||
else if( blk == Blocks.HARDENED_CLAY )
|
||||
else if( blk == Blocks.TERRACOTTA )
|
||||
{
|
||||
this.type = new FalloutCopy( w, x, y, z, this.putter, this.skyStoneDefinition );
|
||||
}
|
||||
@@ -559,16 +544,16 @@ public final class MeteoritePlacer
|
||||
this.decay( w, x, y, z );
|
||||
}
|
||||
|
||||
this.settings.setInteger( "skyMode", skyMode );
|
||||
this.settings.putInt( "skyMode", skyMode );
|
||||
w.done();
|
||||
|
||||
WorldData.instance().spawnData().addNearByMeteorites( w.getWorld().provider.getDimension(), x >> 4, z >> 4, this.settings );
|
||||
WorldData.instance().spawnData().addNearByMeteorites( w.getWorld().getDimension(), x >> 4, z >> 4, this.settings );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
NBTTagCompound getSettings()
|
||||
CompoundNBT getSettings()
|
||||
{
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ package appeng.worldgen;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.IChunkGenerator;
|
||||
@@ -100,7 +100,7 @@ public final class MeteoriteWorldGen implements IWorldGenerator
|
||||
return false;
|
||||
}
|
||||
|
||||
private Iterable<NBTTagCompound> getNearByMeteorites( final World w, final int chunkX, final int chunkZ )
|
||||
private Iterable<CompoundNBT> getNearByMeteorites( final World w, final int chunkX, final int chunkZ )
|
||||
{
|
||||
return WorldData.instance().spawnData().getNearByMeteorites( w.provider.getDimension(), chunkX, chunkZ );
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public final class MeteoriteWorldGen implements IWorldGenerator
|
||||
double minSqDist = Double.MAX_VALUE;
|
||||
|
||||
// near by meteorites!
|
||||
for( final NBTTagCompound data : MeteoriteWorldGen.this.getNearByMeteorites( world, chunkX, chunkZ ) )
|
||||
for( final CompoundNBT data : MeteoriteWorldGen.this.getNearByMeteorites( world, chunkX, chunkZ ) )
|
||||
{
|
||||
final MeteoritePlacer mp = new MeteoritePlacer();
|
||||
mp.spawnMeteorite( new ChunkOnly( world, chunkX, chunkZ ), data );
|
||||
|
||||
@@ -20,7 +20,7 @@ package appeng.worldgen.meteorite;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
@@ -89,7 +89,7 @@ public class ChunkOnly extends StandardWorld
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock( final int x, final int y, final int z, final IBlockState state, final int flags )
|
||||
public void setBlock( final int x, final int y, final int z, final BlockState state, final int flags )
|
||||
{
|
||||
if( this.range( x, y, z ) )
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
package appeng.worldgen.meteorite;
|
||||
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.block.Blocks;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.util.Platform;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
package appeng.worldgen.meteorite;
|
||||
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.util.Platform;
|
||||
@@ -31,7 +31,7 @@ public class FalloutCopy extends Fallout
|
||||
private static final double AIR_BLOCK_THRESHOLD = 0.8;
|
||||
private static final double BLOCK_THRESHOLD_STEP = 0.1;
|
||||
|
||||
private final IBlockState block;
|
||||
private final BlockState block;
|
||||
private final MeteoriteBlockPutter putter;
|
||||
|
||||
public FalloutCopy( final IMeteoriteWorld w, final int x, final int y, final int z, final MeteoriteBlockPutter putter, final IBlockDefinition skyStoneDefinition )
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
package appeng.worldgen.meteorite;
|
||||
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.block.Blocks;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
package appeng.worldgen.meteorite;
|
||||
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.block.Blocks;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ package appeng.worldgen.meteorite;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -47,9 +47,9 @@ public interface IMeteoriteWorld
|
||||
|
||||
void setBlock( int i, int j, int k, Block blk );
|
||||
|
||||
void setBlock( int i, int j, int k, IBlockState state, int l );
|
||||
void setBlock( int i, int j, int k, BlockState state, int l );
|
||||
|
||||
void done();
|
||||
|
||||
IBlockState getBlockState( int x, int y, int z );
|
||||
BlockState getBlockState( int x, int y, int z );
|
||||
}
|
||||
@@ -20,8 +20,8 @@ package appeng.worldgen.meteorite;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
|
||||
|
||||
public class MeteoriteBlockPutter
|
||||
@@ -39,7 +39,7 @@ public class MeteoriteBlockPutter
|
||||
return true;
|
||||
}
|
||||
|
||||
void put( final IMeteoriteWorld w, final int i, final int j, final int k, final IBlockState state, final int meta )
|
||||
void put( final IMeteoriteWorld w, final int i, final int j, final int k, final BlockState state, final int meta )
|
||||
{
|
||||
if( w.getBlock( i, j, k ) == Blocks.BEDROCK )
|
||||
{
|
||||
|
||||
@@ -20,8 +20,8 @@ package appeng.worldgen.meteorite;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -126,7 +126,7 @@ public class StandardWorld implements IMeteoriteWorld
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock( final int x, final int y, final int z, final IBlockState state, final int l )
|
||||
public void setBlock( final int x, final int y, final int z, final BlockState state, final int l )
|
||||
{
|
||||
if( this.range( x, y, z ) )
|
||||
{
|
||||
@@ -135,7 +135,7 @@ public class StandardWorld implements IMeteoriteWorld
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getBlockState( final int x, final int y, final int z )
|
||||
public BlockState getBlockState( final int x, final int y, final int z )
|
||||
{
|
||||
if( this.range( x, y, z ) )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user