From d3d3e2a96633401eaf73f036947e52f95c492b42 Mon Sep 17 00:00:00 2001 From: Raven Szewczyk Date: Sat, 1 Apr 2023 12:15:50 +0100 Subject: [PATCH] Jabel, Generic injection and automatic code cleanup (#21) * Enable jabel&generic injection, fix generic injection errors * Enhanced for loops * Add missing generics part 1 * Add missing generics part 2: getSubBlocks * Add missing generics part 3: structure components * Add missing generics part 4: addInformation * MapGenTFHollowTree cleanup * Replace an unreadable do-while loop with a stream filter-find * Fix unnecessary boxing * Fix unnecessary unboxing * While->Enhanced for loop * Use diamond operator where appropriate * Collapse identical catch blocks * String switch * Use enhanced switch * Fix compilation error after added generics * Use instanceof pattern matching * More missed generic parameters * Use Java-style array declarations * Unnecessary String conversions * Unnecessary modifiers * Unnecessary semicolons * Unchecked warnings fixes * Explicit array filling * Manual min/max calculations * Redundant vararg array creation * Redundant type casts * Unnecessary StringBuilder * Remove redundant suppressions * Apply spotless * Fix ambiguous method call error * Update baubles to fix runObfClient --- dependencies.gradle | 2 +- gradle.properties | 23 +- .../java/twilightforest/CommandTFFeature.java | 21 +- .../twilightforest/CommandTFProgress.java | 50 +- .../twilightforest/TFAchievementPage.java | 2 +- .../java/twilightforest/TFEventListener.java | 34 +- src/main/java/twilightforest/TFFeature.java | 106 +--- .../java/twilightforest/TFMagicMapData.java | 7 +- .../java/twilightforest/TFTeleporter.java | 4 +- .../java/twilightforest/TFTickHandler.java | 3 +- src/main/java/twilightforest/TFTreasure.java | 142 ++--- .../java/twilightforest/TFTreasureTable.java | 2 +- .../twilightforest/TwilightForestMod.java | 2 +- .../twilightforest/biomes/TFBiomeBase.java | 7 +- .../biomes/TFBiomeDarkForest.java | 15 +- .../biomes/TFBiomeDecorator.java | 2 +- .../twilightforest/biomes/TFBiomeGlacier.java | 1 - .../twilightforest/biomes/TFBiomeSnow.java | 7 +- .../twilightforest/biomes/TFBiomeSwamp.java | 15 +- .../biomes/TFBiomeTwilightLake.java | 1 - .../block/BlockTFAuroraBrick.java | 3 +- .../block/BlockTFBossSpawner.java | 29 +- .../block/BlockTFBurntThorns.java | 4 +- .../block/BlockTFCastleBlock.java | 20 +- .../block/BlockTFCastleMagic.java | 3 +- .../block/BlockTFCinderFurnace.java | 29 +- .../twilightforest/block/BlockTFCritter.java | 76 +-- .../twilightforest/block/BlockTFDeadrock.java | 2 +- .../twilightforest/block/BlockTFFireJet.java | 70 +- .../block/BlockTFFireflyJar.java | 2 +- .../block/BlockTFForceField.java | 5 +- .../block/BlockTFGiantBlock.java | 21 +- .../block/BlockTFGiantLeaves.java | 24 +- .../twilightforest/block/BlockTFHedge.java | 19 +- .../block/BlockTFHugeLilyPad.java | 20 +- .../twilightforest/block/BlockTFLeaves.java | 18 +- .../twilightforest/block/BlockTFLeaves3.java | 3 +- .../java/twilightforest/block/BlockTFLog.java | 35 +- .../block/BlockTFMagicLeaves.java | 68 +- .../twilightforest/block/BlockTFMagicLog.java | 36 +- .../block/BlockTFMagicLogSpecial.java | 71 +-- .../block/BlockTFMazestone.java | 32 +- .../twilightforest/block/BlockTFMoonworm.java | 27 +- .../block/BlockTFNagastone.java | 377 ++++++----- .../twilightforest/block/BlockTFPlanks.java | 2 +- .../twilightforest/block/BlockTFPlant.java | 42 +- .../twilightforest/block/BlockTFPortal.java | 8 +- .../twilightforest/block/BlockTFRoots.java | 44 +- .../twilightforest/block/BlockTFSapling.java | 46 +- .../twilightforest/block/BlockTFShield.java | 3 +- .../twilightforest/block/BlockTFSlider.java | 102 ++- .../twilightforest/block/BlockTFThorns.java | 87 ++- .../block/BlockTFTowerDevice.java | 111 ++-- .../block/BlockTFTowerTranslucent.java | 42 +- .../block/BlockTFTowerWood.java | 22 +- .../block/BlockTFTrollRoot.java | 2 +- .../block/BlockTFTrollSteinn.java | 6 +- .../twilightforest/block/BlockTFTrophy.java | 39 +- .../block/BlockTFTrophyPedestal.java | 15 +- .../block/BlockTFUberousSoil.java | 3 +- .../block/BlockTFUncraftingTable.java | 2 +- .../block/BlockTFUnderBrick.java | 2 +- .../java/twilightforest/block/TFBlocks.java | 8 +- .../client/GuiTFCinderFurnace.java | 5 +- .../twilightforest/client/TFClientProxy.java | 50 +- .../client/model/ModelTFArcticArmor.java | 16 +- .../client/model/ModelTFFieryArmor.java | 17 +- .../client/model/ModelTFIceCrystal.java | 4 +- .../client/model/ModelTFIceExploder.java | 6 +- .../client/model/ModelTFIceShooter.java | 3 +- .../client/model/ModelTFKnightlyArmor.java | 17 +- .../client/model/ModelTFTowerBoss.java | 39 +- .../client/model/ModelTFYetiArmor.java | 17 +- .../client/particle/EntityTFBossTearFX.java | 40 +- .../client/particle/EntityTFFireflyFX.java | 40 +- .../client/particle/EntityTFLeafRuneFX.java | 2 +- .../client/renderer/TFMagicMapRenderer.java | 54 +- .../client/renderer/TFMazeMapRenderer.java | 8 +- .../client/renderer/TFSkyRenderer.java | 64 +- .../client/renderer/TFWeatherRenderer.java | 222 ++++--- .../renderer/TileEntityTFTrophyRenderer.java | 43 +- .../blocks/RenderBlockTFCastleMagic.java | 12 +- .../blocks/RenderBlockTFHugeLilyPad.java | 4 +- .../blocks/RenderBlockTFMagicLeaves.java | 28 +- .../blocks/RenderBlockTFNagastone.java | 44 +- .../renderer/blocks/RenderBlockTFThorns.java | 80 +-- .../client/renderer/entity/RenderTFBunny.java | 17 +- .../client/renderer/entity/RenderTFCharm.java | 11 +- .../renderer/entity/RenderTFMiniGhast.java | 16 +- .../client/renderer/entity/RenderTFNaga.java | 3 +- .../renderer/entity/RenderTFSlimeBeetle.java | 2 +- .../renderer/entity/RenderTFTinyBird.java | 17 +- .../renderer/entity/RenderTFUrGhast.java | 16 +- .../entity/EntitySeekerArrow.java | 3 +- .../entity/EntityTFBlockGoblin.java | 5 +- .../entity/EntityTFChainBlock.java | 33 +- .../entity/EntityTFCubeOfAnnihilation.java | 6 +- .../entity/EntityTFGiantMiner.java | 6 +- .../entity/EntityTFGoblinKnightLower.java | 6 +- .../entity/EntityTFGoblinKnightUpper.java | 5 +- .../entity/EntityTFIceExploder.java | 9 +- .../entity/EntityTFKingSpider.java | 2 +- .../entity/EntityTFSlideBlock.java | 3 +- .../entity/EntityTFSnowGuardian.java | 91 +-- .../entity/EntityTFTowerGhast.java | 15 +- .../entity/EntityTFTwilightWandBolt.java | 4 +- .../entity/IBreathAttacker.java | 6 +- .../twilightforest/entity/ITFCharger.java | 4 +- .../twilightforest/entity/TFCreatures.java | 2 +- .../entity/TFEntityEggInfo.java | 6 +- .../entity/ai/EntityAITFBreathAttack.java | 4 +- .../ai/EntityAITFCollideAttackFixed.java | 3 +- .../entity/ai/EntityAITFEatLoose.java | 5 +- .../entity/ai/EntityAITFFindLoose.java | 5 +- .../entity/ai/EntityAITFFlockTarget.java | 5 +- .../entity/ai/EntityAITFFlockToSameKind.java | 3 +- .../ai/EntityAITFGiantAttackOnCollide.java | 2 +- .../entity/ai/EntityAITFHoverBeam.java | 6 +- .../entity/ai/EntityAITFHoverSummon.java | 2 +- .../entity/ai/EntityAITFHoverThenDrop.java | 2 +- .../ai/EntityAITFPanicOnFlockDeath.java | 3 +- .../entity/ai/EntityAITFRedcapBase.java | 4 +- .../entity/ai/EntityAITFThrowRider.java | 3 +- .../entity/ai/EntityTFRavenLookHelper.java | 10 +- .../entity/boss/EntityTFFallingIce.java | 9 +- .../entity/boss/EntityTFHydra.java | 10 +- .../entity/boss/EntityTFHydraMortar.java | 3 +- .../entity/boss/EntityTFIceBomb.java | 3 +- .../entity/boss/EntityTFKnightPhantom.java | 147 ++--- .../entity/boss/EntityTFLich.java | 48 +- .../entity/boss/EntityTFLichBolt.java | 7 +- .../entity/boss/EntityTFLichMinion.java | 1 - .../entity/boss/EntityTFNaga.java | 10 +- .../entity/boss/EntityTFNagaSegment.java | 5 +- .../entity/boss/EntityTFSnowQueen.java | 12 +- .../entity/boss/EntityTFUrGhast.java | 20 +- .../entity/boss/EntityTFUrGhastFireball.java | 3 +- .../entity/boss/EntityTFYetiAlpha.java | 5 +- .../entity/boss/HydraHeadContainer.java | 12 +- .../entity/passive/EntityTFQuestRam.java | 4 +- .../entity/passive/EntityTFTinyBird.java | 16 +- .../inventory/ContainerTFCinderFurnace.java | 8 +- .../inventory/ContainerTFUncrafting.java | 84 +-- .../item/ItemBlockNagastone.java | 2 +- .../item/ItemBlockTFLeaves.java | 2 +- .../twilightforest/item/ItemBlockTFLog.java | 7 +- .../twilightforest/item/ItemBlockTFMeta.java | 6 +- .../twilightforest/item/ItemBlockTFPlant.java | 8 +- .../item/ItemTFArcticArmor.java | 17 +- .../twilightforest/item/ItemTFChainBlock.java | 5 +- .../item/ItemTFCubeOfAnnihilation.java | 2 +- .../twilightforest/item/ItemTFFieryArmor.java | 6 +- .../twilightforest/item/ItemTFFieryPick.java | 2 +- .../twilightforest/item/ItemTFFierySword.java | 3 +- .../twilightforest/item/ItemTFGiantPick.java | 6 +- .../item/ItemTFIronwoodArmor.java | 13 +- .../item/ItemTFIronwoodAxe.java | 2 +- .../item/ItemTFIronwoodPick.java | 2 +- .../item/ItemTFIronwoodShovel.java | 2 +- .../item/ItemTFIronwoodSword.java | 2 +- .../item/ItemTFKnightlyArmor.java | 3 +- .../item/ItemTFKnightlyAxe.java | 9 +- .../item/ItemTFKnightlyPick.java | 9 +- .../item/ItemTFKnightlySword.java | 3 +- .../twilightforest/item/ItemTFMagicBeans.java | 2 +- .../twilightforest/item/ItemTFMagicMap.java | 12 +- .../twilightforest/item/ItemTFMazeMap.java | 10 +- .../item/ItemTFMazebreakerPick.java | 3 +- .../java/twilightforest/item/ItemTFMeta.java | 36 +- .../item/ItemTFMinotaurAxe.java | 11 +- .../item/ItemTFMoonwormQueen.java | 6 +- .../twilightforest/item/ItemTFOreMeter.java | 3 +- .../item/ItemTFPhantomArmor.java | 3 +- .../item/ItemTFScepterLifeDrain.java | 11 +- .../twilightforest/item/ItemTFSpawnEgg.java | 14 +- .../item/ItemTFSteeleafArmor.java | 19 +- .../item/ItemTFSteeleafAxe.java | 2 +- .../item/ItemTFSteeleafPick.java | 3 +- .../item/ItemTFSteeleafShovel.java | 3 +- .../item/ItemTFSteeleafSword.java | 3 +- .../item/ItemTFTransformPowder.java | 2 +- .../twilightforest/item/ItemTFTrophy.java | 6 +- .../item/ItemTFTwilightWand.java | 4 +- .../twilightforest/item/ItemTFYetiArmor.java | 27 +- .../twilightforest/item/ItemTFZombieWand.java | 4 +- .../java/twilightforest/item/TFRecipes.java | 598 ++++++++++++------ .../structures/ComponentTFHedgeMaze.java | 21 +- .../structures/ComponentTFHillMaze.java | 20 +- .../structures/ComponentTFHollowHill.java | 101 +-- .../structures/ComponentTFNagaCourtyard.java | 132 ++-- .../structures/StructureTFComponent.java | 235 +++---- .../StructureTFMajorFeatureStart.java | 11 +- .../ComponentTFDarkTowerBalcony.java | 3 +- .../ComponentTFDarkTowerBossTrap.java | 3 +- .../darktower/ComponentTFDarkTowerBridge.java | 3 +- .../ComponentTFDarkTowerEntrance.java | 3 +- .../darktower/ComponentTFDarkTowerMain.java | 101 ++- .../darktower/ComponentTFDarkTowerRoof.java | 3 +- .../darktower/ComponentTFDarkTowerWing.java | 116 ++-- .../StructureDecoratorDarkTower.java | 2 +- .../ComponentTFFinalCastleBellTower21.java | 2 +- .../ComponentTFFinalCastleBossGazebo.java | 3 +- .../ComponentTFFinalCastleBridge.java | 2 +- .../ComponentTFFinalCastleDamagedTower.java | 4 +- ...ComponentTFFinalCastleDungeonEntrance.java | 2 +- .../ComponentTFFinalCastleDungeonExit.java | 2 +- .../ComponentTFFinalCastleDungeonRoom31.java | 43 +- .../ComponentTFFinalCastleDungeonSteps.java | 18 +- ...onentTFFinalCastleEntranceBottomTower.java | 2 +- ...mponentTFFinalCastleEntranceSideTower.java | 2 +- .../ComponentTFFinalCastleEntranceStairs.java | 3 +- .../ComponentTFFinalCastleEntranceTower.java | 2 +- .../ComponentTFFinalCastleFoundation13.java | 2 +- ...ponentTFFinalCastleFoundation13Thorns.java | 30 +- .../ComponentTFFinalCastleFoundation48.java | 2 +- .../ComponentTFFinalCastleLargeTower.java | 2 +- .../ComponentTFFinalCastleMain.java | 19 +- .../ComponentTFFinalCastleMazeTower13.java | 18 +- .../ComponentTFFinalCastleMural.java | 2 +- .../ComponentTFFinalCastleRoof13Conical.java | 2 +- ...mponentTFFinalCastleRoof13Crenellated.java | 2 +- .../ComponentTFFinalCastleRoof13Peaked.java | 2 +- ...mponentTFFinalCastleRoof48Crenellated.java | 2 +- ...omponentTFFinalCastleRoof9Crenellated.java | 3 +- .../ComponentTFFinalCastleStairTower.java | 2 +- .../ComponentTFFinalCastleWreckedTower.java | 5 +- .../ComponentTFHollowTreeMedBranch.java | 2 +- .../hollowtree/ComponentTFHollowTreeRoot.java | 2 +- .../StructureTFHollowTreeStart.java | 2 +- .../hollowtree/TFHollowTreePieces.java | 7 +- .../icetower/ComponentTFIceTowerBridge.java | 3 +- .../icetower/ComponentTFIceTowerEntrance.java | 3 +- .../icetower/ComponentTFIceTowerMain.java | 5 +- .../icetower/ComponentTFIceTowerStairs.java | 3 +- .../icetower/ComponentTFIceTowerWing.java | 51 +- .../lichtower/ComponentTFTowerBridge.java | 3 +- .../lichtower/ComponentTFTowerMain.java | 53 +- .../lichtower/ComponentTFTowerRoof.java | 64 +- .../lichtower/ComponentTFTowerWing.java | 249 +++----- .../ComponentTFMazeEntranceShaft.java | 4 +- .../minotaurmaze/ComponentTFMazeRoom.java | 4 +- .../ComponentTFMazeUpperEntrance.java | 4 +- .../minotaurmaze/ComponentTFMinotaurMaze.java | 57 +- .../ComponentTFMushroomTowerBridge.java | 2 +- .../ComponentTFMushroomTowerMain.java | 2 +- .../ComponentTFMushroomTowerWing.java | 20 +- .../ComponentTFTowerRoofMushroom.java | 2 +- .../ComponentTFStrongholdAccessChamber.java | 2 +- .../ComponentTFStrongholdAtrium.java | 30 +- .../ComponentTFStrongholdBalconyRoom.java | 2 +- .../ComponentTFStrongholdBossRoom.java | 2 +- .../ComponentTFStrongholdCrossing.java | 2 +- .../ComponentTFStrongholdDeadEnd.java | 2 +- .../ComponentTFStrongholdEntrance.java | 27 +- .../ComponentTFStrongholdFoundry.java | 13 +- .../ComponentTFStrongholdLeftTurn.java | 2 +- .../ComponentTFStrongholdRightTurn.java | 2 +- .../ComponentTFStrongholdSmallHallway.java | 2 +- .../ComponentTFStrongholdSmallStairs.java | 2 +- .../ComponentTFStrongholdTrainingRoom.java | 2 +- ...ComponentTFStrongholdTreasureCorridor.java | 2 +- .../ComponentTFStrongholdTreasureRoom.java | 2 +- .../ComponentTFStrongholdUpperAscender.java | 2 +- .../ComponentTFStrongholdUpperCorridor.java | 2 +- .../ComponentTFStrongholdUpperLeftTurn.java | 2 +- .../ComponentTFStrongholdUpperRightTurn.java | 2 +- ...mponentTFStrongholdUpperTIntersection.java | 2 +- .../StructureTFStrongholdComponent.java | 174 ++--- .../stronghold/TFStrongholdPieces.java | 25 +- .../trollcave/ComponentTFCloudCastle.java | 3 +- .../ComponentTFTrollCaveConnect.java | 37 +- .../trollcave/ComponentTFTrollCaveGarden.java | 3 +- .../trollcave/ComponentTFTrollCaveMain.java | 22 +- .../trollcave/ComponentTFTrollVault.java | 5 +- .../tileentity/TileEntityTFBossSpawner.java | 4 +- .../TileEntityTFCReactorActive.java | 144 ++--- .../tileentity/TileEntityTFCinderFurnace.java | 8 +- .../TileEntityTFGhastTrapActive.java | 10 +- .../TileEntityTFGhastTrapInactive.java | 14 +- .../tileentity/TileEntityTFReverter.java | 65 +- .../tileentity/TileEntityTFTowerBuilder.java | 12 +- .../world/ChunkProviderTwilightForest.java | 48 +- .../world/MapGenTFHollowTree.java | 57 +- .../world/MapGenTFMajorFeature.java | 70 +- .../world/TFGenCanopyMushroom.java | 15 +- .../twilightforest/world/TFGenCanopyTree.java | 15 +- .../java/twilightforest/world/TFGenCaves.java | 20 +- .../world/TFGenFallenSmallLog.java | 28 +- .../world/TFGenLargeRainboak.java | 7 +- .../world/TFGenLargeWinter.java | 22 +- .../world/TFGenMangroveTree.java | 15 +- .../twilightforest/world/TFGenMonolith.java | 17 +- .../twilightforest/world/TFGenRavine.java | 6 +- .../twilightforest/world/TFGenThorns.java | 18 +- .../twilightforest/world/TFGenerator.java | 2 +- .../world/TFWorldChunkManager.java | 27 +- .../world/layer/GenLayerTF7x7Preset.java | 50 +- .../world/layer/GenLayerTFBiomeBorders.java | 4 +- .../world/layer/GenLayerTFBiomeStabilize.java | 4 +- .../world/layer/GenLayerTFBiomes.java | 6 +- .../world/layer/GenLayerTFBiomes1Point7.java | 6 +- .../world/layer/GenLayerTFCheckBad.java | 2 +- .../layer/GenLayerTFCompanionBiomes.java | 4 +- .../world/layer/GenLayerTFFeatureZoom.java | 6 +- .../world/layer/GenLayerTFKeyBiomes.java | 21 +- .../world/layer/GenLayerTFStream.java | 4 +- .../world/layer/GenLayerTFThornBorder.java | 4 +- 307 files changed, 3027 insertions(+), 4041 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index f538f42f15..a2b6436364 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -3,5 +3,5 @@ dependencies { compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev") {transitive = false} - runtimeOnly("com.github.GTNewHorizons:Baubles:1.0.1.14:dev") + runtimeOnly("com.github.GTNewHorizons:Baubles:1.0.1.16:dev") } diff --git a/gradle.properties b/gradle.properties index c6acb4da6c..6d0cfe60f9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,16 +21,27 @@ forgeVersion = 10.13.4.1614 # Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty developmentEnvironmentUserName = Developer -# Define a source file of your project with: +# Enables using modern java syntax (up to version 17) via Jabel, while still targetting JVM 8. +# See https://github.com/bsideup/jabel for details on how this works. +enableModernJavaSyntax = true + +# Enables injecting missing generics into the decompiled source code for a better coding experience +# Turns most publically visible List, Map, etc. into proper List, Map types +enableGenericInjection = true + +# Generate a class with String fields for the mod id, name, version and group name named with the fields below +generateGradleTokenClass = twilightforest.Tags +gradleTokenModId = MODID +gradleTokenModName = MODNAME +gradleTokenVersion = VERSION +gradleTokenGroupName = GROUPNAME +# [DEPRECATED] +# Multiple source files can be defined here by providing a comma-seperated list: Class1.java,Class2.java,Class3.java # public static final String VERSION = "GRADLETOKEN_VERSION"; # The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's # version in @Mod([...], version = VERSION, [...]) # Leave these properties empty to skip individual token replacements -replaceGradleTokenInFile = TwilightForestMod.java -gradleTokenModId = -gradleTokenModName = -gradleTokenVersion = GRADLETOKEN_VERSION -gradleTokenGroupName = +replaceGradleTokenInFile = # In case your mod provides an API for other mods to implement you may declare its package here. Otherwise you can # leave this property empty. diff --git a/src/main/java/twilightforest/CommandTFFeature.java b/src/main/java/twilightforest/CommandTFFeature.java index df30fd1525..e42edb2513 100644 --- a/src/main/java/twilightforest/CommandTFFeature.java +++ b/src/main/java/twilightforest/CommandTFFeature.java @@ -37,16 +37,14 @@ public void processCommand(ICommandSender sender, String[] args) { int dz = MathHelper.floor_double(player.posZ); if (!(player.worldObj.provider instanceof WorldProviderTwilightForest)) { - throw new WrongUsageException("commands.tffeature.not_in_twilight_forest", new Object[0]); + throw new WrongUsageException("commands.tffeature.not_in_twilight_forest"); } else { // nearest feature TFFeature nearbyFeature = ((TFWorldChunkManager) player.worldObj.provider.worldChunkMgr) .getFeatureAt(dx, dz, player.worldObj); sender.addChatMessage( - new ChatComponentTranslation( - "The nearest feature is %s", - new Object[] { nearbyFeature.name })); + new ChatComponentTranslation("The nearest feature is %s", nearbyFeature.name)); // are you in a structure? ChunkProviderTwilightForest chunkProvider = ((WorldProviderTwilightForest) player.worldObj.provider) @@ -59,7 +57,7 @@ public void processCommand(ICommandSender sender, String[] args) { sender.addChatMessage( new ChatComponentTranslation( "Structure conquer flag = %s.", - new Object[] { chunkProvider.isStructureConquered(dx, dy, dz) })); + chunkProvider.isStructureConquered(dx, dy, dz))); // are you in a room? @@ -92,14 +90,14 @@ public void processCommand(ICommandSender sender, String[] args) { TFWorldChunkManager wcm = (TFWorldChunkManager) player.worldObj.provider.worldChunkMgr; boolean fc = wcm.isInFeatureChunk(player.worldObj, dx, dz); - sender.addChatMessage(new ChatComponentTranslation("Center of feature = %s.", new Object[] { cc })); - sender.addChatMessage(new ChatComponentTranslation("Are in feature chunk = %s.", new Object[] { fc })); + sender.addChatMessage(new ChatComponentTranslation("Center of feature = %s.", cc)); + sender.addChatMessage(new ChatComponentTranslation("Are in feature chunk = %s.", fc)); } else { - throw new WrongUsageException("commands.tffeature.usage", new Object[0]); + throw new WrongUsageException("commands.tffeature.usage"); } } else { - throw new WrongUsageException("commands.tffeature.usage", new Object[0]); + throw new WrongUsageException("commands.tffeature.usage"); } } @@ -112,7 +110,7 @@ private void changeStructureActivity(ICommandSender sender, boolean flag) throws int dz = MathHelper.floor_double(player.posZ); if (!(player.worldObj.provider instanceof WorldProviderTwilightForest)) { - throw new WrongUsageException("commands.tffeature.not_in_twilight_forest", new Object[0]); + throw new WrongUsageException("commands.tffeature.not_in_twilight_forest"); } else { // are you in a structure? ChunkProviderTwilightForest chunkProvider = ((WorldProviderTwilightForest) player.worldObj.provider) @@ -122,7 +120,8 @@ private void changeStructureActivity(ICommandSender sender, boolean flag) throws sender.addChatMessage( new ChatComponentTranslation( "Structure conquer flag was %s. Changing to %s.", - new Object[] { chunkProvider.isStructureConquered(dx, dy, dz), flag })); + chunkProvider.isStructureConquered(dx, dy, dz), + flag)); chunkProvider.setStructureConquered(dx, dy, dz, flag); } else { diff --git a/src/main/java/twilightforest/CommandTFProgress.java b/src/main/java/twilightforest/CommandTFProgress.java index 9f6a60677f..1e8aaf0b8c 100644 --- a/src/main/java/twilightforest/CommandTFProgress.java +++ b/src/main/java/twilightforest/CommandTFProgress.java @@ -33,7 +33,7 @@ public int getRequiredPermissionLevel() { @Override public void processCommand(ICommandSender sender, String[] args) { if (args.length < 2) { - throw new WrongUsageException("tfprogress ", new Object[0]); + throw new WrongUsageException("tfprogress "); } else { EntityPlayerMP player = getPlayer(sender, args[0]); int bossIndex = getBossIndex(args[1]); @@ -42,7 +42,8 @@ public void processCommand(ICommandSender sender, String[] args) { sender, this, "Setting player %s progress to past boss %s.", - new Object[] { player.getCommandSenderName(), bosses[bossIndex] }); + player.getCommandSenderName(), + bosses[bossIndex]); setProgress(player, bossIndex); } @@ -59,47 +60,34 @@ private void setProgress(EntityPlayerMP player, int bossIndex) { // give achievements switch (bossIndex) { - case 0: - default: - break; - case 1: + case 1 -> { player.triggerAchievement(TFAchievementPage.twilightPortal); player.triggerAchievement(TFAchievementPage.twilightArrival); player.triggerAchievement(TFAchievementPage.twilightHunter); player.triggerAchievement(TFAchievementPage.twilightKillNaga); player.triggerAchievement(TFAchievementPage.twilightProgressNaga); - break; - case 2: + } + case 2 -> { player.triggerAchievement(TFAchievementPage.twilightKillLich); player.triggerAchievement(TFAchievementPage.twilightProgressLich); - break; - case 3: - player.triggerAchievement(TFAchievementPage.twilightProgressLabyrinth); - break; - case 4: + } + case 3 -> player.triggerAchievement(TFAchievementPage.twilightProgressLabyrinth); + case 4 -> { player.triggerAchievement(TFAchievementPage.twilightKillHydra); player.triggerAchievement(TFAchievementPage.twilightProgressHydra); - break; - case 5: + } + case 5 -> { player.triggerAchievement(TFAchievementPage.twilightProgressTrophyPedestal); player.triggerAchievement(TFAchievementPage.twilightProgressKnights); - break; - case 6: - player.triggerAchievement(TFAchievementPage.twilightProgressUrghast); - break; - case 7: - player.triggerAchievement(TFAchievementPage.twilightProgressYeti); - break; - case 8: - player.triggerAchievement(TFAchievementPage.twilightProgressGlacier); - break; - case 9: - player.triggerAchievement(TFAchievementPage.twilightProgressTroll); - break; - case 10: + } + case 6 -> player.triggerAchievement(TFAchievementPage.twilightProgressUrghast); + case 7 -> player.triggerAchievement(TFAchievementPage.twilightProgressYeti); + case 8 -> player.triggerAchievement(TFAchievementPage.twilightProgressGlacier); + case 9 -> player.triggerAchievement(TFAchievementPage.twilightProgressTroll); + case 10 -> { player.triggerAchievement(TFAchievementPage.twilightProgressThorns); player.triggerAchievement(TFAchievementPage.twilightProgressCastle); - break; + } } } @@ -116,7 +104,7 @@ private int getBossIndex(String string) { /** * Adds the strings available in this command to the given list of tab completion options. */ - public List addTabCompletionOptions(ICommandSender sender, String[] args) { + public List addTabCompletionOptions(ICommandSender sender, String[] args) { return args.length == 1 ? getListOfStringsMatchingLastWord(args, this.getListOfPlayers()) : (args.length == 2 ? getListOfStringsMatchingLastWord(args, bosses) : null); } diff --git a/src/main/java/twilightforest/TFAchievementPage.java b/src/main/java/twilightforest/TFAchievementPage.java index 9c3b066df3..346070bbff 100644 --- a/src/main/java/twilightforest/TFAchievementPage.java +++ b/src/main/java/twilightforest/TFAchievementPage.java @@ -15,7 +15,7 @@ public class TFAchievementPage extends net.minecraftforge.common.AchievementPage -2, 1, TFBlocks.portal, - (Achievement) null)).setSpecial().registerStat(); + null)).setSpecial().registerStat(); public static Achievement twilightArrival = (new Achievement( TwilightForestMod.ID + 2, "twilightArrival", diff --git a/src/main/java/twilightforest/TFEventListener.java b/src/main/java/twilightforest/TFEventListener.java index 19445d0f14..980500860c 100644 --- a/src/main/java/twilightforest/TFEventListener.java +++ b/src/main/java/twilightforest/TFEventListener.java @@ -68,7 +68,7 @@ */ public class TFEventListener { - protected HashMap playerKeepsMap = new HashMap(); + protected HashMap playerKeepsMap = new HashMap<>(); private boolean isBreakingWithGiantPick = false; private boolean shouldMakeGiantCobble = false; private int amountOfCobbleToReplace = 0; @@ -93,21 +93,11 @@ public void pickupItem(EntityItemPickupEvent event) { // trophy gives kill achievement } else if (item == TFItems.trophy) { switch (event.item.getEntityItem().getItemDamage()) { - case 0: - event.entityPlayer.triggerAchievement(TFAchievementPage.twilightKillHydra); - break; - case 1: - event.entityPlayer.triggerAchievement(TFAchievementPage.twilightKillNaga); - break; - case 2: - event.entityPlayer.triggerAchievement(TFAchievementPage.twilightKillLich); - break; - case 3: - event.entityPlayer.triggerAchievement(TFAchievementPage.twilightProgressUrghast); - break; - case 4: - event.entityPlayer.triggerAchievement(TFAchievementPage.twilightProgressGlacier); - break; + case 0 -> event.entityPlayer.triggerAchievement(TFAchievementPage.twilightKillHydra); + case 1 -> event.entityPlayer.triggerAchievement(TFAchievementPage.twilightKillNaga); + case 2 -> event.entityPlayer.triggerAchievement(TFAchievementPage.twilightKillLich); + case 3 -> event.entityPlayer.triggerAchievement(TFAchievementPage.twilightProgressUrghast); + case 4 -> event.entityPlayer.triggerAchievement(TFAchievementPage.twilightProgressGlacier); } // mazebreaker } else if (item == TFItems.mazebreakerPick) { @@ -258,8 +248,8 @@ public void harvestDrops(HarvestDropsEvent event) { if (event.harvester != null && event.harvester.inventory.getCurrentItem() != null && event.harvester.inventory.getCurrentItem().getItem().func_150897_b(event.block)) { if (event.harvester.inventory.getCurrentItem().getItem() == TFItems.fieryPick) { - ArrayList removeThese = new ArrayList(1); - ArrayList addThese = new ArrayList(1); + ArrayList removeThese = new ArrayList<>(1); + ArrayList addThese = new ArrayList<>(1); for (ItemStack input : event.drops) { // does it smelt? @@ -496,9 +486,8 @@ public void bonemealUsed(BonemealEvent event) { */ @SubscribeEvent public void livingDies(LivingDeathEvent event) { - if (event.entityLiving instanceof EntityPlayer + if (event.entityLiving instanceof EntityPlayer player && !event.entityLiving.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) { - EntityPlayer player = (EntityPlayer) event.entityLiving; // TODO: Add support for keeping Bauble slot items on all tiers if (player.inventory.consumeInventoryItem(TFItems.charmOfKeeping3)) { @@ -749,8 +738,7 @@ && isBlockProtectedFromBreaking(event.world, event.x, event.y, event.z)) { && blockThere == event.block && metaThere == event.blockMetadata) { // try to break that block too! - if (event.getPlayer() instanceof EntityPlayerMP) { - EntityPlayerMP playerMP = (EntityPlayerMP) event.getPlayer(); + if (event.getPlayer() instanceof EntityPlayerMP playerMP) { playerMP.theItemInWorldManager.tryHarvestBlock(bx + dx, by + dy, bz + dz); } @@ -999,7 +987,7 @@ public void worldLoaded(WorldEvent.Load event) { public void commandSent(CommandEvent event) { if (event.command instanceof CommandGameRule && event.parameters.length > 1 && TwilightForestMod.ENFORCED_PROGRESSION_RULE.equals(event.parameters[0])) { - boolean isEnforced = Boolean.valueOf(event.parameters[1]); + boolean isEnforced = Boolean.parseBoolean(event.parameters[1]); TwilightForestMod.genericChannel .sendToAll(TFGenericPacketHandler.makeEnforcedProgressionStatusPacket(isEnforced)); } diff --git a/src/main/java/twilightforest/TFFeature.java b/src/main/java/twilightforest/TFFeature.java index 43c296e0ed..243a2725c1 100644 --- a/src/main/java/twilightforest/TFFeature.java +++ b/src/main/java/twilightforest/TFFeature.java @@ -4,7 +4,7 @@ import java.util.List; import java.util.Random; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.monster.EntityBlaze; import net.minecraft.entity.monster.EntityCaveSpider; @@ -100,7 +100,7 @@ public class TFFeature { public static final TFFeature finalCastle = new TFFeature(19, 3, "Final Castle"); public static final TFFeature mushroomTower = new TFFeature(20, 2, "Mushroom Tower"); - ArrayList emptyList = new ArrayList(); + ArrayList emptyList = new ArrayList<>(); static { // spawn lists! @@ -226,9 +226,9 @@ public TFFeature(int parID, int parSize, String parName) { this.areChunkDecorationsEnabled = false; this.isStructureEnabled = true; this.isTerrainAltered = false; - this.spawnableMonsterLists = new ArrayList>(); - this.ambientCreatureList = new ArrayList(); - this.waterCreatureList = new ArrayList(); + this.spawnableMonsterLists = new ArrayList<>(); + this.ambientCreatureList = new ArrayList<>(); + this.waterCreatureList = new ArrayList<>(); this.hasProtectionAura = true; ambientCreatureList.add(new SpawnListEntry(EntityBat.class, 10, 8, 8)); @@ -258,20 +258,19 @@ public TFFeature disableProtectionAura() { } // Add a monster to spawn list 0 - public TFFeature addMonster(Class monsterClass, int weight, int minGroup, - int maxGroup) { + public TFFeature addMonster(Class monsterClass, int weight, int minGroup, int maxGroup) { this.addMonster(0, monsterClass, weight, minGroup, maxGroup); return this; } // Add a monster to a specific spawn list - public TFFeature addMonster(int listIndex, Class monsterClass, int weight, int minGroup, + public TFFeature addMonster(int listIndex, Class monsterClass, int weight, int minGroup, int maxGroup) { List monsterList; if (this.spawnableMonsterLists.size() > listIndex) { monsterList = this.spawnableMonsterLists.get(listIndex); } else { - monsterList = new ArrayList(); + monsterList = new ArrayList<>(); this.spawnableMonsterLists.add(listIndex, monsterList); } @@ -280,7 +279,7 @@ public TFFeature addMonster(int listIndex, Class mon } // Add a water creature - public TFFeature addWaterCreature(Class monsterClass, int weight, int minGroup, + public TFFeature addWaterCreature(Class monsterClass, int weight, int minGroup, int maxGroup) { this.waterCreatureList.add(new SpawnListEntry(monsterClass, weight, minGroup, maxGroup)); return this; @@ -289,8 +288,7 @@ public TFFeature addWaterCreature(Class monsterClass // @return The type of feature directly at the specified Chunk coordinates public static TFFeature getFeatureDirectlyAt(int chunkX, int chunkZ, World world) { - if (world != null && world.getWorldChunkManager() instanceof TFWorldChunkManager) { - TFWorldChunkManager tfManager = (TFWorldChunkManager) world.getWorldChunkManager(); + if (world != null && world.getWorldChunkManager() instanceof TFWorldChunkManager tfManager) { if (tfManager.isInFeatureChunk(world, chunkX << 4, chunkZ << 4)) { return tfManager.getFeatureAt(chunkX << 4, chunkZ << 4, world); @@ -368,32 +366,15 @@ public static TFFeature generateFeatureForOldMapGen(int chunkX, int chunkZ, Worl } // okay, well that takes care of most special cases - switch (randnum) { - default: - case 0: // oops, I forgot about zero for a long time, now there are too many hill 1s - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - return hill1; - case 7: - case 8: - case 9: - return hill2; - case 10: - return hill3; - case 11: - case 12: - return hedgeMaze; - case 13: - return (biomeAt != TFBiomeBase.tfSwamp) ? nagaCourtyard : hydraLair; // hydra in the swamp, naga - // everywhere else - case 14: - case 15: - return lichTower; - } + return switch (randnum) { // oops, I forgot about zero for a long time, now there are too many hill 1s + default -> hill1; + case 7, 8, 9 -> hill2; + case 10 -> hill3; + case 11, 12 -> hedgeMaze; + case 13 -> (biomeAt != TFBiomeBase.tfSwamp) ? nagaCourtyard : hydraLair; // hydra in the swamp, naga + // everywhere else + case 14, 15 -> lichTower; + }; } public static TFFeature generateFeatureFor1Point7(int chunkX, int chunkZ, World world) { @@ -476,31 +457,14 @@ public static TFFeature generateFeatureFor1Point7(int chunkX, int chunkZ, World } // okay, well that takes care of most special cases - switch (randnum) { - default: - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - return hill1; - case 6: - case 7: - case 8: - return hill2; - case 9: - return hill3; - case 10: - case 11: - return hedgeMaze; - case 12: - case 13: - return nagaCourtyard; - case 14: - case 15: - return lichTower; - } + return switch (randnum) { + default -> hill1; + case 6, 7, 8 -> hill2; + case 9 -> hill3; + case 10, 11 -> hedgeMaze; + case 12, 13 -> nagaCourtyard; + case 14, 15 -> lichTower; + }; } /** @@ -662,16 +626,12 @@ private static ChunkCoordinates getNearestCenterXYZOld(int cx, int cz, World wor // Returns a list of hostile monsters. Are we ever going to need passive or water creatures? public List getSpawnableList(EnumCreatureType creatureType) { - switch (creatureType) { - case monster: - return this.getSpawnableList(EnumCreatureType.monster, 0); - case ambient: - return this.ambientCreatureList; - case waterCreature: - return this.waterCreatureList; - default: - return emptyList; - } + return switch (creatureType) { + case monster -> this.getSpawnableList(EnumCreatureType.monster, 0); + case ambient -> this.ambientCreatureList; + case waterCreature -> this.waterCreatureList; + default -> emptyList; + }; } // Returns a list of hostile monsters in the specified indexed category diff --git a/src/main/java/twilightforest/TFMagicMapData.java b/src/main/java/twilightforest/TFMagicMapData.java index 7f59abf51a..d81db470b8 100644 --- a/src/main/java/twilightforest/TFMagicMapData.java +++ b/src/main/java/twilightforest/TFMagicMapData.java @@ -12,7 +12,7 @@ public class TFMagicMapData extends MapData { private static final int FEATURE_DATA_BYTE = 18; - public List featuresVisibleOnMap = new ArrayList(); + public List featuresVisibleOnMap = new ArrayList<>(); public TFMagicMapData(String par1Str) { super(par1Str); @@ -92,13 +92,12 @@ public void checkExistingFeatures(World world) { int worldX = (coord.centerX << this.scale - 1) + this.xCenter; int worldZ = (coord.centerZ << this.scale - 1) + this.zCenter; - if (world != null && world.getWorldChunkManager() instanceof TFWorldChunkManager) { - TFWorldChunkManager tfManager = (TFWorldChunkManager) world.getWorldChunkManager(); + if (world != null && world.getWorldChunkManager() instanceof TFWorldChunkManager tfManager) { coord.iconSize = (byte) tfManager.getFeatureID(worldX, worldZ, world); if (coord.iconSize == 0) { if (toRemove == null) { - toRemove = new ArrayList(); + toRemove = new ArrayList<>(); } toRemove.add(coord); } diff --git a/src/main/java/twilightforest/TFTeleporter.java b/src/main/java/twilightforest/TFTeleporter.java index d34924c5b0..c9ab9ecb90 100644 --- a/src/main/java/twilightforest/TFTeleporter.java +++ b/src/main/java/twilightforest/TFTeleporter.java @@ -96,9 +96,7 @@ private ChunkCoordinates findSafeCoords(int range, int x, int z, Entity entity) boolean isSafeBiomeAt(int x, int z, Entity entity) { BiomeGenBase biomeAt = myWorld.getBiomeGenForCoords(x, z); - if (biomeAt instanceof TFBiomeBase && entity instanceof EntityPlayerMP) { - TFBiomeBase tfBiome = (TFBiomeBase) biomeAt; - EntityPlayerMP player = (EntityPlayerMP) entity; + if (biomeAt instanceof TFBiomeBase tfBiome && entity instanceof EntityPlayerMP player) { return tfBiome.doesPlayerHaveRequiredAchievement(player); diff --git a/src/main/java/twilightforest/TFTickHandler.java b/src/main/java/twilightforest/TFTickHandler.java index 907fc0f74e..f49b1e72a9 100644 --- a/src/main/java/twilightforest/TFTickHandler.java +++ b/src/main/java/twilightforest/TFTickHandler.java @@ -123,8 +123,7 @@ private void checkBiomeForProgression(EntityPlayer player, World world) { BiomeGenBase currentBiome = world .getBiomeGenForCoords(MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posZ)); - if (currentBiome instanceof TFBiomeBase) { - TFBiomeBase tfBiome = (TFBiomeBase) currentBiome; + if (currentBiome instanceof TFBiomeBase tfBiome) { boolean dangerousBiome = !tfBiome.doesPlayerHaveRequiredAchievement(player); if (dangerousBiome) { diff --git a/src/main/java/twilightforest/TFTreasure.java b/src/main/java/twilightforest/TFTreasure.java index ef03b7275e..f4d2580070 100644 --- a/src/main/java/twilightforest/TFTreasure.java +++ b/src/main/java/twilightforest/TFTreasure.java @@ -185,65 +185,55 @@ protected void fill(int i) { useless.add(new ItemStack(Items.dye, 1, 0)); switch (i) { - case 1: + case 1 -> { // hill type 1 chest common.add(Items.iron_ingot, 4); common.add(Items.wheat, 4); common.add(Items.string, 4); common.add(Items.bucket, 1); - uncommon.add(Items.bread, 1); uncommon.add(TFItems.oreMagnet, 1); uncommon.add(Items.gunpowder, 4); uncommon.add(Items.arrow, 12); uncommon.add(Blocks.torch, 12); - rare.add(Items.gold_ingot, 3); rare.add(Items.iron_pickaxe, 1); rare.add(TFItems.liveRoot, 3); - ultrarare.add(TFItems.transformPowder, 12); ultrarare.add(Items.diamond, 1); ultrarare.add(TFItems.steeleafIngot, 3); - break; - case 2: + } + case 2 -> { // hill type 2 chest common.add(Items.iron_ingot, 4); common.add(Items.carrot, 4); common.add(Blocks.ladder, 6); common.add(Items.bucket, 1); - uncommon.add(Items.baked_potato, 2); uncommon.add(TFItems.oreMagnet, 1); uncommon.add(TFItems.ironwoodIngot, 4); uncommon.add(Items.arrow, 12); uncommon.add(Blocks.torch, 12); - rare.add(TFItems.nagaScale, 1); - if (!Loader.isModLoaded("dreamcraft")) rare.add(TFBlocks.uncraftingTable, 1); - rare.add(TFItems.transformPowder, 12); - ultrarare.add(TFItems.peacockFan, 1); ultrarare.add(Items.emerald, 6); ultrarare.add(Items.diamond, 1); ultrarare.add(TFItems.charmOfLife1, 1); - break; - case 3: + } + case 3 -> { // hill type 3 chest common.add(Items.gold_nugget, 9); common.add(Items.potato, 4); common.add(Items.fish, 4); common.add(TFItems.torchberries, 5); - uncommon.add(Items.pumpkin_pie, 1); uncommon.add(TFItems.oreMagnet, 1); uncommon.add(Items.gunpowder, 4); uncommon.add(Items.arrow, 12); uncommon.add(Blocks.torch, 12); uncommon.add(TFItems.steeleafIngot, 4); - rare.add(TFItems.nagaScale, 1); rare.addEnchanted( new ItemStack(TFItems.ironwoodPick, 1), @@ -252,14 +242,13 @@ protected void fill(int i) { Enchantment.fortune, 1); rare.add(TFItems.transformPowder, 12); - ultrarare.add(TFItems.moonwormQueen, 1); ultrarare.add(TFBlocks.sapling, 1, 4); ultrarare.add(Items.diamond, 2); ultrarare.add(TFItems.charmOfLife1, 1); ultrarare.add(TFItems.charmOfKeeping1, 1); - break; - case 4: + } + case 4 -> { // hedge maze chest common.add(Blocks.planks, 4); common.add(Blocks.brown_mushroom, 4); @@ -267,35 +256,30 @@ protected void fill(int i) { common.add(Items.wheat, 4); common.add(Items.string, 4); common.add(Items.stick, 6); - uncommon.add(Items.melon, 4); uncommon.add(Items.melon_seeds, 4); uncommon.add(Items.pumpkin_seeds, 4); uncommon.add(Items.arrow, 12); uncommon.add(TFBlocks.firefly, 4); - rare.add(Blocks.web, 3); rare.add(Items.shears, 1); rare.add(Items.saddle, 1); rare.add(Items.bow, 1); rare.add(Items.apple, 2); - ultrarare.add(Items.diamond_hoe, 1); ultrarare.add(Items.diamond, 1); ultrarare.add(Items.mushroom_stew, 1); ultrarare.add(Items.golden_apple, 1); - break; - case 5: + } + case 5 -> { // labyrinth room chest useless.clear(); - common.add(Items.iron_ingot, 4); common.add(TFItems.mazeWafer, 12); common.add(Items.gunpowder, 4); common.add(TFItems.ironwoodIngot, 4); common.add(TFBlocks.firefly, 5); common.add(Items.milk_bucket, 1); - uncommon.add(TFItems.steeleafIngot, 6); uncommon.add(TFItems.steeleafLegs, 1); uncommon.add(TFItems.steeleafPlate, 1); @@ -305,12 +289,11 @@ protected void fill(int i) { uncommon.add(TFItems.ironwoodPlate, 1); uncommon.add(TFItems.ironwoodSword, 1); uncommon.add(TFItems.charmOfKeeping1, 1); - rare.add(TFItems.mazeMapFocus, 1); rare.add(Blocks.tnt, 3); rare.add(new ItemStack(Items.potionitem, 1, 16373)); // health ii - break; - case 6: + } + case 6 -> { // labyrinth dead end chest common.add(Items.stick, 12); common.add(Items.coal, 12); @@ -319,19 +302,17 @@ protected void fill(int i) { common.add(Items.paper, 12); common.add(Items.leather, 4); common.add(Items.mushroom_stew, 1); - uncommon.add(Items.milk_bucket, 1); uncommon.add(Items.paper, 5); uncommon.add(Items.iron_ingot, 6); uncommon.add(TFItems.ironwoodIngot, 8); uncommon.add(TFBlocks.firefly, 5); uncommon.add(TFItems.charmOfKeeping1, 1); - rare.add(TFItems.steeleafIngot, 8); rare.add(Items.golden_apple, 1); rare.add(Items.blaze_rod, 2); - break; - case 7: + } + case 7 -> { // wizards tower treasure room chest common.add(Items.glass_bottle, 6); common.add(new ItemStack(Items.potionitem, 1, 0)); @@ -343,14 +324,12 @@ protected void fill(int i) { common.add(Items.speckled_melon, 2); common.add(Items.blaze_powder, 3); common.add(Items.paper, 6); - uncommon.addRandomEnchanted(Items.golden_sword, 10); uncommon.addRandomEnchanted(Items.golden_boots, 7); uncommon.add(new ItemStack(Items.potionitem, 1, 16274)); // swiftness uncommon.add(new ItemStack(Items.potionitem, 1, 16341)); // healing uncommon.add(new ItemStack(Items.potionitem, 1, 16307)); // fire resist uncommon.add(new ItemStack(Items.potionitem, 1, 16348)); // harm - rare.addRandomEnchanted(Items.golden_helmet, 18); rare.add(new ItemStack(Items.potionitem, 1, 16306)); // swiftness ii rare.add(new ItemStack(Items.potionitem, 1, 16305)); // regen ii @@ -359,15 +338,14 @@ protected void fill(int i) { rare.add(TFItems.transformPowder, 12); rare.add(TFItems.charmOfLife1, 1); rare.add(TFItems.charmOfKeeping1, 1); - ultrarare.addRandomEnchanted(Items.golden_axe, 20); ultrarare.add(Items.ender_pearl, 1); ultrarare.add(Blocks.obsidian, 4); ultrarare.add(Items.diamond, 1); ultrarare.add(TFItems.moonwormQueen, 1); ultrarare.add(TFItems.peacockFan, 1); - break; - case 8: + } + case 8 -> { // wizards tower library chest common.add(Items.glass_bottle, 6); common.add(new ItemStack(Items.potionitem, 1, 0)); @@ -376,7 +354,6 @@ protected void fill(int i) { common.add(Items.bone, 6); common.add(Items.gold_nugget, 6); common.add(Items.clay_ball, 12); - uncommon.addRandomEnchanted(Items.iron_leggings, 5); uncommon.add(Items.fire_charge, 3); uncommon.add(Items.book, 5); @@ -384,7 +361,6 @@ protected void fill(int i) { uncommon.add(new ItemStack(Items.potionitem, 1, 16)); uncommon.add(new ItemStack(Items.potionitem, 1, 16276)); // poison uncommon.add(new ItemStack(Items.potionitem, 1, 16312)); // weakness - rare.addRandomEnchanted(Items.bow, 5); rare.addRandomEnchanted(Items.stone_sword, 10); rare.addRandomEnchanted(Items.wooden_sword, 15); @@ -394,15 +370,14 @@ protected void fill(int i) { rare.add(new ItemStack(Items.potionitem, 1, 16370)); // extended swiftness ii rare.add(TFItems.transformPowder, 12); rare.add(TFItems.charmOfKeeping1, 1); - ultrarare.addRandomEnchanted(Items.golden_pickaxe, 10); ultrarare.addRandomEnchanted(Items.iron_sword, 20); ultrarare.addRandomEnchanted(Items.bow, 30); ultrarare.add(Blocks.bookshelf, 5); ultrarare.add(Items.ender_pearl, 2); ultrarare.add(Items.experience_bottle, 6); - break; - case 9: + } + case 9 -> { // basement treasure cache, mostly full of food! common.add(new ItemStack(Items.potionitem, 1, 0)); common.add(Items.rotten_flesh, 6); @@ -416,29 +391,25 @@ protected void fill(int i) { common.add(Items.mushroom_stew, 1); common.add(Items.milk_bucket, 1); common.add(Items.melon_seeds, 5); - uncommon.add(Items.bread, 8); uncommon.add(Items.cooked_beef, 6); uncommon.add(Items.cooked_porkchop, 8); uncommon.add(Items.baked_potato, 8); uncommon.add(Items.cooked_chicken, 10); uncommon.add(Items.cooked_fished, 8); - rare.add(Items.speckled_melon, 12); rare.add(Items.apple, 12); rare.add(Items.map, 1); rare.add(TFItems.charmOfKeeping1, 1); - ultrarare.add(Items.golden_apple, 2); ultrarare.add(Items.golden_carrot, 2); ultrarare.add(Items.cake, 1); ultrarare.add(Items.boat, 1); ultrarare.add(new ItemStack(TFBlocks.sapling, 1, 4)); - break; - case 10: + } + case 10 -> { // labyrinth vault chest useless.clear(); - common.add(Items.iron_ingot, 9); common.add(Items.emerald, 5); common.add(TFItems.mazeWafer, 12); @@ -446,7 +417,6 @@ protected void fill(int i) { common.add(new ItemStack(Items.potionitem, 1, 16369)); // regen ii common.add(new ItemStack(Items.potionitem, 1, 16373)); // health ii common.add(new ItemStack(Items.potionitem, 1, 16370)); // extended swiftness ii - uncommon.addEnchanted(new ItemStack(Items.bow), Enchantment.infinity, 1, Enchantment.punch, 2); uncommon.addEnchanted(new ItemStack(Items.bow), Enchantment.power, 3, Enchantment.flame, 1); uncommon.addEnchanted( @@ -461,7 +431,6 @@ protected void fill(int i) { uncommon.addEnchanted(new ItemStack(TFItems.steeleafLegs), Enchantment.fireProtection, 4); uncommon.addEnchanted(new ItemStack(TFItems.steeleafBoots), Enchantment.protection, 2); uncommon.addEnchanted(new ItemStack(TFItems.steeleafHelm), Enchantment.respiration, 3); - rare.add(Blocks.emerald_block, 1); rare.add(Blocks.ender_chest, 1); rare.addEnchanted( @@ -490,8 +459,8 @@ protected void fill(int i) { 3, Enchantment.fortune, 2); - break; - case 11: + } + case 11 -> { // dark tower regular treasure cache, contains supplies common.add(Items.stick, 12); common.add(new ItemStack(Items.coal, 12, 1)); @@ -499,21 +468,18 @@ protected void fill(int i) { common.add(TFItems.experiment115, 9); common.add(new ItemStack(Blocks.wool, 1, 14)); common.add(Items.redstone, 6); - uncommon.add(Blocks.redstone_lamp, 3); uncommon.add(Items.iron_ingot, 6); uncommon.add(TFItems.ironwoodIngot, 8); uncommon.add(TFBlocks.firefly, 5); uncommon.add(TFItems.charmOfKeeping1, 1); - rare.add(TFItems.steeleafIngot, 8); rare.add(Items.diamond, 2); - break; - case 12: + } + case 12 -> { // dark tower key treasure chest, contains higher quality treasure // key will be added seperately useless.clear(); - common.add(Items.iron_ingot, 4); common.add(TFItems.experiment115, 12); common.add(Items.gunpowder, 4); @@ -521,7 +487,6 @@ protected void fill(int i) { common.add(TFBlocks.firefly, 5); common.add(Items.redstone, 12); common.add(Items.glowstone_dust, 12); - uncommon.add(TFItems.steeleafIngot, 6); uncommon.add(TFItems.steeleafLegs, 1); uncommon.add(TFItems.steeleafPlate, 1); @@ -531,21 +496,19 @@ protected void fill(int i) { uncommon.add(TFItems.ironwoodPlate, 1); uncommon.add(TFItems.ironwoodSword, 1); uncommon.add(TFItems.charmOfKeeping1, 1); - rare.add(TFItems.charmOfLife1, 1); rare.addEnchantedBook(Enchantment.featherFalling, 3); rare.addEnchantedBook(Enchantment.knockback, 2); rare.addEnchantedBook(Enchantment.efficiency, 3); - break; - case 13: + } + case 13 -> { // dark tower boss treasure useless.clear(); - common.add(TFItems.carminite, 3); uncommon.add(TFItems.fieryTears, 5); rare.add(new ItemStack(TFItems.trophy, 1, 3)); - break; - case 14: + } + case 14 -> { // tree branch treasure cache, food and saplings common.add(Items.poisonous_potato, 2); common.add(Items.wheat, 6); @@ -555,25 +518,22 @@ protected void fill(int i) { common.add(Items.water_bucket, 1); common.add(Items.milk_bucket, 1); common.add(Items.melon_seeds, 5); - uncommon.add(new ItemStack(TFBlocks.firefly, 12)); uncommon.add(new ItemStack(TFBlocks.sapling, 4, 0)); uncommon.add(new ItemStack(TFBlocks.sapling, 4, 1)); uncommon.add(new ItemStack(TFBlocks.sapling, 4, 2)); uncommon.add(new ItemStack(TFBlocks.sapling, 4, 3)); - rare.add(Items.pumpkin_pie, 12); rare.add(Items.apple, 12); rare.add(TFItems.charmOfLife1, 1); rare.add(TFItems.charmOfKeeping1, 1); - ultrarare.add(new ItemStack(TFBlocks.sapling, 1, 4)); ultrarare.add(new ItemStack(TFBlocks.sapling, 1, 5)); ultrarare.add(new ItemStack(TFBlocks.sapling, 1, 6)); ultrarare.add(new ItemStack(TFBlocks.sapling, 1, 7)); ultrarare.add(new ItemStack(TFBlocks.sapling, 1, 8)); - break; - case 15: + } + case 15 -> { // stronghold regular treasure cache, contains supplies common.add(Items.stick, 12); common.add(new ItemStack(Items.coal, 12)); @@ -581,20 +541,17 @@ protected void fill(int i) { common.add(TFItems.mazeWafer, 9); common.add(new ItemStack(Blocks.wool, 1, 11)); common.add(Items.iron_ingot, 2); - uncommon.add(Items.bucket, 1); uncommon.add(Items.iron_ingot, 6); uncommon.add(TFItems.ironwoodIngot, 6); uncommon.add(TFBlocks.firefly, 5); uncommon.add(TFItems.charmOfKeeping1, 1); uncommon.add(TFItems.armorShard, 3); - rare.add(TFItems.knightMetal, 8); rare.addRandomEnchanted(Items.bow, 20); rare.addRandomEnchanted(Items.iron_sword, 20); rare.addRandomEnchanted(TFItems.ironwoodSword, 15); rare.addRandomEnchanted(TFItems.steeleafSword, 10); - ultrarare.addEnchantedBook(Enchantment.baneOfArthropods, 4); ultrarare.addEnchantedBook(Enchantment.sharpness, 4); ultrarare.addEnchantedBook(Enchantment.smite, 4); @@ -603,18 +560,16 @@ protected void fill(int i) { ultrarare.addEnchantedBook(Enchantment.protection, 3); ultrarare.addEnchantedBook(Enchantment.projectileProtection, 3); ultrarare.addEnchantedBook(Enchantment.featherFalling, 3); - break; - case 16: + } + case 16 -> { // stronghold treasure room chest - kinda rare useless.clear(); - common.add(Items.iron_ingot, 4); common.add(TFItems.mazeWafer, 12); common.add(Items.gunpowder, 4); common.add(TFItems.ironwoodIngot, 4); common.add(TFBlocks.firefly, 5); common.add(Items.milk_bucket, 1); - uncommon.add(TFItems.steeleafIngot, 6); uncommon.add(TFItems.steeleafLegs, 1); uncommon.add(TFItems.steeleafPlate, 1); @@ -624,18 +579,16 @@ protected void fill(int i) { uncommon.add(TFItems.ironwoodPlate, 1); uncommon.add(TFItems.ironwoodSword, 1); uncommon.add(TFItems.charmOfLife1, 1); - rare.add(TFItems.mazeMapFocus, 1); rare.addRandomEnchanted(Items.bow, 30); rare.addRandomEnchanted(Items.iron_sword, 30); rare.addRandomEnchanted(TFItems.ironwoodSword, 25); rare.addRandomEnchanted(TFItems.steeleafSword, 20); rare.addRandomEnchanted(Items.diamond_sword, 15); - break; - case 17: + } + case 17 -> { // stronghold boss treasure useless.clear(); - common.addRandomEnchanted(TFItems.knightlySword, 20); common.addRandomEnchanted(TFItems.knightlyPick, 20); common.addRandomEnchanted(TFItems.knightlyAxe, 20); @@ -643,8 +596,8 @@ protected void fill(int i) { uncommon.addRandomEnchanted(TFItems.phantomPlate, 20); rare.addRandomEnchanted(TFItems.phantomHelm, 30); rare.addRandomEnchanted(TFItems.phantomPlate, 30); - break; - case 18: + } + case 18 -> { // aurora cache common.add(Items.stick, 12); common.add(new ItemStack(Items.coal, 12)); @@ -653,35 +606,30 @@ protected void fill(int i) { common.add(Blocks.ice, 4); common.add(Blocks.packed_ice, 4); common.add(TFItems.ironwoodIngot, 2); - uncommon.add(TFBlocks.auroraBlock, 12); uncommon.add(TFItems.ironwoodIngot, 6); uncommon.add(TFBlocks.firefly, 5); uncommon.add(TFItems.charmOfKeeping1, 1); uncommon.add(TFItems.arcticFur, 3); - rare.add(TFItems.arcticFur, 8); rare.add(TFItems.iceBow, 1); rare.add(TFItems.enderBow, 1); rare.add(TFItems.iceSword, 1); - ultrarare.addEnchantedBook(Enchantment.sharpness, 4); ultrarare.addEnchantedBook(Enchantment.power, 4); ultrarare.addEnchantedBook(Enchantment.punch, 2); ultrarare.addEnchantedBook(Enchantment.unbreaking, 2); ultrarare.addEnchantedBook(Enchantment.unbreaking, 2); ultrarare.addEnchantedBook(Enchantment.infinity, 1); - break; - case 19: + } + case 19 -> { // aurora treasure useless.clear(); - common.add(Blocks.ice, 4); common.add(Blocks.packed_ice, 4); common.add(TFItems.mazeWafer, 12); common.add(TFItems.iceBomb, 4); common.add(TFBlocks.firefly, 5); - uncommon.add(TFItems.arcticFur, 6); uncommon.add(TFItems.arcticLegs, 1); uncommon.add(TFItems.arcticPlate, 1); @@ -690,16 +638,14 @@ protected void fill(int i) { uncommon.add(TFItems.knightlyPlate, 1); uncommon.add(TFItems.knightlySword, 1); uncommon.add(TFItems.charmOfLife1, 1); - rare.addRandomEnchanted(TFItems.iceBow, 30); rare.addRandomEnchanted(TFItems.enderBow, 5); rare.addRandomEnchanted(TFItems.iceSword, 25); rare.addRandomEnchanted(TFItems.glassSword, 20); - break; - case 21: + } + case 21 -> { // troll garden useless.clear(); - common.add(Blocks.red_mushroom, 4); common.add(Blocks.brown_mushroom, 4); common.add(Items.wheat_seeds, 6); @@ -707,23 +653,19 @@ protected void fill(int i) { common.add(Items.potato, 6); common.add(Items.melon_seeds, 6); common.add(new ItemStack(Items.dye, 12, 15)); - uncommon.add(TFBlocks.uberousSoil, 6); - rare.add(TFItems.magicBeans, 1); - break; - case 22: + } + case 22 -> { // troll vault useless.clear(); - common.add(Items.coal, 32); common.add(TFItems.torchberries, 16); common.add(Items.emerald, 6); - uncommon.add(TFBlocks.trollSteinn, 6); uncommon.add(Blocks.obsidian, 6); - rare.add(TFItems.lampOfCinders, 1); + } } } } diff --git a/src/main/java/twilightforest/TFTreasureTable.java b/src/main/java/twilightforest/TFTreasureTable.java index 4d7944815e..93c2ec43f0 100644 --- a/src/main/java/twilightforest/TFTreasureTable.java +++ b/src/main/java/twilightforest/TFTreasureTable.java @@ -22,7 +22,7 @@ public class TFTreasureTable { protected ArrayList list; public TFTreasureTable() { - this.list = new ArrayList(); + this.list = new ArrayList<>(); } /** diff --git a/src/main/java/twilightforest/TwilightForestMod.java b/src/main/java/twilightforest/TwilightForestMod.java index 72a884ac45..a4ce7daa0e 100644 --- a/src/main/java/twilightforest/TwilightForestMod.java +++ b/src/main/java/twilightforest/TwilightForestMod.java @@ -59,7 +59,7 @@ public class TwilightForestMod { public static final String ID = "TwilightForest"; - public static final String VERSION = "GRADLETOKEN_VERSION"; + public static final String VERSION = Tags.VERSION; public static final String MODEL_DIR = "twilightforest:textures/model/"; public static final String GUI_DIR = "twilightforest:textures/gui/"; diff --git a/src/main/java/twilightforest/biomes/TFBiomeBase.java b/src/main/java/twilightforest/biomes/TFBiomeBase.java index 664ffcb24a..00b419caff 100644 --- a/src/main/java/twilightforest/biomes/TFBiomeBase.java +++ b/src/main/java/twilightforest/biomes/TFBiomeBase.java @@ -94,7 +94,6 @@ public abstract class TFBiomeBase extends BiomeGenBase { */ protected List undergroundMonsterList; - @SuppressWarnings("unchecked") public TFBiomeBase(int i) { super(i); @@ -121,7 +120,7 @@ public TFBiomeBase(int i) { spawnableCreatureList.add(new SpawnListEntry(twilightforest.entity.passive.EntityTFBunny.class, 10, 4, 5)); spawnableCreatureList.add(new SpawnListEntry(twilightforest.entity.passive.EntityTFRaven.class, 10, 1, 2)); - undergroundMonsterList = new ArrayList(); + undergroundMonsterList = new ArrayList<>(); undergroundMonsterList.add(new SpawnListEntry(EntitySpider.class, 10, 4, 4)); undergroundMonsterList.add(new SpawnListEntry(EntityZombie.class, 10, 4, 4)); @@ -520,9 +519,7 @@ protected Achievement getRequiredAchievement() { /** * Do something bad to a player in the wrong biome. */ - public void enforceProgession(EntityPlayer player, World world) { - ; - } + public void enforceProgession(EntityPlayer player, World world) {} /** * Returns the list of underground creatures. diff --git a/src/main/java/twilightforest/biomes/TFBiomeDarkForest.java b/src/main/java/twilightforest/biomes/TFBiomeDarkForest.java index 8b4fd7e8ab..5adde345dc 100644 --- a/src/main/java/twilightforest/biomes/TFBiomeDarkForest.java +++ b/src/main/java/twilightforest/biomes/TFBiomeDarkForest.java @@ -18,6 +18,7 @@ import net.minecraft.world.ColorizerGrass; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeDecorator; +import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.gen.feature.WorldGenAbstractTree; import net.minecraft.world.gen.feature.WorldGenShrub; @@ -32,9 +33,8 @@ public class TFBiomeDarkForest extends TFBiomeBase { private static final int MONSTER_SPAWN_RATE = 20; Random monsterRNG; - ArrayList emptyList = new ArrayList(); + ArrayList emptyList = new ArrayList<>(); - @SuppressWarnings("unchecked") public TFBiomeDarkForest(int i) { super(i); @@ -92,8 +92,8 @@ public WorldGenAbstractTree func_150567_a(Random random) { */ @Override public int getBiomeGrassColor(int x, int y, int z) { - double var1 = (double) MathHelper.clamp_float(this.getFloatTemperature(x, y, z), 0.0F, 1.0F); - double var3 = (double) MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F); + double var1 = MathHelper.clamp_float(this.getFloatTemperature(x, y, z), 0.0F, 1.0F); + double var3 = MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F); return ((ColorizerGrass.getGrassColor(var1, var3) & 0xFEFEFE) + 0x1E0E4E) / 2; // return 0x554114; @@ -104,17 +104,16 @@ public int getBiomeGrassColor(int x, int y, int z) { */ @Override public int getBiomeFoliageColor(int x, int y, int z) { - double var1 = (double) MathHelper.clamp_float(this.getFloatTemperature(x, y, z), 0.0F, 1.0F); - double var3 = (double) MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F); + double var1 = MathHelper.clamp_float(this.getFloatTemperature(x, y, z), 0.0F, 1.0F); + double var3 = MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F); return ((ColorizerFoliage.getFoliageColor(var1, var3) & 0xFEFEFE) + 0x1E0E4E) / 2; } /** * Returns the correspondent list of the EnumCreatureType informed. */ - @SuppressWarnings("rawtypes") @Override - public List getSpawnableList(EnumCreatureType par1EnumCreatureType) { + public List getSpawnableList(EnumCreatureType par1EnumCreatureType) { // if is is monster, then only give it the real list 1/MONSTER_SPAWN_RATE of the time if (par1EnumCreatureType == EnumCreatureType.monster) { return monsterRNG.nextInt(MONSTER_SPAWN_RATE) == 0 ? this.spawnableMonsterList : emptyList; diff --git a/src/main/java/twilightforest/biomes/TFBiomeDecorator.java b/src/main/java/twilightforest/biomes/TFBiomeDecorator.java index dd480e439a..fc15ec9266 100644 --- a/src/main/java/twilightforest/biomes/TFBiomeDecorator.java +++ b/src/main/java/twilightforest/biomes/TFBiomeDecorator.java @@ -57,7 +57,7 @@ public class TFBiomeDecorator extends BiomeDecorator { public int lakesPerChunk; public float lavaPoolChance; - static final List ruinList = new ArrayList(); + static final List ruinList = new ArrayList<>(); static { // make list of ruins ruinList.add(new RuinEntry(new TFGenStoneCircle(), 10)); diff --git a/src/main/java/twilightforest/biomes/TFBiomeGlacier.java b/src/main/java/twilightforest/biomes/TFBiomeGlacier.java index e18175c455..10a7b48dad 100644 --- a/src/main/java/twilightforest/biomes/TFBiomeGlacier.java +++ b/src/main/java/twilightforest/biomes/TFBiomeGlacier.java @@ -28,7 +28,6 @@ public class TFBiomeGlacier extends TFBiomeBase { /** * @param i */ - @SuppressWarnings("unchecked") public TFBiomeGlacier(int i) { super(i); diff --git a/src/main/java/twilightforest/biomes/TFBiomeSnow.java b/src/main/java/twilightforest/biomes/TFBiomeSnow.java index 7c493084c0..6f53491501 100644 --- a/src/main/java/twilightforest/biomes/TFBiomeSnow.java +++ b/src/main/java/twilightforest/biomes/TFBiomeSnow.java @@ -13,6 +13,7 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.stats.Achievement; import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.gen.feature.WorldGenAbstractTree; import net.minecraft.world.gen.feature.WorldGenTaiga1; import net.minecraft.world.gen.feature.WorldGenTaiga2; @@ -31,12 +32,11 @@ public class TFBiomeSnow extends TFBiomeBase { private static final int MONSTER_SPAWN_RATE = 10; Random monsterRNG = new Random(53439L); - ArrayList emptyList = new ArrayList(); + ArrayList emptyList = new ArrayList<>(); /** * @param i */ - @SuppressWarnings("unchecked") public TFBiomeSnow(int i) { super(i); @@ -83,9 +83,8 @@ public boolean canSpawnLightningBolt() { /** * Returns the correspondent list of the EnumCreatureType informed. */ - @SuppressWarnings("rawtypes") @Override - public List getSpawnableList(EnumCreatureType par1EnumCreatureType) { + public List getSpawnableList(EnumCreatureType par1EnumCreatureType) { // if is is monster, then only give it the real list 1/MONSTER_SPAWN_RATE of the time if (par1EnumCreatureType == EnumCreatureType.monster) { return monsterRNG.nextInt(MONSTER_SPAWN_RATE) == 0 ? this.spawnableMonsterList : emptyList; diff --git a/src/main/java/twilightforest/biomes/TFBiomeSwamp.java b/src/main/java/twilightforest/biomes/TFBiomeSwamp.java index 1260bdbfb7..d378f122dd 100644 --- a/src/main/java/twilightforest/biomes/TFBiomeSwamp.java +++ b/src/main/java/twilightforest/biomes/TFBiomeSwamp.java @@ -16,6 +16,7 @@ import net.minecraft.world.ColorizerFoliage; import net.minecraft.world.ColorizerGrass; import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.gen.feature.WorldGenAbstractTree; import net.minecraft.world.gen.feature.WorldGenShrub; import net.minecraft.world.gen.feature.WorldGenTallGrass; @@ -34,13 +35,12 @@ public class TFBiomeSwamp extends TFBiomeBase { private static final int MONSTER_SPAWN_RATE = 20; Random monsterRNG = new Random(53439L); - ArrayList emptyList = new ArrayList(); + ArrayList emptyList = new ArrayList<>(); WorldGenVines worldgenvines = new WorldGenVines(); WorldGenerator hugeLilyPadGen = new TFGenHugeLilyPad(); WorldGenerator hugeWaterLilyGen = new TFGenHugeWaterLily(); - @SuppressWarnings("unchecked") public TFBiomeSwamp(int i) { super(i); @@ -120,8 +120,8 @@ public void decorate(World par1World, Random par2Random, int par3, int par4) { */ @Override public int getBiomeGrassColor(int x, int y, int z) { - double var1 = (double) MathHelper.clamp_float(this.getFloatTemperature(x, y, z), 0.0F, 1.0F); - double var3 = (double) MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F); + double var1 = MathHelper.clamp_float(this.getFloatTemperature(x, y, z), 0.0F, 1.0F); + double var3 = MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F); return ((ColorizerGrass.getGrassColor(var1, var3) & 0xFEFEFE) + 0x4E0E4E) / 2; } @@ -130,17 +130,16 @@ public int getBiomeGrassColor(int x, int y, int z) { */ @Override public int getBiomeFoliageColor(int x, int y, int z) { - double var1 = (double) MathHelper.clamp_float(this.getFloatTemperature(x, y, z), 0.0F, 1.0F); - double var3 = (double) MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F); + double var1 = MathHelper.clamp_float(this.getFloatTemperature(x, y, z), 0.0F, 1.0F); + double var3 = MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F); return ((ColorizerFoliage.getFoliageColor(var1, var3) & 0xFEFEFE) + 0x4E0E4E) / 2; } /** * Returns the correspondent list of the EnumCreatureType informed. */ - @SuppressWarnings("rawtypes") @Override - public List getSpawnableList(EnumCreatureType par1EnumCreatureType) { + public List getSpawnableList(EnumCreatureType par1EnumCreatureType) { // if is is monster, then only give it the real list 1/MONSTER_SPAWN_RATE of the time if (par1EnumCreatureType == EnumCreatureType.monster) { return monsterRNG.nextInt(MONSTER_SPAWN_RATE) == 0 ? this.spawnableMonsterList : emptyList; diff --git a/src/main/java/twilightforest/biomes/TFBiomeTwilightLake.java b/src/main/java/twilightforest/biomes/TFBiomeTwilightLake.java index ce657a195e..f30b401a90 100644 --- a/src/main/java/twilightforest/biomes/TFBiomeTwilightLake.java +++ b/src/main/java/twilightforest/biomes/TFBiomeTwilightLake.java @@ -4,7 +4,6 @@ public class TFBiomeTwilightLake extends TFBiomeBase { - @SuppressWarnings("unchecked") public TFBiomeTwilightLake(int i) { super(i); diff --git a/src/main/java/twilightforest/block/BlockTFAuroraBrick.java b/src/main/java/twilightforest/block/BlockTFAuroraBrick.java index d92820d5e3..817440255b 100644 --- a/src/main/java/twilightforest/block/BlockTFAuroraBrick.java +++ b/src/main/java/twilightforest/block/BlockTFAuroraBrick.java @@ -123,10 +123,9 @@ public int getRenderColor(int meta) { /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); } diff --git a/src/main/java/twilightforest/block/BlockTFBossSpawner.java b/src/main/java/twilightforest/block/BlockTFBossSpawner.java index 6690f98635..2f21e278a6 100644 --- a/src/main/java/twilightforest/block/BlockTFBossSpawner.java +++ b/src/main/java/twilightforest/block/BlockTFBossSpawner.java @@ -51,22 +51,15 @@ public boolean hasTileEntity(int metadata) { */ @Override public TileEntity createTileEntity(World world, int meta) { - switch (meta) { - case 0: - return new TileEntityTFNagaSpawner(); - case 1: - return new TileEntityTFLichSpawner(); - case 2: - return new TileEntityTFHydraSpawner(); - case 3: - return new TileEntityTFTowerBossSpawner(); - case 4: - return new TileEntityTFKnightPhantomsSpawner(); - case 5: - return new TileEntityTFSnowQueenSpawner(); - default: - return null; - } + return switch (meta) { + case 0 -> new TileEntityTFNagaSpawner(); + case 1 -> new TileEntityTFLichSpawner(); + case 2 -> new TileEntityTFHydraSpawner(); + case 3 -> new TileEntityTFTowerBossSpawner(); + case 4 -> new TileEntityTFKnightPhantomsSpawner(); + case 5 -> new TileEntityTFSnowQueenSpawner(); + default -> null; + }; } @Override @@ -96,7 +89,7 @@ public boolean isOpaqueCube() { * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { + public void getSubBlocks(Item item, CreativeTabs tab, List list) { list.add(new ItemStack(item, 1, 0)); list.add(new ItemStack(item, 1, 1)); list.add(new ItemStack(item, 1, 2)); @@ -116,6 +109,6 @@ public IIcon getIcon(int side, int metadata) { @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister par1IconRegister) { - ; // don't load anything + // don't load anything } } diff --git a/src/main/java/twilightforest/block/BlockTFBurntThorns.java b/src/main/java/twilightforest/block/BlockTFBurntThorns.java index 0b25f84fff..14eec5f5de 100644 --- a/src/main/java/twilightforest/block/BlockTFBurntThorns.java +++ b/src/main/java/twilightforest/block/BlockTFBurntThorns.java @@ -50,7 +50,5 @@ public boolean canSustainLeaves(IBlockAccess world, int x, int y, int z) { /** * no need for leaf decay, I think */ - public void breakBlock(World world, int x, int y, int z, Block logBlock, int metadata) { - ; - } + public void breakBlock(World world, int x, int y, int z, Block logBlock, int metadata) {} } diff --git a/src/main/java/twilightforest/block/BlockTFCastleBlock.java b/src/main/java/twilightforest/block/BlockTFCastleBlock.java index d12ef5e413..c6ab66d463 100644 --- a/src/main/java/twilightforest/block/BlockTFCastleBlock.java +++ b/src/main/java/twilightforest/block/BlockTFCastleBlock.java @@ -53,17 +53,12 @@ public BlockTFCastleBlock() { */ @Override public IIcon getIcon(int side, int meta) { - switch (meta) { - case 0: - default: - return brickIcon; - case 1: - return fadedIcon; - case 2: - return crackIcon; - case 3: - return roofIcon; - } + return switch (meta) { + default -> brickIcon; + case 1 -> fadedIcon; + case 2 -> crackIcon; + case 3 -> roofIcon; + }; } @Override @@ -92,9 +87,8 @@ public void harvestBlock(World world, EntityPlayer entityplayer, int x, int y, i /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); diff --git a/src/main/java/twilightforest/block/BlockTFCastleMagic.java b/src/main/java/twilightforest/block/BlockTFCastleMagic.java index 5caea76bed..d732d0af62 100644 --- a/src/main/java/twilightforest/block/BlockTFCastleMagic.java +++ b/src/main/java/twilightforest/block/BlockTFCastleMagic.java @@ -76,9 +76,8 @@ public int getRenderType() { /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); diff --git a/src/main/java/twilightforest/block/BlockTFCinderFurnace.java b/src/main/java/twilightforest/block/BlockTFCinderFurnace.java index d2b313fe98..5650174253 100644 --- a/src/main/java/twilightforest/block/BlockTFCinderFurnace.java +++ b/src/main/java/twilightforest/block/BlockTFCinderFurnace.java @@ -130,17 +130,17 @@ public void randomDisplayTick(World world, int x, int y, int z, Random random) { int l = random.nextInt(4) + 2; if (l == 4) { - world.spawnParticle("smoke", (double) (f - f3), (double) f1, (double) (f2 + f4), 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", (double) (f - f3), (double) f1, (double) (f2 + f4), 0.0D, 0.0D, 0.0D); + world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); } else if (l == 5) { - world.spawnParticle("smoke", (double) (f + f3), (double) f1, (double) (f2 + f4), 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", (double) (f + f3), (double) f1, (double) (f2 + f4), 0.0D, 0.0D, 0.0D); + world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); } else if (l == 2) { - world.spawnParticle("smoke", (double) (f + f4), (double) f1, (double) (f2 - f3), 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", (double) (f + f4), (double) f1, (double) (f2 - f3), 0.0D, 0.0D, 0.0D); + world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); } else if (l == 3) { - world.spawnParticle("smoke", (double) (f + f4), (double) f1, (double) (f2 + f3), 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", (double) (f + f4), (double) f1, (double) (f2 + f3), 0.0D, 0.0D, 0.0D); + world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); } } } @@ -171,9 +171,9 @@ public void breakBlock(World world, int x, int y, int z, Block block, int p_1497 itemstack.stackSize -= j1; EntityItem entityitem = new EntityItem( world, - (double) ((float) x + dx), - (double) ((float) y + dy), - (double) ((float) z + dz), + (float) x + dx, + (float) y + dy, + (float) z + dz, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); if (itemstack.hasTagCompound()) { @@ -182,10 +182,9 @@ public void breakBlock(World world, int x, int y, int z, Block block, int p_1497 } float pointFive = 0.05F; - entityitem.motionX = (double) ((float) this.furnaceRandom.nextGaussian() * pointFive); - entityitem.motionY = (double) ((float) this.furnaceRandom.nextGaussian() * pointFive - + 0.2F); - entityitem.motionZ = (double) ((float) this.furnaceRandom.nextGaussian() * pointFive); + entityitem.motionX = (float) this.furnaceRandom.nextGaussian() * pointFive; + entityitem.motionY = (float) this.furnaceRandom.nextGaussian() * pointFive + 0.2F; + entityitem.motionZ = (float) this.furnaceRandom.nextGaussian() * pointFive; world.spawnEntityInWorld(entityitem); } } diff --git a/src/main/java/twilightforest/block/BlockTFCritter.java b/src/main/java/twilightforest/block/BlockTFCritter.java index 1d2f14330e..1742bf6c0e 100644 --- a/src/main/java/twilightforest/block/BlockTFCritter.java +++ b/src/main/java/twilightforest/block/BlockTFCritter.java @@ -39,27 +39,16 @@ public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) int facing = world.getBlockMetadata(x, y, z) & 7; float wide = 0.15F; switch (facing) { - case 1: - setBlockBounds(0.0F, 0.2F, 0.5F - wide, wide * 2.0F, 0.8F, 0.5F + wide); - break; - case 2: - setBlockBounds(1.0F - wide * 2.0F, 0.2F, 0.5F - wide, 1.0F, 0.8F, 0.5F + wide); - break; - case 3: - setBlockBounds(0.5F - wide, 0.2F, 0.0F, 0.5F + wide, 0.8F, wide * 2.0F); - break; - case 4: - setBlockBounds(0.5F - wide, 0.2F, 1.0F - wide * 2.0F, 0.5F + wide, 0.8F, 1.0F); - break; - case 5: - setBlockBounds(0.5F - wide, 0.0F, 0.2F, 0.5F + wide, wide * 2.0F, 0.8F); - break; - case 6: - setBlockBounds(0.5F - wide, 1.0F - wide * 2.0F, 0.2F, 0.5F + wide, 1.0F, 0.8F); - break; - default: + case 1 -> setBlockBounds(0.0F, 0.2F, 0.5F - wide, wide * 2.0F, 0.8F, 0.5F + wide); + case 2 -> setBlockBounds(1.0F - wide * 2.0F, 0.2F, 0.5F - wide, 1.0F, 0.8F, 0.5F + wide); + case 3 -> setBlockBounds(0.5F - wide, 0.2F, 0.0F, 0.5F + wide, 0.8F, wide * 2.0F); + case 4 -> setBlockBounds(0.5F - wide, 0.2F, 1.0F - wide * 2.0F, 0.5F + wide, 0.8F, 1.0F); + case 5 -> setBlockBounds(0.5F - wide, 0.0F, 0.2F, 0.5F + wide, wide * 2.0F, 0.8F); + case 6 -> setBlockBounds(0.5F - wide, 1.0F - wide * 2.0F, 0.2F, 0.5F + wide, 1.0F, 0.8F); + default -> { float f1 = 0.1F; setBlockBounds(0.5F - f1, 0.0F, 0.5F - f1, 0.5F + f1, 0.6F, 0.5F + f1); + } } } @@ -107,35 +96,36 @@ public boolean canPlaceBlockAt(World world, int x, int y, int z) { public int onBlockPlaced(World world, int x, int y, int z, int placementFacing, float par6, float par7, float par8, int meta) { switch (placementFacing) { - case 0: + case 0 -> { if (this.canPlaceAt(world, x, y + 1, z)) { meta = 6; } - break; - case 1: + } + case 1 -> { if (this.canPlaceAt(world, x, y - 1, z)) { meta = 5; } - break; - case 2: + } + case 2 -> { if (world.isSideSolid(x, y, z + 1, NORTH, true)) { meta = 4; } - break; - case 3: + } + case 3 -> { if (world.isSideSolid(x, y, z - 1, SOUTH, true)) { meta = 3; } - break; - case 4: + } + case 4 -> { if (world.isSideSolid(x + 1, y, z, WEST, true)) { meta = 2; } - break; - case 5: + } + case 5 -> { if (world.isSideSolid(x - 1, y, z, EAST, true)) { meta = 1; } + } } return meta; } @@ -189,35 +179,36 @@ public void onNeighborBlockChange(World world, int x, int y, int z, Block blockI boolean flag = false; switch (facing) { - case 1: + case 1 -> { if (!canPlaceAt(world, x - 1, y, z)) { flag = true; } - break; - case 2: + } + case 2 -> { if (!canPlaceAt(world, x + 1, y, z)) { flag = true; } - break; - case 3: + } + case 3 -> { if (!canPlaceAt(world, x, y, z - 1)) { flag = true; } - break; - case 4: + } + case 4 -> { if (!canPlaceAt(world, x, y, z + 1)) { flag = true; } - break; - case 5: + } + case 5 -> { if (!canPlaceAt(world, x, y - 1, z)) { flag = true; } - break; - case 6: + } + case 6 -> { if (!canPlaceAt(world, x, y + 1, z)) { flag = true; } + } } if (flag) { @@ -262,9 +253,8 @@ public boolean hasTileEntity(int metadata) { /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { + public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { itemList.add(new ItemStack(item, 1, 0)); } diff --git a/src/main/java/twilightforest/block/BlockTFDeadrock.java b/src/main/java/twilightforest/block/BlockTFDeadrock.java index 88f5add9fa..b20c68ae38 100644 --- a/src/main/java/twilightforest/block/BlockTFDeadrock.java +++ b/src/main/java/twilightforest/block/BlockTFDeadrock.java @@ -54,7 +54,7 @@ public IIcon getIcon(int side, int meta) { * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { for (int i = 0; i < names.length; i++) { par3List.add(new ItemStack(par1, 1, i)); } diff --git a/src/main/java/twilightforest/block/BlockTFFireJet.java b/src/main/java/twilightforest/block/BlockTFFireJet.java index c4d648fb38..390135f3a6 100644 --- a/src/main/java/twilightforest/block/BlockTFFireJet.java +++ b/src/main/java/twilightforest/block/BlockTFFireJet.java @@ -57,18 +57,12 @@ protected BlockTFFireJet() { */ @Override public int damageDropped(int meta) { - switch (meta) { - default: - return meta; - case META_ENCASED_SMOKER_ON: - return META_ENCASED_SMOKER_OFF; - case META_ENCASED_JET_POPPING: - case META_ENCASED_JET_FLAME: - return META_ENCASED_JET_IDLE; - case META_JET_POPPING: - case META_JET_FLAME: - return META_JET_IDLE; - } + return switch (meta) { + default -> meta; + case META_ENCASED_SMOKER_ON -> META_ENCASED_SMOKER_OFF; + case META_ENCASED_JET_POPPING, META_ENCASED_JET_FLAME -> META_ENCASED_JET_IDLE; + case META_JET_POPPING, META_JET_FLAME -> META_JET_IDLE; + }; } @@ -178,14 +172,10 @@ public int getLightValue(IBlockAccess world, int x, int y, int z) { if (world.getBlock(x, y, z) == this) { int meta = world.getBlockMetadata(x, y, z); - switch (meta) { - case META_SMOKER: - default: - return 0; - case META_JET_FLAME: - case META_ENCASED_JET_FLAME: - return 15; - } + return switch (meta) { + default -> 0; + case META_JET_FLAME, META_ENCASED_JET_FLAME -> 15; + }; } else { return 0; } @@ -286,17 +276,10 @@ private boolean isLava(World world, int x, int y, int z) { */ @Override public boolean hasTileEntity(int meta) { - switch (meta) { - case META_SMOKER: - case META_ENCASED_SMOKER_ON: - case META_JET_POPPING: - case META_JET_FLAME: - case META_ENCASED_JET_POPPING: - case META_ENCASED_JET_FLAME: - return true; - default: - return false; - } + return switch (meta) { + case META_SMOKER, META_ENCASED_SMOKER_ON, META_JET_POPPING, META_JET_FLAME, META_ENCASED_JET_POPPING, META_ENCASED_JET_FLAME -> true; + default -> false; + }; } /** @@ -308,28 +291,21 @@ public boolean hasTileEntity(int meta) { */ @Override public TileEntity createTileEntity(World world, int metadata) { - switch (metadata) { - case META_SMOKER: - case META_ENCASED_SMOKER_ON: - return new TileEntityTFSmoker(); - case META_JET_POPPING: - return new TileEntityTFPoppingJet(META_JET_FLAME); - case META_JET_FLAME: - return new TileEntityTFFlameJet(META_JET_IDLE); - case META_ENCASED_JET_POPPING: - return new TileEntityTFPoppingJet(META_ENCASED_JET_FLAME); - case META_ENCASED_JET_FLAME: - return new TileEntityTFFlameJet(META_ENCASED_JET_IDLE); - default: - return null; - } + return switch (metadata) { + case META_SMOKER, META_ENCASED_SMOKER_ON -> new TileEntityTFSmoker(); + case META_JET_POPPING -> new TileEntityTFPoppingJet(META_JET_FLAME); + case META_JET_FLAME -> new TileEntityTFFlameJet(META_JET_IDLE); + case META_ENCASED_JET_POPPING -> new TileEntityTFPoppingJet(META_ENCASED_JET_FLAME); + case META_ENCASED_JET_FLAME -> new TileEntityTFFlameJet(META_ENCASED_JET_IDLE); + default -> null; + }; } /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @Override - public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { + public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { itemList.add(new ItemStack(item, 1, META_SMOKER)); itemList.add(new ItemStack(item, 1, META_JET_IDLE)); itemList.add(new ItemStack(item, 1, META_ENCASED_SMOKER_OFF)); diff --git a/src/main/java/twilightforest/block/BlockTFFireflyJar.java b/src/main/java/twilightforest/block/BlockTFFireflyJar.java index e890f7fbc3..e18d6bb558 100644 --- a/src/main/java/twilightforest/block/BlockTFFireflyJar.java +++ b/src/main/java/twilightforest/block/BlockTFFireflyJar.java @@ -137,7 +137,7 @@ public void randomDisplayTick(World world, int x, int y, int z, Random rand) { * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); } diff --git a/src/main/java/twilightforest/block/BlockTFForceField.java b/src/main/java/twilightforest/block/BlockTFForceField.java index 84956618f5..cc3815702f 100644 --- a/src/main/java/twilightforest/block/BlockTFForceField.java +++ b/src/main/java/twilightforest/block/BlockTFForceField.java @@ -82,9 +82,8 @@ public int damageDropped(int meta) { /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { for (int i = 0; i < names.length; i++) { par3List.add(new ItemStack(par1, 1, i)); } @@ -102,7 +101,7 @@ public int getRenderBlockPass() { * Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they intersect the * mask.) Parameters: World, X, Y, Z, mask, list, colliding entity */ - public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, + public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) { super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); diff --git a/src/main/java/twilightforest/block/BlockTFGiantBlock.java b/src/main/java/twilightforest/block/BlockTFGiantBlock.java index b59a8c3fe1..3d6ab03572 100644 --- a/src/main/java/twilightforest/block/BlockTFGiantBlock.java +++ b/src/main/java/twilightforest/block/BlockTFGiantBlock.java @@ -45,20 +45,13 @@ public void registerBlockIcons(IIconRegister par1IconRegister) { @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { // return an icon from the icon matrix! - switch (side) { - default: - case 0: - case 1: - return this.giantIcon[x & 3][z & 3][side]; - case 2: - return this.giantIcon[3 - (x & 3)][3 - (y & 3)][side]; - case 3: - return this.giantIcon[x & 3][3 - (y & 3)][side]; - case 4: - return this.giantIcon[z & 3][3 - (y & 3)][side]; - case 5: - return this.giantIcon[3 - (z & 3)][3 - (y & 3)][side]; - } + return switch (side) { + default -> this.giantIcon[x & 3][z & 3][side]; + case 2 -> this.giantIcon[3 - (x & 3)][3 - (y & 3)][side]; + case 3 -> this.giantIcon[x & 3][3 - (y & 3)][side]; + case 4 -> this.giantIcon[z & 3][3 - (y & 3)][side]; + case 5 -> this.giantIcon[3 - (z & 3)][3 - (y & 3)][side]; + }; } // Gets the block's texture. Args: side, meta diff --git a/src/main/java/twilightforest/block/BlockTFGiantLeaves.java b/src/main/java/twilightforest/block/BlockTFGiantLeaves.java index f5f9529581..34dec3bda7 100644 --- a/src/main/java/twilightforest/block/BlockTFGiantLeaves.java +++ b/src/main/java/twilightforest/block/BlockTFGiantLeaves.java @@ -70,21 +70,15 @@ public int colorMultiplier(IBlockAccess world, int x, int y, int z) { */ @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) { - switch (side) { - case 0: - return (y & 3) == 3; - case 1: - return (y & 3) == 0; - case 2: - return (z & 3) == 3; - case 3: - return (z & 3) == 0; - case 4: - return (x & 3) == 3; - case 5: - return (x & 3) == 0; - } + return switch (side) { + case 0 -> (y & 3) == 3; + case 1 -> (y & 3) == 0; + case 2 -> (z & 3) == 3; + case 3 -> (z & 3) == 0; + case 4 -> (x & 3) == 3; + case 5 -> (x & 3) == 0; + default -> super.shouldSideBeRendered(world, x, y, z, side); + }; - return super.shouldSideBeRendered(world, x, y, z, side); } } diff --git a/src/main/java/twilightforest/block/BlockTFHedge.java b/src/main/java/twilightforest/block/BlockTFHedge.java index 7d901c34f0..1484aaf00d 100644 --- a/src/main/java/twilightforest/block/BlockTFHedge.java +++ b/src/main/java/twilightforest/block/BlockTFHedge.java @@ -51,12 +51,13 @@ protected BlockTFHedge() { public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { int meta = world.getBlockMetadata(x, y, z); switch (meta) { - case 0: + case 0 -> { float f = 0.0625F; return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1 - f, z + 1); - default: - case 1: + } + default -> { return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1); + } } } @@ -106,13 +107,10 @@ public int damageDropped(int meta) { */ @Override public IIcon getIcon(int side, int meta) { - switch (meta) { - case 1: - return BlockTFHedge.sprDarkwoodLeaves; - default: - case 0: - return BlockTFHedge.sprHedge; - } + return switch (meta) { + case 1 -> BlockTFHedge.sprDarkwoodLeaves; + default -> BlockTFHedge.sprHedge; + }; } @Override @@ -175,7 +173,6 @@ public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, i * This should be called 5 ticks after we've received a click event from a player. If we see player nearby swinging * at a hedge block, prick them */ - @SuppressWarnings("unchecked") @Override public void updateTick(World world, int x, int y, int z, Random random) { double range = 4.0; // do we need to get this with a better method than hardcoding it? diff --git a/src/main/java/twilightforest/block/BlockTFHugeLilyPad.java b/src/main/java/twilightforest/block/BlockTFHugeLilyPad.java index e45456cccf..9851dd3b37 100644 --- a/src/main/java/twilightforest/block/BlockTFHugeLilyPad.java +++ b/src/main/java/twilightforest/block/BlockTFHugeLilyPad.java @@ -69,9 +69,8 @@ public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_14 /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); } @@ -97,17 +96,12 @@ public IIcon getIcon(int side, int meta) { int display = (piece + orient) % 4; - switch (display) { - case 0: - default: - return this.blockIcon; - case 1: - return this.pad1; - case 2: - return this.pad2; - case 3: - return this.pad3; - } + return switch (display) { + default -> this.blockIcon; + case 1 -> this.pad1; + case 2 -> this.pad2; + case 3 -> this.pad3; + }; } @Override diff --git a/src/main/java/twilightforest/block/BlockTFLeaves.java b/src/main/java/twilightforest/block/BlockTFLeaves.java index 54111fb7b6..400e87b221 100644 --- a/src/main/java/twilightforest/block/BlockTFLeaves.java +++ b/src/main/java/twilightforest/block/BlockTFLeaves.java @@ -72,36 +72,37 @@ public int colorMultiplier(IBlockAccess world, int x, int y, int z) { int normalColor = (red / 9 & 0xFF) << 16 | (green / 9 & 0xFF) << 8 | blue / 9 & 0xFF; switch (meta & 3) { - case 1: + case 1 -> { // canopy colorizer return ((normalColor & 0xFEFEFE) + 0x469A66) / 2; + } // return ((normalColor & 0xFEFEFE) + 0x009822) / 2; - case 2: + case 2 -> { // mangrove colors return ((normalColor & 0xFEFEFE) + 0xC0E694) / 2; - case 3: + } + case 3 -> { // RAINBOW! red = x * 32 + y * 16; if ((red & 256) != 0) { red = 255 - (red & 255); } red &= 255; - blue = y * 32 + z * 16; if ((blue & 256) != 0) { blue = 255 - (blue & 255); } blue ^= 255; - green = x * 16 + z * 32; if ((green & 256) != 0) { green = 255 - (green & 255); } green &= 255; - return red << 16 | blue << 8 | green; - default: + } + default -> { return normalColor; + } } } @@ -120,9 +121,8 @@ public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int return Blocks.leaves.shouldSideBeRendered(world, x, y, z, side); } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { + public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { itemList.add(new ItemStack(item, 1, 0)); itemList.add(new ItemStack(item, 1, 1)); itemList.add(new ItemStack(item, 1, 2)); diff --git a/src/main/java/twilightforest/block/BlockTFLeaves3.java b/src/main/java/twilightforest/block/BlockTFLeaves3.java index c27785ec9c..ed9064377a 100644 --- a/src/main/java/twilightforest/block/BlockTFLeaves3.java +++ b/src/main/java/twilightforest/block/BlockTFLeaves3.java @@ -84,9 +84,8 @@ public IIcon getIcon(int i, int j) { return Blocks.leaves.getIcon(i, 0 & 3); } - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { + public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { for (int meta = 0; meta < names.length; meta++) { itemList.add(new ItemStack(item, 1, meta)); } diff --git a/src/main/java/twilightforest/block/BlockTFLog.java b/src/main/java/twilightforest/block/BlockTFLog.java index a5f6170426..4af37bc669 100644 --- a/src/main/java/twilightforest/block/BlockTFLog.java +++ b/src/main/java/twilightforest/block/BlockTFLog.java @@ -41,25 +41,20 @@ public IIcon getIcon(int side, int meta) { int orient = meta & 12; int woodType = meta & 3; - switch (woodType) { - default: - case 0: - return orient == 0 && (side == 1 || side == 0) ? sprOakTop - : (orient == 4 && (side == 5 || side == 4) ? sprOakTop - : (orient == 8 && (side == 2 || side == 3) ? sprOakTop : sprOakSide)); - case 1: - return orient == 0 && (side == 1 || side == 0) ? sprCanopyTop - : (orient == 4 && (side == 5 || side == 4) ? sprCanopyTop - : (orient == 8 && (side == 2 || side == 3) ? sprCanopyTop : sprCanopySide)); - case 2: - return orient == 0 && (side == 1 || side == 0) ? sprMangroveTop - : (orient == 4 && (side == 5 || side == 4) ? sprMangroveTop - : (orient == 8 && (side == 2 || side == 3) ? sprMangroveTop : sprMangroveSide)); - case 3: - return orient == 0 && (side == 1 || side == 0) ? sprDarkwoodTop - : (orient == 4 && (side == 5 || side == 4) ? sprDarkwoodTop - : (orient == 8 && (side == 2 || side == 3) ? sprDarkwoodTop : sprDarkwoodSide)); - } + return switch (woodType) { + default -> orient == 0 && (side == 1 || side == 0) ? sprOakTop + : (orient == 4 && (side == 5 || side == 4) ? sprOakTop + : (orient == 8 && (side == 2 || side == 3) ? sprOakTop : sprOakSide)); + case 1 -> orient == 0 && (side == 1 || side == 0) ? sprCanopyTop + : (orient == 4 && (side == 5 || side == 4) ? sprCanopyTop + : (orient == 8 && (side == 2 || side == 3) ? sprCanopyTop : sprCanopySide)); + case 2 -> orient == 0 && (side == 1 || side == 0) ? sprMangroveTop + : (orient == 4 && (side == 5 || side == 4) ? sprMangroveTop + : (orient == 8 && (side == 2 || side == 3) ? sprMangroveTop : sprMangroveSide)); + case 3 -> orient == 0 && (side == 1 || side == 0) ? sprDarkwoodTop + : (orient == 4 && (side == 5 || side == 4) ? sprDarkwoodTop + : (orient == 8 && (side == 2 || side == 3) ? sprDarkwoodTop : sprDarkwoodSide)); + }; } @Override @@ -81,7 +76,7 @@ public Item getItemDropped(int par1, Random par2Random, int par3) { } @Override - public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { + public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { itemList.add(new ItemStack(item, 1, 0)); itemList.add(new ItemStack(item, 1, 1)); itemList.add(new ItemStack(item, 1, 2)); diff --git a/src/main/java/twilightforest/block/BlockTFMagicLeaves.java b/src/main/java/twilightforest/block/BlockTFMagicLeaves.java index 7682fcaf67..8fafbf5bcb 100644 --- a/src/main/java/twilightforest/block/BlockTFMagicLeaves.java +++ b/src/main/java/twilightforest/block/BlockTFMagicLeaves.java @@ -56,18 +56,13 @@ protected BlockTFMagicLeaves() { */ @Override public int getRenderColor(int par1) { - switch (par1 & 3) { - case META_TIME: - return 106 << 16 | 156 << 8 | 23; - case META_TRANS: - return 108 << 16 | 204 << 8 | 234; - case META_MINE: - return 252 << 16 | 241 << 8 | 68; - case META_SORT: - return 54 << 16 | 76 << 8 | 3; - default: - return 16777215; - } + return switch (par1 & 3) { + case META_TIME -> 106 << 16 | 156 << 8 | 23; + case META_TRANS -> 108 << 16 | 204 << 8 | 234; + case META_MINE -> 252 << 16 | 241 << 8 | 68; + case META_SORT -> 54 << 16 | 76 << 8 | 3; + default -> 16777215; + }; } /** @@ -87,7 +82,7 @@ public int colorMultiplier(IBlockAccess world, int x, int y, int z) { float fall; switch (leafType) { - case META_TIME: + case META_TIME -> { fade = x * 16 + y * 16 + z * 16; if ((fade & 256) != 0) { fade = 255 - (fade & 255); @@ -95,12 +90,11 @@ public int colorMultiplier(IBlockAccess world, int x, int y, int z) { fade &= 255; spring = (255 - fade) / 255F; fall = fade / 255F; - red = (int) (spring * 106 + fall * 251); green = (int) (spring * 156 + fall * 108); blue = (int) (spring * 23 + fall * 27); - break; - case META_TRANS: + } + case META_TRANS -> { fade = x * 27 + y * 63 + z * 39; if ((fade & 256) != 0) { fade = 255 - (fade & 255); @@ -108,12 +102,11 @@ public int colorMultiplier(IBlockAccess world, int x, int y, int z) { fade &= 255; spring = (255 - fade) / 255F; fall = fade / 255F; - red = (int) (spring * 108 + fall * 96); green = (int) (spring * 204 + fall * 107); blue = (int) (spring * 234 + fall * 121); - break; - case META_MINE: + } + case META_MINE -> { fade = x * 31 + y * 33 + z * 32; if ((fade & 256) != 0) { fade = 255 - (fade & 255); @@ -121,24 +114,22 @@ public int colorMultiplier(IBlockAccess world, int x, int y, int z) { fade &= 255; spring = (255 - fade) / 255F; fall = fade / 255F; - red = (int) (spring * 252 + fall * 237); green = (int) (spring * 241 + fall * 172); blue = (int) (spring * 68 + fall * 9); - break; - case META_SORT: + } + case META_SORT -> { fade = x * 63 + y * 63 + z * 63; if ((fade & 256) != 0) { fade = 255 - (fade & 255); } fade &= 255; - spring = (255 - fade) / 255F; fall = fade / 255F; - red = (int) (spring * 54 + fall * 168); green = (int) (spring * 76 + fall * 199); blue = (int) (spring * 3 + fall * 43); + } } return red << 16 | green << 8 | blue; } @@ -167,23 +158,17 @@ public boolean isOpaqueCube() { @Override public IIcon getIcon(int side, int meta) { if (Blocks.leaves.isOpaqueCube()) { - switch (meta & 0x03) { - default: - return SPR_TIMELEAVES_OPAQUE; - case 1: - return SPR_TRANSLEAVES_OPAQUE; - case 3: - return SPR_SORTLEAVES_OPAQUE; - } + return switch (meta & 0x03) { + default -> SPR_TIMELEAVES_OPAQUE; + case 1 -> SPR_TRANSLEAVES_OPAQUE; + case 3 -> SPR_SORTLEAVES_OPAQUE; + }; } else { - switch (meta & 0x03) { - default: - return SPR_TIMELEAVES; - case 1: - return SPR_TRANSLEAVES; - case 3: - return SPR_SORTLEAVES; - } + return switch (meta & 0x03) { + default -> SPR_TIMELEAVES; + case 1 -> SPR_TRANSLEAVES; + case 3 -> SPR_SORTLEAVES; + }; } } @@ -204,9 +189,8 @@ public void registerBlockIcons(IIconRegister par1IconRegister) { /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ - @SuppressWarnings({ "unchecked" }) @Override - public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { + public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { itemList.add(new ItemStack(item, 1, 0)); itemList.add(new ItemStack(item, 1, 1)); itemList.add(new ItemStack(item, 1, 2)); diff --git a/src/main/java/twilightforest/block/BlockTFMagicLog.java b/src/main/java/twilightforest/block/BlockTFMagicLog.java index 81bfc8755f..7ad6b73f43 100644 --- a/src/main/java/twilightforest/block/BlockTFMagicLog.java +++ b/src/main/java/twilightforest/block/BlockTFMagicLog.java @@ -52,25 +52,20 @@ public IIcon getIcon(int side, int meta) { int orient = meta & 12; int woodType = meta & 3; - switch (woodType) { - default: - case META_TIME: - return orient == 0 && (side == 1 || side == 0) ? SPR_TIMETOP - : (orient == 4 && (side == 5 || side == 4) ? SPR_TIMETOP - : (orient == 8 && (side == 2 || side == 3) ? SPR_TIMETOP : SPR_TIMESIDE)); - case META_TRANS: - return orient == 0 && (side == 1 || side == 0) ? SPR_TRANSTOP - : (orient == 4 && (side == 5 || side == 4) ? SPR_TRANSTOP - : (orient == 8 && (side == 2 || side == 3) ? SPR_TRANSTOP : SPR_TRANSSIDE)); - case META_MINE: - return orient == 0 && (side == 1 || side == 0) ? SPR_MINETOP - : (orient == 4 && (side == 5 || side == 4) ? SPR_MINETOP - : (orient == 8 && (side == 2 || side == 3) ? SPR_MINETOP : SPR_MINESIDE)); - case META_SORT: - return orient == 0 && (side == 1 || side == 0) ? SPR_SORTTOP - : (orient == 4 && (side == 5 || side == 4) ? SPR_SORTTOP - : (orient == 8 && (side == 2 || side == 3) ? SPR_SORTTOP : SPR_SORTSIDE)); - } + return switch (woodType) { + default -> orient == 0 && (side == 1 || side == 0) ? SPR_TIMETOP + : (orient == 4 && (side == 5 || side == 4) ? SPR_TIMETOP + : (orient == 8 && (side == 2 || side == 3) ? SPR_TIMETOP : SPR_TIMESIDE)); + case META_TRANS -> orient == 0 && (side == 1 || side == 0) ? SPR_TRANSTOP + : (orient == 4 && (side == 5 || side == 4) ? SPR_TRANSTOP + : (orient == 8 && (side == 2 || side == 3) ? SPR_TRANSTOP : SPR_TRANSSIDE)); + case META_MINE -> orient == 0 && (side == 1 || side == 0) ? SPR_MINETOP + : (orient == 4 && (side == 5 || side == 4) ? SPR_MINETOP + : (orient == 8 && (side == 2 || side == 3) ? SPR_MINETOP : SPR_MINESIDE)); + case META_SORT -> orient == 0 && (side == 1 || side == 0) ? SPR_SORTTOP + : (orient == 4 && (side == 5 || side == 4) ? SPR_SORTTOP + : (orient == 8 && (side == 2 || side == 3) ? SPR_SORTTOP : SPR_SORTSIDE)); + }; } @@ -100,9 +95,8 @@ public Item getItemDropped(int par1, Random random, int par3) { return Item.getItemFromBlock(this); // hey that's my block ID! } - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { + public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { itemList.add(new ItemStack(item, 1, 0)); itemList.add(new ItemStack(item, 1, 1)); itemList.add(new ItemStack(item, 1, 2)); diff --git a/src/main/java/twilightforest/block/BlockTFMagicLogSpecial.java b/src/main/java/twilightforest/block/BlockTFMagicLogSpecial.java index fc1fa6981a..d6009d21e2 100644 --- a/src/main/java/twilightforest/block/BlockTFMagicLogSpecial.java +++ b/src/main/java/twilightforest/block/BlockTFMagicLogSpecial.java @@ -59,37 +59,27 @@ public IIcon getIcon(int side, int meta) { if (orient == 12) { // off blocks - switch (woodType) { - default: - case META_TIME: - return (side == 1 || side == 0) ? SPR_TIMETOP : SPR_TIMECLOCKOFF; - case META_TRANS: - return (side == 1 || side == 0) ? SPR_TRANSTOP : SPR_TRANSHEARTOFF; - case META_MINE: - return (side == 1 || side == 0) ? SPR_MINETOP : SPR_MINEGEMOFF; - case META_SORT: - return (side == 1 || side == 0) ? SPR_SORTTOP : SPR_SORTEYEOFF; - } + return switch (woodType) { + default -> (side == 1 || side == 0) ? SPR_TIMETOP : SPR_TIMECLOCKOFF; + case META_TRANS -> (side == 1 || side == 0) ? SPR_TRANSTOP : SPR_TRANSHEARTOFF; + case META_MINE -> (side == 1 || side == 0) ? SPR_MINETOP : SPR_MINEGEMOFF; + case META_SORT -> (side == 1 || side == 0) ? SPR_SORTTOP : SPR_SORTEYEOFF; + }; } else { - switch (woodType) { - default: - case META_TIME: - return orient == 0 && (side == 1 || side == 0) ? SPR_TIMETOP - : (orient == 4 && (side == 5 || side == 4) ? SPR_TIMETOP - : (orient == 8 && (side == 2 || side == 3) ? SPR_TIMETOP : SPR_TIMECLOCK)); - case META_TRANS: - return orient == 0 && (side == 1 || side == 0) ? SPR_TRANSTOP - : (orient == 4 && (side == 5 || side == 4) ? SPR_TRANSTOP - : (orient == 8 && (side == 2 || side == 3) ? SPR_TRANSTOP : SPR_TRANSHEART)); - case META_MINE: - return orient == 0 && (side == 1 || side == 0) ? SPR_MINETOP - : (orient == 4 && (side == 5 || side == 4) ? SPR_MINETOP - : (orient == 8 && (side == 2 || side == 3) ? SPR_MINETOP : SPR_MINEGEM)); - case META_SORT: - return orient == 0 && (side == 1 || side == 0) ? SPR_SORTTOP - : (orient == 4 && (side == 5 || side == 4) ? SPR_SORTTOP - : (orient == 8 && (side == 2 || side == 3) ? SPR_SORTTOP : SPR_SORTEYE)); - } + return switch (woodType) { + default -> orient == 0 && (side == 1 || side == 0) ? SPR_TIMETOP + : (orient == 4 && (side == 5 || side == 4) ? SPR_TIMETOP + : (orient == 8 && (side == 2 || side == 3) ? SPR_TIMETOP : SPR_TIMECLOCK)); + case META_TRANS -> orient == 0 && (side == 1 || side == 0) ? SPR_TRANSTOP + : (orient == 4 && (side == 5 || side == 4) ? SPR_TRANSTOP + : (orient == 8 && (side == 2 || side == 3) ? SPR_TRANSTOP : SPR_TRANSHEART)); + case META_MINE -> orient == 0 && (side == 1 || side == 0) ? SPR_MINETOP + : (orient == 4 && (side == 5 || side == 4) ? SPR_MINETOP + : (orient == 8 && (side == 2 || side == 3) ? SPR_MINETOP : SPR_MINEGEM)); + case META_SORT -> orient == 0 && (side == 1 || side == 0) ? SPR_SORTTOP + : (orient == 4 && (side == 5 || side == 4) ? SPR_SORTTOP + : (orient == 8 && (side == 2 || side == 3) ? SPR_SORTTOP : SPR_SORTEYE)); + }; } } @@ -103,20 +93,18 @@ public void updateTick(World world, int x, int y, int z, Random rand) { } if (!world.isRemote) { switch (meta & 3) { - case 0: + case 0 -> { // tree of time effect world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "random.click", 0.1F, 0.5F); doTreeOfTimeEffect(world, x, y, z, rand); - break; - case 1: + } + case 1 -> // tree of transformation effect doTreeOfTransformationEffect(world, x, y, z, rand); - break; - case 2: + case 2 -> // miner's tree effect doMinersTreeEffect(world, x, y, z, rand); - break; - case 3: + case 3 -> // sorting tree effect doSortingTreeEffect(world, x, y, z, rand); } @@ -263,7 +251,7 @@ private void doSortingTreeEffect(World world, int x, int y, int z, Random rand) int YSEARCH = 16; int ZSEARCH = 16; - ArrayList chests = new ArrayList(); + ArrayList chests = new ArrayList<>(); int itemCount = 0; for (int sx = x - XSEARCH; sx < x + XSEARCH; sx++) { @@ -393,9 +381,7 @@ private boolean isSortingMatch(ItemStack beingSorted, ItemStack currentItem) { private Object getCreativeTab(Item item) { try { return ObfuscationReflectionHelper.getPrivateValue(Item.class, item, 0); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (SecurityException e) { + } catch (IllegalArgumentException | SecurityException e) { e.printStackTrace(); } return null; @@ -446,9 +432,8 @@ public int getLightValue(IBlockAccess world, int x, int y, int z) { /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { + public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { itemList.add(new ItemStack(item, 1, 0)); itemList.add(new ItemStack(item, 1, 1)); itemList.add(new ItemStack(item, 1, 2)); diff --git a/src/main/java/twilightforest/block/BlockTFMazestone.java b/src/main/java/twilightforest/block/BlockTFMazestone.java index af71fce179..ebccfed0d8 100644 --- a/src/main/java/twilightforest/block/BlockTFMazestone.java +++ b/src/main/java/twilightforest/block/BlockTFMazestone.java @@ -57,25 +57,16 @@ public BlockTFMazestone() { */ @Override public IIcon getIcon(int side, int meta) { - switch (meta) { - case 0: - default: - return TEX_PLAIN; - case 1: - return TEX_BRICK; - case 2: - return side > 1 ? TEX_PILLAR : TEX_PLAIN; - case 3: - return side > 1 ? TEX_DECO : TEX_BRICK; - case 4: - return TEX_CRACKED; - case 5: - return TEX_MOSSY; - case 6: - return side > 1 ? TEX_BRICK : TEX_MOSAIC; - case 7: - return side > 1 ? TEX_BRICK : TEX_BORDER; - } + return switch (meta) { + default -> TEX_PLAIN; + case 1 -> TEX_BRICK; + case 2 -> side > 1 ? TEX_PILLAR : TEX_PLAIN; + case 3 -> side > 1 ? TEX_DECO : TEX_BRICK; + case 4 -> TEX_CRACKED; + case 5 -> TEX_MOSSY; + case 6 -> side > 1 ? TEX_BRICK : TEX_MOSAIC; + case 7 -> side > 1 ? TEX_BRICK : TEX_BORDER; + }; } @Override @@ -108,9 +99,8 @@ public void harvestBlock(World world, EntityPlayer entityplayer, int x, int y, i /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); diff --git a/src/main/java/twilightforest/block/BlockTFMoonworm.java b/src/main/java/twilightforest/block/BlockTFMoonworm.java index 8ff218e1d9..81dc651eca 100644 --- a/src/main/java/twilightforest/block/BlockTFMoonworm.java +++ b/src/main/java/twilightforest/block/BlockTFMoonworm.java @@ -31,27 +31,16 @@ public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) int facing = world.getBlockMetadata(x, y, z) & 7; float wide = 0.25F; switch (facing) { - case 1: - setBlockBounds(0.0F, 0.25F, 0.5F - wide, wide, 0.75F, 0.5F + wide); - break; - case 2: - setBlockBounds(1.0F - wide, 0.25F, 0.5F - wide, 1.0F, 0.75F, 0.5F + wide); - break; - case 3: - setBlockBounds(0.5F - wide, 0.25F, 0.0F, 0.5F + wide, 0.75F, wide); - break; - case 4: - setBlockBounds(0.5F - wide, 0.25F, 1.0F - wide, 0.5F + wide, 0.75F, 1.0F); - break; - case 5: - setBlockBounds(0.5F - wide, 0.0F, 0.25F, 0.5F + wide, wide, 0.75F); - break; - case 6: - setBlockBounds(0.5F - wide, 1.0F - wide, 0.25F, 0.5F + wide, 1.0F, 0.75F); - break; - default: + case 1 -> setBlockBounds(0.0F, 0.25F, 0.5F - wide, wide, 0.75F, 0.5F + wide); + case 2 -> setBlockBounds(1.0F - wide, 0.25F, 0.5F - wide, 1.0F, 0.75F, 0.5F + wide); + case 3 -> setBlockBounds(0.5F - wide, 0.25F, 0.0F, 0.5F + wide, 0.75F, wide); + case 4 -> setBlockBounds(0.5F - wide, 0.25F, 1.0F - wide, 0.5F + wide, 0.75F, 1.0F); + case 5 -> setBlockBounds(0.5F - wide, 0.0F, 0.25F, 0.5F + wide, wide, 0.75F); + case 6 -> setBlockBounds(0.5F - wide, 1.0F - wide, 0.25F, 0.5F + wide, 1.0F, 0.75F); + default -> { float f1 = 0.1F; setBlockBounds(0.5F - f1, 0.0F, 0.5F - f1, 0.5F + f1, 0.6F, 0.5F + f1); + } } } diff --git a/src/main/java/twilightforest/block/BlockTFNagastone.java b/src/main/java/twilightforest/block/BlockTFNagastone.java index 9ea49721e1..5030474cf6 100644 --- a/src/main/java/twilightforest/block/BlockTFNagastone.java +++ b/src/main/java/twilightforest/block/BlockTFNagastone.java @@ -166,43 +166,25 @@ public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, int orient = 0; if (type == 0) { // head! - switch (side) { - case 0: - case 1: - default: + orient = switch (side) { + default -> // don't know - orient = 1; - break; - case 2: - orient = 0; - break; - case 3: - orient = 1; - break; - case 4: - orient = 2; - break; - case 5: - orient = 3; - break; - } + 1; + case 2 -> 0; + case 3 -> 1; + case 4 -> 2; + case 5 -> 3; + }; } if (type == 12) { // straight - switch (side) { - case 0: - case 1: - orient = 2; // u/d - break; - case 2: - case 3: - orient = 1; // e/w - break; - case 4: - case 5: - orient = 0; // n/s - break; - } + // n/s + orient = switch (side) { + case 0, 1 -> 2; // u/d + case 2, 3 -> 1; // e/w + case 4, 5 -> 0; + default -> orient; + }; } return type | orient; @@ -294,18 +276,22 @@ public boolean placePerfectFitHead(World world, int x, int y, int z) { // if the first connection is n/s/e/w, and the second connection is not, we win! // System.out.println("Got a perfect head fit : " + connect); switch (connect) { - case 0: + case 0 -> { world.setBlock(x, y, z, this, 1, 3); return true; - case 1: + } + case 1 -> { world.setBlock(x, y, z, this, 0, 3); return true; - case 2: + } + case 2 -> { world.setBlock(x, y, z, this, 3, 3); return true; - case 3: + } + case 3 -> { world.setBlock(x, y, z, this, 2, 3); return true; + } } return false; // this is impossible } else { @@ -360,22 +346,17 @@ public int getPosibleConnection(World world, int x, int y, int z, int exclude1, * Is there nagastone in the following direction? 0 = n, 1 = s, 2 = w, 3 = e, 4 = u, 5 = d; */ public boolean isNagaStoneInDirection(World par1World, int x, int y, int z, int direction) { - switch (direction) { - case 0: - return par1World.getBlock(x, y, z - 1) == this; - case 1: - return par1World.getBlock(x, y, z + 1) == this; - case 2: - return par1World.getBlock(x - 1, y, z) == this; - case 3: - return par1World.getBlock(x + 1, y, z) == this; - case 4: - return par1World.getBlock(x, y - 1, z) == this; - case 5: - return par1World.getBlock(x, y + 1, z) == this; - } - // welp, - return false; + return switch (direction) { + case 0 -> par1World.getBlock(x, y, z - 1) == this; + case 1 -> par1World.getBlock(x, y, z + 1) == this; + case 2 -> par1World.getBlock(x - 1, y, z) == this; + case 3 -> par1World.getBlock(x + 1, y, z) == this; + case 4 -> par1World.getBlock(x, y - 1, z) == this; + case 5 -> par1World.getBlock(x, y + 1, z) == this; + default -> + // welp, + false; + }; } /** @@ -404,63 +385,87 @@ public IIcon getIcon(int side, int meta) { if (orient == 0) { // north switch (side) { - case 0: + case 0 -> { return BOTTOM_TIP; - case 1: + } + case 1 -> { return TOP_TIP; - case 2: + } + case 2 -> { return FACE_FRONT; - case 3: + } + case 3 -> { return CROSS_SECTION; - case 4: + } + case 4 -> { return FACE_LEFT; - case 5: + } + case 5 -> { return FACE_RIGHT; + } } } else if (orient == 1) { switch (side) { - case 0: + case 0 -> { return BOTTOM_TIP; - case 1: + } + case 1 -> { return TOP_TIP; - case 2: + } + case 2 -> { return CROSS_SECTION; - case 3: + } + case 3 -> { return FACE_FRONT; - case 4: + } + case 4 -> { return FACE_RIGHT; - case 5: + } + case 5 -> { return FACE_LEFT; + } } } else if (orient == 2) { switch (side) { - case 0: + case 0 -> { return BOTTOM_TIP; - case 1: + } + case 1 -> { return TOP_TIP; - case 2: + } + case 2 -> { return FACE_RIGHT; - case 3: + } + case 3 -> { return FACE_LEFT; - case 4: + } + case 4 -> { return FACE_FRONT; - case 5: + } + case 5 -> { return CROSS_SECTION; + } } } else if (orient == 3) { switch (side) { - case 0: + case 0 -> { return BOTTOM_TIP; - case 1: + } + case 1 -> { return TOP_TIP; - case 2: + } + case 2 -> { return FACE_LEFT; - case 3: + } + case 3 -> { return FACE_RIGHT; - case 4: + } + case 4 -> { return CROSS_SECTION; - case 5: + } + case 5 -> { return FACE_FRONT; + } } } } @@ -470,63 +475,87 @@ public IIcon getIcon(int side, int meta) { if (orient == 0) { // north switch (side) { - case 0: + case 0 -> { return CROSS_SECTION; - case 1: + } + case 1 -> { return TOP_TIP; - case 2: + } + case 2 -> { return CROSS_SECTION; - case 3: + } + case 3 -> { return TIP_RIGHT; - case 4: + } + case 4 -> { return LEFT_DOWN; - case 5: + } + case 5 -> { return RIGHT_DOWN; + } } } else if (orient == 1) { switch (side) { - case 0: + case 0 -> { return CROSS_SECTION; - case 1: + } + case 1 -> { return TOP_TIP; - case 2: + } + case 2 -> { return TIP_LEFT; - case 3: + } + case 3 -> { return CROSS_SECTION; - case 4: + } + case 4 -> { return RIGHT_DOWN; - case 5: + } + case 5 -> { return LEFT_DOWN; + } } } else if (orient == 2) { switch (side) { - case 0: + case 0 -> { return CROSS_SECTION; - case 1: + } + case 1 -> { return TOP_TIP; - case 2: + } + case 2 -> { return RIGHT_DOWN; - case 3: + } + case 3 -> { return LEFT_DOWN; - case 4: + } + case 4 -> { return CROSS_SECTION; - case 5: + } + case 5 -> { return TIP_LEFT; + } } } else if (orient == 3) { switch (side) { - case 0: + case 0 -> { return CROSS_SECTION; - case 1: + } + case 1 -> { return TOP_TIP; - case 2: + } + case 2 -> { return LEFT_DOWN; - case 3: + } + case 3 -> { return RIGHT_DOWN; - case 4: + } + case 4 -> { return TIP_RIGHT; - case 5: + } + case 5 -> { return CROSS_SECTION; + } } } @@ -537,63 +566,87 @@ public IIcon getIcon(int side, int meta) { if (orient == 0) { // north switch (side) { - case 0: + case 0 -> { return BOTTOM_TIP; - case 1: + } + case 1 -> { return CROSS_SECTION; - case 2: + } + case 2 -> { return CROSS_SECTION; - case 3: + } + case 3 -> { return TIP_LEFT; - case 4: + } + case 4 -> { return LEFT_UP; - case 5: + } + case 5 -> { return RIGHT_UP; + } } } else if (orient == 1) { switch (side) { - case 0: + case 0 -> { return BOTTOM_TIP; - case 1: + } + case 1 -> { return CROSS_SECTION; - case 2: + } + case 2 -> { return TIP_RIGHT; - case 3: + } + case 3 -> { return CROSS_SECTION; - case 4: + } + case 4 -> { return RIGHT_UP; - case 5: + } + case 5 -> { return LEFT_UP; + } } } else if (orient == 2) { switch (side) { - case 0: + case 0 -> { return BOTTOM_TIP; - case 1: + } + case 1 -> { return CROSS_SECTION; - case 2: + } + case 2 -> { return RIGHT_UP; - case 3: + } + case 3 -> { return LEFT_UP; - case 4: + } + case 4 -> { return CROSS_SECTION; - case 5: + } + case 5 -> { return TIP_RIGHT; + } } } else if (orient == 3) { switch (side) { - case 0: + case 0 -> { return BOTTOM_TIP; - case 1: + } + case 1 -> { return CROSS_SECTION; - case 2: + } + case 2 -> { return LEFT_UP; - case 3: + } + case 3 -> { return RIGHT_UP; - case 4: + } + case 4 -> { return TIP_LEFT; - case 5: + } + case 5 -> { return CROSS_SECTION; + } } } @@ -603,63 +656,87 @@ public IIcon getIcon(int side, int meta) { if (orient == 0) { // north switch (side) { - case 0: + case 0 -> { return BOTTOM_LONG; - case 1: + } + case 1 -> { return TOP_LONG; - case 2: + } + case 2 -> { return LONG_SIDE; - case 3: + } + case 3 -> { return LONG_SIDE; - case 4: + } + case 4 -> { return CROSS_SECTION; - case 5: + } + case 5 -> { return CROSS_SECTION; + } } } else if (orient == 1) { switch (side) { - case 0: + case 0 -> { return BOTTOM_LONG; - case 1: + } + case 1 -> { return TOP_LONG; - case 2: + } + case 2 -> { return CROSS_SECTION; - case 3: + } + case 3 -> { return CROSS_SECTION; - case 4: + } + case 4 -> { return LONG_SIDE; - case 5: + } + case 5 -> { return LONG_SIDE; + } } } else if (orient == 2) { switch (side) { - case 0: + case 0 -> { return CROSS_SECTION; - case 1: + } + case 1 -> { return CROSS_SECTION; - case 2: + } + case 2 -> { return LONG_SIDE; - case 3: + } + case 3 -> { return LONG_SIDE; - case 4: + } + case 4 -> { return LONG_SIDE; - case 5: + } + case 5 -> { return LONG_SIDE; + } } } else if (orient == 3) { switch (side) { - case 0: + case 0 -> { return CROSS_SECTION; - case 1: + } + case 1 -> { return TURN_TOP; - case 2: + } + case 2 -> { return LONG_SIDE; - case 3: + } + case 3 -> { return LONG_SIDE; - case 4: + } + case 4 -> { return LONG_SIDE; - case 5: + } + case 5 -> { return LONG_SIDE; + } } } @@ -672,7 +749,7 @@ public IIcon getIcon(int side, int meta) { * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 13)); } diff --git a/src/main/java/twilightforest/block/BlockTFPlanks.java b/src/main/java/twilightforest/block/BlockTFPlanks.java index 8397477c95..9de38cd2bf 100644 --- a/src/main/java/twilightforest/block/BlockTFPlanks.java +++ b/src/main/java/twilightforest/block/BlockTFPlanks.java @@ -61,7 +61,7 @@ public int damageDropped(int meta) { @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativeTab, List itemList) { + public void getSubBlocks(Item item, CreativeTabs creativeTab, List itemList) { for (int i = 0; i < textureNames.length; i++) { itemList.add(new ItemStack(item, 1, i)); } diff --git a/src/main/java/twilightforest/block/BlockTFPlant.java b/src/main/java/twilightforest/block/BlockTFPlant.java index 9c6ceec178..50213f6e5f 100644 --- a/src/main/java/twilightforest/block/BlockTFPlant.java +++ b/src/main/java/twilightforest/block/BlockTFPlant.java @@ -127,21 +127,15 @@ public boolean canBlockStay(World world, int x, int y, int z, int meta) { // System.out.println("Can block stay? meta is " + meta); Block soil = world.getBlock(x, y - 1, z); - switch (meta) { - case META_TORCHBERRY: - case META_ROOT_STRAND: - return BlockTFPlant.canPlaceRootBelow(world, x, y + 1, z); - case 0: // let's make this happen - case META_FORESTGRASS: - case META_DEADBUSH: - return (soil != null && soil.canSustainPlant(world, x, y - 1, z, ForgeDirection.UP, this)); - case META_MUSHGLOOM: - case META_MOSSPATCH: - return soil != null && soil.isSideSolid(world, x, y, z, ForgeDirection.UP); - default: - return (world.getFullBlockLightValue(x, y, z) >= 3 || world.canBlockSeeTheSky(x, y, z)) - && (soil != null && soil.canSustainPlant(world, x, y - 1, z, ForgeDirection.UP, this)); - } + return switch (meta) { + case META_TORCHBERRY, META_ROOT_STRAND -> BlockTFPlant.canPlaceRootBelow(world, x, y + 1, z); // let's make + // this happen + case 0, META_FORESTGRASS, META_DEADBUSH -> (soil != null + && soil.canSustainPlant(world, x, y - 1, z, ForgeDirection.UP, this)); + case META_MUSHGLOOM, META_MOSSPATCH -> soil != null && soil.isSideSolid(world, x, y, z, ForgeDirection.UP); + default -> (world.getFullBlockLightValue(x, y, z) >= 3 || world.canBlockSeeTheSky(x, y, z)) + && (soil != null && soil.canSustainPlant(world, x, y - 1, z, ForgeDirection.UP, this)); + }; } /** @@ -349,7 +343,7 @@ public static boolean canPlaceRootBelow(World world, int x, int y, int z) { */ @Override public ArrayList getDrops(World world, int x, int y, int z, int meta, int fortune) { - ArrayList ret = new ArrayList(); + ArrayList ret = new ArrayList<>(); // TODO: this needs to not drop if the player is shearing! Grrr! @@ -415,7 +409,7 @@ public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int */ @Override public ArrayList onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune) { - ArrayList ret = new ArrayList(); + ArrayList ret = new ArrayList<>(); ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z))); // world.setBlockToAir(x, y, z); return ret; @@ -434,9 +428,8 @@ public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, } // returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { + public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { itemList.add(new ItemStack(this, 1, META_MOSSPATCH)); itemList.add(new ItemStack(this, 1, META_MAYAPPLE)); // itemList.add(new ItemStack(this, 1, META_CLOVERPATCH)); @@ -458,13 +451,10 @@ public void setBlockBoundsForItemRender() { public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z) { int meta = world.getBlockMetadata(x, y, z); - switch (meta) { - case META_MOSSPATCH: - case META_MUSHGLOOM: - return EnumPlantType.Cave; - default: - return EnumPlantType.Plains; - } + return switch (meta) { + case META_MOSSPATCH, META_MUSHGLOOM -> EnumPlantType.Cave; + default -> EnumPlantType.Plains; + }; } @Override diff --git a/src/main/java/twilightforest/block/BlockTFPortal.java b/src/main/java/twilightforest/block/BlockTFPortal.java index c17564d8c2..236fc5d616 100644 --- a/src/main/java/twilightforest/block/BlockTFPortal.java +++ b/src/main/java/twilightforest/block/BlockTFPortal.java @@ -72,7 +72,7 @@ public IIcon getIcon(int side, int meta) { @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister par1IconRegister) { - ; // don't load anything + // don't load anything } /** @@ -268,8 +268,7 @@ public int getRenderBlockPass() { @Override public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity) { if (entity.ridingEntity == null && entity.riddenByEntity == null && entity.timeUntilPortal <= 0) { - if (entity instanceof EntityPlayerMP) { - EntityPlayerMP playerMP = (EntityPlayerMP) entity; + if (entity instanceof EntityPlayerMP playerMP) { if (playerMP.timeUntilPortal > 0) { // do not switch dimensions if the player has any time on this thinger @@ -393,9 +392,8 @@ public void randomDisplayTick(World world, int i, int j, int k, Random random) { /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); } } diff --git a/src/main/java/twilightforest/block/BlockTFRoots.java b/src/main/java/twilightforest/block/BlockTFRoots.java index ca1bc1e5f7..77f6825099 100644 --- a/src/main/java/twilightforest/block/BlockTFRoots.java +++ b/src/main/java/twilightforest/block/BlockTFRoots.java @@ -56,16 +56,15 @@ public void registerBlockIcons(IIconRegister par1IconRegister) { */ @Override public Item getItemDropped(int meta, Random random, int j) { - switch (meta) { - case ROOT_META: + return switch (meta) { + case ROOT_META -> // roots drop sticks - return Items.stick; - case OREROOT_META: + Items.stick; + case OREROOT_META -> // oreroots drop liveroot - return TFItems.liveRoot; - default: - return Item.getItemFromBlock(this); - } + TFItems.liveRoot; + default -> Item.getItemFromBlock(this); + }; } /** @@ -73,17 +72,17 @@ public Item getItemDropped(int meta, Random random, int j) { */ @Override public int damageDropped(int meta) { - switch (meta) { - case ROOT_META: + return switch (meta) { + case ROOT_META -> // roots drop sticks, no meta - return 0; - case OREROOT_META: + 0; + case OREROOT_META -> // oreroots drop liveroot, no meta - return 0; - default: + 0; + default -> // set log flag on wood blocks - return meta | 8; - } + meta | 8; + }; } /** @@ -96,13 +95,12 @@ public int damageDropped(int meta) { */ @Override public int quantityDropped(int meta, int fortune, Random random) { - switch (meta) { - case ROOT_META: + return switch (meta) { + case ROOT_META -> // roots drop several sticks - return 3 + random.nextInt(2); - default: - return super.quantityDropped(meta, fortune, random); - } + 3 + random.nextInt(2); + default -> super.quantityDropped(meta, fortune, random); + }; } /** @@ -110,7 +108,7 @@ public int quantityDropped(int meta, int fortune, Random random) { */ @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); } diff --git a/src/main/java/twilightforest/block/BlockTFSapling.java b/src/main/java/twilightforest/block/BlockTFSapling.java index 4bdbd8e1ad..ffb7e8d128 100644 --- a/src/main/java/twilightforest/block/BlockTFSapling.java +++ b/src/main/java/twilightforest/block/BlockTFSapling.java @@ -68,37 +68,18 @@ public void func_149878_d(World world, int x, int y, int z, Random rand) { int var9 = 0; boolean largeTree = false; - switch (meta) { - case 1: - treeGenerator = new TFGenCanopyTree(true); - break; - case 2: - treeGenerator = new TFGenMangroveTree(true); - break; - case 3: - treeGenerator = new TFGenDarkCanopyTree(true); - break; - case 4: - treeGenerator = new TFGenHollowTree(true); - break; - case 5: - treeGenerator = new TFGenTreeOfTime(true); - break; - case 6: - treeGenerator = new TFGenTreeOfTransformation(true); - break; - case 7: - treeGenerator = new TFGenMinersTree(true); - break; - case 8: - treeGenerator = new TFGenSortingTree(true); - break; - case 9: - treeGenerator = rand.nextInt(7) == 0 ? new TFGenLargeRainboak(true) : new TFGenSmallRainboak(true); - break; - default: - treeGenerator = new TFGenSmallTwilightOak(true); - } + treeGenerator = switch (meta) { + case 1 -> new TFGenCanopyTree(true); + case 2 -> new TFGenMangroveTree(true); + case 3 -> new TFGenDarkCanopyTree(true); + case 4 -> new TFGenHollowTree(true); + case 5 -> new TFGenTreeOfTime(true); + case 6 -> new TFGenTreeOfTransformation(true); + case 7 -> new TFGenMinersTree(true); + case 8 -> new TFGenSortingTree(true); + case 9 -> rand.nextInt(7) == 0 ? new TFGenLargeRainboak(true) : new TFGenSmallRainboak(true); + default -> new TFGenSmallTwilightOak(true); + }; if (largeTree) { world.setBlock(x + var8, y, z + var9, Blocks.air, 0, 4); @@ -151,14 +132,13 @@ public int damageDropped(int par1) { return par1; } - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override @SideOnly(Side.CLIENT) /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ - public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { + public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { itemList.add(new ItemStack(item, 1, 0)); itemList.add(new ItemStack(item, 1, 1)); itemList.add(new ItemStack(item, 1, 2)); diff --git a/src/main/java/twilightforest/block/BlockTFShield.java b/src/main/java/twilightforest/block/BlockTFShield.java index 5a86e9e9e5..2441b5796b 100644 --- a/src/main/java/twilightforest/block/BlockTFShield.java +++ b/src/main/java/twilightforest/block/BlockTFShield.java @@ -63,9 +63,8 @@ public void registerBlockIcons(IIconRegister par1IconRegister) { /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); } diff --git a/src/main/java/twilightforest/block/BlockTFSlider.java b/src/main/java/twilightforest/block/BlockTFSlider.java index 5473d531b4..2d63956054 100644 --- a/src/main/java/twilightforest/block/BlockTFSlider.java +++ b/src/main/java/twilightforest/block/BlockTFSlider.java @@ -53,33 +53,29 @@ public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, float pixel = 0.0625F; float inset = 5F; - switch (rotation) { - case 0: - default: - return AxisAlignedBB.getBoundingBox( - x + pixel * inset, - y, - z + pixel * inset, - x + 1F - pixel * inset, - y + 1F, - z + 1F - pixel * inset); - case 4: - return AxisAlignedBB.getBoundingBox( - x, - y + pixel * inset, - z + pixel * inset, - x + 1F, - y + 1F - pixel * inset, - z + 1F - pixel * inset); - case 8: - return AxisAlignedBB.getBoundingBox( - x + pixel * inset, - y + pixel * inset, - z, - x + 1F - pixel * inset, - y + 1F - pixel * inset, - z + 1F); - } + return switch (rotation) { + default -> AxisAlignedBB.getBoundingBox( + x + pixel * inset, + y, + z + pixel * inset, + x + 1F - pixel * inset, + y + 1F, + z + 1F - pixel * inset); + case 4 -> AxisAlignedBB.getBoundingBox( + x, + y + pixel * inset, + z + pixel * inset, + x + 1F, + y + 1F - pixel * inset, + z + 1F - pixel * inset); + case 8 -> AxisAlignedBB.getBoundingBox( + x + pixel * inset, + y + pixel * inset, + z, + x + 1F - pixel * inset, + y + 1F - pixel * inset, + z + 1F); + }; } @@ -106,16 +102,9 @@ public void setBlockBoundsBasedOnMeta(int meta) { float inset = 5F; switch (rotation) { - case 0: - default: - this.setBlockBounds(pixel * inset, 0, pixel * inset, 1F - pixel * inset, 1F, 1F - pixel * inset); - break; - case 4: - this.setBlockBounds(0, pixel * inset, pixel * inset, 1F, 1F - pixel * inset, 1F - pixel * inset); - break; - case 8: - this.setBlockBounds(pixel * inset, pixel * inset, 0, 1F - pixel * inset, 1F - pixel * inset, 1F); - break; + default -> this.setBlockBounds(pixel * inset, 0, pixel * inset, 1F - pixel * inset, 1F, 1F - pixel * inset); + case 4 -> this.setBlockBounds(0, pixel * inset, pixel * inset, 1F, 1F - pixel * inset, 1F - pixel * inset); + case 8 -> this.setBlockBounds(pixel * inset, pixel * inset, 0, 1F - pixel * inset, 1F - pixel * inset, 1F); } } @@ -149,32 +138,21 @@ public IIcon getIcon(int side, int meta) { int rotation = meta & 12; if (rotation == 0) { - switch (side) { - case 0: - case 1: - return this.topIcon; - default: - return this.vertIcon; - } + return switch (side) { + case 0, 1 -> this.topIcon; + default -> this.vertIcon; + }; } else if (rotation == 4) { - switch (side) { - case 4: - case 5: - return this.topIcon; - default: - return this.horiIcon; - } + return switch (side) { + case 4, 5 -> this.topIcon; + default -> this.horiIcon; + }; } else { // rotation == 8 - switch (side) { - case 2: - case 3: - return this.topIcon; - case 0: - case 1: - return this.vertIcon; - default: - return this.horiIcon; - } + return switch (side) { + case 2, 3 -> this.topIcon; + case 0, 1 -> this.vertIcon; + default -> this.horiIcon; + }; } // int type = 0; @@ -304,7 +282,7 @@ public void onBlockAdded(World world, int x, int y, int z) { * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); diff --git a/src/main/java/twilightforest/block/BlockTFThorns.java b/src/main/java/twilightforest/block/BlockTFThorns.java index 85c8a6ec81..e0546579cd 100644 --- a/src/main/java/twilightforest/block/BlockTFThorns.java +++ b/src/main/java/twilightforest/block/BlockTFThorns.java @@ -29,8 +29,8 @@ public class BlockTFThorns extends BlockRotatedPillar { private static final float THORN_DAMAGE = 4.0F; private String[] names; - private IIcon sideIcons[]; - private IIcon topIcons[]; + private IIcon[] sideIcons; + private IIcon[] topIcons; protected BlockTFThorns() { super(Material.wood); @@ -77,33 +77,29 @@ public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int rotation = meta & 12; float pixel = 0.0625F; - switch (rotation) { - case 0: - default: - return AxisAlignedBB.getBoundingBox( - x + pixel * 3F, - y, - z + pixel * 3F, - x + 1F - pixel * 3F, - y + 1F, - z + 1F - pixel * 3F); - case 4: - return AxisAlignedBB.getBoundingBox( - x, - y + pixel * 3F, - z + pixel * 3F, - x + 1F, - y + 1F - pixel * 3F, - z + 1F - pixel * 3F); - case 8: - return AxisAlignedBB.getBoundingBox( - x + pixel * 3F, - y + pixel * 3F, - z, - x + 1F - pixel * 3F, - y + 1F - pixel * 3F, - z + 1F); - } + return switch (rotation) { + default -> AxisAlignedBB.getBoundingBox( + x + pixel * 3F, + y, + z + pixel * 3F, + x + 1F - pixel * 3F, + y + 1F, + z + 1F - pixel * 3F); + case 4 -> AxisAlignedBB.getBoundingBox( + x, + y + pixel * 3F, + z + pixel * 3F, + x + 1F, + y + 1F - pixel * 3F, + z + 1F - pixel * 3F); + case 8 -> AxisAlignedBB.getBoundingBox( + x + pixel * 3F, + y + pixel * 3F, + z, + x + 1F - pixel * 3F, + y + 1F - pixel * 3F, + z + 1F); + }; } @@ -156,18 +152,18 @@ private void doThornBurst(World world, int x, int y, int z, int meta) { int rotation = meta & 12; switch (rotation) { - case 0: + case 0 -> { growThorns(world, x, y, z, ForgeDirection.UP); growThorns(world, x, y, z, ForgeDirection.DOWN); - break; - case 4: + } + case 4 -> { growThorns(world, x, y, z, ForgeDirection.EAST); growThorns(world, x, y, z, ForgeDirection.WEST); - break; - case 8: + } + case 8 -> { growThorns(world, x, y, z, ForgeDirection.NORTH); growThorns(world, x, y, z, ForgeDirection.SOUTH); - break; + } } // also try three random directions @@ -218,19 +214,11 @@ private void growThorns(World world, int x, int y, int z, ForgeDirection dir) { * @return */ public static int getMetaFor(ForgeDirection dir) { - switch (dir) { - case UNKNOWN: - default: - case UP: - case DOWN: - return 0; - case EAST: - case WEST: - return 4; - case NORTH: - case SOUTH: - return 8; - } + return switch (dir) { + default -> 0; + case EAST, WEST -> 4; + case NORTH, SOUTH -> 8; + }; } /** @@ -291,9 +279,8 @@ public boolean canSustainLeaves(IBlockAccess world, int x, int y, int z) { /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { for (int i = 0; i < getNames().length; i++) { par3List.add(new ItemStack(par1, 1, i)); } diff --git a/src/main/java/twilightforest/block/BlockTFTowerDevice.java b/src/main/java/twilightforest/block/BlockTFTowerDevice.java index 7b2302d6a1..bfc16b2765 100644 --- a/src/main/java/twilightforest/block/BlockTFTowerDevice.java +++ b/src/main/java/twilightforest/block/BlockTFTowerDevice.java @@ -94,28 +94,37 @@ public int tickRate() { @Override public IIcon getIcon(int side, int meta) { switch (meta) { - case META_REAPPEARING_INACTIVE: - default: + default -> { return TEX_REAPPEARING_INACTIVE; - case META_REAPPEARING_ACTIVE: + } + case META_REAPPEARING_ACTIVE -> { return TEX_REAPPEARING_ACTIVE; - case META_VANISH_INACTIVE: + } + case META_VANISH_INACTIVE -> { return TEX_VANISH_INACTIVE; - case META_VANISH_ACTIVE: + } + case META_VANISH_ACTIVE -> { return TEX_VANISH_ACTIVE; - case META_VANISH_LOCKED: + } + case META_VANISH_LOCKED -> { return TEX_VANISH_LOCKED; - case META_VANISH_UNLOCKED: + } + case META_VANISH_UNLOCKED -> { return TEX_VANISH_UNLOCKED; - case META_BUILDER_INACTIVE: + } + case META_BUILDER_INACTIVE -> { return TEX_BUILDER_INACTIVE; - case META_BUILDER_TIMEOUT: + } + case META_BUILDER_TIMEOUT -> { return TEX_BUILDER_TIMEOUT; - case META_BUILDER_ACTIVE: + } + case META_BUILDER_ACTIVE -> { return TEX_BUILDER_ACTIVE; - case META_ANTIBUILDER: + } + case META_ANTIBUILDER -> { return TEX_ANTIBUILDER; - case META_GHASTTRAP_INACTIVE: + } + case META_GHASTTRAP_INACTIVE -> { if (side >= 2) { return TEX_GHASTTRAP_INACTIVE; } else if (side == 1) { @@ -123,7 +132,8 @@ public IIcon getIcon(int side, int meta) { } else { return TFBlocks.towerWood.getIcon(side, 1); } - case META_GHASTTRAP_ACTIVE: + } + case META_GHASTTRAP_ACTIVE -> { if (side >= 2) { return TEX_GHASTTRAP_ACTIVE; } else if (side == 1) { @@ -131,10 +141,13 @@ public IIcon getIcon(int side, int meta) { } else { return TFBlocks.towerWood.getIcon(side, 1); } - case META_REACTOR_INACTIVE: + } + case META_REACTOR_INACTIVE -> { return TEX_REACTOR_INACTIVE; - case META_REACTOR_ACTIVE: + } + case META_REACTOR_ACTIVE -> { return TEX_REACTOR_ACTIVE; + } } } @@ -187,7 +200,7 @@ public void registerBlockIcons(IIconRegister par1IconRegister) { * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, META_REAPPEARING_INACTIVE)); par3List.add(new ItemStack(par1, 1, META_VANISH_INACTIVE)); par3List.add(new ItemStack(par1, 1, META_VANISH_LOCKED)); @@ -261,16 +274,10 @@ public float getBlockHardness(World world, int x, int y, int z) { // most vanish blocks can't be broken int meta = world.getBlockMetadata(x, y, z); - switch (meta) { - case META_REAPPEARING_ACTIVE: - case META_VANISH_INACTIVE: - case META_VANISH_ACTIVE: - case META_VANISH_LOCKED: - case META_VANISH_UNLOCKED: - return -1; - default: - return super.getBlockHardness(world, x, y, z); - } + return switch (meta) { + case META_REAPPEARING_ACTIVE, META_VANISH_INACTIVE, META_VANISH_ACTIVE, META_VANISH_LOCKED, META_VANISH_UNLOCKED -> -1; + default -> super.getBlockHardness(world, x, y, z); + }; } /** @@ -603,19 +610,12 @@ public int getLightValue(IBlockAccess world, int x, int y, int z) { return 0; } - switch (meta) { - case META_BUILDER_ACTIVE: - case META_VANISH_ACTIVE: - case META_REAPPEARING_ACTIVE: - return 4; - case META_ANTIBUILDER: - return 10; - case META_GHASTTRAP_ACTIVE: - case META_REACTOR_ACTIVE: - return 15; - default: - return 0; - } + return switch (meta) { + case META_BUILDER_ACTIVE, META_VANISH_ACTIVE, META_REAPPEARING_ACTIVE -> 4; + case META_ANTIBUILDER -> 10; + case META_GHASTTRAP_ACTIVE, META_REACTOR_ACTIVE -> 15; + default -> 0; + }; } /** @@ -657,12 +657,10 @@ public TileEntity createTileEntity(World world, int metadata) { */ @Override public Item getItemDropped(int meta, Random par2Random, int par3) { - switch (meta) { - case META_ANTIBUILDER: - return null; - default: - return Item.getItemFromBlock(this); - } + return switch (meta) { + case META_ANTIBUILDER -> null; + default -> Item.getItemFromBlock(this); + }; } /** @@ -670,21 +668,14 @@ public Item getItemDropped(int meta, Random par2Random, int par3) { */ @Override public int damageDropped(int meta) { - switch (meta) { - case META_REAPPEARING_ACTIVE: - return META_REAPPEARING_INACTIVE; - case META_BUILDER_ACTIVE: - case META_BUILDER_TIMEOUT: - return META_BUILDER_INACTIVE; - case META_VANISH_ACTIVE: - return META_VANISH_INACTIVE; - case META_GHASTTRAP_ACTIVE: - return META_GHASTTRAP_INACTIVE; - case META_REACTOR_ACTIVE: - return META_REACTOR_INACTIVE; - default: - return meta; - } + return switch (meta) { + case META_REAPPEARING_ACTIVE -> META_REAPPEARING_INACTIVE; + case META_BUILDER_ACTIVE, META_BUILDER_TIMEOUT -> META_BUILDER_INACTIVE; + case META_VANISH_ACTIVE -> META_VANISH_INACTIVE; + case META_GHASTTRAP_ACTIVE -> META_GHASTTRAP_INACTIVE; + case META_REACTOR_ACTIVE -> META_REACTOR_INACTIVE; + default -> meta; + }; } // @Override diff --git a/src/main/java/twilightforest/block/BlockTFTowerTranslucent.java b/src/main/java/twilightforest/block/BlockTFTowerTranslucent.java index e90815b724..99b658e8c2 100644 --- a/src/main/java/twilightforest/block/BlockTFTowerTranslucent.java +++ b/src/main/java/twilightforest/block/BlockTFTowerTranslucent.java @@ -136,17 +136,10 @@ public float getBlockHardness(World world, int x, int y, int z) { public boolean getBlocksMovement(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { int meta = par1IBlockAccess.getBlockMetadata(par2, par3, par4); - switch (meta) { - case META_REAPPEARING_INACTIVE: - case META_REAPPEARING_ACTIVE: - default: - return false; - case META_BUILT_INACTIVE: - case META_BUILT_ACTIVE: - case META_REVERTER_REPLACEMENT: - case META_REACTOR_DEBRIS: - return true; - } + return switch (meta) { + default -> false; + case META_BUILT_INACTIVE, META_BUILT_ACTIVE, META_REVERTER_REPLACEMENT, META_REACTOR_DEBRIS -> true; + }; } /** @@ -155,25 +148,32 @@ public boolean getBlocksMovement(IBlockAccess par1IBlockAccess, int par2, int pa @Override public IIcon getIcon(int side, int meta) { switch (meta) { - case META_REAPPEARING_INACTIVE: - default: + default -> { return TEX_REAPPEARING_INACTIVE; - case META_REAPPEARING_ACTIVE: + } + case META_REAPPEARING_ACTIVE -> { return TEX_REAPPEARING_ACTIVE; - case META_BUILT_INACTIVE: + } + case META_BUILT_INACTIVE -> { return TEX_BUILT_INACTIVE; - case META_BUILT_ACTIVE: + } + case META_BUILT_ACTIVE -> { return TEX_BUILT_ACTIVE; - case META_REVERTER_REPLACEMENT: + } + case META_REVERTER_REPLACEMENT -> { return TEX_REVERTER_REPLACEMENT; - case META_REACTOR_DEBRIS: + } + case META_REACTOR_DEBRIS -> { Block toMimic = sideRNG.nextBoolean() ? (sideRNG.nextBoolean() ? Blocks.portal : Blocks.netherrack) : (sideRNG.nextBoolean() ? Blocks.bedrock : Blocks.obsidian); return toMimic.getIcon(side, meta); - case META_FAKE_GOLD: + } + case META_FAKE_GOLD -> { return Blocks.gold_block.getIcon(side, meta); - case META_FAKE_DIAMOND: + } + case META_FAKE_DIAMOND -> { return Blocks.diamond_block.getIcon(side, meta); + } } } @@ -231,7 +231,7 @@ public void updateTick(World par1World, int x, int y, int z, Random par5Random) * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @Override - public void getSubBlocks(Item item, CreativeTabs tab, List list) { + public void getSubBlocks(Item item, CreativeTabs tab, List list) { list.add(new ItemStack(item, 1, 0)); list.add(new ItemStack(item, 1, 1)); list.add(new ItemStack(item, 1, 2)); diff --git a/src/main/java/twilightforest/block/BlockTFTowerWood.java b/src/main/java/twilightforest/block/BlockTFTowerWood.java index 93710dd0bd..2147ee336b 100644 --- a/src/main/java/twilightforest/block/BlockTFTowerWood.java +++ b/src/main/java/twilightforest/block/BlockTFTowerWood.java @@ -75,19 +75,13 @@ public int colorMultiplier(IBlockAccess par1IBlockAccess, int x, int y, int z) { */ @Override public IIcon getIcon(int side, int meta) { - switch (meta) { - case 0: - default: - return TEX_PLAIN; - case 1: - return TEX_ENCASED; - case 2: - return TEX_CRACKED; - case 3: - return TEX_MOSSY; - case META_INFESTED: - return TEX_INFESTED; - } + return switch (meta) { + default -> TEX_PLAIN; + case 1 -> TEX_ENCASED; + case 2 -> TEX_CRACKED; + case 3 -> TEX_MOSSY; + case META_INFESTED -> TEX_INFESTED; + }; } @Override @@ -104,7 +98,7 @@ public void registerBlockIcons(IIconRegister par1IconRegister) { * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); diff --git a/src/main/java/twilightforest/block/BlockTFTrollRoot.java b/src/main/java/twilightforest/block/BlockTFTrollRoot.java index e0b1b7ff94..c82be1fd9f 100644 --- a/src/main/java/twilightforest/block/BlockTFTrollRoot.java +++ b/src/main/java/twilightforest/block/BlockTFTrollRoot.java @@ -33,7 +33,7 @@ public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int @Override public ArrayList onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune) { - ArrayList ret = new ArrayList(); + ArrayList ret = new ArrayList<>(); ret.add(new ItemStack(this)); return ret; } diff --git a/src/main/java/twilightforest/block/BlockTFTrollSteinn.java b/src/main/java/twilightforest/block/BlockTFTrollSteinn.java index bd33ae54bf..e770bb1cec 100644 --- a/src/main/java/twilightforest/block/BlockTFTrollSteinn.java +++ b/src/main/java/twilightforest/block/BlockTFTrollSteinn.java @@ -45,9 +45,9 @@ private void sparkle(World world, int x, int y, int z, Random rand) { int threshhold = LIGHT_THRESHHOLD; for (int side = 0; side < 6; ++side) { - double rx = (double) ((float) x + random.nextFloat()); - double ry = (double) ((float) y + random.nextFloat()); - double rz = (double) ((float) z + random.nextFloat()); + double rx = (float) x + random.nextFloat(); + double ry = (float) y + random.nextFloat(); + double rz = (float) z + random.nextFloat(); if (side == 0 && !world.getBlock(x, y - 1, z).isOpaqueCube() && world.getBlockLightValue(x, y - 1, z) <= threshhold) { diff --git a/src/main/java/twilightforest/block/BlockTFTrophy.java b/src/main/java/twilightforest/block/BlockTFTrophy.java index fb10ed113c..0bada62e9c 100644 --- a/src/main/java/twilightforest/block/BlockTFTrophy.java +++ b/src/main/java/twilightforest/block/BlockTFTrophy.java @@ -81,18 +81,9 @@ public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int x, int if (trophy != null && trophy.func_145904_a() == 0) { // hydra bounds switch (meta) { - case 1: - default: - this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F); - break; - case 2: - case 3: - this.setBlockBounds(0.25F, 0.25F, 0.0F, 0.75F, 0.75F, 1.0F); - break; - case 4: - case 5: - this.setBlockBounds(0.0F, 0.25F, 0.25F, 1.0F, 0.75F, 0.75F); - break; + default -> this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F); + case 2, 3 -> this.setBlockBounds(0.25F, 0.25F, 0.0F, 0.75F, 0.75F, 1.0F); + case 4, 5 -> this.setBlockBounds(0.0F, 0.25F, 0.25F, 1.0F, 0.75F, 0.75F); } } else if (trophy != null && trophy.func_145904_a() == 3) { // urghast bounds @@ -100,21 +91,11 @@ public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int x, int } else { // normal skull bounds switch (meta) { - case 1: - default: - this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F); - break; - case 2: - this.setBlockBounds(0.25F, 0.25F, 0.5F, 0.75F, 0.75F, 1.0F); - break; - case 3: - this.setBlockBounds(0.25F, 0.25F, 0.0F, 0.75F, 0.75F, 0.5F); - break; - case 4: - this.setBlockBounds(0.5F, 0.25F, 0.25F, 1.0F, 0.75F, 0.75F); - break; - case 5: - this.setBlockBounds(0.0F, 0.25F, 0.25F, 0.5F, 0.75F, 0.75F); + default -> this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F); + case 2 -> this.setBlockBounds(0.25F, 0.25F, 0.5F, 0.75F, 0.75F, 1.0F); + case 3 -> this.setBlockBounds(0.25F, 0.25F, 0.0F, 0.75F, 0.75F, 0.5F); + case 4 -> this.setBlockBounds(0.5F, 0.25F, 0.25F, 1.0F, 0.75F, 0.75F); + case 5 -> this.setBlockBounds(0.0F, 0.25F, 0.25F, 0.5F, 0.75F, 0.75F); } } } @@ -190,7 +171,7 @@ public void onBlockHarvested(World par1World, int par2, int par3, int par4, int @Override public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - ArrayList drops = new ArrayList(); + ArrayList drops = new ArrayList<>(); if ((metadata & 8) == 0) { ItemStack var7 = new ItemStack(TFItems.trophy, 1, this.getDamageValue(world, x, y, z)); TileEntityTFTrophy var8 = (TileEntityTFTrophy) world.getTileEntity(x, y, z); @@ -228,7 +209,7 @@ public IIcon getIcon(int side, int meta) { @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister par1IconRegister) { - ; // don't load anything + // don't load anything } } diff --git a/src/main/java/twilightforest/block/BlockTFTrophyPedestal.java b/src/main/java/twilightforest/block/BlockTFTrophyPedestal.java index ad95491bab..02509853ea 100644 --- a/src/main/java/twilightforest/block/BlockTFTrophyPedestal.java +++ b/src/main/java/twilightforest/block/BlockTFTrophyPedestal.java @@ -66,14 +66,18 @@ public IIcon getIcon(int side, int meta) { int rotatedSide = ((side - 2) + rotate) % 4; switch (rotatedSide) { - case 0: + case 0 -> { return meta > 7 ? sprNagaActive : sprNaga; - case 1: + } + case 1 -> { return meta > 7 ? sprLichActive : sprLich; - case 2: + } + case 2 -> { return meta > 7 ? sprHydraActive : sprHydra; - case 3: + } + case 3 -> { return meta > 7 ? sprUrghastActive : sprUrghast; + } } } @@ -120,7 +124,7 @@ public void registerBlockIcons(IIconRegister par1IconRegister) { * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 15)); } @@ -303,7 +307,6 @@ private void doPedestalEffect(World world, int x, int y, int z, int meta) { world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "mob.zombie.infect", 4.0F, 0.1F); } - @SuppressWarnings("unchecked") private void rewardNearbyPlayers(World world, int x, int y, int z) { // scan for players nearby to give the achievement List nearbyPlayers = world.getEntitiesWithinAABB( diff --git a/src/main/java/twilightforest/block/BlockTFUberousSoil.java b/src/main/java/twilightforest/block/BlockTFUberousSoil.java index 0044080d01..862b613881 100644 --- a/src/main/java/twilightforest/block/BlockTFUberousSoil.java +++ b/src/main/java/twilightforest/block/BlockTFUberousSoil.java @@ -97,8 +97,7 @@ public void onNeighborBlockChange(World world, int x, int y, int z, Block neighb world.setBlock(x, y, z, Blocks.dirt); } - if (above instanceof IPlantable) { - IPlantable plant = (IPlantable) above; + if (above instanceof IPlantable plant) { // revert to farmland or grass if (plant.getPlantType(world, x, y + 1, z) == EnumPlantType.Crop) { world.setBlock(x, y, z, Blocks.farmland, 2, 2); diff --git a/src/main/java/twilightforest/block/BlockTFUncraftingTable.java b/src/main/java/twilightforest/block/BlockTFUncraftingTable.java index 2530b39964..88360ec05e 100644 --- a/src/main/java/twilightforest/block/BlockTFUncraftingTable.java +++ b/src/main/java/twilightforest/block/BlockTFUncraftingTable.java @@ -58,7 +58,7 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); } diff --git a/src/main/java/twilightforest/block/BlockTFUnderBrick.java b/src/main/java/twilightforest/block/BlockTFUnderBrick.java index a1192a855c..4623a8459f 100644 --- a/src/main/java/twilightforest/block/BlockTFUnderBrick.java +++ b/src/main/java/twilightforest/block/BlockTFUnderBrick.java @@ -83,7 +83,7 @@ public int colorMultiplier(IBlockAccess par1IBlockAccess, int x, int y, int z) { * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @Override - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); par3List.add(new ItemStack(par1, 1, 2)); diff --git a/src/main/java/twilightforest/block/TFBlocks.java b/src/main/java/twilightforest/block/TFBlocks.java index da720d3133..614ede3be1 100644 --- a/src/main/java/twilightforest/block/TFBlocks.java +++ b/src/main/java/twilightforest/block/TFBlocks.java @@ -186,14 +186,14 @@ public static void registerBlocks() { registerMyBlock( auroraSlab, twilightforest.item.ItemBlockTFAuroraSlab.class, - ((BlockSlab) auroraSlab), - ((BlockSlab) auroraDoubleSlab), + auroraSlab, + auroraDoubleSlab, false); registerMyBlock( auroraDoubleSlab, twilightforest.item.ItemBlockTFAuroraSlab.class, - ((BlockSlab) auroraSlab), - ((BlockSlab) auroraDoubleSlab), + auroraSlab, + auroraDoubleSlab, true); registerMyBlock(trollSteinn, ItemBlock.class); registerMyBlock(wispyCloud, ItemBlock.class); diff --git a/src/main/java/twilightforest/client/GuiTFCinderFurnace.java b/src/main/java/twilightforest/client/GuiTFCinderFurnace.java index c7f4797069..62f37a6b34 100644 --- a/src/main/java/twilightforest/client/GuiTFCinderFurnace.java +++ b/src/main/java/twilightforest/client/GuiTFCinderFurnace.java @@ -34,10 +34,9 @@ public GuiTFCinderFurnace(InventoryPlayer inventory, World world, int x, int y, */ protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { String s = this.tileFurnace.hasCustomInventoryName() ? this.tileFurnace.getInventoryName() - : I18n.format(this.tileFurnace.getInventoryName(), new Object[0]); + : I18n.format(this.tileFurnace.getInventoryName()); this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752); - this.fontRendererObj - .drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752); } protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { diff --git a/src/main/java/twilightforest/client/TFClientProxy.java b/src/main/java/twilightforest/client/TFClientProxy.java index c4a249a342..90fbfb0dbc 100644 --- a/src/main/java/twilightforest/client/TFClientProxy.java +++ b/src/main/java/twilightforest/client/TFClientProxy.java @@ -658,28 +658,34 @@ public void spawnParticle(World world, String particleType, double x, double y, // check for particle max distance if (distX * distX + distY * distY + distZ * distZ < maxDist * maxDist) { - if (particleType.equals("largeflame")) { - particle = new EntityTFLargeFlameFX(world, x, y, z, velX, velY, velZ); - } else if (particleType.equals("hugesmoke")) { - particle = new EntitySmokeFX(world, x, y, z, velX, velY, velZ, 8.0f); - } else if (particleType.equals("leafrune")) { - particle = new EntityTFLeafRuneFX(world, x, y, z, velX, velY, velZ); - } else if (particleType.equals("bosstear")) { - particle = new EntityTFBossTearFX(world, x, y, z, velX, velY, velZ, Items.ghast_tear); - } else if (particleType.equals("ghasttrap")) { - particle = new EntityTFGhastTrapFX(world, x, y, z, velX, velY, velZ); - } else if (particleType.equals("protection")) { - particle = new EntityTFProtectionFX(world, x, y, z, velX, velY, velZ); - } else if (particleType.equals("snowstuff")) { - particle = new EntityTFSnowFX(world, x, y, z, velX, velY, velZ); - } else if (particleType.equals("snowwarning")) { - particle = new EntityTFSnowWarningFX(world, x, y, z, velX, velY, velZ, 1F); - } else if (particleType.equals("snowguardian")) { - particle = new EntityTFSnowGuardianFX(world, x, y, z, velX, velY, velZ, 0.75F); - } else if (particleType.equals("icebeam")) { - particle = new EntityTFIceBeamFX(world, x, y, z, velX, velY, velZ, 0.75F); - } else if (particleType.equals("annihilate")) { - particle = new EntityTFAnnihilateFX(world, x, y, z, velX, velY, velZ, 0.75F); + switch (particleType) { + case "largeflame" -> particle = new EntityTFLargeFlameFX(world, x, y, z, velX, velY, velZ); + case "hugesmoke" -> particle = new EntitySmokeFX(world, x, y, z, velX, velY, velZ, 8.0f); + case "leafrune" -> particle = new EntityTFLeafRuneFX(world, x, y, z, velX, velY, velZ); + case "bosstear" -> particle = new EntityTFBossTearFX( + world, + x, + y, + z, + velX, + velY, + velZ, + Items.ghast_tear); + case "ghasttrap" -> particle = new EntityTFGhastTrapFX(world, x, y, z, velX, velY, velZ); + case "protection" -> particle = new EntityTFProtectionFX(world, x, y, z, velX, velY, velZ); + case "snowstuff" -> particle = new EntityTFSnowFX(world, x, y, z, velX, velY, velZ); + case "snowwarning" -> particle = new EntityTFSnowWarningFX(world, x, y, z, velX, velY, velZ, 1F); + case "snowguardian" -> particle = new EntityTFSnowGuardianFX( + world, + x, + y, + z, + velX, + velY, + velZ, + 0.75F); + case "icebeam" -> particle = new EntityTFIceBeamFX(world, x, y, z, velX, velY, velZ, 0.75F); + case "annihilate" -> particle = new EntityTFAnnihilateFX(world, x, y, z, velX, velY, velZ, 0.75F); } // if we made a partcle, go ahead and add it diff --git a/src/main/java/twilightforest/client/model/ModelTFArcticArmor.java b/src/main/java/twilightforest/client/model/ModelTFArcticArmor.java index 51e0a2270d..7ef9b2bab3 100644 --- a/src/main/java/twilightforest/client/model/ModelTFArcticArmor.java +++ b/src/main/java/twilightforest/client/model/ModelTFArcticArmor.java @@ -31,7 +31,7 @@ public ModelTFArcticArmor(int part, float expand) { this.bipedHead.addChild(bottomHood); switch (part) { - case 0: // helmet + case 0 -> { // helmet this.bipedHead.showModel = true; this.bipedHeadwear.showModel = false; this.bipedBody.showModel = false; @@ -39,8 +39,8 @@ public ModelTFArcticArmor(int part, float expand) { this.bipedLeftArm.showModel = false; this.bipedRightLeg.showModel = false; this.bipedLeftLeg.showModel = false; - break; - case 1: // chest + } + case 1 -> { // chest this.bipedHead.showModel = false; this.bipedHeadwear.showModel = false; this.bipedBody.showModel = true; @@ -48,8 +48,8 @@ public ModelTFArcticArmor(int part, float expand) { this.bipedLeftArm.showModel = true; this.bipedRightLeg.showModel = false; this.bipedLeftLeg.showModel = false; - break; - case 2: // pants + } + case 2 -> { // pants this.bipedHead.showModel = false; this.bipedHeadwear.showModel = false; this.bipedBody.showModel = true; @@ -57,8 +57,8 @@ public ModelTFArcticArmor(int part, float expand) { this.bipedLeftArm.showModel = false; this.bipedRightLeg.showModel = true; this.bipedLeftLeg.showModel = true; - break; - case 3: // boots + } + case 3 -> { // boots this.bipedHead.showModel = false; this.bipedHeadwear.showModel = false; this.bipedBody.showModel = false; @@ -66,7 +66,7 @@ public ModelTFArcticArmor(int part, float expand) { this.bipedLeftArm.showModel = false; this.bipedRightLeg.showModel = true; this.bipedLeftLeg.showModel = true; - break; + } } } diff --git a/src/main/java/twilightforest/client/model/ModelTFFieryArmor.java b/src/main/java/twilightforest/client/model/ModelTFFieryArmor.java index db6cf9c1da..f3fa6ce2f0 100644 --- a/src/main/java/twilightforest/client/model/ModelTFFieryArmor.java +++ b/src/main/java/twilightforest/client/model/ModelTFFieryArmor.java @@ -11,7 +11,7 @@ public ModelTFFieryArmor(int part, float expand) { super(expand); switch (part) { - case 0: // helmet + case 0 -> { // helmet this.bipedHead.showModel = true; this.bipedHeadwear.showModel = false; this.bipedBody.showModel = false; @@ -19,8 +19,8 @@ public ModelTFFieryArmor(int part, float expand) { this.bipedLeftArm.showModel = false; this.bipedRightLeg.showModel = false; this.bipedLeftLeg.showModel = false; - break; - case 1: // chest + } + case 1 -> { // chest this.bipedHead.showModel = false; this.bipedHeadwear.showModel = false; this.bipedBody.showModel = true; @@ -28,8 +28,8 @@ public ModelTFFieryArmor(int part, float expand) { this.bipedLeftArm.showModel = true; this.bipedRightLeg.showModel = false; this.bipedLeftLeg.showModel = false; - break; - case 2: // pants + } + case 2 -> { // pants this.bipedHead.showModel = false; this.bipedHeadwear.showModel = false; this.bipedBody.showModel = true; @@ -37,8 +37,8 @@ public ModelTFFieryArmor(int part, float expand) { this.bipedLeftArm.showModel = false; this.bipedRightLeg.showModel = true; this.bipedLeftLeg.showModel = true; - break; - case 3: // boots + } + case 3 -> { // boots this.bipedHead.showModel = false; this.bipedHeadwear.showModel = false; this.bipedBody.showModel = false; @@ -46,8 +46,7 @@ public ModelTFFieryArmor(int part, float expand) { this.bipedLeftArm.showModel = false; this.bipedRightLeg.showModel = true; this.bipedLeftLeg.showModel = true; - break; - + } } } diff --git a/src/main/java/twilightforest/client/model/ModelTFIceCrystal.java b/src/main/java/twilightforest/client/model/ModelTFIceCrystal.java index 910ac42a57..f53e3fa979 100644 --- a/src/main/java/twilightforest/client/model/ModelTFIceCrystal.java +++ b/src/main/java/twilightforest/client/model/ModelTFIceCrystal.java @@ -43,7 +43,7 @@ public void render(Entity entity, float f, float f1, float f2, float f3, float f setRotationAngles(f, f1, f2, f3, f4, f5, entity); // this.bipedHead.render(f5); - for (int i = 0; i < spikes.length; i++) { + for (ModelRenderer spike : spikes) { if (entity.isEntityAlive()) { GL11.glEnable(GL11.GL_BLEND); @@ -52,7 +52,7 @@ public void render(Entity entity, float f, float f1, float f2, float f3, float f GL11.glColor4f(1F, 1F, 1F, 0.6F); } - this.spikes[i].render(f5); + spike.render(f5); GL11.glDisable(GL11.GL_BLEND); diff --git a/src/main/java/twilightforest/client/model/ModelTFIceExploder.java b/src/main/java/twilightforest/client/model/ModelTFIceExploder.java index a33fe1c879..de8b4a7a62 100644 --- a/src/main/java/twilightforest/client/model/ModelTFIceExploder.java +++ b/src/main/java/twilightforest/client/model/ModelTFIceExploder.java @@ -55,7 +55,7 @@ public void render(Entity entity, float f, float f1, float f2, float f3, float f setRotationAngles(f, f1, f2, f3, f4, f5, entity); this.bipedHead.render(f5); - for (int i = 0; i < spikes.length; i++) { + for (ModelRenderer spike : spikes) { if (entity.isEntityAlive()) { GL11.glEnable(GL11.GL_BLEND); @@ -64,7 +64,7 @@ public void render(Entity entity, float f, float f1, float f2, float f3, float f GL11.glColor4f(1F, 1F, 1F, 0.6F); } - this.spikes[i].render(f5); + spike.render(f5); GL11.glDisable(GL11.GL_BLEND); @@ -91,7 +91,7 @@ public void setLivingAnimations(EntityLivingBase par1EntityLiving, float par2, f + MathHelper.sin((par1EntityLiving.ticksExisted + time) / (float) i) * 3F; this.spikes[i].rotationPointZ = MathHelper.sin((par1EntityLiving.ticksExisted + time) / (float) i) * 3F; - ((ModelRenderer) this.spikes[i].childModels.get(0)).rotationPointY = 10 + this.spikes[i].childModels.get(0).rotationPointY = 10 + MathHelper.sin((i + par1EntityLiving.ticksExisted + time) / i) * 3F; } diff --git a/src/main/java/twilightforest/client/model/ModelTFIceShooter.java b/src/main/java/twilightforest/client/model/ModelTFIceShooter.java index 51f44a0a3f..1969646580 100644 --- a/src/main/java/twilightforest/client/model/ModelTFIceShooter.java +++ b/src/main/java/twilightforest/client/model/ModelTFIceShooter.java @@ -1,6 +1,5 @@ package twilightforest.client.model; -import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.MathHelper; @@ -22,7 +21,7 @@ public void setLivingAnimations(EntityLivingBase par1EntityLiving, float par2, f // this.spikes[i].rotateAngleY += i * 2.5f; // this.spikes[i].rotateAngleZ += i * 3; - ((ModelRenderer) this.spikes[i].childModels.get(0)).rotationPointY = 9.5F + this.spikes[i].childModels.get(0).rotationPointY = 9.5F + MathHelper.sin((i + par1EntityLiving.ticksExisted + time) / 3F) * 3F; // ((ModelBox)this.spikes[i].cubeList.get(0)). = 6 + MathHelper.sin((par1EntityLiving.ticksExisted + diff --git a/src/main/java/twilightforest/client/model/ModelTFKnightlyArmor.java b/src/main/java/twilightforest/client/model/ModelTFKnightlyArmor.java index 0212af2545..9a06eefcfb 100644 --- a/src/main/java/twilightforest/client/model/ModelTFKnightlyArmor.java +++ b/src/main/java/twilightforest/client/model/ModelTFKnightlyArmor.java @@ -84,7 +84,7 @@ public ModelTFKnightlyArmor(int part, float expand) { this.bipedLeftLeg.addChild(shoeSpike2); switch (part) { - case 0: // helmet + case 0 -> { // helmet this.bipedHead.showModel = true; this.bipedHeadwear.showModel = false; this.bipedBody.showModel = false; @@ -92,8 +92,8 @@ public ModelTFKnightlyArmor(int part, float expand) { this.bipedLeftArm.showModel = false; this.bipedRightLeg.showModel = false; this.bipedLeftLeg.showModel = false; - break; - case 1: // chest + } + case 1 -> { // chest this.bipedHead.showModel = false; this.bipedHeadwear.showModel = false; this.bipedBody.showModel = true; @@ -101,8 +101,8 @@ public ModelTFKnightlyArmor(int part, float expand) { this.bipedLeftArm.showModel = true; this.bipedRightLeg.showModel = false; this.bipedLeftLeg.showModel = false; - break; - case 2: // pants + } + case 2 -> { // pants this.bipedHead.showModel = false; this.bipedHeadwear.showModel = false; this.bipedBody.showModel = true; @@ -110,8 +110,8 @@ public ModelTFKnightlyArmor(int part, float expand) { this.bipedLeftArm.showModel = false; this.bipedRightLeg.showModel = true; this.bipedLeftLeg.showModel = true; - break; - case 3: // boots + } + case 3 -> { // boots this.bipedHead.showModel = false; this.bipedHeadwear.showModel = false; this.bipedBody.showModel = false; @@ -119,8 +119,7 @@ public ModelTFKnightlyArmor(int part, float expand) { this.bipedLeftArm.showModel = false; this.bipedRightLeg.showModel = true; this.bipedLeftLeg.showModel = true; - break; - + } } } diff --git a/src/main/java/twilightforest/client/model/ModelTFTowerBoss.java b/src/main/java/twilightforest/client/model/ModelTFTowerBoss.java index b78801a31e..1e94c17aae 100644 --- a/src/main/java/twilightforest/client/model/ModelTFTowerBoss.java +++ b/src/main/java/twilightforest/client/model/ModelTFTowerBoss.java @@ -28,54 +28,55 @@ protected void makeTentacle(byte yOffset, Random random, int num) { this.tentacles[num].addBox(-1.5F, 0.0F, -1.5F, 3, length, 3); switch (num) { - case 0: + case 0 -> { this.tentacles[0].rotationPointX = 4.5F; this.tentacles[0].rotationPointZ = 4.5F; this.tentacles[0].rotationPointY = (float) (23 + yOffset); - break; - case 1: + } + case 1 -> { this.tentacles[1].rotationPointX = -4.5F; this.tentacles[1].rotationPointZ = 4.5F; this.tentacles[1].rotationPointY = (float) (23 + yOffset); - break; - case 2: + } + case 2 -> { this.tentacles[2].rotationPointX = 0F; this.tentacles[2].rotationPointZ = 0F; this.tentacles[2].rotationPointY = (float) (23 + yOffset); - break; - case 3: + } + case 3 -> { this.tentacles[3].rotationPointX = 5.5F; this.tentacles[3].rotationPointZ = -4.5F; this.tentacles[3].rotationPointY = (float) (23 + yOffset); - break; - case 4: + } + case 4 -> { this.tentacles[4].rotationPointX = -5.5F; this.tentacles[4].rotationPointZ = -4.5F; this.tentacles[4].rotationPointY = (float) (23 + yOffset); - break; - case 5: + } + case 5 -> { this.tentacles[5].rotationPointX = -7.5F; this.tentacles[5].rotationPointY = 3.5F; this.tentacles[5].rotationPointZ = -1F; this.tentacles[5].rotateAngleZ = (float) Math.PI / 4.0F; - break; - case 6: + } + case 6 -> { this.tentacles[6].rotationPointX = -7.5F; this.tentacles[6].rotationPointY = -1.5F; this.tentacles[6].rotationPointZ = 3.5F; this.tentacles[6].rotateAngleZ = (float) Math.PI / 3.0F; - break; - case 7: + } + case 7 -> { this.tentacles[7].rotationPointX = 7.5F; this.tentacles[7].rotationPointY = 3.5F; this.tentacles[7].rotationPointZ = -1F; this.tentacles[7].rotateAngleZ = -(float) Math.PI / 4.0F; - break; - case 8: + } + case 8 -> { this.tentacles[8].rotationPointX = 7.5F; this.tentacles[8].rotationPointY = -1.5F; this.tentacles[8].rotationPointZ = 3.5F; this.tentacles[8].rotateAngleZ = -(float) Math.PI / 3.0F; + } } // goofy mid-method initializer @@ -107,9 +108,7 @@ protected void makeTentacle(byte yOffset, Random random, int num) { * * @param i */ - protected void makeSmallTentacle(int num) { - ; - } + protected void makeSmallTentacle(int num) {} /** * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms diff --git a/src/main/java/twilightforest/client/model/ModelTFYetiArmor.java b/src/main/java/twilightforest/client/model/ModelTFYetiArmor.java index 55b23e736b..f89eada0fd 100644 --- a/src/main/java/twilightforest/client/model/ModelTFYetiArmor.java +++ b/src/main/java/twilightforest/client/model/ModelTFYetiArmor.java @@ -75,7 +75,7 @@ public ModelTFYetiArmor(int part, float expand) { this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + 0.0f, 0.0F); switch (part) { - case 0: // helmet + case 0 -> { // helmet this.bipedHead.showModel = true; this.bipedHeadwear.showModel = false; this.bipedBody.showModel = false; @@ -84,8 +84,8 @@ public ModelTFYetiArmor(int part, float expand) { this.bipedLegBody.showModel = false; this.bipedRightLeg.showModel = false; this.bipedLeftLeg.showModel = false; - break; - case 1: // chest + } + case 1 -> { // chest this.bipedHead.showModel = false; this.bipedHeadwear.showModel = false; this.bipedBody.showModel = true; @@ -94,8 +94,8 @@ public ModelTFYetiArmor(int part, float expand) { this.bipedLegBody.showModel = false; this.bipedRightLeg.showModel = false; this.bipedLeftLeg.showModel = false; - break; - case 2: // pants + } + case 2 -> { // pants this.bipedHead.showModel = false; this.bipedHeadwear.showModel = false; this.bipedBody.showModel = false; @@ -108,8 +108,8 @@ public ModelTFYetiArmor(int part, float expand) { this.leftToe.showModel = false; this.rightRuff.showModel = false; this.rightToe.showModel = false; - break; - case 3: // boots + } + case 3 -> { // boots this.bipedHead.showModel = false; this.bipedHeadwear.showModel = false; this.bipedBody.showModel = false; @@ -122,8 +122,7 @@ public ModelTFYetiArmor(int part, float expand) { this.leftToe.showModel = true; this.rightRuff.showModel = true; this.rightToe.showModel = true; - break; - + } } } diff --git a/src/main/java/twilightforest/client/particle/EntityTFBossTearFX.java b/src/main/java/twilightforest/client/particle/EntityTFBossTearFX.java index 1b0f3431e9..4d00435fda 100644 --- a/src/main/java/twilightforest/client/particle/EntityTFBossTearFX.java +++ b/src/main/java/twilightforest/client/particle/EntityTFBossTearFX.java @@ -93,29 +93,29 @@ public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float f14 = 1.0F; par1Tessellator.setColorOpaque_F(f14 * this.particleRed, f14 * this.particleGreen, f14 * this.particleBlue); par1Tessellator.addVertexWithUV( - (double) (f11 - par3 * f10 - par6 * f10), - (double) (f12 - par4 * f10), - (double) (f13 - par5 * f10 - par7 * f10), - (double) f6, - (double) f9); + f11 - par3 * f10 - par6 * f10, + f12 - par4 * f10, + f13 - par5 * f10 - par7 * f10, + f6, + f9); par1Tessellator.addVertexWithUV( - (double) (f11 - par3 * f10 + par6 * f10), - (double) (f12 + par4 * f10), - (double) (f13 - par5 * f10 + par7 * f10), - (double) f6, - (double) f8); + f11 - par3 * f10 + par6 * f10, + f12 + par4 * f10, + f13 - par5 * f10 + par7 * f10, + f6, + f8); par1Tessellator.addVertexWithUV( - (double) (f11 + par3 * f10 + par6 * f10), - (double) (f12 + par4 * f10), - (double) (f13 + par5 * f10 + par7 * f10), - (double) f7, - (double) f8); + f11 + par3 * f10 + par6 * f10, + f12 + par4 * f10, + f13 + par5 * f10 + par7 * f10, + f7, + f8); par1Tessellator.addVertexWithUV( - (double) (f11 + par3 * f10 - par6 * f10), - (double) (f12 - par4 * f10), - (double) (f13 + par5 * f10 - par7 * f10), - (double) f7, - (double) f9); + f11 + par3 * f10 - par6 * f10, + f12 - par4 * f10, + f13 + par5 * f10 - par7 * f10, + f7, + f9); } } diff --git a/src/main/java/twilightforest/client/particle/EntityTFFireflyFX.java b/src/main/java/twilightforest/client/particle/EntityTFFireflyFX.java index 824714a73b..06b2ca858a 100644 --- a/src/main/java/twilightforest/client/particle/EntityTFFireflyFX.java +++ b/src/main/java/twilightforest/client/particle/EntityTFFireflyFX.java @@ -64,29 +64,29 @@ public void renderParticle(Tessellator par1Tessellator, float par2, float par3, this.particleBlue * f14, this.particleAlpha); par1Tessellator.addVertexWithUV( - (double) (f11 - par3 * f10 - par6 * f10), - (double) (f12 - par4 * f10), - (double) (f13 - par5 * f10 - par7 * f10), - (double) f7, - (double) f9); + f11 - par3 * f10 - par6 * f10, + f12 - par4 * f10, + f13 - par5 * f10 - par7 * f10, + f7, + f9); par1Tessellator.addVertexWithUV( - (double) (f11 - par3 * f10 + par6 * f10), - (double) (f12 + par4 * f10), - (double) (f13 - par5 * f10 + par7 * f10), - (double) f7, - (double) f8); + f11 - par3 * f10 + par6 * f10, + f12 + par4 * f10, + f13 - par5 * f10 + par7 * f10, + f7, + f8); par1Tessellator.addVertexWithUV( - (double) (f11 + par3 * f10 + par6 * f10), - (double) (f12 + par4 * f10), - (double) (f13 + par5 * f10 + par7 * f10), - (double) f6, - (double) f8); + f11 + par3 * f10 + par6 * f10, + f12 + par4 * f10, + f13 + par5 * f10 + par7 * f10, + f6, + f8); par1Tessellator.addVertexWithUV( - (double) (f11 + par3 * f10 - par6 * f10), - (double) (f12 - par4 * f10), - (double) (f13 + par5 * f10 - par7 * f10), - (double) f6, - (double) f9); + f11 + par3 * f10 - par6 * f10, + f12 - par4 * f10, + f13 + par5 * f10 - par7 * f10, + f6, + f9); GL11.glDisable(3042 /* GL_BLEND */); GL11.glEnable(3008 /* GL_ALPHA_TEST */); diff --git a/src/main/java/twilightforest/client/particle/EntityTFLeafRuneFX.java b/src/main/java/twilightforest/client/particle/EntityTFLeafRuneFX.java index 008ba7f508..3fe7959d25 100644 --- a/src/main/java/twilightforest/client/particle/EntityTFLeafRuneFX.java +++ b/src/main/java/twilightforest/client/particle/EntityTFLeafRuneFX.java @@ -24,7 +24,7 @@ public void onUpdate() { this.prevPosZ = this.posZ; this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.motionY -= (double) this.particleGravity; + this.motionY -= this.particleGravity; if (this.particleAge++ >= this.particleMaxAge) { this.setDead(); diff --git a/src/main/java/twilightforest/client/renderer/TFMagicMapRenderer.java b/src/main/java/twilightforest/client/renderer/TFMagicMapRenderer.java index b7237887be..71c6cee857 100644 --- a/src/main/java/twilightforest/client/renderer/TFMagicMapRenderer.java +++ b/src/main/java/twilightforest/client/renderer/TFMagicMapRenderer.java @@ -1,7 +1,6 @@ package twilightforest.client.renderer; -import java.util.Collection; -import java.util.List; +import java.util.Arrays; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderItem; @@ -40,9 +39,7 @@ public TFMagicMapRenderer(GameSettings par1GameSettings, TextureManager par2Text this.textureLoc = par2TextureManager.getDynamicTextureLocation("map", this.bufferedImage); this.intArray = this.bufferedImage.getTextureData(); - for (int i = 0; i < this.intArray.length; ++i) { - this.intArray[i] = 0; - } + Arrays.fill(this.intArray, 0); } /** @@ -103,10 +100,9 @@ public void renderItem(ItemRenderType type, ItemStack item, Object... data) { } } - @SuppressWarnings("unchecked") public void renderMap(EntityPlayer par1EntityPlayer, TextureManager par2TextureManager, TFMagicMapData par3MapData) { - TFMagicMapData magicMapData = (TFMagicMapData) par3MapData; + TFMagicMapData magicMapData = par3MapData; for (int i = 0; i < 16384; ++i) { int colorByte = par3MapData.colors[i] & 0xFF; @@ -133,26 +129,26 @@ public void renderMap(EntityPlayer par1EntityPlayer, TextureManager par2TextureM GL11.glDisable(GL11.GL_ALPHA_TEST); tesselator.startDrawingQuads(); tesselator.addVertexWithUV( - (double) ((float) (var15 + 0) + var18), - (double) ((float) (var16 + 128) - var18), + (float) (var15 + 0) + var18, + (float) (var16 + 128) - var18, -0.009999999776482582D, 0.0D, 1.0D); tesselator.addVertexWithUV( - (double) ((float) (var15 + 128) - var18), - (double) ((float) (var16 + 128) - var18), + (float) (var15 + 128) - var18, + (float) (var16 + 128) - var18, -0.009999999776482582D, 1.0D, 1.0D); tesselator.addVertexWithUV( - (double) ((float) (var15 + 128) - var18), - (double) ((float) (var16 + 0) + var18), + (float) (var15 + 128) - var18, + (float) (var16 + 0) + var18, -0.009999999776482582D, 1.0D, 0.0D); tesselator.addVertexWithUV( - (double) ((float) (var15 + 0) + var18), - (double) ((float) (var16 + 0) + var18), + (float) (var15 + 0) + var18, + (float) (var16 + 0) + var18, -0.009999999776482582D, 0.0D, 0.0D); @@ -160,7 +156,7 @@ public void renderMap(EntityPlayer par1EntityPlayer, TextureManager par2TextureM GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_BLEND); par2TextureManager.bindTexture(vanillaMapIcons); - for (MapCoord mapCoord : (Collection) par3MapData.playersVisibleOnMap.values()) { + for (MapCoord mapCoord : par3MapData.playersVisibleOnMap.values()) { GL11.glPushMatrix(); GL11.glTranslatef( (float) var15 + (float) mapCoord.centerX / 2.0F + 64.0F, @@ -174,17 +170,17 @@ public void renderMap(EntityPlayer par1EntityPlayer, TextureManager par2TextureM float var22 = (float) (mapCoord.iconSize % 4 + 1) / 4.0F; float var24 = (float) (mapCoord.iconSize / 4 + 1) / 4.0F; tesselator.startDrawingQuads(); - tesselator.addVertexWithUV(-1.0D, 1.0D, 0.0D, (double) var21, (double) var23); - tesselator.addVertexWithUV(1.0D, 1.0D, 0.0D, (double) var22, (double) var23); - tesselator.addVertexWithUV(1.0D, -1.0D, 0.0D, (double) var22, (double) var24); - tesselator.addVertexWithUV(-1.0D, -1.0D, 0.0D, (double) var21, (double) var24); + tesselator.addVertexWithUV(-1.0D, 1.0D, 0.0D, var21, var23); + tesselator.addVertexWithUV(1.0D, 1.0D, 0.0D, var22, var23); + tesselator.addVertexWithUV(1.0D, -1.0D, 0.0D, var22, var24); + tesselator.addVertexWithUV(-1.0D, -1.0D, 0.0D, var21, var24); tesselator.draw(); GL11.glPopMatrix(); } par2TextureManager.bindTexture(twilightMapIcons); - for (MapCoord mapCoord : (List) magicMapData.featuresVisibleOnMap) { + for (MapCoord mapCoord : magicMapData.featuresVisibleOnMap) { GL11.glPushMatrix(); GL11.glTranslatef( (float) var15 + (float) mapCoord.centerX / 2.0F + 64.0F, @@ -198,10 +194,10 @@ public void renderMap(EntityPlayer par1EntityPlayer, TextureManager par2TextureM float var22 = (float) (mapCoord.iconSize % 8 + 1) / 8.0F; float var24 = (float) (mapCoord.iconSize / 8 + 1) / 8.0F; tesselator.startDrawingQuads(); - tesselator.addVertexWithUV(-1.0D, 1.0D, 0.0D, (double) var21, (double) var23); - tesselator.addVertexWithUV(1.0D, 1.0D, 0.0D, (double) var22, (double) var23); - tesselator.addVertexWithUV(1.0D, -1.0D, 0.0D, (double) var22, (double) var24); - tesselator.addVertexWithUV(-1.0D, -1.0D, 0.0D, (double) var21, (double) var24); + tesselator.addVertexWithUV(-1.0D, 1.0D, 0.0D, var21, var23); + tesselator.addVertexWithUV(1.0D, 1.0D, 0.0D, var22, var23); + tesselator.addVertexWithUV(1.0D, -1.0D, 0.0D, var22, var24); + tesselator.addVertexWithUV(-1.0D, -1.0D, 0.0D, var21, var24); tesselator.draw(); GL11.glPopMatrix(); } @@ -227,10 +223,10 @@ private void renderMapInFrame(ItemStack item, RenderManager renderManager, TFMag Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); byte b0 = 7; - tessellator.addVertexWithUV((double) (0 - b0), (double) (128 + b0), 0.0D, 0.0D, 1.0D); - tessellator.addVertexWithUV((double) (128 + b0), (double) (128 + b0), 0.0D, 1.0D, 1.0D); - tessellator.addVertexWithUV((double) (128 + b0), (double) (0 - b0), 0.0D, 1.0D, 0.0D); - tessellator.addVertexWithUV((double) (0 - b0), (double) (0 - b0), 0.0D, 0.0D, 0.0D); + tessellator.addVertexWithUV(0 - b0, 128 + b0, 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV(128 + b0, 128 + b0, 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV(128 + b0, 0 - b0, 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV(0 - b0, 0 - b0, 0.0D, 0.0D, 0.0D); tessellator.draw(); // push map texture slightly off background diff --git a/src/main/java/twilightforest/client/renderer/TFMazeMapRenderer.java b/src/main/java/twilightforest/client/renderer/TFMazeMapRenderer.java index d9357821a7..858fa1fba1 100644 --- a/src/main/java/twilightforest/client/renderer/TFMazeMapRenderer.java +++ b/src/main/java/twilightforest/client/renderer/TFMazeMapRenderer.java @@ -90,10 +90,10 @@ private void renderMapInFrame(ItemStack item, RenderManager renderManager, TFMaz Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); byte b0 = 7; - tessellator.addVertexWithUV((double) (0 - b0), (double) (128 + b0), 0.0D, 0.0D, 1.0D); - tessellator.addVertexWithUV((double) (128 + b0), (double) (128 + b0), 0.0D, 1.0D, 1.0D); - tessellator.addVertexWithUV((double) (128 + b0), (double) (0 - b0), 0.0D, 1.0D, 0.0D); - tessellator.addVertexWithUV((double) (0 - b0), (double) (0 - b0), 0.0D, 0.0D, 0.0D); + tessellator.addVertexWithUV(0 - b0, 128 + b0, 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV(128 + b0, 128 + b0, 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV(128 + b0, 0 - b0, 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV(0 - b0, 0 - b0, 0.0D, 0.0D, 0.0D); tessellator.draw(); // push map texture slightly off background diff --git a/src/main/java/twilightforest/client/renderer/TFSkyRenderer.java b/src/main/java/twilightforest/client/renderer/TFSkyRenderer.java index d92b5e113b..477e0b453d 100644 --- a/src/main/java/twilightforest/client/renderer/TFSkyRenderer.java +++ b/src/main/java/twilightforest/client/renderer/TFSkyRenderer.java @@ -48,10 +48,10 @@ public TFSkyRenderer() { for (var9 = -var7 * var8; var9 <= var7 * var8; var9 += var7) { for (var10 = -var7 * var8; var10 <= var7 * var8; var10 += var7) { var5.startDrawingQuads(); - var5.addVertex((double) (var9 + 0), (double) var6, (double) (var10 + 0)); - var5.addVertex((double) (var9 + var7), (double) var6, (double) (var10 + 0)); - var5.addVertex((double) (var9 + var7), (double) var6, (double) (var10 + var7)); - var5.addVertex((double) (var9 + 0), (double) var6, (double) (var10 + var7)); + var5.addVertex(var9 + 0, var6, var10 + 0); + var5.addVertex(var9 + var7, var6, var10 + 0); + var5.addVertex(var9 + var7, var6, var10 + var7); + var5.addVertex(var9 + 0, var6, var10 + var7); var5.draw(); } } @@ -64,10 +64,10 @@ public TFSkyRenderer() { for (var9 = -var7 * var8; var9 <= var7 * var8; var9 += var7) { for (var10 = -var7 * var8; var10 <= var7 * var8; var10 += var7) { - var5.addVertex((double) (var9 + var7), (double) var6, (double) (var10 + 0)); - var5.addVertex((double) (var9 + 0), (double) var6, (double) (var10 + 0)); - var5.addVertex((double) (var9 + 0), (double) var6, (double) (var10 + var7)); - var5.addVertex((double) (var9 + var7), (double) var6, (double) (var10 + var7)); + var5.addVertex(var9 + var7, var6, var10 + 0); + var5.addVertex(var9 + 0, var6, var10 + 0); + var5.addVertex(var9 + 0, var6, var10 + var7); + var5.addVertex(var9 + var7, var6, var10 + var7); } } @@ -217,26 +217,26 @@ public void render(float partialTicks, WorldClient world, Minecraft mc) { var12 = -var10; var23.startDrawingQuads(); var23.setColorRGBA_I(0, 255); - var23.addVertex((double) (-var10), (double) var11, (double) var10); - var23.addVertex((double) var10, (double) var11, (double) var10); - var23.addVertex((double) var10, (double) var12, (double) var10); - var23.addVertex((double) (-var10), (double) var12, (double) var10); - var23.addVertex((double) (-var10), (double) var12, (double) (-var10)); - var23.addVertex((double) var10, (double) var12, (double) (-var10)); - var23.addVertex((double) var10, (double) var11, (double) (-var10)); - var23.addVertex((double) (-var10), (double) var11, (double) (-var10)); - var23.addVertex((double) var10, (double) var12, (double) (-var10)); - var23.addVertex((double) var10, (double) var12, (double) var10); - var23.addVertex((double) var10, (double) var11, (double) var10); - var23.addVertex((double) var10, (double) var11, (double) (-var10)); - var23.addVertex((double) (-var10), (double) var11, (double) (-var10)); - var23.addVertex((double) (-var10), (double) var11, (double) var10); - var23.addVertex((double) (-var10), (double) var12, (double) var10); - var23.addVertex((double) (-var10), (double) var12, (double) (-var10)); - var23.addVertex((double) (-var10), (double) var12, (double) (-var10)); - var23.addVertex((double) (-var10), (double) var12, (double) var10); - var23.addVertex((double) var10, (double) var12, (double) var10); - var23.addVertex((double) var10, (double) var12, (double) (-var10)); + var23.addVertex(-var10, var11, var10); + var23.addVertex(var10, var11, var10); + var23.addVertex(var10, var12, var10); + var23.addVertex(-var10, var12, var10); + var23.addVertex(-var10, var12, -var10); + var23.addVertex(var10, var12, -var10); + var23.addVertex(var10, var11, -var10); + var23.addVertex(-var10, var11, -var10); + var23.addVertex(var10, var12, -var10); + var23.addVertex(var10, var12, var10); + var23.addVertex(var10, var11, var10); + var23.addVertex(var10, var11, -var10); + var23.addVertex(-var10, var11, -var10); + var23.addVertex(-var10, var11, var10); + var23.addVertex(-var10, var12, var10); + var23.addVertex(-var10, var12, -var10); + var23.addVertex(-var10, var12, -var10); + var23.addVertex(-var10, var12, var10); + var23.addVertex(var10, var12, var10); + var23.addVertex(var10, var12, -var10); var23.draw(); } @@ -288,10 +288,10 @@ private void renderStars() { var2.startDrawingQuads(); for (int var3 = 0; var3 < 3000; ++var3) { - double var4 = (double) (var1.nextFloat() * 2.0F - 1.0F); - double var6 = (double) (var1.nextFloat() * 2.0F - 1.0F); - double var8 = (double) (var1.nextFloat() * 2.0F - 1.0F); - double size = (double) (0.10F + var1.nextFloat() * 0.25F); + double var4 = var1.nextFloat() * 2.0F - 1.0F; + double var6 = var1.nextFloat() * 2.0F - 1.0F; + double var8 = var1.nextFloat() * 2.0F - 1.0F; + double size = 0.10F + var1.nextFloat() * 0.25F; double var12 = var4 * var4 + var6 * var6 + var8 * var8; if (var12 < 1.0D && var12 > 0.01D) { diff --git a/src/main/java/twilightforest/client/renderer/TFWeatherRenderer.java b/src/main/java/twilightforest/client/renderer/TFWeatherRenderer.java index f5192893fc..7012a6d52a 100644 --- a/src/main/java/twilightforest/client/renderer/TFWeatherRenderer.java +++ b/src/main/java/twilightforest/client/renderer/TFWeatherRenderer.java @@ -83,7 +83,7 @@ private void renderNormalWeather(float partialTicks, Minecraft mc) { float rainStrength = mc.theWorld.getRainStrength(partialTicks); if (rainStrength > 0.0F) { - mc.entityRenderer.enableLightmap((double) partialTicks); + mc.entityRenderer.enableLightmap(partialTicks); this.initializeRainCoords(); @@ -140,14 +140,11 @@ private void renderNormalWeather(float partialTicks, Minecraft mc) { } float f8 = 1.0F; - int j2 = k1; - if (k1 < k) { - j2 = k; - } + int j2 = Math.max(k1, k); if (l1 != i2) { - this.random.setSeed((long) (i1 * i1 * 3121 + i1 * 45238971 ^ l * l * 418711 + l * 13761)); + this.random.setSeed(i1 * i1 * 3121 + i1 * 45238971 ^ l * l * 418711 + l * 13761); float f9 = biomegenbase.getFloatTemperature(i1, l1, l); float downwardsMotion; double xDist; @@ -180,28 +177,28 @@ private void renderNormalWeather(float partialTicks, Minecraft mc) { tessellator.setTranslation(-d0 * 1.0D, -d1 * 1.0D, -d2 * 1.0D); tessellator.addVertexWithUV( (double) ((float) i1 - f6) + 0.5D, - (double) l1, + l1, (double) ((float) l - f7) + 0.5D, - (double) (0.0F * f8), - (double) ((float) l1 * f8 / 4.0F + downwardsMotion * f8)); + 0.0F * f8, + (float) l1 * f8 / 4.0F + downwardsMotion * f8); tessellator.addVertexWithUV( (double) ((float) i1 + f6) + 0.5D, - (double) l1, + l1, (double) ((float) l + f7) + 0.5D, - (double) (1.0F * f8), - (double) ((float) l1 * f8 / 4.0F + downwardsMotion * f8)); + 1.0F * f8, + (float) l1 * f8 / 4.0F + downwardsMotion * f8); tessellator.addVertexWithUV( (double) ((float) i1 + f6) + 0.5D, - (double) i2, + i2, (double) ((float) l + f7) + 0.5D, - (double) (1.0F * f8), - (double) ((float) i2 * f8 / 4.0F + downwardsMotion * f8)); + 1.0F * f8, + (float) i2 * f8 / 4.0F + downwardsMotion * f8); tessellator.addVertexWithUV( (double) ((float) i1 - f6) + 0.5D, - (double) i2, + i2, (double) ((float) l - f7) + 0.5D, - (double) (0.0F * f8), - (double) ((float) i2 * f8 / 4.0F + downwardsMotion * f8)); + 0.0F * f8, + (float) i2 * f8 / 4.0F + downwardsMotion * f8); tessellator.setTranslation(0.0D, 0.0D, 0.0D); } else { if (b1 != 1) { @@ -231,28 +228,28 @@ private void renderNormalWeather(float partialTicks, Minecraft mc) { tessellator.setTranslation(-d0 * 1.0D, -d1 * 1.0D, -d2 * 1.0D); tessellator.addVertexWithUV( (double) ((float) i1 - f6) + 0.5D, - (double) l1, + l1, (double) ((float) l - f7) + 0.5D, - (double) (0.0F * f8 + f16), - (double) ((float) l1 * f8 / 4.0F + downwardsMotion * f8 + f11)); + 0.0F * f8 + f16, + (float) l1 * f8 / 4.0F + downwardsMotion * f8 + f11); tessellator.addVertexWithUV( (double) ((float) i1 + f6) + 0.5D, - (double) l1, + l1, (double) ((float) l + f7) + 0.5D, - (double) (1.0F * f8 + f16), - (double) ((float) l1 * f8 / 4.0F + downwardsMotion * f8 + f11)); + 1.0F * f8 + f16, + (float) l1 * f8 / 4.0F + downwardsMotion * f8 + f11); tessellator.addVertexWithUV( (double) ((float) i1 + f6) + 0.5D, - (double) i2, + i2, (double) ((float) l + f7) + 0.5D, - (double) (1.0F * f8 + f16), - (double) ((float) i2 * f8 / 4.0F + downwardsMotion * f8 + f11)); + 1.0F * f8 + f16, + (float) i2 * f8 / 4.0F + downwardsMotion * f8 + f11); tessellator.addVertexWithUV( (double) ((float) i1 - f6) + 0.5D, - (double) i2, + i2, (double) ((float) l - f7) + 0.5D, - (double) (0.0F * f8 + f16), - (double) ((float) i2 * f8 / 4.0F + downwardsMotion * f8 + f11)); + 0.0F * f8 + f16, + (float) i2 * f8 / 4.0F + downwardsMotion * f8 + f11); tessellator.setTranslation(0.0D, 0.0D, 0.0D); } } @@ -267,7 +264,7 @@ private void renderNormalWeather(float partialTicks, Minecraft mc) { GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_BLEND); GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); - mc.entityRenderer.disableLightmap((double) partialTicks); + mc.entityRenderer.disableLightmap(partialTicks); } } @@ -332,15 +329,11 @@ private void renderLockedBiome(float partialTicks, WorldClient world, Minecraft } float one = 1.0F; - int rainFloor = rainHeight; - if (rainHeight < floorY) { - rainFloor = floorY; - } + int rainFloor = Math.max(rainHeight, floorY); if (rainMin != rainMax) { - this.random - .setSeed((long) (dx * dx * 3121 + dx * 45238971 ^ dz * dz * 418711 + dz * 13761)); + this.random.setSeed(dx * dx * 3121 + dx * 45238971 ^ dz * dz * 418711 + dz * 13761); if (biomegenbase instanceof TFBiomeSnow || biomegenbase instanceof TFBiomeGlacier) { // SNOW @@ -371,28 +364,28 @@ private void renderLockedBiome(float partialTicks, WorldClient world, Minecraft tessellator.setTranslation(-offX * 1.0D, -offY * 1.0D, -offZ * 1.0D); tessellator.addVertexWithUV( (double) ((float) dx - rainX) + 0.5D, - (double) rainMin, + rainMin, (double) ((float) dz - rainZ) + 0.5D, - (double) (0.0F * one + uFactor), - (double) ((float) rainMin * one / 4.0F + countFactor * one + vFactor)); + 0.0F * one + uFactor, + (float) rainMin * one / 4.0F + countFactor * one + vFactor); tessellator.addVertexWithUV( (double) ((float) dx + rainX) + 0.5D, - (double) rainMin, + rainMin, (double) ((float) dz + rainZ) + 0.5D, - (double) (1.0F * one + uFactor), - (double) ((float) rainMin * one / 4.0F + countFactor * one + vFactor)); + 1.0F * one + uFactor, + (float) rainMin * one / 4.0F + countFactor * one + vFactor); tessellator.addVertexWithUV( (double) ((float) dx + rainX) + 0.5D, - (double) rainMax, + rainMax, (double) ((float) dz + rainZ) + 0.5D, - (double) (1.0F * one + uFactor), - (double) ((float) rainMax * one / 4.0F + countFactor * one + vFactor)); + 1.0F * one + uFactor, + (float) rainMax * one / 4.0F + countFactor * one + vFactor); tessellator.addVertexWithUV( (double) ((float) dx - rainX) + 0.5D, - (double) rainMax, + rainMax, (double) ((float) dz - rainZ) + 0.5D, - (double) (0.0F * one + uFactor), - (double) ((float) rainMax * one / 4.0F + countFactor * one + vFactor)); + 0.0F * one + uFactor, + (float) rainMax * one / 4.0F + countFactor * one + vFactor); tessellator.setTranslation(0.0D, 0.0D, 0.0D); } else if (biomegenbase instanceof TFBiomeSwamp) { @@ -428,28 +421,28 @@ private void renderLockedBiome(float partialTicks, WorldClient world, Minecraft tessellator.setTranslation(-offX * 1.0D, -offY * 1.0D, -offZ * 1.0D); tessellator.addVertexWithUV( (double) ((float) dx - rainX) + 0.5D, - (double) rainMin, + rainMin, (double) ((float) dz - rainZ) + 0.5D, - (double) (0.0F * one + uFactor), - (double) ((float) rainMin * one / 4.0F + countFactor * one + vFactor)); + 0.0F * one + uFactor, + (float) rainMin * one / 4.0F + countFactor * one + vFactor); tessellator.addVertexWithUV( (double) ((float) dx + rainX) + 0.5D, - (double) rainMin, + rainMin, (double) ((float) dz + rainZ) + 0.5D, - (double) (1.0F * one + uFactor), - (double) ((float) rainMin * one / 4.0F + countFactor * one + vFactor)); + 1.0F * one + uFactor, + (float) rainMin * one / 4.0F + countFactor * one + vFactor); tessellator.addVertexWithUV( (double) ((float) dx + rainX) + 0.5D, - (double) rainMax, + rainMax, (double) ((float) dz + rainZ) + 0.5D, - (double) (1.0F * one + uFactor), - (double) ((float) rainMax * one / 4.0F + countFactor * one + vFactor)); + 1.0F * one + uFactor, + (float) rainMax * one / 4.0F + countFactor * one + vFactor); tessellator.addVertexWithUV( (double) ((float) dx - rainX) + 0.5D, - (double) rainMax, + rainMax, (double) ((float) dz - rainZ) + 0.5D, - (double) (0.0F * one + uFactor), - (double) ((float) rainMax * one / 4.0F + countFactor * one + vFactor)); + 0.0F * one + uFactor, + (float) rainMax * one / 4.0F + countFactor * one + vFactor); tessellator.setTranslation(0.0D, 0.0D, 0.0D); } else if (biomegenbase instanceof TFBiomeFireSwamp) { // ASHES @@ -484,28 +477,28 @@ private void renderLockedBiome(float partialTicks, WorldClient world, Minecraft tessellator.setTranslation(-offX * 1.0D, -offY * 1.0D, -offZ * 1.0D); tessellator.addVertexWithUV( (double) ((float) dx - rainX) + 0.5D, - (double) rainMin, + rainMin, (double) ((float) dz - rainZ) + 0.5D, - (double) (0.0F * one + uFactor), - (double) ((float) rainMin * one / 4.0F + countFactor * one + vFactor)); + 0.0F * one + uFactor, + (float) rainMin * one / 4.0F + countFactor * one + vFactor); tessellator.addVertexWithUV( (double) ((float) dx + rainX) + 0.5D, - (double) rainMin, + rainMin, (double) ((float) dz + rainZ) + 0.5D, - (double) (1.0F * one + uFactor), - (double) ((float) rainMin * one / 4.0F + countFactor * one + vFactor)); + 1.0F * one + uFactor, + (float) rainMin * one / 4.0F + countFactor * one + vFactor); tessellator.addVertexWithUV( (double) ((float) dx + rainX) + 0.5D, - (double) rainMax, + rainMax, (double) ((float) dz + rainZ) + 0.5D, - (double) (1.0F * one + uFactor), - (double) ((float) rainMax * one / 4.0F + countFactor * one + vFactor)); + 1.0F * one + uFactor, + (float) rainMax * one / 4.0F + countFactor * one + vFactor); tessellator.addVertexWithUV( (double) ((float) dx - rainX) + 0.5D, - (double) rainMax, + rainMax, (double) ((float) dz - rainZ) + 0.5D, - (double) (0.0F * one + uFactor), - (double) ((float) rainMax * one / 4.0F + countFactor * one + vFactor)); + 0.0F * one + uFactor, + (float) rainMax * one / 4.0F + countFactor * one + vFactor); tessellator.setTranslation(0.0D, 0.0D, 0.0D); } else if (biomegenbase instanceof TFBiomeDarkForest && random.nextInt(2) == 0) { // DARKTHINGS @@ -543,28 +536,28 @@ private void renderLockedBiome(float partialTicks, WorldClient world, Minecraft tessellator.setTranslation(-offX * 1.0D, -offY * 1.0D, -offZ * 1.0D); tessellator.addVertexWithUV( (double) ((float) dx - rainX) + 0.5D, - (double) darkRainMin, + darkRainMin, (double) ((float) dz - rainZ) + 0.5D, - (double) (0.0F * one + uFactor), - (double) ((float) darkRainMin * one / 4.0F + countFactor * one + vFactor)); + 0.0F * one + uFactor, + (float) darkRainMin * one / 4.0F + countFactor * one + vFactor); tessellator.addVertexWithUV( (double) ((float) dx + rainX) + 0.5D, - (double) darkRainMin, + darkRainMin, (double) ((float) dz + rainZ) + 0.5D, - (double) (1.0F * one + uFactor), - (double) ((float) darkRainMin * one / 4.0F + countFactor * one + vFactor)); + 1.0F * one + uFactor, + (float) darkRainMin * one / 4.0F + countFactor * one + vFactor); tessellator.addVertexWithUV( (double) ((float) dx + rainX) + 0.5D, - (double) darkRainMax, + darkRainMax, (double) ((float) dz + rainZ) + 0.5D, - (double) (1.0F * one + uFactor), - (double) ((float) darkRainMax * one / 4.0F + countFactor * one + vFactor)); + 1.0F * one + uFactor, + (float) darkRainMax * one / 4.0F + countFactor * one + vFactor); tessellator.addVertexWithUV( (double) ((float) dx - rainX) + 0.5D, - (double) darkRainMax, + darkRainMax, (double) ((float) dz - rainZ) + 0.5D, - (double) (0.0F * one + uFactor), - (double) ((float) darkRainMax * one / 4.0F + countFactor * one + vFactor)); + 0.0F * one + uFactor, + (float) darkRainMax * one / 4.0F + countFactor * one + vFactor); tessellator.setTranslation(0.0D, 0.0D, 0.0D); } else if (biomegenbase instanceof TFBiomeHighlands || biomegenbase instanceof TFBiomeThornlands @@ -605,28 +598,28 @@ private void renderLockedBiome(float partialTicks, WorldClient world, Minecraft tessellator.setTranslation(-offX * 1.0D, -offY * 1.0D, -offZ * 1.0D); tessellator.addVertexWithUV( (double) ((float) dx - rainX) + 0.5D, - (double) rainMin, + rainMin, (double) ((float) dz - rainZ) + 0.5D, - (double) (0.0F * one + uFactor), - (double) ((float) rainMin * one / 4.0F + countFactor * one + vFactor)); + 0.0F * one + uFactor, + (float) rainMin * one / 4.0F + countFactor * one + vFactor); tessellator.addVertexWithUV( (double) ((float) dx + rainX) + 0.5D, - (double) rainMin, + rainMin, (double) ((float) dz + rainZ) + 0.5D, - (double) (1.0F * one + uFactor), - (double) ((float) rainMin * one / 4.0F + countFactor * one + vFactor)); + 1.0F * one + uFactor, + (float) rainMin * one / 4.0F + countFactor * one + vFactor); tessellator.addVertexWithUV( (double) ((float) dx + rainX) + 0.5D, - (double) rainMax, + rainMax, (double) ((float) dz + rainZ) + 0.5D, - (double) (1.0F * one + uFactor), - (double) ((float) rainMax * one / 4.0F + countFactor * one + vFactor)); + 1.0F * one + uFactor, + (float) rainMax * one / 4.0F + countFactor * one + vFactor); tessellator.addVertexWithUV( (double) ((float) dx - rainX) + 0.5D, - (double) rainMax, + rainMax, (double) ((float) dz - rainZ) + 0.5D, - (double) (0.0F * one + uFactor), - (double) ((float) rainMax * one / 4.0F + countFactor * one + vFactor)); + 0.0F * one + uFactor, + (float) rainMax * one / 4.0F + countFactor * one + vFactor); tessellator.setTranslation(0.0D, 0.0D, 0.0D); } @@ -642,7 +635,7 @@ private void renderLockedBiome(float partialTicks, WorldClient world, Minecraft GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_BLEND); GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); - mc.entityRenderer.disableLightmap((double) partialTicks); + mc.entityRenderer.disableLightmap(partialTicks); } } @@ -715,8 +708,7 @@ private void renderLockedStructure(float partialTicks, WorldClient world, Minecr float one = 1.0F; if (rainMin != rainMax) { - this.random - .setSeed((long) (dx * dx * 3121 + dx * 45238971 ^ dz * dz * 418711 + dz * 13761)); + this.random.setSeed(dx * dx * 3121 + dx * 45238971 ^ dz * dz * 418711 + dz * 13761); if (drawFlag != 0) { if (drawFlag >= 0) { @@ -748,28 +740,28 @@ private void renderLockedStructure(float partialTicks, WorldClient world, Minecr tessellator.setTranslation(-offX * 1.0D, -offY * 1.0D, -offZ * 1.0D); tessellator.addVertexWithUV( (double) ((float) dx - rainX) + 0.5D, - (double) rainMin, + rainMin, (double) ((float) dz - rainZ) + 0.5D, - (double) (0.0F * one + uFactor), - (double) ((float) rainMin * one / 4.0F + countFactor * one + vFactor)); + 0.0F * one + uFactor, + (float) rainMin * one / 4.0F + countFactor * one + vFactor); tessellator.addVertexWithUV( (double) ((float) dx + rainX) + 0.5D, - (double) rainMin, + rainMin, (double) ((float) dz + rainZ) + 0.5D, - (double) (1.0F * one + uFactor), - (double) ((float) rainMin * one / 4.0F + countFactor * one + vFactor)); + 1.0F * one + uFactor, + (float) rainMin * one / 4.0F + countFactor * one + vFactor); tessellator.addVertexWithUV( (double) ((float) dx + rainX) + 0.5D, - (double) rainMax, + rainMax, (double) ((float) dz + rainZ) + 0.5D, - (double) (1.0F * one + uFactor), - (double) ((float) rainMax * one / 4.0F + countFactor * one + vFactor)); + 1.0F * one + uFactor, + (float) rainMax * one / 4.0F + countFactor * one + vFactor); tessellator.addVertexWithUV( (double) ((float) dx - rainX) + 0.5D, - (double) rainMax, + rainMax, (double) ((float) dz - rainZ) + 0.5D, - (double) (0.0F * one + uFactor), - (double) ((float) rainMax * one / 4.0F + countFactor * one + vFactor)); + 0.0F * one + uFactor, + (float) rainMax * one / 4.0F + countFactor * one + vFactor); tessellator.setTranslation(0.0D, 0.0D, 0.0D); } } @@ -783,7 +775,7 @@ private void renderLockedStructure(float partialTicks, WorldClient world, Minecr GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_BLEND); GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); - mc.entityRenderer.disableLightmap((double) partialTicks); + mc.entityRenderer.disableLightmap(partialTicks); } } @@ -813,9 +805,7 @@ private boolean isNearLockedBiome(World world, EntityLivingBase viewEntity) { for (int z = pz - range; z <= pz + range; ++z) { for (int x = px - range; x <= px + range; ++x) { BiomeGenBase biomegenbase = world.getBiomeGenForCoords(x, z); - if (biomegenbase instanceof TFBiomeBase && viewEntity instanceof EntityPlayer) { - TFBiomeBase tfBiome = (TFBiomeBase) biomegenbase; - EntityPlayer player = (EntityPlayer) viewEntity; + if (biomegenbase instanceof TFBiomeBase tfBiome && viewEntity instanceof EntityPlayer player) { if (!tfBiome.doesPlayerHaveRequiredAchievement(player)) { return true; } diff --git a/src/main/java/twilightforest/client/renderer/TileEntityTFTrophyRenderer.java b/src/main/java/twilightforest/client/renderer/TileEntityTFTrophyRenderer.java index 28bccafff4..21ecc9a50b 100644 --- a/src/main/java/twilightforest/client/renderer/TileEntityTFTrophyRenderer.java +++ b/src/main/java/twilightforest/client/renderer/TileEntityTFTrophyRenderer.java @@ -1,7 +1,6 @@ package twilightforest.client.renderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; @@ -56,42 +55,30 @@ public void renderTileEntityAt(TileEntity tileentity, double x, double y, double // wall mounted? if (meta != 1) { switch (meta) { - case 2: - onGround = false; - break; - case 3: + case 2 -> onGround = false; + case 3 -> { onGround = false; rotation = 180.0F; - break; - case 4: + } + case 4 -> { onGround = false; rotation = 270.0F; - break; - case 5: - default: + } + default -> { onGround = false; rotation = 90.0F; + } } } GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F); switch (trophy.func_145904_a()) { - case 0: - renderHydraHead(rotation, onGround); - break; - case 1: - renderNagaHead(rotation, onGround); - break; - case 2: - renderLichHead(rotation, onGround); - break; - case 3: - renderUrGhastHead(trophy, rotation, onGround, partialTime); - break; - case 4: - renderSnowQueenHead(rotation, onGround); - break; + case 0 -> renderHydraHead(rotation, onGround); + case 1 -> renderNagaHead(rotation, onGround); + case 2 -> renderLichHead(rotation, onGround); + case 3 -> renderUrGhastHead(trophy, rotation, onGround, partialTime); + case 4 -> renderSnowQueenHead(rotation, onGround); } GL11.glPopMatrix(); @@ -119,7 +106,7 @@ private void renderHydraHead(float rotation, boolean onGround) { hydraHeadModel.openMouthForTrophy(onGround ? 0F : 0.25F); // render the hydra head - hydraHeadModel.render((Entity) null, 0.0F, 0.0F, 0.0F, rotation, 0.0F, 0.0625F); + hydraHeadModel.render(null, 0.0F, 0.0F, 0.0F, rotation, 0.0F, 0.0625F); } private void renderNagaHead(float rotation, boolean onGround) { @@ -139,7 +126,7 @@ private void renderNagaHead(float rotation, boolean onGround) { GL11.glTranslatef(0, onGround ? 1F : -0F, onGround ? 0F : 1F); // render the naga head - nagaHeadModel.render((Entity) null, 0.0F, 0.0F, 0.0F, rotation, 0.0F, 0.0625F); + nagaHeadModel.render(null, 0.0F, 0.0F, 0.0F, rotation, 0.0F, 0.0625F); } private void renderLichHead(float rotation, boolean onGround) { @@ -180,7 +167,7 @@ private void renderUrGhastHead(TileEntityTFTrophy trophy, float rotation, boolea GL11.glTranslatef(0, onGround ? 1F : 1F, onGround ? 0F : 0F); // render the naga head - urGhastModel.render((Entity) null, 0.0F, 0, trophy.ticksExisted + partialTime, 0, 0.0F, 0.0625F); + urGhastModel.render(null, 0.0F, 0, trophy.ticksExisted + partialTime, 0, 0.0F, 0.0625F); } private void renderSnowQueenHead(float rotation, boolean onGround) { diff --git a/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFCastleMagic.java b/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFCastleMagic.java index 06d9a8d504..951d04c08c 100644 --- a/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFCastleMagic.java +++ b/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFCastleMagic.java @@ -142,27 +142,27 @@ public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block b if (renderer.renderAllFaces || block.shouldSideBeRendered(world, x, y - 1, z, 0) && world.isAirBlock(x, y - 1, z)) { - renderer.renderFaceYNeg(block, (double) x, (double) y - pixel, (double) z, renderer.overrideBlockTexture); + renderer.renderFaceYNeg(block, x, (double) y - pixel, z, renderer.overrideBlockTexture); } if (renderer.renderAllFaces || block.shouldSideBeRendered(world, x, y + 1, z, 1) && world.isAirBlock(x, y + 1, z)) { - renderer.renderFaceYPos(block, (double) x, (double) y + pixel, (double) z, renderer.overrideBlockTexture); + renderer.renderFaceYPos(block, x, (double) y + pixel, z, renderer.overrideBlockTexture); } if (renderer.renderAllFaces || block.shouldSideBeRendered(world, x, y, z - 1, 2) && world.isAirBlock(x, y, z - 1)) { - renderer.renderFaceZNeg(block, (double) x, (double) y, (double) z - pixel, renderer.overrideBlockTexture); + renderer.renderFaceZNeg(block, x, y, (double) z - pixel, renderer.overrideBlockTexture); } if (renderer.renderAllFaces || block.shouldSideBeRendered(world, x, y, z + 1, 3) && world.isAirBlock(x, y, z + 1)) { - renderer.renderFaceZPos(block, (double) x, (double) y, (double) z + pixel, renderer.overrideBlockTexture); + renderer.renderFaceZPos(block, x, y, (double) z + pixel, renderer.overrideBlockTexture); } if (renderer.renderAllFaces || block.shouldSideBeRendered(world, x - 1, y, z, 4) && world.isAirBlock(x - 1, y, z)) { - renderer.renderFaceXNeg(block, (double) x - pixel, (double) y, (double) z, renderer.overrideBlockTexture); + renderer.renderFaceXNeg(block, (double) x - pixel, y, z, renderer.overrideBlockTexture); } if (renderer.renderAllFaces || block.shouldSideBeRendered(world, x + 1, y, z, 5) && world.isAirBlock(x + 1, y, z)) { - renderer.renderFaceXPos(block, (double) x + pixel, (double) y, (double) z, renderer.overrideBlockTexture); + renderer.renderFaceXPos(block, (double) x + pixel, y, z, renderer.overrideBlockTexture); } renderer.clearOverrideBlockTexture(); diff --git a/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFHugeLilyPad.java b/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFHugeLilyPad.java index 866d8b90a4..734745509d 100644 --- a/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFHugeLilyPad.java +++ b/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFHugeLilyPad.java @@ -15,9 +15,7 @@ public RenderBlockTFHugeLilyPad(int blockComplexRenderID) { } @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - ; - } + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {} @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, diff --git a/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFMagicLeaves.java b/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFMagicLeaves.java index 7a2b7abc16..31cc008f24 100644 --- a/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFMagicLeaves.java +++ b/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFMagicLeaves.java @@ -55,14 +55,13 @@ private void setRenderRotate(RenderBlocks renderer, int meta, int x, int y, int int type = meta & 3; switch (type) { - case 0: + case 0 -> { renderer.uvRotateEast = 3; renderer.uvRotateBottom = 0; - renderer.uvRotateNorth = 2; renderer.uvRotateSouth = 2; - break; - case 1: + } + case 1 -> { // bottom and top are semi-random renderer.uvRotateBottom = (x + y + z) & 3; renderer.uvRotateTop = (x + y + z) & 3; @@ -70,11 +69,10 @@ private void setRenderRotate(RenderBlocks renderer, int meta, int x, int y, int // sides flow down renderer.uvRotateEast = 1; renderer.uvRotateWest = 2; - renderer.uvRotateNorth = 2; renderer.uvRotateSouth = 1; - break; - case 2: + } + case 2 -> { // bottom and top are semi-random renderer.uvRotateBottom = (x + y + z) & 3; renderer.uvRotateTop = (x + y + z) & 3; @@ -82,20 +80,18 @@ private void setRenderRotate(RenderBlocks renderer, int meta, int x, int y, int // sides flow up renderer.uvRotateEast = 2; renderer.uvRotateWest = 1; - renderer.uvRotateNorth = 1; renderer.uvRotateSouth = 2; - break; - case 3: + } + case 3 -> { // all semi-random renderer.uvRotateBottom = (x + y + z) & 3; renderer.uvRotateTop = (x + y + z) & 3; - - renderer.uvRotateEast = (x + y + z) & 3;; - renderer.uvRotateWest = (x + y + z) & 3;; - - renderer.uvRotateNorth = (x + y + z) & 3;; - renderer.uvRotateSouth = (x + y + z) & 3;; + renderer.uvRotateEast = (x + y + z) & 3; + renderer.uvRotateWest = (x + y + z) & 3; + renderer.uvRotateNorth = (x + y + z) & 3; + renderer.uvRotateSouth = (x + y + z) & 3; + } } } diff --git a/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFNagastone.java b/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFNagastone.java index 238674f367..f9e219200e 100644 --- a/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFNagastone.java +++ b/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFNagastone.java @@ -54,63 +54,63 @@ private void setRenderRotate(RenderBlocks renderer, int meta) { // heads if (type == 0) { switch (orient) { - case 0: + case 0 -> { renderer.uvRotateTop = 1; renderer.uvRotateBottom = 2; - break; - case 1: + } + case 1 -> { renderer.uvRotateTop = 2; renderer.uvRotateBottom = 1; renderer.uvRotateSouth = 0; - break; - case 2: + } + case 2 -> { renderer.uvRotateTop = 0; renderer.uvRotateBottom = 3; - break; - case 3: + } + case 3 -> { renderer.uvRotateTop = 3; renderer.uvRotateBottom = 0; - break; + } } } else if (type == 4 || type == 8) { switch (orient) { - case 0: + case 0 -> { renderer.uvRotateTop = 2; renderer.uvRotateBottom = 1; renderer.uvRotateWest = 2; - break; - case 1: + } + case 1 -> { renderer.uvRotateTop = 1; renderer.uvRotateBottom = 2; renderer.uvRotateEast = 2; - break; - case 2: + } + case 2 -> { renderer.uvRotateTop = 3; renderer.uvRotateBottom = 0; renderer.uvRotateSouth = 2; - break; - case 3: + } + case 3 -> { renderer.uvRotateTop = 0; renderer.uvRotateBottom = 3; renderer.uvRotateNorth = 2; - break; + } } } else if (type == 12) { switch (orient) { - case 0: + case 0 -> { renderer.uvRotateTop = 0; renderer.uvRotateBottom = 0; - break; - case 1: + } + case 1 -> { renderer.uvRotateTop = 1; renderer.uvRotateBottom = 1; - break; - case 2: + } + case 2 -> { renderer.uvRotateNorth = 2; renderer.uvRotateSouth = 2; renderer.uvRotateEast = 2; renderer.uvRotateWest = 2; - break; + } } } } diff --git a/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFThorns.java b/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFThorns.java index 3f01e3fdd5..4436950855 100644 --- a/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFThorns.java +++ b/src/main/java/twilightforest/client/renderer/blocks/RenderBlockTFThorns.java @@ -36,15 +36,11 @@ public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block b int metadata = world.getBlockMetadata(x, y, z); int type = metadata & 12; - switch (type) { - case 0: - default: - return this.renderCactusLikeY(block, x, y, z, f, f1, f2, metadata, world, renderer); - case 4: - return this.renderCactusLikeX(block, x, y, z, f, f1, f2, metadata, world, renderer); - case 8: - return this.renderCactusLikeZ(block, x, y, z, f, f1, f2, metadata, world, renderer); - } + return switch (type) { + default -> this.renderCactusLikeY(block, x, y, z, f, f1, f2, metadata, world, renderer); + case 4 -> this.renderCactusLikeX(block, x, y, z, f, f1, f2, metadata, world, renderer); + case 8 -> this.renderCactusLikeZ(block, x, y, z, f, f1, f2, metadata, world, renderer); + }; } @@ -92,12 +88,7 @@ public boolean renderCactusLikeX(Block block, int x, int y, int z, float red, fl renderer.renderMinX > 0.0D ? blockBrightness : block.getMixedBrightnessForBlock(renderer.blockAccess, x - 1, y, z)); tessellator.setColorOpaque_F(bRed, bGreen, bBlue); - renderer.renderFaceXNeg( - block, - (double) x, - (double) y, - (double) z, - renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 4)); + renderer.renderFaceXNeg(block, x, y, z, renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 4)); } if (renderer.renderAllFaces || block.shouldSideBeRendered(renderer.blockAccess, x + 1, y, z, 5)) { @@ -105,12 +96,7 @@ public boolean renderCactusLikeX(Block block, int x, int y, int z, float red, fl renderer.renderMaxX < 1.0D ? blockBrightness : block.getMixedBrightnessForBlock(renderer.blockAccess, x + 1, y, z)); tessellator.setColorOpaque_F(tRed, tGreen, tBlue); - renderer.renderFaceXPos( - block, - (double) x, - (double) y, - (double) z, - renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 5)); + renderer.renderFaceXPos(block, x, y, z, renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 5)); } drawXSides( @@ -248,12 +234,7 @@ public boolean renderCactusLikeY(Block block, int x, int y, int z, float red, fl renderer.renderMinY > 0.0D ? blockBrightness : block.getMixedBrightnessForBlock(world, x, y - 1, z)); tessellator.setColorOpaque_F(bRed, bGreen, bBlue); - renderer.renderFaceYNeg( - block, - (double) x, - (double) y, - (double) z, - renderer.getBlockIcon(block, world, x, y, z, 0)); + renderer.renderFaceYNeg(block, x, y, z, renderer.getBlockIcon(block, world, x, y, z, 0)); } if (renderer.renderAllFaces || block.shouldSideBeRendered(world, x, y + 1, z, 1)) { @@ -261,12 +242,7 @@ public boolean renderCactusLikeY(Block block, int x, int y, int z, float red, fl renderer.renderMaxY < 1.0D ? blockBrightness : block.getMixedBrightnessForBlock(world, x, y + 1, z)); tessellator.setColorOpaque_F(tRed, tGreen, tBlue); - renderer.renderFaceYPos( - block, - (double) x, - (double) y, - (double) z, - renderer.getBlockIcon(block, world, x, y, z, 1)); + renderer.renderFaceYPos(block, x, y, z, renderer.getBlockIcon(block, world, x, y, z, 1)); } drawYSides( @@ -406,12 +382,7 @@ public boolean renderCactusLikeZ(Block block, int x, int y, int z, float red, fl renderer.renderMinZ > 0.0D ? blockBrightness : block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z - 1)); tessellator.setColorOpaque_F(bRed, bGreen, bBlue); - renderer.renderFaceZNeg( - block, - (double) x, - (double) y, - (double) z, - renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 2)); + renderer.renderFaceZNeg(block, x, y, z, renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 2)); } if (renderer.renderAllFaces || block.shouldSideBeRendered(renderer.blockAccess, x, y, z + 1, 1)) { @@ -419,12 +390,7 @@ public boolean renderCactusLikeZ(Block block, int x, int y, int z, float red, fl renderer.renderMaxZ < 1.0D ? blockBrightness : block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z + 1)); tessellator.setColorOpaque_F(tRed, tGreen, tBlue); - renderer.renderFaceZPos( - block, - (double) x, - (double) y, - (double) z, - renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 3)); + renderer.renderFaceZPos(block, x, y, z, renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 3)); } drawZSides( @@ -537,17 +503,17 @@ private void drawXSides(Block block, int x, int y, int z, RenderBlocks renderer, tessellator.setBrightness(l); tessellator.setColorOpaque_F(zRed, zGreen, zBlue); tessellator.addTranslation(0.0F, 0.0F, onePixel); - renderer.renderFaceZNeg(block, (double) x, (double) y, (double) z, getSideIcon(block, metadata)); + renderer.renderFaceZNeg(block, x, y, z, getSideIcon(block, metadata)); tessellator.addTranslation(0.0F, 0.0F, -onePixel); tessellator.addTranslation(0.0F, 0.0F, -onePixel); - renderer.renderFaceZPos(block, (double) x, (double) y, (double) z, getSideIcon(block, metadata)); + renderer.renderFaceZPos(block, x, y, z, getSideIcon(block, metadata)); tessellator.addTranslation(0.0F, 0.0F, onePixel); tessellator.setColorOpaque_F(xRed, xGreen, xBlue); tessellator.addTranslation(0.0F, onePixel, 0.0F); - renderer.renderFaceYNeg(block, (double) x, (double) y, (double) z, getSideIcon(block, metadata)); + renderer.renderFaceYNeg(block, x, y, z, getSideIcon(block, metadata)); tessellator.addTranslation(0.0F, -onePixel, 0.0F); tessellator.addTranslation(0.0F, -onePixel, 0.0F); - renderer.renderFaceYPos(block, (double) x, (double) y, (double) z, getSideIcon(block, metadata)); + renderer.renderFaceYPos(block, x, y, z, getSideIcon(block, metadata)); tessellator.addTranslation(0.0F, onePixel, 0.0F); } @@ -558,17 +524,17 @@ private void drawYSides(Block block, int x, int y, int z, RenderBlocks renderer, tessellator.setBrightness(blockBrightness); tessellator.setColorOpaque_F(zRed, zGreen, zBlue); tessellator.addTranslation(0.0F, 0.0F, onePixel); - renderer.renderFaceZNeg(block, (double) x, (double) y, (double) z, getSideIcon(block, metadata)); + renderer.renderFaceZNeg(block, x, y, z, getSideIcon(block, metadata)); tessellator.addTranslation(0.0F, 0.0F, -onePixel); tessellator.addTranslation(0.0F, 0.0F, -onePixel); - renderer.renderFaceZPos(block, (double) x, (double) y, (double) z, getSideIcon(block, metadata)); + renderer.renderFaceZPos(block, x, y, z, getSideIcon(block, metadata)); tessellator.addTranslation(0.0F, 0.0F, onePixel); tessellator.setColorOpaque_F(xRed, xGreen, xBlue); tessellator.addTranslation(onePixel, 0.0F, 0.0F); - renderer.renderFaceXNeg(block, (double) x, (double) y, (double) z, getSideIcon(block, metadata)); + renderer.renderFaceXNeg(block, x, y, z, getSideIcon(block, metadata)); tessellator.addTranslation(-onePixel, 0.0F, 0.0F); tessellator.addTranslation(-onePixel, 0.0F, 0.0F); - renderer.renderFaceXPos(block, (double) x, (double) y, (double) z, getSideIcon(block, metadata)); + renderer.renderFaceXPos(block, x, y, z, getSideIcon(block, metadata)); tessellator.addTranslation(onePixel, 0.0F, 0.0F); } @@ -579,17 +545,17 @@ private void drawZSides(Block block, int x, int y, int z, RenderBlocks renderer, tessellator.setBrightness(blockBrightness); tessellator.setColorOpaque_F(xRed, xGreen, xBlue); tessellator.addTranslation(onePixel, 0.0F, 0.0F); - renderer.renderFaceXNeg(block, (double) x, (double) y, (double) z, getSideIcon(block, metadata)); + renderer.renderFaceXNeg(block, x, y, z, getSideIcon(block, metadata)); tessellator.addTranslation(-onePixel, 0.0F, 0.0F); tessellator.addTranslation(-onePixel, 0.0F, 0.0F); - renderer.renderFaceXPos(block, (double) x, (double) y, (double) z, getSideIcon(block, metadata)); + renderer.renderFaceXPos(block, x, y, z, getSideIcon(block, metadata)); tessellator.addTranslation(onePixel, 0.0F, 0.0F); tessellator.setColorOpaque_F(zRed, zGreen, zBlue); tessellator.addTranslation(0.0F, onePixel, 0.0F); - renderer.renderFaceYNeg(block, (double) x, (double) y, (double) z, getSideIcon(block, metadata)); + renderer.renderFaceYNeg(block, x, y, z, getSideIcon(block, metadata)); tessellator.addTranslation(0.0F, -onePixel, 0.0F); tessellator.addTranslation(0.0F, -onePixel, 0.0F); - renderer.renderFaceYPos(block, (double) x, (double) y, (double) z, getSideIcon(block, metadata)); + renderer.renderFaceYPos(block, x, y, z, getSideIcon(block, metadata)); tessellator.addTranslation(0.0F, onePixel, 0.0F); } diff --git a/src/main/java/twilightforest/client/renderer/entity/RenderTFBunny.java b/src/main/java/twilightforest/client/renderer/entity/RenderTFBunny.java index 22edd52451..96dc2d6e35 100644 --- a/src/main/java/twilightforest/client/renderer/entity/RenderTFBunny.java +++ b/src/main/java/twilightforest/client/renderer/entity/RenderTFBunny.java @@ -27,18 +27,11 @@ public RenderTFBunny(ModelBase par1ModelBase, float par2) { */ protected ResourceLocation getEntityTexture(Entity par1Entity) { if (par1Entity instanceof EntityTFBunny) { - switch (((EntityTFBunny) par1Entity).getBunnyType()) { - default: - case 0: - case 1: - return textureLocDutch; - - case 2: - return textureLocWhite; - - case 3: - return textureLocBrown; - } + return switch (((EntityTFBunny) par1Entity).getBunnyType()) { + default -> textureLocDutch; + case 2 -> textureLocWhite; + case 3 -> textureLocBrown; + }; } // fallback diff --git a/src/main/java/twilightforest/client/renderer/entity/RenderTFCharm.java b/src/main/java/twilightforest/client/renderer/entity/RenderTFCharm.java index a7bf811098..0a3e087513 100644 --- a/src/main/java/twilightforest/client/renderer/entity/RenderTFCharm.java +++ b/src/main/java/twilightforest/client/renderer/entity/RenderTFCharm.java @@ -35,8 +35,7 @@ public RenderTFCharm(IIcon par1) { * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. */ public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { - if (par1Entity instanceof EntityTFCharmEffect) { - EntityTFCharmEffect charm = (EntityTFCharmEffect) par1Entity; + if (par1Entity instanceof EntityTFCharmEffect charm) { if (charm.getItemID() > 0) { // this.itemIcon = Items.itemsList[charm.getItemID()].getIconFromDamage(0); this.itemIcon = TFItems.charmOfKeeping1.getIconFromDamage(0); @@ -67,10 +66,10 @@ private void func_77026_a(Tessellator par1Tessellator, IIcon par2Icon) { GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); par1Tessellator.startDrawingQuads(); par1Tessellator.setNormal(0.0F, 1.0F, 0.0F); - par1Tessellator.addVertexWithUV((double) (0.0F - f5), (double) (0.0F - f6), 0.0D, (double) f, (double) f3); - par1Tessellator.addVertexWithUV((double) (f4 - f5), (double) (0.0F - f6), 0.0D, (double) f1, (double) f3); - par1Tessellator.addVertexWithUV((double) (f4 - f5), (double) (f4 - f6), 0.0D, (double) f1, (double) f2); - par1Tessellator.addVertexWithUV((double) (0.0F - f5), (double) (f4 - f6), 0.0D, (double) f, (double) f2); + par1Tessellator.addVertexWithUV(0.0F - f5, 0.0F - f6, 0.0D, f, f3); + par1Tessellator.addVertexWithUV(f4 - f5, 0.0F - f6, 0.0D, f1, f3); + par1Tessellator.addVertexWithUV(f4 - f5, f4 - f6, 0.0D, f1, f2); + par1Tessellator.addVertexWithUV(0.0F - f5, f4 - f6, 0.0D, f, f2); par1Tessellator.draw(); } diff --git a/src/main/java/twilightforest/client/renderer/entity/RenderTFMiniGhast.java b/src/main/java/twilightforest/client/renderer/entity/RenderTFMiniGhast.java index 35880c43b6..4f00dc3f77 100644 --- a/src/main/java/twilightforest/client/renderer/entity/RenderTFMiniGhast.java +++ b/src/main/java/twilightforest/client/renderer/entity/RenderTFMiniGhast.java @@ -27,17 +27,11 @@ public RenderTFMiniGhast(ModelBase par1ModelBase, float par2) { */ protected ResourceLocation getEntityTexture(Entity par1Entity) { if (par1Entity instanceof EntityTFTowerGhast) { - switch (((EntityTFTowerGhast) par1Entity).getAttackStatus()) { - default: - case 0: - return textureLocClosed; - - case 1: - return textureLocOpen; - - case 2: - return textureLocAttack; - } + return switch (((EntityTFTowerGhast) par1Entity).getAttackStatus()) { + default -> textureLocClosed; + case 1 -> textureLocOpen; + case 2 -> textureLocAttack; + }; } // fallback diff --git a/src/main/java/twilightforest/client/renderer/entity/RenderTFNaga.java b/src/main/java/twilightforest/client/renderer/entity/RenderTFNaga.java index 1f36efb67c..b9bcefe40f 100644 --- a/src/main/java/twilightforest/client/renderer/entity/RenderTFNaga.java +++ b/src/main/java/twilightforest/client/renderer/entity/RenderTFNaga.java @@ -34,8 +34,7 @@ public void doRender(Entity entity, double d, double d1, double d2, float f, flo // BossStatus.setBossStatus((EntityTFNagaOld)entity, false); // } - if (entity instanceof EntityTFNaga && ((EntityTFNaga) entity).getParts() != null) { - EntityTFNaga naga = (EntityTFNaga) entity; + if (entity instanceof EntityTFNaga naga && entity.getParts() != null) { for (int i = 0; i < naga.getParts().length; i++) { if (!naga.getParts()[i].isDead) { diff --git a/src/main/java/twilightforest/client/renderer/entity/RenderTFSlimeBeetle.java b/src/main/java/twilightforest/client/renderer/entity/RenderTFSlimeBeetle.java index 8215153ee5..deeea65a5e 100644 --- a/src/main/java/twilightforest/client/renderer/entity/RenderTFSlimeBeetle.java +++ b/src/main/java/twilightforest/client/renderer/entity/RenderTFSlimeBeetle.java @@ -27,7 +27,7 @@ public RenderTFSlimeBeetle(ModelBase par1ModelBase, float par2) { * Queries whether should render the specified pass or not. */ protected int shouldRenderPass(EntityLivingBase par1EntityLiving, int par2, float par3) { - return this.shouldSlimeRenderPass((EntityLivingBase) par1EntityLiving, par2, par3); + return this.shouldSlimeRenderPass(par1EntityLiving, par2, par3); } /** diff --git a/src/main/java/twilightforest/client/renderer/entity/RenderTFTinyBird.java b/src/main/java/twilightforest/client/renderer/entity/RenderTFTinyBird.java index 3a6704f306..3068ffdf4f 100644 --- a/src/main/java/twilightforest/client/renderer/entity/RenderTFTinyBird.java +++ b/src/main/java/twilightforest/client/renderer/entity/RenderTFTinyBird.java @@ -28,17 +28,12 @@ public RenderTFTinyBird(ModelBase par1ModelBase, float par2) { */ protected ResourceLocation getEntityTexture(Entity par1Entity) { if (par1Entity instanceof EntityTFTinyBird) { - switch (((EntityTFTinyBird) par1Entity).getBirdType()) { - default: - case 0: - return textureLocSparrow; - case 1: - return textureLocBluebird; - case 2: - return textureLocCardinal; - case 3: - return textureLocFinch; - } + return switch (((EntityTFTinyBird) par1Entity).getBirdType()) { + default -> textureLocSparrow; + case 1 -> textureLocBluebird; + case 2 -> textureLocCardinal; + case 3 -> textureLocFinch; + }; } // fallback diff --git a/src/main/java/twilightforest/client/renderer/entity/RenderTFUrGhast.java b/src/main/java/twilightforest/client/renderer/entity/RenderTFUrGhast.java index 102ed7071e..d75affeed6 100644 --- a/src/main/java/twilightforest/client/renderer/entity/RenderTFUrGhast.java +++ b/src/main/java/twilightforest/client/renderer/entity/RenderTFUrGhast.java @@ -25,17 +25,11 @@ public RenderTFUrGhast(ModelTFGhast modelTFGhast, float f, float scale) { */ protected ResourceLocation getEntityTexture(Entity par1Entity) { if (par1Entity instanceof EntityTFTowerGhast) { - switch (((EntityTFTowerGhast) par1Entity).getAttackStatus()) { - default: - case 0: - return textureLocClosed; - - case 1: - return textureLocOpen; - - case 2: - return textureLocAttack; - } + return switch (((EntityTFTowerGhast) par1Entity).getAttackStatus()) { + default -> textureLocClosed; + case 1 -> textureLocOpen; + case 2 -> textureLocAttack; + }; } // fallback diff --git a/src/main/java/twilightforest/entity/EntitySeekerArrow.java b/src/main/java/twilightforest/entity/EntitySeekerArrow.java index 8bffcda67d..4f8ec50987 100644 --- a/src/main/java/twilightforest/entity/EntitySeekerArrow.java +++ b/src/main/java/twilightforest/entity/EntitySeekerArrow.java @@ -67,8 +67,7 @@ public void onUpdate() { double closestDot = 1; for (Object thing : targets) { - if (thing instanceof EntityLivingBase && !(thing instanceof EntityPlayer)) { - EntityLivingBase living = (EntityLivingBase) thing; + if (thing instanceof EntityLivingBase living && !(thing instanceof EntityPlayer)) { // cpw.mods.fml.common.FMLLog.info("Possible target : " + living); // cpw.mods.fml.common.FMLLog.info("Selection box = " + targetBB); diff --git a/src/main/java/twilightforest/entity/EntityTFBlockGoblin.java b/src/main/java/twilightforest/entity/EntityTFBlockGoblin.java index 209f1d4f42..0923fe61ca 100644 --- a/src/main/java/twilightforest/entity/EntityTFBlockGoblin.java +++ b/src/main/java/twilightforest/entity/EntityTFBlockGoblin.java @@ -223,15 +223,14 @@ public void onUpdate() { /** * Check if the block is colliding with any nearby entities */ - @SuppressWarnings("unchecked") protected void applyBlockCollisions(Entity collider) { List list = this.worldObj.getEntitiesWithinAABBExcludingEntity( collider, collider.boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D)); if (list != null && !list.isEmpty()) { - for (int i = 0; i < list.size(); ++i) { - Entity entity = (Entity) list.get(i); + for (Entity value : list) { + Entity entity = value; if (entity.canBePushed()) { applyBlockCollision(collider, entity); diff --git a/src/main/java/twilightforest/entity/EntityTFChainBlock.java b/src/main/java/twilightforest/entity/EntityTFChainBlock.java index 7d06ece140..2d84a21b06 100644 --- a/src/main/java/twilightforest/entity/EntityTFChainBlock.java +++ b/src/main/java/twilightforest/entity/EntityTFChainBlock.java @@ -112,36 +112,36 @@ protected void onImpact(MovingObjectPosition mop) { this.velZ *= bounce; switch (mop.sideHit) { - case 0: + case 0 -> { if (this.velY > 0) { this.velY *= -bounce; } - break; - case 1: + } + case 1 -> { if (this.velY < 0) { this.velY *= -bounce; } - break; - case 2: + } + case 2 -> { if (this.velZ > 0) { this.velZ *= -bounce; } - break; - case 3: + } + case 3 -> { if (this.velZ < 0) { this.velZ *= -bounce; } - break; - case 4: + } + case 4 -> { if (this.velX > 0) { this.velX *= -bounce; } - break; - case 5: + } + case 5 -> { if (this.velX < 0) { this.velX *= -bounce; } - break; + } } } @@ -186,8 +186,7 @@ private boolean affectBlocksInAABB(AxisAlignedBB par1AxisAlignedBB, EntityLiving if (block != Blocks.air && block.getExplosionResistance(this) < 7F && block.getBlockHardness(worldObj, dx, dy, dz) >= 0) { - if (entity != null && entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) entity; + if (entity != null && entity instanceof EntityPlayer player) { if (block.canHarvestBlock(player, currentMeta)) { block.harvestBlock(this.worldObj, player, dx, dy, dz, currentMeta); @@ -268,11 +267,11 @@ public void onUpdate() { // on the client, if we are not attached, assume we have just spawned, and attach to the player if (this.worldObj.isRemote && !this.isAttached) { - List nearbyEntities = this.worldObj.getEntitiesWithinAABBExcludingEntity( + List nearbyEntities = this.worldObj.getEntitiesWithinAABBExcludingEntity( this, this.boundingBox.addCoord(-this.motionX, -this.motionY, -this.motionZ).expand(2.0D, 2.0D, 2.0D)); - for (int i = 0; i < nearbyEntities.size(); ++i) { - Entity nearby = (Entity) nearbyEntities.get(i); + for (Object nearbyEntity : nearbyEntities) { + Entity nearby = (Entity) nearbyEntity; // attach? should we check for closest player? if (nearby instanceof EntityPlayer) { diff --git a/src/main/java/twilightforest/entity/EntityTFCubeOfAnnihilation.java b/src/main/java/twilightforest/entity/EntityTFCubeOfAnnihilation.java index 259a63085a..5b72b080f5 100644 --- a/src/main/java/twilightforest/entity/EntityTFCubeOfAnnihilation.java +++ b/src/main/java/twilightforest/entity/EntityTFCubeOfAnnihilation.java @@ -3,6 +3,7 @@ import java.util.List; import net.minecraft.block.Block; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityThrowable; @@ -163,7 +164,7 @@ public void onUpdate() { if (this.isReturning()) { // if we are returning, and are near enough to the player, then we are done - List list = this.worldObj.getEntitiesWithinAABBExcludingEntity( + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity( this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); @@ -233,10 +234,9 @@ public void onUpdate() { } public boolean isReturning() { - if (this.hasHitObstacle || this.getThrower() == null || !(this.getThrower() instanceof EntityPlayer)) { + if (this.hasHitObstacle || this.getThrower() == null || !(this.getThrower() instanceof EntityPlayer player)) { return true; } else { - EntityPlayer player = (EntityPlayer) this.getThrower(); return !player.isUsingItem(); } diff --git a/src/main/java/twilightforest/entity/EntityTFGiantMiner.java b/src/main/java/twilightforest/entity/EntityTFGiantMiner.java index 5f2133aa1c..a862b7f663 100644 --- a/src/main/java/twilightforest/entity/EntityTFGiantMiner.java +++ b/src/main/java/twilightforest/entity/EntityTFGiantMiner.java @@ -1,5 +1,7 @@ package twilightforest.entity; +import java.util.Arrays; + import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILookIdle; @@ -34,9 +36,7 @@ public EntityTFGiantMiner(World par1World) { this.setCurrentItemOrArmor(0, new ItemStack(Items.stone_pickaxe)); - for (int i = 0; i < this.equipmentDropChances.length; ++i) { - this.equipmentDropChances[i] = 0F; - } + Arrays.fill(this.equipmentDropChances, 0F); } protected void applyEntityAttributes() { diff --git a/src/main/java/twilightforest/entity/EntityTFGoblinKnightLower.java b/src/main/java/twilightforest/entity/EntityTFGoblinKnightLower.java index e3f0027190..3e065e9959 100644 --- a/src/main/java/twilightforest/entity/EntityTFGoblinKnightLower.java +++ b/src/main/java/twilightforest/entity/EntityTFGoblinKnightLower.java @@ -82,7 +82,7 @@ public void setHasArmor(boolean flag) { if (flag) { dataWatcher.updateObject(DATA_EQUIP, (byte) (otherFlags | 1)); } else { - dataWatcher.updateObject(DATA_EQUIP, (byte) otherFlags); + dataWatcher.updateObject(DATA_EQUIP, otherFlags); } } @@ -111,7 +111,7 @@ public void initCreature() { // we start with the upper guy riding us EntityTFGoblinKnightUpper upper = new EntityTFGoblinKnightUpper(this.worldObj); upper.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); - upper.onSpawnWithEgg((IEntityLivingData) null); + upper.onSpawnWithEgg(null); this.worldObj.spawnEntityInWorld(upper); upper.mountEntity(this); } @@ -125,7 +125,7 @@ public IEntityLivingData onSpawnWithEgg(IEntityLivingData par1EntityLivingData) // we start with the upper guy riding us EntityTFGoblinKnightUpper upper = new EntityTFGoblinKnightUpper(this.worldObj); upper.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); - upper.onSpawnWithEgg((IEntityLivingData) null); + upper.onSpawnWithEgg(null); this.worldObj.spawnEntityInWorld(upper); upper.mountEntity(this); diff --git a/src/main/java/twilightforest/entity/EntityTFGoblinKnightUpper.java b/src/main/java/twilightforest/entity/EntityTFGoblinKnightUpper.java index d30a171391..ebc608d338 100644 --- a/src/main/java/twilightforest/entity/EntityTFGoblinKnightUpper.java +++ b/src/main/java/twilightforest/entity/EntityTFGoblinKnightUpper.java @@ -99,7 +99,7 @@ public void setHasArmor(boolean flag) { if (flag) { dataWatcher.updateObject(DATA_EQUIP, (byte) (otherFlags | 1)); } else { - dataWatcher.updateObject(DATA_EQUIP, (byte) otherFlags); + dataWatcher.updateObject(DATA_EQUIP, otherFlags); } } @@ -114,7 +114,7 @@ public void setHasShield(boolean flag) { if (flag) { dataWatcher.updateObject(DATA_EQUIP, (byte) (otherFlags | 2)); } else { - dataWatcher.updateObject(DATA_EQUIP, (byte) otherFlags); + dataWatcher.updateObject(DATA_EQUIP, otherFlags); } } @@ -169,7 +169,6 @@ public void onUpdate() { super.onUpdate(); } - @SuppressWarnings("unchecked") private void landHeavySpearAttack() { // find vector in front of us diff --git a/src/main/java/twilightforest/entity/EntityTFIceExploder.java b/src/main/java/twilightforest/entity/EntityTFIceExploder.java index f8a194fc6e..17c0de1aea 100644 --- a/src/main/java/twilightforest/entity/EntityTFIceExploder.java +++ b/src/main/java/twilightforest/entity/EntityTFIceExploder.java @@ -128,13 +128,8 @@ protected void onDeathUpdate() { int i; boolean flag = this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"); - this.worldObj.createExplosion( - this, - this.posX, - this.posY, - this.posZ, - (float) EntityTFIceExploder.EXPLOSION_RADIUS, - flag); + this.worldObj + .createExplosion(this, this.posX, this.posY, this.posZ, EntityTFIceExploder.EXPLOSION_RADIUS, flag); if (flag) { this.detonate(); diff --git a/src/main/java/twilightforest/entity/EntityTFKingSpider.java b/src/main/java/twilightforest/entity/EntityTFKingSpider.java index 0a5afb1f06..42af441bed 100644 --- a/src/main/java/twilightforest/entity/EntityTFKingSpider.java +++ b/src/main/java/twilightforest/entity/EntityTFKingSpider.java @@ -97,7 +97,7 @@ public IEntityLivingData onSpawnWithEgg(IEntityLivingData par1EntityLivingData) // always a spider jockey EntityTFSkeletonDruid druid = new EntityTFSkeletonDruid(this.worldObj); druid.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); - druid.onSpawnWithEgg((IEntityLivingData) null); + druid.onSpawnWithEgg(null); this.worldObj.spawnEntityInWorld(druid); druid.mountEntity(this); diff --git a/src/main/java/twilightforest/entity/EntityTFSlideBlock.java b/src/main/java/twilightforest/entity/EntityTFSlideBlock.java index f71017f5f2..8266c1f847 100644 --- a/src/main/java/twilightforest/entity/EntityTFSlideBlock.java +++ b/src/main/java/twilightforest/entity/EntityTFSlideBlock.java @@ -227,8 +227,7 @@ public void onUpdate() { this.setDead(); - if (this.worldObj - .canPlaceEntityOnSide(this.myBlock, bx, by, bz, true, 1, (Entity) null, (ItemStack) null) + if (this.worldObj.canPlaceEntityOnSide(this.myBlock, bx, by, bz, true, 1, null, null) && this.worldObj.setBlock(bx, by, bz, this.myBlock, this.myMeta, 3)) { // successfully set block } else if (this.canDropItem) { diff --git a/src/main/java/twilightforest/entity/EntityTFSnowGuardian.java b/src/main/java/twilightforest/entity/EntityTFSnowGuardian.java index 3ea57e6d18..9b816d6abc 100644 --- a/src/main/java/twilightforest/entity/EntityTFSnowGuardian.java +++ b/src/main/java/twilightforest/entity/EntityTFSnowGuardian.java @@ -90,69 +90,42 @@ protected void addRandomArmor() { } protected Item makeItemForSlot(int slot, int type) { - switch (slot) { - case 0: // sword - default: + return switch (slot) { // sword + default -> switch (type) { + default -> TFItems.ironwoodSword; + case 1 -> TFItems.steeleafSword; + case 2 -> TFItems.knightlySword; + case 3 -> TFItems.knightlySword; + }; + case 1 -> // boots switch (type) { - case 0: - default: - return TFItems.ironwoodSword; - case 1: - return TFItems.steeleafSword; - case 2: - return TFItems.knightlySword; - case 3: - return TFItems.knightlySword; - } - case 1: // boots + default -> TFItems.ironwoodBoots; + case 1 -> TFItems.steeleafBoots; + case 2 -> TFItems.knightlyBoots; + case 3 -> TFItems.arcticBoots; + }; + case 2 -> // legs switch (type) { - case 0: - default: - return TFItems.ironwoodBoots; - case 1: - return TFItems.steeleafBoots; - case 2: - return TFItems.knightlyBoots; - case 3: - return TFItems.arcticBoots; - } - case 2: // legs + default -> TFItems.ironwoodLegs; + case 1 -> TFItems.steeleafLegs; + case 2 -> TFItems.knightlyLegs; + case 3 -> TFItems.arcticLegs; + }; + case 3 -> // chest switch (type) { - case 0: - default: - return TFItems.ironwoodLegs; - case 1: - return TFItems.steeleafLegs; - case 2: - return TFItems.knightlyLegs; - case 3: - return TFItems.arcticLegs; - } - case 3: // chest + default -> TFItems.ironwoodPlate; + case 1 -> TFItems.steeleafPlate; + case 2 -> TFItems.knightlyPlate; + case 3 -> TFItems.arcticPlate; + }; + case 4 -> // helm switch (type) { - case 0: - default: - return TFItems.ironwoodPlate; - case 1: - return TFItems.steeleafPlate; - case 2: - return TFItems.knightlyPlate; - case 3: - return TFItems.arcticPlate; - } - case 4: // helm - switch (type) { - case 0: - default: - return TFItems.ironwoodHelm; - case 1: - return TFItems.steeleafHelm; - case 2: - return TFItems.knightlyHelm; - case 3: - return TFItems.arcticHelm; - } - } + default -> TFItems.ironwoodHelm; + case 1 -> TFItems.steeleafHelm; + case 2 -> TFItems.knightlyHelm; + case 3 -> TFItems.arcticHelm; + }; + }; } /** diff --git a/src/main/java/twilightforest/entity/EntityTFTowerGhast.java b/src/main/java/twilightforest/entity/EntityTFTowerGhast.java index 7d803296f4..c2b5445049 100644 --- a/src/main/java/twilightforest/entity/EntityTFTowerGhast.java +++ b/src/main/java/twilightforest/entity/EntityTFTowerGhast.java @@ -183,7 +183,7 @@ protected void updateEntityActionState() { if (this.targetedEntity == null && this.wanderFactor > 0) { if (this.courseChangeCooldown-- <= 0) { this.courseChangeCooldown += this.rand.nextInt(20) + 20; - distanceDesired = (double) MathHelper.sqrt_double(distanceDesired); + distanceDesired = MathHelper.sqrt_double(distanceDesired); if (!this.isWithinHomeDistance( MathHelper.floor_double(waypointX), @@ -237,13 +237,7 @@ protected void updateEntityActionState() { // attack if aggressive if (this.isAggressive) { if (this.attackCounter == 10) { - this.worldObj.playAuxSFXAtEntity( - (EntityPlayer) null, - 1007, - (int) this.posX, - (int) this.posY, - (int) this.posZ, - 0); + this.worldObj.playAuxSFXAtEntity(null, 1007, (int) this.posX, (int) this.posY, (int) this.posZ, 0); } ++this.attackCounter; @@ -276,7 +270,7 @@ protected void updateEntityActionState() { : (this.aggroCounter > 0 || this.isAggressive) ? 1 : 0); if (currentAggroStatus != newAggroStatus) { - this.dataWatcher.updateObject(AGGRO_STATUS, Byte.valueOf(newAggroStatus)); + this.dataWatcher.updateObject(AGGRO_STATUS, newAggroStatus); } } @@ -299,8 +293,7 @@ protected void spitFireball() { double offsetZ = this.targetedEntity.posZ - this.posZ; // fireball sound effect - this.worldObj - .playAuxSFXAtEntity((EntityPlayer) null, 1008, (int) this.posX, (int) this.posY, (int) this.posZ, 0); + this.worldObj.playAuxSFXAtEntity(null, 1008, (int) this.posX, (int) this.posY, (int) this.posZ, 0); EntityLargeFireball entityFireball = new EntityLargeFireball(this.worldObj, this, offsetX, offsetY, offsetZ); // var17.field_92012_e = this.explosionPower; diff --git a/src/main/java/twilightforest/entity/EntityTFTwilightWandBolt.java b/src/main/java/twilightforest/entity/EntityTFTwilightWandBolt.java index bfcfacf6b6..8f1abea39d 100644 --- a/src/main/java/twilightforest/entity/EntityTFTwilightWandBolt.java +++ b/src/main/java/twilightforest/entity/EntityTFTwilightWandBolt.java @@ -59,9 +59,7 @@ protected void onImpact(MovingObjectPosition par1MovingObjectPosition) { if (par1MovingObjectPosition.entityHit != null && par1MovingObjectPosition.entityHit instanceof EntityLivingBase) { if (par1MovingObjectPosition.entityHit - .attackEntityFrom(DamageSource.causeIndirectMagicDamage(this, this.getThrower()), 6)) { - ; - } + .attackEntityFrom(DamageSource.causeIndirectMagicDamage(this, this.getThrower()), 6)) {} } for (int i = 0; i < 8; ++i) { diff --git a/src/main/java/twilightforest/entity/IBreathAttacker.java b/src/main/java/twilightforest/entity/IBreathAttacker.java index 99f0a22495..52f14261d4 100644 --- a/src/main/java/twilightforest/entity/IBreathAttacker.java +++ b/src/main/java/twilightforest/entity/IBreathAttacker.java @@ -4,15 +4,15 @@ public interface IBreathAttacker { - public abstract boolean isBreathing(); + boolean isBreathing(); - public abstract void setBreathing(boolean flag); + void setBreathing(boolean flag); /** * Deal damage for our breath attack * * @param target */ - public abstract void doBreathAttack(Entity target); + void doBreathAttack(Entity target); } diff --git a/src/main/java/twilightforest/entity/ITFCharger.java b/src/main/java/twilightforest/entity/ITFCharger.java index a9208375fe..4d8a1b2082 100644 --- a/src/main/java/twilightforest/entity/ITFCharger.java +++ b/src/main/java/twilightforest/entity/ITFCharger.java @@ -2,8 +2,8 @@ public interface ITFCharger { - public boolean isCharging(); + boolean isCharging(); - public void setCharging(boolean flag); + void setCharging(boolean flag); } diff --git a/src/main/java/twilightforest/entity/TFCreatures.java b/src/main/java/twilightforest/entity/TFCreatures.java index 162c285cd1..23cfa3259a 100644 --- a/src/main/java/twilightforest/entity/TFCreatures.java +++ b/src/main/java/twilightforest/entity/TFCreatures.java @@ -16,7 +16,7 @@ public class TFCreatures { /** This is a HashMap of the Creative Entity Eggs/Spawners. */ - public static HashMap entityEggs = new LinkedHashMap(); + public static HashMap entityEggs = new LinkedHashMap<>(); public static void registerTFCreature(Class entityClass, String entityName, int id, int backgroundEggColour, int foregroundEggColour) { diff --git a/src/main/java/twilightforest/entity/TFEntityEggInfo.java b/src/main/java/twilightforest/entity/TFEntityEggInfo.java index e94033d24e..d600a81171 100644 --- a/src/main/java/twilightforest/entity/TFEntityEggInfo.java +++ b/src/main/java/twilightforest/entity/TFEntityEggInfo.java @@ -38,8 +38,7 @@ public static StatBase makeEntityKillStat(TFEntityEggInfo eggInfo) { "stat.killEntity." + s, new ChatComponentTranslation( "stat.entityKill", - new Object[] { new ChatComponentTranslation("entity." + s + ".name", new Object[0]) }))) - .registerStat(); + new ChatComponentTranslation("entity." + s + ".name")))).registerStat(); } public static StatBase makeEntityKilledByStat(TFEntityEggInfo p_151176_0_) { @@ -49,7 +48,6 @@ public static StatBase makeEntityKilledByStat(TFEntityEggInfo p_151176_0_) { "stat.entityKilledBy." + s, new ChatComponentTranslation( "stat.entityKilledBy", - new Object[] { new ChatComponentTranslation("entity." + s + ".name", new Object[0]) }))) - .registerStat(); + new ChatComponentTranslation("entity." + s + ".name")))).registerStat(); } } diff --git a/src/main/java/twilightforest/entity/ai/EntityAITFBreathAttack.java b/src/main/java/twilightforest/entity/ai/EntityAITFBreathAttack.java index b09a9e1f7d..030e0266ff 100644 --- a/src/main/java/twilightforest/entity/ai/EntityAITFBreathAttack.java +++ b/src/main/java/twilightforest/entity/ai/EntityAITFBreathAttack.java @@ -114,7 +114,6 @@ public void resetTask() { /** * What, if anything, is the head currently looking at? */ - @SuppressWarnings("unchecked") private Entity getHeadLookTarget() { Entity pointedEntity = null; double range = 30.0D; @@ -132,8 +131,7 @@ private Entity getHeadLookTarget() { for (Entity possibleEntity : possibleList) { if (possibleEntity.canBeCollidedWith() && possibleEntity != this.entityHost) { float borderSize = possibleEntity.getCollisionBorderSize(); - AxisAlignedBB collisionBB = possibleEntity.boundingBox - .expand((double) borderSize, (double) borderSize, (double) borderSize); + AxisAlignedBB collisionBB = possibleEntity.boundingBox.expand(borderSize, borderSize, borderSize); MovingObjectPosition interceptPos = collisionBB.calculateIntercept(srcVec, destVec); if (collisionBB.isVecInside(srcVec)) { diff --git a/src/main/java/twilightforest/entity/ai/EntityAITFCollideAttackFixed.java b/src/main/java/twilightforest/entity/ai/EntityAITFCollideAttackFixed.java index 831ec4d290..175d85c35a 100644 --- a/src/main/java/twilightforest/entity/ai/EntityAITFCollideAttackFixed.java +++ b/src/main/java/twilightforest/entity/ai/EntityAITFCollideAttackFixed.java @@ -112,8 +112,7 @@ public void updateTask() { double distanceToAttacker = this.attacker .getDistanceSq(entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ); - double attackRange = (double) (this.attacker.width * 2.0F * this.attacker.width * 2.0F - + entitylivingbase.width); + double attackRange = this.attacker.width * 2.0F * this.attacker.width * 2.0F + entitylivingbase.width; --this.delayTicks; diff --git a/src/main/java/twilightforest/entity/ai/EntityAITFEatLoose.java b/src/main/java/twilightforest/entity/ai/EntityAITFEatLoose.java index b781659231..4c8a9d7189 100644 --- a/src/main/java/twilightforest/entity/ai/EntityAITFEatLoose.java +++ b/src/main/java/twilightforest/entity/ai/EntityAITFEatLoose.java @@ -34,7 +34,6 @@ public EntityAITFEatLoose(EntityTFQuestRam entityTFQuestRam, Item blockID) { /** * Returns whether the EntityAIBase should begin execution. */ - @SuppressWarnings("unchecked") @Override public boolean shouldExecute() { if (this.delayTemptCounter > 0) { @@ -76,9 +75,7 @@ public boolean continueExecuting() { * Execute a one shot task or start executing a continuous task */ @Override - public void startExecuting() { - ; - } + public void startExecuting() {} /** * Resets the task diff --git a/src/main/java/twilightforest/entity/ai/EntityAITFFindLoose.java b/src/main/java/twilightforest/entity/ai/EntityAITFFindLoose.java index b173a8ad05..7591be2a0e 100644 --- a/src/main/java/twilightforest/entity/ai/EntityAITFFindLoose.java +++ b/src/main/java/twilightforest/entity/ai/EntityAITFFindLoose.java @@ -31,7 +31,6 @@ public EntityAITFFindLoose(EntityTFQuestRam entityTFQuestRam, float speed, Item /** * Returns whether the EntityAIBase should begin execution. */ - @SuppressWarnings("unchecked") @Override public boolean shouldExecute() { if (this.delayTemptCounter > 0) { @@ -70,9 +69,7 @@ public boolean continueExecuting() { * Execute a one shot task or start executing a continuous task */ @Override - public void startExecuting() { - ; - } + public void startExecuting() {} /** * Resets the task diff --git a/src/main/java/twilightforest/entity/ai/EntityAITFFlockTarget.java b/src/main/java/twilightforest/entity/ai/EntityAITFFlockTarget.java index 3019cfa9dc..fab536b80e 100644 --- a/src/main/java/twilightforest/entity/ai/EntityAITFFlockTarget.java +++ b/src/main/java/twilightforest/entity/ai/EntityAITFFlockTarget.java @@ -23,13 +23,12 @@ public EntityAITFFlockTarget(EntityCreature par1EntityLiving, boolean b) { /** * Returns whether the EntityAIBase should begin execution. */ - @SuppressWarnings("unchecked") @Override public boolean shouldExecute() { - List flockList = this.flockCreature.worldObj.getEntitiesWithinAABB( + List flockList = this.flockCreature.worldObj.getEntitiesWithinAABB( this.flockCreature.getClass(), this.flockCreature.boundingBox.expand(16.0D, 4.0D, 16.0D)); - List targetList = new ArrayList(); + List targetList = new ArrayList<>(); for (EntityLivingBase flocker : flockList) { if (flocker.getAITarget() != null) { diff --git a/src/main/java/twilightforest/entity/ai/EntityAITFFlockToSameKind.java b/src/main/java/twilightforest/entity/ai/EntityAITFFlockToSameKind.java index 225c23ff94..fab7d441f2 100644 --- a/src/main/java/twilightforest/entity/ai/EntityAITFFlockToSameKind.java +++ b/src/main/java/twilightforest/entity/ai/EntityAITFFlockToSameKind.java @@ -24,14 +24,13 @@ public EntityAITFFlockToSameKind(EntityLiving par1EntityLiving, double par2) { /** * Returns whether the EntityAIBase should begin execution. */ - @SuppressWarnings("unchecked") @Override public boolean shouldExecute() { if (this.flockCreature.getRNG().nextInt(40) != 0) { return false; } - List flockList = this.flockCreature.worldObj.getEntitiesWithinAABB( + List flockList = this.flockCreature.worldObj.getEntitiesWithinAABB( this.flockCreature.getClass(), this.flockCreature.boundingBox.expand(16.0D, 4.0D, 16.0D)); diff --git a/src/main/java/twilightforest/entity/ai/EntityAITFGiantAttackOnCollide.java b/src/main/java/twilightforest/entity/ai/EntityAITFGiantAttackOnCollide.java index e6b0c81f2e..47f52b759c 100644 --- a/src/main/java/twilightforest/entity/ai/EntityAITFGiantAttackOnCollide.java +++ b/src/main/java/twilightforest/entity/ai/EntityAITFGiantAttackOnCollide.java @@ -113,7 +113,7 @@ public void updateTask() { double distanceToAttacker = this.attacker .getDistanceSq(entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ); // lower attack range - double attackRange = (double) (this.attacker.width * this.attacker.height); + double attackRange = this.attacker.width * this.attacker.height; --this.delayTicks; diff --git a/src/main/java/twilightforest/entity/ai/EntityAITFHoverBeam.java b/src/main/java/twilightforest/entity/ai/EntityAITFHoverBeam.java index f2a8ef927b..8178f9fea6 100644 --- a/src/main/java/twilightforest/entity/ai/EntityAITFHoverBeam.java +++ b/src/main/java/twilightforest/entity/ai/EntityAITFHoverBeam.java @@ -149,7 +149,7 @@ public void updateTask() { double distanceDesired = offsetX * offsetX + offsetY * offsetY + offsetZ * offsetZ; - distanceDesired = (double) MathHelper.sqrt_double(distanceDesired); + distanceDesired = MathHelper.sqrt_double(distanceDesired); if (distanceDesired > 0.5) { @@ -180,7 +180,6 @@ public void updateTask() { } // What, if anything, is the head currently looking at? - @SuppressWarnings("unchecked") private Entity getHeadLookTarget() { Entity pointedEntity = null; double range = 30.0D; @@ -198,8 +197,7 @@ private Entity getHeadLookTarget() { for (Entity possibleEntity : possibleList) { if (possibleEntity.canBeCollidedWith() && possibleEntity != this.attacker) { float borderSize = possibleEntity.getCollisionBorderSize(); - AxisAlignedBB collisionBB = possibleEntity.boundingBox - .expand((double) borderSize, (double) borderSize, (double) borderSize); + AxisAlignedBB collisionBB = possibleEntity.boundingBox.expand(borderSize, borderSize, borderSize); MovingObjectPosition interceptPos = collisionBB.calculateIntercept(srcVec, destVec); if (collisionBB.isVecInside(srcVec)) { diff --git a/src/main/java/twilightforest/entity/ai/EntityAITFHoverSummon.java b/src/main/java/twilightforest/entity/ai/EntityAITFHoverSummon.java index 3543e2d528..b552b74a0c 100644 --- a/src/main/java/twilightforest/entity/ai/EntityAITFHoverSummon.java +++ b/src/main/java/twilightforest/entity/ai/EntityAITFHoverSummon.java @@ -127,7 +127,7 @@ public void updateTask() { double distanceDesired = offsetX * offsetX + offsetY * offsetY + offsetZ * offsetZ; - distanceDesired = (double) MathHelper.sqrt_double(distanceDesired); + distanceDesired = MathHelper.sqrt_double(distanceDesired); // add velocity double velX = offsetX / distanceDesired * 0.05D; diff --git a/src/main/java/twilightforest/entity/ai/EntityAITFHoverThenDrop.java b/src/main/java/twilightforest/entity/ai/EntityAITFHoverThenDrop.java index 498668652a..1ea4f79d71 100644 --- a/src/main/java/twilightforest/entity/ai/EntityAITFHoverThenDrop.java +++ b/src/main/java/twilightforest/entity/ai/EntityAITFHoverThenDrop.java @@ -137,7 +137,7 @@ public void updateTask() { double distanceDesired = offsetX * offsetX + offsetY * offsetY + offsetZ * offsetZ; - distanceDesired = (double) MathHelper.sqrt_double(distanceDesired); + distanceDesired = MathHelper.sqrt_double(distanceDesired); // add velocity double velX = offsetX / distanceDesired * 0.05D; diff --git a/src/main/java/twilightforest/entity/ai/EntityAITFPanicOnFlockDeath.java b/src/main/java/twilightforest/entity/ai/EntityAITFPanicOnFlockDeath.java index 5a470aa6a4..0afe10045d 100644 --- a/src/main/java/twilightforest/entity/ai/EntityAITFPanicOnFlockDeath.java +++ b/src/main/java/twilightforest/entity/ai/EntityAITFPanicOnFlockDeath.java @@ -30,13 +30,12 @@ public EntityAITFPanicOnFlockDeath(EntityCreature par1EntityCreature, float par2 /** * Returns whether the EntityAIBase should begin execution. */ - @SuppressWarnings("unchecked") @Override public boolean shouldExecute() { boolean yikes = fleeTimer > 0; // check if any of us is dead within 4 squares - List flockList = this.flockCreature.worldObj.getEntitiesWithinAABB( + List flockList = this.flockCreature.worldObj.getEntitiesWithinAABB( this.flockCreature.getClass(), this.flockCreature.boundingBox.expand(4.0D, 2.0D, 4.0D)); for (EntityLiving flocker : flockList) { diff --git a/src/main/java/twilightforest/entity/ai/EntityAITFRedcapBase.java b/src/main/java/twilightforest/entity/ai/EntityAITFRedcapBase.java index 191da33995..0a5681c0eb 100644 --- a/src/main/java/twilightforest/entity/ai/EntityAITFRedcapBase.java +++ b/src/main/java/twilightforest/entity/ai/EntityAITFRedcapBase.java @@ -2,7 +2,6 @@ import java.util.List; -import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.item.EntityTNTPrimed; @@ -65,11 +64,10 @@ public ChunkCoordinates findBlockTNTNearby(int range) { * @param range * @return */ - @SuppressWarnings("unchecked") public boolean isLitTNTNearby(int range) { AxisAlignedBB expandedBox = entityObj.boundingBox.expand(range, range, range); - List nearbyTNT = entityObj.worldObj.getEntitiesWithinAABB(EntityTNTPrimed.class, expandedBox); + List nearbyTNT = entityObj.worldObj.getEntitiesWithinAABB(EntityTNTPrimed.class, expandedBox); return nearbyTNT.size() > 0; } diff --git a/src/main/java/twilightforest/entity/ai/EntityAITFThrowRider.java b/src/main/java/twilightforest/entity/ai/EntityAITFThrowRider.java index 43f7966cf8..d36d7dad08 100644 --- a/src/main/java/twilightforest/entity/ai/EntityAITFThrowRider.java +++ b/src/main/java/twilightforest/entity/ai/EntityAITFThrowRider.java @@ -52,8 +52,7 @@ public void startExecuting() { rider.addVelocity(throwVec.xCoord, throwVec.yCoord, throwVec.zCoord); // if we're throwing a player (probably!), send a packet with the velocity - if (rider instanceof EntityPlayerMP) { - EntityPlayerMP player = (EntityPlayerMP) rider; + if (rider instanceof EntityPlayerMP player) { FMLProxyPacket message = TFGenericPacketHandler .makeThrowPlayerPacket((float) throwVec.xCoord, (float) throwVec.yCoord, (float) throwVec.zCoord); diff --git a/src/main/java/twilightforest/entity/ai/EntityTFRavenLookHelper.java b/src/main/java/twilightforest/entity/ai/EntityTFRavenLookHelper.java index fad094496f..acec3a6531 100644 --- a/src/main/java/twilightforest/entity/ai/EntityTFRavenLookHelper.java +++ b/src/main/java/twilightforest/entity/ai/EntityTFRavenLookHelper.java @@ -27,7 +27,7 @@ public void setLookPositionWithEntity(Entity par1Entity, float par2, float par3) this.posX = par1Entity.posX; if (par1Entity instanceof EntityLiving) { - this.posY = par1Entity.posY + (double) ((EntityLiving) par1Entity).getEyeHeight(); + this.posY = par1Entity.posY + (double) par1Entity.getEyeHeight(); } else { this.posY = (par1Entity.boundingBox.minY + par1Entity.boundingBox.maxY) / 2.0D; } @@ -75,9 +75,7 @@ public void onUpdateLook() { float var11; - for (var11 = this.entity.rotationYawHead - this.entity.renderYawOffset; var11 < -180.0F; var11 += 360.0F) { - ; - } + for (var11 = this.entity.rotationYawHead - this.entity.renderYawOffset; var11 < -180.0F; var11 += 360.0F) {} while (var11 >= 180.0F) { var11 -= 360.0F; @@ -97,9 +95,7 @@ public void onUpdateLook() { private float updateRotation(float par1, float par2, float par3) { float var4; - for (var4 = par2 - par1; var4 < -180.0F; var4 += 360.0F) { - ; - } + for (var4 = par2 - par1; var4 < -180.0F; var4 += 360.0F) {} while (var4 >= 180.0F) { var4 -= 360.0F; diff --git a/src/main/java/twilightforest/entity/boss/EntityTFFallingIce.java b/src/main/java/twilightforest/entity/boss/EntityTFFallingIce.java index 65039140ea..7c922fb5b8 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFFallingIce.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFFallingIce.java @@ -64,7 +64,6 @@ public boolean canBeCollidedWith() { /** * Called to update the entity's position/logic. */ - @SuppressWarnings("unchecked") public void onUpdate() { this.prevPosX = this.posX; this.prevPosY = this.posY; @@ -100,12 +99,11 @@ public void onUpdate() { // kill other nearby blocks if they are not as old as this one if (!this.worldObj.isRemote) { - ArrayList nearby = new ArrayList( + ArrayList nearby = new ArrayList<>( this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox)); for (Entity entity : nearby) { - if (entity instanceof EntityTFFallingIce) { - EntityTFFallingIce otherIce = (EntityTFFallingIce) entity; + if (entity instanceof EntityTFFallingIce otherIce) { if (otherIce.getFallTime() < this.fallTime) { otherIce.setDead(); @@ -132,12 +130,11 @@ public void makeTrail() { /** * Called when the mob is falling. Calculates and applies fall damage. */ - @SuppressWarnings({ "unchecked" }) protected void fall(float par1) { int distance = MathHelper.ceiling_float_int(par1 - 1.0F); if (distance > 0) { - ArrayList nearby = new ArrayList( + ArrayList nearby = new ArrayList<>( this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(2, 0, 2))); DamageSource damagesource = DamageSource.fallingBlock; for (Entity entity : nearby) { diff --git a/src/main/java/twilightforest/entity/boss/EntityTFHydra.java b/src/main/java/twilightforest/entity/boss/EntityTFHydra.java index 5674dc0a07..cd86623c9a 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFHydra.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFHydra.java @@ -46,7 +46,7 @@ public class EntityTFHydra extends EntityLiving implements IBossDisplayData, IEn private static final int DATA_SPAWNHEADS = 17; private static final int DATA_BOSSHEALTH = 18; - public Entity partArray[]; + public Entity[] partArray; public EntityDragonPart body; public HydraHeadContainer[] hc; @@ -75,7 +75,7 @@ public EntityTFHydra(World world) { } // re-do partArray - ArrayList partList = new ArrayList(); + ArrayList partList = new ArrayList<>(); Collections.addAll(partList, partArray); for (int i = 0; i < numHeads; i++) { @@ -110,7 +110,6 @@ protected void applyEntityAttributes() { this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.28D); // movement speed } - @SuppressWarnings("unchecked") @Override public void onLivingUpdate() { if (hc[0].headEntity == null || hc[1].headEntity == null || hc[2].headEntity == null) { @@ -293,7 +292,7 @@ public void onLivingUpdate() { protected void entityInit() { super.entityInit(); dataWatcher.addObject(DATA_SPAWNHEADS, (byte) 0); - this.dataWatcher.addObject(DATA_BOSSHEALTH, new Integer(MAX_HEALTH)); + this.dataWatcher.addObject(DATA_BOSSHEALTH, MAX_HEALTH); } public boolean shouldSpawnHeads() { @@ -630,12 +629,11 @@ private double distanceSqXZ(Entity headEntity, Entity target) { * * Right now just finds the closest living entity that is not exluded by our criteria */ - @SuppressWarnings("unchecked") public EntityLivingBase findSecondaryTarget(double range) { double closestRange = -1.0D; EntityLivingBase closestEntity = null; - List nearbyEntities = this.worldObj.getEntitiesWithinAABB( + List nearbyEntities = this.worldObj.getEntitiesWithinAABB( EntityLivingBase.class, AxisAlignedBB .getBoundingBox(this.posX, this.posY, this.posZ, this.posX + 1, this.posY + 1, this.posZ + 1) diff --git a/src/main/java/twilightforest/entity/boss/EntityTFHydraMortar.java b/src/main/java/twilightforest/entity/boss/EntityTFHydraMortar.java index b5f08b911f..b27216a85f 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFHydraMortar.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFHydraMortar.java @@ -98,7 +98,6 @@ public float func_145772_a(Explosion par1Explosion, World par2World, int par3, i return var6; } - @SuppressWarnings("unchecked") protected void detonate() { // this.worldObj.playAuxSFX(2004, (int)Math.round(this.posX), (int)Math.round(this.posY), // (int)Math.round(this.posZ), 32764); @@ -111,7 +110,7 @@ protected void detonate() { if (!worldObj.isRemote) { // damage nearby things - List nearbyList = new ArrayList( + List nearbyList = new ArrayList<>( this.worldObj .getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(1.0D, 1.0D, 1.0D))); diff --git a/src/main/java/twilightforest/entity/boss/EntityTFIceBomb.java b/src/main/java/twilightforest/entity/boss/EntityTFIceBomb.java index a976a8ddef..25c3337cee 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFIceBomb.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFIceBomb.java @@ -146,9 +146,8 @@ private void makeIceZone() { } } - @SuppressWarnings("unchecked") private void hitNearbyEntities() { - ArrayList nearby = new ArrayList( + ArrayList nearby = new ArrayList<>( this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(3, 2, 3))); for (Entity entity : nearby) { diff --git a/src/main/java/twilightforest/entity/boss/EntityTFKnightPhantom.java b/src/main/java/twilightforest/entity/boss/EntityTFKnightPhantom.java index 2387cdb2fd..d71e56d13f 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFKnightPhantom.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFKnightPhantom.java @@ -61,7 +61,7 @@ public enum Formation { WAITING_FOR_LEADER, ATTACK_PLAYER_START, ATTACK_PLAYER_ATTACK - }; + } public EntityTFKnightPhantom(World par1World) { super(par1World); @@ -274,7 +274,7 @@ protected void updateEntityActionState() { double factor = moveX * moveX + moveY * moveY + moveZ * moveZ; - factor = (double) MathHelper.sqrt_double(factor); + factor = MathHelper.sqrt_double(factor); double speed = 0.1D;// this.isChargingAtPlayer() ? 0.1D : 0.05D; @@ -338,9 +338,9 @@ public boolean attackEntityAsMob(Entity entity) { if (flag) { if (i > 0) { entity.addVelocity( - (double) (-MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F) * (float) i * 0.5F), + -MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F) * (float) i * 0.5F, 0.1D, - (double) (MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F) * (float) i * 0.5F)); + MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F) * (float) i * 0.5F); this.motionX *= 0.6D; this.motionZ *= 0.6D; } @@ -451,7 +451,7 @@ public void knockBack(Entity entity, float damage, double par3, double par5) { this.motionY /= 2.0D; this.motionZ /= 2.0D; this.motionX -= par3 / (double) f * (double) distance; - this.motionY += (double) distance; + this.motionY += distance; this.motionZ -= par5 / (double) f * (double) distance; if (this.motionY > 0.4000000059604645D) { @@ -475,15 +475,9 @@ public void switchToNextFormation() { } else { // random weapon switch! switch (rand.nextInt(3)) { - case 0: - this.setCurrentItemOrArmor(0, new ItemStack(TFItems.knightlySword)); - break; - case 1: - this.setCurrentItemOrArmor(0, new ItemStack(TFItems.knightlyAxe)); - break; - case 2: - this.setCurrentItemOrArmor(0, new ItemStack(TFItems.knightlyPick)); - break; + case 0 -> this.setCurrentItemOrArmor(0, new ItemStack(TFItems.knightlySword)); + case 1 -> this.setCurrentItemOrArmor(0, new ItemStack(TFItems.knightlyAxe)); + case 2 -> this.setCurrentItemOrArmor(0, new ItemStack(TFItems.knightlyPick)); } this.switchToFormation(Formation.ATTACK_PLAYER_START); @@ -516,7 +510,6 @@ public void switchToNextFormation() { } } - @SuppressWarnings("unchecked") private List getNearbyKnights() { List nearbyKnights = worldObj.getEntitiesWithinAABB( EntityTFKnightPhantom.class, @@ -529,31 +522,18 @@ private List getNearbyKnights() { // Pick a random formation. Called by the leader when his current formation duration ends protected void pickRandomFormation() { switch (rand.nextInt(8)) { - case 0: - currentFormation = Formation.SMALL_CLOCKWISE; - break; - case 1: - currentFormation = Formation.SMALL_ANTICLOCKWISE; - // currentFormation = Formation.LARGE_ANTICLOCKWISE; - break; - case 2: - currentFormation = Formation.SMALL_ANTICLOCKWISE; - break; - case 3: - currentFormation = Formation.CHARGE_PLUSX; - break; - case 4: - currentFormation = Formation.CHARGE_MINUSX; - break; - case 5: - currentFormation = Formation.CHARGE_PLUSZ; - break; - case 6: - currentFormation = Formation.CHARGE_MINUSZ; - break; - case 7: - currentFormation = Formation.SMALL_CLOCKWISE; - // currentFormation = Formation.LARGE_CLOCKWISE; + case 0 -> currentFormation = Formation.SMALL_CLOCKWISE; + case 1 -> currentFormation = Formation.SMALL_ANTICLOCKWISE; + + // currentFormation = Formation.LARGE_ANTICLOCKWISE; + case 2 -> currentFormation = Formation.SMALL_ANTICLOCKWISE; + case 3 -> currentFormation = Formation.CHARGE_PLUSX; + case 4 -> currentFormation = Formation.CHARGE_MINUSX; + case 5 -> currentFormation = Formation.CHARGE_PLUSZ; + case 6 -> currentFormation = Formation.CHARGE_MINUSZ; + case 7 -> currentFormation = Formation.SMALL_CLOCKWISE; + + // currentFormation = Formation.LARGE_CLOCKWISE; } this.switchToFormation(currentFormation); } @@ -673,29 +653,16 @@ public void setTicksProgress(int ticksProgress) { } public int getMaxTicksForFormation() { - switch (currentFormation) { - default: - case HOVER: - return 90; - case LARGE_CLOCKWISE: - return 180; - case SMALL_CLOCKWISE: - return 90; - case LARGE_ANTICLOCKWISE: - return 180; - case SMALL_ANTICLOCKWISE: - return 90; - case CHARGE_PLUSX: - case CHARGE_MINUSX: - case CHARGE_PLUSZ: - case CHARGE_MINUSZ: - return 180; - case ATTACK_PLAYER_START: - case ATTACK_PLAYER_ATTACK: - return 50; - case WAITING_FOR_LEADER: - return 10; - } + return switch (currentFormation) { + default -> 90; + case LARGE_CLOCKWISE -> 180; + case SMALL_CLOCKWISE -> 90; + case LARGE_ANTICLOCKWISE -> 180; + case SMALL_ANTICLOCKWISE -> 90; + case CHARGE_PLUSX, CHARGE_MINUSX, CHARGE_PLUSZ, CHARGE_MINUSZ -> 180; + case ATTACK_PLAYER_START, ATTACK_PLAYER_ATTACK -> 50; + case WAITING_FOR_LEADER -> 10; + }; } private Vec3 getDestination() { @@ -704,33 +671,20 @@ private Vec3 getDestination() { // hmmm // } - switch (currentFormation) { - case LARGE_CLOCKWISE: - return getCirclePosition(CIRCLE_LARGE_RADIUS, true); - case SMALL_CLOCKWISE: - return getCirclePosition(CIRCLE_SMALL_RADIUS, true); - case LARGE_ANTICLOCKWISE: - return getCirclePosition(CIRCLE_LARGE_RADIUS, false); - case SMALL_ANTICLOCKWISE: - return getCirclePosition(CIRCLE_SMALL_RADIUS, false); - case CHARGE_PLUSX: - return getMoveAcrossPosition(true, true); - case CHARGE_MINUSX: - return getMoveAcrossPosition(false, true); - case CHARGE_PLUSZ: - return getMoveAcrossPosition(true, false); - case ATTACK_PLAYER_START: - case HOVER: - return getHoverPosition(CIRCLE_LARGE_RADIUS); - case CHARGE_MINUSZ: - return getMoveAcrossPosition(false, false); - case WAITING_FOR_LEADER: - return getLoiterPosition(); - case ATTACK_PLAYER_ATTACK: - return getAttackPlayerPosition(); - default: - return getLoiterPosition(); - } + return switch (currentFormation) { + case LARGE_CLOCKWISE -> getCirclePosition(CIRCLE_LARGE_RADIUS, true); + case SMALL_CLOCKWISE -> getCirclePosition(CIRCLE_SMALL_RADIUS, true); + case LARGE_ANTICLOCKWISE -> getCirclePosition(CIRCLE_LARGE_RADIUS, false); + case SMALL_ANTICLOCKWISE -> getCirclePosition(CIRCLE_SMALL_RADIUS, false); + case CHARGE_PLUSX -> getMoveAcrossPosition(true, true); + case CHARGE_MINUSX -> getMoveAcrossPosition(false, true); + case CHARGE_PLUSZ -> getMoveAcrossPosition(true, false); + case ATTACK_PLAYER_START, HOVER -> getHoverPosition(CIRCLE_LARGE_RADIUS); + case CHARGE_MINUSZ -> getMoveAcrossPosition(false, false); + case WAITING_FOR_LEADER -> getLoiterPosition(); + case ATTACK_PLAYER_ATTACK -> getAttackPlayerPosition(); + default -> getLoiterPosition(); + }; } private Vec3 getMoveAcrossPosition(boolean plus, boolean alongX) { @@ -831,14 +785,9 @@ public void setNumber(int number) { // set weapon per number switch (number % 3) { - case 0: - this.setCurrentItemOrArmor(0, new ItemStack(TFItems.knightlySword)); - break; - case 1: - this.setCurrentItemOrArmor(0, new ItemStack(TFItems.knightlyAxe)); - break; - case 2: - this.setCurrentItemOrArmor(0, new ItemStack(TFItems.knightlyPick)); + case 0 -> this.setCurrentItemOrArmor(0, new ItemStack(TFItems.knightlySword)); + case 1 -> this.setCurrentItemOrArmor(0, new ItemStack(TFItems.knightlyAxe)); + case 2 -> this.setCurrentItemOrArmor(0, new ItemStack(TFItems.knightlyPick)); } } @@ -846,7 +795,7 @@ public void setNumber(int number) { public void writeEntityToNBT(NBTTagCompound nbttagcompound) { super.writeEntityToNBT(nbttagcompound); ChunkCoordinates home = this.getHomePosition(); - nbttagcompound.setTag("Home", newDoubleNBTList(new double[] { home.posX, home.posY, home.posZ })); + nbttagcompound.setTag("Home", newDoubleNBTList(home.posX, home.posY, home.posZ)); nbttagcompound.setBoolean("HasHome", this.hasHome()); nbttagcompound.setInteger("MyNumber", this.getNumber()); nbttagcompound.setInteger("Formation", this.getFormationAsNumber()); diff --git a/src/main/java/twilightforest/entity/boss/EntityTFLich.java b/src/main/java/twilightforest/entity/boss/EntityTFLich.java index 7abd49fc10..c93e8098cd 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFLich.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFLich.java @@ -45,7 +45,7 @@ public class EntityTFLich extends EntityMob implements IBossDisplayData { EntityTFLich masterLich; - private static final ItemStack heldItems[] = { new ItemStack(TFItems.scepterTwilight, 1), + private static final ItemStack[] heldItems = { new ItemStack(TFItems.scepterTwilight, 1), new ItemStack(TFItems.scepterZombie, 1), new ItemStack(Items.golden_sword, 1) }; public static final int MAX_SHADOW_CLONES = 2; public static final int INITIAL_SHIELD_STRENGTH = 5; @@ -93,7 +93,7 @@ protected void entityInit() { this.dataWatcher.addObject(DATA_ISCLONE, (byte) 0); this.dataWatcher.addObject(DATA_SHIELDSTRENGTH, (byte) 0); this.dataWatcher.addObject(DATA_MINIONSLEFT, (byte) 0); - this.dataWatcher.addObject(DATA_BOSSHEALTH, new Integer(EntityTFLich.MAX_HEALTH)); + this.dataWatcher.addObject(DATA_BOSSHEALTH, EntityTFLich.MAX_HEALTH); this.dataWatcher.addObject(DATA_ATTACKTYPE, (byte) 0); } @@ -141,36 +141,22 @@ protected void dropFewItems(boolean par1, int par2) { private void dropScepter() { int scepterType = rand.nextInt(3); switch (scepterType) { - case 0: - this.entityDropItem(new ItemStack(TFItems.scepterZombie), 0); - break; - case 1: - this.entityDropItem(new ItemStack(TFItems.scepterLifeDrain), 0); - break; - default: - this.entityDropItem(new ItemStack(TFItems.scepterTwilight), 0); + case 0 -> this.entityDropItem(new ItemStack(TFItems.scepterZombie), 0); + case 1 -> this.entityDropItem(new ItemStack(TFItems.scepterLifeDrain), 0); + default -> this.entityDropItem(new ItemStack(TFItems.scepterTwilight), 0); } } private void dropGoldThing() { ItemStack goldThing; int thingType = rand.nextInt(5); - switch (thingType) { - case 0: - goldThing = new ItemStack(Items.golden_sword); - break; - case 1: - goldThing = new ItemStack(Items.golden_helmet); - break; - case 2: - goldThing = new ItemStack(Items.golden_chestplate); - break; - case 3: - goldThing = new ItemStack(Items.golden_leggings); - break; - default: - goldThing = new ItemStack(Items.golden_boots); - } + goldThing = switch (thingType) { + case 0 -> new ItemStack(Items.golden_sword); + case 1 -> new ItemStack(Items.golden_helmet); + case 2 -> new ItemStack(Items.golden_chestplate); + case 3 -> new ItemStack(Items.golden_leggings); + default -> new ItemStack(Items.golden_boots); + }; // enchant! EnchantmentHelper.addRandomEnchantment(rand, goldThing, 10 + rand.nextInt(30)); this.entityDropItem(goldThing, 0); @@ -528,7 +514,6 @@ protected void launchBombAt(Entity targetedEntity) { /** * Check the surrounding area for weaker monsters, and if we find any, magically destroy them. */ - @SuppressWarnings("unchecked") protected void popNearbyMob() { List nearbyMobs = worldObj.getEntitiesWithinAABBExcludingEntity( this, @@ -536,8 +521,7 @@ protected void popNearbyMob() { .expand(32.0D, 16.0D, 32.0D)); for (Entity entity : nearbyMobs) { - if (entity instanceof EntityLiving && canPop(entity) && canEntityBeSeen(entity)) { - EntityLiving mob = (EntityLiving) entity; + if (entity instanceof EntityLiving mob && canPop(entity) && canEntityBeSeen(entity)) { if (!worldObj.isRemote) { mob.setDead(); @@ -593,7 +577,6 @@ protected void checkAndSpawnClones(Entity targetedEntity) { } } - @SuppressWarnings("unchecked") protected int countMyClones() { // check if there are enough clones. we check a 32x16x32 area List nearbyLiches = worldObj.getEntitiesWithinAABB( @@ -636,10 +619,9 @@ protected void spawnShadowClone(Entity targetedEntity) { /** * Despawn neaby clones */ - @SuppressWarnings("unchecked") protected void despawnClones() { List nearbyLiches = worldObj.getEntitiesWithinAABB( - this.getClass(), + EntityTFLich.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX + 1, posY + 1, posZ + 1) .expand(32.0D, 16.0D, 32.0D)); @@ -663,7 +645,6 @@ protected void checkAndSpawnMinions(Entity targetedEntity) { // if there's no minions left to summon, we should move into phase 3 naturally } - @SuppressWarnings("unchecked") protected int countMyMinions() { // check if there are enough clones. we check a 32x16x32 area List nearbyMinons = worldObj.getEntitiesWithinAABB( @@ -737,7 +718,6 @@ protected void checkForMaster() { /** * Find a new master for this clone */ - @SuppressWarnings("unchecked") private void findNewMaster() { List nearbyLiches = worldObj.getEntitiesWithinAABB( EntityTFLich.class, diff --git a/src/main/java/twilightforest/entity/boss/EntityTFLichBolt.java b/src/main/java/twilightforest/entity/boss/EntityTFLichBolt.java index 2cce573201..bc2614f030 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFLichBolt.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFLichBolt.java @@ -126,17 +126,14 @@ protected void onImpact(MovingObjectPosition par1MovingObjectPosition) { // only damage living things if (par1MovingObjectPosition.entityHit != null && par1MovingObjectPosition.entityHit instanceof EntityLivingBase) { - if (par1MovingObjectPosition.entityHit instanceof EntityTFLich) { - EntityTFLich lich = (EntityTFLich) par1MovingObjectPosition.entityHit; + if (par1MovingObjectPosition.entityHit instanceof EntityTFLich lich) { if (lich.isShadowClone()) { passThrough = true; } } // if we're not set to pass, damage what we hit if (!passThrough && par1MovingObjectPosition.entityHit - .attackEntityFrom(DamageSource.causeIndirectMagicDamage(this, this.getThrower()), 6)) { - ; - } + .attackEntityFrom(DamageSource.causeIndirectMagicDamage(this, this.getThrower()), 6)) {} } // if we don't pass through, then stop and die if (!passThrough) { diff --git a/src/main/java/twilightforest/entity/boss/EntityTFLichMinion.java b/src/main/java/twilightforest/entity/boss/EntityTFLichMinion.java index 51bb11779a..c37842be21 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFLichMinion.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFLichMinion.java @@ -74,7 +74,6 @@ public void onLivingUpdate() { super.onLivingUpdate(); } - @SuppressWarnings("unchecked") private void findNewMaster() { List nearbyLiches = worldObj.getEntitiesWithinAABB( EntityTFLich.class, diff --git a/src/main/java/twilightforest/entity/boss/EntityTFNaga.java b/src/main/java/twilightforest/entity/boss/EntityTFNaga.java index 917265feaa..3e9b90979f 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFNaga.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFNaga.java @@ -276,9 +276,9 @@ public void onUpdate() { // move bodies moveSegments(); - for (int i = 0; i < body.length; i++) { - if (!body[i].addedToChunk && !worldObj.isRemote) { - worldObj.spawnEntityInWorld(body[i]); + for (EntityTFNagaSegment entityTFNagaSegment : body) { + if (!entityTFNagaSegment.addedToChunk && !worldObj.isRemote) { + worldObj.spawnEntityInWorld(entityTFNagaSegment); } } } @@ -1010,7 +1010,7 @@ protected void moveSegments() { body[i].motionY = f * diff.yCoord; body[i].motionZ = f * diff.zCoord; - double distance = (double) MathHelper.sqrt_double(diff.xCoord * diff.xCoord + diff.zCoord * diff.zCoord); + double distance = MathHelper.sqrt_double(diff.xCoord * diff.xCoord + diff.zCoord * diff.zCoord); if (i == 0) { diff.yCoord -= 0.15D; @@ -1038,7 +1038,7 @@ protected void moveSegments() { @Override public void writeEntityToNBT(NBTTagCompound nbttagcompound) { ChunkCoordinates home = this.getHomePosition(); - nbttagcompound.setTag("Home", newDoubleNBTList(new double[] { home.posX, home.posY, home.posZ })); + nbttagcompound.setTag("Home", newDoubleNBTList(home.posX, home.posY, home.posZ)); nbttagcompound.setBoolean("HasHome", this.hasHome()); super.writeEntityToNBT(nbttagcompound); } diff --git a/src/main/java/twilightforest/entity/boss/EntityTFNagaSegment.java b/src/main/java/twilightforest/entity/boss/EntityTFNagaSegment.java index a85e598ada..459c57a7a2 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFNagaSegment.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFNagaSegment.java @@ -147,7 +147,6 @@ public void onUpdate() { } - @SuppressWarnings("unchecked") protected void collideWithOthers() { List list = this.worldObj.getEntitiesWithinAABBExcludingEntity( this, @@ -224,9 +223,7 @@ protected void writeEntityToNBT(NBTTagCompound nbttagcompound) {} /** * Plays step sound at given x, y, z for the entity */ - protected void func_145780_a(int par1, int par2, int par3, Block par4) { - ; - } + protected void func_145780_a(int par1, int par2, int par3, Block par4) {} @SideOnly(Side.CLIENT) diff --git a/src/main/java/twilightforest/entity/boss/EntityTFSnowQueen.java b/src/main/java/twilightforest/entity/boss/EntityTFSnowQueen.java index 8cac78a411..87a8f48bd6 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFSnowQueen.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFSnowQueen.java @@ -53,7 +53,7 @@ public enum Phase { SUMMON, DROP, BEAM - }; + } public Entity[] iceArray; @@ -182,7 +182,7 @@ public void onLivingUpdate() { // during drop phase, all the ice blocks should make particles if (this.getCurrentPhase() == Phase.DROP) { - for (int i = 0; i < this.iceArray.length; i++) { + for (Entity entity : this.iceArray) { float px = (this.rand.nextFloat() - this.rand.nextFloat()) * 0.5F; float py = (this.rand.nextFloat() - this.rand.nextFloat()) * 0.5F; float pz = (this.rand.nextFloat() - this.rand.nextFloat()) * 0.5F; @@ -190,9 +190,9 @@ public void onLivingUpdate() { TwilightForestMod.proxy.spawnParticle( this.worldObj, "snowwarning", - this.iceArray[i].lastTickPosX + px, - this.iceArray[i].lastTickPosY + py, - this.iceArray[i].lastTickPosZ + pz, + entity.lastTickPosX + px, + entity.lastTickPosY + py, + entity.lastTickPosZ + pz, 0, 0, 0); @@ -351,7 +351,6 @@ public void onDeath(DamageSource par1DamageSource) { } } - @SuppressWarnings("unchecked") private void applyShieldCollisions(Entity collider) { List list = this.worldObj .getEntitiesWithinAABBExcludingEntity(collider, collider.boundingBox.expand(-0.2F, -0.2F, -0.2F)); @@ -634,7 +633,6 @@ protected boolean canEntitySee(Entity entity, double dx, double dy, double dz) { } - @SuppressWarnings("unchecked") public int countMyMinions() { // check if there are enough minions. we check a 32x16x32 area List nearbyMinons = worldObj.getEntitiesWithinAABB( diff --git a/src/main/java/twilightforest/entity/boss/EntityTFUrGhast.java b/src/main/java/twilightforest/entity/boss/EntityTFUrGhast.java index 0e55057b34..445f1c1bf1 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFUrGhast.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFUrGhast.java @@ -68,8 +68,8 @@ public EntityTFUrGhast(World par1World) { this.noClip = true; - this.trapLocations = new ArrayList(); - this.travelCoords = new ArrayList(); + this.trapLocations = new ArrayList<>(); + this.travelCoords = new ArrayList<>(); this.setInTantrum(false); @@ -224,7 +224,7 @@ protected void startTantrum() { */ protected void spawnGhastsAtTraps() { // spawn ghasts around two of the traps - ArrayList ghastSpawns = new ArrayList(this.trapLocations); + ArrayList ghastSpawns = new ArrayList<>(this.trapLocations); int numSpawns = Math.min(2, ghastSpawns.size()); @@ -290,7 +290,6 @@ private void spawnMinionGhastsAt(int x, int y, int z) { /** * Altered Ghast AI */ - @SuppressWarnings("unchecked") protected void updateEntityActionState() { if (!this.worldObj.isRemote && this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL) { this.setDead(); @@ -375,7 +374,7 @@ protected void updateEntityActionState() { // move? if (this.courseChangeCooldown-- <= 0) { this.courseChangeCooldown += this.rand.nextInt(5) + 0; - distanceToWaypoint = (double) MathHelper.sqrt_double(distanceToWaypoint); + distanceToWaypoint = MathHelper.sqrt_double(distanceToWaypoint); double speed = 0.05D; this.motionX += offsetX / distanceToWaypoint * speed; @@ -428,11 +427,10 @@ protected void updateEntityActionState() { : (this.aggroCounter > 0 || this.isAggressive) ? 1 : 0); if (currentAggroStatus != newAggroStatus) { - this.dataWatcher.updateObject(16, Byte.valueOf(newAggroStatus)); + this.dataWatcher.updateObject(16, newAggroStatus); } } - @SuppressWarnings("unchecked") private void doTantrumDamageEffects() { // harm player below AxisAlignedBB below = this.boundingBox.getOffsetBoundingBox(0, -16, 0).expand(0, 16, 0); @@ -553,7 +551,6 @@ private void changeCourse() { /** * Check if there are at least 4 ghasts near at least 2 traps. Return false if not. */ - @SuppressWarnings("unchecked") private boolean checkGhastsAtTraps() { int trapsWithEnoughGhasts = 0; @@ -588,9 +585,9 @@ private void makeTravelPath() { if (!this.noTrapMode) { // make a copy of the trap locations list - potentialPoints = new ArrayList(this.trapLocations); + potentialPoints = new ArrayList<>(this.trapLocations); } else { - potentialPoints = new ArrayList(); + potentialPoints = new ArrayList<>(); potentialPoints.add(new ChunkCoordinates(px + 20, py - HOVER_ALTITUDE, pz)); potentialPoints.add(new ChunkCoordinates(px, py - HOVER_ALTITUDE, pz - 20)); potentialPoints.add(new ChunkCoordinates(px - 20, py - HOVER_ALTITUDE, pz)); @@ -626,8 +623,7 @@ protected void spitFireball() { double offsetZ = this.targetedEntity.posZ - this.posZ; // fireball sound effect - this.worldObj - .playAuxSFXAtEntity((EntityPlayer) null, 1008, (int) this.posX, (int) this.posY, (int) this.posZ, 0); + this.worldObj.playAuxSFXAtEntity(null, 1008, (int) this.posX, (int) this.posY, (int) this.posZ, 0); EntityTFUrGhastFireball entityFireball = new EntityTFUrGhastFireball( this.worldObj, diff --git a/src/main/java/twilightforest/entity/boss/EntityTFUrGhastFireball.java b/src/main/java/twilightforest/entity/boss/EntityTFUrGhastFireball.java index ac31017dba..9715b1dcdd 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFUrGhastFireball.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFUrGhastFireball.java @@ -1,6 +1,5 @@ package twilightforest.entity.boss; -import net.minecraft.entity.Entity; import net.minecraft.entity.projectile.EntityFireball; import net.minecraft.entity.projectile.EntityLargeFireball; import net.minecraft.util.DamageSource; @@ -24,7 +23,7 @@ protected void onImpact(MovingObjectPosition par1MovingObjectPosition) { } this.worldObj.newExplosion( - (Entity) null, + null, this.posX, this.posY, this.posZ, diff --git a/src/main/java/twilightforest/entity/boss/EntityTFYetiAlpha.java b/src/main/java/twilightforest/entity/boss/EntityTFYetiAlpha.java index cfa641659d..8d4b2209cf 100644 --- a/src/main/java/twilightforest/entity/boss/EntityTFYetiAlpha.java +++ b/src/main/java/twilightforest/entity/boss/EntityTFYetiAlpha.java @@ -476,9 +476,8 @@ protected void fall(float par1) { } } - @SuppressWarnings("unchecked") private void hitNearbyEntities() { - ArrayList nearby = new ArrayList( + ArrayList nearby = new ArrayList<>( this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(5, 0, 5))); for (Entity entity : nearby) { @@ -526,7 +525,7 @@ public void onDeath(DamageSource par1DamageSource) { @Override public void writeEntityToNBT(NBTTagCompound nbttagcompound) { ChunkCoordinates home = this.getHomePosition(); - nbttagcompound.setTag("Home", newDoubleNBTList(new double[] { home.posX, home.posY, home.posZ })); + nbttagcompound.setTag("Home", newDoubleNBTList(home.posX, home.posY, home.posZ)); nbttagcompound.setBoolean("HasHome", this.hasHome()); super.writeEntityToNBT(nbttagcompound); } diff --git a/src/main/java/twilightforest/entity/boss/HydraHeadContainer.java b/src/main/java/twilightforest/entity/boss/HydraHeadContainer.java index b6571e5858..16cdee5910 100644 --- a/src/main/java/twilightforest/entity/boss/HydraHeadContainer.java +++ b/src/main/java/twilightforest/entity/boss/HydraHeadContainer.java @@ -6,7 +6,6 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.boss.EntityDragonPart; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; @@ -769,7 +768,6 @@ protected void setHeadPosition() { /** * Execute whatever effect we need. Deal damage with the bite, the breath weapon, or launch mortars when appropriate */ - @SuppressWarnings("unchecked") protected void executeAttacks() { if (this.currentState == HydraHeadContainer.STATE_MORTAR_LAUNCH && this.ticksProgress % 10 == 0) { Entity lookTarget = getHeadLookTarget(); @@ -797,7 +795,7 @@ protected void executeAttacks() { } headEntity.worldObj.playAuxSFXAtEntity( - (EntityPlayer) null, + null, 1008, (int) headEntity.posX, (int) headEntity.posY, @@ -854,7 +852,6 @@ protected void setDifficultyVariables() { /** * What, if anything, is the head currently looking at? */ - @SuppressWarnings("unchecked") private Entity getHeadLookTarget() { Entity pointedEntity = null; double range = 30.0D; @@ -874,8 +871,7 @@ private Entity getHeadLookTarget() { && possibleEntity != neckb && possibleEntity != neckc) { float borderSize = possibleEntity.getCollisionBorderSize(); - AxisAlignedBB collisionBB = possibleEntity.boundingBox - .expand((double) borderSize, (double) borderSize, (double) borderSize); + AxisAlignedBB collisionBB = possibleEntity.boundingBox.expand(borderSize, borderSize, borderSize); MovingObjectPosition interceptPos = collisionBB.calculateIntercept(srcVec, destVec); if (collisionBB.isVecInside(srcVec)) { @@ -913,7 +909,6 @@ public void endCurrentAction() { /** * Search for nearby heads with the string as their name */ - @SuppressWarnings("unchecked") private EntityTFHydraHead findNearbyHead(String string) { List nearbyHeads = hydraObj.worldObj.getEntitiesWithinAABB( @@ -1092,8 +1087,7 @@ protected void faceIdle(float yawConstraint, float pitchConstraint) { */ public void faceEntity(Entity entity, float yawConstraint, float pitchConstraint) { double yTarget; - if (entity instanceof EntityLivingBase) { - EntityLivingBase entityliving = (EntityLivingBase) entity; + if (entity instanceof EntityLivingBase entityliving) { yTarget = entityliving.posY + entityliving.getEyeHeight(); } else { yTarget = (entity.boundingBox.minY + entity.boundingBox.maxY) / 2D; diff --git a/src/main/java/twilightforest/entity/passive/EntityTFQuestRam.java b/src/main/java/twilightforest/entity/passive/EntityTFQuestRam.java index 1fb41a0b46..282b79b751 100644 --- a/src/main/java/twilightforest/entity/passive/EntityTFQuestRam.java +++ b/src/main/java/twilightforest/entity/passive/EntityTFQuestRam.java @@ -140,7 +140,6 @@ private void rewardQuest() { /** * Give achievement to nearby players */ - @SuppressWarnings("unchecked") private void rewardNearbyPlayers(World world, double posX, double posY, double posZ) { // scan for players nearby to give the achievement List nearbyPlayers = world.getEntitiesWithinAABB( @@ -171,8 +170,7 @@ public boolean interact(EntityPlayer par1EntityPlayer) { --currentItem.stackSize; if (currentItem.stackSize <= 0) { - par1EntityPlayer.inventory - .setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack) null); + par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, null); } } diff --git a/src/main/java/twilightforest/entity/passive/EntityTFTinyBird.java b/src/main/java/twilightforest/entity/passive/EntityTFTinyBird.java index 02f4491e22..6918a560b3 100644 --- a/src/main/java/twilightforest/entity/passive/EntityTFTinyBird.java +++ b/src/main/java/twilightforest/entity/passive/EntityTFTinyBird.java @@ -221,26 +221,14 @@ protected void updateAITasks() { MathHelper.floor_double(this.posY - 1), MathHelper.floor_double(this.posZ))) { this.setIsBirdLanded(false); - this.worldObj.playAuxSFXAtEntity( - (EntityPlayer) null, - 1015, - (int) this.posX, - (int) this.posY, - (int) this.posZ, - 0); + this.worldObj.playAuxSFXAtEntity(null, 1015, (int) this.posX, (int) this.posY, (int) this.posZ, 0); this.motionY = 0.4; // FMLLog.info("bird taking off because it is no longer on land"); } else { if (isSpooked()) { this.setIsBirdLanded(false); this.motionY = 0.4; - this.worldObj.playAuxSFXAtEntity( - (EntityPlayer) null, - 1015, - (int) this.posX, - (int) this.posY, - (int) this.posZ, - 0); + this.worldObj.playAuxSFXAtEntity(null, 1015, (int) this.posX, (int) this.posY, (int) this.posZ, 0); // FMLLog.info("bird taking off because it was spooked"); } } diff --git a/src/main/java/twilightforest/inventory/ContainerTFCinderFurnace.java b/src/main/java/twilightforest/inventory/ContainerTFCinderFurnace.java index d5e79ab1a1..3aea5b4ba0 100644 --- a/src/main/java/twilightforest/inventory/ContainerTFCinderFurnace.java +++ b/src/main/java/twilightforest/inventory/ContainerTFCinderFurnace.java @@ -57,8 +57,8 @@ public void addCraftingToCrafters(ICrafting p_75132_1_) { public void detectAndSendChanges() { super.detectAndSendChanges(); - for (int i = 0; i < this.crafters.size(); ++i) { - ICrafting icrafting = (ICrafting) this.crafters.get(i); + for (ICrafting crafter : this.crafters) { + ICrafting icrafting = crafter; if (this.lastCookTime != this.tileFurnace.furnaceCookTime) { icrafting.sendProgressBarUpdate(this, 0, this.tileFurnace.furnaceCookTime); @@ -102,7 +102,7 @@ public boolean canInteractWith(EntityPlayer p_75145_1_) { */ public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) { ItemStack itemstack = null; - Slot slot = (Slot) this.inventorySlots.get(p_82846_2_); + Slot slot = this.inventorySlots.get(p_82846_2_); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); @@ -135,7 +135,7 @@ public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) { } if (itemstack1.stackSize == 0) { - slot.putStack((ItemStack) null); + slot.putStack(null); } else { slot.onSlotChanged(); } diff --git a/src/main/java/twilightforest/inventory/ContainerTFUncrafting.java b/src/main/java/twilightforest/inventory/ContainerTFUncrafting.java index e9f19e340b..270dba9415 100644 --- a/src/main/java/twilightforest/inventory/ContainerTFUncrafting.java +++ b/src/main/java/twilightforest/inventory/ContainerTFUncrafting.java @@ -1,7 +1,6 @@ package twilightforest.inventory; import java.util.ArrayList; -import java.util.List; import java.util.Map; import net.minecraft.enchantment.Enchantment; @@ -233,11 +232,11 @@ public void onCraftMatrixChanged(IInventory par1IInventory) { } // check if the input enchantments can even go onto the result item - Map inputEnchantments = null; + Map inputEnchantments = null; if (input.isItemEnchanted()) { inputEnchantments = EnchantmentHelper.getEnchantments(input); - for (Object key : inputEnchantments.keySet()) { - int enchID = ((Integer) key).intValue(); + for (Integer key : inputEnchantments.keySet()) { + int enchID = key; // int level = ((Integer)inputEnchantments.get(key)).intValue(); Enchantment ench = Enchantment.enchantmentsList[enchID]; @@ -269,8 +268,8 @@ public void onCraftMatrixChanged(IInventory par1IInventory) { // finally, add any innate enchantments back onto the result if (resultInnateEnchantments != null && resultInnateEnchantments.size() > 0) { for (Object key : resultInnateEnchantments.keySet()) { - int enchID = ((Integer) key).intValue(); - int level = ((Integer) resultInnateEnchantments.get(key)).intValue(); + int enchID = (Integer) key; + int level = (Integer) resultInnateEnchantments.get(key); Enchantment ench = Enchantment.enchantmentsList[enchID]; if (EnchantmentHelper.getEnchantmentLevel(enchID, result) > level) { @@ -300,10 +299,9 @@ protected boolean isIngredientProblematic(ItemStack ingredient) { * @param inputStack * @return */ - @SuppressWarnings("unchecked") public IRecipe getRecipeFor(ItemStack inputStack) { if (inputStack != null) { - for (IRecipe recipe : (List) (CraftingManager.getInstance().getRecipeList())) { + for (IRecipe recipe : CraftingManager.getInstance().getRecipeList()) { if ((recipe instanceof ShapedRecipes || recipe instanceof ShapedOreRecipe) && recipe.getRecipeOutput().getItem() == inputStack.getItem() && inputStack.stackSize >= recipe.getRecipeOutput().stackSize @@ -342,9 +340,8 @@ public boolean isValidMatchForInput(ItemStack inputStack, ItemStack resultStack) return true; } - if (inputStack.getItem() instanceof ItemArmor && resultStack.getItem() instanceof ItemArmor) { - ItemArmor inputArmor = (ItemArmor) inputStack.getItem(); - ItemArmor resultArmor = (ItemArmor) resultStack.getItem(); + if (inputStack.getItem() instanceof ItemArmor inputArmor + && resultStack.getItem() instanceof ItemArmor resultArmor) { return inputArmor.armorType == resultArmor.armorType; } @@ -466,23 +463,12 @@ public int countTotalEnchantmentCost(ItemStack itemStack) { } public int getWeightModifier(Enchantment ench) { - switch (ench.getWeight()) { - case 1: - return 8; - case 2: - return 4; - case 3: - case 4: - case 5: - return 2; - case 6: - case 7: - case 8: - case 9: - default: - case 10: - return 1; - } + return switch (ench.getWeight()) { + case 1 -> 8; + case 2 -> 4; + case 3, 4, 5 -> 2; + default -> 1; + }; } /** @@ -494,8 +480,8 @@ public ItemStack slotClick(int slotNum, int mouseButton, int shiftHeld, EntityPl // if the player is trying to take an item out of the assembly grid, and the assembly grid is empty, // take the item from the uncrafting grid. if (slotNum > 0 && par4EntityPlayer.inventory.getItemStack() == null - && ((Slot) this.inventorySlots.get(slotNum)).inventory == this.assemblyMatrix - && !((Slot) this.inventorySlots.get(slotNum)).getHasStack()) { + && this.inventorySlots.get(slotNum).inventory == this.assemblyMatrix + && !this.inventorySlots.get(slotNum).getHasStack()) { // is the assembly matrix empty? if (isMatrixEmpty(this.assemblyMatrix)) { slotNum -= 9; @@ -504,21 +490,21 @@ public ItemStack slotClick(int slotNum, int mouseButton, int shiftHeld, EntityPl // if the player is trying to take the result item and they don't have the XP to pay for it, reject // them - if (slotNum > 0 && ((Slot) this.inventorySlots.get(slotNum)).inventory == this.tinkerResult + if (slotNum > 0 && this.inventorySlots.get(slotNum).inventory == this.tinkerResult && calculateRecraftingCost() > par4EntityPlayer.experienceLevel && !par4EntityPlayer.capabilities.isCreativeMode) { return null; } // similarly, reject uncrafting if they can't do that either - if (slotNum > 0 && ((Slot) this.inventorySlots.get(slotNum)).inventory == this.uncraftingMatrix + if (slotNum > 0 && this.inventorySlots.get(slotNum).inventory == this.uncraftingMatrix && calculateUncraftingCost() > par4EntityPlayer.experienceLevel && !par4EntityPlayer.capabilities.isCreativeMode) { return null; } // don't allow uncrafting if the server option is turned off - if (slotNum > 0 && ((Slot) this.inventorySlots.get(slotNum)).inventory == this.uncraftingMatrix + if (slotNum > 0 && this.inventorySlots.get(slotNum).inventory == this.uncraftingMatrix && TwilightForestMod.disableUncrafting) { // send the player a message // par4EntityPlayer.sendChatToPlayer("Uncrafting is disabled in the server configuration."); @@ -526,9 +512,9 @@ && calculateUncraftingCost() > par4EntityPlayer.experienceLevel } // finally, don't give them damaged goods - if (slotNum > 0 && ((Slot) this.inventorySlots.get(slotNum)).inventory == this.uncraftingMatrix - && (((Slot) this.inventorySlots.get(slotNum)).getStack() == null - || ((Slot) this.inventorySlots.get(slotNum)).getStack().stackSize == 0)) { + if (slotNum > 0 && this.inventorySlots.get(slotNum).inventory == this.uncraftingMatrix + && (this.inventorySlots.get(slotNum).getStack() == null + || this.inventorySlots.get(slotNum).getStack().stackSize == 0)) { return null; } @@ -536,7 +522,7 @@ && calculateUncraftingCost() > par4EntityPlayer.experienceLevel ItemStack ret = super.slotClick(slotNum, mouseButton, shiftHeld, par4EntityPlayer); // just trigger this event whenever the input slot is clicked for any reason - if (slotNum > 0 && ((Slot) this.inventorySlots.get(slotNum)).inventory instanceof InventoryTFGoblinInput) { + if (slotNum > 0 && this.inventorySlots.get(slotNum).inventory instanceof InventoryTFGoblinInput) { this.onCraftMatrixChanged(this.tinkerInput); } @@ -548,7 +534,7 @@ protected void retrySlotClick(int slotNum, int mouseButton, boolean par3, Entity // if they are taking something out of the uncrafting matrix, bump the slot number back to the // assembly matrix // otherwise we lose the stuff in the uncrafting matrix when we shift-click to take multiple things - if (((Slot) this.inventorySlots.get(slotNum)).inventory == this.uncraftingMatrix) { + if (this.inventorySlots.get(slotNum).inventory == this.uncraftingMatrix) { slotNum += 9; } @@ -614,7 +600,7 @@ public int countDamagedParts(ItemStack input) { @Override public ItemStack transferStackInSlot(EntityPlayer player, int slotNum) { ItemStack copyItem = null; - Slot transferSlot = (Slot) this.inventorySlots.get(slotNum); + Slot transferSlot = this.inventorySlots.get(slotNum); if (transferSlot != null && transferSlot.getHasStack()) { ItemStack transferStack = transferSlot.getStack(); @@ -643,7 +629,7 @@ public ItemStack transferStackInSlot(EntityPlayer player, int slotNum) { } if (transferStack.stackSize == 0) { - transferSlot.putStack((ItemStack) null); + transferSlot.putStack(null); } else { transferSlot.onSlotChanged(); } @@ -738,9 +724,7 @@ public ItemStack[] getRecipeItemsOre(ShapedOreRecipe shaped) { } return items; - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (SecurityException e) { + } catch (IllegalArgumentException | SecurityException e) { e.printStackTrace(); } return null; @@ -786,11 +770,8 @@ public int getRecipeWidthShaped(ShapedRecipes shaped) { */ public int getRecipeWidthOre(ShapedOreRecipe shaped) { try { - return ((Integer) (ObfuscationReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 4))) - .intValue(); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (SecurityException e) { + return ObfuscationReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 4); + } catch (IllegalArgumentException | SecurityException e) { e.printStackTrace(); } return 0; @@ -835,11 +816,8 @@ public int getRecipeHeightShaped(ShapedRecipes shaped) { */ public int getRecipeHeightOre(ShapedOreRecipe shaped) { try { - return ((Integer) (ObfuscationReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 5))) - .intValue(); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (SecurityException e) { + return ObfuscationReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 5); + } catch (IllegalArgumentException | SecurityException e) { e.printStackTrace(); } return 0; diff --git a/src/main/java/twilightforest/item/ItemBlockNagastone.java b/src/main/java/twilightforest/item/ItemBlockNagastone.java index 8a10a28b44..0050d029b6 100644 --- a/src/main/java/twilightforest/item/ItemBlockNagastone.java +++ b/src/main/java/twilightforest/item/ItemBlockNagastone.java @@ -26,7 +26,7 @@ public IIcon getIconFromDamage(int i) { @Override public String getUnlocalizedName(ItemStack itemstack) { int meta = itemstack.getItemDamage(); - return (new StringBuilder()).append(super.getUnlocalizedName()).append(".").append(meta).toString(); + return super.getUnlocalizedName() + "." + meta; } @Override diff --git a/src/main/java/twilightforest/item/ItemBlockTFLeaves.java b/src/main/java/twilightforest/item/ItemBlockTFLeaves.java index 77a3d2f53c..571ae8246d 100644 --- a/src/main/java/twilightforest/item/ItemBlockTFLeaves.java +++ b/src/main/java/twilightforest/item/ItemBlockTFLeaves.java @@ -26,7 +26,7 @@ public IIcon getIconFromDamage(int par1) { @Override public String getUnlocalizedName(ItemStack itemstack) { int meta = itemstack.getItemDamage(); - return (new StringBuilder()).append(super.getUnlocalizedName()).append(".").append(meta).toString(); + return super.getUnlocalizedName() + "." + meta; } @Override diff --git a/src/main/java/twilightforest/item/ItemBlockTFLog.java b/src/main/java/twilightforest/item/ItemBlockTFLog.java index 8d6db915f1..c9f54ada83 100644 --- a/src/main/java/twilightforest/item/ItemBlockTFLog.java +++ b/src/main/java/twilightforest/item/ItemBlockTFLog.java @@ -10,7 +10,7 @@ public class ItemBlockTFLog extends ItemBlock { - public static final String woodNames[] = { "oak", "canopy", "mangrove", "darkwood", "x", "root", "oreroot", + public static final String[] woodNames = { "oak", "canopy", "mangrove", "darkwood", "x", "root", "oreroot", "rotten" }; public ItemBlockTFLog(Block log) { @@ -33,13 +33,12 @@ public String getUnlocalizedName(ItemStack itemstack) { if ((meta & 8) == 0) { // wood int i = MathHelper.clamp_int(meta, 0, 7); - return (new StringBuilder()).append(super.getUnlocalizedName()).append(".").append(woodNames[i]).toString(); + return super.getUnlocalizedName() + "." + woodNames[i]; } else { // log meta &= 7; int i = MathHelper.clamp_int(meta, 0, 7); - return (new StringBuilder()).append(super.getUnlocalizedName()).append(".").append(woodNames[i]) - .append(".log").toString(); + return super.getUnlocalizedName() + "." + woodNames[i] + ".log"; } } diff --git a/src/main/java/twilightforest/item/ItemBlockTFMeta.java b/src/main/java/twilightforest/item/ItemBlockTFMeta.java index ad15a12f6a..c82a707d6e 100644 --- a/src/main/java/twilightforest/item/ItemBlockTFMeta.java +++ b/src/main/java/twilightforest/item/ItemBlockTFMeta.java @@ -31,7 +31,7 @@ public int getMetadata(int i) { @Override public String getUnlocalizedName(ItemStack itemstack) { int meta = itemstack.getItemDamage(); - return (new StringBuilder()).append(super.getUnlocalizedName()).append(".").append(meta).toString(); + return super.getUnlocalizedName() + "." + meta; } /** @@ -45,10 +45,10 @@ public IIcon getIconFromDamage(int par1) { /** * allows items to add custom lines of information to the mouseover description */ - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, + boolean par4) { super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4); // add warning for [WIP] tag diff --git a/src/main/java/twilightforest/item/ItemBlockTFPlant.java b/src/main/java/twilightforest/item/ItemBlockTFPlant.java index 8645c40da3..a8ea4bb006 100644 --- a/src/main/java/twilightforest/item/ItemBlockTFPlant.java +++ b/src/main/java/twilightforest/item/ItemBlockTFPlant.java @@ -39,7 +39,7 @@ public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { @Override public String getUnlocalizedName(ItemStack itemstack) { int meta = itemstack.getItemDamage(); - return (new StringBuilder()).append(super.getUnlocalizedName()).append(".").append(meta).toString(); + return super.getUnlocalizedName() + "." + meta; } /** @@ -119,9 +119,9 @@ public boolean onItemUseRoot(ItemStack itemStack, EntityPlayer player, World wor } world.playSoundEffect( - (double) (x + 0.5F), - (double) (y + 0.5F), - (double) (z + 0.5F), + x + 0.5F, + y + 0.5F, + z + 0.5F, plantBlock.stepSound.getBreakSound(), (plantBlock.stepSound.getVolume() + 1.0F) / 2.0F, plantBlock.stepSound.getPitch() * 0.8F); diff --git a/src/main/java/twilightforest/item/ItemTFArcticArmor.java b/src/main/java/twilightforest/item/ItemTFArcticArmor.java index 2f9a5145ec..d428bb3f8c 100644 --- a/src/main/java/twilightforest/item/ItemTFArcticArmor.java +++ b/src/main/java/twilightforest/item/ItemTFArcticArmor.java @@ -44,24 +44,17 @@ public EnumRarity getRarity(ItemStack par1ItemStack) { * @return Path of texture to bind, or null to use default */ public String getArmorTexture(ItemStack itemstack, Entity entity, int slot, String layer) { - switch (slot) { - case 0: - case 1: - case 3: - default: - return TwilightForestMod.ARMOR_DIR + "arcticarmor_1.png"; - case 2: - return TwilightForestMod.ARMOR_DIR + "arcticarmor_2.png"; - - } + return switch (slot) { + default -> TwilightForestMod.ARMOR_DIR + "arcticarmor_1.png"; + case 2 -> TwilightForestMod.ARMOR_DIR + "arcticarmor_2.png"; + }; } /** * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) */ - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { ItemStack istack = new ItemStack(par1, 1, 0); // istack.addEnchantment(TFEnchantment.reactFire, 2); par3List.add(istack); diff --git a/src/main/java/twilightforest/item/ItemTFChainBlock.java b/src/main/java/twilightforest/item/ItemTFChainBlock.java index 701985d51a..5f33f3b433 100644 --- a/src/main/java/twilightforest/item/ItemTFChainBlock.java +++ b/src/main/java/twilightforest/item/ItemTFChainBlock.java @@ -2,7 +2,6 @@ import java.util.HashMap; -import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -26,10 +25,10 @@ public class ItemTFChainBlock extends ItemTool { // which items have launched which blocks? - private HashMap launchedBlocksMap = new HashMap(); + private HashMap launchedBlocksMap = new HashMap<>(); protected ItemTFChainBlock() { - super(6, TFItems.TOOL_KNIGHTLY, Sets.newHashSet(new Block[] { Blocks.stone })); + super(6, TFItems.TOOL_KNIGHTLY, Sets.newHashSet(Blocks.stone)); this.maxStackSize = 1; this.setMaxDamage(99); this.setCreativeTab(TFItems.creativeTab); diff --git a/src/main/java/twilightforest/item/ItemTFCubeOfAnnihilation.java b/src/main/java/twilightforest/item/ItemTFCubeOfAnnihilation.java index deb850393a..9ef237658f 100644 --- a/src/main/java/twilightforest/item/ItemTFCubeOfAnnihilation.java +++ b/src/main/java/twilightforest/item/ItemTFCubeOfAnnihilation.java @@ -20,7 +20,7 @@ public class ItemTFCubeOfAnnihilation extends ItemTF { private IIcon annihilateIcon; - private HashMap launchedCubesMap = new HashMap(); + private HashMap launchedCubesMap = new HashMap<>(); protected ItemTFCubeOfAnnihilation() { super(); diff --git a/src/main/java/twilightforest/item/ItemTFFieryArmor.java b/src/main/java/twilightforest/item/ItemTFFieryArmor.java index 6248f1efb6..683d55ac85 100644 --- a/src/main/java/twilightforest/item/ItemTFFieryArmor.java +++ b/src/main/java/twilightforest/item/ItemTFFieryArmor.java @@ -49,9 +49,8 @@ public String getArmorTexture(ItemStack itemstack, Entity entity, int slot, Stri /** * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) */ - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { ItemStack istack = new ItemStack(par1, 1, 0); // istack.addEnchantment(TFEnchantment.fieryAura, 2); par3List.add(istack); @@ -82,7 +81,8 @@ public void registerIcons(IIconRegister par1IconRegister) { */ @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, + boolean par4) { super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4); par3List.add(StatCollector.translateToLocal(getUnlocalizedName() + ".tooltip")); } diff --git a/src/main/java/twilightforest/item/ItemTFFieryPick.java b/src/main/java/twilightforest/item/ItemTFFieryPick.java index 48e7628e24..1a18f24a30 100644 --- a/src/main/java/twilightforest/item/ItemTFFieryPick.java +++ b/src/main/java/twilightforest/item/ItemTFFieryPick.java @@ -114,7 +114,7 @@ public EnumRarity getRarity(ItemStack itemStack) { */ @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack par1ItemStack, EntityPlayer player, List par3List, boolean par4) { + public void addInformation(ItemStack par1ItemStack, EntityPlayer player, List par3List, boolean par4) { super.addInformation(par1ItemStack, player, par3List, par4); par3List.add(StatCollector.translateToLocal(getUnlocalizedName() + ".tooltip")); } diff --git a/src/main/java/twilightforest/item/ItemTFFierySword.java b/src/main/java/twilightforest/item/ItemTFFierySword.java index 90e4adcb45..e9dced59c2 100644 --- a/src/main/java/twilightforest/item/ItemTFFierySword.java +++ b/src/main/java/twilightforest/item/ItemTFFierySword.java @@ -102,7 +102,8 @@ public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase target, Entit */ @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, + boolean par4) { super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4); par3List.add(StatCollector.translateToLocal(getUnlocalizedName() + ".tooltip")); } diff --git a/src/main/java/twilightforest/item/ItemTFGiantPick.java b/src/main/java/twilightforest/item/ItemTFGiantPick.java index 086e327271..b59534692e 100644 --- a/src/main/java/twilightforest/item/ItemTFGiantPick.java +++ b/src/main/java/twilightforest/item/ItemTFGiantPick.java @@ -87,10 +87,10 @@ public IIcon getIcon(ItemStack stack, int pass) { /** * allows items to add custom lines of information to the mouseover description */ - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, + boolean par4) { super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4); par3List.add(StatCollector.translateToLocal(getUnlocalizedName() + ".tooltip")); } @@ -106,7 +106,7 @@ public Multimap getItemAttributeModifiers() { // add new one multimap.put( SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), - new AttributeModifier(field_111210_e, "Tool modifier", (double) this.damageVsEntity, 0)); + new AttributeModifier(field_111210_e, "Tool modifier", this.damageVsEntity, 0)); return multimap; } diff --git a/src/main/java/twilightforest/item/ItemTFIronwoodArmor.java b/src/main/java/twilightforest/item/ItemTFIronwoodArmor.java index df41b2512d..36e98c8f02 100644 --- a/src/main/java/twilightforest/item/ItemTFIronwoodArmor.java +++ b/src/main/java/twilightforest/item/ItemTFIronwoodArmor.java @@ -49,16 +49,9 @@ public String getArmorTexture(ItemStack itemstack, Entity entity, int slot, Stri public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { ItemStack istack = new ItemStack(item, 1, 0); switch (this.armorType) { - case 0: - istack.addEnchantment(Enchantment.aquaAffinity, 1); - break; - case 1: - case 2: - istack.addEnchantment(Enchantment.protection, 1); - break; - case 3: - istack.addEnchantment(Enchantment.featherFalling, 1); - break; + case 0 -> istack.addEnchantment(Enchantment.aquaAffinity, 1); + case 1, 2 -> istack.addEnchantment(Enchantment.protection, 1); + case 3 -> istack.addEnchantment(Enchantment.featherFalling, 1); } itemList.add(istack); } diff --git a/src/main/java/twilightforest/item/ItemTFIronwoodAxe.java b/src/main/java/twilightforest/item/ItemTFIronwoodAxe.java index 2d65ad852d..408eea2f75 100644 --- a/src/main/java/twilightforest/item/ItemTFIronwoodAxe.java +++ b/src/main/java/twilightforest/item/ItemTFIronwoodAxe.java @@ -24,7 +24,7 @@ protected ItemTFIronwoodAxe(Item.ToolMaterial par2EnumToolMaterial) { * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) */ @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { ItemStack istack = new ItemStack(par1, 1, 0); istack.addEnchantment(Enchantment.fortune, 1); par3List.add(istack); diff --git a/src/main/java/twilightforest/item/ItemTFIronwoodPick.java b/src/main/java/twilightforest/item/ItemTFIronwoodPick.java index b44de26a9e..afd2e30dca 100644 --- a/src/main/java/twilightforest/item/ItemTFIronwoodPick.java +++ b/src/main/java/twilightforest/item/ItemTFIronwoodPick.java @@ -24,7 +24,7 @@ protected ItemTFIronwoodPick(Item.ToolMaterial par2EnumToolMaterial) { * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) */ @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { ItemStack istack = new ItemStack(par1, 1, 0); istack.addEnchantment(Enchantment.efficiency, 1); par3List.add(istack); diff --git a/src/main/java/twilightforest/item/ItemTFIronwoodShovel.java b/src/main/java/twilightforest/item/ItemTFIronwoodShovel.java index 26b50fcd0e..70c6843ada 100644 --- a/src/main/java/twilightforest/item/ItemTFIronwoodShovel.java +++ b/src/main/java/twilightforest/item/ItemTFIronwoodShovel.java @@ -24,7 +24,7 @@ public ItemTFIronwoodShovel(Item.ToolMaterial par2EnumToolMaterial) { * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) */ @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { ItemStack istack = new ItemStack(par1, 1, 0); istack.addEnchantment(Enchantment.unbreaking, 1); par3List.add(istack); diff --git a/src/main/java/twilightforest/item/ItemTFIronwoodSword.java b/src/main/java/twilightforest/item/ItemTFIronwoodSword.java index 973cc84c0e..8d90b7a2a5 100644 --- a/src/main/java/twilightforest/item/ItemTFIronwoodSword.java +++ b/src/main/java/twilightforest/item/ItemTFIronwoodSword.java @@ -24,7 +24,7 @@ public ItemTFIronwoodSword(Item.ToolMaterial par2EnumToolMaterial) { * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) */ @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { ItemStack istack = new ItemStack(par1, 1, 0); istack.addEnchantment(Enchantment.knockback, 1); par3List.add(istack); diff --git a/src/main/java/twilightforest/item/ItemTFKnightlyArmor.java b/src/main/java/twilightforest/item/ItemTFKnightlyArmor.java index 621725a831..d98fd78ba7 100644 --- a/src/main/java/twilightforest/item/ItemTFKnightlyArmor.java +++ b/src/main/java/twilightforest/item/ItemTFKnightlyArmor.java @@ -55,9 +55,8 @@ public String getArmorTexture(ItemStack itemstack, Entity entity, int slot, Stri /** * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) */ - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { ItemStack istack = new ItemStack(par1, 1, 0); // istack.addEnchantment(TFEnchantment.reactFire, 2); par3List.add(istack); diff --git a/src/main/java/twilightforest/item/ItemTFKnightlyAxe.java b/src/main/java/twilightforest/item/ItemTFKnightlyAxe.java index 656bf8c50e..fb872333e2 100644 --- a/src/main/java/twilightforest/item/ItemTFKnightlyAxe.java +++ b/src/main/java/twilightforest/item/ItemTFKnightlyAxe.java @@ -109,7 +109,8 @@ public void registerIcons(IIconRegister par1IconRegister) { */ @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, + boolean par4) { super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4); par3List.add(StatCollector.translateToLocal(getUnlocalizedName() + ".tooltip")); } @@ -117,14 +118,14 @@ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlaye /** * Gets a map of item attribute modifiers, used by ItemSword to increase hit damage. */ - public Multimap getItemAttributeModifiers() { - Multimap multimap = super.getItemAttributeModifiers(); + public Multimap getItemAttributeModifiers() { + Multimap multimap = super.getItemAttributeModifiers(); // remove old damage value multimap.removeAll(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName()); // add new one multimap.put( SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), - new AttributeModifier(field_111210_e, "Tool modifier", (double) this.damageVsEntity, 0)); + new AttributeModifier(field_111210_e, "Tool modifier", this.damageVsEntity, 0)); return multimap; } } diff --git a/src/main/java/twilightforest/item/ItemTFKnightlyPick.java b/src/main/java/twilightforest/item/ItemTFKnightlyPick.java index 03671efc66..9b82513ccc 100644 --- a/src/main/java/twilightforest/item/ItemTFKnightlyPick.java +++ b/src/main/java/twilightforest/item/ItemTFKnightlyPick.java @@ -109,7 +109,8 @@ public void registerIcons(IIconRegister par1IconRegister) { */ @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, + boolean par4) { super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4); par3List.add(StatCollector.translateToLocal(getUnlocalizedName() + ".tooltip")); } @@ -117,14 +118,14 @@ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlaye /** * Gets a map of item attribute modifiers, used by ItemSword to increase hit damage. */ - public Multimap getItemAttributeModifiers() { - Multimap multimap = super.getItemAttributeModifiers(); + public Multimap getItemAttributeModifiers() { + Multimap multimap = super.getItemAttributeModifiers(); // remove old damage value multimap.removeAll(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName()); // add new one multimap.put( SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), - new AttributeModifier(field_111210_e, "Tool modifier", (double) this.damageVsEntity, 0)); + new AttributeModifier(field_111210_e, "Tool modifier", this.damageVsEntity, 0)); return multimap; } } diff --git a/src/main/java/twilightforest/item/ItemTFKnightlySword.java b/src/main/java/twilightforest/item/ItemTFKnightlySword.java index 875d539cfa..9281b4c8d3 100644 --- a/src/main/java/twilightforest/item/ItemTFKnightlySword.java +++ b/src/main/java/twilightforest/item/ItemTFKnightlySword.java @@ -102,7 +102,8 @@ public void registerIcons(IIconRegister par1IconRegister) { */ @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, + boolean par4) { super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4); par3List.add(StatCollector.translateToLocal(getUnlocalizedName() + ".tooltip")); } diff --git a/src/main/java/twilightforest/item/ItemTFMagicBeans.java b/src/main/java/twilightforest/item/ItemTFMagicBeans.java index b9667ad532..ebf2317fc4 100644 --- a/src/main/java/twilightforest/item/ItemTFMagicBeans.java +++ b/src/main/java/twilightforest/item/ItemTFMagicBeans.java @@ -48,7 +48,7 @@ private float getCloudHeight(World world) { if (world.provider instanceof WorldProviderTwilightForest) { // WorldProviderTwilightForest has this method on both server and client - return ((WorldProviderTwilightForest) world.provider).getCloudHeight(); + return world.provider.getCloudHeight(); } else { // are we on a dedicated server // TODO: don't use exceptions for program flow? diff --git a/src/main/java/twilightforest/item/ItemTFMagicMap.java b/src/main/java/twilightforest/item/ItemTFMagicMap.java index 1be4712c58..cc17cd99aa 100644 --- a/src/main/java/twilightforest/item/ItemTFMagicMap.java +++ b/src/main/java/twilightforest/item/ItemTFMagicMap.java @@ -108,9 +108,7 @@ public void updateMapData(World world, Entity entity, TFMagicMapData mapData) { biomeFrequencies[biomeID] += 2; } // add in TF features - if (world.getWorldChunkManager() instanceof TFWorldChunkManager) { - TFWorldChunkManager tfManager = (TFWorldChunkManager) world - .getWorldChunkManager(); + if (world.getWorldChunkManager() instanceof TFWorldChunkManager tfManager) { if (tfManager.isInFeatureChunk(world, xDraw2 + xStep2, zDraw2 + zStep2) && zStep >= 0 @@ -188,8 +186,7 @@ public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, if (!world.isRemote) { TFMagicMapData mapData = this.getMapData(itemStack, world); - if (entity instanceof EntityPlayer) { - EntityPlayer var7 = (EntityPlayer) entity; + if (entity instanceof EntityPlayer var7) { mapData.updateVisiblePlayers(var7, itemStack); } @@ -255,9 +252,8 @@ public Packet func_150911_c(ItemStack itemStack, World world, EntityPlayer playe // Add the map number to the tooltip public String getItemStackDisplayName(ItemStack itemStack) { - return (String.valueOf( - StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(itemStack) + ".name") + " #" - + itemStack.getItemDamage())).trim(); + return (StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(itemStack) + ".name") + " #" + + itemStack.getItemDamage()).trim(); } // Properly register icon source diff --git a/src/main/java/twilightforest/item/ItemTFMazeMap.java b/src/main/java/twilightforest/item/ItemTFMazeMap.java index 8764afed38..834336faa2 100644 --- a/src/main/java/twilightforest/item/ItemTFMazeMap.java +++ b/src/main/java/twilightforest/item/ItemTFMazeMap.java @@ -199,15 +199,14 @@ public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity if (!par2World.isRemote) { TFMazeMapData mapData = this.getMapData(par1ItemStack, par2World); - if (par3Entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) par3Entity; + if (par3Entity instanceof EntityPlayer player) { mapData.updateVisiblePlayers(player, par1ItemStack); int yProximity = MathHelper.floor_double(player.posY - mapData.yCenter); if (yProximity < -YSEARCH || yProximity > YSEARCH) { // fix player icon so that it's a dot - MapCoord mapCoord = (MapCoord) mapData.playersVisibleOnMap.get(player.getCommandSenderName()); + MapCoord mapCoord = mapData.playersVisibleOnMap.get(player.getCommandSenderName()); if (mapCoord != null) { mapCoord.iconSize = 6; } @@ -279,9 +278,8 @@ public Packet func_150911_c(ItemStack itemStack, World world, EntityPlayer playe * Add the map number to the tooltip */ public String getItemStackDisplayName(ItemStack itemStack) { - return (String.valueOf( - StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(itemStack) + ".name") + " #" - + itemStack.getItemDamage())).trim(); + return (StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(itemStack) + ".name") + " #" + + itemStack.getItemDamage()).trim(); } /** diff --git a/src/main/java/twilightforest/item/ItemTFMazebreakerPick.java b/src/main/java/twilightforest/item/ItemTFMazebreakerPick.java index f3ffb259fa..4e07d95405 100644 --- a/src/main/java/twilightforest/item/ItemTFMazebreakerPick.java +++ b/src/main/java/twilightforest/item/ItemTFMazebreakerPick.java @@ -25,9 +25,8 @@ protected ItemTFMazebreakerPick(Item.ToolMaterial par2EnumToolMaterial) { /** * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) */ - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { ItemStack istack = new ItemStack(par1, 1, 0); istack.addEnchantment(Enchantment.efficiency, 4); istack.addEnchantment(Enchantment.unbreaking, 3); diff --git a/src/main/java/twilightforest/item/ItemTFMeta.java b/src/main/java/twilightforest/item/ItemTFMeta.java index d693141ce9..621a4608d0 100644 --- a/src/main/java/twilightforest/item/ItemTFMeta.java +++ b/src/main/java/twilightforest/item/ItemTFMeta.java @@ -28,40 +28,30 @@ public ItemTFMeta() { @Override public String getUnlocalizedName(ItemStack stack) { - switch (stack.getItemDamage()) { - case 0: - return "item.adherentFragment"; - case 1: - return "item.harbingerFragment"; - default: - return "unusedMeta"; - } + return switch (stack.getItemDamage()) { + case 0 -> "item.adherentFragment"; + case 1 -> "item.harbingerFragment"; + default -> "unusedMeta"; + }; } @Override @SideOnly(Side.CLIENT) public EnumRarity getRarity(ItemStack stack) { - switch (stack.getItemDamage()) { - case 0: - case 1: - return EnumRarity.uncommon; + return switch (stack.getItemDamage()) { + case 0, 1 -> EnumRarity.uncommon; // return EnumRarity.rare; - default: - return EnumRarity.common; - } + default -> EnumRarity.common; + }; } @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { switch (stack.getItemDamage()) { - case 0: - list.add(StatCollector.translateToLocal("tooltip.tf.adherent")); - break; - case 1: - list.add(StatCollector.translateToLocal("tooltip.tf.harbinger")); - break; + case 0 -> list.add(StatCollector.translateToLocal("tooltip.tf.adherent")); + case 1 -> list.add(StatCollector.translateToLocal("tooltip.tf.harbinger")); } } @@ -81,7 +71,7 @@ public void registerIcons(IIconRegister iconRegister) { } @Override - public void getSubItems(Item id, CreativeTabs tab, List list) { + public void getSubItems(Item id, CreativeTabs tab, List list) { for (int i = 0; i < textureNames.length; i++) list.add(new ItemStack(id, 1, i)); } diff --git a/src/main/java/twilightforest/item/ItemTFMinotaurAxe.java b/src/main/java/twilightforest/item/ItemTFMinotaurAxe.java index c04b7238b3..44bc4be8fa 100644 --- a/src/main/java/twilightforest/item/ItemTFMinotaurAxe.java +++ b/src/main/java/twilightforest/item/ItemTFMinotaurAxe.java @@ -37,7 +37,7 @@ protected ItemTFMinotaurAxe(Item.ToolMaterial par2EnumToolMaterial) { * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) */ @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { ItemStack istack = new ItemStack(par1, 1, 0); // istack.addEnchantment(Enchantment.efficiency, 2); par3List.add(istack); @@ -91,7 +91,8 @@ public int getItemEnchantability() { */ @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, + boolean par4) { super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4); par3List.add(StatCollector.translateToLocal(getUnlocalizedName() + ".tooltip")); } @@ -109,14 +110,14 @@ public void registerIcons(IIconRegister par1IconRegister) { /** * Gets a map of item attribute modifiers, used by ItemSword to increase hit damage. */ - public Multimap getItemAttributeModifiers() { - Multimap multimap = super.getItemAttributeModifiers(); + public Multimap getItemAttributeModifiers() { + Multimap multimap = super.getItemAttributeModifiers(); // remove old damage value multimap.removeAll(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName()); // add new one multimap.put( SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), - new AttributeModifier(field_111210_e, "Tool modifier", (double) this.damageVsEntity, 0)); + new AttributeModifier(field_111210_e, "Tool modifier", this.damageVsEntity, 0)); return multimap; } } diff --git a/src/main/java/twilightforest/item/ItemTFMoonwormQueen.java b/src/main/java/twilightforest/item/ItemTFMoonwormQueen.java index f04fef51f7..9ac9986149 100644 --- a/src/main/java/twilightforest/item/ItemTFMoonwormQueen.java +++ b/src/main/java/twilightforest/item/ItemTFMoonwormQueen.java @@ -99,9 +99,9 @@ public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World wor } world.playSoundEffect( - (double) (x + 0.5F), - (double) (y + 0.5F), - (double) (z + 0.5F), + x + 0.5F, + y + 0.5F, + z + 0.5F, this.getSound(), TFBlocks.moonworm.stepSound.getVolume() / 2.0F, TFBlocks.moonworm.stepSound.getPitch() * 0.8F); diff --git a/src/main/java/twilightforest/item/ItemTFOreMeter.java b/src/main/java/twilightforest/item/ItemTFOreMeter.java index 44f2cc2c4d..1225cd38a7 100644 --- a/src/main/java/twilightforest/item/ItemTFOreMeter.java +++ b/src/main/java/twilightforest/item/ItemTFOreMeter.java @@ -218,7 +218,8 @@ private int countExposedBlockInChunk(World world, Block blockID, int cx, int cz) } @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, + boolean par4) { super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4); } diff --git a/src/main/java/twilightforest/item/ItemTFPhantomArmor.java b/src/main/java/twilightforest/item/ItemTFPhantomArmor.java index 7eba344f4f..25db6fc86b 100644 --- a/src/main/java/twilightforest/item/ItemTFPhantomArmor.java +++ b/src/main/java/twilightforest/item/ItemTFPhantomArmor.java @@ -51,9 +51,8 @@ public String getArmorTexture(ItemStack itemstack, Entity entity, int slot, Stri /** * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) */ - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { ItemStack istack = new ItemStack(par1, 1, 0); // istack.addEnchantment(TFEnchantment.reactFire, 2); par3List.add(istack); diff --git a/src/main/java/twilightforest/item/ItemTFScepterLifeDrain.java b/src/main/java/twilightforest/item/ItemTFScepterLifeDrain.java index 129335f68e..d44c5e9b9c 100644 --- a/src/main/java/twilightforest/item/ItemTFScepterLifeDrain.java +++ b/src/main/java/twilightforest/item/ItemTFScepterLifeDrain.java @@ -94,8 +94,7 @@ private Entity getPlayerLookTarget(World worldObj, EntityPlayer player) { if (possibleEntity.canBeCollidedWith()) { float borderSize = possibleEntity.getCollisionBorderSize(); - AxisAlignedBB collisionBB = possibleEntity.boundingBox - .expand((double) borderSize, (double) borderSize, (double) borderSize); + AxisAlignedBB collisionBB = possibleEntity.boundingBox.expand(borderSize, borderSize, borderSize); MovingObjectPosition interceptPos = collisionBB.calculateIntercept(srcVec, destVec); if (collisionBB.isVecInside(srcVec)) { @@ -131,8 +130,7 @@ public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { // is the player looking at an entity Entity pointedEntity = getPlayerLookTarget(worldObj, player); - if (pointedEntity != null && pointedEntity instanceof EntityLivingBase) { - EntityLivingBase target = (EntityLivingBase) pointedEntity; + if (pointedEntity != null && pointedEntity instanceof EntityLivingBase target) { if (target.getActivePotionEffect(Potion.moveSlowdown) != null || target.getHealth() < 1) { @@ -155,7 +153,7 @@ public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { "game.player.hurt.fall.big", 1.0F, ((itemRand.nextFloat() - itemRand.nextFloat()) * 0.7F + 1.0F) * 2.0F); - animateTargetShatter(worldObj, (EntityLivingBase) target); + animateTargetShatter(worldObj, target); if (!worldObj.isRemote) { target.setDead(); target.onDeath(DamageSource.causeIndirectMagicDamage(player, player)); @@ -275,7 +273,8 @@ public EnumRarity getRarity(ItemStack par1ItemStack) { */ @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, + boolean par4) { super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4); par3List.add((par1ItemStack.getMaxDamage() - par1ItemStack.getItemDamage()) + " charges left"); } diff --git a/src/main/java/twilightforest/item/ItemTFSpawnEgg.java b/src/main/java/twilightforest/item/ItemTFSpawnEgg.java index cf62f83575..b0a68abe1a 100644 --- a/src/main/java/twilightforest/item/ItemTFSpawnEgg.java +++ b/src/main/java/twilightforest/item/ItemTFSpawnEgg.java @@ -1,6 +1,5 @@ package twilightforest.item; -import java.util.Iterator; import java.util.List; import net.minecraft.block.Block; @@ -9,7 +8,6 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.IEntityLivingData; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -38,7 +36,7 @@ protected ItemTFSpawnEgg() { @SideOnly(Side.CLIENT) @Override public int getColorFromItemStack(ItemStack itemStack, int par2) { - TFEntityEggInfo info = (TFEntityEggInfo) TFCreatures.entityEggs.get(Integer.valueOf(itemStack.getItemDamage())); + TFEntityEggInfo info = TFCreatures.entityEggs.get(itemStack.getItemDamage()); return info != null ? (par2 == 0 ? info.primaryColor : info.secondaryColor) : 16777215; } @@ -104,7 +102,7 @@ public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, public static Entity spawnCreature(World world, int par1, double par2, double par4, double par6) { // System.out.println("Trying to spawn twilight egg"); - if (!TFCreatures.entityEggs.containsKey(Integer.valueOf(par1))) { + if (!TFCreatures.entityEggs.containsKey(par1)) { return null; } else { Entity entityToSpawn = TFCreatures.createEntityByID(par1, world); @@ -113,7 +111,7 @@ public static Entity spawnCreature(World world, int par1, double par2, double pa EntityLiving entityliving = (EntityLiving) entityToSpawn; entityToSpawn.setLocationAndAngles(par2, par4, par6, world.rand.nextFloat() * 360.0F, 0.0F); - entityliving.onSpawnWithEgg((IEntityLivingData) null); + entityliving.onSpawnWithEgg(null); world.spawnEntityInWorld(entityToSpawn); ((EntityLiving) entityToSpawn).playLivingSound(); } @@ -123,11 +121,9 @@ public static Entity spawnCreature(World world, int par1, double par2, double pa // returns a list of items with the same ID, but different meta (eg: dye returns 16 items) @Override - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { - Iterator var4 = TFCreatures.entityEggs.values().iterator(); + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { - while (var4.hasNext()) { - TFEntityEggInfo var5 = (TFEntityEggInfo) var4.next(); + for (TFEntityEggInfo var5 : TFCreatures.entityEggs.values()) { itemList.add(new ItemStack(item, 1, var5.spawnedID)); } } diff --git a/src/main/java/twilightforest/item/ItemTFSteeleafArmor.java b/src/main/java/twilightforest/item/ItemTFSteeleafArmor.java index 43c668f00d..519d358793 100644 --- a/src/main/java/twilightforest/item/ItemTFSteeleafArmor.java +++ b/src/main/java/twilightforest/item/ItemTFSteeleafArmor.java @@ -45,23 +45,14 @@ public String getArmorTexture(ItemStack itemstack, Entity entity, int slot, Stri /** * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) */ - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { ItemStack istack = new ItemStack(par1, 1, 0); switch (this.armorType) { - case 0: - istack.addEnchantment(Enchantment.projectileProtection, 2); - break; - case 1: - istack.addEnchantment(Enchantment.blastProtection, 2); - break; - case 2: - istack.addEnchantment(Enchantment.fireProtection, 2); - break; - case 3: - istack.addEnchantment(Enchantment.featherFalling, 2); - break; + case 0 -> istack.addEnchantment(Enchantment.projectileProtection, 2); + case 1 -> istack.addEnchantment(Enchantment.blastProtection, 2); + case 2 -> istack.addEnchantment(Enchantment.fireProtection, 2); + case 3 -> istack.addEnchantment(Enchantment.featherFalling, 2); } par3List.add(istack); } diff --git a/src/main/java/twilightforest/item/ItemTFSteeleafAxe.java b/src/main/java/twilightforest/item/ItemTFSteeleafAxe.java index 4dc605f6a3..524a14e671 100644 --- a/src/main/java/twilightforest/item/ItemTFSteeleafAxe.java +++ b/src/main/java/twilightforest/item/ItemTFSteeleafAxe.java @@ -24,7 +24,7 @@ protected ItemTFSteeleafAxe(Item.ToolMaterial par2EnumToolMaterial) { * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) */ @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { ItemStack istack = new ItemStack(par1, 1, 0); istack.addEnchantment(Enchantment.efficiency, 2); par3List.add(istack); diff --git a/src/main/java/twilightforest/item/ItemTFSteeleafPick.java b/src/main/java/twilightforest/item/ItemTFSteeleafPick.java index 2c6e05fa42..50cac975d8 100644 --- a/src/main/java/twilightforest/item/ItemTFSteeleafPick.java +++ b/src/main/java/twilightforest/item/ItemTFSteeleafPick.java @@ -23,9 +23,8 @@ protected ItemTFSteeleafPick(Item.ToolMaterial par2EnumToolMaterial) { /** * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) */ - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { ItemStack istack = new ItemStack(par1, 1, 0); istack.addEnchantment(Enchantment.fortune, 2); par3List.add(istack); diff --git a/src/main/java/twilightforest/item/ItemTFSteeleafShovel.java b/src/main/java/twilightforest/item/ItemTFSteeleafShovel.java index 1a527f9d4f..27d69ca0f9 100644 --- a/src/main/java/twilightforest/item/ItemTFSteeleafShovel.java +++ b/src/main/java/twilightforest/item/ItemTFSteeleafShovel.java @@ -24,8 +24,7 @@ public ItemTFSteeleafShovel(Item.ToolMaterial par2EnumToolMaterial) { * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) */ @Override - @SuppressWarnings({ "rawtypes", "unchecked" }) - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { ItemStack istack = new ItemStack(par1, 1, 0); istack.addEnchantment(Enchantment.efficiency, 2); par3List.add(istack); diff --git a/src/main/java/twilightforest/item/ItemTFSteeleafSword.java b/src/main/java/twilightforest/item/ItemTFSteeleafSword.java index 1650e8c37f..b4443c6922 100644 --- a/src/main/java/twilightforest/item/ItemTFSteeleafSword.java +++ b/src/main/java/twilightforest/item/ItemTFSteeleafSword.java @@ -24,8 +24,7 @@ public ItemTFSteeleafSword(Item.ToolMaterial par2EnumToolMaterial) { * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) */ @Override - @SuppressWarnings({ "rawtypes", "unchecked" }) - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { ItemStack istack = new ItemStack(par1, 1, 0); istack.addEnchantment(Enchantment.looting, 2); par3List.add(istack); diff --git a/src/main/java/twilightforest/item/ItemTFTransformPowder.java b/src/main/java/twilightforest/item/ItemTFTransformPowder.java index 7a1d2b5129..29584f6557 100644 --- a/src/main/java/twilightforest/item/ItemTFTransformPowder.java +++ b/src/main/java/twilightforest/item/ItemTFTransformPowder.java @@ -48,7 +48,7 @@ protected ItemTFTransformPowder() { this.maxStackSize = 64; this.setCreativeTab(TFItems.creativeTab); - transformMap = new HashMap, Class>(); + transformMap = new HashMap<>(); addTwoWayTransformation(EntityTFMinotaur.class, EntityPigZombie.class); addTwoWayTransformation(EntityTFDeer.class, EntityCow.class); diff --git a/src/main/java/twilightforest/item/ItemTFTrophy.java b/src/main/java/twilightforest/item/ItemTFTrophy.java index c4152274ee..f5012a112d 100644 --- a/src/main/java/twilightforest/item/ItemTFTrophy.java +++ b/src/main/java/twilightforest/item/ItemTFTrophy.java @@ -37,8 +37,7 @@ public ItemTFTrophy() { /** * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { for (int j = 0; j < trophyTypes.length; ++j) { par3List.add(new ItemStack(par1, 1, j)); } @@ -100,8 +99,7 @@ public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, TileEntity tileEntity = world.getTileEntity(x, y, z); - if (tileEntity != null && tileEntity instanceof TileEntitySkull) { - TileEntitySkull skull = ((TileEntitySkull) tileEntity); + if (tileEntity != null && tileEntity instanceof TileEntitySkull skull) { // use NBT method to set skulltype in order to have 1.7.10 compatibility NBTTagCompound tags = new NBTTagCompound(); diff --git a/src/main/java/twilightforest/item/ItemTFTwilightWand.java b/src/main/java/twilightforest/item/ItemTFTwilightWand.java index 28be84dad5..017559b8c3 100644 --- a/src/main/java/twilightforest/item/ItemTFTwilightWand.java +++ b/src/main/java/twilightforest/item/ItemTFTwilightWand.java @@ -95,10 +95,10 @@ public EnumRarity getRarity(ItemStack par1ItemStack) { /** * Display charges left in tooltip */ - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, + boolean par4) { super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4); par3List.add((par1ItemStack.getMaxDamage() - par1ItemStack.getItemDamage()) + " charges left"); } diff --git a/src/main/java/twilightforest/item/ItemTFYetiArmor.java b/src/main/java/twilightforest/item/ItemTFYetiArmor.java index ec3e4540f3..a87df53e0b 100644 --- a/src/main/java/twilightforest/item/ItemTFYetiArmor.java +++ b/src/main/java/twilightforest/item/ItemTFYetiArmor.java @@ -47,16 +47,10 @@ public EnumRarity getRarity(ItemStack par1ItemStack) { * @return Path of texture to bind, or null to use default */ public String getArmorTexture(ItemStack itemstack, Entity entity, int slot, String layer) { - switch (slot) { - case 0: - case 3: - default: - return TwilightForestMod.ARMOR_DIR + "yetiarmor_1.png"; - case 1: - case 2: - return TwilightForestMod.ARMOR_DIR + "yetiarmor_2.png"; - - } + return switch (slot) { + default -> TwilightForestMod.ARMOR_DIR + "yetiarmor_1.png"; + case 1, 2 -> TwilightForestMod.ARMOR_DIR + "yetiarmor_2.png"; + }; } /** @@ -67,15 +61,11 @@ public String getArmorTexture(ItemStack itemstack, Entity entity, int slot, Stri public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { ItemStack istack = new ItemStack(item, 1, 0); switch (this.armorType) { - case 0: - case 1: - case 2: - istack.addEnchantment(Enchantment.protection, 2); - break; - case 3: + case 0, 1, 2 -> istack.addEnchantment(Enchantment.protection, 2); + case 3 -> { istack.addEnchantment(Enchantment.protection, 2); istack.addEnchantment(Enchantment.featherFalling, 4); - break; + } } itemList.add(istack); } @@ -118,7 +108,8 @@ public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemSta */ @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, + boolean par4) { super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4); par3List.add(StatCollector.translateToLocal(getUnlocalizedName() + ".tooltip")); } diff --git a/src/main/java/twilightforest/item/ItemTFZombieWand.java b/src/main/java/twilightforest/item/ItemTFZombieWand.java index 5f30ef9d43..bfb899198e 100644 --- a/src/main/java/twilightforest/item/ItemTFZombieWand.java +++ b/src/main/java/twilightforest/item/ItemTFZombieWand.java @@ -110,9 +110,9 @@ public EnumRarity getRarity(ItemStack par1ItemStack) { /** * Display charges left in tooltip */ - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, + boolean par4) { par3List.add((par1ItemStack.getMaxDamage() - par1ItemStack.getItemDamage()) + " charges left"); } diff --git a/src/main/java/twilightforest/item/TFRecipes.java b/src/main/java/twilightforest/item/TFRecipes.java index 7e04105cb7..9c77c5fd1a 100644 --- a/src/main/java/twilightforest/item/TFRecipes.java +++ b/src/main/java/twilightforest/item/TFRecipes.java @@ -52,359 +52,539 @@ public static void registerRecipes() { GameRegistry.addSmelting(TFBlocks.magicLog, new ItemStack(Items.coal, 1, 1), 0.1F); // recipes - GameRegistry.addRecipe( - new ItemStack(TFBlocks.plank, 4, 0), - new Object[] { "w", 'w', new ItemStack(TFBlocks.log, 1, 0) }); - GameRegistry.addRecipe( - new ItemStack(TFBlocks.plank, 4, 1), - new Object[] { "w", 'w', new ItemStack(TFBlocks.log, 1, 1) }); - GameRegistry.addRecipe( - new ItemStack(TFBlocks.plank, 4, 2), - new Object[] { "w", 'w', new ItemStack(TFBlocks.log, 1, 2) }); - GameRegistry.addRecipe( - new ItemStack(TFBlocks.plank, 4, 3), - new Object[] { "w", 'w', new ItemStack(TFBlocks.log, 1, 3) }); - GameRegistry.addRecipe( - new ItemStack(TFBlocks.plank, 4, 4), - new Object[] { "w", 'w', new ItemStack(TFBlocks.magicLog, 1, 0) }); - GameRegistry.addRecipe( - new ItemStack(TFBlocks.plank, 4, 5), - new Object[] { "w", 'w', new ItemStack(TFBlocks.magicLog, 1, 1) }); - GameRegistry.addRecipe( - new ItemStack(TFBlocks.plank, 4, 6), - new Object[] { "w", 'w', new ItemStack(TFBlocks.magicLog, 1, 2) }); - GameRegistry.addRecipe( - new ItemStack(TFBlocks.plank, 4, 7), - new Object[] { "w", 'w', new ItemStack(TFBlocks.magicLog, 1, 3) }); + GameRegistry.addRecipe(new ItemStack(TFBlocks.plank, 4, 0), "w", 'w', new ItemStack(TFBlocks.log, 1, 0)); + GameRegistry.addRecipe(new ItemStack(TFBlocks.plank, 4, 1), "w", 'w', new ItemStack(TFBlocks.log, 1, 1)); + GameRegistry.addRecipe(new ItemStack(TFBlocks.plank, 4, 2), "w", 'w', new ItemStack(TFBlocks.log, 1, 2)); + GameRegistry.addRecipe(new ItemStack(TFBlocks.plank, 4, 3), "w", 'w', new ItemStack(TFBlocks.log, 1, 3)); + GameRegistry.addRecipe(new ItemStack(TFBlocks.plank, 4, 4), "w", 'w', new ItemStack(TFBlocks.magicLog, 1, 0)); + GameRegistry.addRecipe(new ItemStack(TFBlocks.plank, 4, 5), "w", 'w', new ItemStack(TFBlocks.magicLog, 1, 1)); + GameRegistry.addRecipe(new ItemStack(TFBlocks.plank, 4, 6), "w", 'w', new ItemStack(TFBlocks.magicLog, 1, 2)); + GameRegistry.addRecipe(new ItemStack(TFBlocks.plank, 4, 7), "w", 'w', new ItemStack(TFBlocks.magicLog, 1, 3)); addEnchantedRecipe( TFItems.plateNaga, Enchantment.fireProtection, 3, - new Object[] { "# #", "###", "###", '#', TFItems.nagaScale }); - addEnchantedRecipe( - TFItems.legsNaga, - Enchantment.protection, - 3, - new Object[] { "###", "# #", "# #", '#', TFItems.nagaScale }); + "# #", + "###", + "###", + '#', + TFItems.nagaScale); + addEnchantedRecipe(TFItems.legsNaga, Enchantment.protection, 3, "###", "# #", "# #", '#', TFItems.nagaScale); - GameRegistry.addShapelessRecipe( - new ItemStack(TFBlocks.fireflyJar, 1, 0), - new Object[] { TFBlocks.firefly, Items.glass_bottle }); + GameRegistry.addShapelessRecipe(new ItemStack(TFBlocks.fireflyJar, 1, 0), TFBlocks.firefly, Items.glass_bottle); GameRegistry.addShapelessRecipe( new ItemStack(TFItems.scepterTwilight), - new Object[] { new ItemStack(TFItems.scepterTwilight, 1, TFItems.scepterTwilight.getMaxDamage()), - Items.ender_pearl }); + new ItemStack(TFItems.scepterTwilight, 1, TFItems.scepterTwilight.getMaxDamage()), + Items.ender_pearl); GameRegistry.addShapelessRecipe( new ItemStack(TFItems.scepterLifeDrain), - new Object[] { new ItemStack(TFItems.scepterLifeDrain, 1, TFItems.scepterLifeDrain.getMaxDamage()), - Items.fermented_spider_eye }); + new ItemStack(TFItems.scepterLifeDrain, 1, TFItems.scepterLifeDrain.getMaxDamage()), + Items.fermented_spider_eye); // aah, why are there so many potions of strength GameRegistry.addShapelessRecipe( new ItemStack(TFItems.scepterZombie), - new Object[] { new ItemStack(TFItems.scepterZombie, 1, TFItems.scepterZombie.getMaxDamage()), - new ItemStack(Items.rotten_flesh), new ItemStack(Items.potionitem, 1, 16281) }); + new ItemStack(TFItems.scepterZombie, 1, TFItems.scepterZombie.getMaxDamage()), + new ItemStack(Items.rotten_flesh), + new ItemStack(Items.potionitem, 1, 16281)); GameRegistry.addShapelessRecipe( new ItemStack(TFItems.scepterZombie), - new Object[] { new ItemStack(TFItems.scepterZombie, 1, TFItems.scepterZombie.getMaxDamage()), - new ItemStack(Items.rotten_flesh), new ItemStack(Items.potionitem, 1, 16313) }); + new ItemStack(TFItems.scepterZombie, 1, TFItems.scepterZombie.getMaxDamage()), + new ItemStack(Items.rotten_flesh), + new ItemStack(Items.potionitem, 1, 16313)); GameRegistry.addShapelessRecipe( new ItemStack(TFItems.scepterZombie), - new Object[] { new ItemStack(TFItems.scepterZombie, 1, TFItems.scepterZombie.getMaxDamage()), - new ItemStack(Items.rotten_flesh), new ItemStack(Items.potionitem, 1, 16345) }); + new ItemStack(TFItems.scepterZombie, 1, TFItems.scepterZombie.getMaxDamage()), + new ItemStack(Items.rotten_flesh), + new ItemStack(Items.potionitem, 1, 16345)); GameRegistry.addShapelessRecipe( new ItemStack(TFItems.scepterZombie), - new Object[] { new ItemStack(TFItems.scepterZombie, 1, TFItems.scepterZombie.getMaxDamage()), - new ItemStack(Items.rotten_flesh), new ItemStack(Items.potionitem, 1, 16377) }); + new ItemStack(TFItems.scepterZombie, 1, TFItems.scepterZombie.getMaxDamage()), + new ItemStack(Items.rotten_flesh), + new ItemStack(Items.potionitem, 1, 16377)); GameRegistry.addShapelessRecipe( new ItemStack(TFItems.scepterZombie), - new Object[] { new ItemStack(TFItems.scepterZombie, 1, TFItems.scepterZombie.getMaxDamage()), - new ItemStack(Items.rotten_flesh), new ItemStack(Items.potionitem, 1, 8201) }); + new ItemStack(TFItems.scepterZombie, 1, TFItems.scepterZombie.getMaxDamage()), + new ItemStack(Items.rotten_flesh), + new ItemStack(Items.potionitem, 1, 8201)); GameRegistry.addShapelessRecipe( new ItemStack(TFItems.scepterZombie), - new Object[] { new ItemStack(TFItems.scepterZombie, 1, TFItems.scepterZombie.getMaxDamage()), - new ItemStack(Items.rotten_flesh), new ItemStack(Items.potionitem, 1, 8265) }); + new ItemStack(TFItems.scepterZombie, 1, TFItems.scepterZombie.getMaxDamage()), + new ItemStack(Items.rotten_flesh), + new ItemStack(Items.potionitem, 1, 8265)); GameRegistry.addShapelessRecipe( new ItemStack(TFItems.scepterZombie), - new Object[] { new ItemStack(TFItems.scepterZombie, 1, TFItems.scepterZombie.getMaxDamage()), - new ItemStack(Items.rotten_flesh), new ItemStack(Items.potionitem, 1, 8233) }); + new ItemStack(TFItems.scepterZombie, 1, TFItems.scepterZombie.getMaxDamage()), + new ItemStack(Items.rotten_flesh), + new ItemStack(Items.potionitem, 1, 8233)); GameRegistry.addShapelessRecipe( new ItemStack(TFItems.magicMapFocus), - new Object[] { TFItems.feather, TFItems.torchberries, Items.glowstone_dust }); + TFItems.feather, + TFItems.torchberries, + Items.glowstone_dust); GameRegistry.addRecipe( new ItemStack(TFItems.emptyMagicMap), - new Object[] { "###", "#X#", "###", '#', Items.paper, 'X', TFItems.magicMapFocus }); + "###", + "#X#", + "###", + '#', + Items.paper, + 'X', + TFItems.magicMapFocus); GameRegistry.addRecipe( new ItemStack(TFItems.emptyMazeMap), - new Object[] { "###", "#X#", "###", '#', Items.paper, 'X', TFItems.mazeMapFocus }); + "###", + "#X#", + "###", + '#', + Items.paper, + 'X', + TFItems.mazeMapFocus); GameRegistry.addShapelessRecipe( new ItemStack(TFItems.emptyOreMap), - new Object[] { new ItemStack(TFItems.mazeMap, 1, Short.MAX_VALUE), Blocks.gold_block, - Blocks.diamond_block, Blocks.iron_block }); + new ItemStack(TFItems.mazeMap, 1, Short.MAX_VALUE), + Blocks.gold_block, + Blocks.diamond_block, + Blocks.iron_block); GameRegistry.addShapelessRecipe( new ItemStack(TFItems.emptyOreMap), - new Object[] { new ItemStack(TFItems.emptyMazeMap, 1, Short.MAX_VALUE), Blocks.gold_block, - Blocks.diamond_block, Blocks.iron_block }); + new ItemStack(TFItems.emptyMazeMap, 1, Short.MAX_VALUE), + Blocks.gold_block, + Blocks.diamond_block, + Blocks.iron_block); GameRegistry.addRecipe( new ItemStack(Items.arrow, 4), - new Object[] { "X", "#", "Y", 'Y', TFItems.feather, 'X', Items.flint, '#', Items.stick }); + "X", + "#", + "Y", + 'Y', + TFItems.feather, + 'X', + Items.flint, + '#', + Items.stick); GameRegistry.addShapelessRecipe( new ItemStack(Items.stick), - new Object[] { new ItemStack(TFBlocks.plant, 1, BlockTFPlant.META_ROOT_STRAND) }); - GameRegistry.addRecipe( - new ItemStack(Blocks.torch, 5), - new Object[] { "B", "S", 'B', TFItems.torchberries, 'S', Items.stick }); + new ItemStack(TFBlocks.plant, 1, BlockTFPlant.META_ROOT_STRAND)); + GameRegistry.addRecipe(new ItemStack(Blocks.torch, 5), "B", "S", 'B', TFItems.torchberries, 'S', Items.stick); GameRegistry.addShapelessRecipe( new ItemStack(TFItems.ironwoodRaw), - new Object[] { TFItems.liveRoot, Items.iron_ingot, Items.gold_nugget }); + TFItems.liveRoot, + Items.iron_ingot, + Items.gold_nugget); GameRegistry.addSmelting(TFItems.ironwoodRaw, new ItemStack(TFItems.ironwoodIngot, 2), 1.0F); - addEnchantedRecipe( - TFItems.ironwoodHelm, - Enchantment.aquaAffinity, - 1, - new Object[] { "###", "# #", '#', TFItems.ironwoodIngot }); + addEnchantedRecipe(TFItems.ironwoodHelm, Enchantment.aquaAffinity, 1, "###", "# #", '#', TFItems.ironwoodIngot); addEnchantedRecipe( TFItems.ironwoodPlate, Enchantment.protection, 1, - new Object[] { "# #", "###", "###", '#', TFItems.ironwoodIngot }); + "# #", + "###", + "###", + '#', + TFItems.ironwoodIngot); addEnchantedRecipe( TFItems.ironwoodLegs, Enchantment.protection, 1, - new Object[] { "###", "# #", "# #", '#', TFItems.ironwoodIngot }); + "###", + "# #", + "# #", + '#', + TFItems.ironwoodIngot); addEnchantedRecipe( TFItems.ironwoodBoots, Enchantment.featherFalling, 1, - new Object[] { "# #", "# #", '#', TFItems.ironwoodIngot }); + "# #", + "# #", + '#', + TFItems.ironwoodIngot); addEnchantedRecipe( TFItems.ironwoodSword, Enchantment.knockback, 1, - new Object[] { "#", "#", "X", '#', TFItems.ironwoodIngot, 'X', Items.stick }); + "#", + "#", + "X", + '#', + TFItems.ironwoodIngot, + 'X', + Items.stick); addEnchantedRecipe( TFItems.ironwoodShovel, Enchantment.unbreaking, 1, - new Object[] { "#", "X", "X", '#', TFItems.ironwoodIngot, 'X', Items.stick }); + "#", + "X", + "X", + '#', + TFItems.ironwoodIngot, + 'X', + Items.stick); addEnchantedRecipe( TFItems.ironwoodPick, Enchantment.efficiency, 1, - new Object[] { "###", " X ", " X ", '#', TFItems.ironwoodIngot, 'X', Items.stick }); + "###", + " X ", + " X ", + '#', + TFItems.ironwoodIngot, + 'X', + Items.stick); addEnchantedRecipe( TFItems.ironwoodAxe, Enchantment.fortune, 1, - new Object[] { "##", "#X", " X", '#', TFItems.ironwoodIngot, 'X', Items.stick }); + "##", + "#X", + " X", + '#', + TFItems.ironwoodIngot, + 'X', + Items.stick); addEnchantedRecipe( TFItems.ironwoodHoe, null, 0, - new Object[] { "##", " X", " X", '#', TFItems.ironwoodIngot, 'X', Items.stick }); + "##", + " X", + " X", + '#', + TFItems.ironwoodIngot, + 'X', + Items.stick); GameRegistry.addRecipe( new ItemStack(TFBlocks.uncraftingTable), - new Object[] { "###", "#X#", "###", '#', Blocks.crafting_table, 'X', TFItems.mazeMapFocus }); + "###", + "#X#", + "###", + '#', + Blocks.crafting_table, + 'X', + TFItems.mazeMapFocus); GameRegistry.addSmelting(TFItems.venisonRaw, new ItemStack(TFItems.venisonCooked), 0.3F); - GameRegistry.addShapelessRecipe( - new ItemStack(TFItems.fieryIngot), - new Object[] { TFItems.fieryBlood, Items.iron_ingot }); - GameRegistry.addShapelessRecipe( - new ItemStack(TFItems.fieryIngot), - new Object[] { TFItems.fieryTears, Items.iron_ingot }); - GameRegistry - .addRecipe(new ItemStack(TFItems.fieryHelm), new Object[] { "###", "# #", '#', TFItems.fieryIngot }); - GameRegistry.addRecipe( - new ItemStack(TFItems.fieryPlate), - new Object[] { "# #", "###", "###", '#', TFItems.fieryIngot }); - GameRegistry.addRecipe( - new ItemStack(TFItems.fieryLegs), - new Object[] { "###", "# #", "# #", '#', TFItems.fieryIngot }); - GameRegistry - .addRecipe(new ItemStack(TFItems.fieryBoots), new Object[] { "# #", "# #", '#', TFItems.fieryIngot }); + GameRegistry.addShapelessRecipe(new ItemStack(TFItems.fieryIngot), TFItems.fieryBlood, Items.iron_ingot); + GameRegistry.addShapelessRecipe(new ItemStack(TFItems.fieryIngot), TFItems.fieryTears, Items.iron_ingot); + GameRegistry.addRecipe(new ItemStack(TFItems.fieryHelm), "###", "# #", '#', TFItems.fieryIngot); + GameRegistry.addRecipe(new ItemStack(TFItems.fieryPlate), "# #", "###", "###", '#', TFItems.fieryIngot); + GameRegistry.addRecipe(new ItemStack(TFItems.fieryLegs), "###", "# #", "# #", '#', TFItems.fieryIngot); + GameRegistry.addRecipe(new ItemStack(TFItems.fieryBoots), "# #", "# #", '#', TFItems.fieryIngot); addEnchantedRecipe( TFItems.fierySword, Enchantment.fireAspect, 2, - new Object[] { "#", "#", "X", '#', TFItems.fieryIngot, 'X', Items.blaze_rod }); + "#", + "#", + "X", + '#', + TFItems.fieryIngot, + 'X', + Items.blaze_rod); GameRegistry.addRecipe( new ItemStack(TFItems.fieryPick), - new Object[] { "###", " X ", " X ", '#', TFItems.fieryIngot, 'X', Items.blaze_rod }); + "###", + " X ", + " X ", + '#', + TFItems.fieryIngot, + 'X', + Items.blaze_rod); addEnchantedRecipe( TFItems.steeleafHelm, Enchantment.projectileProtection, 2, - new Object[] { "###", "# #", '#', TFItems.steeleafIngot }); + "###", + "# #", + '#', + TFItems.steeleafIngot); addEnchantedRecipe( TFItems.steeleafPlate, Enchantment.blastProtection, 2, - new Object[] { "# #", "###", "###", '#', TFItems.steeleafIngot }); + "# #", + "###", + "###", + '#', + TFItems.steeleafIngot); addEnchantedRecipe( TFItems.steeleafLegs, Enchantment.fireProtection, 2, - new Object[] { "###", "# #", "# #", '#', TFItems.steeleafIngot }); + "###", + "# #", + "# #", + '#', + TFItems.steeleafIngot); addEnchantedRecipe( TFItems.steeleafBoots, Enchantment.featherFalling, 2, - new Object[] { "# #", "# #", '#', TFItems.steeleafIngot }); + "# #", + "# #", + '#', + TFItems.steeleafIngot); addEnchantedRecipe( TFItems.steeleafSword, Enchantment.looting, 2, - new Object[] { "#", "#", "X", '#', TFItems.steeleafIngot, 'X', Items.stick }); + "#", + "#", + "X", + '#', + TFItems.steeleafIngot, + 'X', + Items.stick); addEnchantedRecipe( TFItems.steeleafShovel, Enchantment.efficiency, 2, - new Object[] { "#", "X", "X", '#', TFItems.steeleafIngot, 'X', Items.stick }); + "#", + "X", + "X", + '#', + TFItems.steeleafIngot, + 'X', + Items.stick); addEnchantedRecipe( TFItems.steeleafPick, Enchantment.fortune, 2, - new Object[] { "###", " X ", " X ", '#', TFItems.steeleafIngot, 'X', Items.stick }); + "###", + " X ", + " X ", + '#', + TFItems.steeleafIngot, + 'X', + Items.stick); addEnchantedRecipe( TFItems.steeleafAxe, Enchantment.efficiency, 2, - new Object[] { "##", "#X", " X", '#', TFItems.steeleafIngot, 'X', Items.stick }); + "##", + "#X", + " X", + '#', + TFItems.steeleafIngot, + 'X', + Items.stick); addEnchantedRecipe( TFItems.steeleafHoe, null, 0, - new Object[] { "##", " X", " X", '#', TFItems.steeleafIngot, 'X', Items.stick }); + "##", + " X", + " X", + '#', + TFItems.steeleafIngot, + 'X', + Items.stick); GameRegistry.addSmelting(TFItems.meefRaw, new ItemStack(TFItems.meefSteak), 0.3F); GameRegistry.addShapelessRecipe( new ItemStack(TFItems.moonwormQueen), - new Object[] { new ItemStack(TFItems.moonwormQueen, 1, Short.MAX_VALUE), TFItems.torchberries, - TFItems.torchberries, TFItems.torchberries }); + new ItemStack(TFItems.moonwormQueen, 1, Short.MAX_VALUE), + TFItems.torchberries, + TFItems.torchberries, + TFItems.torchberries); GameRegistry.addRecipe( new ItemStack(TFItems.emptyMagicMap), - new Object[] { "###", "#X#", "###", '#', Items.paper, 'X', TFItems.magicMapFocus }); + "###", + "#X#", + "###", + '#', + Items.paper, + 'X', + TFItems.magicMapFocus); GameRegistry.addShapelessRecipe( new ItemStack(TFItems.charmOfKeeping2), - new Object[] { TFItems.charmOfKeeping1, TFItems.charmOfKeeping1, TFItems.charmOfKeeping1, - TFItems.charmOfKeeping1 }); + TFItems.charmOfKeeping1, + TFItems.charmOfKeeping1, + TFItems.charmOfKeeping1, + TFItems.charmOfKeeping1); GameRegistry.addShapelessRecipe( new ItemStack(TFItems.charmOfKeeping3), - new Object[] { TFItems.charmOfKeeping2, TFItems.charmOfKeeping2, TFItems.charmOfKeeping2, - TFItems.charmOfKeeping2 }); + TFItems.charmOfKeeping2, + TFItems.charmOfKeeping2, + TFItems.charmOfKeeping2, + TFItems.charmOfKeeping2); GameRegistry.addShapelessRecipe( new ItemStack(TFItems.charmOfLife2), - new Object[] { TFItems.charmOfLife1, TFItems.charmOfLife1, TFItems.charmOfLife1, - TFItems.charmOfLife1 }); + TFItems.charmOfLife1, + TFItems.charmOfLife1, + TFItems.charmOfLife1, + TFItems.charmOfLife1); GameRegistry.addRecipe(new TFMapCloningRecipe(TFItems.magicMap, TFItems.emptyMagicMap)); GameRegistry.addRecipe(new TFMapCloningRecipe(TFItems.mazeMap, TFItems.emptyMazeMap)); GameRegistry.addRecipe(new TFMapCloningRecipe(TFItems.oreMap, TFItems.emptyOreMap)); // dark tower recipes - GameRegistry.addRecipe( - new ItemStack(TFBlocks.towerWood, 4, 0), - new Object[] { "##", "##", '#', new ItemStack(TFBlocks.log, 1, 3) }); + GameRegistry + .addRecipe(new ItemStack(TFBlocks.towerWood, 4, 0), "##", "##", '#', new ItemStack(TFBlocks.log, 1, 3)); GameRegistry.addRecipe( new ItemStack(TFBlocks.towerWood, 3, 1), - new Object[] { "#", "#", "#", '#', new ItemStack(TFBlocks.towerWood, 1, 0) }); + "#", + "#", + "#", + '#', + new ItemStack(TFBlocks.towerWood, 1, 0)); GameRegistry.addRecipe( new ItemStack(TFItems.carminite), - new Object[] { "brb", "rgr", "brb", 'b', new ItemStack(TFItems.borerEssence), 'r', - new ItemStack(Items.redstone), 'g', new ItemStack(Items.ghast_tear) }); + "brb", + "rgr", + "brb", + 'b', + new ItemStack(TFItems.borerEssence), + 'r', + new ItemStack(Items.redstone), + 'g', + new ItemStack(Items.ghast_tear)); GameRegistry.addRecipe( new ItemStack(TFItems.carminite), - new Object[] { "rbr", "bgb", "rbr", 'b', new ItemStack(TFItems.borerEssence), 'r', - new ItemStack(Items.redstone), 'g', new ItemStack(Items.ghast_tear) }); + "rbr", + "bgb", + "rbr", + 'b', + new ItemStack(TFItems.borerEssence), + 'r', + new ItemStack(Items.redstone), + 'g', + new ItemStack(Items.ghast_tear)); GameRegistry.addRecipe( new ItemStack(TFBlocks.towerDevice, 8, BlockTFTowerDevice.META_VANISH_INACTIVE), - new Object[] { "ewe", "wcw", "ewe", 'e', new ItemStack(TFBlocks.towerWood, 1, 1), 'w', - new ItemStack(TFBlocks.towerWood, 1, 0), 'c', new ItemStack(TFItems.carminite) }); + "ewe", + "wcw", + "ewe", + 'e', + new ItemStack(TFBlocks.towerWood, 1, 1), + 'w', + new ItemStack(TFBlocks.towerWood, 1, 0), + 'c', + new ItemStack(TFItems.carminite)); GameRegistry.addRecipe( new ItemStack(TFBlocks.towerDevice, 2, BlockTFTowerDevice.META_REAPPEARING_INACTIVE), - new Object[] { "ere", "rcr", "ere", 'e', new ItemStack(TFBlocks.towerWood, 1, 1), 'r', - new ItemStack(Items.redstone), 'c', new ItemStack(TFItems.carminite) }); + "ere", + "rcr", + "ere", + 'e', + new ItemStack(TFBlocks.towerWood, 1, 1), + 'r', + new ItemStack(Items.redstone), + 'c', + new ItemStack(TFItems.carminite)); GameRegistry.addRecipe( new ItemStack(TFBlocks.towerDevice, 1, BlockTFTowerDevice.META_BUILDER_INACTIVE), - new Object[] { "ece", "cdc", "ece", 'e', new ItemStack(TFBlocks.towerWood, 1, 1), 'd', - new ItemStack(Blocks.dispenser), 'c', new ItemStack(TFItems.carminite) }); + "ece", + "cdc", + "ece", + 'e', + new ItemStack(TFBlocks.towerWood, 1, 1), + 'd', + new ItemStack(Blocks.dispenser), + 'c', + new ItemStack(TFItems.carminite)); GameRegistry.addRecipe( new ItemStack(TFBlocks.towerDevice, 1, BlockTFTowerDevice.META_REACTOR_INACTIVE), - new Object[] { "ece", "coc", "ece", 'e', new ItemStack(TFBlocks.towerWood, 1, 1), 'o', - new ItemStack(Blocks.redstone_ore), 'c', new ItemStack(TFItems.carminite) }); + "ece", + "coc", + "ece", + 'e', + new ItemStack(TFBlocks.towerWood, 1, 1), + 'o', + new ItemStack(Blocks.redstone_ore), + 'c', + new ItemStack(TFItems.carminite)); GameRegistry.addRecipe( new ItemStack(TFBlocks.fireJet, 1, BlockTFFireJet.META_ENCASED_SMOKER_OFF), - new Object[] { "ere", "rsr", "ere", 'e', new ItemStack(TFBlocks.towerWood, 1, 1), 'r', - new ItemStack(Items.redstone), 's', - new ItemStack(TFBlocks.fireJet, 1, BlockTFFireJet.META_SMOKER) }); + "ere", + "rsr", + "ere", + 'e', + new ItemStack(TFBlocks.towerWood, 1, 1), + 'r', + new ItemStack(Items.redstone), + 's', + new ItemStack(TFBlocks.fireJet, 1, BlockTFFireJet.META_SMOKER)); GameRegistry.addRecipe( new ItemStack(TFBlocks.fireJet, 1, BlockTFFireJet.META_ENCASED_JET_IDLE), - new Object[] { "ere", "rjr", "lll", 'e', new ItemStack(TFBlocks.towerWood, 1, 1), 'r', - new ItemStack(Items.redstone), 'l', new ItemStack(Items.lava_bucket), 'j', - new ItemStack(TFBlocks.fireJet, 1, BlockTFFireJet.META_JET_IDLE) }); - - GameRegistry.addRecipe( - new ItemStack(TFItems.shardCluster), - new Object[] { "###", "###", "###", '#', TFItems.armorShard }); + "ere", + "rjr", + "lll", + 'e', + new ItemStack(TFBlocks.towerWood, 1, 1), + 'r', + new ItemStack(Items.redstone), + 'l', + new ItemStack(Items.lava_bucket), + 'j', + new ItemStack(TFBlocks.fireJet, 1, BlockTFFireJet.META_JET_IDLE)); + + GameRegistry.addRecipe(new ItemStack(TFItems.shardCluster), "###", "###", "###", '#', TFItems.armorShard); GameRegistry.addSmelting(TFItems.shardCluster, new ItemStack(TFItems.knightMetal), 1.0F); - GameRegistry.addRecipe( - new ItemStack(TFItems.knightlyHelm), - new Object[] { "###", "# #", '#', TFItems.knightMetal }); - GameRegistry.addRecipe( - new ItemStack(TFItems.knightlyPlate), - new Object[] { "# #", "###", "###", '#', TFItems.knightMetal }); - GameRegistry.addRecipe( - new ItemStack(TFItems.knightlyLegs), - new Object[] { "###", "# #", "# #", '#', TFItems.knightMetal }); - GameRegistry.addRecipe( - new ItemStack(TFItems.knightlyBoots), - new Object[] { "# #", "# #", '#', TFItems.knightMetal }); + GameRegistry.addRecipe(new ItemStack(TFItems.knightlyHelm), "###", "# #", '#', TFItems.knightMetal); + GameRegistry.addRecipe(new ItemStack(TFItems.knightlyPlate), "# #", "###", "###", '#', TFItems.knightMetal); + GameRegistry.addRecipe(new ItemStack(TFItems.knightlyLegs), "###", "# #", "# #", '#', TFItems.knightMetal); + GameRegistry.addRecipe(new ItemStack(TFItems.knightlyBoots), "# #", "# #", '#', TFItems.knightMetal); GameRegistry.addRecipe( new ItemStack(TFItems.knightlySword), - new Object[] { "#", "#", "X", '#', TFItems.knightMetal, 'X', Items.stick }); + "#", + "#", + "X", + '#', + TFItems.knightMetal, + 'X', + Items.stick); GameRegistry.addRecipe( new ItemStack(TFItems.knightlyPick), - new Object[] { "###", " X ", " X ", '#', TFItems.knightMetal, 'X', Items.stick }); + "###", + " X ", + " X ", + '#', + TFItems.knightMetal, + 'X', + Items.stick); GameRegistry.addRecipe( new ItemStack(TFItems.knightlyAxe), - new Object[] { "##", "#X", " X", '#', TFItems.knightMetal, 'X', Items.stick }); + "##", + "#X", + " X", + '#', + TFItems.knightMetal, + 'X', + Items.stick); GameRegistry.addRecipe( new ItemStack(TFItems.knightlyAxe), - new Object[] { "##", "X#", "X ", '#', TFItems.knightMetal, 'X', Items.stick }); - - addEnchantedRecipe( - TFItems.yetiHelm, - Enchantment.protection, - 2, - new Object[] { "###", "# #", '#', TFItems.alphaFur }); - addEnchantedRecipe( - TFItems.yetiPlate, - Enchantment.protection, - 2, - new Object[] { "# #", "###", "###", '#', TFItems.alphaFur }); - addEnchantedRecipe( - TFItems.yetiLegs, - Enchantment.protection, - 2, - new Object[] { "###", "# #", "# #", '#', TFItems.alphaFur }); + "##", + "X#", + "X ", + '#', + TFItems.knightMetal, + 'X', + Items.stick); + + addEnchantedRecipe(TFItems.yetiHelm, Enchantment.protection, 2, "###", "# #", '#', TFItems.alphaFur); + addEnchantedRecipe(TFItems.yetiPlate, Enchantment.protection, 2, "# #", "###", "###", '#', TFItems.alphaFur); + addEnchantedRecipe(TFItems.yetiLegs, Enchantment.protection, 2, "###", "# #", "# #", '#', TFItems.alphaFur); + // noinspection RedundantArrayCreation Ambiguous method call addEnchantedRecipe( TFItems.yetiBoots, Enchantment.protection, @@ -413,54 +593,50 @@ public static void registerRecipes() { 4, new Object[] { "# #", "# #", '#', TFItems.alphaFur }); - GameRegistry - .addRecipe(new ItemStack(TFItems.arcticHelm), new Object[] { "###", "# #", '#', TFItems.arcticFur }); - GameRegistry.addRecipe( - new ItemStack(TFItems.arcticPlate), - new Object[] { "# #", "###", "###", '#', TFItems.arcticFur }); - GameRegistry.addRecipe( - new ItemStack(TFItems.arcticLegs), - new Object[] { "###", "# #", "# #", '#', TFItems.arcticFur }); - GameRegistry - .addRecipe(new ItemStack(TFItems.arcticBoots), new Object[] { "# #", "# #", '#', TFItems.arcticFur }); + GameRegistry.addRecipe(new ItemStack(TFItems.arcticHelm), "###", "# #", '#', TFItems.arcticFur); + GameRegistry.addRecipe(new ItemStack(TFItems.arcticPlate), "# #", "###", "###", '#', TFItems.arcticFur); + GameRegistry.addRecipe(new ItemStack(TFItems.arcticLegs), "###", "# #", "# #", '#', TFItems.arcticFur); + GameRegistry.addRecipe(new ItemStack(TFItems.arcticBoots), "# #", "# #", '#', TFItems.arcticFur); - GameRegistry - .addRecipe(new ItemStack(TFBlocks.auroraSlab, 6, 0), new Object[] { "###", '#', TFBlocks.auroraBlock }); - GameRegistry.addRecipe( - new ItemStack(TFBlocks.auroraPillar, 2, 0), - new Object[] { "#", "#", '#', TFBlocks.auroraBlock }); + GameRegistry.addRecipe(new ItemStack(TFBlocks.auroraSlab, 6, 0), "###", '#', TFBlocks.auroraBlock); + GameRegistry.addRecipe(new ItemStack(TFBlocks.auroraPillar, 2, 0), "#", "#", '#', TFBlocks.auroraBlock); GameRegistry.addRecipe( new ItemStack(TFItems.giantPick), - new Object[] { "###", " X ", " X ", '#', TFBlocks.giantCobble, 'X', TFBlocks.giantLog }); + "###", + " X ", + " X ", + '#', + TFBlocks.giantCobble, + 'X', + TFBlocks.giantLog); GameRegistry.addRecipe( new ItemStack(TFItems.giantSword), - new Object[] { "#", "#", "X", '#', TFBlocks.giantCobble, 'X', TFBlocks.giantLog }); - - GameRegistry.addShapelessRecipe( - new ItemStack(Blocks.cobblestone, 64), - new Object[] { new ItemStack(TFBlocks.giantCobble) }); - GameRegistry.addShapelessRecipe( - new ItemStack(Blocks.planks, 64), - new Object[] { new ItemStack(TFBlocks.giantLog) }); - GameRegistry.addShapelessRecipe( - new ItemStack(Blocks.leaves, 64), - new Object[] { new ItemStack(TFBlocks.giantLeaves) }); - - GameRegistry.addRecipe( - new ItemStack(TFItems.knightmetalRing), - new Object[] { " # ", "# #", " # ", '#', TFItems.knightMetal }); + "#", + "#", + "X", + '#', + TFBlocks.giantCobble, + 'X', + TFBlocks.giantLog); + + GameRegistry.addShapelessRecipe(new ItemStack(Blocks.cobblestone, 64), new ItemStack(TFBlocks.giantCobble)); + GameRegistry.addShapelessRecipe(new ItemStack(Blocks.planks, 64), new ItemStack(TFBlocks.giantLog)); + GameRegistry.addShapelessRecipe(new ItemStack(Blocks.leaves, 64), new ItemStack(TFBlocks.giantLeaves)); + + GameRegistry.addRecipe(new ItemStack(TFItems.knightmetalRing), " # ", "# #", " # ", '#', TFItems.knightMetal); GameRegistry.addShapelessRecipe( new ItemStack(TFItems.chainBlock), - new Object[] { TFItems.knightmetalRing, TFItems.knightMetal, TFItems.knightMetal, TFItems.knightMetal, - TFBlocks.knightmetalStorage }); + TFItems.knightmetalRing, + TFItems.knightMetal, + TFItems.knightMetal, + TFItems.knightMetal, + TFBlocks.knightmetalStorage); - GameRegistry.addShapelessRecipe( - new ItemStack(TFItems.knightMetal, 9), - new Object[] { new ItemStack(TFBlocks.knightmetalStorage) }); - GameRegistry.addRecipe( - new ItemStack(TFBlocks.knightmetalStorage), - new Object[] { "###", "###", "###", '#', TFItems.knightMetal }); + GameRegistry + .addShapelessRecipe(new ItemStack(TFItems.knightMetal, 9), new ItemStack(TFBlocks.knightmetalStorage)); + GameRegistry + .addRecipe(new ItemStack(TFBlocks.knightmetalStorage), "###", "###", "###", '#', TFItems.knightMetal); } diff --git a/src/main/java/twilightforest/structures/ComponentTFHedgeMaze.java b/src/main/java/twilightforest/structures/ComponentTFHedgeMaze.java index f5e9bdf588..27ef04b68b 100644 --- a/src/main/java/twilightforest/structures/ComponentTFHedgeMaze.java +++ b/src/main/java/twilightforest/structures/ComponentTFHedgeMaze.java @@ -66,7 +66,7 @@ public boolean addComponentParts(World world, Random rand, StructureBoundingBox placeBlockAtCurrentPosition(world, Blocks.lit_pumpkin, 0, 29, FLOOR_LEVEL, 50, sbb); int nrooms = MSIZE / 3; - int rcoords[] = new int[nrooms * 2]; + int[] rcoords = new int[nrooms * 2]; for (int i = 0; i < nrooms; i++) { int rx, rz; @@ -174,19 +174,12 @@ private void roomSpawner(World world, Random rand, int x, int z, int diameter, S int rx = x + rand.nextInt(diameter) - (diameter / 2); int rz = z + rand.nextInt(diameter) - (diameter / 2); - String mobID; - - switch (rand.nextInt(3)) { - case 1: - mobID = TFCreatures.getSpawnerNameFor("Swarm Spider"); - break; - case 2: - mobID = TFCreatures.getSpawnerNameFor("Hostile Wolf"); - break; - case 0: - default: - mobID = TFCreatures.getSpawnerNameFor("Hedge Spider"); - } + String mobID = switch (rand.nextInt(3)) { + case 1 -> TFCreatures.getSpawnerNameFor("Swarm Spider"); + case 2 -> TFCreatures.getSpawnerNameFor("Hostile Wolf"); + default -> TFCreatures.getSpawnerNameFor("Hedge Spider"); + }; + placeSpawnerAtCurrentPosition(world, rand, rx, FLOOR_LEVEL, rz, mobID, sbb); } diff --git a/src/main/java/twilightforest/structures/ComponentTFHillMaze.java b/src/main/java/twilightforest/structures/ComponentTFHillMaze.java index c1fff9102b..d1e7b4f884 100644 --- a/src/main/java/twilightforest/structures/ComponentTFHillMaze.java +++ b/src/main/java/twilightforest/structures/ComponentTFHillMaze.java @@ -77,7 +77,7 @@ public boolean addComponentParts(World world, Random rand, StructureBoundingBox maze.setSeed(world.getSeed() + this.boundingBox.minX * this.boundingBox.minZ); int nrooms = getMazeSize() / 3; - int rcoords[] = new int[nrooms * 2]; + int[] rcoords = new int[nrooms * 2]; // add rooms, trying to keep them separate from existing rooms for (int i = 0; i < nrooms; i++) { @@ -186,19 +186,11 @@ private void roomSpawner(World world, Random rand, int x, int z, int diameter, S int rx = x + rand.nextInt(diameter) - (diameter / 2); int rz = z + rand.nextInt(diameter) - (diameter / 2); - String mobID; - - switch (rand.nextInt(3)) { - case 1: - mobID = "Skeleton"; - break; - case 2: - mobID = "Zombie"; - break; - case 0: - default: - mobID = "Spider"; - } + String mobID = switch (rand.nextInt(3)) { + case 1 -> "Skeleton"; + case 2 -> "Zombie"; + default -> "Spider"; + }; placeSpawnerAtCurrentPosition(world, rand, rx, FLOOR_LEVEL, rz, mobID, sbb); } diff --git a/src/main/java/twilightforest/structures/ComponentTFHollowHill.java b/src/main/java/twilightforest/structures/ComponentTFHollowHill.java index 291cfc7a00..b7d5975c59 100644 --- a/src/main/java/twilightforest/structures/ComponentTFHollowHill.java +++ b/src/main/java/twilightforest/structures/ComponentTFHollowHill.java @@ -254,93 +254,56 @@ protected String getMobID(Random rand) { * @return */ protected String getMobID(Random rand, int level) { - switch (level) { - case 1: - return getLevel1Mob(rand); - case 2: - return getLevel2Mob(rand); - case 3: - return getLevel3Mob(rand); - default: + return switch (level) { + case 1 -> getLevel1Mob(rand); + case 2 -> getLevel2Mob(rand); + case 3 -> getLevel3Mob(rand); + default -> // aaah, default: spider! - return "Spider"; - } + "Spider"; + }; } /** * Returns a mob string appropriate for a level 1 hill */ public String getLevel1Mob(Random rand) { - switch (rand.nextInt(10)) { - case 0: - case 1: - case 2: - return TFCreatures.getSpawnerNameFor("Swarm Spider"); - case 3: - case 4: - case 5: - return "Spider"; - case 6: - case 7: - return "Zombie"; - case 8: - return "Silverfish"; - case 9: - return TFCreatures.getSpawnerNameFor("Redcap"); - default: - return TFCreatures.getSpawnerNameFor("Swarm Spider"); - } + return switch (rand.nextInt(10)) { + case 0, 1, 2 -> TFCreatures.getSpawnerNameFor("Swarm Spider"); + case 3, 4, 5 -> "Spider"; + case 6, 7 -> "Zombie"; + case 8 -> "Silverfish"; + case 9 -> TFCreatures.getSpawnerNameFor("Redcap"); + default -> TFCreatures.getSpawnerNameFor("Swarm Spider"); + }; } /** * Returns a mob string appropriate for a level 2 hill */ public String getLevel2Mob(Random rand) { - switch (rand.nextInt(10)) { - case 0: - case 1: - case 2: - return TFCreatures.getSpawnerNameFor("Redcap"); - case 3: - case 4: - case 5: - return "Zombie"; - case 6: - case 7: - return "Skeleton"; - case 8: - return TFCreatures.getSpawnerNameFor("Swarm Spider"); - case 9: - return "CaveSpider"; - default: - return TFCreatures.getSpawnerNameFor("Redcap"); - } + return switch (rand.nextInt(10)) { + case 0, 1, 2 -> TFCreatures.getSpawnerNameFor("Redcap"); + case 3, 4, 5 -> "Zombie"; + case 6, 7 -> "Skeleton"; + case 8 -> TFCreatures.getSpawnerNameFor("Swarm Spider"); + case 9 -> "CaveSpider"; + default -> TFCreatures.getSpawnerNameFor("Redcap"); + }; } /** * Returns a mob string appropriate for a level 3 hill. The level 3 also has 2 mid-air wraith spawners. */ public String getLevel3Mob(Random rand) { - switch (rand.nextInt(11)) { - case 0: - return TFCreatures.getSpawnerNameFor("Slime Beetle"); - case 1: - return TFCreatures.getSpawnerNameFor("Fire Beetle"); - case 2: - return TFCreatures.getSpawnerNameFor("Pinch Beetle"); - case 3: - case 4: - case 5: - return "Skeleton"; - case 6: - case 7: - case 8: - return "CaveSpider"; - case 9: - return "Creeper"; - case 10: - default: - return TFCreatures.getSpawnerNameFor("Twilight Wraith"); - } + return switch (rand.nextInt(11)) { + case 0 -> TFCreatures.getSpawnerNameFor("Slime Beetle"); + case 1 -> TFCreatures.getSpawnerNameFor("Fire Beetle"); + case 2 -> TFCreatures.getSpawnerNameFor("Pinch Beetle"); + case 3, 4, 5 -> "Skeleton"; + case 6, 7, 8 -> "CaveSpider"; + case 9 -> "Creeper"; + default -> TFCreatures.getSpawnerNameFor("Twilight Wraith"); + }; } } diff --git a/src/main/java/twilightforest/structures/ComponentTFNagaCourtyard.java b/src/main/java/twilightforest/structures/ComponentTFNagaCourtyard.java index b72077238d..a09a1eba1e 100644 --- a/src/main/java/twilightforest/structures/ComponentTFNagaCourtyard.java +++ b/src/main/java/twilightforest/structures/ComponentTFNagaCourtyard.java @@ -65,84 +65,74 @@ public boolean addComponentParts(World world, Random rand, StructureBoundingBox // make nagastone pattern! switch (fx % 23) { - case 2: + case 2 -> { placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 7, fx, 3, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 7, fx, 3, 0, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, fx, 2, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, fx, 2, 0, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 11, fx, 1, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 11, fx, 1, 0, sbb); - break; - case 3: + } + case 3 -> { placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 3, fx, 3, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 3, fx, 3, 0, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 12, fx, 1, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 12, fx, 1, 0, sbb); - break; - case 4: - case 8: - case 16: - case 20: + } + case 4, 8, 16, 20 -> { placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 12, fx, 1, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 12, fx, 1, 0, sbb); - break; - case 5: - case 9: - case 17: + } + case 5, 9, 17 -> { placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 7, fx, 3, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 7, fx, 3, 0, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, fx, 2, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, fx, 2, 0, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 10, fx, 1, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 10, fx, 1, 0, sbb); - break; - case 6: - case 10: - case 14: - case 18: + } + case 6, 10, 14, 18 -> { placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 12, fx, 3, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 12, fx, 3, 0, sbb); - break; - case 7: - case 15: - case 19: + } + case 7, 15, 19 -> { placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 6, fx, 3, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 6, fx, 3, 0, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, fx, 2, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, fx, 2, 0, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 11, fx, 1, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 11, fx, 1, 0, sbb); - break; - case 11: + } + case 11 -> { placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 6, fx, 3, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 6, fx, 3, 0, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, fx, 2, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, fx, 2, 0, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, fx, 1, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, fx, 1, 0, sbb); - break; - case 13: + } + case 13 -> { placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 7, fx, 3, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 7, fx, 3, 0, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, fx, 2, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, fx, 2, 0, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, fx, 1, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, fx, 1, 0, sbb); - break; - case 21: + } + case 21 -> { placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 2, fx, 3, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 2, fx, 3, 0, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 12, fx, 1, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 12, fx, 1, 0, sbb); - break; - case 22: + } + case 22 -> { placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 6, fx, 3, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 6, fx, 3, 0, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, fx, 2, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, fx, 2, 0, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 10, fx, 1, DIAMETER, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 10, fx, 1, 0, sbb); - break; + } } // if (fx % 2 == 0) { @@ -170,84 +160,74 @@ public boolean addComponentParts(World world, Random rand, StructureBoundingBox // make nagastone pattern! switch (fz % 23) { - case 2: + case 2 -> { placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 5, DIAMETER, 3, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 5, 0, 3, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, DIAMETER, 2, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, 0, 2, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 9, DIAMETER, 1, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 9, 0, 1, fz, sbb); - break; - case 3: + } + case 3 -> { placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 1, DIAMETER, 3, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 1, 0, 3, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 13, DIAMETER, 1, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 13, 0, 1, fz, sbb); - break; - case 4: - case 8: - case 16: - case 20: + } + case 4, 8, 16, 20 -> { placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 13, DIAMETER, 1, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 13, 0, 1, fz, sbb); - break; - case 5: - case 9: - case 17: + } + case 5, 9, 17 -> { placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 5, DIAMETER, 3, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 5, 0, 3, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, DIAMETER, 2, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, 0, 2, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 8, DIAMETER, 1, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 8, 0, 1, fz, sbb); - break; - case 6: - case 10: - case 14: - case 18: + } + case 6, 10, 14, 18 -> { placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 13, DIAMETER, 3, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 13, 0, 3, fz, sbb); - break; - case 7: - case 15: - case 19: + } + case 7, 15, 19 -> { placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 4, DIAMETER, 3, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 4, 0, 3, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, DIAMETER, 2, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, 0, 2, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 9, DIAMETER, 1, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 9, 0, 1, fz, sbb); - break; - case 11: + } + case 11 -> { placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 4, DIAMETER, 3, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 4, 0, 3, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, DIAMETER, 2, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, 0, 2, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, DIAMETER, 1, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, 0, 1, fz, sbb); - break; - case 13: + } + case 13 -> { placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 5, DIAMETER, 3, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 5, 0, 3, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, DIAMETER, 2, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, 0, 2, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, DIAMETER, 1, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, 0, 1, fz, sbb); - break; - case 21: + } + case 21 -> { placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 0, DIAMETER, 3, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 0, 0, 3, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 13, DIAMETER, 1, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 13, 0, 1, fz, sbb); - break; - case 22: + } + case 22 -> { placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 4, DIAMETER, 3, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 4, 0, 3, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, DIAMETER, 2, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 14, 0, 2, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 8, DIAMETER, 1, fz, sbb); placeBlockAtCurrentPosition(world, TFBlocks.nagastone, 8, 0, 1, fz, sbb); - break; + } } // if (fz % 2 == 0) { @@ -301,34 +281,18 @@ public boolean makePillar(World world, Random rand, int x, int y, int z, Structu if (i > 0 && rand.nextInt(2) == 0) { // vines? switch (rand.nextInt(4)) { - case 0: - placeBlockAtCurrentPosition(world, Blocks.vine, 8, x - 1, y + i, z + 0, sbb); - break; - case 1: - placeBlockAtCurrentPosition(world, Blocks.vine, 2, x + 1, y + i, z + 0, sbb); - break; - case 2: - placeBlockAtCurrentPosition(world, Blocks.vine, 4, x + 0, y + i, z + 1, sbb); - break; - case 3: - placeBlockAtCurrentPosition(world, Blocks.vine, 1, x + 0, y + i, z - 1, sbb); - break; + case 0 -> placeBlockAtCurrentPosition(world, Blocks.vine, 8, x - 1, y + i, z + 0, sbb); + case 1 -> placeBlockAtCurrentPosition(world, Blocks.vine, 2, x + 1, y + i, z + 0, sbb); + case 2 -> placeBlockAtCurrentPosition(world, Blocks.vine, 4, x + 0, y + i, z + 1, sbb); + case 3 -> placeBlockAtCurrentPosition(world, Blocks.vine, 1, x + 0, y + i, z - 1, sbb); } } else if (i > 0 && rand.nextInt(4) == 0) { // fireflies! switch (rand.nextInt(4)) { - case 0: - placeBlockAtCurrentPosition(world, TFBlocks.firefly, 0, x - 1, y + i, z + 0, sbb); - break; - case 1: - placeBlockAtCurrentPosition(world, TFBlocks.firefly, 0, x + 1, y + i, z + 0, sbb); - break; - case 2: - placeBlockAtCurrentPosition(world, TFBlocks.firefly, 0, x + 0, y + i, z + 1, sbb); - break; - case 3: - placeBlockAtCurrentPosition(world, TFBlocks.firefly, 0, x + 0, y + i, z - 1, sbb); - break; + case 0 -> placeBlockAtCurrentPosition(world, TFBlocks.firefly, 0, x - 1, y + i, z + 0, sbb); + case 1 -> placeBlockAtCurrentPosition(world, TFBlocks.firefly, 0, x + 1, y + i, z + 0, sbb); + case 2 -> placeBlockAtCurrentPosition(world, TFBlocks.firefly, 0, x + 0, y + i, z + 1, sbb); + case 3 -> placeBlockAtCurrentPosition(world, TFBlocks.firefly, 0, x + 0, y + i, z - 1, sbb); } } } diff --git a/src/main/java/twilightforest/structures/StructureTFComponent.java b/src/main/java/twilightforest/structures/StructureTFComponent.java index 607604bce8..9b7e0d4f1c 100644 --- a/src/main/java/twilightforest/structures/StructureTFComponent.java +++ b/src/main/java/twilightforest/structures/StructureTFComponent.java @@ -1,6 +1,5 @@ package twilightforest.structures; -import java.util.Iterator; import java.util.List; import java.util.Random; @@ -51,41 +50,34 @@ protected void func_143011_b(NBTTagCompound par1NBTTagCompound) { public static StructureBoundingBox getComponentToAddBoundingBox(int x, int y, int z, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int dir) { - switch (dir) { - default: - case 0: // '\0' - return new StructureBoundingBox( + return switch (dir) { + default -> // '\0' + new StructureBoundingBox( x + minX, y + minY, z + minZ, x + maxX + minX, y + maxY + minY, z + maxZ + minZ); - case 1: // '\001' - return new StructureBoundingBox( + case 1 -> // '\001' + new StructureBoundingBox( x - maxZ + minZ, y + minY, z + minX, x + minZ, y + maxY + minY, z + maxX + minX); - case 2: // '\002' - return new StructureBoundingBox( + case 2 -> // '\002' + new StructureBoundingBox( x - maxX - minX, y + minY, z - maxZ - minZ, x - minX, y + maxY + minY, z - minZ); - case 3: // '\003' - return new StructureBoundingBox( - x + minZ, - y + minY, - z - maxX, - x + maxZ + minZ, - y + maxY + minY, - z + minX); - } + case 3 -> // '\003' + new StructureBoundingBox(x + minZ, y + minY, z - maxX, x + maxZ + minZ, y + maxY + minY, z + minX); + }; } /** @@ -93,41 +85,34 @@ public static StructureBoundingBox getComponentToAddBoundingBox(int x, int y, in */ public static StructureBoundingBox getComponentToAddBoundingBox2(int x, int y, int z, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int dir) { - switch (dir) { - default: - case 0: // '\0' - return new StructureBoundingBox( + return switch (dir) { + default -> // '\0' + new StructureBoundingBox( x + minX, y + minY, z + minZ, x + maxX + minX, y + maxY + minY, z + maxZ + minZ); - case 1: // '\001' - return new StructureBoundingBox( + case 1 -> // '\001' + new StructureBoundingBox( x - maxZ - minZ, y + minY, z + minX, x - minZ, y + maxY + minY, z + maxX + minX); - case 2: // '\002' - return new StructureBoundingBox( + case 2 -> // '\002' + new StructureBoundingBox( x - maxX - minX, y + minY, z - maxZ - minZ, x - minX, y + maxY + minY, z - minZ); - case 3: // '\003' - return new StructureBoundingBox( - x + minZ, - y + minY, - z - maxX, - x + maxZ + minZ, - y + maxY + minY, - z - minX); - } + case 3 -> // '\003' + new StructureBoundingBox(x + minZ, y + minY, z - maxX, x + maxZ + minZ, y + maxY + minY, z - minX); + }; } /** @@ -266,18 +251,13 @@ protected int[] offsetTowerCoords(int x, int y, int z, int towerSize, int direct int dy = getYWithOffset(y); int dz = getZWithOffset(x, z); - switch (direction) { - case 0: - return new int[] { dx + 1, dy - 1, dz - towerSize / 2 }; - case 1: - return new int[] { dx + towerSize / 2, dy - 1, dz + 1 }; - case 2: - return new int[] { dx - 1, dy - 1, dz + towerSize / 2 }; - case 3: - return new int[] { dx - towerSize / 2, dy - 1, dz - 1 }; - default: - return new int[] { x, y, z }; - } + return switch (direction) { + case 0 -> new int[] { dx + 1, dy - 1, dz - towerSize / 2 }; + case 1 -> new int[] { dx + towerSize / 2, dy - 1, dz + 1 }; + case 2 -> new int[] { dx - 1, dy - 1, dz + towerSize / 2 }; + case 3 -> new int[] { dx - towerSize / 2, dy - 1, dz - 1 }; + default -> new int[] { x, y, z }; + }; } /** @@ -289,21 +269,16 @@ protected ChunkCoordinates offsetTowerCCoords(int x, int y, int z, int towerSize int dy = getYWithOffset(y); int dz = getZWithOffset(x, z); - switch (direction) { - case 0: - return new ChunkCoordinates(dx + 1, dy - 1, dz - towerSize / 2); - case 1: - return new ChunkCoordinates(dx + towerSize / 2, dy - 1, dz + 1); - case 2: - return new ChunkCoordinates(dx - 1, dy - 1, dz + towerSize / 2); - case 3: - return new ChunkCoordinates(dx - towerSize / 2, dy - 1, dz - 1); - default: - return new ChunkCoordinates(x, y, z); - } + return switch (direction) { + case 0 -> new ChunkCoordinates(dx + 1, dy - 1, dz - towerSize / 2); + case 1 -> new ChunkCoordinates(dx + towerSize / 2, dy - 1, dz + 1); + case 2 -> new ChunkCoordinates(dx - 1, dy - 1, dz + towerSize / 2); + case 3 -> new ChunkCoordinates(dx - towerSize / 2, dy - 1, dz - 1); + default -> new ChunkCoordinates(x, y, z); + }; } - public int[] getOffsetAsIfRotated(int src[], int rotation) { + public int[] getOffsetAsIfRotated(int[] src, int rotation) { int temp = this.getCoordBaseMode(); int[] dest = new int[3]; this.setCoordBaseMode(rotation); @@ -317,17 +292,17 @@ public int[] getOffsetAsIfRotated(int src[], int rotation) { } protected int getXWithOffset(int x, int z) { - switch (getCoordBaseMode()) { - case 0: // '\0' - return boundingBox.minX + x; - case 1: // '\001' - return boundingBox.maxX - z; - case 2: // '\002' - return boundingBox.maxX - x; - case 3: // '\003' - return boundingBox.minX + z; - } - return x; + return switch (getCoordBaseMode()) { + case 0 -> // '\0' + boundingBox.minX + x; + case 1 -> // '\001' + boundingBox.maxX - z; + case 2 -> // '\002' + boundingBox.maxX - x; + case 3 -> // '\003' + boundingBox.minX + z; + default -> x; + }; } protected int getYWithOffset(int par1) { @@ -335,17 +310,17 @@ protected int getYWithOffset(int par1) { } protected int getZWithOffset(int x, int z) { - switch (getCoordBaseMode()) { - case 0: // '\0' - return boundingBox.minZ + z; - case 1: // '\001' - return boundingBox.minZ + x; - case 2: // '\002' - return boundingBox.maxZ - z; - case 3: // '\003' - return boundingBox.maxZ - x; - } - return z; + return switch (getCoordBaseMode()) { + case 0 -> // '\0' + boundingBox.minZ + z; + case 1 -> // '\001' + boundingBox.minZ + x; + case 2 -> // '\002' + boundingBox.maxZ - z; + case 3 -> // '\003' + boundingBox.maxZ - x; + default -> z; + }; } /** @@ -356,34 +331,26 @@ protected int getXWithOffsetAsIfRotated(int x, int z, int rotation) { return x; } - switch ((coordBaseMode + rotation) % 4) { - case 0: - return boundingBox.minX + x; - case 1: - return boundingBox.maxX - z; - case 2: - return boundingBox.maxX - x; - case 3: - return boundingBox.minX + z; - } - return x; + return switch ((coordBaseMode + rotation) % 4) { + case 0 -> boundingBox.minX + x; + case 1 -> boundingBox.maxX - z; + case 2 -> boundingBox.maxX - x; + case 3 -> boundingBox.minX + z; + default -> x; + }; } protected int getZWithOffsetAsIfRotated(int x, int z, int rotation) { if (coordBaseMode < 0) { return x; } else { - switch ((coordBaseMode + rotation) % 4) { - case 0: - return boundingBox.minZ + z; - case 1: - return boundingBox.minZ + x; - case 2: - return boundingBox.maxZ - z; - case 3: - return boundingBox.maxZ - x; - } - return z; + return switch ((coordBaseMode + rotation) % 4) { + case 0 -> boundingBox.minZ + z; + case 1 -> boundingBox.minZ + x; + case 2 -> boundingBox.maxZ - z; + case 3 -> boundingBox.maxZ - x; + default -> z; + }; } } @@ -502,18 +469,13 @@ public static StructureComponent.BlockSelector getStrongholdStones() { * @return */ protected int getStairMeta(int dir) { - switch ((this.getCoordBaseMode() + dir) % 4) { - case 0: - return 0; - case 1: - return 2; - case 2: - return 1; - case 3: - return 3; - default: - return -1; // this is impossible - } + return switch ((this.getCoordBaseMode() + dir) % 4) { + case 0 -> 0; + case 1 -> 2; + case 2 -> 1; + case 3 -> 3; + default -> -1; // this is impossible + }; } /** @@ -524,18 +486,13 @@ protected int getStairMeta(int dir) { */ protected int getLadderMeta(int ladderDir) { // ladder data values are... dumb. - switch ((this.getCoordBaseMode() + ladderDir) % 4) { - case 0: - return 4; - case 1: - return 2; - case 2: - return 5; - case 3: - return 3; - default: - return -1; // this is impossible - } + return switch ((this.getCoordBaseMode() + ladderDir) % 4) { + case 0 -> 4; + case 1 -> 2; + case 2 -> 5; + case 3 -> 3; + default -> -1; // this is impossible + }; } /** @@ -653,21 +610,13 @@ public boolean isComponentProtected() { /** * Discover if bounding box can fit within the current bounding box object. */ - public static StructureComponent findIntersectingExcluding(List list, StructureBoundingBox toCheck, - StructureComponent exclude) { - Iterator iterator = list.iterator(); - StructureComponent structurecomponent; - - do { - if (!iterator.hasNext()) { - return null; - } - - structurecomponent = (StructureComponent) iterator.next(); - } while (structurecomponent == exclude || structurecomponent.getBoundingBox() == null - || !structurecomponent.getBoundingBox().intersectsWith(toCheck)); - - return structurecomponent; + public static StructureComponent findIntersectingExcluding(List list, + StructureBoundingBox toCheck, StructureComponent exclude) { + return list.stream() + .filter( + component -> component != exclude && component.getBoundingBox() != null + && component.getBoundingBox().intersectsWith(toCheck)) + .findFirst().orElse(null); } } diff --git a/src/main/java/twilightforest/structures/StructureTFMajorFeatureStart.java b/src/main/java/twilightforest/structures/StructureTFMajorFeatureStart.java index dec52e367f..9d89f56085 100644 --- a/src/main/java/twilightforest/structures/StructureTFMajorFeatureStart.java +++ b/src/main/java/twilightforest/structures/StructureTFMajorFeatureStart.java @@ -1,7 +1,6 @@ package twilightforest.structures; import java.util.ArrayList; -import java.util.LinkedList; import java.util.List; import java.util.Random; @@ -92,11 +91,11 @@ public StructureTFMajorFeatureStart(World world, Random rand, int chunkX, int ch updateBoundingBox(); if (firstComponent instanceof StructureStrongholdPieces.Stairs2) { - List var6 = ((StructureStrongholdPieces.Stairs2) firstComponent).field_75026_c; + List var6 = ((StructureStrongholdPieces.Stairs2) firstComponent).field_75026_c; while (!var6.isEmpty()) { int var7 = rand.nextInt(var6.size()); - StructureComponent var8 = (StructureComponent) var6.remove(var7); + StructureComponent var8 = var6.remove(var7); var8.buildComponent(firstComponent, this.components, rand); } @@ -106,7 +105,7 @@ public StructureTFMajorFeatureStart(World world, Random rand, int chunkX, int ch boundingBox.offset(0, offY, 0); - for (StructureComponent com : (LinkedList) getComponents()) { + for (StructureComponent com : getComponents()) { com.getBoundingBox().offset(0, offY, 0); } @@ -201,7 +200,7 @@ protected void moveToAvgGroundLevel(World world, int x, int z) { boundingBox.offset(0, offY, 0); - for (StructureComponent com : (LinkedList) getComponents()) { + for (StructureComponent com : getComponents()) { com.getBoundingBox().offset(0, offY, 0); } } @@ -273,7 +272,7 @@ private void addShieldFor(World world, StructureComponent component, List intersecting = new ArrayList(); + ArrayList intersecting = new ArrayList<>(); for (StructureComponent other : otherComponents) { if (other != component && shieldBox.intersectsWith(other.getBoundingBox())) { diff --git a/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerBalcony.java b/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerBalcony.java index 829e3a6f0f..da003681f2 100644 --- a/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerBalcony.java +++ b/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerBalcony.java @@ -22,9 +22,8 @@ protected ComponentTFDarkTowerBalcony(int i, int x, int y, int z, int direction) super(i, x, y, z, 5, 5, direction); } - @SuppressWarnings("rawtypes") @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerBossTrap.java b/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerBossTrap.java index 1297dae9d6..dc070b6880 100644 --- a/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerBossTrap.java +++ b/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerBossTrap.java @@ -26,9 +26,8 @@ protected ComponentTFDarkTowerBossTrap(int i, int x, int y, int z, int pSize, in this.spawnListIndex = -1; } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerBridge.java b/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerBridge.java index aa25a680a6..010c2bfb20 100644 --- a/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerBridge.java +++ b/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerBridge.java @@ -26,9 +26,8 @@ protected ComponentTFDarkTowerBridge(int i, int x, int y, int z, int pSize, int this.dHeight = pHeight; } - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerEntrance.java b/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerEntrance.java index 5d29249c39..8fb4082e12 100644 --- a/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerEntrance.java +++ b/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerEntrance.java @@ -18,9 +18,8 @@ protected ComponentTFDarkTowerEntrance(int i, int x, int y, int z, int pSize, in super(i, x, y, z, pSize, pHeight, direction); } - @SuppressWarnings("rawtypes") @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { super.buildComponent(parent, list, rand); // a few more openings diff --git a/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerMain.java b/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerMain.java index f9f98e296e..3a5503ee16 100644 --- a/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerMain.java +++ b/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerMain.java @@ -64,9 +64,9 @@ public ComponentTFDarkTowerMain(World world, Random rand, int index, int x, int } } - @SuppressWarnings({ "rawtypes", "unchecked", "unused" }) + @SuppressWarnings({ "unused" }) @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } @@ -148,13 +148,12 @@ public void buildComponent(StructureComponent parent, List list, Random rand) { // flag certain towers for keys if (!this.placedKeys && this.getComponentType() < 2) { // count how many size 9 towers we have hanging off us - ArrayList possibleKeyTowers = new ArrayList(); + ArrayList possibleKeyTowers = new ArrayList<>(); int smallTowers = 0; for (Object piece : list) { - if (piece instanceof ComponentTFDarkTowerWing) { - ComponentTFDarkTowerWing wing = (ComponentTFDarkTowerWing) piece; + if (piece instanceof ComponentTFDarkTowerWing wing) { if (wing.size == 9 && wing.getComponentType() == this.getComponentType()) { // System.out.println("I found one of my small towers! Its type is " + wing.getComponentType() + @@ -429,16 +428,9 @@ private void decorateFloor(World world, Random decoRNG, StructureBoundingBox sbb if (isTop) { // there are a limited amount that can go at the top switch (decoRNG.nextInt(3)) { - default: - case 0: - decorateAquarium(world, decoRNG, sbb, rotation, y); - break; - case 1: - decorateBotanical(world, decoRNG, sbb, rotation, y); - break; - case 2: - decorateNetherwart(world, decoRNG, sbb, rotation, y, isTop); - break; + default -> decorateAquarium(world, decoRNG, sbb, rotation, y); + case 1 -> decorateBotanical(world, decoRNG, sbb, rotation, y); + case 2 -> decorateNetherwart(world, decoRNG, sbb, rotation, y, isTop); } } else if (isBottom) { // similarly some don't work on the bottom @@ -657,7 +649,7 @@ private void decorateReappearingMaze(World world, Random decoRNG, StructureBound // set some areas out of bounds and make the maze depending on where we start switch (rotation) { - case 0: + case 0 -> { for (int x = 1; x < 6; x++) { for (int z = 1; z < 6; z++) { maze.putRaw(x, z, TFMaze.ROOM); @@ -672,8 +664,8 @@ private void decorateReappearingMaze(World world, Random decoRNG, StructureBound maze.putRaw(7, 1, TFMaze.ROOM); maze.putRaw(8, 1, TFMaze.DOOR); maze.generateRecursiveBacktracker(0, 5); - break; - case 1: + } + case 1 -> { for (int x = 7; x < 12; x++) { for (int z = 1; z < 6; z++) { maze.putRaw(x, z, TFMaze.ROOM); @@ -688,8 +680,8 @@ private void decorateReappearingMaze(World world, Random decoRNG, StructureBound maze.putRaw(11, 7, TFMaze.ROOM); maze.putRaw(11, 8, TFMaze.DOOR); maze.generateRecursiveBacktracker(0, 0); - break; - case 2: + } + case 2 -> { for (int x = 7; x < 12; x++) { for (int z = 7; z < 12; z++) { maze.putRaw(x, z, TFMaze.ROOM); @@ -704,8 +696,8 @@ private void decorateReappearingMaze(World world, Random decoRNG, StructureBound maze.putRaw(5, 11, TFMaze.ROOM); maze.putRaw(4, 11, TFMaze.DOOR); maze.generateRecursiveBacktracker(5, 0); - break; - case 3: + } + case 3 -> { for (int x = 1; x < 6; x++) { for (int z = 7; z < 12; z++) { maze.putRaw(x, z, TFMaze.ROOM); @@ -720,7 +712,7 @@ private void decorateReappearingMaze(World world, Random decoRNG, StructureBound maze.putRaw(1, 5, TFMaze.ROOM); maze.putRaw(1, 4, TFMaze.DOOR); maze.generateRecursiveBacktracker(5, 5); - break; + } } // copy the maze to us! @@ -785,7 +777,7 @@ private void decorateDeadEnd(World world, Random decoRNG, TFMaze maze, int mx, i int z = mz * 3 + 1; switch (facing) { - case 0: + case 0 -> { placeBlockAtCurrentPosition(world, deco.accentID, deco.accentMeta, x + 0, y + 1, z + 1, sbb); placeBlockAtCurrentPosition(world, deco.accentID, deco.accentMeta, x + 1, y + 1, z + 1, sbb); placeBlockAtCurrentPosition(world, Blocks.chest, 0, x + 0, y + 2, z + 1, sbb); @@ -797,8 +789,8 @@ private void decorateDeadEnd(World world, Random decoRNG, TFMaze maze, int mx, i z + 1, TFTreasure.darktower_cache, sbb); - break; - case 1: + } + case 1 -> { placeBlockAtCurrentPosition(world, deco.accentID, deco.accentMeta, x + 0, y + 1, z + 0, sbb); placeBlockAtCurrentPosition(world, deco.accentID, deco.accentMeta, x + 0, y + 1, z + 1, sbb); placeBlockAtCurrentPosition(world, Blocks.chest, rotation, x + 0, y + 2, z + 0, sbb); @@ -810,8 +802,8 @@ private void decorateDeadEnd(World world, Random decoRNG, TFMaze maze, int mx, i z + 1, TFTreasure.darktower_cache, sbb); - break; - case 2: + } + case 2 -> { placeBlockAtCurrentPosition(world, deco.accentID, deco.accentMeta, x + 0, y + 1, z + 0, sbb); placeBlockAtCurrentPosition(world, deco.accentID, deco.accentMeta, x + 1, y + 1, z + 0, sbb); placeBlockAtCurrentPosition(world, Blocks.chest, rotation, x + 0, y + 2, z + 0, sbb); @@ -823,8 +815,8 @@ private void decorateDeadEnd(World world, Random decoRNG, TFMaze maze, int mx, i z + 0, TFTreasure.darktower_cache, sbb); - break; - case 3: + } + case 3 -> { placeBlockAtCurrentPosition(world, deco.accentID, deco.accentMeta, x + 1, y + 1, z + 0, sbb); placeBlockAtCurrentPosition(world, deco.accentID, deco.accentMeta, x + 1, y + 1, z + 1, sbb); placeBlockAtCurrentPosition(world, Blocks.chest, rotation, x + 1, y + 2, z + 0, sbb); @@ -836,7 +828,7 @@ private void decorateDeadEnd(World world, Random decoRNG, TFMaze maze, int mx, i z + 1, TFTreasure.darktower_cache, sbb); - break; + } } } @@ -1375,18 +1367,10 @@ private void makeStonePillar(World world, StructureTFDecorator forgeDeco, int x, int sz = getZWithOffsetAsIfRotated(x, z, rotation); switch (stairMeta) { - case 0: - sx--; - break; - case 1: - sx++; - break; - case 2: - sz--; - break; - case 3: - sz++; - break; + case 0 -> sx--; + case 1 -> sx++; + case 2 -> sz--; + case 3 -> sz++; } if (sbb.isVecInside(sx, sy, sz)) { @@ -1514,29 +1498,20 @@ private void placeTreePlanter(World world, int treeNum, int x, int y, int z, int int dy = getYWithOffset(y + 1); int dz = getZWithOffsetAsIfRotated(x, z, rotation); if (sbb.isVecInside(dx, dy, dz)) { - WorldGenerator treeGen; - // grow a tree - switch (treeNum) { - case 0: - default: + WorldGenerator treeGen = switch (treeNum) { + default -> // oak tree - treeGen = new WorldGenTrees(false); - break; - case 1: + new WorldGenTrees(false); + case 1 -> // jungle tree - treeGen = new WorldGenTrees(true, 3, 3, 3, false); - break; - case 2: + new WorldGenTrees(true, 3, 3, 3, false); + case 2 -> // birch - treeGen = new WorldGenForest(true, false); - break; - case 3: - treeGen = new TFGenSmallTwilightOak(false); - break; - case 4: - treeGen = new TFGenSmallRainboak(false); - break; - } + new WorldGenForest(true, false); + case 3 -> new TFGenSmallTwilightOak(false); + case 4 -> new TFGenSmallRainboak(false); + }; + // grow a tree for (int i = 0; i < 100; i++) { if (treeGen.generate(world, world.rand, dx, dy, dz)) { diff --git a/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerRoof.java b/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerRoof.java index 33d66017f1..3dc779ad34 100644 --- a/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerRoof.java +++ b/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerRoof.java @@ -34,9 +34,8 @@ public ComponentTFDarkTowerRoof(int i, ComponentTFTowerWing wing) { this.spawnListIndex = 1; } - @SuppressWarnings("rawtypes") @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerWing.java b/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerWing.java index 47746ff45b..6321580f61 100644 --- a/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerWing.java +++ b/src/main/java/twilightforest/structures/darktower/ComponentTFDarkTowerWing.java @@ -33,7 +33,7 @@ public class ComponentTFDarkTowerWing extends ComponentTFTowerWing { protected boolean keyTower = false; - protected ArrayList openingTypes = new ArrayList(); + protected ArrayList openingTypes = new ArrayList<>(); public ComponentTFDarkTowerWing() { super(); @@ -101,9 +101,8 @@ private void readOpeningsFromArray(int[] intArray) { } } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } @@ -169,24 +168,12 @@ protected int validateChildHeight(int childHeight, int childSize) { public void makeARoof(StructureComponent parent, List list, Random rand) { int index = this.getComponentType(); - ComponentTFTowerRoof roof; - - switch (rand.nextInt(5)) { - case 0: - case 1: - default: - roof = new ComponentTFDarkTowerRoofAntenna(index, this); - break; - case 2: - roof = new ComponentTFDarkTowerRoofCactus(index, this); - break; - case 3: - roof = new ComponentTFDarkTowerRoofRings(index, this); - break; - case 4: - roof = new ComponentTFDarkTowerRoofFourPost(index, this); - break; - } + ComponentTFTowerRoof roof = switch (rand.nextInt(5)) { + default -> new ComponentTFDarkTowerRoofAntenna(index, this); + case 2 -> new ComponentTFDarkTowerRoofCactus(index, this); + case 3 -> new ComponentTFDarkTowerRoofRings(index, this); + case 4 -> new ComponentTFDarkTowerRoofFourPost(index, this); + }; list.add(roof); roof.buildComponent(this, list, rand); @@ -965,8 +952,7 @@ protected void putItemInTreasure(World world, int x, int y, int z, ItemStack ite int dz = getZWithOffset(x, z); if (sbb.isVecInside(dx, dy, dz)) { TileEntity tileEntity = world.getTileEntity(dx, dy, dz); - if (tileEntity != null && tileEntity instanceof IInventory) { - IInventory inventory = (IInventory) tileEntity; + if (tileEntity != null && tileEntity instanceof IInventory inventory) { // check to see if the item is there, also count empty slots boolean alreadyPresent = false; @@ -1204,15 +1190,11 @@ protected int pickBetweenExcluding(int low, int high, Random rand, int k, int l, * Pick one of the three specified values at random */ protected int pickFrom(Random rand, int i, int j, int k) { - switch (rand.nextInt(3)) { - case 0: - default: - return i; - case 1: - return j; - case 2: - return k; - } + return switch (rand.nextInt(3)) { + default -> i; + case 1 -> j; + case 2 -> k; + }; } /** @@ -1241,9 +1223,7 @@ protected void makeEncasedWalls(World world, Random rand, StructureBoundingBox s for (int x = minX; x <= maxX; x++) { for (int y = minY; y <= maxY; y++) { for (int z = minZ; z <= maxZ; z++) { - if (x != minX && x != maxX && y != minY && y != maxY && z != minZ && z != maxZ) { - ; - } else { + if (x != minX && x != maxX && y != minY && y != maxY && z != minZ && z != maxZ) {} else { // wall if (((x == minY || x == maxX) && ((y == minY || y == maxY) || (z == minZ || z == maxZ))) || ((y == minY || y == maxY) && ((x == minY || x == maxX) || (z == minZ || z == maxZ))) @@ -1365,16 +1345,14 @@ protected void makeOpenings(World world, StructureBoundingBox sbb) { } switch (doorType) { - case VANISHING: - default: - makeDoorOpening(world, doorCoords.posX, doorCoords.posY, doorCoords.posZ, sbb); - break; - case REAPPEARING: - makeReappearingDoorOpening(world, doorCoords.posX, doorCoords.posY, doorCoords.posZ, sbb); - break; - case LOCKED: - makeLockedDoorOpening(world, doorCoords.posX, doorCoords.posY, doorCoords.posZ, sbb); - break; + default -> makeDoorOpening(world, doorCoords.posX, doorCoords.posY, doorCoords.posZ, sbb); + case REAPPEARING -> makeReappearingDoorOpening( + world, + doorCoords.posX, + doorCoords.posY, + doorCoords.posZ, + sbb); + case LOCKED -> makeLockedDoorOpening(world, doorCoords.posX, doorCoords.posY, doorCoords.posZ, sbb); } } @@ -1697,47 +1675,63 @@ protected int getLeverMeta(int rotation, int direction) { if (rotation == 0) { switch (direction) { - case 2: + case 2 -> { return 4; - case 3: + } + case 3 -> { return 3; - case 4: + } + case 4 -> { return 2; - case 5: + } + case 5 -> { return 1; + } } } else if (rotation == 1) { switch (direction) { - case 2: + case 2 -> { return 1; - case 3: + } + case 3 -> { return 2; - case 4: + } + case 4 -> { return 4; - case 5: + } + case 5 -> { return 3; + } } } else if (rotation == 2) { switch (direction) { - case 2: + case 2 -> { return 3; - case 3: + } + case 3 -> { return 4; - case 4: + } + case 4 -> { return 1; - case 5: + } + case 5 -> { return 2; + } } } else if (rotation == 3) { switch (direction) { - case 2: + case 2 -> { return 2; - case 3: + } + case 3 -> { return 1; - case 4: + } + case 4 -> { return 3; - case 5: + } + case 5 -> { return 4; + } } } diff --git a/src/main/java/twilightforest/structures/darktower/StructureDecoratorDarkTower.java b/src/main/java/twilightforest/structures/darktower/StructureDecoratorDarkTower.java index 8e432565b1..cc7708b8bc 100644 --- a/src/main/java/twilightforest/structures/darktower/StructureDecoratorDarkTower.java +++ b/src/main/java/twilightforest/structures/darktower/StructureDecoratorDarkTower.java @@ -21,7 +21,7 @@ public StructureDecoratorDarkTower() { this.pillarID = TFBlocks.towerWood; this.pillarMeta = 1; - this.platformID = TFBlocks.towerWood;; + this.platformID = TFBlocks.towerWood; this.platformMeta = 1; this.randomBlocks = new StructureTFTowerWoods(); diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleBellTower21.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleBellTower21.java index 6e0ff17946..6e57b11e8d 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleBellTower21.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleBellTower21.java @@ -38,7 +38,7 @@ public ComponentTFFinalCastleBellTower21(Random rand, int i, int x, int y, int z } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleBossGazebo.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleBossGazebo.java index be72bd3c94..8c0e7d153e 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleBossGazebo.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleBossGazebo.java @@ -29,9 +29,8 @@ public ComponentTFFinalCastleBossGazebo(Random rand, int i, StructureTFComponent keep.getBoundingBox().maxZ - 14); } - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { this.deco = new StructureTFDecoratorCastle(); this.deco.blockID = TFBlocks.castleMagic; this.deco.blockMeta = 1; diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleBridge.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleBridge.java index c882b64f9d..0fde87031c 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleBridge.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleBridge.java @@ -23,7 +23,7 @@ public ComponentTFFinalCastleBridge(int i, int x, int y, int z, int length, int } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleDamagedTower.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleDamagedTower.java index 8e45ec4b5d..de87003c63 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleDamagedTower.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleDamagedTower.java @@ -21,7 +21,7 @@ public ComponentTFFinalCastleDamagedTower(Random rand, int i, int x, int y, int } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } @@ -105,7 +105,7 @@ public void destroyTower(World world, Random rand, StructureBoundingBox sbb) { } protected ArrayList makeInitialDestroyList(Random rand) { - ArrayList areas = new ArrayList(2); + ArrayList areas = new ArrayList<>(2); areas.add( DestroyArea.createNonIntersecting(this.getBoundingBox(), rand, this.getBoundingBox().maxY - 1, areas)); diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleDungeonEntrance.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleDungeonEntrance.java index 81fcccead3..94aa33a512 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleDungeonEntrance.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleDungeonEntrance.java @@ -22,7 +22,7 @@ public ComponentTFFinalCastleDungeonEntrance(Random rand, int i, int x, int y, i } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { this.deco = new StructureTFDecoratorCastle(); this.deco.blockID = TFBlocks.castleMagic; this.deco.blockMeta = 2; diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleDungeonExit.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleDungeonExit.java index 67d6dcbe82..59528aa781 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleDungeonExit.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleDungeonExit.java @@ -20,7 +20,7 @@ public ComponentTFFinalCastleDungeonExit(Random rand, int i, int x, int y, int z } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleDungeonRoom31.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleDungeonRoom31.java index 15223bf2f2..106385b0b6 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleDungeonRoom31.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleDungeonRoom31.java @@ -31,7 +31,7 @@ public ComponentTFFinalCastleDungeonRoom31(Random rand, int i, int x, int y, int } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } @@ -138,29 +138,24 @@ private ChunkCoordinates getNewRoomCoords(Random rand, int rotation) { offset += this.size; } - switch (rotation) { - default: - case 0: - return new ChunkCoordinates( - this.boundingBox.maxX + 9, - this.boundingBox.minY, - this.boundingBox.minZ + offset); - case 1: - return new ChunkCoordinates( - this.boundingBox.minX + offset, - this.boundingBox.minY, - this.boundingBox.maxZ + 9); - case 2: - return new ChunkCoordinates( - this.boundingBox.minX - 9, - this.boundingBox.minY, - this.boundingBox.minZ + offset); - case 3: - return new ChunkCoordinates( - this.boundingBox.minX + offset, - this.boundingBox.minY, - this.boundingBox.minZ - 9); - } + return switch (rotation) { + default -> new ChunkCoordinates( + this.boundingBox.maxX + 9, + this.boundingBox.minY, + this.boundingBox.minZ + offset); + case 1 -> new ChunkCoordinates( + this.boundingBox.minX + offset, + this.boundingBox.minY, + this.boundingBox.maxZ + 9); + case 2 -> new ChunkCoordinates( + this.boundingBox.minX - 9, + this.boundingBox.minY, + this.boundingBox.minZ + offset); + case 3 -> new ChunkCoordinates( + this.boundingBox.minX + offset, + this.boundingBox.minY, + this.boundingBox.minZ - 9); + }; } @Override diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleDungeonSteps.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleDungeonSteps.java index 577138bf56..0ab8407044 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleDungeonSteps.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleDungeonSteps.java @@ -22,7 +22,7 @@ public ComponentTFFinalCastleDungeonSteps(Random rand, int i, int x, int y, int } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } @@ -41,18 +41,10 @@ public ComponentTFFinalCastleDungeonSteps buildMoreStepsTowards(StructureCompone int sz = 17; switch (rotation) { - case 0: - sz -= 5; - break; - case 1: - sx -= 5; - break; - case 2: - sz += 5; - break; - case 3: - sx += 6; - break; + case 0 -> sz -= 5; + case 1 -> sx -= 5; + case 2 -> sz += 5; + case 3 -> sx += 6; } // find center of landing diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleEntranceBottomTower.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleEntranceBottomTower.java index c19b055573..c53a5466a8 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleEntranceBottomTower.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleEntranceBottomTower.java @@ -23,7 +23,7 @@ public ComponentTFFinalCastleEntranceBottomTower(Random rand, int i, int x, int } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleEntranceSideTower.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleEntranceSideTower.java index ddadc2e839..72958592fa 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleEntranceSideTower.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleEntranceSideTower.java @@ -19,7 +19,7 @@ public ComponentTFFinalCastleEntranceSideTower(Random rand, int i, int x, int y, } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleEntranceStairs.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleEntranceStairs.java index f513a5c2eb..82b0dd1151 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleEntranceStairs.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleEntranceStairs.java @@ -19,9 +19,8 @@ public ComponentTFFinalCastleEntranceStairs(int index, int x, int y, int z, int this.boundingBox = StructureTFComponent.getComponentToAddBoundingBox2(x, y, z, 0, -1, -5, 12, 0, 12, direction); } - @SuppressWarnings({ "rawtypes" }) @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleEntranceTower.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleEntranceTower.java index 8f57e58d85..3b3af7823b 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleEntranceTower.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleEntranceTower.java @@ -19,7 +19,7 @@ public ComponentTFFinalCastleEntranceTower(Random rand, int i, int x, int y, int } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleFoundation13.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleFoundation13.java index 3d66aded6f..99e6735741 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleFoundation13.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleFoundation13.java @@ -31,7 +31,7 @@ public ComponentTFFinalCastleFoundation13(Random rand, int i, StructureTFCompone } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleFoundation13Thorns.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleFoundation13Thorns.java index 2c62363420..f6fc0fcc20 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleFoundation13Thorns.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleFoundation13Thorns.java @@ -52,25 +52,26 @@ private void makeThornVine(World world, Random decoRNG, int rotation, StructureB this.placeBlockRotated(world, TFBlocks.thorns, 0, x, y, z, rotation, sbb); // twist vines around the center block switch (twist) { - case 0: + case 0 -> { this.placeBlockRotated(world, TFBlocks.thorns, 0, x + 1, y, z, rotation, sbb); this.placeBlockRotated(world, TFBlocks.thorns, 0, x, y, z + 1, rotation, sbb); this.placeBlockRotated(world, TFBlocks.thorns, 0, x + 1, y, z + 1, rotation, sbb); - break; - case 1: + } + case 1 -> { this.placeBlockRotated(world, TFBlocks.thorns, 0, x + 1, y, z, rotation, sbb); this.placeBlockRotated(world, TFBlocks.thorns, 0, x, y, z - 1, rotation, sbb); this.placeBlockRotated(world, TFBlocks.thorns, 0, x + 1, y, z - 1, rotation, sbb); - break; - case 2: + } + case 2 -> { this.placeBlockRotated(world, TFBlocks.thorns, 0, x - 1, y, z, rotation, sbb); this.placeBlockRotated(world, TFBlocks.thorns, 0, x, y, z - 1, rotation, sbb); this.placeBlockRotated(world, TFBlocks.thorns, 0, x - 1, y, z - 1, rotation, sbb); - break; - case 3: + } + case 3 -> { this.placeBlockRotated(world, TFBlocks.thorns, 0, x - 1, y, z, rotation, sbb); this.placeBlockRotated(world, TFBlocks.thorns, 0, x, y, z + 1, rotation, sbb); this.placeBlockRotated(world, TFBlocks.thorns, 0, x - 1, y, z + 1, rotation, sbb); + } } if (Math.abs(y % twistMod) == 1) { @@ -98,17 +99,10 @@ private void makeThornBranch(World world, int x, int y, int z, int rotation, Str int dz = 0; switch (dir) { - case 0: - dx = +1; - break; - case 1: - dz = +1; - break; - case 2: - dx = -1; - break; - case 3: - dz = -1; + case 0 -> dx = +1; + case 1 -> dz = +1; + case 2 -> dx = -1; + case 3 -> dz = -1; } // how far do we branch? diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleFoundation48.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleFoundation48.java index 8fd4b5d74e..d56f3550f4 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleFoundation48.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleFoundation48.java @@ -29,7 +29,7 @@ public ComponentTFFinalCastleFoundation48(Random rand, int i, StructureTFCompone } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleLargeTower.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleLargeTower.java index 813841b3b7..293eaac3cc 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleLargeTower.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleLargeTower.java @@ -25,7 +25,7 @@ public ComponentTFFinalCastleLargeTower(Random rand, int i, int x, int y, int z, } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleMain.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleMain.java index aab11e095f..5d37359c6a 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleMain.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleMain.java @@ -45,9 +45,8 @@ public ComponentTFFinalCastleMain(World world, Random rand, int i, int x, int y, } } - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { // add foundation ComponentTFFinalCastleFoundation48 foundation = new ComponentTFFinalCastleFoundation48(rand, 4, this); list.add(foundation); @@ -232,18 +231,10 @@ protected ChunkCoordinates offsetTowerCCoords(int x, int y, int z, int howFar, i int dz = getZWithOffset(x, z); switch (direction) { - case 0: - dx += howFar; - break; - case 1: - dz += howFar; - break; - case 2: - dx -= howFar; - break; - case 3: - dz -= howFar; - break; + case 0 -> dx += howFar; + case 1 -> dz += howFar; + case 2 -> dx -= howFar; + case 3 -> dz -= howFar; } // ugh? diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleMazeTower13.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleMazeTower13.java index 8b7508c1a8..fef120a4c7 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleMazeTower13.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleMazeTower13.java @@ -88,7 +88,7 @@ public ComponentTFFinalCastleMazeTower13(Random rand, int i, int x, int y, int z } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } @@ -507,18 +507,10 @@ protected ChunkCoordinates offsetTowerCCoords(int x, int y, int z, int howFar, i int dz = getZWithOffset(x, z); switch (direction) { - case 0: - dx += howFar; - break; - case 1: - dz += howFar; - break; - case 2: - dx -= howFar; - break; - case 3: - dz -= howFar; - break; + case 0 -> dx += howFar; + case 1 -> dz += howFar; + case 2 -> dx -= howFar; + case 3 -> dz -= howFar; } // ugh? return new ChunkCoordinates(dx, dy, dz); diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleMural.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleMural.java index c643b4b917..bceb980de5 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleMural.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleMural.java @@ -163,7 +163,7 @@ private boolean makeVerticalBranch(byte[][] mural, Random rand, int sx, int sy, } if (clear) { int bx = sx; - int by = sy + (plusY ? downLine : -downLine);; + int by = sy + (plusY ? downLine : -downLine); // jag this.fillHorizontalLine(mural, bx, by, 1, plusX); diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleRoof13Conical.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleRoof13Conical.java index 3a37b34af0..11c11cbbf8 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleRoof13Conical.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleRoof13Conical.java @@ -54,7 +54,7 @@ protected void func_143011_b(NBTTagCompound par1NBTTagCompound) { } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleRoof13Crenellated.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleRoof13Crenellated.java index 29d9bb1f38..e0b04f5577 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleRoof13Crenellated.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleRoof13Crenellated.java @@ -29,7 +29,7 @@ public ComponentTFFinalCastleRoof13Crenellated(Random rand, int i, StructureTFCo } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleRoof13Peaked.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleRoof13Peaked.java index 68ca225669..3d142afefa 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleRoof13Peaked.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleRoof13Peaked.java @@ -29,7 +29,7 @@ public ComponentTFFinalCastleRoof13Peaked(Random rand, int i, StructureTFCompone } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleRoof48Crenellated.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleRoof48Crenellated.java index 9623849c51..d05027c1d0 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleRoof48Crenellated.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleRoof48Crenellated.java @@ -30,7 +30,7 @@ public ComponentTFFinalCastleRoof48Crenellated(Random rand, int i, StructureTFCo } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleRoof9Crenellated.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleRoof9Crenellated.java index c2a46ef16b..f995506021 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleRoof9Crenellated.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleRoof9Crenellated.java @@ -28,9 +28,8 @@ public ComponentTFFinalCastleRoof9Crenellated(Random rand, int i, StructureTFCom sideTower.getBoundingBox().maxZ + 2); } - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleStairTower.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleStairTower.java index 6e4e06b7b6..3ec2102840 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleStairTower.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleStairTower.java @@ -26,7 +26,7 @@ public ComponentTFFinalCastleStairTower(Random rand, int i, int x, int y, int z, } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleWreckedTower.java b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleWreckedTower.java index 1acbaaaf7a..705728838c 100644 --- a/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleWreckedTower.java +++ b/src/main/java/twilightforest/structures/finalcastle/ComponentTFFinalCastleWreckedTower.java @@ -17,9 +17,8 @@ public ComponentTFFinalCastleWreckedTower(Random rand, int i, int x, int y, int super(rand, i, x, y, z, direction); } - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } @@ -62,7 +61,7 @@ protected void determineBlockDestroyed(World world, ArrayList areas } protected ArrayList makeInitialDestroyList(Random rand) { - ArrayList areas = new ArrayList(2); + ArrayList areas = new ArrayList<>(2); areas.add( DestroyArea.createNonIntersecting(this.getBoundingBox(), rand, this.getBoundingBox().maxY - 1, areas)); diff --git a/src/main/java/twilightforest/structures/hollowtree/ComponentTFHollowTreeMedBranch.java b/src/main/java/twilightforest/structures/hollowtree/ComponentTFHollowTreeMedBranch.java index 3fd24e248d..561d7e72ea 100644 --- a/src/main/java/twilightforest/structures/hollowtree/ComponentTFHollowTreeMedBranch.java +++ b/src/main/java/twilightforest/structures/hollowtree/ComponentTFHollowTreeMedBranch.java @@ -274,7 +274,7 @@ public boolean addComponentParts(World world, Random random, StructureBoundingBo */ protected void drawBresehnam(World world, StructureBoundingBox sbb, int x1, int y1, int z1, int x2, int y2, int z2, Block blockValue, int metaValue) { - ChunkCoordinates lineCoords[] = TFGenerator.getBresehnamArrayCoords(x1, y1, z1, x2, y2, z2); + ChunkCoordinates[] lineCoords = TFGenerator.getBresehnamArrayCoords(x1, y1, z1, x2, y2, z2); for (ChunkCoordinates coords : lineCoords) { this.placeBlockAtCurrentPosition(world, blockValue, metaValue, coords.posX, coords.posY, coords.posZ, sbb); diff --git a/src/main/java/twilightforest/structures/hollowtree/ComponentTFHollowTreeRoot.java b/src/main/java/twilightforest/structures/hollowtree/ComponentTFHollowTreeRoot.java index 1c9de7d1aa..f86ac8505d 100644 --- a/src/main/java/twilightforest/structures/hollowtree/ComponentTFHollowTreeRoot.java +++ b/src/main/java/twilightforest/structures/hollowtree/ComponentTFHollowTreeRoot.java @@ -79,7 +79,7 @@ public boolean addComponentParts(World world, Random random, StructureBoundingBo */ protected void drawRootLine(World world, StructureBoundingBox sbb, int x1, int y1, int z1, int x2, int y2, int z2, Block blockValue, int metaValue) { - ChunkCoordinates lineCoords[] = TFGenerator.getBresehnamArrayCoords(x1, y1, z1, x2, y2, z2); + ChunkCoordinates[] lineCoords = TFGenerator.getBresehnamArrayCoords(x1, y1, z1, x2, y2, z2); for (ChunkCoordinates coords : lineCoords) { Block block = this.getBlockAtCurrentPosition(world, coords.posX, coords.posY, coords.posZ, sbb); diff --git a/src/main/java/twilightforest/structures/hollowtree/StructureTFHollowTreeStart.java b/src/main/java/twilightforest/structures/hollowtree/StructureTFHollowTreeStart.java index e0f6575e88..7755bfd4b5 100644 --- a/src/main/java/twilightforest/structures/hollowtree/StructureTFHollowTreeStart.java +++ b/src/main/java/twilightforest/structures/hollowtree/StructureTFHollowTreeStart.java @@ -15,7 +15,7 @@ public StructureTFHollowTreeStart() {} public StructureTFHollowTreeStart(World world, Random rand, int chunkX, int chunkZ) { int x = (chunkX << 4) + 8; int z = (chunkZ << 4) + 8; - int y = TFWorld.SEALEVEL + 1;;// world.getTopSolidOrLiquidBlock(x, z); + int y = TFWorld.SEALEVEL + 1;// world.getTopSolidOrLiquidBlock(x, z); StructureTFComponent trunk = new ComponentTFHollowTreeTrunk(world, rand, 0, x, y, z); components.add(trunk); diff --git a/src/main/java/twilightforest/structures/hollowtree/TFHollowTreePieces.java b/src/main/java/twilightforest/structures/hollowtree/TFHollowTreePieces.java index 704731abb6..ec639c922e 100644 --- a/src/main/java/twilightforest/structures/hollowtree/TFHollowTreePieces.java +++ b/src/main/java/twilightforest/structures/hollowtree/TFHollowTreePieces.java @@ -1,9 +1,11 @@ package twilightforest.structures.hollowtree; import net.minecraft.world.gen.structure.MapGenStructureIO; +import net.minecraft.world.gen.structure.StructureComponent; public class TFHollowTreePieces { + @SuppressWarnings("unchecked") public static void registerPieces() { MapGenStructureIO.func_143031_a(ComponentTFHollowTreeLargeBranch.class, "TFHTLB"); MapGenStructureIO.func_143031_a(ComponentTFHollowTreeMedBranch.class, "TFHTMB"); @@ -11,7 +13,10 @@ public static void registerPieces() { MapGenStructureIO.func_143031_a(ComponentTFHollowTreeTrunk.class, "TFHTTr"); MapGenStructureIO.func_143031_a(ComponentTFLeafSphere.class, "TFHTLS"); MapGenStructureIO.func_143031_a(ComponentTFHollowTreeRoot.class, "TFHTRo"); - MapGenStructureIO.func_143031_a(StructureTFHollowTreeStart.class, "TFHTLSt"); + // This was of a broken type, but removing it breaks worldgen on old worlds with weird crashes + MapGenStructureIO.func_143031_a( + (Class) (Class) StructureTFHollowTreeStart.class, + "TFHTLSt"); MapGenStructureIO.func_143031_a(ComponentTFHollowTreeLeafDungeon.class, "TFHTLD"); } diff --git a/src/main/java/twilightforest/structures/icetower/ComponentTFIceTowerBridge.java b/src/main/java/twilightforest/structures/icetower/ComponentTFIceTowerBridge.java index 7303074895..03613f659b 100644 --- a/src/main/java/twilightforest/structures/icetower/ComponentTFIceTowerBridge.java +++ b/src/main/java/twilightforest/structures/icetower/ComponentTFIceTowerBridge.java @@ -46,9 +46,8 @@ protected void func_143011_b(NBTTagCompound par1NBTTagCompound) { this.length = par1NBTTagCompound.getInteger("bridgeLength"); } - @SuppressWarnings({ "rawtypes" }) @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/icetower/ComponentTFIceTowerEntrance.java b/src/main/java/twilightforest/structures/icetower/ComponentTFIceTowerEntrance.java index 5bf9395647..d97b99db0b 100644 --- a/src/main/java/twilightforest/structures/icetower/ComponentTFIceTowerEntrance.java +++ b/src/main/java/twilightforest/structures/icetower/ComponentTFIceTowerEntrance.java @@ -22,9 +22,8 @@ protected boolean shouldHaveBase(Random rand) { return true; } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/icetower/ComponentTFIceTowerMain.java b/src/main/java/twilightforest/structures/icetower/ComponentTFIceTowerMain.java index 54e1f9c7c7..3296a82b55 100644 --- a/src/main/java/twilightforest/structures/icetower/ComponentTFIceTowerMain.java +++ b/src/main/java/twilightforest/structures/icetower/ComponentTFIceTowerMain.java @@ -53,15 +53,14 @@ protected void func_143011_b(NBTTagCompound par1NBTTagCompound) { this.hasBossWing = par1NBTTagCompound.getBoolean("hasBossWing"); } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { super.buildComponent(parent, list, rand); // add entrance tower StructureBoundingBox towerBB = StructureBoundingBox.getNewBoundingBox(); - for (StructureComponent structurecomponent : (List) list) { + for (StructureComponent structurecomponent : list) { towerBB.expandTo(structurecomponent.getBoundingBox()); } diff --git a/src/main/java/twilightforest/structures/icetower/ComponentTFIceTowerStairs.java b/src/main/java/twilightforest/structures/icetower/ComponentTFIceTowerStairs.java index 4016708b84..ddea33e657 100644 --- a/src/main/java/twilightforest/structures/icetower/ComponentTFIceTowerStairs.java +++ b/src/main/java/twilightforest/structures/icetower/ComponentTFIceTowerStairs.java @@ -18,9 +18,8 @@ public ComponentTFIceTowerStairs(int index, int x, int y, int z, int size, int h super(index, x, y, z, size, height, direction); } - @SuppressWarnings({ "rawtypes" }) @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/icetower/ComponentTFIceTowerWing.java b/src/main/java/twilightforest/structures/icetower/ComponentTFIceTowerWing.java index cdc53208e7..05c67f1b29 100644 --- a/src/main/java/twilightforest/structures/icetower/ComponentTFIceTowerWing.java +++ b/src/main/java/twilightforest/structures/icetower/ComponentTFIceTowerWing.java @@ -51,9 +51,8 @@ protected void func_143011_b(NBTTagCompound par1NBTTagCompound) { this.treasureFloor = par1NBTTagCompound.getInteger("treasureFloor"); } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } @@ -157,7 +156,7 @@ public boolean makeTowerWing(List list, Random rand, int ind // System.out.println("Making tower, index = " + index + ", list.size() = " + list.size()); // stop if out of range - if (isOutOfRange((StructureComponent) list.get(0), dx[0], dx[1], dx[2], RANGE)) { + if (isOutOfRange(list.get(0), dx[0], dx[1], dx[2], RANGE)) { return false; } @@ -405,40 +404,18 @@ protected void decorateFloor(World world, Random rand, int floor, int bottom, in private boolean isNoDoorAreaRotated(int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int rotation) { boolean isClear = true; // make a bounding box of the area - StructureBoundingBox exclusionBox; - switch (rotation) { - case 0: - default: - exclusionBox = new StructureBoundingBox(minX, minY, minZ, maxX, maxY, maxZ); - break; - case 1: - exclusionBox = new StructureBoundingBox( - this.size - 1 - maxZ, - minY, - minX, - this.size - 1 - minZ, - maxY, - maxX); - break; - case 2: - exclusionBox = new StructureBoundingBox( - this.size - 1 - maxX, - minY, - this.size - 1 - maxZ, - this.size - 1 - minX, - maxY, - this.size - 1 - minZ); - break; - case 3: - exclusionBox = new StructureBoundingBox( - minZ, - minY, - this.size - 1 - maxX, - maxZ, - maxY, - this.size - 1 - minX); - break; - } + StructureBoundingBox exclusionBox = switch (rotation) { + default -> new StructureBoundingBox(minX, minY, minZ, maxX, maxY, maxZ); + case 1 -> new StructureBoundingBox(this.size - 1 - maxZ, minY, minX, this.size - 1 - minZ, maxY, maxX); + case 2 -> new StructureBoundingBox( + this.size - 1 - maxX, + minY, + this.size - 1 - maxZ, + this.size - 1 - minX, + maxY, + this.size - 1 - minZ); + case 3 -> new StructureBoundingBox(minZ, minY, this.size - 1 - maxX, maxZ, maxY, this.size - 1 - minX); + }; for (ChunkCoordinates door : this.openings) { if (exclusionBox.isVecInside(door.posX, door.posY, door.posZ)) { diff --git a/src/main/java/twilightforest/structures/lichtower/ComponentTFTowerBridge.java b/src/main/java/twilightforest/structures/lichtower/ComponentTFTowerBridge.java index 189e4b8645..0f9ffedade 100644 --- a/src/main/java/twilightforest/structures/lichtower/ComponentTFTowerBridge.java +++ b/src/main/java/twilightforest/structures/lichtower/ComponentTFTowerBridge.java @@ -27,9 +27,8 @@ protected ComponentTFTowerBridge(int i, int x, int y, int z, int pSize, int pHei this.dHeight = pHeight; } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { int[] dest = new int[] { 2, 1, 1 };// getValidOpening(rand, 0); diff --git a/src/main/java/twilightforest/structures/lichtower/ComponentTFTowerMain.java b/src/main/java/twilightforest/structures/lichtower/ComponentTFTowerMain.java index daacce9a34..0b3d06d875 100644 --- a/src/main/java/twilightforest/structures/lichtower/ComponentTFTowerMain.java +++ b/src/main/java/twilightforest/structures/lichtower/ComponentTFTowerMain.java @@ -26,7 +26,7 @@ public ComponentTFTowerMain(World world, Random rand, int index, int x, int y, i } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { // add a roof? makeARoof(parent, list, rand); @@ -105,24 +105,24 @@ public int[] getOutbuildingOpening(Random rand, int rotation) { int rz = 0; switch (rotation) { - case 0: + case 0 -> { // for directions 0 or 2, the wall lies along the z axis rx = size - 1; rz = 6 + rand.nextInt(8); - break; - case 1: + } + case 1 -> { // for directions 1 or 3, the wall lies along the x axis rx = 1 + rand.nextInt(11); rz = size - 1; - break; - case 2: + } + case 2 -> { rx = 0; rz = 1 + rand.nextInt(8); - break; - case 3: + } + case 3 -> { rx = 3 + rand.nextInt(11); rz = 0; - break; + } } return new int[] { rx, ry, rz }; @@ -261,19 +261,12 @@ protected void makeStairCrossing(World world, Random rand, int flight, Structure placeBlockAtCurrentPosition(world, Blocks.fence, 0, 9, floorLevel, 3, sbb); // place spawner in the middle - String mobID = "Skeleton"; - switch (rand.nextInt(4)) { - case 0: - case 1: - mobID = "Skeleton"; - break; - case 2: - mobID = "Zombie"; - break; - case 3: - mobID = TFCreatures.getSpawnerNameFor("Swarm Spider"); - break; - } + String mobID = switch (rand.nextInt(4)) { + case 0, 1 -> "Skeleton"; + case 2 -> "Zombie"; + case 3 -> TFCreatures.getSpawnerNameFor("Swarm Spider"); + default -> "Skeleton"; + }; placeSpawnerAtCurrentPosition(world, rand, 7, floorLevel + 2, 7, mobID, sbb); // make a fence arch support for the spawner @@ -476,18 +469,10 @@ protected void generateTorchesOnWall(World world, Random rand, int floorLevel, i // offset to see where the fence should be ChunkCoordinates tCoords = new ChunkCoordinates(wCoords); switch (direction) { - case 0: - tCoords.posZ++; - break; - case 1: - tCoords.posX--; - break; - case 2: - tCoords.posZ--; - break; - case 3: - tCoords.posX++; - break; + case 0 -> tCoords.posZ++; + case 1 -> tCoords.posX--; + case 2 -> tCoords.posZ--; + case 3 -> tCoords.posX++; } // is there a painting or another torch there? diff --git a/src/main/java/twilightforest/structures/lichtower/ComponentTFTowerRoof.java b/src/main/java/twilightforest/structures/lichtower/ComponentTFTowerRoof.java index 268a37201e..68415ac1fb 100644 --- a/src/main/java/twilightforest/structures/lichtower/ComponentTFTowerRoof.java +++ b/src/main/java/twilightforest/structures/lichtower/ComponentTFTowerRoof.java @@ -57,42 +57,34 @@ protected void func_143011_b(NBTTagCompound par1NBTTagCompound) { protected void makeAttachedOverhangBB(ComponentTFTowerWing wing) { // just hang out at the very top of the tower switch (getCoordBaseMode()) { - case 0: - this.boundingBox = new StructureBoundingBox( - wing.getBoundingBox().minX, - wing.getBoundingBox().maxY, - wing.getBoundingBox().minZ - 1, - wing.getBoundingBox().maxX + 1, - wing.getBoundingBox().maxY + this.height - 1, - wing.getBoundingBox().maxZ + 1); - break; - case 1: - this.boundingBox = new StructureBoundingBox( - wing.getBoundingBox().minX - 1, - wing.getBoundingBox().maxY, - wing.getBoundingBox().minZ, - wing.getBoundingBox().maxX + 1, - wing.getBoundingBox().maxY + this.height - 1, - wing.getBoundingBox().maxZ + 1); - break; - case 2: - this.boundingBox = new StructureBoundingBox( - wing.getBoundingBox().minX - 1, - wing.getBoundingBox().maxY, - wing.getBoundingBox().minZ - 1, - wing.getBoundingBox().maxX, - wing.getBoundingBox().maxY + this.height - 1, - wing.getBoundingBox().maxZ + 1); - break; - case 3: - this.boundingBox = new StructureBoundingBox( - wing.getBoundingBox().minX - 1, - wing.getBoundingBox().maxY, - wing.getBoundingBox().minZ - 1, - wing.getBoundingBox().maxX + 1, - wing.getBoundingBox().maxY + this.height - 1, - wing.getBoundingBox().maxZ); - break; + case 0 -> this.boundingBox = new StructureBoundingBox( + wing.getBoundingBox().minX, + wing.getBoundingBox().maxY, + wing.getBoundingBox().minZ - 1, + wing.getBoundingBox().maxX + 1, + wing.getBoundingBox().maxY + this.height - 1, + wing.getBoundingBox().maxZ + 1); + case 1 -> this.boundingBox = new StructureBoundingBox( + wing.getBoundingBox().minX - 1, + wing.getBoundingBox().maxY, + wing.getBoundingBox().minZ, + wing.getBoundingBox().maxX + 1, + wing.getBoundingBox().maxY + this.height - 1, + wing.getBoundingBox().maxZ + 1); + case 2 -> this.boundingBox = new StructureBoundingBox( + wing.getBoundingBox().minX - 1, + wing.getBoundingBox().maxY, + wing.getBoundingBox().minZ - 1, + wing.getBoundingBox().maxX, + wing.getBoundingBox().maxY + this.height - 1, + wing.getBoundingBox().maxZ + 1); + case 3 -> this.boundingBox = new StructureBoundingBox( + wing.getBoundingBox().minX - 1, + wing.getBoundingBox().maxY, + wing.getBoundingBox().minZ - 1, + wing.getBoundingBox().maxX + 1, + wing.getBoundingBox().maxY + this.height - 1, + wing.getBoundingBox().maxZ); } } diff --git a/src/main/java/twilightforest/structures/lichtower/ComponentTFTowerWing.java b/src/main/java/twilightforest/structures/lichtower/ComponentTFTowerWing.java index 64882f5ae7..c170331da1 100644 --- a/src/main/java/twilightforest/structures/lichtower/ComponentTFTowerWing.java +++ b/src/main/java/twilightforest/structures/lichtower/ComponentTFTowerWing.java @@ -2,12 +2,10 @@ import java.nio.IntBuffer; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.Random; import net.minecraft.block.Block; -import net.minecraft.block.BlockMushroom; import net.minecraft.block.BlockSapling; import net.minecraft.block.BlockSlab; import net.minecraft.entity.Entity; @@ -37,7 +35,7 @@ public ComponentTFTowerWing() { protected int height; protected Class roofType; - protected ArrayList openings = new ArrayList(); + protected ArrayList openings = new ArrayList<>(); protected int highestOpening; protected boolean[] openingTowards = new boolean[] { false, false, true, false }; @@ -126,7 +124,7 @@ private void readOpeningsFromArray(int[] intArray) { } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { // we should have a door where we started addOpening(0, 1, size / 2, 2); @@ -605,7 +603,7 @@ protected void decorateSkeletonRoom(World world, Random rand, int bottom, int to placeSpawnerAtCurrentPosition(world, rand, size / 2, bottom + 2, size / 2, "Skeleton", sbb); // floor-to-ceiling chains - ArrayList chainList = new ArrayList(); + ArrayList chainList = new ArrayList<>(); chainList.add(new ChunkCoordinates(size / 2, bottom + 2, size / 2)); // don't block the spawner for (int i = 0; i < size + 2; i++) { ChunkCoordinates chain = new ChunkCoordinates( @@ -657,7 +655,7 @@ protected void decorateZombieRoom(World world, Random rand, int bottom, int top, } // slab tables - ArrayList slabList = new ArrayList(); + ArrayList slabList = new ArrayList<>(); slabList.add(new ChunkCoordinates(size / 2, bottom + 2, size / 2)); // don't block the spawner for (int i = 0; i < size - 1; i++) { ChunkCoordinates slab = new ChunkCoordinates( @@ -694,7 +692,7 @@ protected void decorateCactusRoom(World world, Random rand, int bottom, int top, } // cacti - ArrayList cactusList = new ArrayList(); + ArrayList cactusList = new ArrayList<>(); cactusList.add(new ChunkCoordinates(size / 2, bottom + 2, size / 2)); // don't block the spawner for (int i = 0; i < size + 12; i++) { ChunkCoordinates cactus = new ChunkCoordinates( @@ -814,22 +812,12 @@ protected void decorateSpiderWebs(World world, Random rand, int bottom, int top, // 20% chance of a spider spawner! if (rand.nextInt(5) == 0) { - String spiderName; - switch (rand.nextInt(4)) { - case 3: - spiderName = "CaveSpider"; - break; - case 2: - spiderName = TFCreatures.getSpawnerNameFor("Swarm Spider"); - break; - case 1: - spiderName = TFCreatures.getSpawnerNameFor("Hedge Spider"); - break; - case 0: - default: - spiderName = "Spider"; - break; - } + String spiderName = switch (rand.nextInt(4)) { + case 3 -> "CaveSpider"; + case 2 -> TFCreatures.getSpawnerNameFor("Swarm Spider"); + case 1 -> TFCreatures.getSpawnerNameFor("Hedge Spider"); + default -> "Spider"; + }; placeSpawnerAtCurrentPosition(world, rand, size / 2, bottom + 2, size / 2, spiderName, sbb); @@ -1080,9 +1068,7 @@ protected boolean isWindowPos(int x, int y, int z) { * Although since there's usually only one opening, I guess it's not bad. */ protected boolean isOpeningPos(int x, int y, int z) { - Iterator itr = openings.iterator(); - while (itr.hasNext()) { - ChunkCoordinates door = itr.next(); + for (ChunkCoordinates door : openings) { // determine which wall we're at ChunkCoordinates inside = new ChunkCoordinates(door); if (inside.posX == 0) { @@ -1122,18 +1108,13 @@ protected boolean isLadderPos(int x, int z, int ladderUpDir, int ladderDownDir) * @return */ protected int getLadderX(int ladderDir) { - switch (ladderDir) { - case 0: - return size - 2; - case 1: - return size / 2 + 1; - case 2: - return 1; - case 3: - return size / 2 - 1; - default: - return size / 2; - } + return switch (ladderDir) { + case 0 -> size - 2; + case 1 -> size / 2 + 1; + case 2 -> 1; + case 3 -> size / 2 - 1; + default -> size / 2; + }; } /** @@ -1144,18 +1125,13 @@ protected int getLadderX(int ladderDir) { */ protected int getLadderZ(int ladderDir) { - switch (ladderDir) { - case 0: - return size / 2 - 1; - case 1: - return size - 2; - case 2: - return size / 2 + 1; - case 3: - return 1; - default: - return size / 2; - } + return switch (ladderDir) { + case 0 -> size / 2 - 1; + case 1 -> size - 2; + case 2 -> size / 2 + 1; + case 3 -> 1; + default -> size / 2; + }; } /** @@ -1213,48 +1189,26 @@ protected void decorateStairTower(World world, Random rand, StructureBoundingBox // decorate below the bottom floor, into the stairs if (base > 8) { switch (rand.nextInt(4)) { - case 0: - decorateChandelier(world, rand, base + 1, sbb); - break; - case 1: - decorateHangingChains(world, rand, base + 1, sbb); - break; - case 2: - decorateFloatingBooks(world, rand, base + 1, sbb); - break; - case 3: - decorateFloatingVines(world, rand, base + 1, sbb); - break; + case 0 -> decorateChandelier(world, rand, base + 1, sbb); + case 1 -> decorateHangingChains(world, rand, base + 1, sbb); + case 2 -> decorateFloatingBooks(world, rand, base + 1, sbb); + case 3 -> decorateFloatingVines(world, rand, base + 1, sbb); } } } else { // decorate the top normally if (size > 5) { switch (rand.nextInt(4)) { - case 0: - decorateChandelier(world, rand, height, sbb); - break; - case 1: - decorateHangingChains(world, rand, height, sbb); - break; - case 2: - decorateFloatingBooks(world, rand, height, sbb); - break; - case 3: - decorateFloatingVines(world, rand, height, sbb); - break; + case 0 -> decorateChandelier(world, rand, height, sbb); + case 1 -> decorateHangingChains(world, rand, height, sbb); + case 2 -> decorateFloatingBooks(world, rand, height, sbb); + case 3 -> decorateFloatingVines(world, rand, height, sbb); } } else if (size > 3) { switch (rand.nextInt(3)) { - case 0: - decorateHangingChains(world, rand, height, sbb); - break; - case 1: - decorateFloatingBooks(world, rand, height, sbb); - break; - case 2: - decorateFloatingVines(world, rand, height, sbb); - break; + case 0 -> decorateHangingChains(world, rand, height, sbb); + case 1 -> decorateFloatingBooks(world, rand, height, sbb); + case 2 -> decorateFloatingVines(world, rand, height, sbb); } } } @@ -1319,7 +1273,7 @@ protected void decorateChandelier(World world, Random rand, int decoTop, Structu */ protected void decorateHangingChains(World world, Random rand, int decoTop, StructureBoundingBox sbb) { // a list of existing chains - ArrayList chainList = new ArrayList(); + ArrayList chainList = new ArrayList<>(); // try size + 2 times to find a chain that does not collide for (int i = 0; i < size + 2; i++) { int filled = size < 15 ? 2 : 4; @@ -1341,9 +1295,7 @@ protected void decorateHangingChains(World world, Random rand, int decoTop, Stru * Return true if the specified coords are orthogonally adjacent to any other coords on the list. */ protected boolean chainCollides(ChunkCoordinates coords, List list) { - Iterator itr = list.iterator(); - while (itr.hasNext()) { - ChunkCoordinates existing = itr.next(); + for (ChunkCoordinates existing : list) { // if x is within 1 and z is equal, we collide if (coords.posZ == existing.posZ && Math.abs(coords.posX - existing.posX) <= 1) { return true; @@ -1374,39 +1326,38 @@ protected void decorateOneChain(World world, Random rand, int dx, int decoTop, i Block ballBlock; int ballMeta; switch (rand.nextInt(10)) { - case 0: + case 0 -> { ballBlock = Blocks.iron_block; ballMeta = 0; - break; - case 1: + } + case 1 -> { ballBlock = Blocks.bookshelf; ballMeta = 0; - break; - case 2: + } + case 2 -> { ballBlock = Blocks.netherrack; ballMeta = 0; - break; - case 3: + } + case 3 -> { ballBlock = Blocks.soul_sand; ballMeta = 0; - break; - case 4: + } + case 4 -> { ballBlock = Blocks.glass; ballMeta = 0; - break; - case 5: + } + case 5 -> { ballBlock = Blocks.lapis_block; ballMeta = 0; - break; - case 6: + } + case 6 -> { ballBlock = Blocks.monster_egg; ballMeta = 2; - break; - case 7: - default: + } + default -> { ballBlock = Blocks.glowstone; ballMeta = 0; - break; + } } placeBlockAtCurrentPosition(world, ballBlock, ballMeta, dx, decoTop - length - 2, dz, sbb); } @@ -1418,7 +1369,7 @@ protected void decorateOneChain(World world, Random rand, int dx, int decoTop, i */ protected void decorateFloatingBooks(World world, Random rand, int decoTop, StructureBoundingBox sbb) { // a list of existing bookshelves - ArrayList shelfList = new ArrayList(); + ArrayList shelfList = new ArrayList<>(); // try size + 2 times to find a shelf that does not collide for (int i = 0; i < size + 2; i++) { int filled = size < 15 ? 2 : 4; @@ -1445,7 +1396,7 @@ protected void decorateFloatingBooks(World world, Random rand, int decoTop, Stru */ protected void decorateFloatingVines(World world, Random rand, int decoTop, StructureBoundingBox sbb) { // a list of existing blocks - ArrayList mossList = new ArrayList(); + ArrayList mossList = new ArrayList<>(); // try size + 2 times to find a rock pillar that does not collide for (int i = 0; i < size + 2; i++) { int filled = size < 15 ? 2 : 4; @@ -1532,18 +1483,13 @@ protected void decorateFloatingVines(World world, Random rand, int decoTop, Stru * @return */ protected int getVineMeta(int vineDir) { - switch ((this.getCoordBaseMode() + vineDir) % 4) { - case 0: - return 8; - case 1: - return 1; - case 2: - return 2; - case 3: - return 4; - default: - return -1; // this is impossible - } + return switch ((this.getCoordBaseMode() + vineDir) % 4) { + case 0 -> 8; + case 1 -> 1; + case 2 -> 2; + case 3 -> 4; + default -> -1; // this is impossible + }; } /** @@ -1571,31 +1517,30 @@ protected void decoratePlanter(World world, Random rand, StructureBoundingBox sb Block planterBlock; int planterMeta; switch (rand.nextInt(6)) { - case 0: + case 0 -> { planterBlock = Blocks.sapling; planterMeta = 0; - break; - case 1: + } + case 1 -> { planterBlock = Blocks.sapling; planterMeta = 1; - break; - case 2: + } + case 2 -> { planterBlock = Blocks.sapling; planterMeta = 2; - break; - case 3: + } + case 3 -> { planterBlock = Blocks.sapling; planterMeta = 3; - break; - case 4: + } + case 4 -> { planterBlock = Blocks.brown_mushroom; planterMeta = 0; - break; - case 5: - default: + } + default -> { planterBlock = Blocks.red_mushroom; planterMeta = 0; - break; + } } placeBlockAtCurrentPosition(world, planterBlock, planterMeta, cx + 0, 2, cz + 0, sbb); @@ -1611,7 +1556,7 @@ protected void decoratePlanter(World world, Random rand, StructureBoundingBox sb int wx = getXWithOffset(cx, cz); int wy = getYWithOffset(2); int wz = getZWithOffset(cx, cz); - ((BlockMushroom) planterBlock).updateTick(world, wx, wy, wz, world.rand); + planterBlock.updateTick(world, wx, wy, wz, world.rand); } // otherwise, place the block into a flowerpot @@ -1810,20 +1755,13 @@ protected int getYByStairs(int rx, Random rand, int direction) { if (size == 5) { rise = 4; // bleh, a switch. - switch (direction) { - case 0: - base = 3; - break; - case 1: - base = 2; - break; - case 2: - base = 5; - break; - case 3: - base = 4; - break; - } + base = switch (direction) { + case 0 -> 3; + case 1 -> 2; + case 2 -> 5; + case 3 -> 4; + default -> base; + }; } int flights = ((height - 6 - base) / rise) + 1; @@ -2228,7 +2166,7 @@ protected void generatePaintingsOnWall(World world, Random rand, int howMany, in * At least one of the painting's parameters must be the specified size or greater */ protected EnumArt getPaintingOfSize(Random rand, int minSize) { - ArrayList valid = new ArrayList(); + ArrayList valid = new ArrayList<>(); for (EnumArt art : EnumArt.values()) { if (art.sizeX >= minSize || art.sizeY >= minSize) { @@ -2247,7 +2185,6 @@ protected EnumArt getPaintingOfSize(Random rand, int minSize) { * This is similar to EntityPainting.isOnValidSurface, except that it does not check for a solid wall behind the * painting. */ - @SuppressWarnings("unchecked") protected boolean checkPainting(World world, EntityPainting painting, StructureBoundingBox sbb) { if (painting == null) { @@ -2296,22 +2233,22 @@ protected ChunkCoordinates getRandomWallSpot(Random rand, int floorLevel, int di // these directions correspond to painting facing directions, not necessarily to the structure // orienting directions switch (direction) { - case 0: + case 0 -> { minZ = this.boundingBox.minZ; maxZ = this.boundingBox.minZ; - break; - case 1: + } + case 1 -> { maxX = this.boundingBox.maxX; minX = this.boundingBox.maxX; - break; - case 2: + } + case 2 -> { maxZ = this.boundingBox.maxZ; minZ = this.boundingBox.maxZ; - break; - case 3: + } + case 3 -> { minX = this.boundingBox.minX; maxX = this.boundingBox.minX; - break; + } } // try 30 times to get a proper result diff --git a/src/main/java/twilightforest/structures/minotaurmaze/ComponentTFMazeEntranceShaft.java b/src/main/java/twilightforest/structures/minotaurmaze/ComponentTFMazeEntranceShaft.java index 10b5729420..2d50403e8d 100644 --- a/src/main/java/twilightforest/structures/minotaurmaze/ComponentTFMazeEntranceShaft.java +++ b/src/main/java/twilightforest/structures/minotaurmaze/ComponentTFMazeEntranceShaft.java @@ -31,9 +31,7 @@ public ComponentTFMazeEntranceShaft(int i, Random rand, int x, int y, int z) { * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent structurecomponent, List list, Random random) { - ; - } + public void buildComponent(StructureComponent structurecomponent, List list, Random random) {} @Override public boolean addComponentParts(World world, Random rand, StructureBoundingBox sbb) { diff --git a/src/main/java/twilightforest/structures/minotaurmaze/ComponentTFMazeRoom.java b/src/main/java/twilightforest/structures/minotaurmaze/ComponentTFMazeRoom.java index 3f40c49ee2..aee515f536 100644 --- a/src/main/java/twilightforest/structures/minotaurmaze/ComponentTFMazeRoom.java +++ b/src/main/java/twilightforest/structures/minotaurmaze/ComponentTFMazeRoom.java @@ -28,9 +28,7 @@ public ComponentTFMazeRoom(int i, Random rand, int x, int y, int z) { * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent structurecomponent, List list, Random random) { - ; - } + public void buildComponent(StructureComponent structurecomponent, List list, Random random) {} @Override public boolean addComponentParts(World world, Random rand, StructureBoundingBox sbb) { diff --git a/src/main/java/twilightforest/structures/minotaurmaze/ComponentTFMazeUpperEntrance.java b/src/main/java/twilightforest/structures/minotaurmaze/ComponentTFMazeUpperEntrance.java index e9516a504a..b1a2ddf3ea 100644 --- a/src/main/java/twilightforest/structures/minotaurmaze/ComponentTFMazeUpperEntrance.java +++ b/src/main/java/twilightforest/structures/minotaurmaze/ComponentTFMazeUpperEntrance.java @@ -31,9 +31,7 @@ public ComponentTFMazeUpperEntrance(int i, Random rand, int x, int y, int z) { * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent structurecomponent, List list, Random random) { - ; - } + public void buildComponent(StructureComponent structurecomponent, List list, Random random) {} @Override public boolean addComponentParts(World world, Random rand, StructureBoundingBox sbb) { diff --git a/src/main/java/twilightforest/structures/minotaurmaze/ComponentTFMinotaurMaze.java b/src/main/java/twilightforest/structures/minotaurmaze/ComponentTFMinotaurMaze.java index d856407917..46cb5d9d66 100644 --- a/src/main/java/twilightforest/structures/minotaurmaze/ComponentTFMinotaurMaze.java +++ b/src/main/java/twilightforest/structures/minotaurmaze/ComponentTFMinotaurMaze.java @@ -17,7 +17,7 @@ public class ComponentTFMinotaurMaze extends StructureTFComponent { private static final int FLOOR_LEVEL = 1; TFMaze maze; - int rcoords[]; + int[] rcoords; private int level; public ComponentTFMinotaurMaze() { @@ -237,28 +237,19 @@ protected ComponentTFMazeDeadEnd makeDeadEnd(Random random, int dx, int dz, int int decorationType = random.nextInt(8); - switch (decorationType) { - default: - case 0: + return switch (decorationType) { + default -> // blank with fence doorway - return new ComponentTFMazeDeadEnd(4, worldX, worldY, worldZ, rotation); - case 1: - return new ComponentTFMazeDeadEndChest(4, worldX, worldY, worldZ, rotation); - case 2: - return new ComponentTFMazeDeadEndTrappedChest(4, worldX, worldY, worldZ, rotation); - case 3: - return new ComponentTFMazeDeadEndTorches(4, worldX, worldY, worldZ, rotation); - case 4: - return new ComponentTFMazeDeadEndFountain(4, worldX, worldY, worldZ, rotation); - case 5: - return new ComponentTFMazeDeadEndFountainLava(4, worldX, worldY, worldZ, rotation); - case 6: - return new ComponentTFMazeDeadEndPainting(4, worldX, worldY, worldZ, rotation); - case 7: - return this.level == 1 ? new ComponentTFMazeDeadEndRoots(4, worldX, worldY, worldZ, rotation) - : new ComponentTFMazeDeadEndShrooms(4, worldX, worldY, worldZ, rotation); - - } + new ComponentTFMazeDeadEnd(4, worldX, worldY, worldZ, rotation); + case 1 -> new ComponentTFMazeDeadEndChest(4, worldX, worldY, worldZ, rotation); + case 2 -> new ComponentTFMazeDeadEndTrappedChest(4, worldX, worldY, worldZ, rotation); + case 3 -> new ComponentTFMazeDeadEndTorches(4, worldX, worldY, worldZ, rotation); + case 4 -> new ComponentTFMazeDeadEndFountain(4, worldX, worldY, worldZ, rotation); + case 5 -> new ComponentTFMazeDeadEndFountainLava(4, worldX, worldY, worldZ, rotation); + case 6 -> new ComponentTFMazeDeadEndPainting(4, worldX, worldY, worldZ, rotation); + case 7 -> this.level == 1 ? new ComponentTFMazeDeadEndRoots(4, worldX, worldY, worldZ, rotation) + : new ComponentTFMazeDeadEndShrooms(4, worldX, worldY, worldZ, rotation); + }; } @@ -269,20 +260,14 @@ protected ComponentTFMazeCorridor makeCorridor(Random random, int dx, int dz, in int decorationType = random.nextInt(5); - switch (decorationType) { - default: - case 0: - return null; - case 1: - return new ComponentTFMazeCorridor(4, worldX, worldY, worldZ, rotation); - case 2: - return new ComponentTFMazeCorridorIronFence(4, worldX, worldY, worldZ, rotation); - case 3: - return null; // painting - case 4: - return this.level == 1 ? new ComponentTFMazeCorridorRoots(4, worldX, worldY, worldZ, rotation) - : new ComponentTFMazeCorridorShrooms(4, worldX, worldY, worldZ, rotation); - } + return switch (decorationType) { + default -> null; + case 1 -> new ComponentTFMazeCorridor(4, worldX, worldY, worldZ, rotation); + case 2 -> new ComponentTFMazeCorridorIronFence(4, worldX, worldY, worldZ, rotation); + case 3 -> null; // painting + case 4 -> this.level == 1 ? new ComponentTFMazeCorridorRoots(4, worldX, worldY, worldZ, rotation) + : new ComponentTFMazeCorridorShrooms(4, worldX, worldY, worldZ, rotation); + }; } diff --git a/src/main/java/twilightforest/structures/mushroomtower/ComponentTFMushroomTowerBridge.java b/src/main/java/twilightforest/structures/mushroomtower/ComponentTFMushroomTowerBridge.java index f1e1afb116..c182749863 100644 --- a/src/main/java/twilightforest/structures/mushroomtower/ComponentTFMushroomTowerBridge.java +++ b/src/main/java/twilightforest/structures/mushroomtower/ComponentTFMushroomTowerBridge.java @@ -53,7 +53,7 @@ protected void func_143011_b(NBTTagCompound par1NBTTagCompound) { } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/mushroomtower/ComponentTFMushroomTowerMain.java b/src/main/java/twilightforest/structures/mushroomtower/ComponentTFMushroomTowerMain.java index 3b4f1a3995..471e2dd0e4 100644 --- a/src/main/java/twilightforest/structures/mushroomtower/ComponentTFMushroomTowerMain.java +++ b/src/main/java/twilightforest/structures/mushroomtower/ComponentTFMushroomTowerMain.java @@ -48,7 +48,7 @@ protected ComponentTFMushroomTowerMain(int i, int x, int y, int z, int pSize, in } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/mushroomtower/ComponentTFMushroomTowerWing.java b/src/main/java/twilightforest/structures/mushroomtower/ComponentTFMushroomTowerWing.java index f711a95de4..ab73e5d3f1 100644 --- a/src/main/java/twilightforest/structures/mushroomtower/ComponentTFMushroomTowerWing.java +++ b/src/main/java/twilightforest/structures/mushroomtower/ComponentTFMushroomTowerWing.java @@ -53,7 +53,7 @@ protected void func_143011_b(NBTTagCompound par1NBTTagCompound) { } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } @@ -191,8 +191,7 @@ protected int[] adjustCoordinates(int x, int y, int z, int wingSize, int directi // go through list. if there are any same size towers within wingSize, return their xyz instead for (Object obj : list) { - if (obj instanceof ComponentTFTowerWing && !(obj instanceof ComponentTFMushroomTowerBridge)) { - ComponentTFTowerWing otherWing = (ComponentTFTowerWing) obj; + if (obj instanceof ComponentTFTowerWing otherWing && !(obj instanceof ComponentTFMushroomTowerBridge)) { if (wingSize == otherWing.size && otherWing.getBoundingBox().intersectsWith(x - 3, z - 3, x + 3, z + 3)) { @@ -203,14 +202,18 @@ protected int[] adjustCoordinates(int x, int y, int z, int wingSize, int directi // otherWing.getBoundingBox().minZ + " other.maxZ = " + otherWing.getBoundingBox().maxZ); switch (direction) { - case 0: + case 0 -> { return new int[] { otherWing.getBoundingBox().minX, y, otherWing.getBoundingBox().minZ }; - case 1: + } + case 1 -> { return new int[] { otherWing.getBoundingBox().maxX, y, otherWing.getBoundingBox().minZ }; - case 2: + } + case 2 -> { return new int[] { otherWing.getBoundingBox().maxX, y, otherWing.getBoundingBox().maxZ }; - case 3: + } + case 3 -> { return new int[] { otherWing.getBoundingBox().minX, y, otherWing.getBoundingBox().maxZ }; + } } } } @@ -230,9 +233,8 @@ private boolean isHighest(StructureBoundingBox boundingBox, int size, List list) boxAbove.maxY = 256; for (Object obj : list) { - if (this != obj && obj instanceof ComponentTFTowerWing + if (this != obj && obj instanceof ComponentTFTowerWing otherWing && !(obj instanceof ComponentTFMushroomTowerBridge)) { - ComponentTFTowerWing otherWing = (ComponentTFTowerWing) obj; if (size == otherWing.size && otherWing.getBoundingBox().intersectsWith(boxAbove)) { // System.out.println("This tower (" + boundingBox + ") is not the highest, there is " + otherWing + diff --git a/src/main/java/twilightforest/structures/mushroomtower/ComponentTFTowerRoofMushroom.java b/src/main/java/twilightforest/structures/mushroomtower/ComponentTFTowerRoofMushroom.java index f8ae05fcaf..06bd42f820 100644 --- a/src/main/java/twilightforest/structures/mushroomtower/ComponentTFTowerRoofMushroom.java +++ b/src/main/java/twilightforest/structures/mushroomtower/ComponentTFTowerRoofMushroom.java @@ -36,7 +36,7 @@ public ComponentTFTowerRoofMushroom(int i, ComponentTFTowerWing wing, float pHan } @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } diff --git a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdAccessChamber.java b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdAccessChamber.java index 76bae46b42..85da7ed45b 100644 --- a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdAccessChamber.java +++ b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdAccessChamber.java @@ -30,7 +30,7 @@ public StructureBoundingBox generateBoundingBox(int facing, int x, int y, int z) * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent parent, List list, Random random) { + public void buildComponent(StructureComponent parent, List list, Random random) { super.buildComponent(parent, list, random); // make a random component in each direction diff --git a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdAtrium.java b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdAtrium.java index 414ec443aa..1f396a4d35 100644 --- a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdAtrium.java +++ b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdAtrium.java @@ -71,7 +71,7 @@ public StructureBoundingBox generateBoundingBox(int facing, int x, int y, int z) * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent parent, List list, Random random) { + public void buildComponent(StructureComponent parent, List list, Random random) { super.buildComponent(parent, list, random); if (this.enterBottom) { @@ -146,27 +146,19 @@ private void spawnATree(World world, int treeNum, int x, int y, int z, Structure // grow a tree int minHeight = 8; - switch (treeNum) { - case 0: - default: + treeGen = switch (treeNum) { + default -> // oak tree - treeGen = new WorldGenTrees(true, minHeight, 0, 0, false); - break; - case 1: + new WorldGenTrees(true, minHeight, 0, 0, false); + case 1 -> // jungle tree - treeGen = new WorldGenTrees(true, minHeight, 3, 3, false); - break; - case 2: + new WorldGenTrees(true, minHeight, 3, 3, false); + case 2 -> // birch - treeGen = new WorldGenTrees(true, minHeight, 2, 2, false); - break; - case 3: - treeGen = new TFGenSmallTwilightOak(false, minHeight); - break; - case 4: - treeGen = new TFGenSmallRainboak(false); - break; - } + new WorldGenTrees(true, minHeight, 2, 2, false); + case 3 -> new TFGenSmallTwilightOak(false, minHeight); + case 4 -> new TFGenSmallRainboak(false); + }; for (int i = 0; i < 100; i++) { if (treeGen.generate(world, world.rand, dx, dy, dz)) { diff --git a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdBalconyRoom.java b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdBalconyRoom.java index c09fa52618..a4488cceec 100644 --- a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdBalconyRoom.java +++ b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdBalconyRoom.java @@ -66,7 +66,7 @@ public StructureBoundingBox generateBoundingBox(int facing, int x, int y, int z) * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent parent, List list, Random random) { + public void buildComponent(StructureComponent parent, List list, Random random) { super.buildComponent(parent, list, random); // lower left exit diff --git a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdBossRoom.java b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdBossRoom.java index 1eba3f128c..9aaf0569bb 100644 --- a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdBossRoom.java +++ b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdBossRoom.java @@ -33,7 +33,7 @@ public StructureBoundingBox generateBoundingBox(int facing, int x, int y, int z) * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent parent, List list, Random random) { + public void buildComponent(StructureComponent parent, List list, Random random) { super.buildComponent(parent, list, random); this.addDoor(13, 1, 0); diff --git a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdCrossing.java b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdCrossing.java index c969b6bf41..20bd03dbe7 100644 --- a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdCrossing.java +++ b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdCrossing.java @@ -30,7 +30,7 @@ public StructureBoundingBox generateBoundingBox(int facing, int x, int y, int z) * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent parent, List list, Random random) { + public void buildComponent(StructureComponent parent, List list, Random random) { super.buildComponent(parent, list, random); this.addDoor(13, 1, 0); diff --git a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdDeadEnd.java b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdDeadEnd.java index 15e3b0423d..5739f7d073 100644 --- a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdDeadEnd.java +++ b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdDeadEnd.java @@ -55,7 +55,7 @@ public StructureBoundingBox generateBoundingBox(int facing, int x, int y, int z) * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent parent, List list, Random random) { + public void buildComponent(StructureComponent parent, List list, Random random) { super.buildComponent(parent, list, random); // entrance diff --git a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdEntrance.java b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdEntrance.java index 1250f3d9e4..148fd5e51a 100644 --- a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdEntrance.java +++ b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdEntrance.java @@ -29,31 +29,30 @@ public ComponentTFStrongholdEntrance(World world, Random rand, int i, int x, int * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent parent, List list, Random random) { - super.buildComponent(parent, list, random); + public void buildComponent(StructureComponent parent, List pieceList, Random random) { + super.buildComponent(parent, pieceList, random); // make a random component in each direction lowerPieces.prepareStructurePieces(); - addNewComponent(parent, list, random, 0, 4, 1, 18); + addNewComponent(parent, pieceList, random, 0, 4, 1, 18); lowerPieces.prepareStructurePieces(); - if (listContainsBossRoom(list)) { + if (listContainsBossRoom(pieceList)) { lowerPieces.markBossRoomUsed(); } - addNewComponent(parent, list, random, 1, -1, 1, 13); + addNewComponent(parent, pieceList, random, 1, -1, 1, 13); lowerPieces.prepareStructurePieces(); - if (listContainsBossRoom(list)) { + if (listContainsBossRoom(pieceList)) { lowerPieces.markBossRoomUsed(); } - addNewComponent(parent, list, random, 2, 13, 1, -1); + addNewComponent(parent, pieceList, random, 2, 13, 1, -1); lowerPieces.prepareStructurePieces(); - if (listContainsBossRoom(list)) { + if (listContainsBossRoom(pieceList)) { lowerPieces.markBossRoomUsed(); } - addNewComponent(parent, list, random, 3, 18, 1, 4); - if (!listContainsBossRoom(list)) { + addNewComponent(parent, pieceList, random, 3, 18, 1, 4); + if (!listContainsBossRoom(pieceList)) { FMLLog.fine("[TwilightForest] Did not find boss room from exit 3 - EPIC FAIL"); } - List pieceList = (List) list; StructureBoundingBox shieldBox = new StructureBoundingBox(this.boundingBox); int tStairs = 0; @@ -63,7 +62,7 @@ public void buildComponent(StructureComponent parent, List list, Random random) int bossRooms = 0; // compute and generate MEGASHIELD - for (StructureTFStrongholdComponent component : pieceList) { + for (StructureComponent component : pieceList) { shieldBox.expandTo(component.getBoundingBox()); if (component instanceof ComponentTFStrongholdSmallStairs @@ -102,8 +101,8 @@ public void buildComponent(StructureComponent parent, List list, Random random) boundingBox.minX + 8, boundingBox.minY + 7, boundingBox.minZ + 4); - list.add(accessChamber); - accessChamber.buildComponent(this, list, random); + pieceList.add(accessChamber); + accessChamber.buildComponent(this, pieceList, random); } diff --git a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdFoundry.java b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdFoundry.java index 02aa3a3736..0289d74e11 100644 --- a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdFoundry.java +++ b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdFoundry.java @@ -60,27 +60,28 @@ public StructureBoundingBox generateBoundingBox(int facing, int x, int y, int z) * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent parent, List list, Random random) { + public void buildComponent(StructureComponent parent, List list, Random random) { super.buildComponent(parent, list, random); switch (this.entranceLevel) { - case 1: + case 1 -> { this.addDoor(4, 6, 0); addNewComponent(parent, list, random, 1, -1, 13, 13); addNewComponent(parent, list, random, 3, 18, 13, 4); addNewComponent(parent, list, random, 0, 13, 20, 18); - break; - case 2: + } + case 2 -> { this.addDoor(4, 13, 0); addNewComponent(parent, list, random, 1, -1, 6, 13); addNewComponent(parent, list, random, 3, 18, 20, 4); addNewComponent(parent, list, random, 0, 13, 13, 18); - break; - case 3: + } + case 3 -> { this.addDoor(4, 20, 0); addNewComponent(parent, list, random, 0, 13, 6, 18); addNewComponent(parent, list, random, 1, -1, 13, 13); addNewComponent(parent, list, random, 3, 18, 13, 4); + } } } diff --git a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdLeftTurn.java b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdLeftTurn.java index 554b42fd7a..1c19d88ce5 100644 --- a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdLeftTurn.java +++ b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdLeftTurn.java @@ -29,7 +29,7 @@ public StructureBoundingBox generateBoundingBox(int facing, int x, int y, int z) * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent parent, List list, Random random) { + public void buildComponent(StructureComponent parent, List list, Random random) { super.buildComponent(parent, list, random); // entrance diff --git a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdRightTurn.java b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdRightTurn.java index 9fab9e213f..7879a7d23f 100644 --- a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdRightTurn.java +++ b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdRightTurn.java @@ -29,7 +29,7 @@ public StructureBoundingBox generateBoundingBox(int facing, int x, int y, int z) * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent parent, List list, Random random) { + public void buildComponent(StructureComponent parent, List list, Random random) { super.buildComponent(parent, list, random); // entrance diff --git a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdSmallHallway.java b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdSmallHallway.java index 6f49a310e2..452a6fcb09 100644 --- a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdSmallHallway.java +++ b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdSmallHallway.java @@ -29,7 +29,7 @@ public StructureBoundingBox generateBoundingBox(int facing, int x, int y, int z) * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent parent, List list, Random random) { + public void buildComponent(StructureComponent parent, List list, Random random) { super.buildComponent(parent, list, random); // entrance diff --git a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdSmallStairs.java b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdSmallStairs.java index 8ba0167143..c53a8fed5b 100644 --- a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdSmallStairs.java +++ b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdSmallStairs.java @@ -74,7 +74,7 @@ public StructureBoundingBox generateBoundingBox(int facing, int x, int y, int z) * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent parent, List list, Random random) { + public void buildComponent(StructureComponent parent, List list, Random random) { super.buildComponent(parent, list, random); if (this.enterBottom) { diff --git a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdTrainingRoom.java b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdTrainingRoom.java index 8e639d14d8..b04c07226f 100644 --- a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdTrainingRoom.java +++ b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdTrainingRoom.java @@ -30,7 +30,7 @@ public StructureBoundingBox generateBoundingBox(int facing, int x, int y, int z) * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent parent, List list, Random random) { + public void buildComponent(StructureComponent parent, List list, Random random) { super.buildComponent(parent, list, random); this.addDoor(13, 1, 0); diff --git a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdTreasureCorridor.java b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdTreasureCorridor.java index 5c42bccbe1..3950b68a2b 100644 --- a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdTreasureCorridor.java +++ b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdTreasureCorridor.java @@ -31,7 +31,7 @@ public StructureBoundingBox generateBoundingBox(int facing, int x, int y, int z) * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent parent, List list, Random random) { + public void buildComponent(StructureComponent parent, List list, Random random) { super.buildComponent(parent, list, random); // entrance diff --git a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdTreasureRoom.java b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdTreasureRoom.java index 0b2f2a314e..9a71c991fe 100644 --- a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdTreasureRoom.java +++ b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdTreasureRoom.java @@ -56,7 +56,7 @@ public StructureBoundingBox generateBoundingBox(int facing, int x, int y, int z) * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent parent, List list, Random random) { + public void buildComponent(StructureComponent parent, List list, Random random) { super.buildComponent(parent, list, random); this.addDoor(4, 1, 0); diff --git a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdUpperAscender.java b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdUpperAscender.java index 307f35e99b..0a47ab5c52 100644 --- a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdUpperAscender.java +++ b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdUpperAscender.java @@ -58,7 +58,7 @@ public StructureBoundingBox generateBoundingBox(int facing, int x, int y, int z) * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent parent, List list, Random random) { + public void buildComponent(StructureComponent parent, List list, Random random) { super.buildComponent(parent, list, random); // make a random component on the other side diff --git a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdUpperCorridor.java b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdUpperCorridor.java index cdec91f7c3..67e18aae7b 100644 --- a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdUpperCorridor.java +++ b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdUpperCorridor.java @@ -29,7 +29,7 @@ public StructureBoundingBox generateBoundingBox(int facing, int x, int y, int z) * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent parent, List list, Random random) { + public void buildComponent(StructureComponent parent, List list, Random random) { super.buildComponent(parent, list, random); // make a random component at the end diff --git a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdUpperLeftTurn.java b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdUpperLeftTurn.java index 4d3e91fad3..f5cd1b3619 100644 --- a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdUpperLeftTurn.java +++ b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdUpperLeftTurn.java @@ -29,7 +29,7 @@ public StructureBoundingBox generateBoundingBox(int facing, int x, int y, int z) * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent parent, List list, Random random) { + public void buildComponent(StructureComponent parent, List list, Random random) { super.buildComponent(parent, list, random); // make a random component to the left diff --git a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdUpperRightTurn.java b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdUpperRightTurn.java index 053f002ee9..419c83308e 100644 --- a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdUpperRightTurn.java +++ b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdUpperRightTurn.java @@ -29,7 +29,7 @@ public StructureBoundingBox generateBoundingBox(int facing, int x, int y, int z) * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent parent, List list, Random random) { + public void buildComponent(StructureComponent parent, List list, Random random) { super.buildComponent(parent, list, random); // make a random component to the right diff --git a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdUpperTIntersection.java b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdUpperTIntersection.java index 41b03d1138..50af96ce89 100644 --- a/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdUpperTIntersection.java +++ b/src/main/java/twilightforest/structures/stronghold/ComponentTFStrongholdUpperTIntersection.java @@ -29,7 +29,7 @@ public StructureBoundingBox generateBoundingBox(int facing, int x, int y, int z) * Initiates construction of the Structure Component picked, at the current Location of StructGen */ @Override - public void buildComponent(StructureComponent parent, List list, Random random) { + public void buildComponent(StructureComponent parent, List list, Random random) { super.buildComponent(parent, list, random); // make a random component to the left diff --git a/src/main/java/twilightforest/structures/stronghold/StructureTFStrongholdComponent.java b/src/main/java/twilightforest/structures/stronghold/StructureTFStrongholdComponent.java index 457b6ad04f..d7e2d8d3a0 100644 --- a/src/main/java/twilightforest/structures/stronghold/StructureTFStrongholdComponent.java +++ b/src/main/java/twilightforest/structures/stronghold/StructureTFStrongholdComponent.java @@ -18,7 +18,7 @@ public abstract class StructureTFStrongholdComponent extends StructureTFComponent { - public List doors = new ArrayList(); + public List doors = new ArrayList<>(); public StructureTFStrongholdComponent() { super(); @@ -85,53 +85,47 @@ private void readOpeningsFromArray(int[] intArray) { */ public static StructureBoundingBox getComponentToAddBoundingBox(int x, int y, int z, int xOff, int yOff, int zOff, int xSize, int ySize, int zSize, int facing) { - switch (facing) { - case 0: - return new StructureBoundingBox( - x + xOff, - y + yOff, - z + zOff, - x + xSize - 1 + xOff, - y + ySize - 1 + yOff, - z + zSize - 1 + zOff); - case 1: - return new StructureBoundingBox( - x - zSize + 1 + zOff, - y + yOff, - z + xOff, - x + zOff, - y + ySize - 1 + yOff, - z + xSize - 1 + xOff); - case 2: - return new StructureBoundingBox( - x - xSize + 1 - xOff, - y + yOff, - z - zSize + 1 + zOff, - x - xOff, - y + ySize - 1 + yOff, - z + zOff); - case 3: - return new StructureBoundingBox( - x + zOff, - y + yOff, - z - xSize + 1 - xOff, - x + zSize - 1 + zOff, - y + ySize - 1 + yOff, - z - xOff); - default: - return new StructureBoundingBox( - x + xOff, - y + yOff, - z + zOff, - x + xSize - 1 + xOff, - y + ySize - 1 + yOff, - z + zSize - 1 + zOff); - } + return switch (facing) { + case 0 -> new StructureBoundingBox( + x + xOff, + y + yOff, + z + zOff, + x + xSize - 1 + xOff, + y + ySize - 1 + yOff, + z + zSize - 1 + zOff); + case 1 -> new StructureBoundingBox( + x - zSize + 1 + zOff, + y + yOff, + z + xOff, + x + zOff, + y + ySize - 1 + yOff, + z + xSize - 1 + xOff); + case 2 -> new StructureBoundingBox( + x - xSize + 1 - xOff, + y + yOff, + z - zSize + 1 + zOff, + x - xOff, + y + ySize - 1 + yOff, + z + zOff); + case 3 -> new StructureBoundingBox( + x + zOff, + y + yOff, + z - xSize + 1 - xOff, + x + zSize - 1 + zOff, + y + ySize - 1 + yOff, + z - xOff); + default -> new StructureBoundingBox( + x + xOff, + y + yOff, + z + zOff, + x + xSize - 1 + xOff, + y + ySize - 1 + yOff, + z + zSize - 1 + zOff); + }; } - @SuppressWarnings("rawtypes") @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { if (parent != null && parent instanceof StructureTFComponent) { this.deco = ((StructureTFComponent) parent).deco; } @@ -207,24 +201,13 @@ protected void addNewUpperComponent(StructureComponent parent, List list, Random } // find a new component - switch (random.nextInt(5)) { - case 0: - default: - attempted = new ComponentTFStrongholdUpperTIntersection(index, nFacing, nx, ny, nz); - break; - case 1: - attempted = new ComponentTFStrongholdUpperLeftTurn(index, nFacing, nx, ny, nz); - break; - case 2: - attempted = new ComponentTFStrongholdUpperRightTurn(index, nFacing, nx, ny, nz); - break; - case 3: - attempted = new ComponentTFStrongholdUpperCorridor(index, nFacing, nx, ny, nz); - break; - case 4: - attempted = new ComponentTFStrongholdUpperAscender(index, nFacing, nx, ny, nz); - break; - } + attempted = switch (random.nextInt(5)) { + default -> new ComponentTFStrongholdUpperTIntersection(index, nFacing, nx, ny, nz); + case 1 -> new ComponentTFStrongholdUpperLeftTurn(index, nFacing, nx, ny, nz); + case 2 -> new ComponentTFStrongholdUpperRightTurn(index, nFacing, nx, ny, nz); + case 3 -> new ComponentTFStrongholdUpperCorridor(index, nFacing, nx, ny, nz); + case 4 -> new ComponentTFStrongholdUpperAscender(index, nFacing, nx, ny, nz); + }; // is it clear? if (attempted != null && StructureComponent.findIntersecting(list, attempted.getBoundingBox()) == null) { @@ -287,15 +270,10 @@ protected void placeDoorwayAt(World world, Random rand, int x, int y, int z, Str } protected int getXSize() { - switch (this.getCoordBaseMode()) { - default: - case 0: - case 2: - return this.boundingBox.getXSize() - 1; - case 1: - case 3: - return this.boundingBox.getZSize() - 1; - } + return switch (this.getCoordBaseMode()) { + default -> this.boundingBox.getXSize() - 1; + case 1, 3 -> this.boundingBox.getZSize() - 1; + }; } /** @@ -613,18 +591,10 @@ public boolean attemptToBreakIn(int wx, int wy, int wz) { */ public void addDoorwayTo(int dx, int dy, int dz, int facing) { switch (facing) { - case 0: - addDoor(dx, dy, dz - 1); - break; - case 1: - addDoor(dx + 1, dy, dz); - break; - case 2: - addDoor(dx, dy, dz + 1); - break; - case 3: - addDoor(dx - 1, dy, dz); - break; + case 0 -> addDoor(dx, dy, dz - 1); + case 1 -> addDoor(dx + 1, dy, dz); + case 2 -> addDoor(dx, dy, dz + 1); + case 3 -> addDoor(dx - 1, dy, dz); } } @@ -653,17 +623,13 @@ protected boolean isValidBreakInPoint(int wx, int wy, int wz) { protected int getRelativeX(int x, int z) { // this.getXWithOffset(x, z); - switch (getCoordBaseMode()) { - case 0: - return x - boundingBox.minX; - case 2: - return boundingBox.maxX - x; - case 1: - return z - boundingBox.minZ; - case 3: - return boundingBox.maxZ - z; - } - return x; + return switch (getCoordBaseMode()) { + case 0 -> x - boundingBox.minX; + case 2 -> boundingBox.maxX - x; + case 1 -> z - boundingBox.minZ; + case 3 -> boundingBox.maxZ - z; + default -> x; + }; } protected int getRelativeY(int par1) { @@ -671,17 +637,13 @@ protected int getRelativeY(int par1) { } protected int getRelativeZ(int x, int z) { - switch (getCoordBaseMode()) { - case 0: - return z - boundingBox.minZ; - case 2: - return boundingBox.maxZ - z; - case 1: - return boundingBox.maxX - x; - case 3: - return x - boundingBox.minX; - } - return z; + return switch (getCoordBaseMode()) { + case 0 -> z - boundingBox.minZ; + case 2 -> boundingBox.maxZ - z; + case 1 -> boundingBox.maxX - x; + case 3 -> x - boundingBox.minX; + default -> z; + }; } /** diff --git a/src/main/java/twilightforest/structures/stronghold/TFStrongholdPieces.java b/src/main/java/twilightforest/structures/stronghold/TFStrongholdPieces.java index 9385c5fc10..a99a4b53a3 100644 --- a/src/main/java/twilightforest/structures/stronghold/TFStrongholdPieces.java +++ b/src/main/java/twilightforest/structures/stronghold/TFStrongholdPieces.java @@ -60,7 +60,7 @@ public static void registerPieces() { * sets up Arrays with the Structure pieces and their weights */ public void prepareStructurePieces() { - pieceList = new ArrayList(); + pieceList = new ArrayList<>(); for (TFStrongholdPieceWeight piece : pieceWeightArray) { piece.instancesSpawned = 0; @@ -90,9 +90,8 @@ private boolean hasMoreLimitedPieces() { return flag; } - @SuppressWarnings("rawtypes") - public StructureTFStrongholdComponent getNextComponent(StructureComponent parent, List list, Random random, - int index, int facing, int x, int y, int z) { + public StructureTFStrongholdComponent getNextComponent(StructureComponent parent, List list, + Random random, int index, int facing, int x, int y, int z) { if (!hasMoreLimitedPieces()) { return null; } else { @@ -150,22 +149,8 @@ private static StructureTFStrongholdComponent instantiateComponent(Class list, Random rand) { // up to two trees // tree in x direction boolean plus = rand.nextBoolean(); diff --git a/src/main/java/twilightforest/structures/trollcave/ComponentTFTrollCaveConnect.java b/src/main/java/twilightforest/structures/trollcave/ComponentTFTrollCaveConnect.java index 73c01bd26a..5635b3eb04 100644 --- a/src/main/java/twilightforest/structures/trollcave/ComponentTFTrollCaveConnect.java +++ b/src/main/java/twilightforest/structures/trollcave/ComponentTFTrollCaveConnect.java @@ -57,9 +57,8 @@ protected void func_143011_b(NBTTagCompound par1NBTTagCompound) { this.openingTowards[3] = par1NBTTagCompound.getBoolean("openingTowards3"); } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { // make 4 caves if (this.getComponentType() < 3) { @@ -183,8 +182,8 @@ protected void makeMonolith(World world, Random rand, StructureBoundingBox sbb) private int countExits() { int count = 0; - for (int i = 0; i < this.openingTowards.length; i++) { - if (this.openingTowards[i] == true) { + for (boolean openingToward : this.openingTowards) { + if (openingToward == true) { count++; } } @@ -440,31 +439,41 @@ private int getMushroomMetaFor(int meta, int rotation) { return meta; case 1: switch (meta) { - case 1: + case 1 -> { return 3; - case 2: + } + case 2 -> { return 6; - case 4: + } + case 4 -> { return 2; - case 7: + } + case 7 -> { return 1; - case 8: + } + case 8 -> { return 4; + } } case 2: return 10 - (meta % 10); case 3: switch (meta) { - case 1: + case 1 -> { return 7; - case 2: + } + case 2 -> { return 4; - case 4: + } + case 4 -> { return 8; - case 7: + } + case 7 -> { return 9; - case 8: + } + case 8 -> { return 6; + } } default: return 15; diff --git a/src/main/java/twilightforest/structures/trollcave/ComponentTFTrollCaveGarden.java b/src/main/java/twilightforest/structures/trollcave/ComponentTFTrollCaveGarden.java index bd4a2a4e26..be9551c14a 100644 --- a/src/main/java/twilightforest/structures/trollcave/ComponentTFTrollCaveGarden.java +++ b/src/main/java/twilightforest/structures/trollcave/ComponentTFTrollCaveGarden.java @@ -33,9 +33,8 @@ public ComponentTFTrollCaveGarden(int index, int x, int y, int z, int caveSize, .getComponentToAddBoundingBox(x, y, z, 0, 0, 0, size - 1, height - 1, size - 1, direction); } - @SuppressWarnings({ "rawtypes" }) @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { // add a cloud // ComponentTFTrollCloud cloud = new ComponentTFTrollCloud(1, boundingBox.minX + ((boundingBox.maxX - // boundingBox.minX) / 2), rand.nextInt(64) + 160, boundingBox.minZ + ((boundingBox.maxZ - boundingBox.minZ) / diff --git a/src/main/java/twilightforest/structures/trollcave/ComponentTFTrollCaveMain.java b/src/main/java/twilightforest/structures/trollcave/ComponentTFTrollCaveMain.java index dd28af5e30..cf3cca5b55 100644 --- a/src/main/java/twilightforest/structures/trollcave/ComponentTFTrollCaveMain.java +++ b/src/main/java/twilightforest/structures/trollcave/ComponentTFTrollCaveMain.java @@ -77,9 +77,8 @@ protected void func_143011_b(NBTTagCompound par1NBTTagCompound) { this.height = par1NBTTagCompound.getInteger("height"); } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { + public void buildComponent(StructureComponent parent, List list, Random rand) { // make 4 caves for (int i = 0; i < 4; i++) { ChunkCoordinates dest = getValidOpening(rand, 5, i); @@ -243,18 +242,13 @@ protected ChunkCoordinates offsetTowerCCoords(int x, int y, int z, int towerSize int dy = getYWithOffset(y); int dz = getZWithOffset(x, z); - switch (direction) { - case 0: - return new ChunkCoordinates(dx - 1, dy - 1, dz - towerSize / 2); - case 1: - return new ChunkCoordinates(dx + towerSize / 2, dy - 1, dz - 1); - case 2: - return new ChunkCoordinates(dx + 1, dy - 1, dz + towerSize / 2); - case 3: - return new ChunkCoordinates(dx - towerSize / 2, dy - 1, dz + 1); - default: - return new ChunkCoordinates(x, y, z); - } + return switch (direction) { + case 0 -> new ChunkCoordinates(dx - 1, dy - 1, dz - towerSize / 2); + case 1 -> new ChunkCoordinates(dx + towerSize / 2, dy - 1, dz - 1); + case 2 -> new ChunkCoordinates(dx + 1, dy - 1, dz + towerSize / 2); + case 3 -> new ChunkCoordinates(dx - towerSize / 2, dy - 1, dz + 1); + default -> new ChunkCoordinates(x, y, z); + }; } public boolean isBoundingBoxOutOfHighlands(World world, StructureBoundingBox sbb) { diff --git a/src/main/java/twilightforest/structures/trollcave/ComponentTFTrollVault.java b/src/main/java/twilightforest/structures/trollcave/ComponentTFTrollVault.java index 2d1ed903f6..95e0d6e84c 100644 --- a/src/main/java/twilightforest/structures/trollcave/ComponentTFTrollVault.java +++ b/src/main/java/twilightforest/structures/trollcave/ComponentTFTrollVault.java @@ -31,11 +31,8 @@ public ComponentTFTrollVault(int index, int x, int y, int z) { this.boundingBox = StructureTFComponent.getComponentToAddBoundingBox(x, y, z, -8, 0, -8, 12, 12, 12, 0); } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void buildComponent(StructureComponent parent, List list, Random rand) { - ; - } + public void buildComponent(StructureComponent parent, List list, Random rand) {} @Override public boolean addComponentParts(World world, Random rand, StructureBoundingBox sbb) { diff --git a/src/main/java/twilightforest/tileentity/TileEntityTFBossSpawner.java b/src/main/java/twilightforest/tileentity/TileEntityTFBossSpawner.java index bbb233234b..a47221aa4f 100644 --- a/src/main/java/twilightforest/tileentity/TileEntityTFBossSpawner.java +++ b/src/main/java/twilightforest/tileentity/TileEntityTFBossSpawner.java @@ -15,9 +15,7 @@ public abstract class TileEntityTFBossSpawner extends TileEntity { protected Entity displayCreature = null; - public TileEntityTFBossSpawner() { - ; - } + public TileEntityTFBossSpawner() {} /** * Is there a player in our detection range? diff --git a/src/main/java/twilightforest/tileentity/TileEntityTFCReactorActive.java b/src/main/java/twilightforest/tileentity/TileEntityTFCReactorActive.java index ef3c2e8990..fb1d5e9d37 100644 --- a/src/main/java/twilightforest/tileentity/TileEntityTFCReactorActive.java +++ b/src/main/java/twilightforest/tileentity/TileEntityTFCReactorActive.java @@ -376,86 +376,70 @@ public void drawBlob(int sx, int sy, int sz, int rad, Block blockValue, int meta if (dist == rad && !(dx == 0 && dy == 0 && dz == 0)) { // do eight at a time for easiness! switch (fuzzX) { - case 0: - transformBlock( - sx + dx, - sy + dy, - sz + dz, - blockValue, - metaValue, - fuzzY, - netherTransform); - break; - case 1: - transformBlock( - sx + dx, - sy + dy, - sz - dz, - blockValue, - metaValue, - fuzzY, - netherTransform); - break; - case 2: - transformBlock( - sx - dx, - sy + dy, - sz + dz, - blockValue, - metaValue, - fuzzY, - netherTransform); - break; - case 3: - transformBlock( - sx - dx, - sy + dy, - sz - dz, - blockValue, - metaValue, - fuzzY, - netherTransform); - break; - case 4: - transformBlock( - sx + dx, - sy - dy, - sz + dz, - blockValue, - metaValue, - fuzzY, - netherTransform); - break; - case 5: - transformBlock( - sx + dx, - sy - dy, - sz - dz, - blockValue, - metaValue, - fuzzY, - netherTransform); - break; - case 6: - transformBlock( - sx - dx, - sy - dy, - sz + dz, - blockValue, - metaValue, - fuzzY, - netherTransform); - break; - case 7: - transformBlock( - sx - dx, - sy - dy, - sz - dz, - blockValue, - metaValue, - fuzzY, - netherTransform); - break; + case 0 -> transformBlock( + sx + dx, + sy + dy, + sz + dz, + blockValue, + metaValue, + fuzzY, + netherTransform); + case 1 -> transformBlock( + sx + dx, + sy + dy, + sz - dz, + blockValue, + metaValue, + fuzzY, + netherTransform); + case 2 -> transformBlock( + sx - dx, + sy + dy, + sz + dz, + blockValue, + metaValue, + fuzzY, + netherTransform); + case 3 -> transformBlock( + sx - dx, + sy + dy, + sz - dz, + blockValue, + metaValue, + fuzzY, + netherTransform); + case 4 -> transformBlock( + sx + dx, + sy - dy, + sz + dz, + blockValue, + metaValue, + fuzzY, + netherTransform); + case 5 -> transformBlock( + sx + dx, + sy - dy, + sz - dz, + blockValue, + metaValue, + fuzzY, + netherTransform); + case 6 -> transformBlock( + sx - dx, + sy - dy, + sz + dz, + blockValue, + metaValue, + fuzzY, + netherTransform); + case 7 -> transformBlock( + sx - dx, + sy - dy, + sz - dz, + blockValue, + metaValue, + fuzzY, + netherTransform); } } } diff --git a/src/main/java/twilightforest/tileentity/TileEntityTFCinderFurnace.java b/src/main/java/twilightforest/tileentity/TileEntityTFCinderFurnace.java index 8cf2bb4bd1..a0e6ed11d0 100644 --- a/src/main/java/twilightforest/tileentity/TileEntityTFCinderFurnace.java +++ b/src/main/java/twilightforest/tileentity/TileEntityTFCinderFurnace.java @@ -548,14 +548,10 @@ public boolean isUseableByPlayer(EntityPlayer player) { } @Override - public void openInventory() { - ; - } + public void openInventory() {} @Override - public void closeInventory() { - ; - } + public void closeInventory() {} @Override public boolean isItemValidForSlot(int slot, ItemStack itemStack) { diff --git a/src/main/java/twilightforest/tileentity/TileEntityTFGhastTrapActive.java b/src/main/java/twilightforest/tileentity/TileEntityTFGhastTrapActive.java index 2d271b4048..46f8916f32 100644 --- a/src/main/java/twilightforest/tileentity/TileEntityTFGhastTrapActive.java +++ b/src/main/java/twilightforest/tileentity/TileEntityTFGhastTrapActive.java @@ -140,12 +140,12 @@ public void updateEntity() { if (!worldObj.isRemote) { // trap nearby ghasts AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox( - (double) this.xCoord, + this.xCoord, (double) this.yCoord + 16, - (double) this.zCoord, - (double) (this.xCoord + 1), - (double) (this.yCoord + 16 + 1), - (double) (this.zCoord + 1)).expand(6D, 16D, 6D); + this.zCoord, + this.xCoord + 1, + this.yCoord + 16 + 1, + this.zCoord + 1).expand(6D, 16D, 6D); List nearbyGhasts = worldObj.getEntitiesWithinAABB(EntityGhast.class, aabb); diff --git a/src/main/java/twilightforest/tileentity/TileEntityTFGhastTrapInactive.java b/src/main/java/twilightforest/tileentity/TileEntityTFGhastTrapInactive.java index cda3d2aa06..d0af6b3f12 100644 --- a/src/main/java/twilightforest/tileentity/TileEntityTFGhastTrapInactive.java +++ b/src/main/java/twilightforest/tileentity/TileEntityTFGhastTrapInactive.java @@ -18,7 +18,7 @@ public class TileEntityTFGhastTrapInactive extends TileEntity { int counter; Random rand = new Random(); - ArrayList dyingGhasts = new ArrayList(); + ArrayList dyingGhasts = new ArrayList<>(); /** * Determines if this TileEntity requires update calls. @@ -38,12 +38,12 @@ public boolean canUpdate() { public void updateEntity() { // check to see if there are any dying mini ghasts within our scan range AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox( - (double) this.xCoord, - (double) this.yCoord, - (double) this.zCoord, - (double) (this.xCoord + 1), - (double) (this.yCoord + 1), - (double) (this.zCoord + 1)).expand(10D, 16D, 10D); + this.xCoord, + this.yCoord, + this.zCoord, + this.xCoord + 1, + this.yCoord + 1, + this.zCoord + 1).expand(10D, 16D, 10D); List nearbyGhasts = worldObj.getEntitiesWithinAABB(EntityTFMiniGhast.class, aabb); diff --git a/src/main/java/twilightforest/tileentity/TileEntityTFReverter.java b/src/main/java/twilightforest/tileentity/TileEntityTFReverter.java index 89695f1c38..612d889d61 100644 --- a/src/main/java/twilightforest/tileentity/TileEntityTFReverter.java +++ b/src/main/java/twilightforest/tileentity/TileEntityTFReverter.java @@ -46,9 +46,9 @@ public void updateEntity() { this.tickCount++; if (this.worldObj.isRemote) { - double var1 = (double) ((float) this.xCoord + this.worldObj.rand.nextFloat()); - double var3 = (double) ((float) this.yCoord + this.worldObj.rand.nextFloat()); - double var5 = (double) ((float) this.zCoord + this.worldObj.rand.nextFloat()); + double var1 = (float) this.xCoord + this.worldObj.rand.nextFloat(); + double var3 = (float) this.yCoord + this.worldObj.rand.nextFloat(); + double var5 = (float) this.zCoord + this.worldObj.rand.nextFloat(); // this.worldObj.spawnParticle("smoke", var1, var3, var5, 0.0D, 0.0D, 0.0D); this.worldObj.spawnParticle("reddust", var1, var3, var5, 0.0D, 0.0D, 0.0D); @@ -110,82 +110,69 @@ private void makeOutline(int outline) { double dz = this.zCoord; switch (outline) { - case 0: - case 8: + case 0, 8 -> { sx -= radius; dx += radius + 1; sz -= radius; dz -= radius; - break; - case 1: - case 9: + } + case 1, 9 -> { sx -= radius; dx -= radius; sz -= radius; dz += radius + 1; - break; - case 2: - case 10: + } + case 2, 10 -> { sx -= radius; dx += radius + 1; sz += radius + 1; dz += radius + 1; - break; - case 3: - case 11: + } + case 3, 11 -> { sx += radius + 1; dx += radius + 1; sz -= radius; dz += radius + 1; - break; - case 4: + } + case 4 -> { sx -= radius; dx -= radius; sz -= radius; dz -= radius; - break; - case 5: + } + case 5 -> { sx += radius + 1; dx += radius + 1; sz -= radius; dz -= radius; - break; - case 6: + } + case 6 -> { sx += radius + 1; dx += radius + 1; sz += radius + 1; dz += radius + 1; - break; - case 7: + } + case 7 -> { sx -= radius; dx -= radius; sz += radius + 1; dz += radius + 1; - break; + } } switch (outline) { - case 0: - case 1: - case 2: - case 3: + case 0, 1, 2, 3 -> { sy += radius + 1; dy += radius + 1; - break; - case 4: - case 5: - case 6: - case 7: + } + case 4, 5, 6, 7 -> { sy -= radius; dy += radius + 1; - break; - case 8: - case 9: - case 10: - case 11: + } + case 8, 9, 10, 11 -> { sy -= radius; dy -= radius; - break; + } } if (rand.nextBoolean()) { @@ -341,6 +328,6 @@ public boolean anyPlayerInRange() { (double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D, - (double) this.requiredPlayerRange) != null; + this.requiredPlayerRange) != null; } } diff --git a/src/main/java/twilightforest/tileentity/TileEntityTFTowerBuilder.java b/src/main/java/twilightforest/tileentity/TileEntityTFTowerBuilder.java index f9adb32aed..39994ce73c 100644 --- a/src/main/java/twilightforest/tileentity/TileEntityTFTowerBuilder.java +++ b/src/main/java/twilightforest/tileentity/TileEntityTFTowerBuilder.java @@ -144,14 +144,18 @@ private int findNextFacing() { & 3; switch (direction) { - case 0: // south + case 0 -> { // south return 3; - case 1: // west + } + case 1 -> { // west return 4; - case 2: // north + } + case 2 -> { // north return 2; - case 3: // east + } + case 3 -> { // east return 5; + } } } } diff --git a/src/main/java/twilightforest/world/ChunkProviderTwilightForest.java b/src/main/java/twilightforest/world/ChunkProviderTwilightForest.java index 1711d84e69..3ba60a0306 100644 --- a/src/main/java/twilightforest/world/ChunkProviderTwilightForest.java +++ b/src/main/java/twilightforest/world/ChunkProviderTwilightForest.java @@ -53,17 +53,17 @@ public class ChunkProviderTwilightForest implements IChunkProvider { public NoiseGeneratorOctaves noiseGen6; public NoiseGeneratorOctaves mobSpawnerNoise; private World worldObj; - private double stoneNoise[]; + private double[] stoneNoise; private TFGenCaves caveGenerator; private TFGenRavine ravineGenerator; - private BiomeGenBase biomesForGeneration[]; - double noise3[]; - double noise1[]; - double noise2[]; - double noise5[]; - double noise6[]; - float squareTable[]; - int unusedIntArray32x32[][]; + private BiomeGenBase[] biomesForGeneration; + double[] noise3; + double[] noise1; + double[] noise2; + double[] noise5; + double[] noise6; + float[] squareTable; + int[][] unusedIntArray32x32; private WorldType field_147435_p; @@ -123,8 +123,8 @@ public ChunkProviderTwilightForest(World world, long l, boolean flag) { @Override public Chunk provideChunk(int cx, int cz) { rand.setSeed(cx * 0x4f9939f508L + cz * 0x1ef1565bd5L); - Block blockStorage[] = new Block[16 * 16 * TFWorld.CHUNKHEIGHT]; - byte metaStorage[] = new byte[16 * 16 * TFWorld.CHUNKHEIGHT]; + Block[] blockStorage = new Block[16 * 16 * TFWorld.CHUNKHEIGHT]; + byte[] metaStorage = new byte[16 * 16 * TFWorld.CHUNKHEIGHT]; generateTerrain2(cx, cz, blockStorage); squishTerrain(blockStorage); @@ -303,8 +303,8 @@ private void makeLandPerBiome2(int x, int zero, int z) { } ++noiseIndex; - double heightCalc = (double) totalHeight; - double variationCalc = (double) totalVariation; + double heightCalc = totalHeight; + double variationCalc = totalVariation; heightCalc += terrainNoise * 0.2D; heightCalc = heightCalc * 8.5D / 8.0D; double d5 = 8.5D + heightCalc * 4.0D; @@ -322,7 +322,7 @@ private void makeLandPerBiome2(int x, int zero, int z) { double terrainCalc = MathHelper.denormalizeClamp(d7, d8, d9) - d6; if (ay > 29) { - double d11 = (double) ((float) (ay - 29) / 3.0F); + double d11 = (float) (ay - 29) / 3.0F; terrainCalc = terrainCalc * (1.0D - d11) + -10.0D * d11; } @@ -370,15 +370,8 @@ public void replaceBlocksForBiome(int chunkX, int chunkZ, Block[] blockStorage, if (event.getResult() == Result.DENY) return; double d0 = 0.03125D; - this.stoneNoise = this.field_147430_m.func_151599_a( - this.stoneNoise, - (double) (chunkX * 16), - (double) (chunkZ * 16), - 16, - 16, - d0 * 2.0D, - d0 * 2.0D, - 1.0D); + this.stoneNoise = this.field_147430_m + .func_151599_a(this.stoneNoise, chunkX * 16, chunkZ * 16, 16, 16, d0 * 2.0D, d0 * 2.0D, 1.0D); for (int z = 0; z < 16; ++z) { for (int x = 0; x < 16; ++x) { @@ -781,7 +774,7 @@ private float pseudoRand(int bx, int bz) { * @param chunkZ * @param blocks */ - public void addGlaciers(int chunkX, int chunkZ, Block blocks[], byte meta[], BiomeGenBase biomes[]) { + public void addGlaciers(int chunkX, int chunkZ, Block[] blocks, byte[] meta, BiomeGenBase[] biomes) { for (int z = 0; z < 16; z++) { for (int x = 0; x < 16; x++) { BiomeGenBase biome = biomes[x & 15 | (z & 15) << 4]; @@ -817,7 +810,7 @@ public void addGlaciers(int chunkX, int chunkZ, Block blocks[], byte meta[], Bio * Adds dark forest canopy. This version uses the "unzoomed" array of biomes used in land generation to determine * how many of the nearby blocks are dark forest */ - public void addDarkForestCanopy2(int chunkX, int chunkZ, Block blocks[], byte meta[]) { + public void addDarkForestCanopy2(int chunkX, int chunkZ, Block[] blocks, byte[] meta) { int[] thicks = new int[5 * 5]; @@ -1034,7 +1027,6 @@ public String makeString() { * * Twilight Forest varient! First check features, then only if we're not in a feature, check the biome. */ - @SuppressWarnings("unchecked") @Override public List getPossibleCreatures(EnumCreatureType creatureType, int mapX, int mapY, int mapZ) { // are the specified coordinates precicely in a feature? @@ -1119,8 +1111,8 @@ public int getLoadedChunkCount() { @Override public void recreateStructures(int var1, int var2) { - majorFeatureGenerator.func_151539_a(this, worldObj, var1, var2, (Block[]) null); - hollowTreeGenerator.func_151539_a(this, worldObj, var1, var2, (Block[]) null); + majorFeatureGenerator.func_151539_a(this, worldObj, var1, var2, null); + hollowTreeGenerator.func_151539_a(this, worldObj, var1, var2, null); } @Override diff --git a/src/main/java/twilightforest/world/MapGenTFHollowTree.java b/src/main/java/twilightforest/world/MapGenTFHollowTree.java index 917fcc3185..943232150f 100644 --- a/src/main/java/twilightforest/world/MapGenTFHollowTree.java +++ b/src/main/java/twilightforest/world/MapGenTFHollowTree.java @@ -2,11 +2,9 @@ import java.util.Arrays; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Random; -import java.util.concurrent.Callable; import net.minecraft.block.Block; import net.minecraft.crash.CrashReport; @@ -32,44 +30,34 @@ public class MapGenTFHollowTree extends MapGenBase { * generation, the structure generator can avoid generating structures that intersect ones that have already been * placed. */ - protected Map structureMap = new HashMap(); + protected Map structureMap = new HashMap<>(); /** * Generate recursively */ protected void func_151538_a(World world, final int chunkX, final int chunkZ, int centerX, int centerZ, Block[] blockData) { - if (!this.structureMap.containsKey(Long.valueOf(ChunkCoordIntPair.chunkXZ2Int(chunkX, chunkZ)))) { + if (!this.structureMap.containsKey(ChunkCoordIntPair.chunkXZ2Int(chunkX, chunkZ))) { this.rand.nextInt(); try { if (this.canSpawnStructureAtCoords(chunkX, chunkZ)) { StructureStart structurestart = this.getStructureStart(chunkX, chunkZ); - this.structureMap.put(Long.valueOf(ChunkCoordIntPair.chunkXZ2Int(chunkX, chunkZ)), structurestart); + this.structureMap.put(ChunkCoordIntPair.chunkXZ2Int(chunkX, chunkZ), structurestart); } } catch (Throwable throwable) { CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Exception preparing hollow tree"); CrashReportCategory crashreportcategory = crashreport.makeCategory("Feature being prepared"); - crashreportcategory.addCrashSectionCallable("Is feature chunk", new Callable() { - - public String call() { - return MapGenTFHollowTree.this.canSpawnStructureAtCoords(chunkX, chunkZ) ? "True" : "False"; - } - }); - crashreportcategory - .addCrashSection("Chunk location", String.format("%d,%d", new Object[] { chunkX, chunkZ })); - crashreportcategory.addCrashSectionCallable("Chunk pos hash", new Callable() { - - public String call() { - return String.valueOf(ChunkCoordIntPair.chunkXZ2Int(chunkX, chunkZ)); - } - }); - crashreportcategory.addCrashSectionCallable("Structure type", new Callable() { - - public String call() { - return MapGenTFHollowTree.this.getClass().getCanonicalName(); - } - }); + crashreportcategory.addCrashSectionCallable( + "Is feature chunk", + () -> MapGenTFHollowTree.this.canSpawnStructureAtCoords(chunkX, chunkZ) ? "True" : "False"); + crashreportcategory.addCrashSection("Chunk location", String.format("%d,%d", chunkX, chunkZ)); + crashreportcategory.addCrashSectionCallable( + "Chunk pos hash", + () -> String.valueOf(ChunkCoordIntPair.chunkXZ2Int(chunkX, chunkZ))); + crashreportcategory.addCrashSectionCallable( + "Structure type", + () -> MapGenTFHollowTree.this.getClass().getCanonicalName()); throw new ReportedException(crashreport); } } @@ -81,11 +69,7 @@ public boolean generateStructuresInChunk(World world, Random rand, int chunkX, i int mapZ = (chunkZ << 4) + 8; boolean flag = false; - Iterator iterator = this.structureMap.values().iterator(); - - while (iterator.hasNext()) { - StructureStart structurestart = iterator.next(); - + for (StructureStart structurestart : this.structureMap.values()) { if (structurestart.isSizeableStructure() && structurestart.getBoundingBox().intersectsWith(mapX, mapZ, mapX + 15, mapZ + 15)) { structurestart @@ -99,9 +83,16 @@ public boolean generateStructuresInChunk(World world, Random rand, int chunkX, i /** A list of all the biomes twilight oaks can spawn in. */ public static List oakSpawnBiomes = Arrays.asList( - new BiomeGenBase[] { TFBiomeBase.twilightForest, TFBiomeBase.twilightForest2, TFBiomeBase.mushrooms, - TFBiomeBase.tfSwamp, TFBiomeBase.clearing, TFBiomeBase.oakSavanna, TFBiomeBase.fireflyForest, - TFBiomeBase.deepMushrooms, TFBiomeBase.enchantedForest, TFBiomeBase.fireSwamp }); + TFBiomeBase.twilightForest, + TFBiomeBase.twilightForest2, + TFBiomeBase.mushrooms, + TFBiomeBase.tfSwamp, + TFBiomeBase.clearing, + TFBiomeBase.oakSavanna, + TFBiomeBase.fireflyForest, + TFBiomeBase.deepMushrooms, + TFBiomeBase.enchantedForest, + TFBiomeBase.fireSwamp); protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ) { return rand.nextInt(TwilightForestMod.twilightOakChance) == 0 diff --git a/src/main/java/twilightforest/world/MapGenTFMajorFeature.java b/src/main/java/twilightforest/world/MapGenTFMajorFeature.java index 2ac088da11..0615858bf8 100644 --- a/src/main/java/twilightforest/world/MapGenTFMajorFeature.java +++ b/src/main/java/twilightforest/world/MapGenTFMajorFeature.java @@ -1,8 +1,5 @@ package twilightforest.world; -import java.util.Collection; -import java.util.Iterator; - import net.minecraft.world.gen.structure.MapGenStructure; import net.minecraft.world.gen.structure.MapGenStructureData; import net.minecraft.world.gen.structure.StructureBoundingBox; @@ -44,25 +41,16 @@ public String func_143025_a() { /** * Returns true if the structure generator has generated a structure located at the given position tuple. */ - @SuppressWarnings({ "rawtypes", "unchecked" }) public int getSpawnListIndexAt(int par1, int par2, int par3) { int highestFoundIndex = -1; - Iterator startIterator = this.structureMap.values().iterator(); - - while (startIterator.hasNext()) { - StructureStart start = (StructureStart) startIterator.next(); - + for (StructureStart start : this.structureMap.values()) { if (start.isSizeableStructure() && start.getBoundingBox().intersectsWith(par1, par3, par1, par3)) { - Iterator componentIterator = start.getComponents().iterator(); - - while (componentIterator.hasNext()) { - StructureComponent component = (StructureComponent) componentIterator.next(); + for (StructureComponent component : start.getComponents()) { if (component != null && component.getBoundingBox() != null && component.getBoundingBox().isVecInside(par1, par2, par3)) { - if (component instanceof StructureTFComponent) { - StructureTFComponent tfComponent = (StructureTFComponent) component; + if (component instanceof StructureTFComponent tfComponent) { // System.out.println("found a tfComponent at the specified coordinates. It's a " + // tfComponent + ", @@ -85,21 +73,13 @@ public int getSpawnListIndexAt(int par1, int par2, int par3) { /** * Get the structure bounding box, if any, at the specified position */ - @SuppressWarnings("unchecked") public StructureBoundingBox getSBBAt(int mapX, int mapY, int mapZ) { StructureBoundingBox boxFound = null; - Iterator startIterator = this.structureMap.values().iterator(); - - while (startIterator.hasNext()) { - StructureStart start = (StructureStart) startIterator.next(); - + for (StructureStart start : this.structureMap.values()) { if (start.isSizeableStructure() && start.getBoundingBox().intersectsWith(mapX, mapZ, mapX, mapZ)) { - Iterator componentIterator = start.getComponents().iterator(); - - while (componentIterator.hasNext()) { - StructureComponent component = (StructureComponent) componentIterator.next(); + for (StructureComponent component : start.getComponents()) { if (component.getBoundingBox().isVecInside(mapX, mapY, mapZ)) { boxFound = component.getBoundingBox(); } @@ -113,25 +93,16 @@ public StructureBoundingBox getSBBAt(int mapX, int mapY, int mapZ) { /** * Is the block at the coordinates given a protected one? */ - @SuppressWarnings("unchecked") public boolean isBlockProtectedAt(int mapX, int mapY, int mapZ) { boolean blockProtected = false; - Iterator startIterator = this.structureMap.values().iterator(); - - while (startIterator.hasNext()) { - StructureStart start = (StructureStart) startIterator.next(); - + for (StructureStart start : this.structureMap.values()) { if (start.isSizeableStructure() && start.getBoundingBox().intersectsWith(mapX, mapZ, mapX, mapZ)) { - Iterator componentIterator = start.getComponents().iterator(); - - while (componentIterator.hasNext()) { - StructureComponent component = (StructureComponent) componentIterator.next(); + for (StructureComponent component : start.getComponents()) { if (component.getBoundingBox().isVecInside(mapX, mapY, mapZ)) { - if (component instanceof StructureTFComponent) { - StructureTFComponent tfComp = (StructureTFComponent) component; + if (component instanceof StructureTFComponent tfComp) { blockProtected = tfComp.isComponentProtected(); @@ -154,14 +125,11 @@ public boolean isBlockProtectedAt(int mapX, int mapY, int mapZ) { * * @return */ - @SuppressWarnings("unchecked") public void setStructureConquered(int mapX, int mapY, int mapZ, boolean flag) { - for (StructureStart start : (Collection) this.structureMap.values()) { + for (StructureStart start : this.structureMap.values()) { if (start.isSizeableStructure() && start.getBoundingBox().intersectsWith(mapX, mapZ, mapX, mapZ)) { - if (start instanceof StructureTFMajorFeatureStart) { - - StructureTFMajorFeatureStart featureStart = (StructureTFMajorFeatureStart) start; + if (start instanceof StructureTFMajorFeatureStart featureStart) { // System.out.println("The data says that the conquered flag is " + featureStart.isConquered); @@ -184,12 +152,11 @@ public void setStructureConquered(int mapX, int mapY, int mapZ, boolean flag) { } } - @SuppressWarnings("unchecked") public boolean isStructureConquered(int mapX, int mapY, int mapZ) { boolean conquered = false; - for (StructureStart start : (Collection) this.structureMap.values()) { + for (StructureStart start : this.structureMap.values()) { if (start.isSizeableStructure() && start.getBoundingBox().intersectsWith(mapX, mapZ, mapX, mapZ)) { if (start instanceof StructureTFMajorFeatureStart) { @@ -204,12 +171,11 @@ public boolean isStructureConquered(int mapX, int mapY, int mapZ) { /** * Check the lock at the specified lockIndex for the structure at the specified coords */ - @SuppressWarnings("unchecked") public boolean isStructureLocked(int mapX, int mapY, int mapZ, int lockIndex) { boolean locked = false; - for (StructureStart start : (Collection) this.structureMap.values()) { + for (StructureStart start : this.structureMap.values()) { if (start.isSizeableStructure() && start.getBoundingBox().intersectsWith(mapX, mapZ, mapX, mapZ)) { if (start instanceof StructureTFMajorFeatureStart) { @@ -224,9 +190,8 @@ public boolean isStructureLocked(int mapX, int mapY, int mapZ, int lockIndex) { /** * Do the specified x & z coordinates intersect the full structure? */ - @SuppressWarnings("unchecked") public boolean isBlockInFullStructure(int mapX, int mapZ) { - for (StructureStart start : (Collection) this.structureMap.values()) { + for (StructureStart start : this.structureMap.values()) { if (start.isSizeableStructure() && start.getBoundingBox().intersectsWith(mapX, mapZ, mapX, mapZ)) { return true; } @@ -237,10 +202,9 @@ public boolean isBlockInFullStructure(int mapX, int mapZ) { /** * Are the specified x & z coordinates close to a full structure? */ - @SuppressWarnings("unchecked") public boolean isBlockNearFullStructure(int mapX, int mapZ, int range) { StructureBoundingBox rangeBB = new StructureBoundingBox(mapX - range, mapZ - range, mapX + range, mapZ + range); - for (StructureStart start : (Collection) this.structureMap.values()) { + for (StructureStart start : this.structureMap.values()) { if (start.isSizeableStructure() && start.getBoundingBox().intersectsWith(rangeBB)) { return true; } @@ -251,9 +215,8 @@ public boolean isBlockNearFullStructure(int mapX, int mapZ, int range) { /** * Get full structure bounding box at the specified x, z coordinates. */ - @SuppressWarnings("unchecked") public StructureBoundingBox getFullSBBAt(int mapX, int mapZ) { - for (StructureStart start : (Collection) this.structureMap.values()) { + for (StructureStart start : this.structureMap.values()) { if (start.isSizeableStructure() && start.getBoundingBox().intersectsWith(mapX, mapZ, mapX, mapZ)) { return start.getBoundingBox(); } @@ -261,10 +224,9 @@ public StructureBoundingBox getFullSBBAt(int mapX, int mapZ) { return null; } - @SuppressWarnings("unchecked") public StructureBoundingBox getFullSBBNear(int mapX, int mapZ, int range) { StructureBoundingBox rangeBB = new StructureBoundingBox(mapX - range, mapZ - range, mapX + range, mapZ + range); - for (StructureStart start : (Collection) this.structureMap.values()) { + for (StructureStart start : this.structureMap.values()) { if (start.isSizeableStructure() && start.getBoundingBox().intersectsWith(rangeBB)) { return start.getBoundingBox(); } diff --git a/src/main/java/twilightforest/world/TFGenCanopyMushroom.java b/src/main/java/twilightforest/world/TFGenCanopyMushroom.java index ac55a3c5eb..24d7fb809b 100644 --- a/src/main/java/twilightforest/world/TFGenCanopyMushroom.java +++ b/src/main/java/twilightforest/world/TFGenCanopyMushroom.java @@ -195,17 +195,10 @@ public void drawMushroomCircle(World world, int sx, int sy, int sz, int rad, Blo private void addFirefly(World world, int x, int y, int z, int height, double angle) { int iAngle = (int) (angle * 4.0); switch (iAngle) { - case 0: - setBlockAndMetadata(world, x + 1, y + height, z, TFBlocks.firefly, 0); - break; - case 1: - setBlockAndMetadata(world, x - 1, y + height, z, TFBlocks.firefly, 0); - break; - case 2: - setBlockAndMetadata(world, x, y + height, z + 1, TFBlocks.firefly, 0); - break; - case 3: - setBlockAndMetadata(world, x, y + height, z - 1, TFBlocks.firefly, 0); + case 0 -> setBlockAndMetadata(world, x + 1, y + height, z, TFBlocks.firefly, 0); + case 1 -> setBlockAndMetadata(world, x - 1, y + height, z, TFBlocks.firefly, 0); + case 2 -> setBlockAndMetadata(world, x, y + height, z + 1, TFBlocks.firefly, 0); + case 3 -> setBlockAndMetadata(world, x, y + height, z - 1, TFBlocks.firefly, 0); } } } diff --git a/src/main/java/twilightforest/world/TFGenCanopyTree.java b/src/main/java/twilightforest/world/TFGenCanopyTree.java index 19186fedd5..53182ba609 100644 --- a/src/main/java/twilightforest/world/TFGenCanopyTree.java +++ b/src/main/java/twilightforest/world/TFGenCanopyTree.java @@ -148,17 +148,10 @@ void buildBranch(World world, int x, int y, int z, int height, double length, do protected void addFirefly(World world, int x, int y, int z, int height, double angle) { int iAngle = (int) (angle * 4.0); switch (iAngle) { - case 0: - setBlockAndMetadata(world, x + 1, y + height, z, TFBlocks.firefly, 0); - break; - case 1: - setBlockAndMetadata(world, x - 1, y + height, z, TFBlocks.firefly, 0); - break; - case 2: - setBlockAndMetadata(world, x, y + height, z + 1, TFBlocks.firefly, 0); - break; - case 3: - setBlockAndMetadata(world, x, y + height, z - 1, TFBlocks.firefly, 0); + case 0 -> setBlockAndMetadata(world, x + 1, y + height, z, TFBlocks.firefly, 0); + case 1 -> setBlockAndMetadata(world, x - 1, y + height, z, TFBlocks.firefly, 0); + case 2 -> setBlockAndMetadata(world, x, y + height, z + 1, TFBlocks.firefly, 0); + case 3 -> setBlockAndMetadata(world, x, y + height, z - 1, TFBlocks.firefly, 0); } } } diff --git a/src/main/java/twilightforest/world/TFGenCaves.java b/src/main/java/twilightforest/world/TFGenCaves.java index 8ee51ced1d..afddbc0f43 100644 --- a/src/main/java/twilightforest/world/TFGenCaves.java +++ b/src/main/java/twilightforest/world/TFGenCaves.java @@ -46,8 +46,8 @@ protected void generateLargeCaveNode(long caveSeed, int centerX, int centerZ, Bl protected void generateCaveNode(long caveSeed, int centerX, int centerZ, Block[] blockStorage, double randX, double randY, double randZ, float caveSize, float randPI, float angleToGenerate, int loopOne, int loopEnd, double yScale, boolean isHighlands) { - double offsetCenterX = (double) (centerX * 16 + 8); - double offsetCenterZ = (double) (centerZ * 16 + 8); + double offsetCenterX = centerX * 16 + 8; + double offsetCenterZ = centerZ * 16 + 8; float var23 = 0.0F; float var24 = 0.0F; Random caveRNG = new Random(caveSeed); @@ -82,9 +82,9 @@ protected void generateCaveNode(long caveSeed, int centerX, int centerZ, Block[] double scaledSize = sizeVar * yScale; float cosAngle = MathHelper.cos(angleToGenerate); float sinAngle = MathHelper.sin(angleToGenerate); - randX += (double) (MathHelper.cos(randPI) * cosAngle); - randY += (double) sinAngle; - randZ += (double) (MathHelper.sin(randPI) * cosAngle); + randX += MathHelper.cos(randPI) * cosAngle; + randY += sinAngle; + randZ += MathHelper.sin(randPI) * cosAngle; if (var28) { angleToGenerate *= 0.92F; @@ -136,8 +136,8 @@ protected void generateCaveNode(long caveSeed, int centerX, int centerZ, Block[] if (shouldStop || caveRNG.nextInt(4) != 0) { double distX = randX - offsetCenterX; double distZ = randZ - offsetCenterZ; - double var39 = (double) (loopEnd - loopOne); - double sizeSixteen = (double) (caveSize + 2.0F + 16.0F); + double var39 = loopEnd - loopOne; + double sizeSixteen = caveSize + 2.0F + 16.0F; if (distX * distX + distZ * distZ - var39 * var39 > sizeSixteen * sizeSixteen) { return; @@ -272,9 +272,9 @@ protected void func_151538_a(World par1World, int genX, int genZ, int centerX, i } for (int i = 0; i < numberOfCaves; ++i) { - double randX = (double) (genX * 16 + this.rand.nextInt(16)); - double randY = (double) this.rand.nextInt(this.rand.nextInt(120) + 8); - double randZ = (double) (genZ * 16 + this.rand.nextInt(16)); + double randX = genX * 16 + this.rand.nextInt(16); + double randY = this.rand.nextInt(this.rand.nextInt(120) + 8); + double randZ = genZ * 16 + this.rand.nextInt(16); int numberOfNormalNodes = 1; if (this.rand.nextInt(4) == 0) { diff --git a/src/main/java/twilightforest/world/TFGenFallenSmallLog.java b/src/main/java/twilightforest/world/TFGenFallenSmallLog.java index 7118c7b9cc..5823b54794 100644 --- a/src/main/java/twilightforest/world/TFGenFallenSmallLog.java +++ b/src/main/java/twilightforest/world/TFGenFallenSmallLog.java @@ -37,34 +37,34 @@ public boolean generate(World world, Random rand, int x, int y, int z) { int logMetaBranch; switch (rand.nextInt(7)) { - case 0: - default: + default -> { logID = TFBlocks.log; logMeta = 0; - break; - case 1: + } + case 1 -> { logID = TFBlocks.log; logMeta = 1; - break; - case 2: + } + case 2 -> { logID = TFBlocks.log; logMeta = 2; - break; - case 3: + } + case 3 -> { logID = Blocks.log; logMeta = 0; - break; - case 4: + } + case 4 -> { logID = Blocks.log; logMeta = 1; - break; - case 5: + } + case 5 -> { logID = Blocks.log; logMeta = 2; - break; - case 6: + } + case 6 -> { logID = Blocks.log; logMeta = 3; + } } logMetaBranch = logMeta; diff --git a/src/main/java/twilightforest/world/TFGenLargeRainboak.java b/src/main/java/twilightforest/world/TFGenLargeRainboak.java index f364fa5734..1cffc7ad93 100644 --- a/src/main/java/twilightforest/world/TFGenLargeRainboak.java +++ b/src/main/java/twilightforest/world/TFGenLargeRainboak.java @@ -108,8 +108,8 @@ void generateLeafNodeList() { if (this.checkBlockLine(var17, var18) == -1) { int[] var19 = new int[] { this.basePos[0], this.basePos[1], this.basePos[2] }; double var20 = Math.sqrt( - Math.pow((double) Math.abs(this.basePos[0] - var17[0]), 2.0D) - + Math.pow((double) Math.abs(this.basePos[2] - var17[2]), 2.0D)); + Math.pow(Math.abs(this.basePos[0] - var17[0]), 2.0D) + + Math.pow(Math.abs(this.basePos[2] - var17[2]), 2.0D)); double var22 = var20 * this.branchSlope; if ((double) var17[1] - var22 > (double) var5) { @@ -188,8 +188,7 @@ float layerSize(int par1) { } else if (Math.abs(var3) >= var2) { var4 = 0.0F; } else { - var4 = (float) Math - .sqrt(Math.pow((double) Math.abs(var2), 2.0D) - Math.pow((double) Math.abs(var3), 2.0D)); + var4 = (float) Math.sqrt(Math.pow(Math.abs(var2), 2.0D) - Math.pow(Math.abs(var3), 2.0D)); } var4 *= 0.5F; diff --git a/src/main/java/twilightforest/world/TFGenLargeWinter.java b/src/main/java/twilightforest/world/TFGenLargeWinter.java index 691455fbb8..90109690a8 100644 --- a/src/main/java/twilightforest/world/TFGenLargeWinter.java +++ b/src/main/java/twilightforest/world/TFGenLargeWinter.java @@ -76,7 +76,7 @@ private void makePineBranches(World world, int x, int y, int z, int radius) { int branchLength = radius > 4 ? radius - 1 : radius - 2; switch (y % 2) { - case 0: + case 0 -> { // branches for (int i = 1; i <= branchLength; i++) { this.setBlockAndMetadata(world, x + 0 - i, y, z + 0, treeBlock, branchMeta & 3 | 4); @@ -84,28 +84,24 @@ private void makePineBranches(World world, int x, int y, int z, int radius) { this.setBlockAndMetadata(world, x + 1 + i, y, z + 1, treeBlock, branchMeta & 3 | 4); this.setBlockAndMetadata(world, x + 1, y, z - 0 - i, treeBlock, branchMeta & 3 | 8); } - break; - case 1: + } + case 1 -> { for (int i = 1; i <= branchLength; i++) { this.setBlockAndMetadata(world, x + 0 - i, y, z + 1, treeBlock, branchMeta & 3 | 4); this.setBlockAndMetadata(world, x + 1, y, z + 1 + i, treeBlock, branchMeta & 3 | 8); this.setBlockAndMetadata(world, x + 1 + i, y, z + 0, treeBlock, branchMeta & 3 | 4); this.setBlockAndMetadata(world, x + 0, y, z - 0 - i, treeBlock, branchMeta & 3 | 8); } - break; + } } } private int leafRadius(int treeHeight, int dy, int functionType) { - switch (functionType) { - case 0: - default: - return (dy - 1) % 4; - case 1: - return (int) (4F * (float) dy / (float) treeHeight + (0.75F * dy % 3)); - case 99: - return (treeHeight - (dy / 2) - 1) % 4; // bad - } + return switch (functionType) { + default -> (dy - 1) % 4; + case 1 -> (int) (4F * (float) dy / (float) treeHeight + (0.75F * dy % 3)); + case 99 -> (treeHeight - (dy / 2) - 1) % 4; // bad + }; } private void buildTrunk(World world, int x, int y, int z, int treeHeight) { diff --git a/src/main/java/twilightforest/world/TFGenMangroveTree.java b/src/main/java/twilightforest/world/TFGenMangroveTree.java index e876879b9b..8b487ca107 100644 --- a/src/main/java/twilightforest/world/TFGenMangroveTree.java +++ b/src/main/java/twilightforest/world/TFGenMangroveTree.java @@ -151,17 +151,10 @@ void buildRoot(World world, int x, int y, int z, int height, double length, doub private void addFirefly(World world, int x, int y, int z, int height, double angle) { int iAngle = (int) (angle * 4.0); switch (iAngle) { - case 0: - setBlockAndMetadata(world, x + 1, y + height, z, TFBlocks.firefly, 0); - break; - case 1: - setBlockAndMetadata(world, x - 1, y + height, z, TFBlocks.firefly, 0); - break; - case 2: - setBlockAndMetadata(world, x, y + height, z + 1, TFBlocks.firefly, 0); - break; - case 3: - setBlockAndMetadata(world, x, y + height, z - 1, TFBlocks.firefly, 0); + case 0 -> setBlockAndMetadata(world, x + 1, y + height, z, TFBlocks.firefly, 0); + case 1 -> setBlockAndMetadata(world, x - 1, y + height, z, TFBlocks.firefly, 0); + case 2 -> setBlockAndMetadata(world, x, y + height, z + 1, TFBlocks.firefly, 0); + case 3 -> setBlockAndMetadata(world, x, y + height, z - 1, TFBlocks.firefly, 0); } } } diff --git a/src/main/java/twilightforest/world/TFGenMonolith.java b/src/main/java/twilightforest/world/TFGenMonolith.java index fdd2c03630..3547ea8101 100644 --- a/src/main/java/twilightforest/world/TFGenMonolith.java +++ b/src/main/java/twilightforest/world/TFGenMonolith.java @@ -26,31 +26,30 @@ public boolean generate(World world, Random rand, int x, int y, int z) { } switch (dir) { - case 0: + case 0 -> { h0 = ht; h1 = (int) (ht * .75); h2 = (int) (ht * .75); h3 = (int) (ht * .5); - break; - case 1: + } + case 1 -> { h0 = (int) (ht * .5); h1 = ht; h2 = (int) (ht * .75); h3 = (int) (ht * .75); - break; - case 2: + } + case 2 -> { h0 = (int) (ht * .75); h1 = (int) (ht * .5); h2 = ht; h3 = (int) (ht * .75); - break; - case 3: - default: + } + default -> { h0 = (int) (ht * .75); h1 = (int) (ht * .75); h2 = (int) (ht * .5); h3 = ht; - break; + } } for (int cy = 0; cy <= h0; cy++) { diff --git a/src/main/java/twilightforest/world/TFGenRavine.java b/src/main/java/twilightforest/world/TFGenRavine.java index f27e4e1ecf..5da4ae5ae3 100644 --- a/src/main/java/twilightforest/world/TFGenRavine.java +++ b/src/main/java/twilightforest/world/TFGenRavine.java @@ -13,13 +13,13 @@ public class TFGenRavine extends MapGenBase { - private float field_35627_a[]; + private float[] field_35627_a; public TFGenRavine() { field_35627_a = new float[1024]; } - protected void generateRavine(long l, int i, int j, Block blockStorage[], double d, double d1, double d2, float f, + protected void generateRavine(long l, int i, int j, Block[] blockStorage, double d, double d1, double d2, float f, float f1, float f2, int k, int i1, double d3) { Random random = new Random(l); double d4 = i * 16 + 8; @@ -163,7 +163,7 @@ protected void generateRavine(long l, int i, int j, Block blockStorage[], double } protected void func_151538_a(World world, int centerChunkX, int centerChunkZ, int currentChunkX, int currentChunkZ, - Block shortStorage[]) { + Block[] shortStorage) { if (rand.nextInt(127) != 0) { return; } diff --git a/src/main/java/twilightforest/world/TFGenThorns.java b/src/main/java/twilightforest/world/TFGenThorns.java index 33eace89e4..b81bc3c983 100644 --- a/src/main/java/twilightforest/world/TFGenThorns.java +++ b/src/main/java/twilightforest/world/TFGenThorns.java @@ -123,18 +123,10 @@ private boolean canPlaceThorns(World world, int dx, int dy, int dz) { } private int getMetaFor(ForgeDirection dir) { - switch (dir) { - case UNKNOWN: - default: - case UP: - case DOWN: - return 0; - case EAST: - case WEST: - return 4; - case NORTH: - case SOUTH: - return 8; - } + return switch (dir) { + default -> 0; + case EAST, WEST -> 4; + case NORTH, SOUTH -> 8; + }; } } diff --git a/src/main/java/twilightforest/world/TFGenerator.java b/src/main/java/twilightforest/world/TFGenerator.java index ce99c20bd9..17ae75d200 100644 --- a/src/main/java/twilightforest/world/TFGenerator.java +++ b/src/main/java/twilightforest/world/TFGenerator.java @@ -87,7 +87,7 @@ public static ChunkCoordinates[] getBresehnamArrayCoords(int x1, int y1, int z1, int i, dx, dy, dz, l, m, n, x_inc, y_inc, z_inc, err_1, err_2, dx2, dy2, dz2; ChunkCoordinates pixel = new ChunkCoordinates(x1, y1, z1); - ChunkCoordinates lineArray[]; + ChunkCoordinates[] lineArray; dx = x2 - x1; dy = y2 - y1; diff --git a/src/main/java/twilightforest/world/TFWorldChunkManager.java b/src/main/java/twilightforest/world/TFWorldChunkManager.java index aeaf6fd543..e862502607 100644 --- a/src/main/java/twilightforest/world/TFWorldChunkManager.java +++ b/src/main/java/twilightforest/world/TFWorldChunkManager.java @@ -34,7 +34,7 @@ public class TFWorldChunkManager extends WorldChunkManager { protected TFWorldChunkManager() { myBiomeCache = new BiomeCache(this); - myBiomesToSpawnIn = new ArrayList(); + myBiomesToSpawnIn = new ArrayList<>(); myBiomesToSpawnIn.add(TFBiomeBase.twilightForest); myBiomesToSpawnIn.add(TFBiomeBase.twilightForest2); myBiomesToSpawnIn.add(TFBiomeBase.clearing); @@ -44,7 +44,7 @@ protected TFWorldChunkManager() { public TFWorldChunkManager(long par1, WorldType par3WorldType) { this(); - GenLayer agenlayer[]; + GenLayer[] agenlayer; // new world gen! if (TwilightForestMod.oldMapGen) { agenlayer = GenLayerTF.makeTheWorldOldMapGen(par1); @@ -62,8 +62,7 @@ public TFWorldChunkManager(World par1World) { /** * Gets the list of valid biomes for the player to spawn in. */ - @SuppressWarnings("rawtypes") - public List getBiomesToSpawnIn() { + public List getBiomesToSpawnIn() { return myBiomesToSpawnIn; } @@ -86,14 +85,14 @@ public BiomeGenBase getBiomeGenAt(int par1, int par2) { /** * Returns a list of rainfall values for the specified blocks. Args: listToReuse, x, z, width, length. */ - public float[] getRainfall(float par1ArrayOfFloat[], int par2, int par3, int par4, int par5) { + public float[] getRainfall(float[] par1ArrayOfFloat, int par2, int par3, int par4, int par5) { IntCache.resetIntCache(); if (par1ArrayOfFloat == null || par1ArrayOfFloat.length < par4 * par5) { par1ArrayOfFloat = new float[par4 * par5]; } - int ai[] = zoomedBiomes.getInts(par2, par3, par4, par5); + int[] ai = zoomedBiomes.getInts(par2, par3, par4, par5); for (int i = 0; i < par4 * par5; i++) { // this keeps NPEing, I wonder why @@ -123,7 +122,7 @@ public float getTemperatureAtHeight(float par1, int par2) { /** * Returns an array of biomes for the location input. */ - public BiomeGenBase[] getBiomesForGeneration(BiomeGenBase par1ArrayOfBiomeGenBase[], int x, int z, int length, + public BiomeGenBase[] getBiomesForGeneration(BiomeGenBase[] par1ArrayOfBiomeGenBase, int x, int z, int length, int width) { IntCache.resetIntCache(); @@ -131,7 +130,7 @@ public BiomeGenBase[] getBiomesForGeneration(BiomeGenBase par1ArrayOfBiomeGenBas par1ArrayOfBiomeGenBase = new BiomeGenBase[length * width]; } - int arrayOfInts[] = unzoomedBiomes.getInts(x, z, length, width); + int[] arrayOfInts = unzoomedBiomes.getInts(x, z, length, width); for (int i = 0; i < length * width; i++) { // biome validity check @@ -150,7 +149,7 @@ public BiomeGenBase[] getBiomesForGeneration(BiomeGenBase par1ArrayOfBiomeGenBas * Returns biomes to use for the blocks and loads the other data like temperature and humidity onto the * WorldChunkManager Args: oldBiomeList, x, z, width, depth */ - public BiomeGenBase[] loadBlockGeneratorData(BiomeGenBase par1ArrayOfBiomeGenBase[], int par2, int par3, int par4, + public BiomeGenBase[] loadBlockGeneratorData(BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5) { return getBiomeGenAt(par1ArrayOfBiomeGenBase, par2, par3, par4, par5, true); } @@ -159,7 +158,7 @@ public BiomeGenBase[] loadBlockGeneratorData(BiomeGenBase par1ArrayOfBiomeGenBas * Return a list of biomes for the specified blocks. Args: listToReuse, x, y, width, length, cacheFlag (if false, * don't check biomeCache to avoid infinite loop in BiomeCacheBlock) */ - public BiomeGenBase[] getBiomeGenAt(BiomeGenBase par1ArrayOfBiomeGenBase[], int x, int y, int width, int length, + public BiomeGenBase[] getBiomeGenAt(BiomeGenBase[] par1ArrayOfBiomeGenBase, int x, int y, int width, int length, boolean cacheFlag) { IntCache.resetIntCache(); @@ -168,12 +167,12 @@ public BiomeGenBase[] getBiomeGenAt(BiomeGenBase par1ArrayOfBiomeGenBase[], int } if (cacheFlag && width == 16 && length == 16 && (x & 0xf) == 0 && (y & 0xf) == 0) { - BiomeGenBase abiomegenbase[] = myBiomeCache.getCachedBiomes(x, y); + BiomeGenBase[] abiomegenbase = myBiomeCache.getCachedBiomes(x, y); System.arraycopy(abiomegenbase, 0, par1ArrayOfBiomeGenBase, 0, width * length); return par1ArrayOfBiomeGenBase; } - int ai[] = zoomedBiomes.getInts(x, y, width, length); + int[] ai = zoomedBiomes.getInts(x, y, width, length); for (int i = 0; i < width * length; i++) { // biome validity check @@ -199,7 +198,7 @@ public boolean areBiomesViable(int par1, int par2, int par3, List par4List) { int l = par2 + par3 >> 2; int i1 = (k - i) + 1; int j1 = (l - j) + 1; - int ai[] = unzoomedBiomes.getInts(i, j, i1, j1); + int[] ai = unzoomedBiomes.getInts(i, j, i1, j1); for (int k1 = 0; k1 < i1 * j1; k1++) { BiomeGenBase biomegenbase = BiomeGenBase.getBiome(ai[k1]); @@ -223,7 +222,7 @@ public ChunkPosition findBiomePosition(int par1, int par2, int par3, List par4Li int l = par2 + par3 >> 2; int i1 = (k - i) + 1; int j1 = (l - j) + 1; - int ai[] = unzoomedBiomes.getInts(i, j, i1, j1); + int[] ai = unzoomedBiomes.getInts(i, j, i1, j1); ChunkPosition chunkposition = null; int k1 = 0; diff --git a/src/main/java/twilightforest/world/layer/GenLayerTF7x7Preset.java b/src/main/java/twilightforest/world/layer/GenLayerTF7x7Preset.java index 7b1915366a..08e4bb6e73 100644 --- a/src/main/java/twilightforest/world/layer/GenLayerTF7x7Preset.java +++ b/src/main/java/twilightforest/world/layer/GenLayerTF7x7Preset.java @@ -8,7 +8,7 @@ public class GenLayerTF7x7Preset extends GenLayer { - BiomeGenBase preset[][] = new BiomeGenBase[9][9]; + BiomeGenBase[][] preset = new BiomeGenBase[9][9]; public GenLayerTF7x7Preset(long par1) { super(par1); @@ -17,7 +17,7 @@ public GenLayerTF7x7Preset(long par1) { @Override public int[] getInts(int x, int z, int width, int depth) { - int dest[] = IntCache.getIntCache(width * depth); + int[] dest = IntCache.getIntCache(width * depth); for (int dz = 0; dz < depth; dz++) { for (int dx = 0; dx < width; dx++) { int sx = x + dx + 4; @@ -52,38 +52,24 @@ private void initPresets() { } protected BiomeGenBase getBiomeFor(char c) { - switch (c) { - default: - return BiomeGenBase.ocean; + return switch (c) { + default -> BiomeGenBase.ocean; // case 'P' : // return BiomeGenBase.plains; - case 'F': - return TFBiomeBase.twilightForest; - case 'f': - return TFBiomeBase.twilightForest2; - case 'E': - return TFBiomeBase.enchantedForest; - case 'm': - return TFBiomeBase.mushrooms; - case 'M': - return TFBiomeBase.deepMushrooms; - case 'C': - return TFBiomeBase.clearing; - case 'S': - return TFBiomeBase.tfSwamp; - case 'Y': - return TFBiomeBase.fireSwamp; - case 'D': - return TFBiomeBase.darkForest; - case 'L': - return TFBiomeBase.tfLake; - case 'O': - return TFBiomeBase.tfSnow; - case 'G': - return TFBiomeBase.glacier; - case 'H': - return TFBiomeBase.highlands; - } + case 'F' -> TFBiomeBase.twilightForest; + case 'f' -> TFBiomeBase.twilightForest2; + case 'E' -> TFBiomeBase.enchantedForest; + case 'm' -> TFBiomeBase.mushrooms; + case 'M' -> TFBiomeBase.deepMushrooms; + case 'C' -> TFBiomeBase.clearing; + case 'S' -> TFBiomeBase.tfSwamp; + case 'Y' -> TFBiomeBase.fireSwamp; + case 'D' -> TFBiomeBase.darkForest; + case 'L' -> TFBiomeBase.tfLake; + case 'O' -> TFBiomeBase.tfSnow; + case 'G' -> TFBiomeBase.glacier; + case 'H' -> TFBiomeBase.highlands; + }; } } diff --git a/src/main/java/twilightforest/world/layer/GenLayerTFBiomeBorders.java b/src/main/java/twilightforest/world/layer/GenLayerTFBiomeBorders.java index 2933237c20..387fdca06d 100644 --- a/src/main/java/twilightforest/world/layer/GenLayerTFBiomeBorders.java +++ b/src/main/java/twilightforest/world/layer/GenLayerTFBiomeBorders.java @@ -21,8 +21,8 @@ public int[] getInts(int x, int z, int width, int depth) { int nz = z - 1; int nwidth = width + 2; int ndepth = depth + 2; - int input[] = parent.getInts(nx, nz, nwidth, ndepth); - int output[] = IntCache.getIntCache(width * depth); + int[] input = parent.getInts(nx, nz, nwidth, ndepth); + int[] output = IntCache.getIntCache(width * depth); for (int dz = 0; dz < depth; dz++) { for (int dx = 0; dx < width; dx++) { int right = input[dx + 0 + (dz + 1) * nwidth]; diff --git a/src/main/java/twilightforest/world/layer/GenLayerTFBiomeStabilize.java b/src/main/java/twilightforest/world/layer/GenLayerTFBiomeStabilize.java index fae3b417d6..b2cc08bb82 100644 --- a/src/main/java/twilightforest/world/layer/GenLayerTFBiomeStabilize.java +++ b/src/main/java/twilightforest/world/layer/GenLayerTFBiomeStabilize.java @@ -19,8 +19,8 @@ public int[] getInts(int x, int z, int width, int depth) { int nz = z - 1; int nwidth = width + 2; int ndepth = depth + 2; - int input[] = parent.getInts(nx, nz, nwidth, ndepth); - int output[] = IntCache.getIntCache(width * depth); + int[] input = parent.getInts(nx, nz, nwidth, ndepth); + int[] output = IntCache.getIntCache(width * depth); int offX = x & 3; int offZ = z & 3; diff --git a/src/main/java/twilightforest/world/layer/GenLayerTFBiomes.java b/src/main/java/twilightforest/world/layer/GenLayerTFBiomes.java index 349041b215..e4ada0b342 100644 --- a/src/main/java/twilightforest/world/layer/GenLayerTFBiomes.java +++ b/src/main/java/twilightforest/world/layer/GenLayerTFBiomes.java @@ -14,10 +14,10 @@ */ public class GenLayerTFBiomes extends GenLayer { - protected BiomeGenBase commonBiomes[] = (new BiomeGenBase[] { TFBiomeBase.twilightForest, + protected BiomeGenBase[] commonBiomes = (new BiomeGenBase[] { TFBiomeBase.twilightForest, TFBiomeBase.twilightForest2, TFBiomeBase.highlands, TFBiomeBase.mushrooms, TFBiomeBase.tfSwamp, TFBiomeBase.clearing, TFBiomeBase.darkForest }); - protected BiomeGenBase rareBiomes[] = (new BiomeGenBase[] { TFBiomeBase.tfLake, TFBiomeBase.glacier, + protected BiomeGenBase[] rareBiomes = (new BiomeGenBase[] { TFBiomeBase.tfLake, TFBiomeBase.glacier, TFBiomeBase.deepMushrooms, TFBiomeBase.enchantedForest, TFBiomeBase.fireSwamp }); public GenLayerTFBiomes(long l, GenLayer genlayer) { @@ -30,7 +30,7 @@ public GenLayerTFBiomes(long l) { } public int[] getInts(int x, int z, int width, int depth) { - int dest[] = IntCache.getIntCache(width * depth); + int[] dest = IntCache.getIntCache(width * depth); for (int dz = 0; dz < depth; dz++) { for (int dx = 0; dx < width; dx++) { initChunkSeed(dx + x, dz + z); diff --git a/src/main/java/twilightforest/world/layer/GenLayerTFBiomes1Point7.java b/src/main/java/twilightforest/world/layer/GenLayerTFBiomes1Point7.java index a68a2a748e..4709733a71 100644 --- a/src/main/java/twilightforest/world/layer/GenLayerTFBiomes1Point7.java +++ b/src/main/java/twilightforest/world/layer/GenLayerTFBiomes1Point7.java @@ -15,9 +15,9 @@ public class GenLayerTFBiomes1Point7 extends GenLayer { private static final int RARE_BIOME_CHANCE = 15; - protected BiomeGenBase commonBiomes[] = (new BiomeGenBase[] { TFBiomeBase.twilightForest, + protected BiomeGenBase[] commonBiomes = (new BiomeGenBase[] { TFBiomeBase.twilightForest, TFBiomeBase.twilightForest2, TFBiomeBase.mushrooms, TFBiomeBase.oakSavanna, TFBiomeBase.fireflyForest }); - protected BiomeGenBase rareBiomes[] = (new BiomeGenBase[] { TFBiomeBase.tfLake, TFBiomeBase.deepMushrooms, + protected BiomeGenBase[] rareBiomes = (new BiomeGenBase[] { TFBiomeBase.tfLake, TFBiomeBase.deepMushrooms, TFBiomeBase.enchantedForest, TFBiomeBase.clearing }); public GenLayerTFBiomes1Point7(long l, GenLayer genlayer) { @@ -31,7 +31,7 @@ public GenLayerTFBiomes1Point7(long l) { @Override public int[] getInts(int x, int z, int width, int depth) { - int dest[] = IntCache.getIntCache(width * depth); + int[] dest = IntCache.getIntCache(width * depth); for (int dz = 0; dz < depth; dz++) { for (int dx = 0; dx < width; dx++) { initChunkSeed(dx + x, dz + z); diff --git a/src/main/java/twilightforest/world/layer/GenLayerTFCheckBad.java b/src/main/java/twilightforest/world/layer/GenLayerTFCheckBad.java index 618ae91d0d..fb0eab4e34 100644 --- a/src/main/java/twilightforest/world/layer/GenLayerTFCheckBad.java +++ b/src/main/java/twilightforest/world/layer/GenLayerTFCheckBad.java @@ -17,7 +17,7 @@ public GenLayerTFCheckBad(long par1, GenLayer par3GenLayer, String stage) { @Override public int[] getInts(int x, int z, int width, int depth) { - int input[] = parent.getInts(x, z, width, depth); + int[] input = parent.getInts(x, z, width, depth); for (int i = 0; i < width * depth; i++) { if (input[i] < 0 || input[i] > TFBiomeBase.fireSwamp.biomeID) { diff --git a/src/main/java/twilightforest/world/layer/GenLayerTFCompanionBiomes.java b/src/main/java/twilightforest/world/layer/GenLayerTFCompanionBiomes.java index 421778cec2..7153468beb 100644 --- a/src/main/java/twilightforest/world/layer/GenLayerTFCompanionBiomes.java +++ b/src/main/java/twilightforest/world/layer/GenLayerTFCompanionBiomes.java @@ -21,8 +21,8 @@ public int[] getInts(int x, int z, int width, int depth) { int nz = z - 1; int nwidth = width + 2; int ndepth = depth + 2; - int input[] = parent.getInts(nx, nz, nwidth, ndepth); - int output[] = IntCache.getIntCache(width * depth); + int[] input = parent.getInts(nx, nz, nwidth, ndepth); + int[] output = IntCache.getIntCache(width * depth); for (int dz = 0; dz < depth; dz++) { for (int dx = 0; dx < width; dx++) { int right = input[dx + 0 + (dz + 1) * nwidth]; diff --git a/src/main/java/twilightforest/world/layer/GenLayerTFFeatureZoom.java b/src/main/java/twilightforest/world/layer/GenLayerTFFeatureZoom.java index 3a25412f76..c03ea99a18 100644 --- a/src/main/java/twilightforest/world/layer/GenLayerTFFeatureZoom.java +++ b/src/main/java/twilightforest/world/layer/GenLayerTFFeatureZoom.java @@ -15,8 +15,8 @@ public int[] getInts(int x, int z, int width, int depth) { int sz = z >> 1; int swidth = (width >> 1) + 3; int sdepth = (depth >> 1) + 3; - int src[] = parent.getInts(sx, sz, swidth, sdepth); - int dest[] = IntCache.getIntCache(swidth * 2 * (sdepth * 2)); + int[] src = parent.getInts(sx, sz, swidth, sdepth); + int[] dest = IntCache.getIntCache(swidth * 2 * (sdepth * 2)); int doubleWidth = swidth << 1; for (int dz = 0; dz < sdepth - 1; dz++) { for (int dx = 0; dx < swidth - 1; dx++) { @@ -27,7 +27,7 @@ public int[] getInts(int x, int z, int width, int depth) { } } - int output[] = IntCache.getIntCache(width * depth); + int[] output = IntCache.getIntCache(width * depth); for (int copyZ = 0; copyZ < depth; copyZ++) { System.arraycopy(dest, (copyZ + (z & 1)) * (swidth << 1) + (x & 1), output, copyZ * width, width); } diff --git a/src/main/java/twilightforest/world/layer/GenLayerTFKeyBiomes.java b/src/main/java/twilightforest/world/layer/GenLayerTFKeyBiomes.java index 2351b4f25f..b74b271eef 100644 --- a/src/main/java/twilightforest/world/layer/GenLayerTFKeyBiomes.java +++ b/src/main/java/twilightforest/world/layer/GenLayerTFKeyBiomes.java @@ -23,8 +23,8 @@ public GenLayerTFKeyBiomes(long l) { } public int[] getInts(int x, int z, int width, int depth) { - int src[] = this.parent.getInts(x, z, width, depth); - int dest[] = IntCache.getIntCache(width * depth); + int[] src = this.parent.getInts(x, z, width, depth); + int[] dest = IntCache.getIntCache(width * depth); for (int dz = 0; dz < depth; dz++) { for (int dx = 0; dx < width; dx++) { // get offsets @@ -72,16 +72,11 @@ private int getKeyBiomeFor(int mapX, int mapZ, int index) { // do we need to shuffle this better? // the current version just "rotates" the 4 key biomes - switch ((index + offset) % 4) { - case 0: - default: - return TFBiomeBase.glacier.biomeID; - case 1: - return TFBiomeBase.fireSwamp.biomeID; - case 2: - return TFBiomeBase.darkForestCenter.biomeID; - case 3: - return TFBiomeBase.highlandsCenter.biomeID; - } + return switch ((index + offset) % 4) { + default -> TFBiomeBase.glacier.biomeID; + case 1 -> TFBiomeBase.fireSwamp.biomeID; + case 2 -> TFBiomeBase.darkForestCenter.biomeID; + case 3 -> TFBiomeBase.highlandsCenter.biomeID; + }; } } diff --git a/src/main/java/twilightforest/world/layer/GenLayerTFStream.java b/src/main/java/twilightforest/world/layer/GenLayerTFStream.java index f27df0cce6..981ca9941a 100644 --- a/src/main/java/twilightforest/world/layer/GenLayerTFStream.java +++ b/src/main/java/twilightforest/world/layer/GenLayerTFStream.java @@ -24,8 +24,8 @@ public int[] getInts(int x, int z, int width, int depth) { int nz = z - 1; int nwidth = width + 2; int ndepth = depth + 2; - int input[] = parent.getInts(nx, nz, nwidth, ndepth); - int output[] = IntCache.getIntCache(width * depth); + int[] input = parent.getInts(nx, nz, nwidth, ndepth); + int[] output = IntCache.getIntCache(width * depth); for (int dz = 0; dz < depth; dz++) { for (int dx = 0; dx < width; dx++) { int left = input[dx + 0 + (dz + 1) * nwidth]; diff --git a/src/main/java/twilightforest/world/layer/GenLayerTFThornBorder.java b/src/main/java/twilightforest/world/layer/GenLayerTFThornBorder.java index d7f2295d9f..f6ebb6f2b3 100644 --- a/src/main/java/twilightforest/world/layer/GenLayerTFThornBorder.java +++ b/src/main/java/twilightforest/world/layer/GenLayerTFThornBorder.java @@ -21,8 +21,8 @@ public int[] getInts(int x, int z, int width, int depth) { int nz = z - 1; int nwidth = width + 2; int ndepth = depth + 2; - int input[] = parent.getInts(nx, nz, nwidth, ndepth); - int output[] = IntCache.getIntCache(width * depth); + int[] input = parent.getInts(nx, nz, nwidth, ndepth); + int[] output = IntCache.getIntCache(width * depth); for (int dz = 0; dz < depth; dz++) { for (int dx = 0; dx < width; dx++) { int right = input[dx + 0 + (dz + 1) * nwidth];