From 500558982f0827880645a66a0122bb6536131419 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Mon, 3 Mar 2014 22:56:08 -0600 Subject: [PATCH] SkyStone Mining finalized. Added Ice meteorite spawn. Fixed Crash with Meteorite Spawning. --- block/solids/BlockSkyStone.java | 18 +++++++++++++++ core/WorldSettings.java | 3 ++- helpers/MeteoritePlacer.java | 39 ++++++++++++++++++++++++++++----- 3 files changed, 54 insertions(+), 6 deletions(-) diff --git a/block/solids/BlockSkyStone.java b/block/solids/BlockSkyStone.java index e7c968de..42d2619f 100644 --- a/block/solids/BlockSkyStone.java +++ b/block/solids/BlockSkyStone.java @@ -13,12 +13,15 @@ import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.PlayerEvent; import appeng.api.util.IOrientable; import appeng.api.util.IOrientableBlock; import appeng.block.AEBaseBlock; import appeng.core.WorldSettings; import appeng.core.features.AEFeature; import appeng.helpers.LocationRotation; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -34,12 +37,27 @@ public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock @SideOnly(Side.CLIENT) IIcon SmallBrick; + @SubscribeEvent + public void breakFaster(PlayerEvent.BreakSpeed Ev) + { + if ( Ev.block == this && Ev.originalSpeed > 7 || Ev.metadata > 0 ) + Ev.newSpeed /= 0.1; + } + public BlockSkyStone() { super( BlockSkyStone.class, Material.rock ); setfeature( EnumSet.of( AEFeature.Core ) ); setHardness( 50 ); hasSubtypes = true; blockResistance = 150.0f; + setHarvestLevel( "pickaxe", 3, 0 ); + MinecraftForge.EVENT_BUS.register( this ); + } + + @Override + public int damageDropped(int meta) + { + return meta; } @Override diff --git a/core/WorldSettings.java b/core/WorldSettings.java index 2cfe167b..11912304 100644 --- a/core/WorldSettings.java +++ b/core/WorldSettings.java @@ -55,7 +55,8 @@ public class WorldSettings extends Configuration { if ( instance == null ) { - File world = DimensionManager.getWorld( 0 ).getSaveHandler().getWorldDirectory(); + File world = DimensionManager.getCurrentSaveRootDirectory(); + File f = new File( world.getPath() + File.separatorChar + "AE2" ); if ( !f.exists() || !f.isDirectory() ) diff --git a/helpers/MeteoritePlacer.java b/helpers/MeteoritePlacer.java index 776e1959..5f6267b5 100644 --- a/helpers/MeteoritePlacer.java +++ b/helpers/MeteoritePlacer.java @@ -111,6 +111,28 @@ public class MeteoritePlacer }; + private class FalloutSnow extends FalloutCopy + { + + public FalloutSnow(World w, int x, int y, int z) { + super( w, x, y, z ); + } + + public int adjustCrator() + { + return 2; + } + + public void getOther(World w, int x, int y, int z, double a) + { + if ( a > 0.7 ) + put( w, x, y, z, Blocks.snow ); + else if ( a > 0.5 ) + put( w, x, y, z, Blocks.ice ); + } + + }; + int minBLocks = 200; HashSet validSpawn = new HashSet(); HashSet invalidSpawn = new HashSet(); @@ -140,6 +162,8 @@ public class MeteoritePlacer validSpawn.add( Blocks.diamond_ore ); validSpawn.add( Blocks.redstone_ore ); validSpawn.add( Blocks.hardened_clay ); + validSpawn.add( Blocks.ice ); + validSpawn.add( Blocks.snow ); invalidSpawn.add( skystone ); invalidSpawn.add( Blocks.planks ); @@ -168,6 +192,8 @@ public class MeteoritePlacer type = new FalloutSand( w, x, y, z ); else if ( blk == Blocks.hardened_clay ) type = new FalloutCopy( w, x, y, z ); + else if ( blk == Blocks.ice || blk == Blocks.snow ) + type = new FalloutSnow( w, x, y, z ); int realValidBlocks = 0; @@ -283,10 +309,11 @@ public class MeteoritePlacer private void Decay(World w, int x, int y, int z) { + double randomShit = 0; for (int i = x - 30; i < x + 30; i++) - for (int j = y - 9; j < y + 30; j++) - for (int k = z - 30; k < z + 30; k++) + for (int k = z - 30; k < z + 30; k++) + for (int j = y - 9; j < y + 30; j++) { Block blk = w.getBlock( i, j, k ); if ( blk == Blocks.lava ) @@ -304,7 +331,7 @@ public class MeteoritePlacer w.setBlock( i, j, k, blk_b, meta_b, 3 ); w.setBlock( i, j + 1, k, blk ); } - else + else if ( randomShit < 100 * crator ) { double dx = i - x; double dy = j - y; @@ -314,10 +341,12 @@ public class MeteoritePlacer Block xf = w.getBlock( i, j - 1, k ); if ( !xf.isReplaceable( w, i, j - 1, k ) ) { - double height = crator * 0.1 - Math.abs( dist - crator * 1.7 ); + double extrRange = Math.random() * 0.6; + double height = crator * (extrRange + 0.2) - Math.abs( dist - crator * 1.7 ); - if ( xf != blk && height > 0 && Math.random() > 0.5 ) + if ( xf != blk && height > 0 && Math.random() > 0.6 ) { + randomShit++; type.getRandomFall( w, i, j, k ); } }