From 6beaa85da68e21c9f7cad2d83bf5b4688f8ff90d Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 8 Mar 2014 17:31:09 -0600 Subject: [PATCH] Website Name Fix. Meteorite Spawns tweaked and chest contents tweaked. Catch Dimension Registration. --- .../packets/PacketNewStorageDimension.java | 9 ++- helpers/MeteoritePlacer.java | 67 ++++++++++++------- hooks/MeteoriteWorldGen.java | 2 +- recipes/RecipeHandler.java | 9 ++- 4 files changed, 57 insertions(+), 30 deletions(-) diff --git a/core/sync/packets/PacketNewStorageDimension.java b/core/sync/packets/PacketNewStorageDimension.java index e504d3449..6ae7f7a94 100644 --- a/core/sync/packets/PacketNewStorageDimension.java +++ b/core/sync/packets/PacketNewStorageDimension.java @@ -27,7 +27,14 @@ public class PacketNewStorageDimension extends AppEngPacket @SideOnly(Side.CLIENT) public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player) { - DimensionManager.registerDimension( newDim, AEConfig.instance.storageProviderID ); + try + { + DimensionManager.registerDimension( newDim, AEConfig.instance.storageProviderID ); + } + catch (IllegalArgumentException iae) + { + // ok! + } } // api diff --git a/helpers/MeteoritePlacer.java b/helpers/MeteoritePlacer.java index a690b8f76..237720e09 100644 --- a/helpers/MeteoritePlacer.java +++ b/helpers/MeteoritePlacer.java @@ -11,7 +11,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import appeng.api.AEApi; +import appeng.util.InventoryAdaptor; import appeng.util.Platform; public class MeteoritePlacer @@ -143,7 +145,7 @@ public class MeteoritePlacer Fallout type = new Fallout(); Block skystone = AEApi.instance().blocks().blockSkyStone.block(); - Block skychest = AEApi.instance().blocks().blockSkyChest.block(); + Block skychest; double real_sizeOfMetorite = (Math.random() * 6.0) + 2; double real_crator = real_sizeOfMetorite * 2 + 5; @@ -153,6 +155,11 @@ public class MeteoritePlacer public MeteoritePlacer() { + if ( AEApi.instance().blocks().blockSkyChest.block() == null ) + skychest = Blocks.chest; + else + skychest = AEApi.instance().blocks().blockSkyChest.block(); + validSpawn.add( Blocks.stone ); validSpawn.add( Blocks.cobblestone ); validSpawn.add( Blocks.grass ); @@ -311,34 +318,44 @@ public class MeteoritePlacer TileEntity te = w.getTileEntity( x, y, z ); if ( te instanceof IInventory ) { - switch ((int) (Math.random() * 1000) % 4) + InventoryAdaptor ap = InventoryAdaptor.getAdaptor( te, ForgeDirection.UP ); + + int primary = (int) (Math.random() * 4); + for (int zz = 0; zz < primary; zz++) { - case 0: - ((IInventory) te).setInventorySlotContents( 0, AEApi.instance().materials().materialCalcProcessorPress.stack( 1 ) ); - break; - case 1: - ((IInventory) te).setInventorySlotContents( 0, AEApi.instance().materials().materialEngProcessorPress.stack( 1 ) ); - break; - case 2: - ((IInventory) te).setInventorySlotContents( 0, AEApi.instance().materials().materialLogicProcessorPress.stack( 1 ) ); - break; - case 3: - ((IInventory) te).setInventorySlotContents( 0, AEApi.instance().materials().materialSiliconPress.stack( 1 ) ); - break; - default: + switch ((int) (Math.random() * 1000) % 4) + { + case 0: + ap.addItems( AEApi.instance().materials().materialCalcProcessorPress.stack( 1 ) ); + break; + case 1: + ap.addItems( AEApi.instance().materials().materialEngProcessorPress.stack( 1 ) ); + break; + case 2: + ap.addItems( AEApi.instance().materials().materialLogicProcessorPress.stack( 1 ) ); + break; + case 3: + ap.addItems( AEApi.instance().materials().materialSiliconPress.stack( 1 ) ); + break; + default: + } } - switch ((int) (Math.random() * 1000) % 3) + int secondary = (int) (Math.random() * 3); + for (int zz = 0; zz < secondary; zz++) { - case 0: - ((IInventory) te).setInventorySlotContents( 1, AEApi.instance().blocks().blockSkyStone.stack( (int) (Math.random() * 12) + 1 ) ); - break; - case 1: - ((IInventory) te).setInventorySlotContents( 1, AEApi.instance().materials().materialIronNugget.stack( (int) (Math.random() * 12) + 1 ) ); - break; - case 2: - ((IInventory) te).setInventorySlotContents( 1, new ItemStack( net.minecraft.init.Items.gold_nugget, (int) (Math.random() * 12) + 1 ) ); - break; + switch ((int) (Math.random() * 1000) % 3) + { + case 0: + ap.addItems( AEApi.instance().blocks().blockSkyStone.stack( (int) (Math.random() * 12) + 1 ) ); + break; + case 1: + ap.addItems( AEApi.instance().materials().materialIronNugget.stack( (int) (Math.random() * 12) + 1 ) ); + break; + case 2: + ap.addItems( new ItemStack( net.minecraft.init.Items.gold_nugget, (int) (Math.random() * 12) + 1 ) ); + break; + } } } } diff --git a/hooks/MeteoriteWorldGen.java b/hooks/MeteoriteWorldGen.java index fb5f99c0f..b88b0cd0d 100644 --- a/hooks/MeteoriteWorldGen.java +++ b/hooks/MeteoriteWorldGen.java @@ -59,7 +59,7 @@ final public class MeteoriteWorldGen implements IWorldGenerator } } - if ( obj.distance > 1000 * 1000 ) + if ( obj.distance > 1000 * 500 ) { int depth = 180 + r.nextInt( 20 ); for (int trys = 0; trys < 20; trys++) diff --git a/recipes/RecipeHandler.java b/recipes/RecipeHandler.java index 4d7a3b921..326091060 100644 --- a/recipes/RecipeHandler.java +++ b/recipes/RecipeHandler.java @@ -179,10 +179,12 @@ public class RecipeHandler implements IRecipeHandler { try { - return getName( i.getItemStack() ); + for (ItemStack is : i.getItemStackSet()) + return getName( is ); } catch (Throwable t) { + t.printStackTrace(); // :P } @@ -191,12 +193,13 @@ public class RecipeHandler implements IRecipeHandler public String getName(ItemStack is) { - UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor( is.getItem() ); String realName = id.modId + ":" + id.name; + AELog.info( realName ); + if ( is.getItem() instanceof ItemMaterial ) - realName += ":" + ((ItemMaterial) is.getItem()).getType( is ).name(); + realName += ":" + ((ItemMaterial) is.getItem()).getTypeByStack( is ).name(); else if ( is.getItem() instanceof ItemPart ) realName += ":" + ((ItemPart) is.getItem()).getTypeByStack( is ).name(); else if ( is.getItemDamage() > 0 )