From 3fd69cc5a5d9c3647bf441bbf3fa0cef65e1ff60 Mon Sep 17 00:00:00 2001 From: John Yorke Date: Mon, 29 Nov 2021 16:07:31 -0400 Subject: [PATCH] Cleanup --- .../common/blocks/tile/TileLumos.java | 2 +- .../common/entities/EntityHomingShard.java | 2 +- .../common/handler/TMEventHandler.java | 6 +- .../common/handler/UpdateHandler.java | 2 +- .../common/handler/WandHandler.java | 2 +- .../common/items/ItemMagicFunguar.java | 2 +- .../common/items/ItemMaterial.java | 2 +- .../taintedmagic/common/items/ItemSalis.java | 2 +- .../common/items/ItemWarpFertilizer.java | 2 +- .../items/equipment/ItemVoidwalkerBoots.java | 2 +- .../items/tools/ItemThaumicDisassembler.java | 2 +- .../common/items/wand/ItemWandCap.java | 2 +- .../common/items/wand/ItemWandRod.java | 2 +- .../research/ThaumcraftResearchItem.java | 2 +- .../common/world/WorldGenWarpwoodTree.java | 215 +++++++++--------- 15 files changed, 120 insertions(+), 127 deletions(-) diff --git a/src/main/java/taintedmagic/common/blocks/tile/TileLumos.java b/src/main/java/taintedmagic/common/blocks/tile/TileLumos.java index f190bd9..00860cc 100644 --- a/src/main/java/taintedmagic/common/blocks/tile/TileLumos.java +++ b/src/main/java/taintedmagic/common/blocks/tile/TileLumos.java @@ -33,7 +33,7 @@ public class TileLumos extends TileEntity { if (block instanceof BlockLumos) { final EntityPlayer player = worldObj.getClosestPlayer(xCoord, yCoord, zCoord, 4); - if ( (meta == 0 && worldObj.rand.nextInt(15) == 0) && worldObj.isRemote) { + if (meta == 0 && worldObj.rand.nextInt(15) == 0 && worldObj.isRemote) { spawnParticles(); } if ( (meta == 1 || meta == 2) && player == null) { diff --git a/src/main/java/taintedmagic/common/entities/EntityHomingShard.java b/src/main/java/taintedmagic/common/entities/EntityHomingShard.java index 627a5c8..b07b6e5 100644 --- a/src/main/java/taintedmagic/common/entities/EntityHomingShard.java +++ b/src/main/java/taintedmagic/common/entities/EntityHomingShard.java @@ -41,7 +41,7 @@ public class EntityHomingShard extends EntityThrowable implements IEntityAdditio final int strength, final boolean persistent) { super(world, thrower); this.target = target; - this.targetClass = target.getClass(); + targetClass = target.getClass(); this.persistent = persistent; setStrength(strength); final Vec3 vec = thrower.getLookVec(); diff --git a/src/main/java/taintedmagic/common/handler/TMEventHandler.java b/src/main/java/taintedmagic/common/handler/TMEventHandler.java index a7ba85f..25caf58 100644 --- a/src/main/java/taintedmagic/common/handler/TMEventHandler.java +++ b/src/main/java/taintedmagic/common/handler/TMEventHandler.java @@ -1,6 +1,5 @@ package taintedmagic.common.handler; -import java.util.Random; import java.util.UUID; import baubles.api.BaublesApi; @@ -186,7 +185,6 @@ public class TMEventHandler { if (focus != null && focus instanceof ItemFocusMageMace) { if (wand.consumeAllVis(held, player, focus.getVisCost(held), true, false)) { - ; } else { event.setCanceled(true); @@ -238,8 +236,8 @@ public class TMEventHandler { * Give the player the Creation research upon crafting the Shard of Creation */ public void giveResearch (final EntityPlayer player) { - if (!player.worldObj.isRemote && (!ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), "CREATION") - && ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), "CREATIONSHARD"))) { + if (!player.worldObj.isRemote && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), "CREATION") + && ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), "CREATIONSHARD")) { Thaumcraft.proxy.getResearchManager().completeResearch(player, "CREATION"); PacketHandler.INSTANCE.sendTo(new PacketResearchComplete("CREATION"), (EntityPlayerMP) player); player.addChatMessage( diff --git a/src/main/java/taintedmagic/common/handler/UpdateHandler.java b/src/main/java/taintedmagic/common/handler/UpdateHandler.java index 666cb48..49585f0 100644 --- a/src/main/java/taintedmagic/common/handler/UpdateHandler.java +++ b/src/main/java/taintedmagic/common/handler/UpdateHandler.java @@ -41,7 +41,7 @@ public class UpdateHandler { catch (final MalformedURLException e) { throw new IllegalStateException(e); } - catch (IOException e) { + catch (final IOException e) { TaintedMagic.logger.error("Could not connect to GitHub repository!"); } } diff --git a/src/main/java/taintedmagic/common/handler/WandHandler.java b/src/main/java/taintedmagic/common/handler/WandHandler.java index 86d9ae2..f826d1a 100644 --- a/src/main/java/taintedmagic/common/handler/WandHandler.java +++ b/src/main/java/taintedmagic/common/handler/WandHandler.java @@ -25,7 +25,7 @@ public class WandHandler implements IWandRodOnUpdate { final int roundPeriod = period < 1.0F ? 1 : Math.round(period); if (player.ticksExisted % roundPeriod == 0) { - Aspect[] primals = Aspect.getPrimalAspects().toArray(new Aspect[0]); + final Aspect[] primals = Aspect.getPrimalAspects().toArray(new Aspect[0]); for (final Aspect primal : primals) { ((ItemWandCasting) stack.getItem()).addVis(stack, primal, 1, true); } diff --git a/src/main/java/taintedmagic/common/items/ItemMagicFunguar.java b/src/main/java/taintedmagic/common/items/ItemMagicFunguar.java index 69de5c4..e691fe5 100644 --- a/src/main/java/taintedmagic/common/items/ItemMagicFunguar.java +++ b/src/main/java/taintedmagic/common/items/ItemMagicFunguar.java @@ -35,7 +35,7 @@ public class ItemMagicFunguar extends ItemFood { player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 60, 1)); player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 100, 2)); - Aspect[] aspects = Aspect.getPrimalAspects().toArray(new Aspect[0]); + final Aspect[] aspects = Aspect.getPrimalAspects().toArray(new Aspect[0]); final int i = world.rand.nextInt(aspects.length); if (!world.isRemote) { diff --git a/src/main/java/taintedmagic/common/items/ItemMaterial.java b/src/main/java/taintedmagic/common/items/ItemMaterial.java index 09d3d6f..5d0106f 100644 --- a/src/main/java/taintedmagic/common/items/ItemMaterial.java +++ b/src/main/java/taintedmagic/common/items/ItemMaterial.java @@ -32,7 +32,7 @@ public class ItemMaterial extends Item { * 11 Fragment of Creation */ private static final int SUBTYPES = 12; - private IIcon[] icons = new IIcon[SUBTYPES]; + private final IIcon[] icons = new IIcon[SUBTYPES]; public ItemMaterial () { setCreativeTab(TaintedMagic.tabTM); diff --git a/src/main/java/taintedmagic/common/items/ItemSalis.java b/src/main/java/taintedmagic/common/items/ItemSalis.java index f34ae14..6f0072d 100644 --- a/src/main/java/taintedmagic/common/items/ItemSalis.java +++ b/src/main/java/taintedmagic/common/items/ItemSalis.java @@ -17,7 +17,7 @@ import taintedmagic.common.TaintedMagic; public class ItemSalis extends Item { private static final int SUBTYPES = 2; - private IIcon[] icons = new IIcon[SUBTYPES]; + private final IIcon[] icons = new IIcon[SUBTYPES]; public ItemSalis () { setCreativeTab(TaintedMagic.tabTM); diff --git a/src/main/java/taintedmagic/common/items/ItemWarpFertilizer.java b/src/main/java/taintedmagic/common/items/ItemWarpFertilizer.java index b6aac71..9845221 100644 --- a/src/main/java/taintedmagic/common/items/ItemWarpFertilizer.java +++ b/src/main/java/taintedmagic/common/items/ItemWarpFertilizer.java @@ -36,7 +36,7 @@ public class ItemWarpFertilizer extends Item { public boolean onItemUse (final ItemStack stack, final EntityPlayer player, final World world, final int x, final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ) { super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ); - if (! (world.getBlock(x, y, z) instanceof BlockCustomPlant) || (world.getBlockMetadata(x, y, z) != 1)) + if (! (world.getBlock(x, y, z) instanceof BlockCustomPlant) || world.getBlockMetadata(x, y, z) != 1) return false; if (world.isRemote) { particles(world, x, y, z, 10 + world.rand.nextInt(11)); diff --git a/src/main/java/taintedmagic/common/items/equipment/ItemVoidwalkerBoots.java b/src/main/java/taintedmagic/common/items/equipment/ItemVoidwalkerBoots.java index 8fb55d0..45f96ca 100644 --- a/src/main/java/taintedmagic/common/items/equipment/ItemVoidwalkerBoots.java +++ b/src/main/java/taintedmagic/common/items/equipment/ItemVoidwalkerBoots.java @@ -74,7 +74,7 @@ public class ItemVoidwalkerBoots extends ItemArmor int priority = 0; double ratio = damageReduceAmount / 90.0D; - if (source.isMagicDamage() || (source.isFireDamage() || source.isExplosion())) { + if (source.isMagicDamage() || source.isFireDamage() || source.isExplosion()) { priority = 1; ratio = damageReduceAmount / 80.0D; } diff --git a/src/main/java/taintedmagic/common/items/tools/ItemThaumicDisassembler.java b/src/main/java/taintedmagic/common/items/tools/ItemThaumicDisassembler.java index 7efe344..4b32a14 100644 --- a/src/main/java/taintedmagic/common/items/tools/ItemThaumicDisassembler.java +++ b/src/main/java/taintedmagic/common/items/tools/ItemThaumicDisassembler.java @@ -160,7 +160,7 @@ public class ItemThaumicDisassembler extends Item { final Block block = world.getBlock(x, y, z); final boolean air = world.isAirBlock(x, y + 1, z); - if (side == 0 || !air || (block != Blocks.grass && block != Blocks.dirt)) + if (side == 0 || !air || block != Blocks.grass && block != Blocks.dirt) return false; final Block farm = Blocks.farmland; diff --git a/src/main/java/taintedmagic/common/items/wand/ItemWandCap.java b/src/main/java/taintedmagic/common/items/wand/ItemWandCap.java index 294d3b8..75b4976 100644 --- a/src/main/java/taintedmagic/common/items/wand/ItemWandCap.java +++ b/src/main/java/taintedmagic/common/items/wand/ItemWandCap.java @@ -15,7 +15,7 @@ import taintedmagic.common.TaintedMagic; public class ItemWandCap extends Item { private static final int SUBTYPES = 4; - private IIcon[] icons = new IIcon[SUBTYPES]; + private final IIcon[] icons = new IIcon[SUBTYPES]; public ItemWandCap () { setCreativeTab(TaintedMagic.tabTM); diff --git a/src/main/java/taintedmagic/common/items/wand/ItemWandRod.java b/src/main/java/taintedmagic/common/items/wand/ItemWandRod.java index 728df68..c037a15 100644 --- a/src/main/java/taintedmagic/common/items/wand/ItemWandRod.java +++ b/src/main/java/taintedmagic/common/items/wand/ItemWandRod.java @@ -15,7 +15,7 @@ import taintedmagic.common.TaintedMagic; public class ItemWandRod extends Item { private static final int SUBTYPES = 2; - private IIcon[] icons = new IIcon[SUBTYPES]; + private final IIcon[] icons = new IIcon[SUBTYPES]; public ItemWandRod () { setCreativeTab(TaintedMagic.tabTM); diff --git a/src/main/java/taintedmagic/common/research/ThaumcraftResearchItem.java b/src/main/java/taintedmagic/common/research/ThaumcraftResearchItem.java index aa59033..f974571 100644 --- a/src/main/java/taintedmagic/common/research/ThaumcraftResearchItem.java +++ b/src/main/java/taintedmagic/common/research/ThaumcraftResearchItem.java @@ -16,7 +16,7 @@ import thaumcraft.api.research.ResearchPage; */ public class ThaumcraftResearchItem extends ResearchItem { - private ResearchItem original; + private final ResearchItem original; public ThaumcraftResearchItem (final String tag, final String origin, final String originCategory, final int col, final int row, final ResourceLocation icon) { diff --git a/src/main/java/taintedmagic/common/world/WorldGenWarpwoodTree.java b/src/main/java/taintedmagic/common/world/WorldGenWarpwoodTree.java index d3e8763..d6c278b 100644 --- a/src/main/java/taintedmagic/common/world/WorldGenWarpwoodTree.java +++ b/src/main/java/taintedmagic/common/world/WorldGenWarpwoodTree.java @@ -67,122 +67,117 @@ public class WorldGenWarpwoodTree extends WorldGenAbstractTree { if (!flag) return false; - else { - final Block block1 = world.getBlock(x, y - 1, z); - final boolean isSoil = block1.canSustainPlant(world, x, y - 1, z, ForgeDirection.UP, (BlockSapling) Blocks.sapling); - if (isSoil && y < 256 - height - 1) { - block1.onPlantGrow(world, x, y - 1, z, x, y, z); - final int start = y + height - 5; - final int end = y + height + 3 + random.nextInt(3); + final Block block1 = world.getBlock(x, y - 1, z); + final boolean isSoil = block1.canSustainPlant(world, x, y - 1, z, ForgeDirection.UP, (BlockSapling) Blocks.sapling); + if (!isSoil || y >= 256 - height - 1) + return false; + block1.onPlantGrow(world, x, y - 1, z, x, y, z); + final int start = y + height - 5; + final int end = y + height + 3 + random.nextInt(3); - int k2; - for (k2 = start; k2 <= end; ++k2) { - final int cty = MathHelper.clamp_int(k2, y + height - 3, y + height); + int k2; + for (k2 = start; k2 <= end; ++k2) { + final int cty = MathHelper.clamp_int(k2, y + height - 3, y + height); - for (int xx = x - 5; xx <= x + 5; ++xx) { - for (int zz = z - 5; zz <= z + 5; ++zz) { - final double d3 = xx - x; - final double d4 = k2 - cty; - final double d5 = zz - z; - final double dist = d3 * d3 + d4 * d4 + d5 * d5; + for (int xx = x - 5; xx <= x + 5; ++xx) { + for (int zz = z - 5; zz <= z + 5; ++zz) { + final double d3 = xx - x; + final double d4 = k2 - cty; + final double d5 = zz - z; + final double dist = d3 * d3 + d4 * d4 + d5 * d5; - if (dist < 10 + random.nextInt(8) - && world.getBlock(xx, k2, zz).canBeReplacedByLeaves(world, xx, k2, zz)) { - setBlockAndNotifyAdequately(world, xx, k2, zz, leaves, 1); - } - } + if (dist < 10 + random.nextInt(8) && world.getBlock(xx, k2, zz).canBeReplacedByLeaves(world, xx, k2, zz)) { + setBlockAndNotifyAdequately(world, xx, k2, zz, leaves, 1); } } - - int chance = height; - boolean lastblock = false; - - for (k2 = 0; k2 < height; k2++) { - final Block block2 = world.getBlock(x, y + k2, z); - - if (!block2.isAir(world, x, y + k2, z) && !block2.isLeaves(world, x, y + k2, z) - && !block2.isReplaceable(world, x, y + k2, z)) { - continue; - } - - if (k2 > 0 && !lastblock && random.nextInt(chance) == 0) { - setBlockAndNotifyAdequately(world, x, y + k2, z, trunk, 2); - lastblock = true; - } - else { - setBlockAndNotifyAdequately(world, x, y + k2, z, trunk, 0); - lastblock = false; - chance--; - } - setBlockAndNotifyAdequately(world, x - 1, y + k2, z, trunk, 0); - setBlockAndNotifyAdequately(world, x + 1, y + k2, z, trunk, 0); - setBlockAndNotifyAdequately(world, x, y + k2, z - 1, trunk, 0); - setBlockAndNotifyAdequately(world, x, y + k2, z + 1, trunk, 0); - } - - setBlockAndNotifyAdequately(world, x, y + k2, z, trunk, 0); - setBlockAndNotifyAdequately(world, x - 1, y, z - 1, trunk, 0); - setBlockAndNotifyAdequately(world, x + 1, y, z + 1, trunk, 0); - setBlockAndNotifyAdequately(world, x - 1, y, z + 1, trunk, 0); - setBlockAndNotifyAdequately(world, x + 1, y, z - 1, trunk, 0); - - if (random.nextInt(3) != 0) { - setBlockAndNotifyAdequately(world, x - 1, y + 1, z - 1, trunk, 0); - } - - if (random.nextInt(3) != 0) { - setBlockAndNotifyAdequately(world, x + 1, y + 1, z + 1, trunk, 0); - } - - if (random.nextInt(3) != 0) { - setBlockAndNotifyAdequately(world, x - 1, y + 1, z + 1, trunk, 0); - } - - if (random.nextInt(3) != 0) { - setBlockAndNotifyAdequately(world, x + 1, y + 1, z - 1, trunk, 0); - } - - setBlockAndNotifyAdequately(world, x - 2, y, z, trunk, 5); - setBlockAndNotifyAdequately(world, x + 2, y, z, trunk, 5); - setBlockAndNotifyAdequately(world, x, y, z - 2, trunk, 9); - setBlockAndNotifyAdequately(world, x, y, z + 2, trunk, 9); - setBlockAndNotifyAdequately(world, x - 2, y - 1, z, trunk, 0); - setBlockAndNotifyAdequately(world, x + 2, y - 1, z, trunk, 0); - setBlockAndNotifyAdequately(world, x, y - 1, z - 2, trunk, 0); - setBlockAndNotifyAdequately(world, x, y - 1, z + 2, trunk, 0); - setBlockAndNotifyAdequately(world, x - 1, y + height - 4, z - 1, trunk, 0); - setBlockAndNotifyAdequately(world, x + 1, y + height - 4, z + 1, trunk, 0); - setBlockAndNotifyAdequately(world, x - 1, y + height - 4, z + 1, trunk, 0); - setBlockAndNotifyAdequately(world, x + 1, y + height - 4, z - 1, trunk, 0); - - if (random.nextInt(3) == 0) { - setBlockAndNotifyAdequately(world, x - 1, y + height - 5, z - 1, trunk, 0); - } - - if (random.nextInt(3) == 0) { - setBlockAndNotifyAdequately(world, x + 1, y + height - 5, z + 1, trunk, 0); - } - - if (random.nextInt(3) == 0) { - setBlockAndNotifyAdequately(world, x - 1, y + height - 5, z + 1, trunk, 0); - } - - if (random.nextInt(3) == 0) { - setBlockAndNotifyAdequately(world, x + 1, y + height - 5, z - 1, trunk, 0); - } - - setBlockAndNotifyAdequately(world, x - 2, y + height - 4, z, trunk, 5); - setBlockAndNotifyAdequately(world, x + 2, y + height - 4, z, trunk, 5); - setBlockAndNotifyAdequately(world, x, y + height - 4, z - 2, trunk, 9); - setBlockAndNotifyAdequately(world, x, y + height - 4, z + 2, trunk, 9); - - final WorldGenerator flowers = new WorldGenCustomFlowers(BlockRegistry.BlockNightshadeBush, 0); - flowers.generate(world, random, x, y, z); - - return true; } - else - return false; } + + int chance = height; + boolean lastblock = false; + + for (k2 = 0; k2 < height; k2++) { + final Block block2 = world.getBlock(x, y + k2, z); + + if (!block2.isAir(world, x, y + k2, z) && !block2.isLeaves(world, x, y + k2, z) + && !block2.isReplaceable(world, x, y + k2, z)) { + continue; + } + + if (k2 > 0 && !lastblock && random.nextInt(chance) == 0) { + setBlockAndNotifyAdequately(world, x, y + k2, z, trunk, 2); + lastblock = true; + } + else { + setBlockAndNotifyAdequately(world, x, y + k2, z, trunk, 0); + lastblock = false; + chance--; + } + setBlockAndNotifyAdequately(world, x - 1, y + k2, z, trunk, 0); + setBlockAndNotifyAdequately(world, x + 1, y + k2, z, trunk, 0); + setBlockAndNotifyAdequately(world, x, y + k2, z - 1, trunk, 0); + setBlockAndNotifyAdequately(world, x, y + k2, z + 1, trunk, 0); + } + + setBlockAndNotifyAdequately(world, x, y + k2, z, trunk, 0); + setBlockAndNotifyAdequately(world, x - 1, y, z - 1, trunk, 0); + setBlockAndNotifyAdequately(world, x + 1, y, z + 1, trunk, 0); + setBlockAndNotifyAdequately(world, x - 1, y, z + 1, trunk, 0); + setBlockAndNotifyAdequately(world, x + 1, y, z - 1, trunk, 0); + + if (random.nextInt(3) != 0) { + setBlockAndNotifyAdequately(world, x - 1, y + 1, z - 1, trunk, 0); + } + + if (random.nextInt(3) != 0) { + setBlockAndNotifyAdequately(world, x + 1, y + 1, z + 1, trunk, 0); + } + + if (random.nextInt(3) != 0) { + setBlockAndNotifyAdequately(world, x - 1, y + 1, z + 1, trunk, 0); + } + + if (random.nextInt(3) != 0) { + setBlockAndNotifyAdequately(world, x + 1, y + 1, z - 1, trunk, 0); + } + + setBlockAndNotifyAdequately(world, x - 2, y, z, trunk, 5); + setBlockAndNotifyAdequately(world, x + 2, y, z, trunk, 5); + setBlockAndNotifyAdequately(world, x, y, z - 2, trunk, 9); + setBlockAndNotifyAdequately(world, x, y, z + 2, trunk, 9); + setBlockAndNotifyAdequately(world, x - 2, y - 1, z, trunk, 0); + setBlockAndNotifyAdequately(world, x + 2, y - 1, z, trunk, 0); + setBlockAndNotifyAdequately(world, x, y - 1, z - 2, trunk, 0); + setBlockAndNotifyAdequately(world, x, y - 1, z + 2, trunk, 0); + setBlockAndNotifyAdequately(world, x - 1, y + height - 4, z - 1, trunk, 0); + setBlockAndNotifyAdequately(world, x + 1, y + height - 4, z + 1, trunk, 0); + setBlockAndNotifyAdequately(world, x - 1, y + height - 4, z + 1, trunk, 0); + setBlockAndNotifyAdequately(world, x + 1, y + height - 4, z - 1, trunk, 0); + + if (random.nextInt(3) == 0) { + setBlockAndNotifyAdequately(world, x - 1, y + height - 5, z - 1, trunk, 0); + } + + if (random.nextInt(3) == 0) { + setBlockAndNotifyAdequately(world, x + 1, y + height - 5, z + 1, trunk, 0); + } + + if (random.nextInt(3) == 0) { + setBlockAndNotifyAdequately(world, x - 1, y + height - 5, z + 1, trunk, 0); + } + + if (random.nextInt(3) == 0) { + setBlockAndNotifyAdequately(world, x + 1, y + height - 5, z - 1, trunk, 0); + } + + setBlockAndNotifyAdequately(world, x - 2, y + height - 4, z, trunk, 5); + setBlockAndNotifyAdequately(world, x + 2, y + height - 4, z, trunk, 5); + setBlockAndNotifyAdequately(world, x, y + height - 4, z - 2, trunk, 9); + setBlockAndNotifyAdequately(world, x, y + height - 4, z + 2, trunk, 9); + + final WorldGenerator flowers = new WorldGenCustomFlowers(BlockRegistry.BlockNightshadeBush, 0); + flowers.generate(world, random, x, y, z); + + return true; } } \ No newline at end of file