No more duplicate patterns in meteorites.

This commit is contained in:
AlgorithmX2 2014-06-05 23:51:37 -05:00
parent 1ab7f7c110
commit 6646f7c7f0

View file

@ -325,31 +325,52 @@ public class MeteoritePlacer
InventoryAdaptor ap = InventoryAdaptor.getAdaptor( te, ForgeDirection.UP ); InventoryAdaptor ap = InventoryAdaptor.getAdaptor( te, ForgeDirection.UP );
int primary = Math.max( 1, (int) (Math.random() * 4) ); 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++) for (int zz = 0; zz < primary; zz++)
{ {
int r = 0; int r = 0;
boolean duplicate = false;
if ( Math.random() > 0.7 ) do
r = WorldSettings.getInstance().getNextOrderedValue( "presses" );
else
r = (int) (Math.random() * 1000);
switch (r % 4)
{ {
case 0: duplicate = false;
ap.addItems( AEApi.instance().materials().materialCalcProcessorPress.stack( 1 ) );
break; if ( Math.random() > 0.7 )
case 1: r = WorldSettings.getInstance().getNextOrderedValue( "presses" );
ap.addItems( AEApi.instance().materials().materialEngProcessorPress.stack( 1 ) ); else
break; r = (int) (Math.random() * 1000);
case 2:
ap.addItems( AEApi.instance().materials().materialLogicProcessorPress.stack( 1 ) ); ItemStack toAdd = null;
break;
case 3: switch (r % 4)
ap.addItems( AEApi.instance().materials().materialSiliconPress.stack( 1 ) ); {
break; case 0:
default: 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) ); int secondary = Math.max( 1, (int) (Math.random() * 3) );