No more duplicate patterns in meteorites.

This commit is contained in:
AlgorithmX2
2014-06-05 23:51:37 -05:00
parent 1ab7f7c110
commit 6646f7c7f0
+25 -4
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;
do
{
duplicate = false;
if ( Math.random() > 0.7 ) if ( Math.random() > 0.7 )
r = WorldSettings.getInstance().getNextOrderedValue( "presses" ); r = WorldSettings.getInstance().getNextOrderedValue( "presses" );
else else
r = (int) (Math.random() * 1000); r = (int) (Math.random() * 1000);
ItemStack toAdd = null;
switch (r % 4) switch (r % 4)
{ {
case 0: case 0:
ap.addItems( AEApi.instance().materials().materialCalcProcessorPress.stack( 1 ) ); toAdd = AEApi.instance().materials().materialCalcProcessorPress.stack( 1 );
break; break;
case 1: case 1:
ap.addItems( AEApi.instance().materials().materialEngProcessorPress.stack( 1 ) ); toAdd = AEApi.instance().materials().materialEngProcessorPress.stack( 1 );
break; break;
case 2: case 2:
ap.addItems( AEApi.instance().materials().materialLogicProcessorPress.stack( 1 ) ); toAdd = AEApi.instance().materials().materialLogicProcessorPress.stack( 1 );
break; break;
case 3: case 3:
ap.addItems( AEApi.instance().materials().materialSiliconPress.stack( 1 ) ); toAdd = AEApi.instance().materials().materialSiliconPress.stack( 1 );
break; break;
default: 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) );