Added SpawnPressesInMeteorites to disable press spawns.

This commit is contained in:
AlgorithmX2
2014-08-24 01:50:22 -05:00
parent 4b83c804cf
commit 6619bfce38
2 changed files with 77 additions and 72 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ public enum AEFeature
CertusQuartzWorldGen("World"), MeteoriteWorldGen("World"), CertusQuartzWorldGen("World"), MeteoriteWorldGen("World"),
DecorativeLights("World"), DecorativeQuartzBlocks("World"), SkyStoneChests("World"), DecorativeLights("World"), DecorativeQuartzBlocks("World"), SkyStoneChests("World"), SpawnPressesInMeteorites("World"),
GrindStone("World"), Flour("World"), Inscriber("World"), GrindStone("World"), Flour("World"), Inscriber("World"),
+76 -71
View File
@@ -18,7 +18,9 @@ import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.core.AEConfig;
import appeng.core.WorldSettings; import appeng.core.WorldSettings;
import appeng.core.features.AEFeature;
import appeng.util.InventoryAdaptor; import appeng.util.InventoryAdaptor;
import appeng.util.Platform; import appeng.util.Platform;
@@ -626,91 +628,94 @@ public class MeteoritePlacer
put( w, i, j, k, skystone ); put( w, i, j, k, skystone );
} }
put( w, x, y, z, skychest ); if ( AEConfig.instance.isFeatureEnabled( AEFeature.SpawnPressesInMeteorites ) )
TileEntity te = w.getTileEntity( x, y, z );
if ( te != null && te instanceof IInventory )
{ {
InventoryAdaptor ap = InventoryAdaptor.getAdaptor( te, ForgeDirection.UP ); put( w, x, y, z, skychest );
TileEntity te = w.getTileEntity( x, y, z );
int primary = Math.max( 1, (int) (Math.random() * 4) ); if ( te != null && te instanceof IInventory )
if ( primary > 3 ) // in case math breaks...
primary = 3;
for (int zz = 0; zz < primary; zz++)
{ {
int r = 0; InventoryAdaptor ap = InventoryAdaptor.getAdaptor( te, ForgeDirection.UP );
boolean duplicate = false;
do int primary = Math.max( 1, (int) (Math.random() * 4) );
if ( primary > 3 ) // in case math breaks...
primary = 3;
for (int zz = 0; zz < primary; zz++)
{ {
duplicate = false; int r = 0;
boolean duplicate = false;
if ( Math.random() > 0.7 ) do
r = WorldSettings.getInstance().getNextOrderedValue( "presses" ); {
else duplicate = false;
r = (int) (Math.random() * 1000);
ItemStack toAdd = null; if ( Math.random() > 0.7 )
r = WorldSettings.getInstance().getNextOrderedValue( "presses" );
else
r = (int) (Math.random() * 1000);
switch (r % 4) ItemStack toAdd = null;
switch (r % 4)
{
case 0:
toAdd = AEApi.instance().materials().materialCalcProcessorPress.stack( 1 );
break;
case 1:
toAdd = AEApi.instance().materials().materialEngProcessorPress.stack( 1 );
break;
case 2:
toAdd = AEApi.instance().materials().materialLogicProcessorPress.stack( 1 );
break;
case 3:
toAdd = AEApi.instance().materials().materialSiliconPress.stack( 1 );
break;
default:
}
if ( toAdd != null )
{
if ( ap.simulateRemove( 1, toAdd, null ) == null )
ap.addItems( toAdd );
else
duplicate = true;
}
}
while (duplicate);
}
int secondary = Math.max( 1, (int) (Math.random() * 3) );
for (int zz = 0; zz < secondary; zz++)
{
switch ((int) (Math.random() * 1000) % 3)
{ {
case 0: case 0:
toAdd = AEApi.instance().materials().materialCalcProcessorPress.stack( 1 ); ap.addItems( AEApi.instance().blocks().blockSkyStone.stack( (int) (Math.random() * 12) + 1 ) );
break; break;
case 1: case 1:
toAdd = AEApi.instance().materials().materialEngProcessorPress.stack( 1 ); List<ItemStack> possibles = new LinkedList();
break; possibles.addAll( OreDictionary.getOres( "nuggetIron" ) );
case 2: possibles.addAll( OreDictionary.getOres( "nuggetCopper" ) );
toAdd = AEApi.instance().materials().materialLogicProcessorPress.stack( 1 ); possibles.addAll( OreDictionary.getOres( "nuggetTin" ) );
break; possibles.addAll( OreDictionary.getOres( "nuggetSilver" ) );
case 3: possibles.addAll( OreDictionary.getOres( "nuggetLead" ) );
toAdd = AEApi.instance().materials().materialSiliconPress.stack( 1 ); possibles.addAll( OreDictionary.getOres( "nuggetPlatinum" ) );
break; possibles.addAll( OreDictionary.getOres( "nuggetNickel" ) );
default: possibles.addAll( OreDictionary.getOres( "nuggetAluminium" ) );
} possibles.addAll( OreDictionary.getOres( "nuggetElectrum" ) );
possibles.add( new ItemStack( net.minecraft.init.Items.gold_nugget ) );
if ( toAdd != null ) ItemStack nugget = Platform.pickRandom( possibles );
{ if ( nugget != null )
if ( ap.simulateRemove( 1, toAdd, null ) == null ) {
ap.addItems( toAdd ); nugget = nugget.copy();
else nugget.stackSize = (int) (Math.random() * 12) + 1;
duplicate = true; ap.addItems( nugget );
}
break;
} }
} }
while (duplicate);
}
int secondary = Math.max( 1, (int) (Math.random() * 3) );
for (int zz = 0; zz < secondary; zz++)
{
switch ((int) (Math.random() * 1000) % 3)
{
case 0:
ap.addItems( AEApi.instance().blocks().blockSkyStone.stack( (int) (Math.random() * 12) + 1 ) );
break;
case 1:
List<ItemStack> possibles = new LinkedList();
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 ) );
ItemStack nugget = Platform.pickRandom( possibles );
if ( nugget != null )
{
nugget = nugget.copy();
nugget.stackSize = (int) (Math.random() * 12) + 1;
ap.addItems( nugget );
}
break;
}
} }
} }
} }