diff --git a/src/powercrystals/netherores/NetherOresCore.java b/src/powercrystals/netherores/NetherOresCore.java index 6637095..b0c218d 100644 --- a/src/powercrystals/netherores/NetherOresCore.java +++ b/src/powercrystals/netherores/NetherOresCore.java @@ -12,6 +12,7 @@ import powercrystals.netherores.net.INetherOresProxy; import powercrystals.netherores.net.ServerPacketHandler; import powercrystals.netherores.ores.BlockNetherOres; +import powercrystals.netherores.ores.BlockNetherOverrideOre; import powercrystals.netherores.ores.ItemBlockNetherOre; import powercrystals.netherores.ores.Ores; import powercrystals.netherores.world.BlockHellfish; @@ -54,7 +55,7 @@ public class NetherOresCore extends BaseMod public static final String mobTexureFolder = "/textures/mob/powercrystals/netherores/"; - public static Block[] blockNetherOres = new Block[(int)((Ores.values().length + 15) / 16)]; + public static Block[] blockNetherOres = new Block[(Ores.values().length + 15) / 16]; public static Block blockHellfish; private static Property[] netherOreBlockIds = new Property[blockNetherOres.length]; @@ -72,6 +73,7 @@ public class NetherOresCore extends BaseMod public static Property enableInductionSmelterRecipes; public static Property forceOreSpawn; public static Property worldGenAllDimensions; + public static Property enableHellQuartz; @SidedProxy(clientSide = "powercrystals.netherores.net.ClientProxy", serverSide="powercrystals.netherores.net.ServerProxy") public static INetherOresProxy proxy; @@ -98,6 +100,13 @@ public void load(FMLInitializationEvent evt) blockHellfish = new BlockHellfish(hellfishBlockId.getInt()); GameRegistry.registerBlock(blockHellfish, "netherOresBlockHellfish"); GameRegistry.registerWorldGenerator(new NetherOresWorldGenHandler()); + if (enableHellQuartz.getBoolean(true)) + { + int id = Block.oreNetherQuartz.blockID; + Block.blocksList[id] = null; + Block quartz = new BlockNetherOverrideOre(id).setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundStoneFootstep).setUnlocalizedName("netherquartz"); + Block.oreNetherQuartz = quartz; + } for(Ores o : Ores.values()) { @@ -221,6 +230,8 @@ private void loadConfig(File f) enableHellfish.comment = "If true, Hellfish will spawn in the Nether. Note that setting this false will not kill active Hellfish mobs."; worldGenAllDimensions = c.get(Configuration.CATEGORY_GENERAL, "AllDimensionWorldGen", false); worldGenAllDimensions.comment = "If true, Nether Ores oregen will run in all dimensions instead of just the Nether. It will still require netherrack to place ores."; + enableHellQuartz = c.get(Configuration.CATEGORY_GENERAL, "OverrideNetherQuartz", true); + enableHellQuartz.comment = "If true, Nether Quartz ore will be a NetherOre and will follow the same rules as all other NetherOres."; for(Ores o : Ores.values()) { diff --git a/src/powercrystals/netherores/entity/EntityArmedOre.java b/src/powercrystals/netherores/entity/EntityArmedOre.java index 7812a70..41d1aa7 100644 --- a/src/powercrystals/netherores/entity/EntityArmedOre.java +++ b/src/powercrystals/netherores/entity/EntityArmedOre.java @@ -12,6 +12,7 @@ public class EntityArmedOre extends Entity { private int _fuse; + private int _target; public EntityArmedOre(World world) { @@ -21,8 +22,10 @@ public EntityArmedOre(World world) setSize(0.0F, 0.0F); yOffset = height / 2.0F; } + + public EntityArmedOre(World world, double x, double y, double z) { this(world, x, y, z, null); } - public EntityArmedOre(World world, double x, double y, double z) + public EntityArmedOre(World world, double x, double y, double z, Block block) { this(world); setPosition(x, y, z); @@ -33,6 +36,7 @@ public EntityArmedOre(World world, double x, double y, double z) prevPosX = x; prevPosY = y; prevPosZ = z; + _target = block != null ? block.blockID : -1; } @Override @@ -71,10 +75,7 @@ public void onUpdate() private void explode() { int blockId = worldObj.getBlockId(MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)); - boolean found = false; - for (Block b : NetherOresCore.blockNetherOres) - if ((found = b.blockID == blockId)) - break; + boolean found = blockId == _target; if (found) { worldObj.newExplosion(null, this.posX, this.posY, this.posZ, NetherOresCore.explosionPower.getInt(), true, true); diff --git a/src/powercrystals/netherores/ores/BlockNetherOres.java b/src/powercrystals/netherores/ores/BlockNetherOres.java index 0920b5f..6ccf2df 100644 --- a/src/powercrystals/netherores/ores/BlockNetherOres.java +++ b/src/powercrystals/netherores/ores/BlockNetherOres.java @@ -83,7 +83,7 @@ public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int { if(player == null || !EnchantmentHelper.getSilkTouchModifier(player)) { - checkExplosionChances(world, x, y, z); + checkExplosionChances(this, world, x, y, z); } return super.removeBlockByPlayer(world, player, x, y, z); @@ -94,11 +94,11 @@ public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explos { if(NetherOresCore.enableExplosionChainReactions.getBoolean(true)) { - checkExplosionChances(world, x, y, z); + checkExplosionChances(this, world, x, y, z); } } - private void checkExplosionChances(World world, int x, int y, int z) + public static void checkExplosionChances(Block block, World world, int x, int y, int z) { if(!world.isRemote && NetherOresCore.enableExplosions.getBoolean(true)) { @@ -117,9 +117,9 @@ private void checkExplosionChances(World world, int x, int y, int z) continue; } - if(world.getBlockId(tx, ty, tz) == blockID && world.rand.nextInt(1000) < NetherOresCore.explosionProbability.getInt()) + if(world.getBlockId(tx, ty, tz) == block.blockID && world.rand.nextInt(1000) < NetherOresCore.explosionProbability.getInt()) { - EntityArmedOre eao = new EntityArmedOre(world, tx + 0.5, ty + 0.5, tz + 0.5); + EntityArmedOre eao = new EntityArmedOre(world, tx + 0.5, ty + 0.5, tz + 0.5, block); world.spawnEntityInWorld(eao); world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "random.fuse", 1.0F, 1.0F); @@ -130,7 +130,7 @@ private void checkExplosionChances(World world, int x, int y, int z) } } - private void angerPigmen(EntityPlayer player, World world, int x, int y, int z) + public static void angerPigmen(EntityPlayer player, World world, int x, int y, int z) { List list = world.getEntitiesWithinAABB(EntityPigZombie.class, AxisAlignedBB.getBoundingBox(x - _aggroRange, y - _aggroRange, z - _aggroRange, x + _aggroRange + 1, y + _aggroRange + 1, z + _aggroRange + 1)); diff --git a/src/powercrystals/netherores/ores/BlockNetherOverrideOre.java b/src/powercrystals/netherores/ores/BlockNetherOverrideOre.java new file mode 100644 index 0000000..746bb85 --- /dev/null +++ b/src/powercrystals/netherores/ores/BlockNetherOverrideOre.java @@ -0,0 +1,48 @@ +package powercrystals.netherores.ores; + +import powercrystals.netherores.NetherOresCore; + +import net.minecraft.block.BlockOre; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.Explosion; +import net.minecraft.world.World; + +public class BlockNetherOverrideOre extends BlockOre +{ + public BlockNetherOverrideOre(int par1) + { + super(par1); + } + + @Override + public void harvestBlock(World world, EntityPlayer entityplayer, int x, int y, int z, int fortune) + { + super.harvestBlock(world, entityplayer, x, y, z, fortune); + if(NetherOresCore.enableAngryPigmen.getBoolean(true)) + { + BlockNetherOres.angerPigmen(entityplayer, world, x, y, z); + } + } + + @Override + public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) + { + if(player == null || !EnchantmentHelper.getSilkTouchModifier(player)) + { + BlockNetherOres.checkExplosionChances(this, world, x, y, z); + } + + return super.removeBlockByPlayer(world, player, x, y, z); + } + + @Override + public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) + { + if(NetherOresCore.enableExplosionChainReactions.getBoolean(true)) + { + BlockNetherOres.checkExplosionChances(this, world, x, y, z); + } + } + +} diff --git a/src/powercrystals/netherores/ores/Ores.java b/src/powercrystals/netherores/ores/Ores.java index 9953b99..6870abb 100644 --- a/src/powercrystals/netherores/ores/Ores.java +++ b/src/powercrystals/netherores/ores/Ores.java @@ -55,7 +55,7 @@ public enum Ores private Ores(String oreSuffix, int groupsPerChunk, int blocksPerGroup, int smeltCount, int maceCount) { int meta = this.ordinal(); - _blockIndex = (int)(meta / 16); + _blockIndex = meta / 16; _metadata = meta % 16; _oreName = "ore" + oreSuffix; _dustName = "dust" + oreSuffix; diff --git a/src/powercrystals/netherores/world/BlockHellfish.java b/src/powercrystals/netherores/world/BlockHellfish.java index 078d06c..3b8926c 100644 --- a/src/powercrystals/netherores/world/BlockHellfish.java +++ b/src/powercrystals/netherores/world/BlockHellfish.java @@ -26,7 +26,7 @@ public BlockHellfish(int blockId) @Override public void registerIcons(IconRegister ir) { - _icon = ir.registerIcon("powercrystals/netherores/" + getUnlocalizedName()); + _icon = ir.registerIcon("hellrock"); } @Override @@ -61,12 +61,12 @@ public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explos super.onBlockDestroyedByExplosion(world, x, y, z, explosion); } - private void spawnHellfish(World world, int x, int y, int z) + public static void spawnHellfish(World world, int x, int y, int z) { if(!world.isRemote && NetherOresCore.enableHellfish.getBoolean(true)) { EntityHellfish hellfish = new EntityHellfish(world); - hellfish.setLocationAndAngles((double)x + 0.5D, (double)y, (double)z + 0.5D, 0.0F, 0.0F); + hellfish.setLocationAndAngles(x + 0.5D, y, z + 0.5D, 0.0F, 0.0F); world.spawnEntityInWorld(hellfish); hellfish.spawnExplosionParticle(); } diff --git a/src/powercrystals/netherores/world/WorldGenNetherOres.java b/src/powercrystals/netherores/world/WorldGenNetherOres.java index 4460bc4..3ce5d4a 100644 --- a/src/powercrystals/netherores/world/WorldGenNetherOres.java +++ b/src/powercrystals/netherores/world/WorldGenNetherOres.java @@ -24,20 +24,20 @@ public WorldGenNetherOres(int blockId, int blockMeta, int numBlocks) public boolean generate(World world, Random random, int chunkX, int y, int chunkZ) { float f = random.nextFloat() * (float)Math.PI; - double d = (float)(chunkX + 8) + (MathHelper.sin(f) * (float)_numberOfBlocks) / 8F; - double d1 = (float)(chunkX + 8) - (MathHelper.sin(f) * (float)_numberOfBlocks) / 8F; - double d2 = (float)(chunkZ + 8) + (MathHelper.cos(f) * (float)_numberOfBlocks) / 8F; - double d3 = (float)(chunkZ + 8) - (MathHelper.cos(f) * (float)_numberOfBlocks) / 8F; + double d = chunkX + 8 + (MathHelper.sin(f) * _numberOfBlocks) / 8F; + double d1 = chunkX + 8 - (MathHelper.sin(f) * _numberOfBlocks) / 8F; + double d2 = chunkZ + 8 + (MathHelper.cos(f) * _numberOfBlocks) / 8F; + double d3 = chunkZ + 8 - (MathHelper.cos(f) * _numberOfBlocks) / 8F; double d4 = (y + random.nextInt(3)) - 2; double d5 = (y + random.nextInt(3)) - 2; for(int blockNum = 0; blockNum <= _numberOfBlocks; blockNum++) { - double d6 = d + ((d1 - d) * (double)blockNum) / (double)_numberOfBlocks; - double d7 = d4 + ((d5 - d4) * (double)blockNum) / (double)_numberOfBlocks; - double d8 = d2 + ((d3 - d2) * (double)blockNum) / (double)_numberOfBlocks; - double d9 = (random.nextDouble() * (double)_numberOfBlocks) / 16D; - double d10 = (double)(MathHelper.sin(((float)blockNum * 3.141593F) / (float)_numberOfBlocks) + 1.0F) * d9 + 1.0D; - double d11 = (double)(MathHelper.sin(((float)blockNum * 3.141593F) / (float)_numberOfBlocks) + 1.0F) * d9 + 1.0D; + double d6 = d + ((d1 - d) * blockNum) / _numberOfBlocks; + double d7 = d4 + ((d5 - d4) * blockNum) / _numberOfBlocks; + double d8 = d2 + ((d3 - d2) * blockNum) / _numberOfBlocks; + double d9 = (random.nextDouble() * _numberOfBlocks) / 16D; + double d10 = (MathHelper.sin((blockNum * 3.141593F) / _numberOfBlocks) + 1.0F) * d9 + 1.0D; + double d11 = (MathHelper.sin((blockNum * 3.141593F) / _numberOfBlocks) + 1.0F) * d9 + 1.0D; int xStart = MathHelper.floor_double(d6 - d10 / 2D); int yStart = MathHelper.floor_double(d7 - d11 / 2D); int zStart = MathHelper.floor_double(d8 - d10 / 2D); @@ -46,21 +46,21 @@ public boolean generate(World world, Random random, int chunkX, int y, int chunk int zStop = MathHelper.floor_double(d8 + d10 / 2D); for(int blockX = xStart; blockX <= xStop; blockX++) { - double d12 = (((double)blockX + 0.5D) - d6) / (d10 / 2D); + double d12 = ((blockX + 0.5D) - d6) / (d10 / 2D); if(d12 * d12 >= 1.0D) { continue; } for(int blockY = yStart; blockY <= yStop; blockY++) { - double d13 = (((double)blockY + 0.5D) - d7) / (d11 / 2D); + double d13 = ((blockY + 0.5D) - d7) / (d11 / 2D); if(d12 * d12 + d13 * d13 >= 1.0D) { continue; } for(int blockZ = zStart; blockZ <= zStop; blockZ++) { - double d14 = (((double)blockZ + 0.5D) - d8) / (d10 / 2D); + double d14 = ((blockZ + 0.5D) - d8) / (d10 / 2D); if(d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && world.getBlockId(blockX, blockY, blockZ) == Block.netherrack.blockID) { world.setBlock(blockX, blockY, blockZ, _minableBlockId, _minableBlockMeta, 2);