From 4e03ac893c3f76529a2a170045c71327a77f7fb5 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sun, 26 May 2019 12:37:59 +0100 Subject: [PATCH] 1147 - Initial auto mappings pass --- build.gradle | 203 ++---------------- settings.gradle | 2 +- src/main/java/techreborn/TechReborn.java | 24 +-- src/main/java/techreborn/api/IC2Helper.java | 5 +- .../techreborn/api/RollingMachineRecipe.java | 14 +- .../FluidReplicatorRecipe.java | 2 +- .../FluidReplicatorRecipeCrafter.java | 16 +- .../FluidReplicatorRecipeList.java | 2 +- .../api/generator/FluidGeneratorRecipe.java | 2 +- .../generator/FluidGeneratorRecipeList.java | 2 +- .../api/generator/GeneratorRecipeHelper.java | 2 +- .../api/recipe/ScrapboxRecipeCrafter.java | 6 +- .../recipe/recipes/BlastFurnaceRecipe.java | 14 +- .../recipes/IndustrialGrinderRecipe.java | 12 +- .../recipes/IndustrialSawmillRecipe.java | 12 +- .../java/techreborn/blocks/BlockAlarm.java | 100 ++++----- .../techreborn/blocks/BlockComputerCube.java | 26 +-- .../techreborn/blocks/BlockMachineCasing.java | 16 +- .../techreborn/blocks/BlockMachineFrame.java | 6 +- .../java/techreborn/blocks/BlockNuke.java | 62 +++--- src/main/java/techreborn/blocks/BlockOre.java | 10 +- .../blocks/BlockRefinedIronFence.java | 12 +- .../blocks/BlockReinforcedGlass.java | 14 +- .../techreborn/blocks/BlockRubberLeaves.java | 24 +-- .../techreborn/blocks/BlockRubberLog.java | 92 ++++---- .../techreborn/blocks/BlockRubberPlank.java | 12 +- .../blocks/BlockRubberPlankSlab.java | 12 +- .../blocks/BlockRubberPlankStair.java | 6 +- .../techreborn/blocks/BlockRubberSapling.java | 10 +- .../java/techreborn/blocks/BlockStorage.java | 6 +- .../blocks/BlockSupercondensator.java | 16 +- .../java/techreborn/blocks/RubberTree.java | 9 +- .../techreborn/blocks/cable/BlockCable.java | 50 ++--- .../blocks/fluid/BlockFluidBase.java | 8 +- .../blocks/fluid/BlockFluidTechReborn.java | 4 +- .../blocks/fluid/TechRebornFluid.java | 8 +- .../generator/BlockDieselGenerator.java | 6 +- .../generator/BlockDragonEggSyphon.java | 6 +- .../blocks/generator/BlockFusionCoil.java | 52 ++--- .../generator/BlockFusionControlComputer.java | 40 ++-- .../blocks/generator/BlockGasTurbine.java | 6 +- .../blocks/generator/BlockLightningRod.java | 6 +- .../generator/BlockMagicEnergyAbsorber.java | 14 +- .../generator/BlockMagicEnergyConverter.java | 14 +- .../generator/BlockPlasmaGenerator.java | 6 +- .../generator/BlockSemiFluidGenerator.java | 6 +- .../blocks/generator/BlockSolarPanel.java | 6 +- .../generator/BlockSolidFuelGenerator.java | 6 +- .../generator/BlockThermalGenerator.java | 6 +- .../blocks/generator/BlockWaterMill.java | 6 +- .../blocks/generator/BlockWindMill.java | 6 +- .../techreborn/blocks/lighting/BlockLamp.java | 84 ++++---- .../blocks/storage/BlockAdjustableSU.java | 12 +- .../blocks/storage/BlockEnergyStorage.java | 52 ++--- .../blocks/storage/BlockHighVoltageSU.java | 12 +- .../storage/BlockInterdimensionalSU.java | 30 +-- .../blocks/storage/BlockLSUStorage.java | 46 ++-- .../blocks/storage/BlockLapotronicSU.java | 12 +- .../blocks/storage/BlockLowVoltageSU.java | 6 +- .../blocks/storage/BlockMediumVoltageSU.java | 12 +- .../blocks/tier0/BlockIronAlloyFurnace.java | 12 +- .../blocks/tier0/BlockIronFurnace.java | 46 ++-- .../blocks/tier1/BlockAlloySmelter.java | 6 +- .../blocks/tier1/BlockAssemblingMachine.java | 6 +- .../blocks/tier1/BlockAutoCraftingTable.java | 6 +- .../blocks/tier1/BlockCompressor.java | 6 +- .../blocks/tier1/BlockElectricFurnace.java | 6 +- .../blocks/tier1/BlockExtractor.java | 6 +- .../techreborn/blocks/tier1/BlockGrinder.java | 6 +- .../blocks/tier1/BlockPlayerDetector.java | 76 +++---- .../blocks/tier1/BlockRecycler.java | 6 +- .../blocks/tier1/BlockRollingMachine.java | 6 +- .../blocks/tier1/BlockScrapboxinator.java | 6 +- .../blocks/tier2/BlockChargeOMat.java | 6 +- .../blocks/tier2/BlockChemicalReactor.java | 6 +- .../blocks/tier2/BlockDigitalChest.java | 6 +- .../blocks/tier2/BlockDistillationTower.java | 16 +- .../tier2/BlockImplosionCompressor.java | 6 +- .../tier2/BlockIndustrialBlastFurnace.java | 6 +- .../tier2/BlockIndustrialCentrifuge.java | 6 +- .../tier2/BlockIndustrialElectrolyzer.java | 6 +- .../blocks/tier2/BlockIndustrialGrinder.java | 6 +- .../blocks/tier2/BlockIndustrialSawmill.java | 6 +- .../blocks/tier2/BlockVacuumFreezer.java | 6 +- .../blocks/tier3/BlockChunkLoader.java | 6 +- .../tier3/BlockCreativeQuantumChest.java | 12 +- .../tier3/BlockCreativeQuantumTank.java | 6 +- .../blocks/tier3/BlockFluidReplicator.java | 6 +- .../blocks/tier3/BlockMatterFabricator.java | 6 +- .../blocks/tier3/BlockQuantumChest.java | 6 +- .../blocks/tier3/BlockQuantumTank.java | 6 +- .../transformers/BlockHVTransformer.java | 12 +- .../transformers/BlockLVTransformer.java | 6 +- .../transformers/BlockMVTransformer.java | 12 +- .../blocks/transformers/BlockTransformer.java | 52 ++--- .../techreborn/client/ClientEventHandler.java | 14 +- src/main/java/techreborn/client/EGui.java | 59 +++-- .../java/techreborn/client/GuiHandler.java | 18 +- .../container/ContainerDestructoPack.java | 10 +- .../builder/slot/FurnaceFuelSlot.java | 14 +- .../java/techreborn/client/gui/GuiAESU.java | 12 +- .../client/gui/GuiAlloyFurnace.java | 42 ++-- .../client/gui/GuiAlloySmelter.java | 12 +- .../client/gui/GuiAssemblingMachine.java | 12 +- .../client/gui/GuiAutoCrafting.java | 31 +-- .../java/techreborn/client/gui/GuiBatbox.java | 12 +- .../client/gui/GuiBlastFurnace.java | 24 +-- .../techreborn/client/gui/GuiCentrifuge.java | 12 +- .../techreborn/client/gui/GuiChargeBench.java | 12 +- .../client/gui/GuiChemicalReactor.java | 12 +- .../techreborn/client/gui/GuiChunkLoader.java | 60 +++--- .../techreborn/client/gui/GuiCompressor.java | 12 +- .../client/gui/GuiDestructoPack.java | 32 +-- .../client/gui/GuiDieselGenerator.java | 18 +- .../client/gui/GuiDigitalChest.java | 24 +-- .../client/gui/GuiDistillationTower.java | 32 +-- .../client/gui/GuiElectricFurnace.java | 12 +- .../techreborn/client/gui/GuiExtractor.java | 12 +- .../client/gui/GuiFluidReplicator.java | 24 +-- .../client/gui/GuiFusionReactor.java | 22 +- .../techreborn/client/gui/GuiGasTurbine.java | 12 +- .../techreborn/client/gui/GuiGenerator.java | 12 +- .../techreborn/client/gui/GuiGrinder.java | 12 +- .../java/techreborn/client/gui/GuiIDSU.java | 12 +- .../client/gui/GuiImplosionCompressor.java | 16 +- .../client/gui/GuiIndustrialElectrolyzer.java | 12 +- .../client/gui/GuiIndustrialGrinder.java | 28 +-- .../client/gui/GuiIndustrialSawmill.java | 28 +-- .../techreborn/client/gui/GuiIronFurnace.java | 40 ++-- .../java/techreborn/client/gui/GuiLESU.java | 12 +- .../java/techreborn/client/gui/GuiMFE.java | 12 +- .../java/techreborn/client/gui/GuiMFSU.java | 13 +- .../java/techreborn/client/gui/GuiManual.java | 42 ++-- .../client/gui/GuiMatterFabricator.java | 12 +- .../client/gui/GuiPlasmaGenerator.java | 18 +- .../client/gui/GuiQuantumChest.java | 20 +- .../techreborn/client/gui/GuiQuantumTank.java | 24 +-- .../techreborn/client/gui/GuiRecycler.java | 12 +- .../client/gui/GuiRollingMachine.java | 12 +- .../client/gui/GuiScrapboxinator.java | 12 +- .../client/gui/GuiSemifluidGenerator.java | 12 +- .../client/gui/GuiThermalGenerator.java | 12 +- .../client/gui/GuiVacuumFreezer.java | 20 +- .../client/keybindings/KeyBindings.java | 2 +- .../client/particle/ParticleSmoke.java | 4 +- .../client/render/ModelDynamicCell.java | 83 +++---- .../techreborn/client/render/ModelHelper.java | 30 +-- .../render/entitys/RenderNukePrimed.java | 39 ++-- .../techreborn/entities/EntityNukePrimed.java | 34 +-- .../techreborn/events/BlockBreakHandler.java | 34 +-- .../events/ModelRegistryEventHandler.java | 36 ++-- .../events/RegistryEventHandler.java | 82 +++---- .../techreborn/events/StackToolTipEvent.java | 62 +++--- .../techreborn/events/TRRecipeHandler.java | 44 ++-- .../java/techreborn/events/TRTickHandler.java | 20 +- src/main/java/techreborn/init/ModFluids.java | 6 +- src/main/java/techreborn/init/ModLoot.java | 50 +++-- src/main/java/techreborn/init/ModRecipes.java | 44 ++-- src/main/java/techreborn/init/ModSounds.java | 14 +- src/main/java/techreborn/init/ModTags.java | 8 +- .../java/techreborn/init/TRArmorMaterial.java | 41 ++-- src/main/java/techreborn/init/TRContent.java | 42 ++-- .../java/techreborn/init/TRTileEntities.java | 134 ++++++------ src/main/java/techreborn/init/TRToolTier.java | 31 ++- .../init/recipes/ChemicalReactorRecipes.java | 4 +- .../init/recipes/CraftingTableRecipes.java | 2 +- .../recipes/DistillationTowerRecipes.java | 12 +- .../init/recipes/FluidGeneratorRecipes.java | 2 +- .../recipes/ImplosionCompressorRecipes.java | 1 - .../recipes/IndustrialCentrifugeRecipes.java | 8 +- .../init/recipes/RecipeMethods.java | 2 +- .../init/recipes/RollingMachineRecipes.java | 40 ++-- .../init/recipes/ScrapboxRecipes.java | 4 +- .../init/recipes/SmeltingRecipes.java | 2 +- .../itemblocks/ItemBlockRubberSapling.java | 6 +- .../java/techreborn/items/DynamicCell.java | 90 ++++---- src/main/java/techreborn/items/ItemCells.java | 2 +- .../techreborn/items/ItemDestructopack.java | 16 +- .../items/ItemFrequencyTransmitter.java | 118 +++++----- .../java/techreborn/items/ItemManual.java | 12 +- .../java/techreborn/items/ItemScrapBox.java | 22 +- .../java/techreborn/items/ItemUpgrade.java | 2 +- .../items/armor/ItemCloakingDevice.java | 42 ++-- .../items/armor/ItemLapotronicOrbpack.java | 34 +-- .../items/armor/ItemLithiumIonBatpack.java | 46 ++-- .../techreborn/items/armor/ItemTRArmour.java | 26 +-- .../techreborn/items/battery/ItemBattery.java | 24 +-- .../items/battery/ItemEnergyCrystal.java | 12 +- .../items/battery/ItemLapotronCrystal.java | 12 +- .../items/battery/ItemLapotronicOrb.java | 12 +- .../items/battery/ItemLithiumIonBattery.java | 12 +- .../items/battery/ItemRedCellBattery.java | 12 +- .../techreborn/items/tool/ItemChainsaw.java | 52 ++--- .../techreborn/items/tool/ItemDebugTool.java | 79 ++++--- .../java/techreborn/items/tool/ItemDrill.java | 44 ++-- .../techreborn/items/tool/ItemJackhammer.java | 44 ++-- .../techreborn/items/tool/ItemTreeTap.java | 2 +- .../techreborn/items/tool/ItemWrench.java | 8 +- .../tool/advanced/ItemAdvancedChainsaw.java | 24 +-- .../tool/advanced/ItemAdvancedDrill.java | 24 +-- .../tool/advanced/ItemAdvancedJackhammer.java | 18 +- .../items/tool/advanced/ItemRockCutter.java | 57 +++-- .../items/tool/basic/ItemBasicChainsaw.java | 24 +-- .../items/tool/basic/ItemBasicDrill.java | 24 +-- .../items/tool/basic/ItemBasicJackhammer.java | 18 +- .../items/tool/basic/ItemElectricTreetap.java | 34 +-- .../industrial/ItemIndustrialChainsaw.java | 134 ++++++------ .../tool/industrial/ItemIndustrialDrill.java | 143 ++++++------ .../industrial/ItemIndustrialJackhammer.java | 20 +- .../items/tool/industrial/ItemNanosaber.java | 130 +++++------ .../items/tool/industrial/ItemOmniTool.java | 65 +++--- .../items/tool/vanilla/ItemTRAxe.java | 16 +- .../items/tool/vanilla/ItemTRHoe.java | 16 +- .../items/tool/vanilla/ItemTRPickaxe.java | 16 +- .../items/tool/vanilla/ItemTRSpade.java | 16 +- .../items/tool/vanilla/ItemTRSword.java | 16 +- .../multiblocks/MultiBlockCasing.java | 18 +- .../packets/ServerboundPackets.java | 19 +- .../java/techreborn/proxies/ClientProxy.java | 26 +-- src/main/java/techreborn/tiles/TileAlarm.java | 38 ++-- .../java/techreborn/tiles/TileChargeOMat.java | 16 +- .../techreborn/tiles/TileDigitalChest.java | 4 +- .../techreborn/tiles/TileGenericMachine.java | 16 +- .../tiles/TileIndustrialCentrifuge.java | 12 +- .../techreborn/tiles/TileTechStorageBase.java | 128 +++++------ .../techreborn/tiles/cable/TileCable.java | 78 +++---- .../TileFusionControlComputer.java | 58 ++--- .../generator/TileBaseFluidGenerator.java | 36 ++-- .../tiles/generator/TileLightningRod.java | 26 +-- .../tiles/generator/TilePlasmaGenerator.java | 6 +- .../tiles/generator/TileSolarPanel.java | 40 ++-- .../advanced/TileDieselGenerator.java | 6 +- .../advanced/TileDragonEggSyphon.java | 20 +- .../generator/advanced/TileGasTurbine.java | 6 +- .../advanced/TileSemiFluidGenerator.java | 6 +- .../advanced/TileThermalGenerator.java | 6 +- .../basic/TileSolidFuelGenerator.java | 34 +-- .../tiles/generator/basic/TileWaterMill.java | 16 +- .../tiles/generator/basic/TileWindMill.java | 10 +- .../techreborn/tiles/lighting/TileLamp.java | 18 +- .../machine/iron/TileIronAlloyFurnace.java | 42 ++-- .../tiles/machine/iron/TileIronFurnace.java | 54 ++--- .../machine/multiblock/MultiblockChecker.java | 6 +- .../multiblock/TileDistillationTower.java | 24 +-- .../multiblock/TileFluidReplicator.java | 22 +- .../multiblock/TileImplosionCompressor.java | 6 +- .../TileIndustrialBlastFurnace.java | 26 +-- .../multiblock/TileIndustrialGrinder.java | 34 +-- .../multiblock/TileIndustrialSawmill.java | 34 +-- .../machine/multiblock/TileVacuumFreezer.java | 6 +- .../tiles/machine/tier1/TileAlloySmelter.java | 4 +- .../machine/tier1/TileAssemblingMachine.java | 4 +- .../machine/tier1/TileAutoCraftingTable.java | 154 ++++++------- .../machine/tier1/TileChemicalReactor.java | 4 +- .../tiles/machine/tier1/TileCompressor.java | 4 +- .../machine/tier1/TileElectricFurnace.java | 42 ++-- .../tiles/machine/tier1/TileExtractor.java | 4 +- .../tiles/machine/tier1/TileGrinder.java | 4 +- .../tier1/TileIndustrialElectrolyzer.java | 4 +- .../machine/tier1/TilePlayerDectector.java | 34 +-- .../tiles/machine/tier1/TileRecycler.java | 30 +-- .../machine/tier1/TileRollingMachine.java | 124 +++++------ .../machine/tier1/TileScrapboxinator.java | 4 +- .../tiles/machine/tier3/TileChunkLoader.java | 12 +- .../tier3/TileCreativeQuantumChest.java | 6 +- .../machine/tier3/TileMatterFabricator.java | 30 +-- .../tiles/machine/tier3/TileQuantumChest.java | 8 +- .../tiles/machine/tier3/TileQuantumTank.java | 50 ++--- .../tiles/storage/TileAdjustableSU.java | 24 +-- .../tiles/storage/TileEnergyStorage.java | 24 +-- .../tiles/storage/TileHighVoltageSU.java | 4 +- .../tiles/storage/TileLowVoltageSU.java | 4 +- .../tiles/storage/TileMediumVoltageSU.java | 4 +- .../tiles/storage/idsu/IDSUSaveManger.java | 10 +- .../storage/idsu/TileInterdimensionalSU.java | 14 +- .../tiles/storage/lesu/TileLSUStorage.java | 18 +- .../tiles/storage/lesu/TileLapotronicSU.java | 22 +- .../tiles/transformers/TileTransformer.java | 32 +-- .../utils/BehaviorDispenseScrapbox.java | 24 +-- .../java/techreborn/utils/FluidUtils.java | 2 +- src/main/java/techreborn/utils/InitUtils.java | 6 +- .../techreborn/utils/StackWIPHandler.java | 28 +-- src/main/java/techreborn/utils/TagUtils.java | 20 +- .../damageSources/ElectrialShockSource.java | 2 +- .../damageSources/FusionDamageSource.java | 2 +- .../techreborn/world/OilLakeGenerator.java | 10 +- .../techreborn/world/RubberTreeGenerator.java | 16 +- .../world/feature/RubberTreeFeature.java | 35 ++- .../world/village/ModLootTables.java | 6 +- .../VillageComponentRubberPlantaion.java | 36 ++-- .../village/VillagePlantaionHandler.java | 14 +- 291 files changed, 3335 insertions(+), 3504 deletions(-) diff --git a/build.gradle b/build.gradle index a4dc4abce..b2153e88e 100644 --- a/build.gradle +++ b/build.gradle @@ -2,10 +2,6 @@ buildscript { repositories { mavenCentral() jcenter() - maven { - name = "forge" - url = "http://files.minecraftforge.net/maven" - } maven { name = "sonatype" url = "https://oss.sonatype.org/content/repositories/snapshots/" @@ -17,16 +13,20 @@ buildscript { name = "CB Repo" url = "http://chickenbones.net/maven" } + maven { + name = "Modmuss50" + url = "http://maven.modmuss50.me/" + } } dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true + classpath "net.fabricmc:fabric-loom:0.2.2-SNAPSHOT" classpath "gradle.plugin.net.minecrell:licenser:0.2.1" classpath 'de.undercouch:gradle-download-task:3.4.3' //classpath 'net.covers1624:GradleStuff:1.0-SNAPSHOT' } } -apply plugin: 'net.minecraftforge.gradle' +apply plugin: net.fabricmc.loom.LoomGradlePlugin apply plugin: 'maven' apply plugin: 'maven-publish' apply plugin: net.minecrell.gradle.licenser.Licenser @@ -64,40 +64,6 @@ if (ENV.BUILD_NUMBER) { version = version + "." + "${System.getenv().BUILD_NUMBER}" } -minecraft { - mappings channel: 'snapshot', version: '20190401-1.13.2' - - runs { - client { - workingDirectory project.file('run') - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - property 'forge.logging.console.level', 'debug' - - mods { - techreborn { - source sourceSets.main - } - if (findProject(':reborncore') != null) { - reborncore { - source project(":reborncore").sourceSets.main - } - } - } - } - - server { - workingDirectory project.file('run') - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - property 'forge.logging.console.level', 'debug' - mods { - techreborn { - source sourceSets.main - } - } - } - } -} - license { header file('HEADER') include '**/*.java' @@ -107,23 +73,27 @@ license { group = 'TechReborn' dependencies { - minecraft 'net.minecraftforge:forge:1.13.2-25.0.191' + minecraft "com.mojang:minecraft:1.14" + mappings "net.fabricmc:yarn:1.14+build.21" + + modCompile "net.fabricmc:fabric-loader:0.4.8+build.154" + + modCompile "net.fabricmc.fabric-api:fabric-api:0.3.0-pre+build.156" - if (findProject(':reborncore') != null) { - compile project(":reborncore") - } else { - compile 'RebornCore:RebornCore-1.13.2:+:dev' + modCompile ('RebornCore:RebornCore-1.14:4.0.0.14') { + transitive = false } + compileOnly "com.google.code.findbugs:jsr305:+" } processResources{ inputs.property 'version', project.version - inputs.property 'mcversion', '1.13.2' + inputs.property 'mcversion', '1.14' from(sourceSets.main.resources.srcDirs) { include 'META_INF/mods.toml' - expand 'version':project.version, 'mcversion': '1.13.2' + expand 'version':project.version, 'mcversion': '1.14' } from(sourceSets.main.resources.srcDirs) { @@ -249,6 +219,8 @@ import com.google.gson.JsonArray import groovy.util.XmlSlurper import org.apache.commons.io.FileUtils +import java.util.function.Consumer + task curseTools { doLast { def cacheFiles = new File(".gradle/curseTools") @@ -277,140 +249,3 @@ task curseTools { } } } - -import com.google.gson.GsonBuilder -import com.google.gson.JsonObject -import org.apache.commons.io.IOUtils - -import java.util.zip.ZipFile - -//Reads the new fml_cache_annotation file built into the jar file, to find all crafttweaker methods, and saves the data to a file -task mtDocGen { - doLast{ - def inputFile = new File(jar.archivePath.getAbsolutePath()) - println("Reading " + inputFile.getName() + " for crafttweaker documentation") - def jarFile = new ZipFile(inputFile) - - def annotation_cache = jarFile.getEntry("META-INF/fml_cache_annotation.json") - def cache_json = IOUtils.toString(jarFile.getInputStream(annotation_cache), "UTF-8") - - def jsonObject = new GsonBuilder().create().fromJson(cache_json, JsonObject.class) - - def builder = new StringBuilder() - - for(entry in jsonObject.entrySet()){ - def clzz = entry.value.asJsonObject - if(!clzz.has("annotations")){ - continue - } - def annoations = clzz.get("annotations").asJsonArray - for(annotation in annoations.toList()){ - if(annotation.asJsonObject.get("type").asString.equals("METHOD") && annotation.asJsonObject.get("name").asString.equals("Lstanhebben/zenscript/annotations/ZenMethod;")){ - def method = sanitsiseMethodName(annotation.asJsonObject.get("target").asString) - if(hasZenDoc(annotation, annoations)){ - method = getZenDoc(annotation, annoations) - } - def zen_name = getZenMetName(clzz) - builder.append(zen_name + "." + method) - builder.append("\n") - } - - } - } - - def outputFile = new File(jar.archivePath.getAbsolutePath().replace(".jar", "-crafttweaker.txt")) - outputFile.write builder.toString() - - println("Crafttweaker documentation saved to " + outputFile.name) - } -} - -boolean hasZenDoc(JsonObject currentAnnotation, JsonArray annoations){ - for(annotation in annoations.toList()){ - if(annotation.asJsonObject.get("target").asString.equals(currentAnnotation.get("target").asString) && annotation.asJsonObject.get("name").asString.equals("Ltechreborn/compat/crafttweaker/ZenDocumentation;")){ - return true - } - } - return false -} - -String getZenDoc(JsonObject currentAnnotation, JsonArray annoations){ - for(annotation in annoations.toList()){ - if(annotation.asJsonObject.get("target").asString.equals(currentAnnotation.get("target").asString) && annotation.asJsonObject.get("name").asString.equals("Ltechreborn/compat/crafttweaker/ZenDocumentation;")){ - def methodName = annotation.asJsonObject.get("target").asString.split("\\(")[0] - def methodParams = annotation.asJsonObject.get("value").asJsonObject.get("value").asString - if(!methodParams.startsWith("(")){ - methodParams = "(" + methodParams - } - if(!methodParams.endsWith(")")){ - methodParams = methodParams + ")" - } - return methodName + methodParams - } - } - return "" -} - -//Gets the zenMethod class name from the class json object -String getZenMetName(JsonObject jsonObject){ - def annoations = jsonObject.get("annotations").asJsonArray - for(annotation in annoations.toList()){ - if(annotation.asJsonObject.get("type").asString.equals("CLASS") && annotation.asJsonObject.get("name").asString.equals("Lstanhebben/zenscript/annotations/ZenClass;")){ - return annotation.asJsonObject.get("value").asJsonObject.get("value").asString - } - } -} - -String sanitsiseMethodName(String methodSig){ - def builder = new StringBuilder() - def name = methodSig.split("\\(")[0] - builder.append(name) - builder.append("(") - - def methodArgs = methodSig.split("\\(")[1].split("\\)")[0].split(";") - for(arg in methodArgs){ - def argSlit = arg.split("/") - def argStr = argSlit[argSlit.length -1] - //If a class is not in a package I assume its a primitive //TODO any suggestions for a better way to do this? - if(!arg.contains("/") && !arg.isEmpty()){ - argStr = humanizeArg(argStr) - } - builder.append(argStr) - //Dont add the comma to the last arg - if(arg != methodArgs[methodArgs.length - 1]){ - builder.append(",") - } - - } - builder.append(")") - - return builder.toString() -} - -//Argumets that are java primitives do not use a freindly name, this method replaces them with something most people will understand -String humanizeArg(String arg){ - def primitiveMap = [ - Z: "Boolean", - B: "Byte", - C: "Char", - D: "Double", - F: "Float", - I: "Integer", - J: "Long", - L: "Object", - S: "Short" - ] - - def builder = new StringBuilder() - for(cha in arg.toCharArray()){ - builder.append(primitiveMap.get(cha.toString().toUpperCase())) - builder.append(",") - } - //Removes the last , - return builder.toString().substring(0, builder.toString().length() - 1) -} - -task copyToLib(type: Copy) { - into "$buildDir/output/lib" - from configurations.runtime -} diff --git a/settings.gradle b/settings.gradle index 982a6bffa..5e4a221ec 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -rootProject.name = "TechReborn-1.13.2" \ No newline at end of file +rootProject.name = "TechReborn-1.14.2" \ No newline at end of file diff --git a/src/main/java/techreborn/TechReborn.java b/src/main/java/techreborn/TechReborn.java index aca1ac9df..7b8eddfec 100644 --- a/src/main/java/techreborn/TechReborn.java +++ b/src/main/java/techreborn/TechReborn.java @@ -24,18 +24,18 @@ package techreborn; -import net.minecraft.block.BlockDispenser; +import net.minecraft.block.DispenserBlock; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.registry.VillagerRegistry; -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + + + + + + + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import reborncore.common.multiblock.MultiblockEventHandler; @@ -66,7 +66,7 @@ public class TechReborn { public static TechReborn INSTANCE; public static final ItemGroup ITEMGROUP = new ItemGroup(-1, MOD_ID) { - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) public ItemStack createIcon() { return TRContent.Parts.MACHINE_PARTS.getStack(); } @@ -127,7 +127,7 @@ public class TechReborn { // Scrapbox if (BehaviorDispenseScrapbox.dispenseScrapboxes) { - BlockDispenser.registerDispenseBehavior(TRContent.SCRAP_BOX, new BehaviorDispenseScrapbox()); + DispenserBlock.registerBehavior(TRContent.SCRAP_BOX, new BehaviorDispenseScrapbox()); } Torus.genSizeMap(TileFusionControlComputer.maxCoilSize); diff --git a/src/main/java/techreborn/api/IC2Helper.java b/src/main/java/techreborn/api/IC2Helper.java index fa1ca059b..a8e6eb048 100644 --- a/src/main/java/techreborn/api/IC2Helper.java +++ b/src/main/java/techreborn/api/IC2Helper.java @@ -25,14 +25,13 @@ package techreborn.api; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; - +import net.minecraft.item.ItemUsageContext; import java.util.List; public interface IC2Helper { public void initDuplicates(); - public boolean extractSap(ItemUseContext context, List stacks); + public boolean extractSap(ItemUsageContext context, List stacks); } diff --git a/src/main/java/techreborn/api/RollingMachineRecipe.java b/src/main/java/techreborn/api/RollingMachineRecipe.java index 68d494d3d..4c1d5e0da 100644 --- a/src/main/java/techreborn/api/RollingMachineRecipe.java +++ b/src/main/java/techreborn/api/RollingMachineRecipe.java @@ -24,10 +24,10 @@ package techreborn.api; -import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.ResourceLocation; +import net.minecraft.recipe.Recipe; +import net.minecraft.util.Identifier; import net.minecraft.world.World; @@ -35,19 +35,19 @@ public class RollingMachineRecipe { public static final RollingMachineRecipe instance = new RollingMachineRecipe(); - public void addShapedOreRecipe(ResourceLocation resourceLocation, ItemStack outputItemStack, Object... objectInputs) { + public void addShapedOreRecipe(Identifier resourceLocation, ItemStack outputItemStack, Object... objectInputs) { throw new UnsupportedOperationException("Needs moving to json"); } - public void addShapelessOreRecipe(ResourceLocation resourceLocation, ItemStack outputItemStack, Object... objectInputs) { + public void addShapelessOreRecipe(Identifier resourceLocation, ItemStack outputItemStack, Object... objectInputs) { throw new UnsupportedOperationException("Needs moving to json"); } - public ItemStack findMatchingRecipeOutput(InventoryCrafting inv, World world) { + public ItemStack findMatchingRecipeOutput(CraftingInventory inv, World world) { throw new UnsupportedOperationException("Needs moving to json"); } - public IRecipe findMatchingRecipe(InventoryCrafting inv, World world) { + public Recipe findMatchingRecipe(CraftingInventory inv, World world) { throw new UnsupportedOperationException("Needs moving to json"); } diff --git a/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipe.java b/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipe.java index e07564279..b788abbfa 100644 --- a/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipe.java +++ b/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipe.java @@ -25,7 +25,7 @@ package techreborn.api.fluidreplicator; import net.minecraft.util.math.BlockPos; -import net.minecraftforge.fluids.Fluid; + import reborncore.common.util.FluidUtils; import techreborn.init.TRContent; import techreborn.tiles.machine.multiblock.TileFluidReplicator; diff --git a/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeCrafter.java b/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeCrafter.java index 261e0b061..e88385062 100644 --- a/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeCrafter.java +++ b/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeCrafter.java @@ -24,10 +24,10 @@ package techreborn.api.fluidreplicator; +import net.minecraft.block.entity.BlockEntity; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; + + import reborncore.common.recipes.RecipeCrafter; import reborncore.common.util.Inventory; import reborncore.common.util.Tank; @@ -52,7 +52,7 @@ public class FluidReplicatorRecipeCrafter extends RecipeCrafter { * @param inputSlots This is the list of the slots that the crafting logic should look for the input UU-Matter. * @param outputSlots This is the list of slots that the crafting logic should look for output fluid */ - public FluidReplicatorRecipeCrafter(TileEntity parentTile, Inventory inventory, int[] inputSlots, int[] outputSlots) { + public FluidReplicatorRecipeCrafter(BlockEntity parentTile, Inventory inventory, int[] inputSlots, int[] outputSlots) { super(ModRecipes.FLUID_REPLICATOR, parentTile, 1, 1, inventory, inputSlots, outputSlots); } @@ -63,11 +63,11 @@ public class FluidReplicatorRecipeCrafter extends RecipeCrafter { if (recipe == null) { return false; } - ItemStack inputStack = inventory.getStackInSlot(inputSlots[0]); - if (!inputStack.isItemEqual(TRContent.Parts.UU_MATTER.getStack())) { + ItemStack inputStack = inventory.getInvStack(inputSlots[0]); + if (!inputStack.isEqualIgnoreTags(TRContent.Parts.UU_MATTER.getStack())) { return false; } - if (inputStack.getCount() < recipe.getInput()) { + if (inputStack.getAmount() < recipe.getInput()) { return false; } @@ -92,7 +92,7 @@ public class FluidReplicatorRecipeCrafter extends RecipeCrafter { // RecipeCrafter @Override public void updateEntity() { - if (tile.getWorld().isRemote) { + if (tile.getWorld().isClient) { return; } ticksSinceLastChange++; diff --git a/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeList.java b/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeList.java index bfedb6066..29dde6277 100644 --- a/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeList.java +++ b/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeList.java @@ -24,7 +24,7 @@ package techreborn.api.fluidreplicator; -import net.minecraftforge.fluids.Fluid; + import org.apache.commons.lang3.Validate; import reborncore.common.util.FluidUtils; diff --git a/src/main/java/techreborn/api/generator/FluidGeneratorRecipe.java b/src/main/java/techreborn/api/generator/FluidGeneratorRecipe.java index fae632ed2..e66c500e4 100644 --- a/src/main/java/techreborn/api/generator/FluidGeneratorRecipe.java +++ b/src/main/java/techreborn/api/generator/FluidGeneratorRecipe.java @@ -24,7 +24,7 @@ package techreborn.api.generator; -import net.minecraftforge.fluids.Fluid; + import reborncore.common.util.FluidUtils; public class FluidGeneratorRecipe { diff --git a/src/main/java/techreborn/api/generator/FluidGeneratorRecipeList.java b/src/main/java/techreborn/api/generator/FluidGeneratorRecipeList.java index 0a74f92fb..645419964 100644 --- a/src/main/java/techreborn/api/generator/FluidGeneratorRecipeList.java +++ b/src/main/java/techreborn/api/generator/FluidGeneratorRecipeList.java @@ -25,7 +25,7 @@ package techreborn.api.generator; import com.google.common.collect.Sets; -import net.minecraftforge.fluids.Fluid; + import reborncore.common.util.FluidUtils; import java.util.HashSet; diff --git a/src/main/java/techreborn/api/generator/GeneratorRecipeHelper.java b/src/main/java/techreborn/api/generator/GeneratorRecipeHelper.java index 0c06c3732..64180ddab 100644 --- a/src/main/java/techreborn/api/generator/GeneratorRecipeHelper.java +++ b/src/main/java/techreborn/api/generator/GeneratorRecipeHelper.java @@ -24,7 +24,7 @@ package techreborn.api.generator; -import net.minecraftforge.fluids.Fluid; + import java.util.EnumMap; import java.util.Optional; diff --git a/src/main/java/techreborn/api/recipe/ScrapboxRecipeCrafter.java b/src/main/java/techreborn/api/recipe/ScrapboxRecipeCrafter.java index b9dd278cf..00039d440 100644 --- a/src/main/java/techreborn/api/recipe/ScrapboxRecipeCrafter.java +++ b/src/main/java/techreborn/api/recipe/ScrapboxRecipeCrafter.java @@ -24,13 +24,13 @@ package techreborn.api.recipe; -import net.minecraft.tileentity.TileEntity; import reborncore.common.crafting.Recipe; import reborncore.common.recipes.RecipeCrafter; import reborncore.common.util.Inventory; import techreborn.init.ModRecipes; import java.util.List; +import net.minecraft.block.entity.BlockEntity; /** * @author drcrazy @@ -44,14 +44,14 @@ public class ScrapboxRecipeCrafter extends RecipeCrafter { * @param inputSlots Slot IDs for input * @param outputSlots Slot IDs for output */ - public ScrapboxRecipeCrafter(TileEntity parentTile, Inventory inventory, int[] inputSlots, int[] outputSlots) { + public ScrapboxRecipeCrafter(BlockEntity parentTile, Inventory inventory, int[] inputSlots, int[] outputSlots) { super(ModRecipes.SCRAPBOX, parentTile, 1, 1, inventory, inputSlots, outputSlots); } @Override public void updateCurrentRecipe(){ List scrapboxRecipeList = ModRecipes.SCRAPBOX.getRecipes(tile.getWorld()); - int random = tile.getWorld().rand.nextInt(scrapboxRecipeList.size()); + int random = tile.getWorld().random.nextInt(scrapboxRecipeList.size()); // Sets the current recipe then syncs setCurrentRecipe(scrapboxRecipeList.get(random)); this.currentNeededTicks = Math.max((int) (currentRecipe.getTime() * (1.0 - getSpeedMultiplier())), 1); diff --git a/src/main/java/techreborn/api/recipe/recipes/BlastFurnaceRecipe.java b/src/main/java/techreborn/api/recipe/recipes/BlastFurnaceRecipe.java index 4bb63ee12..0cd397b23 100644 --- a/src/main/java/techreborn/api/recipe/recipes/BlastFurnaceRecipe.java +++ b/src/main/java/techreborn/api/recipe/recipes/BlastFurnaceRecipe.java @@ -25,9 +25,9 @@ package techreborn.api.recipe.recipes; import com.google.gson.JsonObject; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.JsonUtils; -import net.minecraft.util.ResourceLocation; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.util.Identifier; +import net.minecraft.util.JsonHelper; import reborncore.common.crafting.Recipe; import reborncore.common.crafting.RecipeType; import techreborn.tiles.machine.multiblock.TileIndustrialBlastFurnace; @@ -36,14 +36,14 @@ public class BlastFurnaceRecipe extends Recipe { int heat; - public BlastFurnaceRecipe(RecipeType type, ResourceLocation name) { + public BlastFurnaceRecipe(RecipeType type, Identifier name) { super(type, name); } @Override public void deserialize(JsonObject jsonObject) { super.deserialize(jsonObject); - heat = JsonUtils.getInt(jsonObject, "heat"); + heat = JsonHelper.getInt(jsonObject, "heat"); } @Override @@ -53,7 +53,7 @@ public class BlastFurnaceRecipe extends Recipe { } @Override - public boolean canCraft(final TileEntity tile) { + public boolean canCraft(final BlockEntity tile) { if (tile instanceof TileIndustrialBlastFurnace) { final TileIndustrialBlastFurnace blastFurnace = (TileIndustrialBlastFurnace) tile; return blastFurnace.getHeat() >= heat; @@ -62,7 +62,7 @@ public class BlastFurnaceRecipe extends Recipe { } @Override - public boolean onCraft(final TileEntity tile) { + public boolean onCraft(final BlockEntity tile) { return true; } } diff --git a/src/main/java/techreborn/api/recipe/recipes/IndustrialGrinderRecipe.java b/src/main/java/techreborn/api/recipe/recipes/IndustrialGrinderRecipe.java index e64253794..1ca590648 100644 --- a/src/main/java/techreborn/api/recipe/recipes/IndustrialGrinderRecipe.java +++ b/src/main/java/techreborn/api/recipe/recipes/IndustrialGrinderRecipe.java @@ -24,9 +24,9 @@ package techreborn.api.recipe.recipes; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.FluidStack; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.util.Identifier; + import reborncore.common.crafting.Recipe; import reborncore.common.crafting.RecipeType; import techreborn.tiles.machine.multiblock.TileIndustrialGrinder; @@ -36,12 +36,12 @@ public class IndustrialGrinderRecipe extends Recipe { //TODO 1.14 fluids FluidStack fluidStack = null; - public IndustrialGrinderRecipe(RecipeType type, ResourceLocation name) { + public IndustrialGrinderRecipe(RecipeType type, Identifier name) { super(type, name); } @Override - public boolean canCraft(final TileEntity tileEntity) { + public boolean canCraft(final BlockEntity tileEntity) { TileIndustrialGrinder tile = (TileIndustrialGrinder) tileEntity; if (!tile.getMultiBlock()) { return false; @@ -63,7 +63,7 @@ public class IndustrialGrinderRecipe extends Recipe { } @Override - public boolean onCraft(final TileEntity tileEntity) { + public boolean onCraft(final BlockEntity tileEntity) { TileIndustrialGrinder tile = (TileIndustrialGrinder) tileEntity; final FluidStack recipeFluid = fluidStack; final FluidStack tankFluid = tile.tank.getFluid(); diff --git a/src/main/java/techreborn/api/recipe/recipes/IndustrialSawmillRecipe.java b/src/main/java/techreborn/api/recipe/recipes/IndustrialSawmillRecipe.java index d9167d333..d1f19cac9 100644 --- a/src/main/java/techreborn/api/recipe/recipes/IndustrialSawmillRecipe.java +++ b/src/main/java/techreborn/api/recipe/recipes/IndustrialSawmillRecipe.java @@ -24,9 +24,9 @@ package techreborn.api.recipe.recipes; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.FluidStack; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.util.Identifier; + import reborncore.common.crafting.Recipe; import reborncore.common.crafting.RecipeType; import techreborn.tiles.machine.multiblock.TileIndustrialSawmill; @@ -36,12 +36,12 @@ public class IndustrialSawmillRecipe extends Recipe { //TODO 1.14 fluids FluidStack fluidStack = null; - public IndustrialSawmillRecipe(RecipeType type, ResourceLocation name) { + public IndustrialSawmillRecipe(RecipeType type, Identifier name) { super(type, name); } @Override - public boolean canCraft(TileEntity tileEntity) { + public boolean canCraft(BlockEntity tileEntity) { TileIndustrialSawmill tile = (TileIndustrialSawmill) tileEntity; if (!tile.getMutliBlock()) { return false; @@ -63,7 +63,7 @@ public class IndustrialSawmillRecipe extends Recipe { } @Override - public boolean onCraft(TileEntity tileEntity) { + public boolean onCraft(BlockEntity tileEntity) { TileIndustrialSawmill tile = (TileIndustrialSawmill) tileEntity; final FluidStack recipeFluid = fluidStack; final FluidStack tankFluid = tile.tank.getFluid(); diff --git a/src/main/java/techreborn/blocks/BlockAlarm.java b/src/main/java/techreborn/blocks/BlockAlarm.java index dd508f244..5afc4c904 100644 --- a/src/main/java/techreborn/blocks/BlockAlarm.java +++ b/src/main/java/techreborn/blocks/BlockAlarm.java @@ -24,27 +24,27 @@ package techreborn.blocks; +import net.minecraft.ChatFormat; import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.BlockItemUseContext; +import net.minecraft.block.BlockRenderType; +import net.minecraft.block.BlockState; +import net.minecraft.block.Material; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.client.item.TooltipContext; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemStack; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.DirectionProperty; -import net.minecraft.state.StateContainer; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumBlockRenderType; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.state.StateFactory; +import net.minecraft.state.property.BooleanProperty; +import net.minecraft.state.property.DirectionProperty; +import net.minecraft.state.property.Properties; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentTranslation; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.IBlockReader; +import net.minecraft.util.math.Direction; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.world.BlockView; import net.minecraft.world.World; import reborncore.api.ToolManager; import reborncore.client.models.ModelCompound; @@ -59,13 +59,13 @@ import javax.annotation.Nullable; import java.util.List; public class BlockAlarm extends BaseTileBlock { - public static DirectionProperty FACING = BlockStateProperties.FACING; + public static DirectionProperty FACING = Properties.FACING; public static BooleanProperty ACTIVE; protected final VoxelShape[] shape; public BlockAlarm() { - super(Block.Properties.create(Material.ROCK)); - this.setDefaultState(this.stateContainer.getBaseState().with(FACING, EnumFacing.NORTH).with(ACTIVE, false)); + super(Block.Settings.of(Material.STONE)); + this.setDefaultState(this.stateFactory.getDefaultState().with(FACING, Direction.NORTH).with(ACTIVE, false)); this.shape = GenCuboidShapes(3, 10); RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, "machines/lighting")); BlockWrenchEventHandler.wrenableBlocks.add(this); @@ -74,54 +74,54 @@ public class BlockAlarm extends BaseTileBlock { private VoxelShape[] GenCuboidShapes(double depth, double width) { double culling = (16.0D - width) / 2 ; VoxelShape[] shapes = { - Block.makeCuboidShape(culling, 16.0 - depth, culling, 16.0 - culling, 16.0D, 16.0 - culling), - Block.makeCuboidShape(culling, 0.0D, culling, 16.0D - culling, depth, 16.0 - culling), - Block.makeCuboidShape(culling, culling, 16.0 - depth, 16.0 - culling, 16.0 - culling, 16.0D), - Block.makeCuboidShape(culling, culling, 0.0D, 16.0 - culling, 16.0 - culling, depth), - Block.makeCuboidShape(16.0 - depth, culling, culling, 16.0D, 16.0 - culling, 16.0 - culling), - Block.makeCuboidShape(0.0D, culling, culling, depth, 16.0 - culling, 16.0 - culling) + Block.createCuboidShape(culling, 16.0 - depth, culling, 16.0 - culling, 16.0D, 16.0 - culling), + Block.createCuboidShape(culling, 0.0D, culling, 16.0D - culling, depth, 16.0 - culling), + Block.createCuboidShape(culling, culling, 16.0 - depth, 16.0 - culling, 16.0 - culling, 16.0D), + Block.createCuboidShape(culling, culling, 0.0D, 16.0 - culling, 16.0 - culling, depth), + Block.createCuboidShape(16.0 - depth, culling, culling, 16.0D, 16.0 - culling, 16.0 - culling), + Block.createCuboidShape(0.0D, culling, culling, depth, 16.0 - culling, 16.0 - culling) }; return shapes; } - public static boolean isActive(IBlockState state) { + public static boolean isActive(BlockState state) { return state.get(ACTIVE); } - public static EnumFacing getFacing(IBlockState state) { - return (EnumFacing) state.get(FACING); + public static Direction getFacing(BlockState state) { + return (Direction) state.get(FACING); } - public static void setFacing(EnumFacing facing, World world, BlockPos pos) { + public static void setFacing(Direction facing, World world, BlockPos pos) { world.setBlockState(pos, world.getBlockState(pos).with(FACING, facing)); } public static void setActive(boolean active, World world, BlockPos pos) { - EnumFacing facing = world.getBlockState(pos).get(FACING); - IBlockState state = world.getBlockState(pos).with(ACTIVE, active).with(FACING, facing); + Direction facing = world.getBlockState(pos).get(FACING); + BlockState state = world.getBlockState(pos).with(ACTIVE, active).with(FACING, facing); world.setBlockState(pos, state, 3); } // BaseTileBlock @Nullable @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileAlarm(); } // Block @Override - protected void fillStateContainer(StateContainer.Builder builder) { + protected void appendProperties(StateFactory.Builder builder) { ACTIVE = BooleanProperty.create("active"); builder.add(FACING, ACTIVE); } @Nullable @Override - public IBlockState getStateForPlacement(BlockItemUseContext context) { - for (EnumFacing enumfacing : context.getNearestLookingDirections()) { - IBlockState iblockstate = this.getDefaultState().with(FACING, enumfacing.getOpposite()); - if (iblockstate.isValidPosition(context.getWorld(), context.getPos())) { + public BlockState getPlacementState(ItemPlacementContext context) { + for (Direction enumfacing : context.getPlacementFacings()) { + BlockState iblockstate = this.getDefaultState().with(FACING, enumfacing.getOpposite()); + if (iblockstate.canPlaceAt(context.getWorld(), context.getBlockPos())) { return iblockstate; } } @@ -130,9 +130,9 @@ public class BlockAlarm extends BaseTileBlock { @SuppressWarnings("deprecation") @Override - public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { - ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND); - TileEntity tileEntity = worldIn.getTileEntity(pos); + public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) { + ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND); + BlockEntity tileEntity = worldIn.getBlockEntity(pos); // We extended BaseTileBlock. Thus we should always have tile entity. I hope. if (tileEntity == null) { @@ -145,7 +145,7 @@ public class BlockAlarm extends BaseTileBlock { } } - if (!worldIn.isRemote && playerIn.isSneaking()) { + if (!worldIn.isClient && playerIn.isSneaking()) { ((TileAlarm) tileEntity).rightClick(); return true; @@ -155,22 +155,22 @@ public class BlockAlarm extends BaseTileBlock { } @Override - public EnumBlockRenderType getRenderType(IBlockState state) { - return EnumBlockRenderType.MODEL; + public BlockRenderType getRenderType(BlockState state) { + return BlockRenderType.MODEL; } @Override - public boolean isFullCube(IBlockState state) { + public boolean isFullCube(BlockState state) { return false; } @Override - public void addInformation(ItemStack stack, @Nullable IBlockReader worldIn, List tooltip, ITooltipFlag flagIn) { - tooltip.add(new TextComponentTranslation("techreborn.tooltip.alarm").applyTextStyle(TextFormatting.GRAY)); + public void buildTooltip(ItemStack stack, @Nullable BlockView worldIn, List tooltip, TooltipContext flagIn) { + tooltip.add(new TranslatableComponent("techreborn.tooltip.alarm").applyFormat(ChatFormat.GRAY)); } @Override - public VoxelShape getShape(IBlockState state, IBlockReader worldIn, BlockPos pos) { - return shape[getFacing(state).getIndex()]; + public VoxelShape getShape(BlockState state, BlockView worldIn, BlockPos pos) { + return shape[getFacing(state).getId()]; } } diff --git a/src/main/java/techreborn/blocks/BlockComputerCube.java b/src/main/java/techreborn/blocks/BlockComputerCube.java index 56a31bae3..d84cf8b65 100644 --- a/src/main/java/techreborn/blocks/BlockComputerCube.java +++ b/src/main/java/techreborn/blocks/BlockComputerCube.java @@ -24,15 +24,15 @@ package techreborn.blocks; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.Rotation; -import net.minecraft.util.SoundCategory; +import net.minecraft.sound.SoundCategory; +import net.minecraft.util.BlockRotation; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import net.minecraft.world.World; import reborncore.api.ToolManager; import reborncore.api.tile.IMachineGuiHandler; @@ -56,23 +56,23 @@ public class BlockComputerCube extends BlockMachineBase { } @Override - public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) { - ItemStack tool = playerIn.getHeldItem(EnumHand.MAIN_HAND); + ItemStack tool = playerIn.getStackInHand(Hand.MAIN_HAND); if (!tool.isEmpty() && ToolManager.INSTANCE.canHandleTool(tool)) { if (ToolManager.INSTANCE.handleTool(tool, pos, worldIn, playerIn, side, false)) { if (playerIn.isSneaking()) { ItemStack drop = new ItemStack(TRContent.COMPUTER_CUBE, 1); - spawnAsEntity(worldIn, pos, drop); - worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, ModSounds.BLOCK_DISMANTLE, + dropStack(worldIn, pos, drop); + worldIn.playSound(null, playerIn.x, playerIn.y, playerIn.z, ModSounds.BLOCK_DISMANTLE, SoundCategory.BLOCKS, 0.6F, 1F); - if (!worldIn.isRemote) { + if (!worldIn.isClient) { worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 2); } return true; } else { - rotate(worldIn.getBlockState(pos), worldIn, pos, Rotation.CLOCKWISE_90); + rotate(worldIn.getBlockState(pos), worldIn, pos, BlockRotation.CLOCKWISE_90); return true; } } diff --git a/src/main/java/techreborn/blocks/BlockMachineCasing.java b/src/main/java/techreborn/blocks/BlockMachineCasing.java index 53c89861c..3eb424323 100644 --- a/src/main/java/techreborn/blocks/BlockMachineCasing.java +++ b/src/main/java/techreborn/blocks/BlockMachineCasing.java @@ -25,11 +25,11 @@ package techreborn.blocks; import net.minecraft.block.Block; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.BlockState; +import net.minecraft.block.Material; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.world.BlockView; import reborncore.common.multiblock.BlockMultiblockBase; import techreborn.tiles.TileMachineCasing; @@ -38,11 +38,11 @@ public class BlockMachineCasing extends BlockMultiblockBase { public final int heatCapacity; public BlockMachineCasing(int heatCapacity) { - super(Block.Properties.create(Material.IRON).hardnessAndResistance(2f).sound(SoundType.METAL)); + super(Block.Settings.of(Material.METAL).strength(2f).sounds(BlockSoundGroup.METAL)); this.heatCapacity = heatCapacity; } - public static int getHeatFromState(IBlockState state) { + public static int getHeatFromState(BlockState state) { Block block = state.getBlock(); if (!(block instanceof BlockMachineCasing)) { return 0; @@ -52,7 +52,7 @@ public class BlockMachineCasing extends BlockMultiblockBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileMachineCasing(); } diff --git a/src/main/java/techreborn/blocks/BlockMachineFrame.java b/src/main/java/techreborn/blocks/BlockMachineFrame.java index caa15dd3c..584f757ae 100644 --- a/src/main/java/techreborn/blocks/BlockMachineFrame.java +++ b/src/main/java/techreborn/blocks/BlockMachineFrame.java @@ -25,13 +25,13 @@ package techreborn.blocks; import net.minecraft.block.Block; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; +import net.minecraft.block.Material; +import net.minecraft.sound.BlockSoundGroup; import reborncore.common.BaseBlock; public class BlockMachineFrame extends BaseBlock { public BlockMachineFrame() { - super(Block.Properties.create(Material.IRON).hardnessAndResistance(1f).sound(SoundType.METAL)); + super(Block.Settings.of(Material.METAL).strength(1f).sounds(BlockSoundGroup.METAL)); } } diff --git a/src/main/java/techreborn/blocks/BlockNuke.java b/src/main/java/techreborn/blocks/BlockNuke.java index 88f3de785..661b207f6 100644 --- a/src/main/java/techreborn/blocks/BlockNuke.java +++ b/src/main/java/techreborn/blocks/BlockNuke.java @@ -25,19 +25,19 @@ package techreborn.blocks; import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; +import net.minecraft.block.Material; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.projectile.EntityArrow; -import net.minecraft.init.SoundEvents; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer; -import net.minecraft.util.SoundCategory; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.projectile.ProjectileEntity; +import net.minecraft.sound.SoundCategory; +import net.minecraft.sound.SoundEvents; +import net.minecraft.state.StateFactory; +import net.minecraft.state.property.BooleanProperty; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.Explosion; import net.minecraft.world.World; +import net.minecraft.world.explosion.Explosion; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; import reborncore.common.BaseBlock; @@ -51,40 +51,40 @@ public class BlockNuke extends BaseBlock { public static BooleanProperty OVERLAY = BooleanProperty.create("overlay"); public BlockNuke() { - super(Block.Properties.create(Material.TNT)); - this.setDefaultState(this.stateContainer.getBaseState().with(OVERLAY, false)); + super(Block.Settings.of(Material.TNT)); + this.setDefaultState(this.stateFactory.getDefaultState().with(OVERLAY, false)); RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this)); } - public void ignite(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase igniter) { - if (!worldIn.isRemote) { + public void ignite(World worldIn, BlockPos pos, BlockState state, LivingEntity igniter) { + if (!worldIn.isClient) { EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (double) ((float) pos.getX() + 0.5F), (double) pos.getY(), (double) ((float) pos.getZ() + 0.5F), igniter); worldIn.spawnEntity(entitynukeprimed); - worldIn.playSound((EntityPlayer) null, entitynukeprimed.posX, entitynukeprimed.posY, entitynukeprimed.posZ, + worldIn.playSound((PlayerEntity) null, entitynukeprimed.x, entitynukeprimed.y, entitynukeprimed.z, SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F); } } @Override - public void onExplosionDestroy(World worldIn, BlockPos pos, Explosion explosionIn) { - if (!worldIn.isRemote) { + public void onDestroyedByExplosion(World worldIn, BlockPos pos, Explosion explosionIn) { + if (!worldIn.isClient) { EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (double) ((float) pos.getX() + 0.5F), - (double) pos.getY(), (double) ((float) pos.getZ() + 0.5F), explosionIn.getExplosivePlacedBy()); - entitynukeprimed.setFuse(worldIn.rand.nextInt(EntityNukePrimed.fuseTime / 4) + EntityNukePrimed.fuseTime / 8); + (double) pos.getY(), (double) ((float) pos.getZ() + 0.5F), explosionIn.getCausingEntity()); + entitynukeprimed.setFuse(worldIn.random.nextInt(EntityNukePrimed.fuseTime / 4) + EntityNukePrimed.fuseTime / 8); worldIn.spawnEntity(entitynukeprimed); } } @Override - public void onEntityCollision(IBlockState state, World worldIn, BlockPos pos, Entity entityIn) { - if (!worldIn.isRemote && entityIn instanceof EntityArrow) { - EntityArrow entityarrow = (EntityArrow) entityIn; - EntityLivingBase shooter = null; - if (entityarrow.getShooter() instanceof EntityLivingBase) { - shooter = (EntityLivingBase) entityarrow.getShooter(); + public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { + if (!worldIn.isClient && entityIn instanceof ProjectileEntity) { + ProjectileEntity entityarrow = (ProjectileEntity) entityIn; + LivingEntity shooter = null; + if (entityarrow.getOwner() instanceof LivingEntity) { + shooter = (LivingEntity) entityarrow.getOwner(); } - if (entityarrow.isBurning()) { + if (entityarrow.isOnFire()) { ignite(worldIn, pos, state, shooter); worldIn.removeBlock(pos); } @@ -93,24 +93,24 @@ public class BlockNuke extends BaseBlock { @SuppressWarnings("deprecation") @Override - public void onBlockAdded(IBlockState state, World worldIn, BlockPos pos, IBlockState oldState) { + public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState) { super.onBlockAdded(state, worldIn, pos, oldState); - if (worldIn.isBlockPowered(pos)) { + if (worldIn.isReceivingRedstonePower(pos)) { ignite(worldIn, pos, state, null); worldIn.removeBlock(pos); } } @Override - public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos p_189540_5_) { - if (worldIn.isBlockPowered(pos)) { + public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos p_189540_5_) { + if (worldIn.isReceivingRedstonePower(pos)) { ignite(worldIn, pos, state, null); worldIn.removeBlock(pos); } } @Override - protected void fillStateContainer(StateContainer.Builder builder) { + protected void appendProperties(StateFactory.Builder builder) { builder.add(OVERLAY); } } diff --git a/src/main/java/techreborn/blocks/BlockOre.java b/src/main/java/techreborn/blocks/BlockOre.java index 8a4653390..3af78d3ee 100644 --- a/src/main/java/techreborn/blocks/BlockOre.java +++ b/src/main/java/techreborn/blocks/BlockOre.java @@ -25,10 +25,10 @@ package techreborn.blocks; import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; +import net.minecraft.block.Material; import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; +import net.minecraft.util.DefaultedList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import reborncore.common.registration.RebornRegister; @@ -68,11 +68,11 @@ public class BlockOre extends Block { public static int sphaleriteMaxQuantity = 2; public BlockOre() { - super(Block.Properties.create(Material.ROCK).hardnessAndResistance(2f)); + super(Block.Settings.of(Material.STONE).strength(2f)); } @Override - public void getDrops(IBlockState state, NonNullList drops, World world, BlockPos pos, int fortune) { + public void getDrops(BlockState state, DefaultedList drops, World world, BlockPos pos, int fortune) { Block ore = state.getBlock(); Random random = new Random(); diff --git a/src/main/java/techreborn/blocks/BlockRefinedIronFence.java b/src/main/java/techreborn/blocks/BlockRefinedIronFence.java index f6fe9ef46..e9ca074f7 100644 --- a/src/main/java/techreborn/blocks/BlockRefinedIronFence.java +++ b/src/main/java/techreborn/blocks/BlockRefinedIronFence.java @@ -25,14 +25,14 @@ package techreborn.blocks; import net.minecraft.block.Block; -import net.minecraft.block.BlockFence; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.material.MaterialColor; +import net.minecraft.block.FenceBlock; +import net.minecraft.block.Material; +import net.minecraft.block.MaterialColor; +import net.minecraft.sound.BlockSoundGroup; -public class BlockRefinedIronFence extends BlockFence { +public class BlockRefinedIronFence extends FenceBlock { public BlockRefinedIronFence() { - super(Block.Properties.create(Material.IRON, MaterialColor.WOOD).hardnessAndResistance(2.0F, 3.0F).sound(SoundType.METAL)); + super(Block.Settings.of(Material.METAL, MaterialColor.WOOD).strength(2.0F, 3.0F).sounds(BlockSoundGroup.METAL)); } } diff --git a/src/main/java/techreborn/blocks/BlockReinforcedGlass.java b/src/main/java/techreborn/blocks/BlockReinforcedGlass.java index c278a05e8..415ffb87e 100644 --- a/src/main/java/techreborn/blocks/BlockReinforcedGlass.java +++ b/src/main/java/techreborn/blocks/BlockReinforcedGlass.java @@ -25,25 +25,25 @@ package techreborn.blocks; import net.minecraft.block.Block; -import net.minecraft.block.BlockGlass; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; +import net.minecraft.block.GlassBlock; +import net.minecraft.block.Material; +import net.minecraft.sound.BlockSoundGroup; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; import techreborn.TechReborn; import java.util.Random; -public class BlockReinforcedGlass extends BlockGlass { +public class BlockReinforcedGlass extends GlassBlock { public BlockReinforcedGlass() { - super(Block.Properties.create(Material.GLASS).hardnessAndResistance(4f, 60f).sound(SoundType.STONE)); + super(Block.Settings.of(Material.GLASS).strength(4f, 60f).sounds(BlockSoundGroup.STONE)); RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this)); } @Override - public int quantityDropped(IBlockState state, Random random) { + public int quantityDropped(BlockState state, Random random) { return 1; } } diff --git a/src/main/java/techreborn/blocks/BlockRubberLeaves.java b/src/main/java/techreborn/blocks/BlockRubberLeaves.java index 956f36194..39fc3ef63 100644 --- a/src/main/java/techreborn/blocks/BlockRubberLeaves.java +++ b/src/main/java/techreborn/blocks/BlockRubberLeaves.java @@ -25,13 +25,13 @@ package techreborn.blocks; import net.minecraft.block.Block; -import net.minecraft.block.BlockFire; -import net.minecraft.block.BlockLeaves; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.util.IItemProvider; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.FireBlock; +import net.minecraft.block.LeavesBlock; +import net.minecraft.block.Material; +import net.minecraft.item.ItemConvertible; +import net.minecraft.sound.BlockSoundGroup; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import reborncore.client.models.ModelCompound; @@ -39,16 +39,16 @@ import reborncore.client.models.RebornModelRegistry; import techreborn.TechReborn; import techreborn.init.TRContent; -public class BlockRubberLeaves extends BlockLeaves { +public class BlockRubberLeaves extends LeavesBlock { public BlockRubberLeaves() { - super(Block.Properties.create(Material.LEAVES).hardnessAndResistance(0.2F).tickRandomly().sound(SoundType.PLANT)); - ((BlockFire) Blocks.FIRE).setFireInfo(this, 30, 60); - RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, DISTANCE, PERSISTENT)); + super(Block.Settings.of(Material.LEAVES).strength(0.2F).ticksRandomly().sounds(BlockSoundGroup.GRASS)); + ((FireBlock) Blocks.FIRE).registerFlammableBlock(this, 30, 60); + RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, EnvTypeANCE, PERSISTENT)); } @Override - public IItemProvider getItemDropped(IBlockState state, World worldIn, BlockPos pos, int fortune) { + public ItemConvertible getItemDropped(BlockState state, World worldIn, BlockPos pos, int fortune) { return TRContent.RUBBER_SAPLING; } } diff --git a/src/main/java/techreborn/blocks/BlockRubberLog.java b/src/main/java/techreborn/blocks/BlockRubberLog.java index 334c62433..78f246c92 100644 --- a/src/main/java/techreborn/blocks/BlockRubberLog.java +++ b/src/main/java/techreborn/blocks/BlockRubberLog.java @@ -25,27 +25,27 @@ package techreborn.blocks; import net.minecraft.block.Block; -import net.minecraft.block.BlockFire; -import net.minecraft.block.BlockLog; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.material.MaterialColor; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Blocks; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.FireBlock; +import net.minecraft.block.LogBlock; +import net.minecraft.block.Material; +import net.minecraft.block.MaterialColor; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.DirectionProperty; -import net.minecraft.state.StateContainer; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tags.BlockTags; -import net.minecraft.tags.Tag; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.NonNullList; -import net.minecraft.util.SoundCategory; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.sound.SoundCategory; +import net.minecraft.state.StateFactory; +import net.minecraft.state.property.BooleanProperty; +import net.minecraft.state.property.DirectionProperty; +import net.minecraft.state.property.Properties; +import net.minecraft.tag.BlockTags; +import net.minecraft.tag.Tag; +import net.minecraft.util.DefaultedList; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import net.minecraft.world.World; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -64,39 +64,39 @@ import java.util.Random; /** * Created by modmuss50 on 19/02/2016. */ -public class BlockRubberLog extends BlockLog { +public class BlockRubberLog extends LogBlock { - public static DirectionProperty SAP_SIDE = BlockStateProperties.HORIZONTAL_FACING; + public static DirectionProperty SAP_SIDE = Properties.FACING_HORIZONTAL; public static BooleanProperty HAS_SAP = BooleanProperty.create("hassap"); public BlockRubberLog() { - super(MaterialColor.OBSIDIAN, Block.Properties.create(Material.WOOD, MaterialColor.BROWN).hardnessAndResistance(2.0F).sound(SoundType.WOOD).tickRandomly()); - this.setDefaultState(this.getDefaultState().with(SAP_SIDE, EnumFacing.NORTH).with(HAS_SAP, false).with(AXIS, EnumFacing.Axis.Y)); - ((BlockFire) Blocks.FIRE).setFireInfo(this, 5, 5); + super(MaterialColor.SPRUCE, Block.Settings.of(Material.WOOD, MaterialColor.BROWN).strength(2.0F).sounds(BlockSoundGroup.WOOD).ticksRandomly()); + this.setDefaultState(this.getDefaultState().with(SAP_SIDE, Direction.NORTH).with(HAS_SAP, false).with(AXIS, Direction.Axis.Y)); + ((FireBlock) Blocks.FIRE).registerFlammableBlock(this, 5, 5); RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this)); } @Override - protected void fillStateContainer(StateContainer.Builder builder) { - super.fillStateContainer(builder); + protected void appendProperties(StateFactory.Builder builder) { + super.appendProperties(builder); builder.add(SAP_SIDE, HAS_SAP); } @Override - public boolean isIn(Tag tagIn) { + public boolean matches(Tag tagIn) { return tagIn == BlockTags.LOGS; } @Override - public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player) { + public void onBreak(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) { int i = 4; int j = i + 1; if (worldIn.isAreaLoaded(pos.add(-j, -j, -j), pos.add(j, j, j))) { for (BlockPos blockpos : BlockPos.getAllInBox(pos.add(-i, -i, -i), pos.add(i, i, i))) { - IBlockState state1 = worldIn.getBlockState(blockpos); - if (state1.isIn(BlockTags.LEAVES)) { - state1.tick(worldIn, blockpos, worldIn.getRandom()); - state1.randomTick(worldIn, blockpos, worldIn.getRandom()); + BlockState state1 = worldIn.getBlockState(blockpos); + if (state1.matches(BlockTags.LEAVES)) { + state1.scheduledTick(worldIn, blockpos, worldIn.getRandom()); + state1.onRandomTick(worldIn, blockpos, worldIn.getRandom()); } } } @@ -104,16 +104,16 @@ public class BlockRubberLog extends BlockLog { @SuppressWarnings("deprecation") @Override - public void tick(IBlockState state, World worldIn, BlockPos pos, Random random) { - super.tick(state, worldIn, pos, random); - if (state.get(AXIS) != EnumFacing.Axis.Y) { + public void onScheduledTick(BlockState state, World worldIn, BlockPos pos, Random random) { + super.onScheduledTick(state, worldIn, pos, random); + if (state.get(AXIS) != Direction.Axis.Y) { return; } if (state.get(HAS_SAP)) { return; } if (random.nextInt(50) == 0) { - EnumFacing facing = EnumFacing.byHorizontalIndex(random.nextInt(4)); + Direction facing = Direction.fromHorizontal(random.nextInt(4)); if (worldIn.getBlockState(pos.down()).getBlock() == this && worldIn.getBlockState(pos.up()).getBlock() == this) { worldIn.setBlockState(pos, state.with(HAS_SAP, true).with(SAP_SIDE, facing)); @@ -123,10 +123,10 @@ public class BlockRubberLog extends BlockLog { @SuppressWarnings("deprecation") @Override - public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn, - EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, + Hand hand, Direction side, float hitX, float hitY, float hitZ) { super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ); - ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND); + ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND); if (stack.isEmpty()) { return false; } @@ -136,22 +136,22 @@ public class BlockRubberLog extends BlockLog { } if ((capEnergy != null && capEnergy.getEnergyStored() > 20) || stack.getItem() instanceof ItemTreeTap) { if (state.get(HAS_SAP) && state.get(SAP_SIDE) == side) { - worldIn.setBlockState(pos, state.with(HAS_SAP, false).with(SAP_SIDE, EnumFacing.byHorizontalIndex(0))); + worldIn.setBlockState(pos, state.with(HAS_SAP, false).with(SAP_SIDE, Direction.fromHorizontal(0))); worldIn.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.SAP_EXTRACT, SoundCategory.BLOCKS, 0.6F, 1F); - if (!worldIn.isRemote) { + if (!worldIn.isClient) { if (capEnergy != null) { capEnergy.extractEnergy(20, false); ExternalPowerSystems.requestEnergyFromArmor(capEnergy, playerIn); } else { - playerIn.getHeldItem(EnumHand.MAIN_HAND).damageItem(1, playerIn); + playerIn.getStackInHand(Hand.MAIN_HAND).damageItem(1, playerIn); } - if (!playerIn.inventory.addItemStackToInventory(TRContent.Parts.SAP.getStack())) { + if (!playerIn.inventory.insertStack(TRContent.Parts.SAP.getStack())) { WorldUtils.dropItem(TRContent.Parts.SAP.getStack(), worldIn, pos.offset(side)); } - if (playerIn instanceof EntityPlayerMP) { - TRRecipeHandler.unlockTRRecipes((EntityPlayerMP) playerIn); + if (playerIn instanceof ServerPlayerEntity) { + TRRecipeHandler.unlockTRRecipes((ServerPlayerEntity) playerIn); } } return true; @@ -161,7 +161,7 @@ public class BlockRubberLog extends BlockLog { } @Override - public void getDrops(IBlockState state, NonNullList drops, World world, BlockPos pos, int fortune) { + public void getDrops(BlockState state, DefaultedList drops, World world, BlockPos pos, int fortune) { drops.add(new ItemStack(this)); if (state.get(HAS_SAP)) { if (new Random().nextInt(4) == 0) { diff --git a/src/main/java/techreborn/blocks/BlockRubberPlank.java b/src/main/java/techreborn/blocks/BlockRubberPlank.java index 010812c8f..ff3c72d2b 100644 --- a/src/main/java/techreborn/blocks/BlockRubberPlank.java +++ b/src/main/java/techreborn/blocks/BlockRubberPlank.java @@ -25,10 +25,10 @@ package techreborn.blocks; import net.minecraft.block.Block; -import net.minecraft.block.BlockFire; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; +import net.minecraft.block.Blocks; +import net.minecraft.block.FireBlock; +import net.minecraft.block.Material; +import net.minecraft.sound.BlockSoundGroup; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; import techreborn.TechReborn; @@ -39,8 +39,8 @@ import techreborn.TechReborn; public class BlockRubberPlank extends Block { public BlockRubberPlank() { - super(Block.Properties.create(Material.WOOD).hardnessAndResistance(2f).sound(SoundType.WOOD)); - ((BlockFire) Blocks.FIRE).setFireInfo(this, 5, 20); + super(Block.Settings.of(Material.WOOD).strength(2f).sounds(BlockSoundGroup.WOOD)); + ((FireBlock) Blocks.FIRE).registerFlammableBlock(this, 5, 20); RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this)); } } diff --git a/src/main/java/techreborn/blocks/BlockRubberPlankSlab.java b/src/main/java/techreborn/blocks/BlockRubberPlankSlab.java index 8ecf9c2d4..4dffa67dc 100644 --- a/src/main/java/techreborn/blocks/BlockRubberPlankSlab.java +++ b/src/main/java/techreborn/blocks/BlockRubberPlankSlab.java @@ -25,18 +25,18 @@ package techreborn.blocks; import net.minecraft.block.Block; -import net.minecraft.block.BlockSlab; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.material.MaterialColor; +import net.minecraft.block.Material; +import net.minecraft.block.MaterialColor; +import net.minecraft.block.SlabBlock; +import net.minecraft.sound.BlockSoundGroup; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; import techreborn.TechReborn; -public class BlockRubberPlankSlab extends BlockSlab { +public class BlockRubberPlankSlab extends SlabBlock { public BlockRubberPlankSlab() { - super(Block.Properties.create(Material.WOOD, MaterialColor.OBSIDIAN).hardnessAndResistance(2.0F, 15.0F).sound(SoundType.WOOD)); + super(Block.Settings.of(Material.WOOD, MaterialColor.SPRUCE).strength(2.0F, 15.0F).sounds(BlockSoundGroup.WOOD)); RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this)); } } diff --git a/src/main/java/techreborn/blocks/BlockRubberPlankStair.java b/src/main/java/techreborn/blocks/BlockRubberPlankStair.java index b1ae360e5..96225c4b8 100644 --- a/src/main/java/techreborn/blocks/BlockRubberPlankStair.java +++ b/src/main/java/techreborn/blocks/BlockRubberPlankStair.java @@ -25,16 +25,16 @@ package techreborn.blocks; import net.minecraft.block.Block; -import net.minecraft.block.BlockStairs; +import net.minecraft.block.StairsBlock; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; import techreborn.TechReborn; import techreborn.init.TRContent; -public class BlockRubberPlankStair extends BlockStairs { +public class BlockRubberPlankStair extends StairsBlock { public BlockRubberPlankStair() { - super(TRContent.RUBBER_PLANKS.getDefaultState(), Block.Properties.from(TRContent.RUBBER_PLANKS)); + super(TRContent.RUBBER_PLANKS.getDefaultState(), Block.Settings.copy(TRContent.RUBBER_PLANKS)); RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this)); } } \ No newline at end of file diff --git a/src/main/java/techreborn/blocks/BlockRubberSapling.java b/src/main/java/techreborn/blocks/BlockRubberSapling.java index dba748205..47828d326 100644 --- a/src/main/java/techreborn/blocks/BlockRubberSapling.java +++ b/src/main/java/techreborn/blocks/BlockRubberSapling.java @@ -25,16 +25,16 @@ package techreborn.blocks; import net.minecraft.block.Block; -import net.minecraft.block.BlockSapling; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; +import net.minecraft.block.Material; +import net.minecraft.block.SaplingBlock; +import net.minecraft.sound.BlockSoundGroup; /** * Created by modmuss50 on 20/02/2016. */ -public class BlockRubberSapling extends BlockSapling { +public class BlockRubberSapling extends SaplingBlock { public BlockRubberSapling() { - super(new RubberTree(), Block.Properties.create(Material.PLANTS).sound(SoundType.PLANT)); + super(new RubberTree(), Block.Settings.of(Material.PLANT).sounds(BlockSoundGroup.GRASS)); } } diff --git a/src/main/java/techreborn/blocks/BlockStorage.java b/src/main/java/techreborn/blocks/BlockStorage.java index 1003c1073..f0c1edbe1 100644 --- a/src/main/java/techreborn/blocks/BlockStorage.java +++ b/src/main/java/techreborn/blocks/BlockStorage.java @@ -25,14 +25,14 @@ package techreborn.blocks; import net.minecraft.block.Block; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; +import net.minecraft.block.Material; +import net.minecraft.sound.BlockSoundGroup; import reborncore.common.BaseBlock; public class BlockStorage extends BaseBlock { public BlockStorage() { - super(Block.Properties.create(Material.IRON).hardnessAndResistance(2f).sound(SoundType.METAL)); + super(Block.Settings.of(Material.METAL).strength(2f).sounds(BlockSoundGroup.METAL)); } // public static ItemStack getStorageBlockByName(String name, int count) { diff --git a/src/main/java/techreborn/blocks/BlockSupercondensator.java b/src/main/java/techreborn/blocks/BlockSupercondensator.java index e7d28e267..f77092756 100644 --- a/src/main/java/techreborn/blocks/BlockSupercondensator.java +++ b/src/main/java/techreborn/blocks/BlockSupercondensator.java @@ -24,13 +24,13 @@ package techreborn.blocks; -import net.minecraft.block.material.Material; -import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.ChatFormat; +import net.minecraft.block.Material; +import net.minecraft.client.item.TooltipContext; import net.minecraft.item.ItemStack; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.IBlockReader; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.common.blocks.BlockMachineBase; @@ -43,8 +43,8 @@ public class BlockSupercondensator extends BlockMachineBase { } @Override - public void addInformation(ItemStack stack, @Nullable IBlockReader worldIn, List tooltip, ITooltipFlag flagIn) { - tooltip.add(new TextComponentString("WIP Coming Soon").applyTextStyle(TextFormatting.RED)); + public void buildTooltip(ItemStack stack, @Nullable BlockView worldIn, List tooltip, TooltipContext flagIn) { + tooltip.add(new TextComponent("WIP Coming Soon").applyFormat(ChatFormat.RED)); // TODO // Remember to remove WIP override and imports once complete } diff --git a/src/main/java/techreborn/blocks/RubberTree.java b/src/main/java/techreborn/blocks/RubberTree.java index 4b5e7f7c2..8a6d6d415 100644 --- a/src/main/java/techreborn/blocks/RubberTree.java +++ b/src/main/java/techreborn/blocks/RubberTree.java @@ -25,20 +25,19 @@ package techreborn.blocks; import java.util.Random; - -import net.minecraft.block.trees.AbstractTree; +import net.minecraft.block.sapling.SaplingGenerator; import net.minecraft.world.gen.feature.AbstractTreeFeature; -import net.minecraft.world.gen.feature.NoFeatureConfig; +import net.minecraft.world.gen.feature.DefaultFeatureConfig; import techreborn.world.feature.RubberTreeFeature; /** * @author drcrazy * */ -public class RubberTree extends AbstractTree { +public class RubberTree extends SaplingGenerator { @Override - protected AbstractTreeFeature getTreeFeature(Random random) { + protected AbstractTreeFeature createTreeFeature(Random random) { return new RubberTreeFeature(); } } diff --git a/src/main/java/techreborn/blocks/cable/BlockCable.java b/src/main/java/techreborn/blocks/cable/BlockCable.java index edc36c32b..09060b981 100644 --- a/src/main/java/techreborn/blocks/cable/BlockCable.java +++ b/src/main/java/techreborn/blocks/cable/BlockCable.java @@ -25,20 +25,20 @@ package techreborn.blocks.cable; import net.minecraft.block.Block; -import net.minecraft.block.BlockContainer; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.block.BlockRenderType; +import net.minecraft.block.BlockState; +import net.minecraft.block.BlockWithEntity; +import net.minecraft.block.Material; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.state.AbstractProperty; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumBlockRenderType; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; +import net.minecraft.state.StateFactory; +import net.minecraft.state.property.AbstractProperty; +import net.minecraft.state.property.BooleanProperty; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; +import net.minecraft.util.math.Direction; +import net.minecraft.world.BlockView; import net.minecraft.world.IWorld; import net.minecraft.world.World; import reborncore.api.ToolManager; @@ -56,7 +56,7 @@ import javax.annotation.Nullable; * Created by modmuss50 on 19/05/2017. */ @RebornRegister(TechReborn.MOD_ID) -public class BlockCable extends BlockContainer { +public class BlockCable extends BlockWithEntity { public static final BooleanProperty EAST = BooleanProperty.create("east"); public static final BooleanProperty WEST = BooleanProperty.create("west"); @@ -77,22 +77,22 @@ public class BlockCable extends BlockContainer { public final TRContent.Cables type; public BlockCable(TRContent.Cables type) { - super(Block.Properties.create(Material.ROCK).hardnessAndResistance(1f, 8f)); + super(Block.Settings.of(Material.STONE).strength(1f, 8f)); this.type = type; - setDefaultState(this.stateContainer.getBaseState().with(EAST, false).with(WEST, false).with(NORTH, false).with(SOUTH, false).with(UP, false).with(DOWN, false)); + setDefaultState(this.stateFactory.getDefaultState().with(EAST, false).with(WEST, false).with(NORTH, false).with(SOUTH, false).with(UP, false).with(DOWN, false)); BlockWrenchEventHandler.wrenableBlocks.add(this); } //see for more info https://www.reddit.com/r/feedthebeast/comments/5mxwq9/psa_mod_devs_do_you_call_worldgettileentity_from/ - public TileEntity getTileEntitySafely(IWorld blockAccess, BlockPos pos) { + public BlockEntity getTileEntitySafely(IWorld blockAccess, BlockPos pos) { // if (blockAccess instanceof ChunkCache) { // return ((ChunkCache) blockAccess).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK); // } else { - return blockAccess.getTileEntity(pos); + return blockAccess.getBlockEntity(pos); // } } - public AbstractProperty getProperty(EnumFacing facing) { + public AbstractProperty getProperty(Direction facing) { switch (facing) { case EAST: return EAST; @@ -113,22 +113,22 @@ public class BlockCable extends BlockContainer { // BlockContainer @Override - public EnumBlockRenderType getRenderType(IBlockState state) { - return EnumBlockRenderType.MODEL; + public BlockRenderType getRenderType(BlockState state) { + return BlockRenderType.MODEL; } @Nullable @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileCable(); } // Block @SuppressWarnings("deprecation") @Override - public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { - ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND); - TileEntity tileEntity = worldIn.getTileEntity(pos); + public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) { + ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND); + BlockEntity tileEntity = worldIn.getBlockEntity(pos); // We should always have tile entity. I hope. if (tileEntity == null) { @@ -144,7 +144,7 @@ public class BlockCable extends BlockContainer { } @Override - protected void fillStateContainer(StateContainer.Builder builder) { + protected void appendProperties(StateFactory.Builder builder) { builder.add(EAST, WEST, NORTH, SOUTH, UP, DOWN); } diff --git a/src/main/java/techreborn/blocks/fluid/BlockFluidBase.java b/src/main/java/techreborn/blocks/fluid/BlockFluidBase.java index 58ce35668..80c3e163c 100644 --- a/src/main/java/techreborn/blocks/fluid/BlockFluidBase.java +++ b/src/main/java/techreborn/blocks/fluid/BlockFluidBase.java @@ -24,12 +24,12 @@ package techreborn.blocks.fluid; -import net.minecraft.block.BlockFlowingFluid; -import net.minecraft.fluid.FlowingFluid; +import net.minecraft.block.FluidBlock; +import net.minecraft.fluid.BaseFluid; -public class BlockFluidBase extends BlockFlowingFluid { +public class BlockFluidBase extends FluidBlock { - public BlockFluidBase(FlowingFluid fluid, Properties properties) { + public BlockFluidBase(BaseFluid fluid, Settings properties) { super(fluid, properties); } diff --git a/src/main/java/techreborn/blocks/fluid/BlockFluidTechReborn.java b/src/main/java/techreborn/blocks/fluid/BlockFluidTechReborn.java index 53c11dfc9..1d82a28ea 100644 --- a/src/main/java/techreborn/blocks/fluid/BlockFluidTechReborn.java +++ b/src/main/java/techreborn/blocks/fluid/BlockFluidTechReborn.java @@ -24,13 +24,13 @@ package techreborn.blocks.fluid; -import net.minecraft.fluid.FlowingFluid; +import net.minecraft.fluid.BaseFluid; public class BlockFluidTechReborn extends BlockFluidBase { String name; - public BlockFluidTechReborn(FlowingFluid fluid, Properties properties, String name) { + public BlockFluidTechReborn(BaseFluid fluid, Settings properties, String name) { super(fluid, properties); //setTranslationKey(name); this.name = name; diff --git a/src/main/java/techreborn/blocks/fluid/TechRebornFluid.java b/src/main/java/techreborn/blocks/fluid/TechRebornFluid.java index b52cbdade..c683c4cd4 100644 --- a/src/main/java/techreborn/blocks/fluid/TechRebornFluid.java +++ b/src/main/java/techreborn/blocks/fluid/TechRebornFluid.java @@ -24,14 +24,14 @@ package techreborn.blocks.fluid; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.Fluid; +import net.minecraft.util.Identifier; + public class TechRebornFluid extends Fluid { public TechRebornFluid(String fluidName) { super(fluidName, - new ResourceLocation("techreborn:blocks/fluids/" + fluidName.replaceFirst("fluid", "") + "_flowing"), - new ResourceLocation("techreborn:blocks/fluids/" + fluidName.replaceFirst("fluid", "") + "_flowing")); + new Identifier("techreborn:blocks/fluids/" + fluidName.replaceFirst("fluid", "") + "_flowing"), + new Identifier("techreborn:blocks/fluids/" + fluidName.replaceFirst("fluid", "") + "_flowing")); //FluidRegistry.addBucketForFluid(this); } } diff --git a/src/main/java/techreborn/blocks/generator/BlockDieselGenerator.java b/src/main/java/techreborn/blocks/generator/BlockDieselGenerator.java index 10ff01db5..65215cb6f 100644 --- a/src/main/java/techreborn/blocks/generator/BlockDieselGenerator.java +++ b/src/main/java/techreborn/blocks/generator/BlockDieselGenerator.java @@ -24,8 +24,8 @@ package techreborn.blocks.generator; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -45,7 +45,7 @@ public class BlockDieselGenerator extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileDieselGenerator(); } diff --git a/src/main/java/techreborn/blocks/generator/BlockDragonEggSyphon.java b/src/main/java/techreborn/blocks/generator/BlockDragonEggSyphon.java index 5c2bac460..9e7cbea7d 100644 --- a/src/main/java/techreborn/blocks/generator/BlockDragonEggSyphon.java +++ b/src/main/java/techreborn/blocks/generator/BlockDragonEggSyphon.java @@ -24,8 +24,8 @@ package techreborn.blocks.generator; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -41,7 +41,7 @@ public class BlockDragonEggSyphon extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileDragonEggSyphon(); } diff --git a/src/main/java/techreborn/blocks/generator/BlockFusionCoil.java b/src/main/java/techreborn/blocks/generator/BlockFusionCoil.java index 188968811..f530e2c94 100644 --- a/src/main/java/techreborn/blocks/generator/BlockFusionCoil.java +++ b/src/main/java/techreborn/blocks/generator/BlockFusionCoil.java @@ -25,23 +25,23 @@ package techreborn.blocks.generator; import net.minecraft.block.Block; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.Material; +import net.minecraft.client.item.TooltipContext; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.SoundCategory; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.sound.SoundCategory; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.world.IBlockReader; +import net.minecraft.util.math.Direction; +import net.minecraft.world.BlockView; import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import reborncore.api.ToolManager; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -54,23 +54,23 @@ import java.util.List; public class BlockFusionCoil extends Block { public BlockFusionCoil() { - super(Block.Properties.create(Material.IRON).hardnessAndResistance(2f).sound(SoundType.METAL)); + super(Block.Settings.of(Material.METAL).strength(2f).sounds(BlockSoundGroup.METAL)); RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, "machines/generators")); } @Override - public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn, - EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, + Hand hand, Direction side, float hitX, float hitY, float hitZ) { - ItemStack tool = playerIn.getHeldItem(EnumHand.MAIN_HAND); + ItemStack tool = playerIn.getStackInHand(Hand.MAIN_HAND); if (!tool.isEmpty() && ToolManager.INSTANCE.canHandleTool(tool)) { if (ToolManager.INSTANCE.handleTool(tool, pos, worldIn, playerIn, side, false)) { if (playerIn.isSneaking()) { ItemStack drop = new ItemStack(this); - spawnAsEntity(worldIn, pos, drop); - worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, ModSounds.BLOCK_DISMANTLE, + dropStack(worldIn, pos, drop); + worldIn.playSound(null, playerIn.x, playerIn.y, playerIn.z, ModSounds.BLOCK_DISMANTLE, SoundCategory.BLOCKS, 0.6F, 1F); - if (!worldIn.isRemote) { + if (!worldIn.isClient) { worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 2); } return true; @@ -80,12 +80,12 @@ public class BlockFusionCoil extends Block { return false; } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void addInformation(ItemStack stack, @Nullable IBlockReader worldIn, List tooltip, - ITooltipFlag flagIn) { - super.addInformation(stack, worldIn, tooltip, flagIn); + public void buildTooltip(ItemStack stack, @Nullable BlockView worldIn, List tooltip, + TooltipContext flagIn) { + super.buildTooltip(stack, worldIn, tooltip, flagIn); // TODO: Translate - tooltip.add(new TextComponentString("Right click Fusion Control computer to auto place")); + tooltip.add(new TextComponent("Right click Fusion Control computer to auto place")); } } \ No newline at end of file diff --git a/src/main/java/techreborn/blocks/generator/BlockFusionControlComputer.java b/src/main/java/techreborn/blocks/generator/BlockFusionControlComputer.java index f7aae88bc..a5cc40770 100644 --- a/src/main/java/techreborn/blocks/generator/BlockFusionControlComputer.java +++ b/src/main/java/techreborn/blocks/generator/BlockFusionControlComputer.java @@ -24,14 +24,14 @@ package techreborn.blocks.generator; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; +import net.minecraft.util.math.Direction; +import net.minecraft.world.BlockView; import net.minecraft.world.World; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; @@ -54,20 +54,20 @@ public class BlockFusionControlComputer extends BlockMachineBase { } @Override - public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn, - EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { - final TileFusionControlComputer tileFusionControlComputer = (TileFusionControlComputer) worldIn.getTileEntity(pos); - if(!playerIn.getHeldItem(hand).isEmpty() && (playerIn.getHeldItem(hand).getItem() == TRContent.Machine.FUSION_COIL.asItem())){ + public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, + Hand hand, Direction side, float hitX, float hitY, float hitZ) { + final TileFusionControlComputer tileFusionControlComputer = (TileFusionControlComputer) worldIn.getBlockEntity(pos); + if(!playerIn.getStackInHand(hand).isEmpty() && (playerIn.getStackInHand(hand).getItem() == TRContent.Machine.FUSION_COIL.asItem())){ List coils = Torus.generate(tileFusionControlComputer.getPos(), tileFusionControlComputer.size); boolean placed = false; for(BlockPos coil : coils){ - if(playerIn.getHeldItem(hand).isEmpty()){ + if(playerIn.getStackInHand(hand).isEmpty()){ return true; } - if(worldIn.isAirBlock(coil) && !tileFusionControlComputer.isCoil(coil)){ + if(worldIn.isAir(coil) && !tileFusionControlComputer.isCoil(coil)){ worldIn.setBlockState(coil, TRContent.Machine.FUSION_COIL.block.getDefaultState()); if(!playerIn.isCreative()){ - playerIn.getHeldItem(hand).shrink(1); + playerIn.getStackInHand(hand).subtractAmount(1); } placed = true; } @@ -87,18 +87,18 @@ public class BlockFusionControlComputer extends BlockMachineBase { } @Override - public void onEntityWalk(final World worldIn, final BlockPos pos, final Entity entityIn) { - super.onEntityWalk(worldIn, pos, entityIn); - if (worldIn.getTileEntity(pos) instanceof TileFusionControlComputer) { - if (((TileFusionControlComputer) worldIn.getTileEntity(pos)).crafingTickTime != 0 - && ((TileFusionControlComputer) worldIn.getTileEntity(pos)).checkCoils()) { - entityIn.attackEntityFrom(new FusionDamageSource(), 200F); + public void onSteppedOn(final World worldIn, final BlockPos pos, final Entity entityIn) { + super.onSteppedOn(worldIn, pos, entityIn); + if (worldIn.getBlockEntity(pos) instanceof TileFusionControlComputer) { + if (((TileFusionControlComputer) worldIn.getBlockEntity(pos)).crafingTickTime != 0 + && ((TileFusionControlComputer) worldIn.getBlockEntity(pos)).checkCoils()) { + entityIn.damage(new FusionDamageSource(), 200F); } } } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileFusionControlComputer(); } diff --git a/src/main/java/techreborn/blocks/generator/BlockGasTurbine.java b/src/main/java/techreborn/blocks/generator/BlockGasTurbine.java index e875780e4..c6b7b86b3 100644 --- a/src/main/java/techreborn/blocks/generator/BlockGasTurbine.java +++ b/src/main/java/techreborn/blocks/generator/BlockGasTurbine.java @@ -24,8 +24,8 @@ package techreborn.blocks.generator; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockGasTurbine extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileGasTurbine(); } diff --git a/src/main/java/techreborn/blocks/generator/BlockLightningRod.java b/src/main/java/techreborn/blocks/generator/BlockLightningRod.java index 804efb156..c3a3d9851 100644 --- a/src/main/java/techreborn/blocks/generator/BlockLightningRod.java +++ b/src/main/java/techreborn/blocks/generator/BlockLightningRod.java @@ -24,8 +24,8 @@ package techreborn.blocks.generator; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -41,7 +41,7 @@ public class BlockLightningRod extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileLightningRod(); } diff --git a/src/main/java/techreborn/blocks/generator/BlockMagicEnergyAbsorber.java b/src/main/java/techreborn/blocks/generator/BlockMagicEnergyAbsorber.java index 901ad32f6..ed9ee1bde 100644 --- a/src/main/java/techreborn/blocks/generator/BlockMagicEnergyAbsorber.java +++ b/src/main/java/techreborn/blocks/generator/BlockMagicEnergyAbsorber.java @@ -24,12 +24,12 @@ package techreborn.blocks.generator; -import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.ChatFormat; +import net.minecraft.client.item.TooltipContext; import net.minecraft.item.ItemStack; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.IBlockReader; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -47,8 +47,8 @@ public class BlockMagicEnergyAbsorber extends BlockMachineBase { } @Override - public void addInformation(ItemStack stack, @Nullable IBlockReader worldIn, List tooltip, ITooltipFlag flagIn) { - tooltip.add(new TextComponentString("WIP Coming Soon").applyTextStyle(TextFormatting.RED)); + public void buildTooltip(ItemStack stack, @Nullable BlockView worldIn, List tooltip, TooltipContext flagIn) { + tooltip.add(new TextComponent("WIP Coming Soon").applyFormat(ChatFormat.RED)); // TODO // Remember to remove WIP override and imports once complete } diff --git a/src/main/java/techreborn/blocks/generator/BlockMagicEnergyConverter.java b/src/main/java/techreborn/blocks/generator/BlockMagicEnergyConverter.java index 3e870f34f..c594d4826 100644 --- a/src/main/java/techreborn/blocks/generator/BlockMagicEnergyConverter.java +++ b/src/main/java/techreborn/blocks/generator/BlockMagicEnergyConverter.java @@ -24,12 +24,12 @@ package techreborn.blocks.generator; -import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.ChatFormat; +import net.minecraft.client.item.TooltipContext; import net.minecraft.item.ItemStack; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.IBlockReader; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -47,8 +47,8 @@ public class BlockMagicEnergyConverter extends BlockMachineBase { } @Override - public void addInformation(ItemStack stack, @Nullable IBlockReader worldIn, List tooltip, ITooltipFlag flagIn) { - tooltip.add(new TextComponentString("WIP Coming Soon").applyTextStyle(TextFormatting.RED)); + public void buildTooltip(ItemStack stack, @Nullable BlockView worldIn, List tooltip, TooltipContext flagIn) { + tooltip.add(new TextComponent("WIP Coming Soon").applyFormat(ChatFormat.RED)); // TODO // Remember to remove WIP override and imports once complete } diff --git a/src/main/java/techreborn/blocks/generator/BlockPlasmaGenerator.java b/src/main/java/techreborn/blocks/generator/BlockPlasmaGenerator.java index 3896c855c..08df05125 100644 --- a/src/main/java/techreborn/blocks/generator/BlockPlasmaGenerator.java +++ b/src/main/java/techreborn/blocks/generator/BlockPlasmaGenerator.java @@ -24,8 +24,8 @@ package techreborn.blocks.generator; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -45,7 +45,7 @@ public class BlockPlasmaGenerator extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TilePlasmaGenerator(); } diff --git a/src/main/java/techreborn/blocks/generator/BlockSemiFluidGenerator.java b/src/main/java/techreborn/blocks/generator/BlockSemiFluidGenerator.java index 8229f2c14..05c735bce 100644 --- a/src/main/java/techreborn/blocks/generator/BlockSemiFluidGenerator.java +++ b/src/main/java/techreborn/blocks/generator/BlockSemiFluidGenerator.java @@ -24,8 +24,8 @@ package techreborn.blocks.generator; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockSemiFluidGenerator extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileSemiFluidGenerator(); } diff --git a/src/main/java/techreborn/blocks/generator/BlockSolarPanel.java b/src/main/java/techreborn/blocks/generator/BlockSolarPanel.java index a075a0a35..be93d1801 100644 --- a/src/main/java/techreborn/blocks/generator/BlockSolarPanel.java +++ b/src/main/java/techreborn/blocks/generator/BlockSolarPanel.java @@ -24,8 +24,8 @@ package techreborn.blocks.generator; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -48,7 +48,7 @@ public class BlockSolarPanel extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileSolarPanel(); } diff --git a/src/main/java/techreborn/blocks/generator/BlockSolidFuelGenerator.java b/src/main/java/techreborn/blocks/generator/BlockSolidFuelGenerator.java index 8f3fae09d..f553f7d1c 100644 --- a/src/main/java/techreborn/blocks/generator/BlockSolidFuelGenerator.java +++ b/src/main/java/techreborn/blocks/generator/BlockSolidFuelGenerator.java @@ -24,8 +24,8 @@ package techreborn.blocks.generator; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockSolidFuelGenerator extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileSolidFuelGenerator(); } diff --git a/src/main/java/techreborn/blocks/generator/BlockThermalGenerator.java b/src/main/java/techreborn/blocks/generator/BlockThermalGenerator.java index 66c162604..85b7ad93a 100644 --- a/src/main/java/techreborn/blocks/generator/BlockThermalGenerator.java +++ b/src/main/java/techreborn/blocks/generator/BlockThermalGenerator.java @@ -24,8 +24,8 @@ package techreborn.blocks.generator; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockThermalGenerator extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileThermalGenerator(); } diff --git a/src/main/java/techreborn/blocks/generator/BlockWaterMill.java b/src/main/java/techreborn/blocks/generator/BlockWaterMill.java index db05121d5..f76f20c91 100644 --- a/src/main/java/techreborn/blocks/generator/BlockWaterMill.java +++ b/src/main/java/techreborn/blocks/generator/BlockWaterMill.java @@ -24,8 +24,8 @@ package techreborn.blocks.generator; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -44,7 +44,7 @@ public class BlockWaterMill extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileWaterMill(); } diff --git a/src/main/java/techreborn/blocks/generator/BlockWindMill.java b/src/main/java/techreborn/blocks/generator/BlockWindMill.java index 8e73085f7..c6a77b1c1 100644 --- a/src/main/java/techreborn/blocks/generator/BlockWindMill.java +++ b/src/main/java/techreborn/blocks/generator/BlockWindMill.java @@ -24,8 +24,8 @@ package techreborn.blocks.generator; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -44,7 +44,7 @@ public class BlockWindMill extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileWindMill(); } diff --git a/src/main/java/techreborn/blocks/lighting/BlockLamp.java b/src/main/java/techreborn/blocks/lighting/BlockLamp.java index 678b66395..52655d514 100644 --- a/src/main/java/techreborn/blocks/lighting/BlockLamp.java +++ b/src/main/java/techreborn/blocks/lighting/BlockLamp.java @@ -27,23 +27,23 @@ package techreborn.blocks.lighting; import javax.annotation.Nullable; import net.minecraft.block.Block; -import net.minecraft.block.material.Material; +import net.minecraft.block.BlockRenderLayer; +import net.minecraft.block.BlockState; +import net.minecraft.block.Material; +import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.state.BlockFaceShape; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.BlockItemUseContext; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemStack; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.DirectionProperty; -import net.minecraft.state.StateContainer; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockRenderLayer; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; +import net.minecraft.state.StateFactory; +import net.minecraft.state.property.BooleanProperty; +import net.minecraft.state.property.DirectionProperty; +import net.minecraft.state.property.Properties; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; +import net.minecraft.util.math.Direction; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.world.BlockView; import net.minecraft.world.World; import reborncore.api.ToolManager; import reborncore.client.models.ModelCompound; @@ -56,7 +56,7 @@ import techreborn.tiles.lighting.TileLamp; public class BlockLamp extends BaseTileBlock { - public static DirectionProperty FACING = BlockStateProperties.FACING; + public static DirectionProperty FACING = Properties.FACING; public static BooleanProperty ACTIVE; protected final VoxelShape[] shape; @@ -64,8 +64,8 @@ public class BlockLamp extends BaseTileBlock { private int brightness; public BlockLamp(int brightness, int cost, double depth, double width) { - super(Block.Properties.create(Material.REDSTONE_LIGHT)); - this.setDefaultState(this.stateContainer.getBaseState().with(FACING, EnumFacing.NORTH).with(ACTIVE, false)); + super(Block.Settings.of(Material.REDSTONE_LAMP)); + this.setDefaultState(this.stateFactory.getDefaultState().with(FACING, Direction.NORTH).with(ACTIVE, false)); this.shape = GenCuboidShapes(depth, width); this.cost = cost; this.brightness = brightness; @@ -76,31 +76,31 @@ public class BlockLamp extends BaseTileBlock { private VoxelShape[] GenCuboidShapes(double depth, double width) { double culling = (16.0D - width) / 2 ; VoxelShape[] shapes = { - Block.makeCuboidShape(culling, 16.0 - depth, culling, 16.0 - culling, 16.0D, 16.0 - culling), - Block.makeCuboidShape(culling, 0.0D, culling, 16.0D - culling, depth, 16.0 - culling), - Block.makeCuboidShape(culling, culling, 16.0 - depth, 16.0 - culling, 16.0 - culling, 16.0D), - Block.makeCuboidShape(culling, culling, 0.0D, 16.0 - culling, 16.0 - culling, depth), - Block.makeCuboidShape(16.0 - depth, culling, culling, 16.0D, 16.0 - culling, 16.0 - culling), - Block.makeCuboidShape(0.0D, culling, culling, depth, 16.0 - culling, 16.0 - culling) + Block.createCuboidShape(culling, 16.0 - depth, culling, 16.0 - culling, 16.0D, 16.0 - culling), + Block.createCuboidShape(culling, 0.0D, culling, 16.0D - culling, depth, 16.0 - culling), + Block.createCuboidShape(culling, culling, 16.0 - depth, 16.0 - culling, 16.0 - culling, 16.0D), + Block.createCuboidShape(culling, culling, 0.0D, 16.0 - culling, 16.0 - culling, depth), + Block.createCuboidShape(16.0 - depth, culling, culling, 16.0D, 16.0 - culling, 16.0 - culling), + Block.createCuboidShape(0.0D, culling, culling, depth, 16.0 - culling, 16.0 - culling) }; return shapes; } - public static boolean isActive(IBlockState state) { + public static boolean isActive(BlockState state) { return state.get(ACTIVE); } - public static EnumFacing getFacing(IBlockState state) { + public static Direction getFacing(BlockState state) { return state.get(FACING); } - public static void setFacing(EnumFacing facing, World world, BlockPos pos) { + public static void setFacing(Direction facing, World world, BlockPos pos) { world.setBlockState(pos, world.getBlockState(pos).with(FACING, facing)); } public static void setActive(Boolean active, World world, BlockPos pos) { - EnumFacing facing = (EnumFacing)world.getBlockState(pos).get(FACING); - IBlockState state = world.getBlockState(pos).with(ACTIVE, active).with(FACING, facing); + Direction facing = (Direction)world.getBlockState(pos).get(FACING); + BlockState state = world.getBlockState(pos).with(ACTIVE, active).with(FACING, facing); world.setBlockState(pos, state, 3); } @@ -110,23 +110,23 @@ public class BlockLamp extends BaseTileBlock { // BaseTileBlock @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileLamp(); } // Block @Override - protected void fillStateContainer(StateContainer.Builder builder) { + protected void appendProperties(StateFactory.Builder builder) { ACTIVE = BooleanProperty.create("active"); builder.add(FACING, ACTIVE); } @Nullable @Override - public IBlockState getStateForPlacement(BlockItemUseContext context) { - for (EnumFacing enumfacing : context.getNearestLookingDirections()) { - IBlockState iblockstate = this.getDefaultState().with(FACING, enumfacing.getOpposite()); - if (iblockstate.isValidPosition(context.getWorld(), context.getPos())) { + public BlockState getPlacementState(ItemPlacementContext context) { + for (Direction enumfacing : context.getPlacementFacings()) { + BlockState iblockstate = this.getDefaultState().with(FACING, enumfacing.getOpposite()); + if (iblockstate.canPlaceAt(context.getWorld(), context.getBlockPos())) { return iblockstate; } } @@ -134,7 +134,7 @@ public class BlockLamp extends BaseTileBlock { } @Override - public int getLightValue(IBlockState state) { + public int getLuminance(BlockState state) { return state.get(ACTIVE) ? brightness : 0; } @@ -144,12 +144,12 @@ public class BlockLamp extends BaseTileBlock { } @Override - public boolean isFullCube(IBlockState state) { + public boolean isFullCube(BlockState state) { return false; } @Override - public BlockFaceShape getBlockFaceShape(IBlockReader worldIn, IBlockState state, BlockPos pos, EnumFacing facing) { + public BlockFaceShape getBlockFaceShape(BlockView worldIn, BlockState state, BlockPos pos, Direction facing) { // This makes only the back face of lamps connect to fences. if (getFacing(state).getOpposite() == facing) return BlockFaceShape.SOLID; @@ -158,15 +158,15 @@ public class BlockLamp extends BaseTileBlock { } @Override - public VoxelShape getShape(IBlockState state, IBlockReader worldIn, BlockPos pos) { - return shape[getFacing(state).getIndex()]; + public VoxelShape getShape(BlockState state, BlockView worldIn, BlockPos pos) { + return shape[getFacing(state).getId()]; } @SuppressWarnings("deprecation") @Override - public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { - ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND); - TileEntity tileEntity = worldIn.getTileEntity(pos); + public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) { + ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND); + BlockEntity tileEntity = worldIn.getBlockEntity(pos); // We extended BaseTileBlock. Thus we should always have tile entity. I hope. if (tileEntity == null) { diff --git a/src/main/java/techreborn/blocks/storage/BlockAdjustableSU.java b/src/main/java/techreborn/blocks/storage/BlockAdjustableSU.java index b1e7547bd..521c930d0 100644 --- a/src/main/java/techreborn/blocks/storage/BlockAdjustableSU.java +++ b/src/main/java/techreborn/blocks/storage/BlockAdjustableSU.java @@ -24,12 +24,12 @@ package techreborn.blocks.storage; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.NonNullList; +import net.minecraft.util.DefaultedList; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; +import net.minecraft.world.BlockView; import net.minecraft.world.World; import reborncore.common.RebornCoreConfig; import techreborn.client.EGui; @@ -43,12 +43,12 @@ public class BlockAdjustableSU extends BlockEnergyStorage { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileAdjustableSU(); } @Override - public void getDrops(IBlockState state, NonNullList drops, World world, BlockPos pos, int fortune) { + public void getDrops(BlockState state, DefaultedList drops, World world, BlockPos pos, int fortune) { if (RebornCoreConfig.wrenchRequired) { drops.add(new ItemStack(TRContent.MachineBlocks.INDUSTRIAL.getFrame())); } else { diff --git a/src/main/java/techreborn/blocks/storage/BlockEnergyStorage.java b/src/main/java/techreborn/blocks/storage/BlockEnergyStorage.java index 29234204f..c15e81be2 100644 --- a/src/main/java/techreborn/blocks/storage/BlockEnergyStorage.java +++ b/src/main/java/techreborn/blocks/storage/BlockEnergyStorage.java @@ -25,18 +25,18 @@ package techreborn.blocks.storage; import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.block.BlockState; +import net.minecraft.block.Material; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.state.DirectionProperty; -import net.minecraft.state.StateContainer; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; +import net.minecraft.state.StateFactory; +import net.minecraft.state.property.DirectionProperty; +import net.minecraft.state.property.Properties; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import net.minecraft.world.World; import reborncore.api.ToolManager; import reborncore.api.tile.IMachineGuiHandler; @@ -51,24 +51,24 @@ import techreborn.TechReborn; * Created by Rushmead */ public abstract class BlockEnergyStorage extends BaseTileBlock { - public static DirectionProperty FACING = BlockStateProperties.FACING; + public static DirectionProperty FACING = Properties.FACING; public String name; public IMachineGuiHandler gui; public BlockEnergyStorage(String name, IMachineGuiHandler gui) { - super(Block.Properties.create(Material.IRON).hardnessAndResistance(2f)); - this.setDefaultState(this.stateContainer.getBaseState().with(FACING, EnumFacing.NORTH)); + super(Block.Settings.of(Material.METAL).strength(2f)); + this.setDefaultState(this.stateFactory.getDefaultState().with(FACING, Direction.NORTH)); this.name = name; this.gui = gui; RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, "machines/energy")); BlockWrenchEventHandler.wrenableBlocks.add(this); } - public void setFacing(EnumFacing facing, World world, BlockPos pos) { + public void setFacing(Direction facing, World world, BlockPos pos) { world.setBlockState(pos, world.getBlockState(pos).with(FACING, facing)); } - public EnumFacing getFacing(IBlockState state) { + public Direction getFacing(BlockState state) { return state.get(FACING); } @@ -96,15 +96,15 @@ public abstract class BlockEnergyStorage extends BaseTileBlock { // Block @Override - protected void fillStateContainer(StateContainer.Builder builder) { + protected void appendProperties(StateFactory.Builder builder) { builder.add(FACING); } @SuppressWarnings("deprecation") @Override - public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { - ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND); - TileEntity tileEntity = worldIn.getTileEntity(pos); + public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) { + ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND); + BlockEntity tileEntity = worldIn.getBlockEntity(pos); // We extended BlockTileBase. Thus we should always have tile entity. I hope. if (tileEntity == null) { @@ -126,14 +126,14 @@ public abstract class BlockEnergyStorage extends BaseTileBlock { } @Override - public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, + public void onPlaced(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { - super.onBlockPlacedBy(worldIn, pos, state, placer, stack); - EnumFacing facing = placer.getHorizontalFacing().getOpposite(); - if (placer.rotationPitch < -50) { - facing = EnumFacing.DOWN; - } else if (placer.rotationPitch > 50) { - facing = EnumFacing.UP; + super.onPlaced(worldIn, pos, state, placer, stack); + Direction facing = placer.getHorizontalFacing().getOpposite(); + if (placer.pitch < -50) { + facing = Direction.DOWN; + } else if (placer.pitch > 50) { + facing = Direction.UP; } setFacing(facing, worldIn, pos); } diff --git a/src/main/java/techreborn/blocks/storage/BlockHighVoltageSU.java b/src/main/java/techreborn/blocks/storage/BlockHighVoltageSU.java index 79e579b49..0a07179e4 100644 --- a/src/main/java/techreborn/blocks/storage/BlockHighVoltageSU.java +++ b/src/main/java/techreborn/blocks/storage/BlockHighVoltageSU.java @@ -24,12 +24,12 @@ package techreborn.blocks.storage; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.NonNullList; +import net.minecraft.util.DefaultedList; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; +import net.minecraft.world.BlockView; import net.minecraft.world.World; import reborncore.common.RebornCoreConfig; import techreborn.client.EGui; @@ -46,12 +46,12 @@ public class BlockHighVoltageSU extends BlockEnergyStorage { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileHighVoltageSU(); } @Override - public void getDrops(IBlockState state, NonNullList drops, World world, BlockPos pos, int fortune) { + public void getDrops(BlockState state, DefaultedList drops, World world, BlockPos pos, int fortune) { if (RebornCoreConfig.wrenchRequired) { drops.add(new ItemStack(TRContent.MachineBlocks.ADVANCED.getFrame())); } else { diff --git a/src/main/java/techreborn/blocks/storage/BlockInterdimensionalSU.java b/src/main/java/techreborn/blocks/storage/BlockInterdimensionalSU.java index 0dac3e7a2..1f281fdf4 100644 --- a/src/main/java/techreborn/blocks/storage/BlockInterdimensionalSU.java +++ b/src/main/java/techreborn/blocks/storage/BlockInterdimensionalSU.java @@ -24,14 +24,14 @@ package techreborn.blocks.storage; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.BlockItemUseContext; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.NonNullList; +import net.minecraft.util.DefaultedList; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; +import net.minecraft.world.BlockView; import net.minecraft.world.World; import reborncore.common.RebornCoreConfig; import techreborn.client.EGui; @@ -45,30 +45,30 @@ public class BlockInterdimensionalSU extends BlockEnergyStorage { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileInterdimensionalSU(); } @Override - public IBlockState getStateForPlacement(BlockItemUseContext context) { - final TileEntity tile = context.getWorld().getTileEntity(context.getPos()); + public BlockState getPlacementState(ItemPlacementContext context) { + final BlockEntity tile = context.getWorld().getBlockEntity(context.getBlockPos()); if (tile instanceof TileInterdimensionalSU) { - ((TileInterdimensionalSU) tile).ownerUdid = context.getPlayer().getUniqueID().toString(); + ((TileInterdimensionalSU) tile).ownerUdid = context.getPlayer().getUuid().toString(); } return this.getDefaultState(); } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { - super.onBlockPlacedBy(world, pos, state, placer, stack); - TileEntity tile = world.getTileEntity(pos); + public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { + super.onPlaced(world, pos, state, placer, stack); + BlockEntity tile = world.getBlockEntity(pos); if (tile instanceof TileInterdimensionalSU) { - ((TileInterdimensionalSU) tile).ownerUdid = placer.getUniqueID().toString(); + ((TileInterdimensionalSU) tile).ownerUdid = placer.getUuid().toString(); } } @Override - public void getDrops(IBlockState state, NonNullList drops, World world, BlockPos pos, int fortune) { + public void getDrops(BlockState state, DefaultedList drops, World world, BlockPos pos, int fortune) { if (RebornCoreConfig.wrenchRequired) { drops.add(new ItemStack(TRContent.MachineBlocks.ADVANCED.getFrame())); } else { diff --git a/src/main/java/techreborn/blocks/storage/BlockLSUStorage.java b/src/main/java/techreborn/blocks/storage/BlockLSUStorage.java index bb8b73cd2..99209c27f 100644 --- a/src/main/java/techreborn/blocks/storage/BlockLSUStorage.java +++ b/src/main/java/techreborn/blocks/storage/BlockLSUStorage.java @@ -25,17 +25,17 @@ package techreborn.blocks.storage; import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.block.BlockState; +import net.minecraft.block.Material; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.NonNullList; +import net.minecraft.util.DefaultedList; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; +import net.minecraft.util.math.Direction; +import net.minecraft.world.BlockView; import net.minecraft.world.World; import reborncore.api.ToolManager; import reborncore.client.models.ModelCompound; @@ -54,36 +54,36 @@ import techreborn.tiles.storage.lesu.TileLSUStorage; public class BlockLSUStorage extends BaseTileBlock { public BlockLSUStorage() { - super(Block.Properties.create(Material.IRON).hardnessAndResistance(2f)); + super(Block.Settings.of(Material.METAL).strength(2f)); RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, "machines/energy")); BlockWrenchEventHandler.wrenableBlocks.add(this); } // BaseTileBlock @Override - public void onReplaced(IBlockState state, World worldIn, BlockPos pos, IBlockState newState, boolean isMoving) { + public void onBlockRemoved(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { if (state.getBlock() == newState.getBlock()) { return; } - if (worldIn.getTileEntity(pos) instanceof TileLSUStorage) { - TileLSUStorage tile = (TileLSUStorage) worldIn.getTileEntity(pos); + if (worldIn.getBlockEntity(pos) instanceof TileLSUStorage) { + TileLSUStorage tile = (TileLSUStorage) worldIn.getBlockEntity(pos); if (tile != null) { tile.removeFromNetwork(); } } - super.onReplaced(state, worldIn, pos, newState, isMoving); + super.onBlockRemoved(state, worldIn, pos, newState, isMoving); } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileLSUStorage(); } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack itemstack) { - super.onBlockPlacedBy(world, pos, state, player, itemstack); - if (world.getTileEntity(pos) instanceof TileLSUStorage) { - TileLSUStorage tile = (TileLSUStorage) world.getTileEntity(pos); + public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity player, ItemStack itemstack) { + super.onPlaced(world, pos, state, player, itemstack); + if (world.getBlockEntity(pos) instanceof TileLSUStorage) { + TileLSUStorage tile = (TileLSUStorage) world.getBlockEntity(pos); if (tile != null) { tile.rebuildNetwork(); } @@ -93,9 +93,9 @@ public class BlockLSUStorage extends BaseTileBlock { // Block @SuppressWarnings("deprecation") @Override - public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { - ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND); - TileEntity tileEntity = worldIn.getTileEntity(pos); + public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) { + ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND); + BlockEntity tileEntity = worldIn.getBlockEntity(pos); // We extended BaseTileBlock. Thus we should always have tile entity. I hope. if (tileEntity == null) { @@ -112,7 +112,7 @@ public class BlockLSUStorage extends BaseTileBlock { } @Override - public void getDrops(IBlockState state, NonNullList drops, World world, BlockPos pos, int fortune) { + public void getDrops(BlockState state, DefaultedList drops, World world, BlockPos pos, int fortune) { if (RebornCoreConfig.wrenchRequired) { drops.add(new ItemStack(TRContent.MachineBlocks.BASIC.getFrame())); } else { diff --git a/src/main/java/techreborn/blocks/storage/BlockLapotronicSU.java b/src/main/java/techreborn/blocks/storage/BlockLapotronicSU.java index f7ee488b1..14f1cde51 100644 --- a/src/main/java/techreborn/blocks/storage/BlockLapotronicSU.java +++ b/src/main/java/techreborn/blocks/storage/BlockLapotronicSU.java @@ -24,12 +24,12 @@ package techreborn.blocks.storage; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.NonNullList; +import net.minecraft.util.DefaultedList; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; +import net.minecraft.world.BlockView; import net.minecraft.world.World; import reborncore.common.RebornCoreConfig; import techreborn.client.EGui; @@ -43,12 +43,12 @@ public class BlockLapotronicSU extends BlockEnergyStorage { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileLapotronicSU(); } @Override - public void getDrops(IBlockState state, NonNullList drops, World world, BlockPos pos, int fortune) { + public void getDrops(BlockState state, DefaultedList drops, World world, BlockPos pos, int fortune) { if (RebornCoreConfig.wrenchRequired) { drops.add(new ItemStack(TRContent.MachineBlocks.ADVANCED.getFrame())); } else { diff --git a/src/main/java/techreborn/blocks/storage/BlockLowVoltageSU.java b/src/main/java/techreborn/blocks/storage/BlockLowVoltageSU.java index 3e6dbda50..85d50844c 100644 --- a/src/main/java/techreborn/blocks/storage/BlockLowVoltageSU.java +++ b/src/main/java/techreborn/blocks/storage/BlockLowVoltageSU.java @@ -24,8 +24,8 @@ package techreborn.blocks.storage; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import techreborn.client.EGui; import techreborn.tiles.storage.TileLowVoltageSU; @@ -39,7 +39,7 @@ public class BlockLowVoltageSU extends BlockEnergyStorage { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileLowVoltageSU(); } } diff --git a/src/main/java/techreborn/blocks/storage/BlockMediumVoltageSU.java b/src/main/java/techreborn/blocks/storage/BlockMediumVoltageSU.java index 56de4464a..476aaa210 100644 --- a/src/main/java/techreborn/blocks/storage/BlockMediumVoltageSU.java +++ b/src/main/java/techreborn/blocks/storage/BlockMediumVoltageSU.java @@ -24,12 +24,12 @@ package techreborn.blocks.storage; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.NonNullList; +import net.minecraft.util.DefaultedList; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; +import net.minecraft.world.BlockView; import net.minecraft.world.World; import reborncore.common.RebornCoreConfig; import techreborn.client.EGui; @@ -46,12 +46,12 @@ public class BlockMediumVoltageSU extends BlockEnergyStorage { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileMediumVoltageSU(); } @Override - public void getDrops(IBlockState state, NonNullList drops, World world, BlockPos pos, int fortune) { + public void getDrops(BlockState state, DefaultedList drops, World world, BlockPos pos, int fortune) { if (RebornCoreConfig.wrenchRequired) { drops.add(new ItemStack(TRContent.MachineBlocks.BASIC.getFrame())); } else { diff --git a/src/main/java/techreborn/blocks/tier0/BlockIronAlloyFurnace.java b/src/main/java/techreborn/blocks/tier0/BlockIronAlloyFurnace.java index 77b422293..ed901ddad 100644 --- a/src/main/java/techreborn/blocks/tier0/BlockIronAlloyFurnace.java +++ b/src/main/java/techreborn/blocks/tier0/BlockIronAlloyFurnace.java @@ -24,12 +24,12 @@ package techreborn.blocks.tier0; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.NonNullList; +import net.minecraft.util.DefaultedList; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; +import net.minecraft.world.BlockView; import net.minecraft.world.World; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; @@ -47,7 +47,7 @@ public class BlockIronAlloyFurnace extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileIronAlloyFurnace(); } @@ -57,7 +57,7 @@ public class BlockIronAlloyFurnace extends BlockMachineBase { } @Override - public void getDrops(IBlockState state, NonNullList drops, World world, BlockPos pos, int fortune) { + public void getDrops(BlockState state, DefaultedList drops, World world, BlockPos pos, int fortune) { drops.add(new ItemStack(this)); } } diff --git a/src/main/java/techreborn/blocks/tier0/BlockIronFurnace.java b/src/main/java/techreborn/blocks/tier0/BlockIronFurnace.java index f685f71a5..beec97716 100644 --- a/src/main/java/techreborn/blocks/tier0/BlockIronFurnace.java +++ b/src/main/java/techreborn/blocks/tier0/BlockIronFurnace.java @@ -24,19 +24,19 @@ package techreborn.blocks.tier0; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Particles; -import net.minecraft.init.SoundEvents; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.NonNullList; -import net.minecraft.util.SoundCategory; +import net.minecraft.particle.ParticleTypes; +import net.minecraft.sound.SoundCategory; +import net.minecraft.sound.SoundEvents; +import net.minecraft.util.DefaultedList; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; +import net.minecraft.util.math.Direction; +import net.minecraft.world.BlockView; import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -55,8 +55,8 @@ public class BlockIronFurnace extends BlockMachineBase { } @SuppressWarnings("incomplete-switch") - @OnlyIn(Dist.CLIENT) - public void animateTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { + @Environment(EnvType.CLIENT) + public void randomDisplayTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) { if (this.isActive(stateIn)) { final double d0 = pos.getX() + 0.5D; @@ -67,33 +67,33 @@ public class BlockIronFurnace extends BlockMachineBase { false); } - final EnumFacing enumfacing = stateIn.get(BlockMachineBase.FACING); + final Direction enumfacing = stateIn.get(BlockMachineBase.FACING); final double d3 = 0.52D; final double d4 = rand.nextDouble() * 0.6D - 0.3D; switch (enumfacing) { case WEST: - worldIn.addParticle(Particles.SMOKE, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D); - worldIn.addParticle(Particles.FLAME, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D); + worldIn.addParticle(ParticleTypes.SMOKE, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D); + worldIn.addParticle(ParticleTypes.FLAME, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D); break; case EAST: - worldIn.addParticle(Particles.SMOKE, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D); - worldIn.addParticle(Particles.FLAME, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D); + worldIn.addParticle(ParticleTypes.SMOKE, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D); + worldIn.addParticle(ParticleTypes.FLAME, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D); break; case NORTH: - worldIn.addParticle(Particles.SMOKE, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D); - worldIn.addParticle(Particles.FLAME, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D); + worldIn.addParticle(ParticleTypes.SMOKE, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D); + worldIn.addParticle(ParticleTypes.FLAME, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D); break; case SOUTH: - worldIn.addParticle(Particles.SMOKE, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D); - worldIn.addParticle(Particles.FLAME, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D); + worldIn.addParticle(ParticleTypes.SMOKE, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D); + worldIn.addParticle(ParticleTypes.FLAME, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D); } } } // BlockMachineBase @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileIronFurnace(); } @@ -103,7 +103,7 @@ public class BlockIronFurnace extends BlockMachineBase { } @Override - public void getDrops(IBlockState state, NonNullList drops, World world, BlockPos pos, int fortune) { + public void getDrops(BlockState state, DefaultedList drops, World world, BlockPos pos, int fortune) { drops.add(new ItemStack(this)); } } diff --git a/src/main/java/techreborn/blocks/tier1/BlockAlloySmelter.java b/src/main/java/techreborn/blocks/tier1/BlockAlloySmelter.java index b7a51bb46..2c8981548 100644 --- a/src/main/java/techreborn/blocks/tier1/BlockAlloySmelter.java +++ b/src/main/java/techreborn/blocks/tier1/BlockAlloySmelter.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier1; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockAlloySmelter extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileAlloySmelter(); } diff --git a/src/main/java/techreborn/blocks/tier1/BlockAssemblingMachine.java b/src/main/java/techreborn/blocks/tier1/BlockAssemblingMachine.java index d17f99279..4af543dc4 100644 --- a/src/main/java/techreborn/blocks/tier1/BlockAssemblingMachine.java +++ b/src/main/java/techreborn/blocks/tier1/BlockAssemblingMachine.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier1; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockAssemblingMachine extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileAssemblingMachine(); } diff --git a/src/main/java/techreborn/blocks/tier1/BlockAutoCraftingTable.java b/src/main/java/techreborn/blocks/tier1/BlockAutoCraftingTable.java index b668fa76d..772e5f893 100644 --- a/src/main/java/techreborn/blocks/tier1/BlockAutoCraftingTable.java +++ b/src/main/java/techreborn/blocks/tier1/BlockAutoCraftingTable.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier1; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockAutoCraftingTable extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileAutoCraftingTable(); } diff --git a/src/main/java/techreborn/blocks/tier1/BlockCompressor.java b/src/main/java/techreborn/blocks/tier1/BlockCompressor.java index d8e7fa88f..66e6a6214 100644 --- a/src/main/java/techreborn/blocks/tier1/BlockCompressor.java +++ b/src/main/java/techreborn/blocks/tier1/BlockCompressor.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier1; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockCompressor extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileCompressor(); } diff --git a/src/main/java/techreborn/blocks/tier1/BlockElectricFurnace.java b/src/main/java/techreborn/blocks/tier1/BlockElectricFurnace.java index d012a033b..c72be48de 100644 --- a/src/main/java/techreborn/blocks/tier1/BlockElectricFurnace.java +++ b/src/main/java/techreborn/blocks/tier1/BlockElectricFurnace.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier1; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockElectricFurnace extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileElectricFurnace(); } diff --git a/src/main/java/techreborn/blocks/tier1/BlockExtractor.java b/src/main/java/techreborn/blocks/tier1/BlockExtractor.java index 568d44f59..5c7db65ca 100644 --- a/src/main/java/techreborn/blocks/tier1/BlockExtractor.java +++ b/src/main/java/techreborn/blocks/tier1/BlockExtractor.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier1; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockExtractor extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileExtractor(); } diff --git a/src/main/java/techreborn/blocks/tier1/BlockGrinder.java b/src/main/java/techreborn/blocks/tier1/BlockGrinder.java index 95cdc5326..d1bb71a40 100644 --- a/src/main/java/techreborn/blocks/tier1/BlockGrinder.java +++ b/src/main/java/techreborn/blocks/tier1/BlockGrinder.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier1; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockGrinder extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileGrinder(); } diff --git a/src/main/java/techreborn/blocks/tier1/BlockPlayerDetector.java b/src/main/java/techreborn/blocks/tier1/BlockPlayerDetector.java index 825f7e386..852a4396c 100644 --- a/src/main/java/techreborn/blocks/tier1/BlockPlayerDetector.java +++ b/src/main/java/techreborn/blocks/tier1/BlockPlayerDetector.java @@ -25,22 +25,22 @@ package techreborn.blocks.tier1; import com.google.common.collect.Lists; +import net.minecraft.ChatFormat; import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.Material; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.client.resource.language.I18n; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.state.StateContainer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.state.StateFactory; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.IBlockReader; +import net.minecraft.util.math.Direction; +import net.minecraft.world.BlockView; import net.minecraft.world.World; import reborncore.api.IToolDrop; import reborncore.api.ToolManager; @@ -66,8 +66,8 @@ public class BlockPlayerDetector extends BlockMachineBase { public static PropertyString TYPE; public BlockPlayerDetector() { - super(Block.Properties.create(Material.IRON), true); - this.setDefaultState(this.stateContainer.getBaseState().with(TYPE, types[0])); + super(Block.Settings.of(Material.METAL), true); + this.setDefaultState(this.stateFactory.getDefaultState().with(TYPE, types[0])); for (int i = 0; i < types.length; i++) { RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, i, "machines/tier1_machines").setInvVariant("type=" + types[i])); } @@ -75,24 +75,24 @@ public class BlockPlayerDetector extends BlockMachineBase { // BlockMachineBase @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TilePlayerDectector(); } @Override - public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, + public void onPlaced(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { - super.onBlockPlacedBy(worldIn, pos, state, placer, stack); - TileEntity tile = worldIn.getTileEntity(pos); + super.onPlaced(worldIn, pos, state, placer, stack); + BlockEntity tile = worldIn.getBlockEntity(pos); if (tile instanceof TilePlayerDectector) { - ((TilePlayerDectector) tile).owenerUdid = placer.getUniqueID().toString(); + ((TilePlayerDectector) tile).owenerUdid = placer.getUuid().toString(); } } @Override - public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { - ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND); - TileEntity tileEntity = worldIn.getTileEntity(pos); + public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) { + ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND); + BlockEntity tileEntity = worldIn.getBlockEntity(pos); if (tileEntity == null) { return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ); @@ -100,7 +100,7 @@ public class BlockPlayerDetector extends BlockMachineBase { String type = state.get(TYPE); String newType = type; - TextFormatting color = TextFormatting.GREEN; + ChatFormat color = ChatFormat.GREEN; if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) { if (ToolManager.INSTANCE.handleTool(stack, pos, worldIn, playerIn, side, false)) { @@ -111,9 +111,9 @@ public class BlockPlayerDetector extends BlockMachineBase { return false; } if (!drop.isEmpty()) { - spawnAsEntity(worldIn, pos, drop); + dropStack(worldIn, pos, drop); } - if (!worldIn.isRemote) { + if (!worldIn.isClient) { worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 2); } return true; @@ -121,10 +121,10 @@ public class BlockPlayerDetector extends BlockMachineBase { } else { if (type.equals("all")) { newType = "others"; - color = TextFormatting.RED; + color = ChatFormat.RED; } else if (type.equals("others")) { newType = "you"; - color = TextFormatting.BLUE; + color = ChatFormat.BLUE; } else if (type.equals("you")) { newType = "all"; } @@ -133,9 +133,9 @@ public class BlockPlayerDetector extends BlockMachineBase { } } - if (worldIn.isRemote) { - ChatUtils.sendNoSpamMessages(MessageIDs.playerDetectorID, new TextComponentString( - TextFormatting.GRAY + I18n.format("techreborn.message.detects") + " " + color + if (worldIn.isClient) { + ChatUtils.sendNoSpamMessages(MessageIDs.playerDetectorID, new TextComponent( + ChatFormat.GRAY + I18n.translate("techreborn.message.detects") + " " + color + StringUtils.toFirstCapital(newType))); } return true; @@ -148,24 +148,24 @@ public class BlockPlayerDetector extends BlockMachineBase { // Block @Override - protected void fillStateContainer(StateContainer.Builder builder) { + protected void appendProperties(StateFactory.Builder builder) { TYPE = new PropertyString("type", types); builder.add(TYPE); } @Override - public boolean canConnectRedstone(IBlockState state, IBlockReader world, BlockPos pos, @Nullable EnumFacing side) { + public boolean canConnectRedstone(BlockState state, BlockView world, BlockPos pos, @Nullable Direction side) { return true; } @Override - public boolean canProvidePower(IBlockState state) { + public boolean emitsRedstonePower(BlockState state) { return true; } @Override - public int getWeakPower(IBlockState blockState, IBlockReader blockAccess, BlockPos pos, EnumFacing side) { - TileEntity entity = blockAccess.getTileEntity(pos); + public int getWeakRedstonePower(BlockState blockState, BlockView blockAccess, BlockPos pos, Direction side) { + BlockEntity entity = blockAccess.getBlockEntity(pos); if (entity instanceof TilePlayerDectector) { return ((TilePlayerDectector) entity).isProvidingPower() ? 15 : 0; } @@ -173,8 +173,8 @@ public class BlockPlayerDetector extends BlockMachineBase { } @Override - public int getStrongPower(IBlockState blockState, IBlockReader blockAccess, BlockPos pos, EnumFacing side) { - TileEntity entity = blockAccess.getTileEntity(pos); + public int getStrongRedstonePower(BlockState blockState, BlockView blockAccess, BlockPos pos, Direction side) { + BlockEntity entity = blockAccess.getBlockEntity(pos); if (entity instanceof TilePlayerDectector) { return ((TilePlayerDectector) entity).isProvidingPower() ? 15 : 0; } diff --git a/src/main/java/techreborn/blocks/tier1/BlockRecycler.java b/src/main/java/techreborn/blocks/tier1/BlockRecycler.java index acc47d17e..3e4ee9012 100644 --- a/src/main/java/techreborn/blocks/tier1/BlockRecycler.java +++ b/src/main/java/techreborn/blocks/tier1/BlockRecycler.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier1; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockRecycler extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileRecycler(); } diff --git a/src/main/java/techreborn/blocks/tier1/BlockRollingMachine.java b/src/main/java/techreborn/blocks/tier1/BlockRollingMachine.java index 8cbeef832..5c08dc9ee 100644 --- a/src/main/java/techreborn/blocks/tier1/BlockRollingMachine.java +++ b/src/main/java/techreborn/blocks/tier1/BlockRollingMachine.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier1; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockRollingMachine extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileRollingMachine(); } diff --git a/src/main/java/techreborn/blocks/tier1/BlockScrapboxinator.java b/src/main/java/techreborn/blocks/tier1/BlockScrapboxinator.java index 6d15b5271..4d975320c 100644 --- a/src/main/java/techreborn/blocks/tier1/BlockScrapboxinator.java +++ b/src/main/java/techreborn/blocks/tier1/BlockScrapboxinator.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier1; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockScrapboxinator extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileScrapboxinator(); } diff --git a/src/main/java/techreborn/blocks/tier2/BlockChargeOMat.java b/src/main/java/techreborn/blocks/tier2/BlockChargeOMat.java index 42e1b88b0..aaeab18c6 100644 --- a/src/main/java/techreborn/blocks/tier2/BlockChargeOMat.java +++ b/src/main/java/techreborn/blocks/tier2/BlockChargeOMat.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier2; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockChargeOMat extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileChargeOMat(); } diff --git a/src/main/java/techreborn/blocks/tier2/BlockChemicalReactor.java b/src/main/java/techreborn/blocks/tier2/BlockChemicalReactor.java index 2afdecd1c..e7fae51d5 100644 --- a/src/main/java/techreborn/blocks/tier2/BlockChemicalReactor.java +++ b/src/main/java/techreborn/blocks/tier2/BlockChemicalReactor.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier2; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockChemicalReactor extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileChemicalReactor(); } diff --git a/src/main/java/techreborn/blocks/tier2/BlockDigitalChest.java b/src/main/java/techreborn/blocks/tier2/BlockDigitalChest.java index 737f33b7e..b44c71865 100644 --- a/src/main/java/techreborn/blocks/tier2/BlockDigitalChest.java +++ b/src/main/java/techreborn/blocks/tier2/BlockDigitalChest.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier2; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockDigitalChest extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileDigitalChest(); } diff --git a/src/main/java/techreborn/blocks/tier2/BlockDistillationTower.java b/src/main/java/techreborn/blocks/tier2/BlockDistillationTower.java index 194d34736..77e95cb03 100644 --- a/src/main/java/techreborn/blocks/tier2/BlockDistillationTower.java +++ b/src/main/java/techreborn/blocks/tier2/BlockDistillationTower.java @@ -24,31 +24,31 @@ package techreborn.blocks.tier2; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; import reborncore.common.blocks.BlockMachineBase; import techreborn.TechReborn; import techreborn.client.EGui; -import techreborn.tiles.machine.multiblock.TileDistillationTower; +import techreborn.tiles.machine.multiblock.TileEnvTypeillationTower; -public class BlockDistillationTower extends BlockMachineBase { +public class BlockEnvTypeillationTower extends BlockMachineBase { - public BlockDistillationTower() { + public BlockEnvTypeillationTower() { super(); RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, "machines/tier2_machines")); } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { - return new TileDistillationTower(); + public BlockEntity createBlockEntity(BlockView worldIn) { + return new TileEnvTypeillationTower(); } @Override public IMachineGuiHandler getGui() { - return EGui.DISTILLATION_TOWER; + return EGui.EnvTypeILLATION_TOWER; } @Override diff --git a/src/main/java/techreborn/blocks/tier2/BlockImplosionCompressor.java b/src/main/java/techreborn/blocks/tier2/BlockImplosionCompressor.java index 3fa54ad7d..dec0f361c 100644 --- a/src/main/java/techreborn/blocks/tier2/BlockImplosionCompressor.java +++ b/src/main/java/techreborn/blocks/tier2/BlockImplosionCompressor.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier2; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockImplosionCompressor extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileImplosionCompressor(); } diff --git a/src/main/java/techreborn/blocks/tier2/BlockIndustrialBlastFurnace.java b/src/main/java/techreborn/blocks/tier2/BlockIndustrialBlastFurnace.java index 4e624dc7e..b22f1529c 100644 --- a/src/main/java/techreborn/blocks/tier2/BlockIndustrialBlastFurnace.java +++ b/src/main/java/techreborn/blocks/tier2/BlockIndustrialBlastFurnace.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier2; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockIndustrialBlastFurnace extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileIndustrialBlastFurnace(); } diff --git a/src/main/java/techreborn/blocks/tier2/BlockIndustrialCentrifuge.java b/src/main/java/techreborn/blocks/tier2/BlockIndustrialCentrifuge.java index 31ae6d68f..5fb6a657a 100644 --- a/src/main/java/techreborn/blocks/tier2/BlockIndustrialCentrifuge.java +++ b/src/main/java/techreborn/blocks/tier2/BlockIndustrialCentrifuge.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier2; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockIndustrialCentrifuge extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileIndustrialCentrifuge(); } diff --git a/src/main/java/techreborn/blocks/tier2/BlockIndustrialElectrolyzer.java b/src/main/java/techreborn/blocks/tier2/BlockIndustrialElectrolyzer.java index ffb828961..db2e9710a 100644 --- a/src/main/java/techreborn/blocks/tier2/BlockIndustrialElectrolyzer.java +++ b/src/main/java/techreborn/blocks/tier2/BlockIndustrialElectrolyzer.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier2; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockIndustrialElectrolyzer extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileIndustrialElectrolyzer(); } diff --git a/src/main/java/techreborn/blocks/tier2/BlockIndustrialGrinder.java b/src/main/java/techreborn/blocks/tier2/BlockIndustrialGrinder.java index 42a17f20e..71b5f4e31 100644 --- a/src/main/java/techreborn/blocks/tier2/BlockIndustrialGrinder.java +++ b/src/main/java/techreborn/blocks/tier2/BlockIndustrialGrinder.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier2; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockIndustrialGrinder extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileIndustrialGrinder(); } diff --git a/src/main/java/techreborn/blocks/tier2/BlockIndustrialSawmill.java b/src/main/java/techreborn/blocks/tier2/BlockIndustrialSawmill.java index 3e709220b..1ccabd8c4 100644 --- a/src/main/java/techreborn/blocks/tier2/BlockIndustrialSawmill.java +++ b/src/main/java/techreborn/blocks/tier2/BlockIndustrialSawmill.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier2; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockIndustrialSawmill extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileIndustrialSawmill(); } diff --git a/src/main/java/techreborn/blocks/tier2/BlockVacuumFreezer.java b/src/main/java/techreborn/blocks/tier2/BlockVacuumFreezer.java index a5cc460b5..1807f7566 100644 --- a/src/main/java/techreborn/blocks/tier2/BlockVacuumFreezer.java +++ b/src/main/java/techreborn/blocks/tier2/BlockVacuumFreezer.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier2; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockVacuumFreezer extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileVacuumFreezer(); } diff --git a/src/main/java/techreborn/blocks/tier3/BlockChunkLoader.java b/src/main/java/techreborn/blocks/tier3/BlockChunkLoader.java index 4c5feff7a..79082bac1 100644 --- a/src/main/java/techreborn/blocks/tier3/BlockChunkLoader.java +++ b/src/main/java/techreborn/blocks/tier3/BlockChunkLoader.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier3; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockChunkLoader extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileChunkLoader(); } diff --git a/src/main/java/techreborn/blocks/tier3/BlockCreativeQuantumChest.java b/src/main/java/techreborn/blocks/tier3/BlockCreativeQuantumChest.java index db52bc9d7..9b900789f 100644 --- a/src/main/java/techreborn/blocks/tier3/BlockCreativeQuantumChest.java +++ b/src/main/java/techreborn/blocks/tier3/BlockCreativeQuantumChest.java @@ -24,10 +24,10 @@ package techreborn.blocks.tier3; -import net.minecraft.block.state.IBlockState; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; +import net.minecraft.world.BlockView; import net.minecraft.world.World; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; @@ -45,7 +45,7 @@ public class BlockCreativeQuantumChest extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileCreativeQuantumChest(); } @@ -60,10 +60,10 @@ public class BlockCreativeQuantumChest extends BlockMachineBase { } @Override - public void onReplaced(IBlockState state, World worldIn, BlockPos pos, IBlockState newState, boolean isMoving) { + public void onBlockRemoved(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { if (state.getBlock() != newState.getBlock()) { //lets not drop max int items into the world, that sounds like a bad idea - worldIn.removeTileEntity(pos); + worldIn.removeBlockEntity(pos); } } } diff --git a/src/main/java/techreborn/blocks/tier3/BlockCreativeQuantumTank.java b/src/main/java/techreborn/blocks/tier3/BlockCreativeQuantumTank.java index 4260e7bc4..bd1ef1d69 100644 --- a/src/main/java/techreborn/blocks/tier3/BlockCreativeQuantumTank.java +++ b/src/main/java/techreborn/blocks/tier3/BlockCreativeQuantumTank.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier3; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockCreativeQuantumTank extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileCreativeQuantumTank(); } diff --git a/src/main/java/techreborn/blocks/tier3/BlockFluidReplicator.java b/src/main/java/techreborn/blocks/tier3/BlockFluidReplicator.java index 0dccbc544..e07b2b917 100644 --- a/src/main/java/techreborn/blocks/tier3/BlockFluidReplicator.java +++ b/src/main/java/techreborn/blocks/tier3/BlockFluidReplicator.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier3; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockFluidReplicator extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileFluidReplicator(); } diff --git a/src/main/java/techreborn/blocks/tier3/BlockMatterFabricator.java b/src/main/java/techreborn/blocks/tier3/BlockMatterFabricator.java index f332d61fa..1b2b396c3 100644 --- a/src/main/java/techreborn/blocks/tier3/BlockMatterFabricator.java +++ b/src/main/java/techreborn/blocks/tier3/BlockMatterFabricator.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier3; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockMatterFabricator extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileMatterFabricator(); } diff --git a/src/main/java/techreborn/blocks/tier3/BlockQuantumChest.java b/src/main/java/techreborn/blocks/tier3/BlockQuantumChest.java index 2ea39b877..2313792af 100644 --- a/src/main/java/techreborn/blocks/tier3/BlockQuantumChest.java +++ b/src/main/java/techreborn/blocks/tier3/BlockQuantumChest.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier3; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockQuantumChest extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileQuantumChest(); } diff --git a/src/main/java/techreborn/blocks/tier3/BlockQuantumTank.java b/src/main/java/techreborn/blocks/tier3/BlockQuantumTank.java index b11be8dff..8a90c68aa 100644 --- a/src/main/java/techreborn/blocks/tier3/BlockQuantumTank.java +++ b/src/main/java/techreborn/blocks/tier3/BlockQuantumTank.java @@ -24,8 +24,8 @@ package techreborn.blocks.tier3; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; @@ -42,7 +42,7 @@ public class BlockQuantumTank extends BlockMachineBase { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileQuantumTank(); } diff --git a/src/main/java/techreborn/blocks/transformers/BlockHVTransformer.java b/src/main/java/techreborn/blocks/transformers/BlockHVTransformer.java index 03c235f43..b33ad76d6 100644 --- a/src/main/java/techreborn/blocks/transformers/BlockHVTransformer.java +++ b/src/main/java/techreborn/blocks/transformers/BlockHVTransformer.java @@ -24,12 +24,12 @@ package techreborn.blocks.transformers; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.NonNullList; +import net.minecraft.util.DefaultedList; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; +import net.minecraft.world.BlockView; import net.minecraft.world.World; import reborncore.common.RebornCoreConfig; import techreborn.init.TRContent; @@ -45,12 +45,12 @@ public class BlockHVTransformer extends BlockTransformer { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileHVTransformer(); } @Override - public void getDrops(IBlockState state, NonNullList drops, World world, BlockPos pos, int fortune) { + public void getDrops(BlockState state, DefaultedList drops, World world, BlockPos pos, int fortune) { if (RebornCoreConfig.wrenchRequired){ drops.add(new ItemStack(TRContent.MachineBlocks.ADVANCED.getFrame())); } diff --git a/src/main/java/techreborn/blocks/transformers/BlockLVTransformer.java b/src/main/java/techreborn/blocks/transformers/BlockLVTransformer.java index 8414db65a..75d8d18b3 100644 --- a/src/main/java/techreborn/blocks/transformers/BlockLVTransformer.java +++ b/src/main/java/techreborn/blocks/transformers/BlockLVTransformer.java @@ -24,8 +24,8 @@ package techreborn.blocks.transformers; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; import techreborn.tiles.transformers.TileLVTransformer; /** @@ -38,7 +38,7 @@ public class BlockLVTransformer extends BlockTransformer { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileLVTransformer(); } } diff --git a/src/main/java/techreborn/blocks/transformers/BlockMVTransformer.java b/src/main/java/techreborn/blocks/transformers/BlockMVTransformer.java index 42c289e9c..e0629dc30 100644 --- a/src/main/java/techreborn/blocks/transformers/BlockMVTransformer.java +++ b/src/main/java/techreborn/blocks/transformers/BlockMVTransformer.java @@ -24,12 +24,12 @@ package techreborn.blocks.transformers; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.NonNullList; +import net.minecraft.util.DefaultedList; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; +import net.minecraft.world.BlockView; import net.minecraft.world.World; import reborncore.common.RebornCoreConfig; import techreborn.init.TRContent; @@ -45,12 +45,12 @@ public class BlockMVTransformer extends BlockTransformer { } @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createBlockEntity(BlockView worldIn) { return new TileMVTransformer(); } @Override - public void getDrops(IBlockState state, NonNullList drops, World world, BlockPos pos, int fortune) { + public void getDrops(BlockState state, DefaultedList drops, World world, BlockPos pos, int fortune) { if (RebornCoreConfig.wrenchRequired){ drops.add(new ItemStack(TRContent.MachineBlocks.BASIC.getFrame())); } diff --git a/src/main/java/techreborn/blocks/transformers/BlockTransformer.java b/src/main/java/techreborn/blocks/transformers/BlockTransformer.java index 6f5ce7468..03ece7b7c 100644 --- a/src/main/java/techreborn/blocks/transformers/BlockTransformer.java +++ b/src/main/java/techreborn/blocks/transformers/BlockTransformer.java @@ -25,18 +25,18 @@ package techreborn.blocks.transformers; import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.block.BlockState; +import net.minecraft.block.Material; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.state.DirectionProperty; -import net.minecraft.state.StateContainer; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; +import net.minecraft.state.StateFactory; +import net.minecraft.state.property.DirectionProperty; +import net.minecraft.state.property.Properties; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import net.minecraft.world.World; import reborncore.api.ToolManager; import reborncore.client.models.ModelCompound; @@ -51,50 +51,50 @@ import techreborn.TechReborn; */ public abstract class BlockTransformer extends BaseTileBlock { - public static DirectionProperty FACING = BlockStateProperties.FACING; + public static DirectionProperty FACING = Properties.FACING; public String name; public BlockTransformer(String name) { - super(Block.Properties.create(Material.IRON).hardnessAndResistance(2f)); - this.setDefaultState(this.stateContainer.getBaseState().with(FACING, EnumFacing.NORTH)); + super(Block.Settings.of(Material.METAL).strength(2f)); + this.setDefaultState(this.stateFactory.getDefaultState().with(FACING, Direction.NORTH)); this.name = name; RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, "machines/energy")); BlockWrenchEventHandler.wrenableBlocks.add(this); } - public void setFacing(EnumFacing facing, World world, BlockPos pos) { + public void setFacing(Direction facing, World world, BlockPos pos) { world.setBlockState(pos, world.getBlockState(pos).with(FACING, facing)); } - public EnumFacing getFacing(IBlockState state) { + public Direction getFacing(BlockState state) { return state.get(FACING); } // BaseTileBlock @Override - public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, + public void onPlaced(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { - super.onBlockPlacedBy(worldIn, pos, state, placer, stack); - EnumFacing facing = placer.getHorizontalFacing().getOpposite(); - if (placer.rotationPitch < -50) { - facing = EnumFacing.DOWN; - } else if (placer.rotationPitch > 50) { - facing = EnumFacing.UP; + super.onPlaced(worldIn, pos, state, placer, stack); + Direction facing = placer.getHorizontalFacing().getOpposite(); + if (placer.pitch < -50) { + facing = Direction.DOWN; + } else if (placer.pitch > 50) { + facing = Direction.UP; } setFacing(facing, worldIn, pos); } // Block @Override - protected void fillStateContainer(StateContainer.Builder builder) { + protected void appendProperties(StateFactory.Builder builder) { builder.add(FACING); } @SuppressWarnings("deprecation") @Override - public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { - ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND); - TileEntity tileEntity = worldIn.getTileEntity(pos); + public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) { + ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND); + BlockEntity tileEntity = worldIn.getBlockEntity(pos); // We extended BlockTileBase. Thus we should always have tile entity. I hope. if (tileEntity == null) { diff --git a/src/main/java/techreborn/client/ClientEventHandler.java b/src/main/java/techreborn/client/ClientEventHandler.java index eb8a6fce1..a7ea2c9b0 100644 --- a/src/main/java/techreborn/client/ClientEventHandler.java +++ b/src/main/java/techreborn/client/ClientEventHandler.java @@ -24,20 +24,20 @@ package techreborn.client; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; -import net.minecraftforge.client.event.RenderPlayerEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; + + import techreborn.init.TRContent; public class ClientEventHandler { @SubscribeEvent public static void renderPlayer(RenderPlayerEvent.Pre event) { - EntityPlayer player = event.getEntityPlayer(); - Item chestslot = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty() - ? player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() : null; + PlayerEntity player = event.getEntityPlayer(); + Item chestslot = !player.getEquippedStack(EquipmentSlot.CHEST).isEmpty() + ? player.getEquippedStack(EquipmentSlot.CHEST).getItem() : null; if (chestslot != null && chestslot == TRContent.CLOAKING_DEVICE) { event.setCanceled(true); } diff --git a/src/main/java/techreborn/client/EGui.java b/src/main/java/techreborn/client/EGui.java index 57cf05f7b..b5d491305 100644 --- a/src/main/java/techreborn/client/EGui.java +++ b/src/main/java/techreborn/client/EGui.java @@ -24,24 +24,23 @@ package techreborn.client; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.ContainerScreen; +import net.minecraft.container.Container; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; import net.minecraft.world.IInteractionObject; import net.minecraft.world.World; -import net.minecraftforge.fml.ExtensionPoint; -import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.network.FMLPlayMessages; -import net.minecraftforge.fml.network.NetworkHooks; + + + + import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.containerBuilder.IContainerProvider; import techreborn.client.container.ContainerDestructoPack; @@ -89,7 +88,7 @@ public enum EGui implements IMachineGuiHandler { DESTRUCTOPACK(false), DIESEL_GENERATOR(true), DIGITAL_CHEST(true), - DISTILLATION_TOWER(true), + EnvTypeILLATION_TOWER(true), ELECTRIC_FURNACE(true), EXTRACTOR(true), FUSION_CONTROLLER(true), @@ -129,11 +128,11 @@ public enum EGui implements IMachineGuiHandler { ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.GUIFACTORY, ()-> EGui::getClientGuiElement); } - public static GuiContainer getClientGuiElement(FMLPlayMessages.OpenContainer msg) { + public static ContainerScreen getClientGuiElement(FMLPlayMessages.OpenContainer msg) { EGui gui = byID(msg.getId()); - EntityPlayer player = Minecraft.getInstance().player; + PlayerEntity player = MinecraftClient.getInstance().player; BlockPos pos = msg.getAdditionalData().readBlockPos(); - TileEntity tile = player.world.getTileEntity(pos); + BlockEntity tile = player.world.getBlockEntity(pos); switch (gui) { case AESU: @@ -216,8 +215,8 @@ public enum EGui implements IMachineGuiHandler { return new GuiAutoCrafting(player, (TileAutoCraftingTable) tile); case PLASMA_GENERATOR: return new GuiPlasmaGenerator(player, (TilePlasmaGenerator) tile); - case DISTILLATION_TOWER: - return new GuiDistillationTower(player, (TileDistillationTower) tile); + case EnvTypeILLATION_TOWER: + return new GuiEnvTypeillationTower(player, (TileEnvTypeillationTower) tile); case FLUID_REPLICATOR: return new GuiFluidReplicator(player, (TileFluidReplicator) tile); default: @@ -226,7 +225,7 @@ public enum EGui implements IMachineGuiHandler { } } - public static EGui byID(ResourceLocation resourceLocation){ + public static EGui byID(Identifier resourceLocation){ return Arrays.stream(values()) .filter(eGui -> eGui.name().toLowerCase().equals(resourceLocation.getPath())) .findFirst() @@ -234,13 +233,13 @@ public enum EGui implements IMachineGuiHandler { } @Override - public void open(EntityPlayer player, BlockPos pos, World world) { - if(!world.isRemote){ + public void open(PlayerEntity player, BlockPos pos, World world) { + if(!world.isClient){ EGui gui = this; - NetworkHooks.openGui((EntityPlayerMP) player, new IInteractionObject() { + NetworkHooks.openGui((ServerPlayerEntity) player, new IInteractionObject() { @Override - public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) { - TileEntity tileEntity = playerIn.world.getTileEntity(pos); + public Container createContainer(PlayerInventory playerInventory, PlayerEntity playerIn) { + BlockEntity tileEntity = playerIn.world.getBlockEntity(pos); if (tileEntity instanceof IContainerProvider) { return ((IContainerProvider) tileEntity).createContainer(player); } @@ -253,8 +252,8 @@ public enum EGui implements IMachineGuiHandler { } @Override - public ITextComponent getName() { - return new TextComponentString(getGuiID()); + public Component getName() { + return new TextComponent(getGuiID()); } @Override @@ -264,7 +263,7 @@ public enum EGui implements IMachineGuiHandler { @Nullable @Override - public ITextComponent getCustomName() { + public Component getCustomName() { return null; } }, packetBuffer -> packetBuffer.writeBlockPos(pos)); diff --git a/src/main/java/techreborn/client/GuiHandler.java b/src/main/java/techreborn/client/GuiHandler.java index 8f0b066aa..4e2d1b19b 100644 --- a/src/main/java/techreborn/client/GuiHandler.java +++ b/src/main/java/techreborn/client/GuiHandler.java @@ -24,11 +24,11 @@ package techreborn.client; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.common.network.IGuiHandler; + import reborncore.client.containerBuilder.IContainerProvider; import techreborn.client.container.ContainerDestructoPack; import techreborn.client.gui.*; @@ -58,11 +58,11 @@ import techreborn.tiles.storage.lesu.TileLapotronicSU; public class GuiHandler implements IGuiHandler { @Override - public Object getServerGuiElement(final int ID, final EntityPlayer player, final World world, final int x, + public Object getServerGuiElement(final int ID, final PlayerEntity player, final World world, final int x, final int y, final int z) { final EGui gui = EGui.values()[ID]; - final TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); + final BlockEntity tile = world.getBlockEntity(new BlockPos(x, y, z)); if (gui.useContainerBuilder() && tile != null) return ((IContainerProvider) tile).createContainer(player); @@ -77,10 +77,10 @@ public class GuiHandler implements IGuiHandler { } @Override - public Object getClientGuiElement(final int ID, final EntityPlayer player, final World world, final int x, + public Object getClientGuiElement(final int ID, final PlayerEntity player, final World world, final int x, final int y, final int z) { final EGui gui = EGui.values()[ID]; - final TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); + final BlockEntity tile = world.getBlockEntity(new BlockPos(x, y, z)); switch (gui) { case AESU: @@ -163,8 +163,8 @@ public class GuiHandler implements IGuiHandler { return new GuiAutoCrafting(player, (TileAutoCraftingTable) tile); case PLASMA_GENERATOR: return new GuiPlasmaGenerator(player, (TilePlasmaGenerator) tile); - case DISTILLATION_TOWER: - return new GuiDistillationTower(player, (TileDistillationTower) tile); + case EnvTypeILLATION_TOWER: + return new GuiEnvTypeillationTower(player, (TileEnvTypeillationTower) tile); case MANUAL: return new GuiManual(player); case FLUID_REPLICATOR: diff --git a/src/main/java/techreborn/client/container/ContainerDestructoPack.java b/src/main/java/techreborn/client/container/ContainerDestructoPack.java index c5d39c7a2..0f3447f24 100644 --- a/src/main/java/techreborn/client/container/ContainerDestructoPack.java +++ b/src/main/java/techreborn/client/container/ContainerDestructoPack.java @@ -24,8 +24,8 @@ package techreborn.client.container; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Slot; +import net.minecraft.container.Slot; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import reborncore.client.gui.slots.SlotFilteredVoid; import reborncore.common.container.RebornContainer; @@ -34,10 +34,10 @@ import techreborn.init.TRContent; public class ContainerDestructoPack extends RebornContainer { - private EntityPlayer player; + private PlayerEntity player; private Inventory inv; - public ContainerDestructoPack(EntityPlayer player) { + public ContainerDestructoPack(PlayerEntity player) { super(null); this.player = player; inv = new Inventory<>(1, "destructopack", 64, null); @@ -45,7 +45,7 @@ public class ContainerDestructoPack extends RebornContainer { } @Override - public boolean canInteractWith(EntityPlayer arg0) { + public boolean canUse(PlayerEntity arg0) { return true; } diff --git a/src/main/java/techreborn/client/container/builder/slot/FurnaceFuelSlot.java b/src/main/java/techreborn/client/container/builder/slot/FurnaceFuelSlot.java index a10ca09f9..979437dc0 100644 --- a/src/main/java/techreborn/client/container/builder/slot/FurnaceFuelSlot.java +++ b/src/main/java/techreborn/client/container/builder/slot/FurnaceFuelSlot.java @@ -24,10 +24,10 @@ package techreborn.client.container.builder.slot; -import net.minecraft.init.Items; +import net.minecraft.block.entity.FurnaceBlockEntity; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntityFurnace; -import net.minecraftforge.items.IItemHandler; +import net.minecraft.item.Items; + import reborncore.client.gui.slots.BaseSlot; public class FurnaceFuelSlot extends BaseSlot { @@ -37,15 +37,15 @@ public class FurnaceFuelSlot extends BaseSlot { } @Override - public boolean isItemValid(ItemStack stack) + public boolean canInsert(ItemStack stack) { - return TileEntityFurnace.isItemFuel(stack) || isBucket(stack); + return FurnaceBlockEntity.isItemFuel(stack) || isBucket(stack); } @Override - public int getItemStackLimit(ItemStack stack) + public int getMaxStackAmount(ItemStack stack) { - return isBucket(stack) ? 1 : super.getItemStackLimit(stack); + return isBucket(stack) ? 1 : super.getMaxStackAmount(stack); } public static boolean isBucket(ItemStack stack) diff --git a/src/main/java/techreborn/client/gui/GuiAESU.java b/src/main/java/techreborn/client/gui/GuiAESU.java index 885079a3a..f8bf0640c 100644 --- a/src/main/java/techreborn/client/gui/GuiAESU.java +++ b/src/main/java/techreborn/client/gui/GuiAESU.java @@ -25,7 +25,7 @@ package techreborn.client.gui; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.builder.widget.GuiButtonExtended; import reborncore.client.gui.builder.widget.GuiButtonUpDown; @@ -38,14 +38,14 @@ public class GuiAESU extends GuiBase { TileAdjustableSU tile; - public GuiAESU(final EntityPlayer player, final TileAdjustableSU aesu) { + public GuiAESU(final PlayerEntity player, final TileAdjustableSU aesu) { super(player, aesu, aesu.createContainer(player)); this.tile = aesu; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final Layer layer = Layer.BACKGROUND; this.drawSlot(62, 45, layer); @@ -56,8 +56,8 @@ public class GuiAESU extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final Layer layer = Layer.FOREGROUND; if(GuiBase.slotConfigType == SlotConfigType.NONE){ diff --git a/src/main/java/techreborn/client/gui/GuiAlloyFurnace.java b/src/main/java/techreborn/client/gui/GuiAlloyFurnace.java index eb96f6c84..135a28283 100644 --- a/src/main/java/techreborn/client/gui/GuiAlloyFurnace.java +++ b/src/main/java/techreborn/client/gui/GuiAlloyFurnace.java @@ -24,56 +24,56 @@ package techreborn.client.gui; -import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.gui.ContainerScreen; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.resource.language.I18n; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.Identifier; import techreborn.tiles.machine.iron.TileIronAlloyFurnace; -public class GuiAlloyFurnace extends GuiContainer { +public class GuiAlloyFurnace extends ContainerScreen { - private static final ResourceLocation texture = new ResourceLocation("techreborn", + private static final Identifier texture = new Identifier("techreborn", "textures/gui/alloy_furnace.png"); TileIronAlloyFurnace alloyfurnace; - public GuiAlloyFurnace(final EntityPlayer player, final TileIronAlloyFurnace alloyFurnace) { + public GuiAlloyFurnace(final PlayerEntity player, final TileIronAlloyFurnace alloyFurnace) { super(alloyFurnace.createContainer(player)); - this.xSize = 176; - this.ySize = 167; + this.containerWidth = 176; + this.containerHeight = 167; this.alloyfurnace = alloyFurnace; } @Override - protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) { + protected void drawBackground(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) { this.drawDefaultBackground(); GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(GuiAlloyFurnace.texture); - final int k = (this.width - this.xSize) / 2; - final int l = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + final int k = (this.width - this.containerWidth) / 2; + final int l = (this.height - this.containerHeight) / 2; + this.blit(k, l, 0, 0, this.containerWidth, this.containerHeight); if (this.alloyfurnace.isBurning()) { int i1 = this.alloyfurnace.getBurnTimeRemainingScaled(13); - this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1); + this.blit(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1); i1 = this.alloyfurnace.getCookProgressScaled(24); - this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16); + this.blit(k + 79, l + 34, 176, 14, i1 + 1, 16); } } @Override - protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) { - final String name = I18n.format("tile.techreborn.iron_alloy_furnace.name"); - this.fontRenderer.drawString(name, this.xSize / 2 - this.fontRenderer.getStringWidth(name) / 2, 6, + protected void drawForeground(final int p_146979_1_, final int p_146979_2_) { + final String name = I18n.translate("tile.techreborn.iron_alloy_furnace.name"); + this.font.draw(name, this.containerWidth / 2 - this.font.getStringWidth(name) / 2, 6, 4210752); - this.fontRenderer.drawString(I18n.format("container.inventory", new Object[0]), 8, - this.ySize - 96 + 2, 4210752); + this.font.draw(I18n.translate("container.inventory", new Object[0]), 8, + this.containerHeight - 96 + 2, 4210752); } @Override public void render(int mouseX, int mouseY, float partialTicks) { super.render(mouseX, mouseY, partialTicks); - this.renderHoveredToolTip(mouseX, mouseY); + this.drawMouseoverTooltip(mouseX, mouseY); } } diff --git a/src/main/java/techreborn/client/gui/GuiAlloySmelter.java b/src/main/java/techreborn/client/gui/GuiAlloySmelter.java index 291ae1498..d90be541c 100644 --- a/src/main/java/techreborn/client/gui/GuiAlloySmelter.java +++ b/src/main/java/techreborn/client/gui/GuiAlloySmelter.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.guibuilder.GuiBuilder; import techreborn.tiles.machine.tier1.TileAlloySmelter; @@ -33,15 +33,15 @@ public class GuiAlloySmelter extends GuiBase { TileAlloySmelter tile; - public GuiAlloySmelter(final EntityPlayer player, final TileAlloySmelter tile) { + public GuiAlloySmelter(final PlayerEntity player, final TileAlloySmelter tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; drawSlot(8, 72, layer); @@ -54,8 +54,8 @@ public class GuiAlloySmelter extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 55, 51, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); diff --git a/src/main/java/techreborn/client/gui/GuiAssemblingMachine.java b/src/main/java/techreborn/client/gui/GuiAssemblingMachine.java index dc277a3aa..83bc5a1d3 100644 --- a/src/main/java/techreborn/client/gui/GuiAssemblingMachine.java +++ b/src/main/java/techreborn/client/gui/GuiAssemblingMachine.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.guibuilder.GuiBuilder; import techreborn.tiles.machine.tier1.TileAssemblingMachine; @@ -33,14 +33,14 @@ public class GuiAssemblingMachine extends GuiBase { TileAssemblingMachine tile; - public GuiAssemblingMachine(final EntityPlayer player, final TileAssemblingMachine tile) { + public GuiAssemblingMachine(final PlayerEntity player, final TileAssemblingMachine tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float partialTicks, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY); + protected void drawBackground(final float partialTicks, final int mouseX, final int mouseY) { + super.drawBackground(partialTicks, mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; // Battery slot @@ -56,8 +56,8 @@ public class GuiAssemblingMachine extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); diff --git a/src/main/java/techreborn/client/gui/GuiAutoCrafting.java b/src/main/java/techreborn/client/gui/GuiAutoCrafting.java index 2dadf6a63..3a7dc03fd 100644 --- a/src/main/java/techreborn/client/gui/GuiAutoCrafting.java +++ b/src/main/java/techreborn/client/gui/GuiAutoCrafting.java @@ -24,12 +24,13 @@ package techreborn.client.gui; +import com.mojang.blaze3d.platform.GlStateManager; +import net.minecraft.client.render.GuiLighting; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.ResourceLocation; +import net.minecraft.recipe.Recipe; +import net.minecraft.util.Identifier; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.guibuilder.GuiBuilder; import reborncore.common.network.NetworkManager; @@ -43,11 +44,11 @@ import static net.minecraft.item.ItemStack.EMPTY; */ public class GuiAutoCrafting extends GuiBase { - static final ResourceLocation RECIPE_BOOK_TEXTURE = new ResourceLocation("textures/gui/recipe_book.png"); + static final Identifier RECIPE_BOOK_TEXTURE = new Identifier("textures/gui/recipe_book.png"); boolean showGui = true; TileAutoCraftingTable tileAutoCraftingTable; - public GuiAutoCrafting(EntityPlayer player, TileAutoCraftingTable tile) { + public GuiAutoCrafting(PlayerEntity player, TileAutoCraftingTable tile) { super(player, tile, tile.createContainer(player)); this.tileAutoCraftingTable = tile; } @@ -56,8 +57,8 @@ public class GuiAutoCrafting extends GuiBase { if (stack != EMPTY) { GlStateManager.enableBlend(); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); - RenderHelper.enableGUIStandardItemLighting(); - itemRender.renderItemAndEffectIntoGUI(stack, x, y); + GuiLighting.enableForItems(); + itemRenderer.renderGuiItem(stack, x, y); GlStateManager.disableLighting(); GlStateManager.pushMatrix(); GlStateManager.disableDepthTest(); @@ -71,11 +72,11 @@ public class GuiAutoCrafting extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - IRecipe recipe = tileAutoCraftingTable.getIRecipe(); + protected void drawForeground(int mouseX, int mouseY) { + super.drawForeground(mouseX, mouseY); + Recipe recipe = tileAutoCraftingTable.getIRecipe(); if (recipe != null) { - renderItemStack(recipe.getRecipeOutput(), 95, 42); + renderItemStack(recipe.getOutput(), 95, 42); } final Layer layer = Layer.FOREGROUND; @@ -84,8 +85,8 @@ public class GuiAutoCrafting extends GuiBase { } @Override - protected void drawGuiContainerBackgroundLayer(final float f, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, int mouseX, int mouseY) { + super.drawBackground(f, mouseX, mouseY); final Layer layer = Layer.BACKGROUND; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { @@ -94,7 +95,7 @@ public class GuiAutoCrafting extends GuiBase { } drawOutputSlot(145, 42, layer); drawOutputSlot(95, 42, layer); - drawString("Inventory", 8, 82, 4210752, layer); + draw("Inventory", 8, 82, 4210752, layer); builder.drawLockButton(this, 145, 4, mouseX, mouseY, layer, tileAutoCraftingTable.locked); } diff --git a/src/main/java/techreborn/client/gui/GuiBatbox.java b/src/main/java/techreborn/client/gui/GuiBatbox.java index c3c8f386d..9317a1d04 100644 --- a/src/main/java/techreborn/client/gui/GuiBatbox.java +++ b/src/main/java/techreborn/client/gui/GuiBatbox.java @@ -25,7 +25,7 @@ package techreborn.client.gui; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.common.powerSystem.PowerSystem; import techreborn.tiles.storage.TileLowVoltageSU; @@ -34,14 +34,14 @@ public class GuiBatbox extends GuiBase { TileLowVoltageSU tile; - public GuiBatbox(final EntityPlayer player, final TileLowVoltageSU tile) { + public GuiBatbox(final PlayerEntity player, final TileLowVoltageSU tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final Layer layer = Layer.BACKGROUND; drawSlot(62, 45, layer); @@ -49,8 +49,8 @@ public class GuiBatbox extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final Layer layer = Layer.FOREGROUND; if(GuiBase.slotConfigType == SlotConfigType.NONE){ diff --git a/src/main/java/techreborn/client/gui/GuiBlastFurnace.java b/src/main/java/techreborn/client/gui/GuiBlastFurnace.java index bf702afff..0a58bdfb6 100644 --- a/src/main/java/techreborn/client/gui/GuiBlastFurnace.java +++ b/src/main/java/techreborn/client/gui/GuiBlastFurnace.java @@ -24,11 +24,11 @@ package techreborn.client.gui; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.EnumFacing; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import reborncore.ClientProxy; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.builder.widget.GuiButtonExtended; @@ -44,7 +44,7 @@ public class GuiBlastFurnace extends GuiBase { public TileIndustrialBlastFurnace tile; boolean hasMultiBlock; - public GuiBlastFurnace(final EntityPlayer player, final TileIndustrialBlastFurnace tile) { + public GuiBlastFurnace(final PlayerEntity player, final TileIndustrialBlastFurnace tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @@ -57,8 +57,8 @@ public class GuiBlastFurnace extends GuiBase { } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); this.hasMultiBlock = this.tile.getCachedHeat() != 0; GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); @@ -77,8 +77,8 @@ public class GuiBlastFurnace extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); this.hasMultiBlock = tile.getCachedHeat() != 0; final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; @@ -101,7 +101,7 @@ public class GuiBlastFurnace extends GuiBase { { // This code here makes a basic multiblock and then sets to the selected one. final Multiblock multiblock = new Multiblock(); - IBlockState standardCasing = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState(); + BlockState standardCasing = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState(); this.addComponent(0, 0, 0, standardCasing, multiblock); this.addComponent(1, 0, 0, standardCasing, multiblock); @@ -145,9 +145,9 @@ public class GuiBlastFurnace extends GuiBase { ClientProxy.multiblockRenderEvent.setMultiblock(set); ClientProxy.multiblockRenderEvent.parent = tile.getPos(); MultiblockRenderEvent.anchor = new BlockPos( - tile.getPos().getX() - EnumFacing.byIndex(tile.getFacingInt()).getXOffset() * 2, + tile.getPos().getX() - Direction.byId(tile.getFacingInt()).getOffsetX() * 2, tile.getPos().getY() - 1, - tile.getPos().getZ() - EnumFacing.byIndex(tile.getFacingInt()).getZOffset() * 2); + tile.getPos().getZ() - Direction.byId(tile.getFacingInt()).getOffsetZ() * 2); } } else { ClientProxy.multiblockRenderEvent.setMultiblock(null); @@ -155,7 +155,7 @@ public class GuiBlastFurnace extends GuiBase { } } - public void addComponent(final int x, final int y, final int z, final IBlockState blockState, final Multiblock multiblock) { + public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) { multiblock.addComponent(new BlockPos(x, y, z), blockState); } diff --git a/src/main/java/techreborn/client/gui/GuiCentrifuge.java b/src/main/java/techreborn/client/gui/GuiCentrifuge.java index dbfdaaf3e..a75fd0d97 100644 --- a/src/main/java/techreborn/client/gui/GuiCentrifuge.java +++ b/src/main/java/techreborn/client/gui/GuiCentrifuge.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.guibuilder.GuiBuilder; import techreborn.tiles.TileIndustrialCentrifuge; @@ -33,14 +33,14 @@ public class GuiCentrifuge extends GuiBase { TileIndustrialCentrifuge tile; - public GuiCentrifuge(final EntityPlayer player, final TileIndustrialCentrifuge tile) { + public GuiCentrifuge(final PlayerEntity player, final TileIndustrialCentrifuge tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final Layer layer = Layer.BACKGROUND; drawSlot(8, 72, layer); @@ -57,8 +57,8 @@ public class GuiCentrifuge extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final Layer layer = Layer.FOREGROUND; builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 61, 47, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); diff --git a/src/main/java/techreborn/client/gui/GuiChargeBench.java b/src/main/java/techreborn/client/gui/GuiChargeBench.java index cf9180c0a..1709a1ec3 100644 --- a/src/main/java/techreborn/client/gui/GuiChargeBench.java +++ b/src/main/java/techreborn/client/gui/GuiChargeBench.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import techreborn.tiles.TileChargeOMat; @@ -32,14 +32,14 @@ public class GuiChargeBench extends GuiBase { TileChargeOMat tile; - public GuiChargeBench(final EntityPlayer player, final TileChargeOMat tile) { + public GuiChargeBench(final PlayerEntity player, final TileChargeOMat tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final Layer layer = Layer.BACKGROUND; drawSlot(62, 25, layer); @@ -51,8 +51,8 @@ public class GuiChargeBench extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final Layer layer = Layer.FOREGROUND; builder.drawMultiEnergyBar(this, 81, 28, (int) tile.getEnergy(), (int) tile.getMaxPower(), mouseX, mouseY, 0, layer); diff --git a/src/main/java/techreborn/client/gui/GuiChemicalReactor.java b/src/main/java/techreborn/client/gui/GuiChemicalReactor.java index be3117c80..06b48d639 100644 --- a/src/main/java/techreborn/client/gui/GuiChemicalReactor.java +++ b/src/main/java/techreborn/client/gui/GuiChemicalReactor.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.guibuilder.GuiBuilder; import techreborn.tiles.machine.tier1.TileChemicalReactor; @@ -33,14 +33,14 @@ public class GuiChemicalReactor extends GuiBase { TileChemicalReactor tile; - public GuiChemicalReactor(final EntityPlayer player, final TileChemicalReactor tile) { + public GuiChemicalReactor(final PlayerEntity player, final TileChemicalReactor tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; drawSlot(8, 72, layer); @@ -53,8 +53,8 @@ public class GuiChemicalReactor extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 55, 51, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); diff --git a/src/main/java/techreborn/client/gui/GuiChunkLoader.java b/src/main/java/techreborn/client/gui/GuiChunkLoader.java index 4cdc95b5b..c9f6b7607 100644 --- a/src/main/java/techreborn/client/gui/GuiChunkLoader.java +++ b/src/main/java/techreborn/client/gui/GuiChunkLoader.java @@ -24,42 +24,42 @@ package techreborn.client.gui; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.gui.ContainerScreen; +import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.resource.language.I18n; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.Identifier; import reborncore.client.gui.builder.widget.GuiButtonSimple; import techreborn.tiles.machine.tier3.TileChunkLoader; -public class GuiChunkLoader extends GuiContainer { +public class GuiChunkLoader extends ContainerScreen { - private static final ResourceLocation texture = new ResourceLocation("techreborn", + private static final Identifier texture = new Identifier("techreborn", "textures/gui/industrial_chunkloader.png"); TileChunkLoader chunkloader; - private GuiButton plusOneButton; - private GuiButton plusTenButton; - private GuiButton minusOneButton; - private GuiButton minusTenButton; + private ButtonWidget plusOneButton; + private ButtonWidget plusTenButton; + private ButtonWidget minusOneButton; + private ButtonWidget minusTenButton; - public GuiChunkLoader(final EntityPlayer player, final TileChunkLoader chunkLoader) { + public GuiChunkLoader(final PlayerEntity player, final TileChunkLoader chunkLoader) { super(chunkLoader.createContainer(player)); - this.xSize = 176; - this.ySize = 167; + this.containerWidth = 176; + this.containerHeight = 167; this.chunkloader = chunkLoader; } @Override public void initGui() { super.initGui(); - this.guiLeft = this.width / 2 - this.xSize / 2; - this.guiTop = this.height / 2 - this.ySize / 2; - this.plusOneButton = new GuiButtonSimple(0, this.guiLeft + 5, this.guiTop + 37, 40, 20, "+1"); - this.plusTenButton = new GuiButtonSimple(0, this.guiLeft + 45, this.guiTop + 37, 40, 20, "+10"); + this.left = this.width / 2 - this.containerWidth / 2; + this.top = this.height / 2 - this.containerHeight / 2; + this.plusOneButton = new GuiButtonSimple(0, this.left + 5, this.top + 37, 40, 20, "+1"); + this.plusTenButton = new GuiButtonSimple(0, this.left + 45, this.top + 37, 40, 20, "+10"); - this.minusOneButton = new GuiButtonSimple(0, this.guiLeft + 90, this.guiTop + 37, 40, 20, "-1"); - this.minusTenButton = new GuiButtonSimple(0, this.guiLeft + 130, this.guiTop + 37, 40, 20, "-10"); + this.minusOneButton = new GuiButtonSimple(0, this.left + 90, this.top + 37, 40, 20, "-1"); + this.minusTenButton = new GuiButtonSimple(0, this.left + 130, this.top + 37, 40, 20, "-10"); this.buttons.add(this.plusOneButton); this.buttons.add(this.plusTenButton); @@ -68,28 +68,28 @@ public class GuiChunkLoader extends GuiContainer { } @Override - protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) { + protected void drawBackground(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) { this.drawDefaultBackground(); GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(GuiChunkLoader.texture); - final int k = (this.width - this.xSize) / 2; - final int l = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + final int k = (this.width - this.containerWidth) / 2; + final int l = (this.height - this.containerHeight) / 2; + this.blit(k, l, 0, 0, this.containerWidth, this.containerHeight); } @Override - protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) { - final String name = I18n.format("tile.techreborn:chunk_loader.name"); - this.fontRenderer.drawString(name, this.xSize / 2 - this.fontRenderer.getStringWidth(name) / 2, 6, + protected void drawForeground(final int p_146979_1_, final int p_146979_2_) { + final String name = I18n.translate("tile.techreborn:chunk_loader.name"); + this.font.draw(name, this.containerWidth / 2 - this.font.getStringWidth(name) / 2, 6, 4210752); - this.fontRenderer.drawString(I18n.format("container.inventory", new Object[0]), 8, - this.ySize - 96 + 2, 4210752); + this.font.draw(I18n.translate("container.inventory", new Object[0]), 8, + this.containerHeight - 96 + 2, 4210752); } @Override public void render(int mouseX, int mouseY, float partialTicks) { super.render(mouseX, mouseY, partialTicks); - this.renderHoveredToolTip(mouseX, mouseY); + this.drawMouseoverTooltip(mouseX, mouseY); } } diff --git a/src/main/java/techreborn/client/gui/GuiCompressor.java b/src/main/java/techreborn/client/gui/GuiCompressor.java index 8f5480f0d..bbb80adb3 100644 --- a/src/main/java/techreborn/client/gui/GuiCompressor.java +++ b/src/main/java/techreborn/client/gui/GuiCompressor.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.guibuilder.GuiBuilder; import techreborn.tiles.machine.tier1.TileCompressor; @@ -33,14 +33,14 @@ public class GuiCompressor extends GuiBase { TileCompressor tile; - public GuiCompressor(final EntityPlayer player, final TileCompressor tile) { + public GuiCompressor(final PlayerEntity player, final TileCompressor tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; drawSlot(8, 72, layer); @@ -52,8 +52,8 @@ public class GuiCompressor extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; this.builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); diff --git a/src/main/java/techreborn/client/gui/GuiDestructoPack.java b/src/main/java/techreborn/client/gui/GuiDestructoPack.java index c403cae6c..174c55116 100644 --- a/src/main/java/techreborn/client/gui/GuiDestructoPack.java +++ b/src/main/java/techreborn/client/gui/GuiDestructoPack.java @@ -24,43 +24,43 @@ package techreborn.client.gui; -import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.gui.ContainerScreen; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.inventory.Container; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.resource.language.I18n; +import net.minecraft.container.Container; +import net.minecraft.util.Identifier; -public class GuiDestructoPack extends GuiContainer { +public class GuiDestructoPack extends ContainerScreen { - private static final ResourceLocation texture = new ResourceLocation("techreborn", + private static final Identifier texture = new Identifier("techreborn", "textures/gui/destructopack.png"); public GuiDestructoPack(Container container) { super(container); - this.xSize = 176; - this.ySize = 166; + this.containerWidth = 176; + this.containerHeight = 166; } @Override - protected void drawGuiContainerBackgroundLayer(float arg0, int arg1, int arg2) { + protected void drawBackground(float arg0, int arg1, int arg2) { this.drawDefaultBackground(); GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(texture); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, 176, 166); + blit(left, top, 0, 0, 176, 166); } @Override - protected void drawGuiContainerForegroundLayer(int arg0, int arg1) { - String name = I18n.format("item.techreborn.part.destructoPack.name"); - fontRenderer.drawString(name, xSize / 2 - fontRenderer.getStringWidth(name) / 2, 5, 4210752); - this.fontRenderer.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, + protected void drawForeground(int arg0, int arg1) { + String name = I18n.translate("item.techreborn.part.destructoPack.name"); + font.draw(name, containerWidth / 2 - font.getStringWidth(name) / 2, 5, 4210752); + this.font.draw(I18n.translate("container.inventory"), 8, this.containerHeight - 96 + 2, 4210752); - super.drawGuiContainerForegroundLayer(arg0, arg1); + super.drawForeground(arg0, arg1); } @Override public void render(int mouseX, int mouseY, float partialTicks) { super.render(mouseX, mouseY, partialTicks); - this.renderHoveredToolTip(mouseX, mouseY); + this.drawMouseoverTooltip(mouseX, mouseY); } } diff --git a/src/main/java/techreborn/client/gui/GuiDieselGenerator.java b/src/main/java/techreborn/client/gui/GuiDieselGenerator.java index bcccd9e81..73a6a47cb 100644 --- a/src/main/java/techreborn/client/gui/GuiDieselGenerator.java +++ b/src/main/java/techreborn/client/gui/GuiDieselGenerator.java @@ -24,26 +24,26 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.entity.player.PlayerEntity; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.guibuilder.GuiBuilder; import techreborn.tiles.generator.advanced.TileDieselGenerator; -@OnlyIn(Dist.CLIENT) +@Environment(EnvType.CLIENT) public class GuiDieselGenerator extends GuiBase { TileDieselGenerator tile; - public GuiDieselGenerator(final EntityPlayer player, final TileDieselGenerator tile) { + public GuiDieselGenerator(final PlayerEntity player, final TileDieselGenerator tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; drawSlot(25, 35, layer); drawSlot(25, 55, layer); @@ -52,8 +52,8 @@ public class GuiDieselGenerator extends GuiBase { @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; builder.drawProgressBar(this, tile.getProgressScaled(10), 100, 83, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); diff --git a/src/main/java/techreborn/client/gui/GuiDigitalChest.java b/src/main/java/techreborn/client/gui/GuiDigitalChest.java index cb19369e0..69d322890 100644 --- a/src/main/java/techreborn/client/gui/GuiDigitalChest.java +++ b/src/main/java/techreborn/client/gui/GuiDigitalChest.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import techreborn.tiles.TileDigitalChest; @@ -32,14 +32,14 @@ public class GuiDigitalChest extends GuiBase { TileDigitalChest tile; - public GuiDigitalChest(final EntityPlayer player, final TileDigitalChest tile) { + public GuiDigitalChest(final PlayerEntity player, final TileDigitalChest tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final Layer layer = Layer.BACKGROUND; drawSlot(80, 24, layer); @@ -47,18 +47,18 @@ public class GuiDigitalChest extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final Layer layer = Layer.FOREGROUND; - if (!tile.storedItem.isEmpty() && tile.inventory.getStackInSlot(1) != null) { + if (!tile.storedItem.isEmpty() && tile.inventory.getInvStack(1) != null) { builder.drawBigBlueBar(this, 31, 43, - tile.storedItem.getCount() + tile.inventory.getStackInSlot(1).getCount(), - tile.maxCapacity, mouseX - guiLeft, mouseY - guiTop, "Stored", layer); + tile.storedItem.getAmount() + tile.inventory.getInvStack(1).getAmount(), + tile.maxCapacity, mouseX - left, mouseY - top, "Stored", layer); } - if (tile.storedItem.isEmpty() && tile.inventory.getStackInSlot(1) != null) { - builder.drawBigBlueBar(this, 31, 43, tile.inventory.getStackInSlot(1).getCount(), - tile.maxCapacity, mouseX - guiLeft, mouseY - guiTop, "Stored", layer); + if (tile.storedItem.isEmpty() && tile.inventory.getInvStack(1) != null) { + builder.drawBigBlueBar(this, 31, 43, tile.inventory.getInvStack(1).getAmount(), + tile.maxCapacity, mouseX - left, mouseY - top, "Stored", layer); } } } diff --git a/src/main/java/techreborn/client/gui/GuiDistillationTower.java b/src/main/java/techreborn/client/gui/GuiDistillationTower.java index 22548bbc1..2adc2eb07 100644 --- a/src/main/java/techreborn/client/gui/GuiDistillationTower.java +++ b/src/main/java/techreborn/client/gui/GuiDistillationTower.java @@ -24,11 +24,11 @@ package techreborn.client.gui; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.EnumFacing; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import reborncore.ClientProxy; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.builder.widget.GuiButtonExtended; @@ -37,13 +37,13 @@ import reborncore.client.multiblock.Multiblock; import reborncore.client.multiblock.MultiblockRenderEvent; import reborncore.client.multiblock.MultiblockSet; import techreborn.init.TRContent; -import techreborn.tiles.machine.multiblock.TileDistillationTower; +import techreborn.tiles.machine.multiblock.TileEnvTypeillationTower; -public class GuiDistillationTower extends GuiBase { +public class GuiEnvTypeillationTower extends GuiBase { - public TileDistillationTower tile; + public TileEnvTypeillationTower tile; - public GuiDistillationTower(final EntityPlayer player, final TileDistillationTower tile) { + public GuiEnvTypeillationTower(final PlayerEntity player, final TileEnvTypeillationTower tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @@ -55,8 +55,8 @@ public class GuiDistillationTower extends GuiBase { } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); final GuiBase.Layer layer = Layer.BACKGROUND; @@ -72,8 +72,8 @@ public class GuiDistillationTower extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final GuiBase.Layer layer = Layer.FOREGROUND; builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 55, 40, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); @@ -95,8 +95,8 @@ public class GuiDistillationTower extends GuiBase { { // This code here makes a basic multiblock and then sets to the selected one. final Multiblock multiblock = new Multiblock(); - IBlockState advancedCasing = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState(); - IBlockState standardCasing = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState(); + BlockState advancedCasing = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState(); + BlockState standardCasing = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState(); addComponent(0, 0, 0, standardCasing, multiblock); addComponent(1, 0, 0, standardCasing, multiblock); @@ -140,9 +140,9 @@ public class GuiDistillationTower extends GuiBase { ClientProxy.multiblockRenderEvent.setMultiblock(set); ClientProxy.multiblockRenderEvent.parent = tile.getPos(); MultiblockRenderEvent.anchor = new BlockPos( - tile.getPos().getX() - EnumFacing.byIndex(tile.getFacingInt()).getXOffset() * 2, + tile.getPos().getX() - Direction.byId(tile.getFacingInt()).getOffsetX() * 2, tile.getPos().getY() - 1, - tile.getPos().getZ() - EnumFacing.byIndex(tile.getFacingInt()).getZOffset() * 2); + tile.getPos().getZ() - Direction.byId(tile.getFacingInt()).getOffsetZ() * 2); } } else { ClientProxy.multiblockRenderEvent.setMultiblock(null); @@ -150,7 +150,7 @@ public class GuiDistillationTower extends GuiBase { } } - public void addComponent(final int x, final int y, final int z, final IBlockState blockState, final Multiblock multiblock) { + public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) { multiblock.addComponent(new BlockPos(x, y, z), blockState); } diff --git a/src/main/java/techreborn/client/gui/GuiElectricFurnace.java b/src/main/java/techreborn/client/gui/GuiElectricFurnace.java index ecb019de4..0cbb3324d 100644 --- a/src/main/java/techreborn/client/gui/GuiElectricFurnace.java +++ b/src/main/java/techreborn/client/gui/GuiElectricFurnace.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.guibuilder.GuiBuilder; import techreborn.tiles.machine.tier1.TileElectricFurnace; @@ -33,14 +33,14 @@ public class GuiElectricFurnace extends GuiBase { TileElectricFurnace tile; - public GuiElectricFurnace(final EntityPlayer player, final TileElectricFurnace tile) { + public GuiElectricFurnace(final PlayerEntity player, final TileElectricFurnace tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY); + protected void drawBackground(float partialTicks, int mouseX, int mouseY) { + super.drawBackground(partialTicks, mouseX, mouseY); Layer layer = Layer.BACKGROUND; drawSlot(8, 72, layer); @@ -52,8 +52,8 @@ public class GuiElectricFurnace extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(int mouseX, int mouseY) { + super.drawForeground(mouseX, mouseY); Layer layer = Layer.FOREGROUND; builder.drawProgressBar(this, tile.gaugeProgressScaled(100), 100, 76, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); diff --git a/src/main/java/techreborn/client/gui/GuiExtractor.java b/src/main/java/techreborn/client/gui/GuiExtractor.java index c4391556c..ee66e9f0f 100644 --- a/src/main/java/techreborn/client/gui/GuiExtractor.java +++ b/src/main/java/techreborn/client/gui/GuiExtractor.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.guibuilder.GuiBuilder; import techreborn.tiles.machine.tier1.TileExtractor; @@ -33,14 +33,14 @@ public class GuiExtractor extends GuiBase { TileExtractor tile; - public GuiExtractor(final EntityPlayer player, final TileExtractor tile) { + public GuiExtractor(final PlayerEntity player, final TileExtractor tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; drawSlot(8, 72, layer); @@ -52,8 +52,8 @@ public class GuiExtractor extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); diff --git a/src/main/java/techreborn/client/gui/GuiFluidReplicator.java b/src/main/java/techreborn/client/gui/GuiFluidReplicator.java index 072cf9153..0b94b09c8 100644 --- a/src/main/java/techreborn/client/gui/GuiFluidReplicator.java +++ b/src/main/java/techreborn/client/gui/GuiFluidReplicator.java @@ -24,10 +24,10 @@ package techreborn.client.gui; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.EnumFacing; +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import reborncore.ClientProxy; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.builder.widget.GuiButtonExtended; @@ -46,12 +46,12 @@ public class GuiFluidReplicator extends GuiBase { TileFluidReplicator tile; - public GuiFluidReplicator(final EntityPlayer player, final TileFluidReplicator tile) { + public GuiFluidReplicator(final PlayerEntity player, final TileFluidReplicator tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } - public void addComponent(final int x, final int y, final int z, final IBlockState blockState, final Multiblock multiblock) { + public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) { multiblock.addComponent(new BlockPos(x, y, z), blockState); } @@ -63,8 +63,8 @@ public class GuiFluidReplicator extends GuiBase { } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; // Battery slot drawSlot(8, 72, layer); @@ -82,8 +82,8 @@ public class GuiFluidReplicator extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; builder.drawTank(this, 99, 25, mouseX, mouseY, tile.tank.getFluid(), tile.tank.getCapacity(), tile.tank.isEmpty(), layer); @@ -105,7 +105,7 @@ public class GuiFluidReplicator extends GuiBase { { // This code here makes a basic multiblock and then sets to the selected one. final Multiblock multiblock = new Multiblock(); - final IBlockState reinforcedCasing = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState(); + final BlockState reinforcedCasing = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState(); addComponent(1, 0, 0, reinforcedCasing, multiblock); addComponent(0, 0, 1, reinforcedCasing, multiblock); @@ -121,9 +121,9 @@ public class GuiFluidReplicator extends GuiBase { ClientProxy.multiblockRenderEvent.parent = tile.getPos(); MultiblockRenderEvent.anchor = new BlockPos( this.tile.getPos().getX() - - EnumFacing.byIndex(this.tile.getFacingInt()).getXOffset() * 2, + - Direction.byId(this.tile.getFacingInt()).getOffsetX() * 2, this.tile.getPos().getY() - 1, this.tile.getPos().getZ() - - EnumFacing.byIndex(this.tile.getFacingInt()).getZOffset() * 2); + - Direction.byId(this.tile.getFacingInt()).getOffsetZ() * 2); } } else { ClientProxy.multiblockRenderEvent.setMultiblock(null); diff --git a/src/main/java/techreborn/client/gui/GuiFusionReactor.java b/src/main/java/techreborn/client/gui/GuiFusionReactor.java index f552f8b61..3ecbaddec 100644 --- a/src/main/java/techreborn/client/gui/GuiFusionReactor.java +++ b/src/main/java/techreborn/client/gui/GuiFusionReactor.java @@ -24,8 +24,8 @@ package techreborn.client.gui; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; import org.apache.commons.lang3.tuple.Pair; import reborncore.ClientProxy; @@ -50,14 +50,14 @@ import java.util.Optional; public class GuiFusionReactor extends GuiBase { TileFusionControlComputer tile; - public GuiFusionReactor(final EntityPlayer player, final TileFusionControlComputer tile) { + public GuiFusionReactor(final PlayerEntity player, final TileFusionControlComputer tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float partialTicks, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY); + protected void drawBackground(final float partialTicks, final int mouseX, final int mouseY) { + super.drawBackground(partialTicks, mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; drawSlot(34, 47, layer); @@ -72,8 +72,8 @@ public class GuiFusionReactor extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 55, 51, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); @@ -100,8 +100,8 @@ public class GuiFusionReactor extends GuiBase { } } builder.drawUpDownButtons(this, 121, 79, layer); - drawString("Size: " + tile.size, 83, 81, 0xFFFFFF, layer); - drawString("" + tile.getPowerMultiplier() + "x", 10, 81, 0xFFFFFF, layer); + draw("Size: " + tile.size, 83, 81, 0xFFFFFF, layer); + draw("" + tile.getPowerMultiplier() + "x", 10, 81, 0xFFFFFF, layer); buttons.add(new GuiButtonUpDown(300, 121, 79, this, GuiBase.Layer.FOREGROUND)); buttons.add(new GuiButtonUpDown(301, 121 + 12, 79, this, GuiBase.Layer.FOREGROUND)); @@ -140,7 +140,7 @@ public class GuiFusionReactor extends GuiBase { private void updateMultiBlockRender(){ final Multiblock multiblock = new Multiblock(); - IBlockState coil = TRContent.Machine.FUSION_COIL.block.getDefaultState(); + BlockState coil = TRContent.Machine.FUSION_COIL.block.getDefaultState(); List coils = Torus.generate(new BlockPos(0, 0, 0), tile.size); coils.forEach(pos -> addComponent(pos.getX(), pos.getY(), pos.getZ(), coil, multiblock)); @@ -152,7 +152,7 @@ public class GuiFusionReactor extends GuiBase { tile.getPos().getZ()); } - public void addComponent(final int x, final int y, final int z, final IBlockState blockState, final Multiblock multiblock) { + public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) { multiblock.addComponent(new BlockPos(x, y, z), blockState); } diff --git a/src/main/java/techreborn/client/gui/GuiGasTurbine.java b/src/main/java/techreborn/client/gui/GuiGasTurbine.java index 2c38321e5..5b335523c 100644 --- a/src/main/java/techreborn/client/gui/GuiGasTurbine.java +++ b/src/main/java/techreborn/client/gui/GuiGasTurbine.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.guibuilder.GuiBuilder; import techreborn.tiles.generator.advanced.TileGasTurbine; @@ -33,14 +33,14 @@ public class GuiGasTurbine extends GuiBase { TileGasTurbine tile; - public GuiGasTurbine(final EntityPlayer player, final TileGasTurbine tile) { + public GuiGasTurbine(final PlayerEntity player, final TileGasTurbine tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; drawSlot(25, 35, layer); drawSlot(25, 55, layer); @@ -49,8 +49,8 @@ public class GuiGasTurbine extends GuiBase { @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; builder.drawProgressBar(this, tile.getProgressScaled(10), 100, 83, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); diff --git a/src/main/java/techreborn/client/gui/GuiGenerator.java b/src/main/java/techreborn/client/gui/GuiGenerator.java index 0cb5d1810..cf5bbdb37 100644 --- a/src/main/java/techreborn/client/gui/GuiGenerator.java +++ b/src/main/java/techreborn/client/gui/GuiGenerator.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import techreborn.tiles.generator.basic.TileSolidFuelGenerator; @@ -32,14 +32,14 @@ public class GuiGenerator extends GuiBase { TileSolidFuelGenerator tile; - public GuiGenerator(final EntityPlayer player, final TileSolidFuelGenerator tile) { + public GuiGenerator(final PlayerEntity player, final TileSolidFuelGenerator tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final Layer layer = Layer.BACKGROUND; drawSlot(8, 72, layer); @@ -50,8 +50,8 @@ public class GuiGenerator extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final Layer layer = Layer.FOREGROUND; builder.drawBurnBar(this, tile.getScaledBurnTime(100), 100, 81, 38, mouseX, mouseY, layer); diff --git a/src/main/java/techreborn/client/gui/GuiGrinder.java b/src/main/java/techreborn/client/gui/GuiGrinder.java index 09fb12fe4..51651cb00 100644 --- a/src/main/java/techreborn/client/gui/GuiGrinder.java +++ b/src/main/java/techreborn/client/gui/GuiGrinder.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.guibuilder.GuiBuilder; import techreborn.tiles.machine.tier1.TileGrinder; @@ -33,14 +33,14 @@ public class GuiGrinder extends GuiBase { TileGrinder tile; - public GuiGrinder(final EntityPlayer player, final TileGrinder tile) { + public GuiGrinder(final PlayerEntity player, final TileGrinder tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; drawSlot(8, 72, layer); @@ -52,8 +52,8 @@ public class GuiGrinder extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); diff --git a/src/main/java/techreborn/client/gui/GuiIDSU.java b/src/main/java/techreborn/client/gui/GuiIDSU.java index 84fc75c34..08545444a 100644 --- a/src/main/java/techreborn/client/gui/GuiIDSU.java +++ b/src/main/java/techreborn/client/gui/GuiIDSU.java @@ -25,7 +25,7 @@ package techreborn.client.gui; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.common.powerSystem.PowerSystem; import techreborn.tiles.storage.idsu.TileInterdimensionalSU; @@ -34,14 +34,14 @@ public class GuiIDSU extends GuiBase { TileInterdimensionalSU idsu; - public GuiIDSU(EntityPlayer player, TileInterdimensionalSU tileIDSU) { + public GuiIDSU(PlayerEntity player, TileInterdimensionalSU tileIDSU) { super(player, tileIDSU, tileIDSU.createContainer(player)); idsu = tileIDSU; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final Layer layer = Layer.BACKGROUND; drawSlot(62, 45, layer); @@ -50,8 +50,8 @@ public class GuiIDSU extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final Layer layer = Layer.FOREGROUND; GlStateManager.pushMatrix(); diff --git a/src/main/java/techreborn/client/gui/GuiImplosionCompressor.java b/src/main/java/techreborn/client/gui/GuiImplosionCompressor.java index 878ee328a..a8ee4390d 100644 --- a/src/main/java/techreborn/client/gui/GuiImplosionCompressor.java +++ b/src/main/java/techreborn/client/gui/GuiImplosionCompressor.java @@ -24,9 +24,9 @@ package techreborn.client.gui; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; import reborncore.ClientProxy; import reborncore.client.gui.builder.GuiBase; @@ -42,7 +42,7 @@ public class GuiImplosionCompressor extends GuiBase { TileImplosionCompressor tile; - public GuiImplosionCompressor(final EntityPlayer player, final TileImplosionCompressor tile) { + public GuiImplosionCompressor(final PlayerEntity player, final TileImplosionCompressor tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @@ -54,8 +54,8 @@ public class GuiImplosionCompressor extends GuiBase { } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); final GuiBase.Layer layer = Layer.BACKGROUND; @@ -75,8 +75,8 @@ public class GuiImplosionCompressor extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final GuiBase.Layer layer = Layer.FOREGROUND; builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 71, 40, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); @@ -118,7 +118,7 @@ public class GuiImplosionCompressor extends GuiBase { } } - public void addComponent(final int x, final int y, final int z, final IBlockState blockState, final Multiblock multiblock) { + public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) { multiblock.addComponent(new BlockPos(x, y, z), blockState); } } diff --git a/src/main/java/techreborn/client/gui/GuiIndustrialElectrolyzer.java b/src/main/java/techreborn/client/gui/GuiIndustrialElectrolyzer.java index 7f43f1dbd..d45abb915 100644 --- a/src/main/java/techreborn/client/gui/GuiIndustrialElectrolyzer.java +++ b/src/main/java/techreborn/client/gui/GuiIndustrialElectrolyzer.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.guibuilder.GuiBuilder; import techreborn.tiles.machine.tier1.TileIndustrialElectrolyzer; @@ -33,14 +33,14 @@ public class GuiIndustrialElectrolyzer extends GuiBase { TileIndustrialElectrolyzer tile; - public GuiIndustrialElectrolyzer(final EntityPlayer player, final TileIndustrialElectrolyzer tile) { + public GuiIndustrialElectrolyzer(final PlayerEntity player, final TileIndustrialElectrolyzer tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; //Battery slot @@ -54,8 +54,8 @@ public class GuiIndustrialElectrolyzer extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 84, 52, mouseX, mouseY, GuiBuilder.ProgressDirection.UP, layer); diff --git a/src/main/java/techreborn/client/gui/GuiIndustrialGrinder.java b/src/main/java/techreborn/client/gui/GuiIndustrialGrinder.java index 7e15ad5e5..c59eb4b44 100644 --- a/src/main/java/techreborn/client/gui/GuiIndustrialGrinder.java +++ b/src/main/java/techreborn/client/gui/GuiIndustrialGrinder.java @@ -24,11 +24,11 @@ package techreborn.client.gui; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.util.EnumFacing; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import reborncore.ClientProxy; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.builder.widget.GuiButtonExtended; @@ -43,7 +43,7 @@ public class GuiIndustrialGrinder extends GuiBase { TileIndustrialGrinder tile; - public GuiIndustrialGrinder(final EntityPlayer player, final TileIndustrialGrinder tile) { + public GuiIndustrialGrinder(final PlayerEntity player, final TileIndustrialGrinder tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @@ -55,8 +55,8 @@ public class GuiIndustrialGrinder extends GuiBase { } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final Layer layer = Layer.BACKGROUND; // Battery slot @@ -80,8 +80,8 @@ public class GuiIndustrialGrinder extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final Layer layer = Layer.FOREGROUND; builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 105, 47, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); @@ -102,8 +102,8 @@ public class GuiIndustrialGrinder extends GuiBase { { // This code here makes a basic multiblock and then sets to the selected one. final Multiblock multiblock = new Multiblock(); - IBlockState standardCasing = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState(); - IBlockState reinforcedCasing = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState(); + BlockState standardCasing = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState(); + BlockState reinforcedCasing = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState(); addComponent(0, -1, 0, standardCasing, multiblock); addComponent(1, -1, 0, standardCasing, multiblock); @@ -141,9 +141,9 @@ public class GuiIndustrialGrinder extends GuiBase { ClientProxy.multiblockRenderEvent.parent = tile.getPos(); MultiblockRenderEvent.anchor = new BlockPos( this.tile.getPos().getX() - - EnumFacing.byIndex(this.tile.getFacingInt()).getXOffset() * 2, + - Direction.byId(this.tile.getFacingInt()).getOffsetX() * 2, this.tile.getPos().getY() - 1, this.tile.getPos().getZ() - - EnumFacing.byIndex(this.tile.getFacingInt()).getZOffset() * 2); + - Direction.byId(this.tile.getFacingInt()).getOffsetZ() * 2); } } else { ClientProxy.multiblockRenderEvent.setMultiblock(null); @@ -151,7 +151,7 @@ public class GuiIndustrialGrinder extends GuiBase { } } - public void addComponent(final int x, final int y, final int z, final IBlockState blockState, final Multiblock multiblock) { + public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) { multiblock.addComponent(new BlockPos(x, y, z), blockState); } diff --git a/src/main/java/techreborn/client/gui/GuiIndustrialSawmill.java b/src/main/java/techreborn/client/gui/GuiIndustrialSawmill.java index 5bc283708..668a91479 100644 --- a/src/main/java/techreborn/client/gui/GuiIndustrialSawmill.java +++ b/src/main/java/techreborn/client/gui/GuiIndustrialSawmill.java @@ -24,11 +24,11 @@ package techreborn.client.gui; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.util.EnumFacing; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import reborncore.ClientProxy; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.builder.widget.GuiButtonExtended; @@ -43,7 +43,7 @@ public class GuiIndustrialSawmill extends GuiBase { TileIndustrialSawmill tile; - public GuiIndustrialSawmill(final EntityPlayer player, final TileIndustrialSawmill tile) { + public GuiIndustrialSawmill(final PlayerEntity player, final TileIndustrialSawmill tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @@ -55,8 +55,8 @@ public class GuiIndustrialSawmill extends GuiBase { } @Override - protected void drawGuiContainerBackgroundLayer(final float partialTicks, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY); + protected void drawBackground(final float partialTicks, final int mouseX, final int mouseY) { + super.drawBackground(partialTicks, mouseX, mouseY); final Layer layer = Layer.BACKGROUND; // Battery slot @@ -79,8 +79,8 @@ public class GuiIndustrialSawmill extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final Layer layer = Layer.FOREGROUND; builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 105, 47, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); @@ -101,8 +101,8 @@ public class GuiIndustrialSawmill extends GuiBase { { // This code here makes a basic multiblock and then sets to the selected one. final Multiblock multiblock = new Multiblock(); - IBlockState standardCasing = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState(); - IBlockState reinforcedCasing = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState(); + BlockState standardCasing = TRContent.MachineBlocks.BASIC.getCasing().getDefaultState(); + BlockState reinforcedCasing = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState(); addComponent(0, -1, 0, standardCasing, multiblock); addComponent(1, -1, 0, standardCasing, multiblock); @@ -140,9 +140,9 @@ public class GuiIndustrialSawmill extends GuiBase { ClientProxy.multiblockRenderEvent.parent = tile.getPos(); MultiblockRenderEvent.anchor = new BlockPos( this.tile.getPos().getX() - - EnumFacing.byIndex(this.tile.getFacingInt()).getYOffset() * 2, + - Direction.byId(this.tile.getFacingInt()).getOffsetY() * 2, this.tile.getPos().getY() - 1, this.tile.getPos().getZ() - - EnumFacing.byIndex(this.tile.getFacingInt()).getYOffset() * 2); + - Direction.byId(this.tile.getFacingInt()).getOffsetY() * 2); } } else { ClientProxy.multiblockRenderEvent.setMultiblock(null); @@ -150,7 +150,7 @@ public class GuiIndustrialSawmill extends GuiBase { } } - public void addComponent(final int x, final int y, final int z, final IBlockState blockState, final Multiblock multiblock) { + public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) { multiblock.addComponent(new BlockPos(x, y, z), blockState); } } diff --git a/src/main/java/techreborn/client/gui/GuiIronFurnace.java b/src/main/java/techreborn/client/gui/GuiIronFurnace.java index d3c6c38f3..210f93615 100644 --- a/src/main/java/techreborn/client/gui/GuiIronFurnace.java +++ b/src/main/java/techreborn/client/gui/GuiIronFurnace.java @@ -25,64 +25,64 @@ package techreborn.client.gui; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.client.resource.language.I18n; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Identifier; import reborncore.client.gui.builder.GuiBase; import techreborn.init.TRContent; import techreborn.tiles.machine.iron.TileIronFurnace; public class GuiIronFurnace extends GuiBase { - public static final ResourceLocation texture = new ResourceLocation("minecraft", + public static final Identifier texture = new Identifier("minecraft", "textures/gui/container/furnace.png"); TileIronFurnace furnace; - public GuiIronFurnace(final EntityPlayer player, final TileIronFurnace furnace) { + public GuiIronFurnace(final PlayerEntity player, final TileIronFurnace furnace) { super(player, furnace, furnace.createContainer(player)); - this.xSize = 176; - this.ySize = 167; + this.containerWidth = 176; + this.containerHeight = 167; this.furnace = furnace; } @Override - protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { + protected void drawBackground(float partialTicks, int mouseX, int mouseY) { drawDefaultBackground(); GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); - builder.drawSlotTab(this, guiLeft - 24, guiTop + 6, new ItemStack(TRContent.WRENCH)); + builder.drawSlotTab(this, left - 24, top + 6, new ItemStack(TRContent.WRENCH)); mc.getTextureManager().bindTexture(GuiIronFurnace.texture); - final int k = (this.width - xSize) / 2; - final int l = (this.height - ySize) / 2; - drawTexturedModalRect(k, l, 0, 0, xSize, ySize); + final int k = (this.width - containerWidth) / 2; + final int l = (this.height - containerHeight) / 2; + blit(k, l, 0, 0, containerWidth, containerHeight); int j = 0; j = furnace.gaugeProgressScaled(24); if (j > 0) { - drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16); + blit(k + 78, l + 35, 176, 14, j + 1, 16); } j = furnace.gaugeFuelScaled(12); if (j > 0) { - drawTexturedModalRect(k + 57, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); + blit(k + 57, l + 36 + 12 - j, 176, 12 - j, 14, j + 2); } } @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - final String name = I18n.format("tile.techreborn.iron_furnace.name"); - fontRenderer.drawString(name, xSize / 2 - fontRenderer.getStringWidth(name) / 2, 6, 4210752); - fontRenderer.drawString(I18n.format("container.inventory", new Object[0]), 8, ySize - 96 + 2, 4210752); + protected void drawForeground(int mouseX, int mouseY) { + final String name = I18n.translate("tile.techreborn.iron_furnace.name"); + font.draw(name, containerWidth / 2 - font.getStringWidth(name) / 2, 6, 4210752); + font.draw(I18n.translate("container.inventory", new Object[0]), 8, containerHeight - 96 + 2, 4210752); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + super.drawForeground(mouseX, mouseY); } @Override public void render(int mouseX, int mouseY, float partialTicks) { super.render(mouseX, mouseY, partialTicks); - renderHoveredToolTip(mouseX, mouseY); + drawMouseoverTooltip(mouseX, mouseY); } } diff --git a/src/main/java/techreborn/client/gui/GuiLESU.java b/src/main/java/techreborn/client/gui/GuiLESU.java index b41511906..f5229d17b 100644 --- a/src/main/java/techreborn/client/gui/GuiLESU.java +++ b/src/main/java/techreborn/client/gui/GuiLESU.java @@ -25,7 +25,7 @@ package techreborn.client.gui; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.common.powerSystem.PowerSystem; import techreborn.tiles.storage.lesu.TileLapotronicSU; @@ -34,14 +34,14 @@ public class GuiLESU extends GuiBase { TileLapotronicSU tile; - public GuiLESU(final EntityPlayer player, final TileLapotronicSU tile) { + public GuiLESU(final PlayerEntity player, final TileLapotronicSU tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final Layer layer = Layer.BACKGROUND; drawSlot(62, 45, layer); @@ -50,8 +50,8 @@ public class GuiLESU extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final Layer layer = Layer.FOREGROUND; GlStateManager.pushMatrix(); diff --git a/src/main/java/techreborn/client/gui/GuiMFE.java b/src/main/java/techreborn/client/gui/GuiMFE.java index 7b6ac3250..880db2bcc 100644 --- a/src/main/java/techreborn/client/gui/GuiMFE.java +++ b/src/main/java/techreborn/client/gui/GuiMFE.java @@ -25,7 +25,7 @@ package techreborn.client.gui; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.common.powerSystem.PowerSystem; import techreborn.tiles.storage.TileMediumVoltageSU; @@ -34,14 +34,14 @@ public class GuiMFE extends GuiBase { TileMediumVoltageSU mfe; - public GuiMFE(final EntityPlayer player, final TileMediumVoltageSU mfe) { + public GuiMFE(final PlayerEntity player, final TileMediumVoltageSU mfe) { super(player, mfe, mfe.createContainer(player)); this.mfe = mfe; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final Layer layer = Layer.BACKGROUND; drawSlot(62, 45, layer); @@ -50,8 +50,8 @@ public class GuiMFE extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final Layer layer = Layer.FOREGROUND; if(GuiBase.slotConfigType == SlotConfigType.NONE){ diff --git a/src/main/java/techreborn/client/gui/GuiMFSU.java b/src/main/java/techreborn/client/gui/GuiMFSU.java index bed5877e5..a75983e61 100644 --- a/src/main/java/techreborn/client/gui/GuiMFSU.java +++ b/src/main/java/techreborn/client/gui/GuiMFSU.java @@ -24,8 +24,9 @@ package techreborn.client.gui; +import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.common.powerSystem.PowerSystem; import techreborn.tiles.storage.TileHighVoltageSU; @@ -34,14 +35,14 @@ public class GuiMFSU extends GuiBase { TileHighVoltageSU mfsu; - public GuiMFSU(final EntityPlayer player, final TileHighVoltageSU mfsu) { + public GuiMFSU(final PlayerEntity player, final TileHighVoltageSU mfsu) { super(player, mfsu, mfsu.createContainer(player)); this.mfsu = mfsu; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final Layer layer = Layer.BACKGROUND; drawSlot(62, 45, layer); @@ -50,8 +51,8 @@ public class GuiMFSU extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final Layer layer = Layer.FOREGROUND; GlStateManager.pushMatrix(); diff --git a/src/main/java/techreborn/client/gui/GuiManual.java b/src/main/java/techreborn/client/gui/GuiManual.java index d31e67d4a..9f79b8683 100644 --- a/src/main/java/techreborn/client/gui/GuiManual.java +++ b/src/main/java/techreborn/client/gui/GuiManual.java @@ -24,11 +24,6 @@ package techreborn.client.gui; -import net.minecraft.client.gui.GuiConfirmOpenLink; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ResourceLocation; import reborncore.client.gui.builder.widget.GuiButtonExtended; import reborncore.common.network.NetworkManager; @@ -36,21 +31,26 @@ import techreborn.items.ItemManual; import techreborn.packets.ServerboundPackets; import java.awt.*; +import net.minecraft.client.gui.Screen; +import net.minecraft.client.gui.ingame.ConfirmChatLinkScreen; +import net.minecraft.client.resource.language.I18n; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.Identifier; -public class GuiManual extends GuiScreen { +public class GuiManual extends Screen { ItemManual manual; - EntityPlayer player; + PlayerEntity player; - private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/manual.png"); + private static final Identifier texture = new Identifier("techreborn", "textures/gui/manual.png"); int guiWidth = 207; int guiHeight = 195; - private static final String text1 = I18n.format("techreborn.manual.wiki"); - private static final String text2 = I18n.format("techreborn.manual.discord"); - private static final String text3 = I18n.format("techreborn.manual.refund"); + private static final String text1 = I18n.translate("techreborn.manual.wiki"); + private static final String text2 = I18n.translate("techreborn.manual.discord"); + private static final String text3 = I18n.translate("techreborn.manual.refund"); - public GuiManual(EntityPlayer player) { + public GuiManual(PlayerEntity player) { this.player = player; } @@ -62,10 +62,10 @@ public class GuiManual extends GuiScreen { @Override public void initGui() { int y = height / 4; - buttons.add(new GuiButtonExtended(1, (width / 2 - 30), y + 10, 60, 20, I18n.format("techreborn.manual.wikibtn"))); - buttons.add(new GuiButtonExtended(2, (width / 2 - 30), y + 60, 60, 20, I18n.format("techreborn.manual.discordbtn"))); + buttons.add(new GuiButtonExtended(1, (width / 2 - 30), y + 10, 60, 20, I18n.translate("techreborn.manual.wikibtn"))); + buttons.add(new GuiButtonExtended(2, (width / 2 - 30), y + 60, 60, 20, I18n.translate("techreborn.manual.discordbtn"))); if(ItemManual.allowRefund){ - buttons.add(new GuiButtonExtended(3, (width / 2 - 30), y + 110, 60, 20, I18n.format("techreborn.manual.refundbtn"))); + buttons.add(new GuiButtonExtended(3, (width / 2 - 30), y + 110, 60, 20, I18n.translate("techreborn.manual.refundbtn"))); } } @@ -75,12 +75,12 @@ public class GuiManual extends GuiScreen { mc.getTextureManager().bindTexture(GuiManual.texture); int centerX = (width / 2) - guiWidth / 2; int centerY = (height / 2) - guiHeight / 2; - drawTexturedModalRect(centerX, centerY, 0, 0, guiWidth, guiHeight); + blit(centerX, centerY, 0, 0, guiWidth, guiHeight); int y = height / 4; - fontRenderer.drawString(text1, ((width / 2) - fontRenderer.getStringWidth(text1) / 2), height / 2 - (guiHeight / 4), 4210752); - fontRenderer.drawString(text2, ((width / 2) - fontRenderer.getStringWidth(text2) / 2), height / 2 + 5, 4210752); + font.draw(text1, ((width / 2) - font.getStringWidth(text1) / 2), height / 2 - (guiHeight / 4), 4210752); + font.draw(text2, ((width / 2) - font.getStringWidth(text2) / 2), height / 2 + 5, 4210752); if(ItemManual.allowRefund){ - fontRenderer.drawString(text3, ((width / 2) - fontRenderer.getStringWidth(text3) / 2), y + 100, 4210752); + font.draw(text3, ((width / 2) - font.getStringWidth(text3) / 2), y + 100, 4210752); } super.render(mouseX, mouseY, partialTicks); } @@ -88,10 +88,10 @@ public class GuiManual extends GuiScreen { public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY){ switch (button.id) { case 1: - mc.displayGuiScreen(new GuiConfirmOpenLink(this, "http://wiki.techreborn.ovh", 1, false)); + mc.displayGuiScreen(new ConfirmChatLinkScreen(this, "http://wiki.techreborn.ovh", 1, false)); break; case 2: - this.mc.displayGuiScreen(new GuiConfirmOpenLink(this, "https://discord.gg/teamreborn", 2, false)); + this.mc.displayGuiScreen(new ConfirmChatLinkScreen(this, "https://discord.gg/teamreborn", 2, false)); break; case 3: mc.displayGuiScreen(null); diff --git a/src/main/java/techreborn/client/gui/GuiMatterFabricator.java b/src/main/java/techreborn/client/gui/GuiMatterFabricator.java index c0baa8036..5b458168b 100644 --- a/src/main/java/techreborn/client/gui/GuiMatterFabricator.java +++ b/src/main/java/techreborn/client/gui/GuiMatterFabricator.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.guibuilder.GuiBuilder; import techreborn.tiles.machine.tier3.TileMatterFabricator; @@ -33,14 +33,14 @@ public class GuiMatterFabricator extends GuiBase { TileMatterFabricator tile; - public GuiMatterFabricator(final EntityPlayer player, final TileMatterFabricator tile) { + public GuiMatterFabricator(final PlayerEntity player, final TileMatterFabricator tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final Layer layer = Layer.BACKGROUND; drawSlot(8, 72, layer); @@ -56,8 +56,8 @@ public class GuiMatterFabricator extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final Layer layer = Layer.FOREGROUND; builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 83, 41, mouseX, mouseY, GuiBuilder.ProgressDirection.DOWN, layer); diff --git a/src/main/java/techreborn/client/gui/GuiPlasmaGenerator.java b/src/main/java/techreborn/client/gui/GuiPlasmaGenerator.java index 74feb0dc7..9b2ff8df4 100644 --- a/src/main/java/techreborn/client/gui/GuiPlasmaGenerator.java +++ b/src/main/java/techreborn/client/gui/GuiPlasmaGenerator.java @@ -24,9 +24,9 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.entity.player.PlayerEntity; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.guibuilder.GuiBuilder; import techreborn.tiles.generator.TilePlasmaGenerator; @@ -35,7 +35,7 @@ import techreborn.tiles.generator.TilePlasmaGenerator; * @author drcrazy * */ -@OnlyIn(Dist.CLIENT) +@Environment(EnvType.CLIENT) public class GuiPlasmaGenerator extends GuiBase { /** @@ -45,14 +45,14 @@ public class GuiPlasmaGenerator extends GuiBase { */ TilePlasmaGenerator tile; - public GuiPlasmaGenerator(final EntityPlayer player, final TilePlasmaGenerator tile) { + public GuiPlasmaGenerator(final PlayerEntity player, final TilePlasmaGenerator tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; drawSlot(25, 35, layer); drawSlot(25, 55, layer); @@ -61,8 +61,8 @@ public class GuiPlasmaGenerator extends GuiBase { @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; builder.drawProgressBar(this, tile.getProgressScaled(10), 100, 83, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); diff --git a/src/main/java/techreborn/client/gui/GuiQuantumChest.java b/src/main/java/techreborn/client/gui/GuiQuantumChest.java index 3249ad1af..8abf1326d 100644 --- a/src/main/java/techreborn/client/gui/GuiQuantumChest.java +++ b/src/main/java/techreborn/client/gui/GuiQuantumChest.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import techreborn.tiles.machine.tier3.TileQuantumChest; @@ -32,14 +32,14 @@ public class GuiQuantumChest extends GuiBase { TileQuantumChest quantumChest; - public GuiQuantumChest(final EntityPlayer player, final TileQuantumChest quantumChest) { + public GuiQuantumChest(final PlayerEntity player, final TileQuantumChest quantumChest) { super(player, quantumChest, quantumChest.createContainer(player)); this.quantumChest = quantumChest; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final Layer layer = Layer.BACKGROUND; drawSlot(80, 24, layer); @@ -47,15 +47,15 @@ public class GuiQuantumChest extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final Layer layer = Layer.FOREGROUND; - if (!this.quantumChest.storedItem.isEmpty() && !this.quantumChest.inventory.getStackInSlot(1).isEmpty()) { - this.builder.drawBigBlueBar(this, 31, 43, this.quantumChest.storedItem.getCount() + this.quantumChest.inventory.getStackInSlot(1).getCount(), this.quantumChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer); + if (!this.quantumChest.storedItem.isEmpty() && !this.quantumChest.inventory.getInvStack(1).isEmpty()) { + this.builder.drawBigBlueBar(this, 31, 43, this.quantumChest.storedItem.getAmount() + this.quantumChest.inventory.getInvStack(1).getAmount(), this.quantumChest.maxCapacity, mouseX - this.left, mouseY - this.top, "Stored", layer); } - if (this.quantumChest.storedItem.isEmpty() && !this.quantumChest.inventory.getStackInSlot(1).isEmpty()) { - this.builder.drawBigBlueBar(this, 31, 43, this.quantumChest.inventory.getStackInSlot(1).getCount(), this.quantumChest.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer); + if (this.quantumChest.storedItem.isEmpty() && !this.quantumChest.inventory.getInvStack(1).isEmpty()) { + this.builder.drawBigBlueBar(this, 31, 43, this.quantumChest.inventory.getInvStack(1).getAmount(), this.quantumChest.maxCapacity, mouseX - this.left, mouseY - this.top, "Stored", layer); } } } diff --git a/src/main/java/techreborn/client/gui/GuiQuantumTank.java b/src/main/java/techreborn/client/gui/GuiQuantumTank.java index e112351a2..d4c266556 100644 --- a/src/main/java/techreborn/client/gui/GuiQuantumTank.java +++ b/src/main/java/techreborn/client/gui/GuiQuantumTank.java @@ -24,8 +24,8 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.fluids.FluidStack; +import net.minecraft.entity.player.PlayerEntity; + import reborncore.client.gui.builder.GuiBase; import techreborn.tiles.machine.tier3.TileQuantumTank; @@ -33,14 +33,14 @@ public class GuiQuantumTank extends GuiBase { TileQuantumTank quantumTank; - public GuiQuantumTank(final EntityPlayer player, final TileQuantumTank quantumTank) { + public GuiQuantumTank(final PlayerEntity player, final TileQuantumTank quantumTank) { super(player, quantumTank, quantumTank.createContainer(player)); this.quantumTank = quantumTank; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; drawSlot(80, 17, layer); @@ -49,16 +49,16 @@ public class GuiQuantumTank extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); FluidStack fluid = quantumTank.tank.getFluid(); if(fluid != null){ - fontRenderer.drawString( "Fluid Type:", 10, 20, 4210752); - fontRenderer.drawString(fluid.getLocalizedName() + "", 10, 30, 4210752); + font.draw( "Fluid Type:", 10, 20, 4210752); + font.draw(fluid.getLocalizedName() + "", 10, 30, 4210752); - fontRenderer.drawString("Fluid Amount:", 10, 50, 4210752); - fontRenderer.drawString(quantumTank.tank.getFluidAmount() + "mb", 10, 60, 4210752); + font.draw("Fluid Amount:", 10, 50, 4210752); + font.draw(quantumTank.tank.getFluidAmount() + "mb", 10, 60, 4210752); } } @@ -66,6 +66,6 @@ public class GuiQuantumTank extends GuiBase { @Override public void render(int mouseX, int mouseY, float partialTicks) { super.render(mouseX, mouseY, partialTicks); - renderHoveredToolTip(mouseX, mouseY); + drawMouseoverTooltip(mouseX, mouseY); } } diff --git a/src/main/java/techreborn/client/gui/GuiRecycler.java b/src/main/java/techreborn/client/gui/GuiRecycler.java index a9328eb50..01233eef8 100644 --- a/src/main/java/techreborn/client/gui/GuiRecycler.java +++ b/src/main/java/techreborn/client/gui/GuiRecycler.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.guibuilder.GuiBuilder; import techreborn.tiles.machine.tier1.TileRecycler; @@ -33,14 +33,14 @@ public class GuiRecycler extends GuiBase { TileRecycler tile; - public GuiRecycler(final EntityPlayer player, final TileRecycler tile) { + public GuiRecycler(final PlayerEntity player, final TileRecycler tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; drawSlot(8, 72, layer); @@ -50,8 +50,8 @@ public class GuiRecycler extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; builder.drawProgressBar(this, tile.gaugeProgressScaled(100), 100, 76, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); diff --git a/src/main/java/techreborn/client/gui/GuiRollingMachine.java b/src/main/java/techreborn/client/gui/GuiRollingMachine.java index 098bacd41..652af814c 100644 --- a/src/main/java/techreborn/client/gui/GuiRollingMachine.java +++ b/src/main/java/techreborn/client/gui/GuiRollingMachine.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.guibuilder.GuiBuilder; import reborncore.common.network.NetworkManager; @@ -35,14 +35,14 @@ public class GuiRollingMachine extends GuiBase { TileRollingMachine rollingMachine; - public GuiRollingMachine(final EntityPlayer player, final TileRollingMachine tileRollingmachine) { + public GuiRollingMachine(final PlayerEntity player, final TileRollingMachine tileRollingmachine) { super(player, tileRollingmachine, tileRollingmachine.createContainer(player)); this.rollingMachine = tileRollingmachine; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; int gridYPos = 22; @@ -64,8 +64,8 @@ public class GuiRollingMachine extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; builder.drawProgressBar(this, rollingMachine.getProgressScaled(100), 100, 92, 43, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); diff --git a/src/main/java/techreborn/client/gui/GuiScrapboxinator.java b/src/main/java/techreborn/client/gui/GuiScrapboxinator.java index 276a4005f..27ffb1b2c 100644 --- a/src/main/java/techreborn/client/gui/GuiScrapboxinator.java +++ b/src/main/java/techreborn/client/gui/GuiScrapboxinator.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.guibuilder.GuiBuilder; import techreborn.tiles.machine.tier1.TileScrapboxinator; @@ -33,14 +33,14 @@ public class GuiScrapboxinator extends GuiBase { TileScrapboxinator tile; - public GuiScrapboxinator(final EntityPlayer player, final TileScrapboxinator tile) { + public GuiScrapboxinator(final PlayerEntity player, final TileScrapboxinator tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY); + protected void drawBackground(float partialTicks, int mouseX, int mouseY) { + super.drawBackground(partialTicks, mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; // Battery slot @@ -54,8 +54,8 @@ public class GuiScrapboxinator extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); diff --git a/src/main/java/techreborn/client/gui/GuiSemifluidGenerator.java b/src/main/java/techreborn/client/gui/GuiSemifluidGenerator.java index 03bba60e5..4a866d280 100644 --- a/src/main/java/techreborn/client/gui/GuiSemifluidGenerator.java +++ b/src/main/java/techreborn/client/gui/GuiSemifluidGenerator.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.guibuilder.GuiBuilder; import techreborn.tiles.generator.advanced.TileSemiFluidGenerator; @@ -33,14 +33,14 @@ public class GuiSemifluidGenerator extends GuiBase { TileSemiFluidGenerator tile; - public GuiSemifluidGenerator(final EntityPlayer player, final TileSemiFluidGenerator tile) { + public GuiSemifluidGenerator(final PlayerEntity player, final TileSemiFluidGenerator tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; drawSlot(25, 35, layer); drawSlot(25, 55, layer); @@ -49,8 +49,8 @@ public class GuiSemifluidGenerator extends GuiBase { @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; builder.drawProgressBar(this, tile.getProgressScaled(10), 100, 83, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); diff --git a/src/main/java/techreborn/client/gui/GuiThermalGenerator.java b/src/main/java/techreborn/client/gui/GuiThermalGenerator.java index c35d5a754..b318380e7 100644 --- a/src/main/java/techreborn/client/gui/GuiThermalGenerator.java +++ b/src/main/java/techreborn/client/gui/GuiThermalGenerator.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.guibuilder.GuiBuilder; import techreborn.tiles.generator.advanced.TileThermalGenerator; @@ -33,14 +33,14 @@ public class GuiThermalGenerator extends GuiBase { TileThermalGenerator tile; - public GuiThermalGenerator(final EntityPlayer player, final TileThermalGenerator tile) { + public GuiThermalGenerator(final PlayerEntity player, final TileThermalGenerator tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; drawSlot(25, 35, layer); drawSlot(25, 55, layer); @@ -49,8 +49,8 @@ public class GuiThermalGenerator extends GuiBase { @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; builder.drawProgressBar(this, tile.getProgressScaled(10), 100, 83, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); diff --git a/src/main/java/techreborn/client/gui/GuiVacuumFreezer.java b/src/main/java/techreborn/client/gui/GuiVacuumFreezer.java index 0792bad23..e9abfe586 100644 --- a/src/main/java/techreborn/client/gui/GuiVacuumFreezer.java +++ b/src/main/java/techreborn/client/gui/GuiVacuumFreezer.java @@ -24,8 +24,8 @@ package techreborn.client.gui; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; import reborncore.ClientProxy; import reborncore.client.gui.builder.GuiBase; @@ -41,7 +41,7 @@ public class GuiVacuumFreezer extends GuiBase { TileVacuumFreezer tile; - public GuiVacuumFreezer(final EntityPlayer player, final TileVacuumFreezer tile) { + public GuiVacuumFreezer(final PlayerEntity player, final TileVacuumFreezer tile) { super(player, tile, tile.createContainer(player)); this.tile = tile; } @@ -53,8 +53,8 @@ public class GuiVacuumFreezer extends GuiBase { } @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + protected void drawBackground(final float f, final int mouseX, final int mouseY) { + super.drawBackground(f, mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND; // Battery slot @@ -72,8 +72,8 @@ public class GuiVacuumFreezer extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer); @@ -93,8 +93,8 @@ public class GuiVacuumFreezer extends GuiBase { { // This code here makes a basic multiblock and then sets to the selected one. final Multiblock multiblock = new Multiblock(); - IBlockState advancedCasing = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState(); - IBlockState industrialCasing = TRContent.MachineBlocks.INDUSTRIAL.getCasing().getDefaultState(); + BlockState advancedCasing = TRContent.MachineBlocks.ADVANCED.getCasing().getDefaultState(); + BlockState industrialCasing = TRContent.MachineBlocks.INDUSTRIAL.getCasing().getDefaultState(); addComponent(0, -1, 0, advancedCasing, multiblock); addComponent(1, -1, 0, advancedCasing, multiblock); @@ -136,7 +136,7 @@ public class GuiVacuumFreezer extends GuiBase { } } - public void addComponent(final int x, final int y, final int z, final IBlockState blockState, final Multiblock multiblock) { + public void addComponent(final int x, final int y, final int z, final BlockState blockState, final Multiblock multiblock) { multiblock.addComponent(new BlockPos(x, y, z), blockState); } } diff --git a/src/main/java/techreborn/client/keybindings/KeyBindings.java b/src/main/java/techreborn/client/keybindings/KeyBindings.java index 922e48763..9b25806c9 100644 --- a/src/main/java/techreborn/client/keybindings/KeyBindings.java +++ b/src/main/java/techreborn/client/keybindings/KeyBindings.java @@ -24,7 +24,7 @@ package techreborn.client.keybindings; -import net.minecraft.client.settings.KeyBinding; +import net.minecraft.client.options.KeyBinding; import org.lwjgl.glfw.GLFW; public class KeyBindings { diff --git a/src/main/java/techreborn/client/particle/ParticleSmoke.java b/src/main/java/techreborn/client/particle/ParticleSmoke.java index e7d408cb8..7856ea154 100644 --- a/src/main/java/techreborn/client/particle/ParticleSmoke.java +++ b/src/main/java/techreborn/client/particle/ParticleSmoke.java @@ -24,10 +24,10 @@ package techreborn.client.particle; -import net.minecraft.client.particle.ParticleSmokeLarge; +import net.minecraft.client.particle.FireSmokeLargeParticle; import net.minecraft.world.World; -public class ParticleSmoke extends ParticleSmokeLarge { +public class ParticleSmoke extends FireSmokeLargeParticle { public ParticleSmoke(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double p_i1201_8_, double p_i1201_10_, double p_i1201_12_) { super(worldIn, xCoordIn, yCoordIn, zCoordIn, p_i1201_8_, p_i1201_10_, p_i1201_12_); diff --git a/src/main/java/techreborn/client/render/ModelDynamicCell.java b/src/main/java/techreborn/client/render/ModelDynamicCell.java index 27a021a33..ded3a93cb 100644 --- a/src/main/java/techreborn/client/render/ModelDynamicCell.java +++ b/src/main/java/techreborn/client/render/ModelDynamicCell.java @@ -26,34 +26,35 @@ package techreborn.client.render; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import net.minecraft.client.render.VertexFormat; +import net.minecraft.client.render.model.BakedModel; +import net.minecraft.client.render.model.BakedQuad; +import net.minecraft.client.render.model.UnbakedModel; +import net.minecraft.client.render.model.json.ModelItemPropertyOverrideList; +import net.minecraft.client.render.model.json.ModelTransformation; import net.minecraft.client.renderer.model.*; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.resources.IResourceManager; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.model.*; -import net.minecraftforge.common.model.IModelState; -import net.minecraftforge.common.model.TRSRTransformation; -import net.minecraftforge.fluids.Fluid; +import net.minecraft.client.texture.Sprite; +import net.minecraft.client.util.ModelIdentifier; +import net.minecraft.resource.ResourceManager; +import net.minecraft.util.Identifier; +import net.minecraft.util.math.Direction; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import java.awt.*; -import java.util.List; import java.util.*; import java.util.function.Function; //TODO 1.13 very broken, look at ModelDynBucket for help porting this fully -@OnlyIn(Dist.CLIENT) -public class ModelDynamicCell implements IUnbakedModel { +@Environment(EnvType.CLIENT) +public class ModelDynamicCell implements UnbakedModel { public static final ModelDynamicCell MODEL = new ModelDynamicCell( - new ResourceLocation("techreborn:items/cell_cover"), - new ResourceLocation("techreborn:items/cell_empty") + new Identifier("techreborn:items/cell_cover"), + new Identifier("techreborn:items/cell_empty") ); - public static final ModelResourceLocation MODEL_LOCATION = new ModelResourceLocation(new ResourceLocation("techreborn", "dynamic_cell"), "default"); + public static final ModelIdentifier MODEL_LOCATION = new ModelIdentifier(new Identifier("techreborn", "dynamic_cell"), "default"); private static final float NORTH_Z_FLUID = 7.6f / 16f; private static final float SOUTH_Z_FLUID = 8.4f / 16f; @@ -64,46 +65,46 @@ public class ModelDynamicCell implements IUnbakedModel { ModelLoaderRegistry.registerLoader(new DynamicCellLoader()); } - private final ResourceLocation baseTexture; - private final ResourceLocation emptyTexture; + private final Identifier baseTexture; + private final Identifier emptyTexture; private final Fluid fluid; - public ModelDynamicCell(ResourceLocation baseTexture, ResourceLocation emptyTexture) { + public ModelDynamicCell(Identifier baseTexture, Identifier emptyTexture) { this(baseTexture, emptyTexture, null); } - public ModelDynamicCell(ResourceLocation baseTexture, ResourceLocation emptyTexture, Fluid fluid) { + public ModelDynamicCell(Identifier baseTexture, Identifier emptyTexture, Fluid fluid) { this.baseTexture = baseTexture; this.emptyTexture = emptyTexture; this.fluid = fluid; } @Override - public Collection getDependencies() { + public Collection getModelDependencies() { return ImmutableList.of(); } @Override - public Collection getTextures(Function modelGetter, Set missingTextureErrors) { + public Collection getTextureDependencies(Function modelGetter, Set missingTextureErrors) { return ImmutableList.of(baseTexture, emptyTexture); } @Override - public IBakedModel bake(Function modelGetter, Function spriteGetter, IModelState state, boolean uvlock, VertexFormat format) { + public BakedModel bake(Function modelGetter, Function spriteGetter, IModelState state, boolean uvlock, VertexFormat format) { - ImmutableMap transformMap = PerspectiveMapWrapper.getTransforms(state); + ImmutableMap transformMap = PerspectiveMapWrapper.getTransforms(state); TRSRTransformation transform = state.apply(Optional.empty()).orElse(TRSRTransformation.identity()); ImmutableList.Builder builder = ImmutableList.builder(); builder.addAll(new ItemLayerModel(ImmutableList.of(baseTexture)).bake(modelGetter, spriteGetter, state, uvlock, format).getQuads(null, null, new Random())); - ResourceLocation sprite = fluid != null ? fluid.getStill() : emptyTexture; + Identifier sprite = fluid != null ? fluid.getStill() : emptyTexture; int color = fluid != null ? fluid.getColor() : Color.WHITE.getRGB(); - TextureAtlasSprite fluidSprite = spriteGetter.apply(sprite); + Sprite fluidSprite = spriteGetter.apply(sprite); if (fluid != null) { if (fluidSprite != null) { - builder.add(ItemTextureQuadConverter.genQuad(format, transform, 5, 2, 11, 14, NORTH_Z_FLUID, fluidSprite, EnumFacing.NORTH, color, -1)); - builder.add(ItemTextureQuadConverter.genQuad(format, transform, 5, 2, 11, 14, SOUTH_Z_FLUID, fluidSprite, EnumFacing.SOUTH, color, -1)); + builder.add(ItemTextureQuadConverter.genQuad(format, transform, 5, 2, 11, 14, NORTH_Z_FLUID, fluidSprite, Direction.NORTH, color, -1)); + builder.add(ItemTextureQuadConverter.genQuad(format, transform, 5, 2, 11, 14, SOUTH_Z_FLUID, fluidSprite, Direction.SOUTH, color, -1)); } } @@ -119,17 +120,17 @@ public class ModelDynamicCell implements IUnbakedModel { public static class DynamicCellLoader implements ICustomModelLoader { @Override - public boolean accepts(ResourceLocation modelLocation) { + public boolean accepts(Identifier modelLocation) { return modelLocation.getNamespace().equals("techreborn") && modelLocation.getPath().contains("dynamic_cell"); } @Override - public IUnbakedModel loadModel(ResourceLocation modelLocation) { + public UnbakedModel loadModel(Identifier modelLocation) { return MODEL; } @Override - public void onResourceManagerReload(IResourceManager resourceManager) {} + public void onResourceManagerReload(ResourceManager resourceManager) {} } @@ -137,15 +138,15 @@ public class ModelDynamicCell implements IUnbakedModel { private final List quads; private final ModelDynamicCell parent; - private final TextureAtlasSprite particle; + private final Sprite particle; private final VertexFormat format; - private final ImmutableMap transformMap; + private final ImmutableMap transformMap; public BakedDynamicCell(ImmutableList quads, ModelDynamicCell parent, - TextureAtlasSprite particle, + Sprite particle, VertexFormat format, - ImmutableMap transformMap) { + ImmutableMap transformMap) { super(quads, particle, transformMap, null /* TODO fix this */); this.transformMap = transformMap; this.quads = quads; @@ -170,17 +171,17 @@ public class ModelDynamicCell implements IUnbakedModel { } @Override - public TextureAtlasSprite getParticleTexture() { + public Sprite getParticleTexture() { return particle; } @Override - public ItemCameraTransforms getItemCameraTransforms() { + public ModelTransformation getItemCameraTransforms() { return ModelHelper.DEFAULT_ITEM_TRANSFORMS; } @Override - public ItemOverrideList getOverrides() { + public ModelItemPropertyOverrideList getOverrides() { return OVERRIDES; } @@ -188,9 +189,9 @@ public class ModelDynamicCell implements IUnbakedModel { public static final OverrideHandler OVERRIDES = new OverrideHandler(); - public static class OverrideHandler extends ItemOverrideList { + public static class OverrideHandler extends ModelItemPropertyOverrideList { - private final HashMap modelCache = new HashMap<>(); + private final HashMap modelCache = new HashMap<>(); // private final Function textureGetter = location -> // Minecraft.getInstance().getTextureMapBlocks().getAtlasSprite(location.toString()); diff --git a/src/main/java/techreborn/client/render/ModelHelper.java b/src/main/java/techreborn/client/render/ModelHelper.java index e5849ca25..f9ebb114a 100644 --- a/src/main/java/techreborn/client/render/ModelHelper.java +++ b/src/main/java/techreborn/client/render/ModelHelper.java @@ -25,13 +25,13 @@ package techreborn.client.render; import com.google.common.base.Charsets; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.client.renderer.model.ModelBlock; -import net.minecraft.resources.IResource; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.model.json.JsonUnbakedModel; +import net.minecraft.client.render.model.json.ModelTransformation; +import net.minecraft.resource.Resource; +import net.minecraft.util.Identifier; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import techreborn.TechReborn; import java.io.BufferedReader; @@ -42,16 +42,16 @@ import java.io.Reader; /* * Credits to JsonDestroyer */ -@OnlyIn(Dist.CLIENT) +@Environment(EnvType.CLIENT) public class ModelHelper { - public static final ItemCameraTransforms DEFAULT_ITEM_TRANSFORMS = loadTransformFromJson(new ResourceLocation("minecraft:models/item/generated")); - public static final ItemCameraTransforms HANDHELD_ITEM_TRANSFORMS = loadTransformFromJson(new ResourceLocation("minecraft:models/item/handheld")); + public static final ModelTransformation DEFAULT_ITEM_TRANSFORMS = loadTransformFromJson(new Identifier("minecraft:models/item/generated")); + public static final ModelTransformation HANDHELD_ITEM_TRANSFORMS = loadTransformFromJson(new Identifier("minecraft:models/item/handheld")); - public static ItemCameraTransforms loadTransformFromJson(ResourceLocation location) { + public static ModelTransformation loadTransformFromJson(Identifier location) { try { - return ModelBlock.deserialize(getReaderForResource(location)).getAllTransforms(); + return JsonUnbakedModel.deserialize(getReaderForResource(location)).getTransformations(); } catch (IOException exception) { TechReborn.LOGGER.warn("Can't load resource " + location); exception.printStackTrace(); @@ -59,9 +59,9 @@ public class ModelHelper { } } - public static Reader getReaderForResource(ResourceLocation location) throws IOException { - ResourceLocation file = new ResourceLocation(location.getNamespace(), location.getPath() + ".json"); - IResource iresource = Minecraft.getInstance().getResourceManager().getResource(file); + public static Reader getReaderForResource(Identifier location) throws IOException { + Identifier file = new Identifier(location.getNamespace(), location.getPath() + ".json"); + Resource iresource = MinecraftClient.getInstance().getResourceManager().getResource(file); return new BufferedReader(new InputStreamReader(iresource.getInputStream(), Charsets.UTF_8)); } diff --git a/src/main/java/techreborn/client/render/entitys/RenderNukePrimed.java b/src/main/java/techreborn/client/render/entitys/RenderNukePrimed.java index 997b4de94..0aeb89631 100644 --- a/src/main/java/techreborn/client/render/entitys/RenderNukePrimed.java +++ b/src/main/java/techreborn/client/render/entitys/RenderNukePrimed.java @@ -24,13 +24,14 @@ package techreborn.client.render.entitys; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BlockRendererDispatcher; +import com.mojang.blaze3d.platform.GlStateManager; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.block.BlockRenderManager; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.client.render.entity.EntityRenderer; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.util.ResourceLocation; +import net.minecraft.client.texture.SpriteAtlasTexture; +import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; import techreborn.blocks.BlockNuke; import techreborn.entities.EntityNukePrimed; @@ -39,20 +40,20 @@ import techreborn.init.TRContent; /** * Created by Mark on 13/03/2016. */ -public class RenderNukePrimed extends Render { +public class RenderNukePrimed extends EntityRenderer { - public RenderNukePrimed(RenderManager renderManager) { + public RenderNukePrimed(EntityRenderDispatcher renderManager) { super(renderManager); - this.shadowSize = 0.5F; + this.field_4673 = 0.5F; } @Override public void doRender(EntityNukePrimed entity, double x, double y, double z, float entityYaw, float partialTicks) { - BlockRendererDispatcher blockrendererdispatcher = Minecraft.getInstance().getBlockRendererDispatcher(); + BlockRenderManager blockrendererdispatcher = MinecraftClient.getInstance().getBlockRenderManager(); GlStateManager.pushMatrix(); GlStateManager.translatef((float) x, (float) y + 0.5F, (float) z); - if ((float) entity.getFuse() - partialTicks + 1.0F < 10.0F) { - float f = 1.0F - ((float) entity.getFuse() - partialTicks + 1.0F) / 10.0F; + if ((float) entity.getFuseTimer() - partialTicks + 1.0F < 10.0F) { + float f = 1.0F - ((float) entity.getFuseTimer() - partialTicks + 1.0F) / 10.0F; f = MathHelper.clamp(f, 0.0F, 1.0F); f = f * f; f = f * f; @@ -61,17 +62,17 @@ public class RenderNukePrimed extends Render { } this.bindEntityTexture(entity); GlStateManager.translatef(-0.5F, -0.5F, 0.5F); - blockrendererdispatcher.renderBlockBrightness(TRContent.NUKE.getDefaultState(), - entity.getBrightness()); + blockrendererdispatcher.renderDynamic(TRContent.NUKE.getDefaultState(), + entity.getBrightnessAtEyes()); GlStateManager.translatef(0.0F, 0.0F, 1.0F); - if (entity.getFuse() / 5 % 2 == 0) { + if (entity.getFuseTimer() / 5 % 2 == 0) { GlStateManager.disableLighting(); GlStateManager.enableBlend(); GlStateManager.blendFunc(770, 772); GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1F); GlStateManager.polygonOffset(-3.0F, -3.0F); GlStateManager.enablePolygonOffset(); - blockrendererdispatcher.renderBlockBrightness( + blockrendererdispatcher.renderDynamic( TRContent.NUKE.getDefaultState().with(BlockNuke.OVERLAY, true), 1.0F); GlStateManager.polygonOffset(0.0F, 0.0F); GlStateManager.disablePolygonOffset(); @@ -80,11 +81,11 @@ public class RenderNukePrimed extends Render { GlStateManager.enableLighting(); } GlStateManager.popMatrix(); - super.doRender(entity, x, y, z, entityYaw, partialTicks); + super.render(entity, x, y, z, entityYaw, partialTicks); } @Override - protected ResourceLocation getEntityTexture(EntityNukePrimed entity) { - return TextureMap.LOCATION_BLOCKS_TEXTURE; + protected Identifier getEntityTexture(EntityNukePrimed entity) { + return SpriteAtlasTexture.BLOCK_ATLAS_TEX; } } diff --git a/src/main/java/techreborn/entities/EntityNukePrimed.java b/src/main/java/techreborn/entities/EntityNukePrimed.java index 32cae3f34..b7497790b 100644 --- a/src/main/java/techreborn/entities/EntityNukePrimed.java +++ b/src/main/java/techreborn/entities/EntityNukePrimed.java @@ -24,10 +24,10 @@ package techreborn.entities; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.MoverType; -import net.minecraft.entity.item.EntityTNTPrimed; -import net.minecraft.init.Particles; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.MovementType; +import net.minecraft.entity.PrimedTntEntity; +import net.minecraft.particle.ParticleTypes; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import reborncore.common.explosion.RebornExplosion; @@ -39,7 +39,7 @@ import techreborn.TechReborn; * Created by Mark on 13/03/2016. */ @RebornRegister(TechReborn.MOD_ID) -public class EntityNukePrimed extends EntityTNTPrimed { +public class EntityNukePrimed extends PrimedTntEntity { @ConfigRegistry(config = "misc", category = "nuke", key = "fusetime", comment = "Nuke fuse time (ticks)") public static int fuseTime = 400; @@ -55,22 +55,22 @@ public class EntityNukePrimed extends EntityTNTPrimed { setFuse(EntityNukePrimed.fuseTime); } - public EntityNukePrimed(World world, double x, double y, double z, EntityLivingBase tntPlacedBy) { + public EntityNukePrimed(World world, double x, double y, double z, LivingEntity tntPlacedBy) { super(world, x, y, z, tntPlacedBy); setFuse(EntityNukePrimed.fuseTime); } @Override public void tick() { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; + this.prevX = this.x; + this.prevY = this.y; + this.prevZ = this.z; if (!this.hasNoGravity()) { this.motionY -= 0.03999999910593033D; } - this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ); + this.move(MovementType.SELF, this.motionX, this.motionY, this.motionZ); this.motionX *= 0.9800000190734863D; this.motionY *= 0.9800000190734863D; this.motionZ *= 0.9800000190734863D; @@ -81,16 +81,16 @@ public class EntityNukePrimed extends EntityTNTPrimed { this.motionY *= -0.5D; } - setFuse(getFuse() - 1); + setFuse(getFuseTimer() - 1); - if (getFuse() <= 0) { + if (getFuseTimer() <= 0) { this.remove(); - if (!this.world.isRemote) { + if (!this.world.isClient) { explodeNuke(); } } else { - this.handleWaterMovement(); - this.world.addParticle(Particles.SMOKE, this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); + this.method_5713(); + this.world.addParticle(ParticleTypes.SMOKE, this.x, this.y + 0.5D, this.z, 0.0D, 0.0D, 0.0D); } } @@ -98,8 +98,8 @@ public class EntityNukePrimed extends EntityTNTPrimed { if (!enabled) { return; } - RebornExplosion nukeExplosion = new RebornExplosion(new BlockPos(posX, posY, posZ), world, radius); - nukeExplosion.setLivingBase(getTntPlacedBy()); + RebornExplosion nukeExplosion = new RebornExplosion(new BlockPos(x, y, z), world, radius); + nukeExplosion.setLivingBase(getCausingEntity()); nukeExplosion.explode(); } } diff --git a/src/main/java/techreborn/events/BlockBreakHandler.java b/src/main/java/techreborn/events/BlockBreakHandler.java index 301f6f2a4..00c929cc7 100644 --- a/src/main/java/techreborn/events/BlockBreakHandler.java +++ b/src/main/java/techreborn/events/BlockBreakHandler.java @@ -24,17 +24,17 @@ package techreborn.events; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Items; +import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; -import net.minecraft.tags.BlockTags; -import net.minecraft.util.EnumHand; -import net.minecraft.util.ResourceLocation; +import net.minecraft.item.Items; +import net.minecraft.tag.BlockTags; +import net.minecraft.util.Hand; +import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.event.entity.player.PlayerEvent; -import net.minecraftforge.event.world.BlockEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; + + + import reborncore.common.registration.RebornRegister; import reborncore.common.registration.config.ConfigRegistry; import reborncore.common.util.OreDrop; @@ -62,27 +62,27 @@ public class BlockBreakHandler { @SubscribeEvent public void onBlockHarvest(BlockEvent.HarvestDropsEvent event) { if (secondaryGemDrops && !event.isSilkTouching()) { - IBlockState state = event.getState(); + BlockState state = event.getState(); List drops = event.getDrops(); Random random = new Random(); //TODO: fix tags - if (state.getBlock().isIn(new BlockTags.Wrapper(new ResourceLocation(TechReborn.MOD_ID, "ruby_ore")))) { + if (state.getBlock().matches(new BlockTags.CachingTag(new Identifier(TechReborn.MOD_ID, "ruby_ore")))) { OreDrop redGarnet = new OreDrop(TRContent.Gems.RED_GARNET.getStack(), redGarnetDropChance, 1); drops.add(redGarnet.getDrops(event.getFortuneLevel(), random)); } - else if (state.getBlock().isIn(new BlockTags.Wrapper(new ResourceLocation(TechReborn.MOD_ID, "sapphire_ore")))) { + else if (state.getBlock().matches(new BlockTags.CachingTag(new Identifier(TechReborn.MOD_ID, "sapphire_ore")))) { OreDrop peridot = new OreDrop(TRContent.Gems.PERIDOT.getStack(), peridotDropChance, 1); drops.add(peridot.getDrops(event.getFortuneLevel(), random)); } - else if (state.getBlock().isIn(new BlockTags.Wrapper(new ResourceLocation(TechReborn.MOD_ID, "sodalite_ore")))) { + else if (state.getBlock().matches(new BlockTags.CachingTag(new Identifier(TechReborn.MOD_ID, "sodalite_ore")))) { OreDrop aluminium = new OreDrop(TRContent.Dusts.ALUMINUM.getStack(), aluminiumDropChance, 1); drops.add(aluminium.getDrops(event.getFortuneLevel(), random)); } - else if (state.getBlock().isIn(new BlockTags.Wrapper(new ResourceLocation(TechReborn.MOD_ID, "cinnabar_ore")))) { + else if (state.getBlock().matches(new BlockTags.CachingTag(new Identifier(TechReborn.MOD_ID, "cinnabar_ore")))) { OreDrop redstone = new OreDrop(new ItemStack(Items.REDSTONE), redstoneDropChance, 1); drops.add(redstone.getDrops(event.getFortuneLevel(), random)); } - else if (state.getBlock().isIn(new BlockTags.Wrapper(new ResourceLocation(TechReborn.MOD_ID, "sphalerite_ore")))) { + else if (state.getBlock().matches(new BlockTags.CachingTag(new Identifier(TechReborn.MOD_ID, "sphalerite_ore")))) { OreDrop yellowGarnet = new OreDrop(TRContent.Gems.YELLOW_GARNET.getStack(), yellowGarnetDropChance, 1); drops.add(yellowGarnet.getDrops(event.getFortuneLevel(), random)); } @@ -91,15 +91,15 @@ public class BlockBreakHandler { @SubscribeEvent public void getBreakSpeedEvent(PlayerEvent.BreakSpeed event){ - if(event.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND).getItem() == TRContent.INDUSTRIAL_CHAINSAW && event.getOriginalSpeed() > 1.0f){ + if(event.getEntityPlayer().getHeldItem(Hand.MAIN_HAND).getItem() == TRContent.INDUSTRIAL_CHAINSAW && event.getOriginalSpeed() > 1.0f){ BlockPos pos = event.getPos(); World worldIn = event.getEntityPlayer().world; float speed = 20F; int blocks = 0; for (int i = 1; i < 10; i++) { BlockPos nextPos = pos.up(i); - IBlockState nextState = worldIn.getBlockState(nextPos); - if(nextState.getBlock().isIn(BlockTags.LOGS)){ + BlockState nextState = worldIn.getBlockState(nextPos); + if(nextState.getBlock().matches(BlockTags.LOGS)){ blocks ++; } } diff --git a/src/main/java/techreborn/events/ModelRegistryEventHandler.java b/src/main/java/techreborn/events/ModelRegistryEventHandler.java index 5fc312fb8..dcf8a677d 100644 --- a/src/main/java/techreborn/events/ModelRegistryEventHandler.java +++ b/src/main/java/techreborn/events/ModelRegistryEventHandler.java @@ -25,12 +25,12 @@ package techreborn.events; import net.minecraft.item.Item; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.event.ModelRegistryEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; +import net.minecraft.util.Identifier; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + + + import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; import techreborn.TechReborn; @@ -45,7 +45,7 @@ import java.util.Arrays; * @author drcrazy * */ -@OnlyIn(Dist.CLIENT) +@Environment(EnvType.CLIENT) @Mod.EventBusSubscriber(modid = TechReborn.MOD_ID) public class ModelRegistryEventHandler { @@ -174,7 +174,7 @@ public class ModelRegistryEventHandler { // Gem armor & tools if (ConfigTechReborn.enableGemArmorAndTools) { - ResourceLocation armourRL = new ResourceLocation(TechReborn.MOD_ID, "items/armour"); + Identifier armourRL = new Identifier(TechReborn.MOD_ID, "items/armour"); registerBlockstateMultiItem(armourRL, TRContent.RUBY_HELMET, "ruby_helmet"); registerBlockstateMultiItem(armourRL, TRContent.RUBY_CHESTPLATE, "ruby_chestplate"); registerBlockstateMultiItem(armourRL, TRContent.RUBY_LEGGINGS, "ruby_leggings"); @@ -192,7 +192,7 @@ public class ModelRegistryEventHandler { registerBlockstateMultiItem(armourRL, TRContent.BRONZE_LEGGINGS, "bronze_leggings"); registerBlockstateMultiItem(armourRL, TRContent.BRONZE_BOOTS, "bronze_boots"); - ResourceLocation toolRL = new ResourceLocation(TechReborn.MOD_ID, "items/tool"); + Identifier toolRL = new Identifier(TechReborn.MOD_ID, "items/tool"); registerBlockstateMultiItem(toolRL, TRContent.RUBY_PICKAXE, "ruby_pickaxe"); registerBlockstateMultiItem(toolRL, TRContent.RUBY_SWORD, "ruby_sword"); registerBlockstateMultiItem(toolRL, TRContent.RUBY_AXE, "ruby_axe"); @@ -215,28 +215,28 @@ public class ModelRegistryEventHandler { registerBlockstateMultiItem(toolRL, TRContent.BRONZE_HOE, "bronze_hoe"); } - ResourceLocation dustsRL = new ResourceLocation(TechReborn.MOD_ID, "items/material/dust"); + Identifier dustsRL = new Identifier(TechReborn.MOD_ID, "items/material/dust"); Arrays.stream(Dusts.values()).forEach(value -> registerBlockstateMultiItem(dustsRL, value.item, value.name)); - ResourceLocation dustsSmallRL = new ResourceLocation(TechReborn.MOD_ID, "items/material/small_dust"); + Identifier dustsSmallRL = new Identifier(TechReborn.MOD_ID, "items/material/small_dust"); Arrays.stream(SmallDusts.values()).forEach(value -> registerBlockstateMultiItem(dustsSmallRL, value.item, value.name)); - ResourceLocation gemsRL = new ResourceLocation(TechReborn.MOD_ID, "items/material/gem"); + Identifier gemsRL = new Identifier(TechReborn.MOD_ID, "items/material/gem"); Arrays.stream(Gems.values()).forEach(value -> registerBlockstateMultiItem(gemsRL, value.item, value.name)); - ResourceLocation ingotsRL = new ResourceLocation(TechReborn.MOD_ID, "items/material/ingot"); + Identifier ingotsRL = new Identifier(TechReborn.MOD_ID, "items/material/ingot"); Arrays.stream(Ingots.values()).forEach(value -> registerBlockstateMultiItem(ingotsRL, value.item, value.name)); - ResourceLocation nuggetsRL = new ResourceLocation(TechReborn.MOD_ID, "items/material/nugget"); + Identifier nuggetsRL = new Identifier(TechReborn.MOD_ID, "items/material/nugget"); Arrays.stream(Nuggets.values()).forEach(value -> registerBlockstateMultiItem(nuggetsRL, value.item, value.name)); - ResourceLocation partsRL = new ResourceLocation(TechReborn.MOD_ID, "items/material/part"); + Identifier partsRL = new Identifier(TechReborn.MOD_ID, "items/material/part"); Arrays.stream(Parts.values()).forEach(value -> registerBlockstateMultiItem(partsRL, value.item, value.name)); - ResourceLocation platesRL = new ResourceLocation(TechReborn.MOD_ID, "items/material/plate"); + Identifier platesRL = new Identifier(TechReborn.MOD_ID, "items/material/plate"); Arrays.stream(Plates.values()).forEach(value -> registerBlockstateMultiItem(platesRL, value.item, value.name)); - ResourceLocation upgradeRL = new ResourceLocation(TechReborn.MOD_ID, "items/misc/upgrades"); + Identifier upgradeRL = new Identifier(TechReborn.MOD_ID, "items/misc/upgrades"); Arrays.stream(Upgrades.values()).forEach(value -> registerBlockstateMultiItem(upgradeRL, value.item, value.name)); } @@ -270,7 +270,7 @@ public class ModelRegistryEventHandler { RebornModelRegistry.registerItemModel(item, modelPath); } - private static void registerBlockstateMultiItem(ResourceLocation RL, Item item, String variantName) { + private static void registerBlockstateMultiItem(Identifier RL, Item item, String variantName) { //ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(RL, "type=" + variantName)); } diff --git a/src/main/java/techreborn/events/RegistryEventHandler.java b/src/main/java/techreborn/events/RegistryEventHandler.java index 5446825ed..6274ebe0f 100644 --- a/src/main/java/techreborn/events/RegistryEventHandler.java +++ b/src/main/java/techreborn/events/RegistryEventHandler.java @@ -25,16 +25,16 @@ package techreborn.events; import net.minecraft.block.Block; +import net.minecraft.block.entity.BlockEntityType; import net.minecraft.entity.EntityType; -import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.entity.EquipmentSlot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; +import net.minecraft.util.Identifier; + + + + import reborncore.RebornRegistry; import reborncore.common.blocks.BlockMachineBase; import reborncore.common.util.BucketHandler; @@ -88,29 +88,29 @@ public class RegistryEventHandler { @SubscribeEvent public static void registerBlocks(RegistryEvent.Register event) { - Arrays.stream(Ores.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Properties().group(TechReborn.ITEMGROUP))); - Arrays.stream(StorageBlocks.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Properties().group(TechReborn.ITEMGROUP))); + Arrays.stream(Ores.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Settings().itemGroup(TechReborn.ITEMGROUP))); + Arrays.stream(StorageBlocks.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Settings().itemGroup(TechReborn.ITEMGROUP))); Arrays.stream(MachineBlocks.values()).forEach(value -> { - RebornRegistry.registerBlock(value.frame, new Item.Properties().group(TechReborn.ITEMGROUP)); - RebornRegistry.registerBlock(value.casing, new Item.Properties().group(TechReborn.ITEMGROUP)); + RebornRegistry.registerBlock(value.frame, new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); + RebornRegistry.registerBlock(value.casing, new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); }); - Arrays.stream(SolarPanels.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Properties().group(TechReborn.ITEMGROUP))); - Arrays.stream(Cables.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Properties().group(TechReborn.ITEMGROUP))); - Arrays.stream(Machine.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Properties().group(TechReborn.ITEMGROUP))); + Arrays.stream(SolarPanels.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Settings().itemGroup(TechReborn.ITEMGROUP))); + Arrays.stream(Cables.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Settings().itemGroup(TechReborn.ITEMGROUP))); + Arrays.stream(Machine.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Settings().itemGroup(TechReborn.ITEMGROUP))); // Misc. blocks - RebornRegistry.registerBlock(TRContent.COMPUTER_CUBE = InitUtils.setup(new BlockComputerCube(), "computer_cube"), new Item.Properties().group(TechReborn.ITEMGROUP)); - RebornRegistry.registerBlock(TRContent.NUKE = InitUtils.setup(new BlockNuke(), "nuke"), new Item.Properties().group(TechReborn.ITEMGROUP)); - RebornRegistry.registerBlock(TRContent.REFINED_IRON_FENCE = InitUtils.setup(new BlockRefinedIronFence(), "refined_iron_fence"), new Item.Properties().group(TechReborn.ITEMGROUP)); - RebornRegistry.registerBlock(TRContent.REINFORCED_GLASS = InitUtils.setup(new BlockReinforcedGlass(), "reinforced_glass"), new Item.Properties().group(TechReborn.ITEMGROUP)); - RebornRegistry.registerBlock(TRContent.RUBBER_LEAVES = InitUtils.setup(new BlockRubberLeaves(), "rubber_leaves"), new Item.Properties().group(TechReborn.ITEMGROUP)); - RebornRegistry.registerBlock(TRContent.RUBBER_LOG = InitUtils.setup(new BlockRubberLog(), "rubber_log"), new Item.Properties().group(TechReborn.ITEMGROUP)); - RebornRegistry.registerBlock(TRContent.RUBBER_PLANKS = InitUtils.setup(new BlockRubberPlank(), "rubber_planks"), new Item.Properties().group(TechReborn.ITEMGROUP)); + RebornRegistry.registerBlock(TRContent.COMPUTER_CUBE = InitUtils.setup(new BlockComputerCube(), "computer_cube"), new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); + RebornRegistry.registerBlock(TRContent.NUKE = InitUtils.setup(new BlockNuke(), "nuke"), new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); + RebornRegistry.registerBlock(TRContent.REFINED_IRON_FENCE = InitUtils.setup(new BlockRefinedIronFence(), "refined_iron_fence"), new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); + RebornRegistry.registerBlock(TRContent.REINFORCED_GLASS = InitUtils.setup(new BlockReinforcedGlass(), "reinforced_glass"), new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); + RebornRegistry.registerBlock(TRContent.RUBBER_LEAVES = InitUtils.setup(new BlockRubberLeaves(), "rubber_leaves"), new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); + RebornRegistry.registerBlock(TRContent.RUBBER_LOG = InitUtils.setup(new BlockRubberLog(), "rubber_log"), new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); + RebornRegistry.registerBlock(TRContent.RUBBER_PLANKS = InitUtils.setup(new BlockRubberPlank(), "rubber_planks"), new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); RebornRegistry.registerBlock(TRContent.RUBBER_SAPLING = InitUtils.setup(new BlockRubberSapling(), "rubber_sapling"), ItemBlockRubberSapling.class, "rubber_sapling"); - RebornRegistry.registerBlock(TRContent.RUBBER_PLANK_SLAB = InitUtils.setup(new BlockRubberPlankSlab(), "rubber_plank_slab"), new Item.Properties().group(TechReborn.ITEMGROUP)); - RebornRegistry.registerBlock(TRContent.RUBBER_PLANK_STAIR = InitUtils.setup(new BlockRubberPlankStair(), "rubber_plank_stair"), new Item.Properties().group(TechReborn.ITEMGROUP)); + RebornRegistry.registerBlock(TRContent.RUBBER_PLANK_SLAB = InitUtils.setup(new BlockRubberPlankSlab(), "rubber_plank_slab"), new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); + RebornRegistry.registerBlock(TRContent.RUBBER_PLANK_STAIR = InitUtils.setup(new BlockRubberPlankStair(), "rubber_plank_stair"), new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); TechReborn.LOGGER.debug("TechReborns Blocks Loaded"); } @@ -135,10 +135,10 @@ public class RegistryEventHandler { RebornRegistry.registerItem(TRContent.BRONZE_AXE = InitUtils.setup(new ItemTRAxe(TRToolTier.BRONZE, "ingotBronze"), "bronze_axe")); RebornRegistry.registerItem(TRContent.BRONZE_HOE = InitUtils.setup(new ItemTRHoe(TRToolTier.BRONZE, "ingotBronze"), "bronze_hoe")); - RebornRegistry.registerItem(TRContent.BRONZE_HELMET = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.BRONZE, EntityEquipmentSlot.HEAD, "ingotBronze"), "bronze_helmet")); - RebornRegistry.registerItem(TRContent.BRONZE_CHESTPLATE = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.BRONZE, EntityEquipmentSlot.CHEST, "ingotBronze"), "bronze_chestplate")); - RebornRegistry.registerItem(TRContent.BRONZE_LEGGINGS = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.BRONZE, EntityEquipmentSlot.LEGS, "ingotBronze"), "bronze_leggings")); - RebornRegistry.registerItem(TRContent.BRONZE_BOOTS = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.BRONZE, EntityEquipmentSlot.FEET, "ingotBronze"), "bronze_boots")); + RebornRegistry.registerItem(TRContent.BRONZE_HELMET = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.BRONZE, EquipmentSlot.HEAD, "ingotBronze"), "bronze_helmet")); + RebornRegistry.registerItem(TRContent.BRONZE_CHESTPLATE = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.BRONZE, EquipmentSlot.CHEST, "ingotBronze"), "bronze_chestplate")); + RebornRegistry.registerItem(TRContent.BRONZE_LEGGINGS = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.BRONZE, EquipmentSlot.LEGS, "ingotBronze"), "bronze_leggings")); + RebornRegistry.registerItem(TRContent.BRONZE_BOOTS = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.BRONZE, EquipmentSlot.FEET, "ingotBronze"), "bronze_boots")); RebornRegistry.registerItem(TRContent.RUBY_SWORD = InitUtils.setup(new ItemTRSword(TRToolTier.RUBY, "gemRuby"), "ruby_sword")); RebornRegistry.registerItem(TRContent.RUBY_PICKAXE = InitUtils.setup(new ItemTRPickaxe(TRToolTier.RUBY, "gemRuby"), "ruby_pickaxe")); @@ -146,10 +146,10 @@ public class RegistryEventHandler { RebornRegistry.registerItem(TRContent.RUBY_AXE = InitUtils.setup(new ItemTRAxe(TRToolTier.RUBY, "gemRuby"), "ruby_axe")); RebornRegistry.registerItem(TRContent.RUBY_HOE = InitUtils.setup(new ItemTRHoe(TRToolTier.RUBY, "gemRuby"), "ruby_hoe")); - RebornRegistry.registerItem(TRContent.RUBY_HELMET = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.RUBY, EntityEquipmentSlot.HEAD, "gemRuby"), "ruby_helmet")); - RebornRegistry.registerItem(TRContent.RUBY_CHESTPLATE = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.RUBY, EntityEquipmentSlot.CHEST, "gemRuby"), "ruby_chestplate")); - RebornRegistry.registerItem(TRContent.RUBY_LEGGINGS = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.RUBY, EntityEquipmentSlot.LEGS, "gemRuby"), "ruby_leggings")); - RebornRegistry.registerItem(TRContent.RUBY_BOOTS = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.RUBY, EntityEquipmentSlot.FEET, "gemRuby"), "ruby_boots")); + RebornRegistry.registerItem(TRContent.RUBY_HELMET = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.RUBY, EquipmentSlot.HEAD, "gemRuby"), "ruby_helmet")); + RebornRegistry.registerItem(TRContent.RUBY_CHESTPLATE = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.RUBY, EquipmentSlot.CHEST, "gemRuby"), "ruby_chestplate")); + RebornRegistry.registerItem(TRContent.RUBY_LEGGINGS = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.RUBY, EquipmentSlot.LEGS, "gemRuby"), "ruby_leggings")); + RebornRegistry.registerItem(TRContent.RUBY_BOOTS = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.RUBY, EquipmentSlot.FEET, "gemRuby"), "ruby_boots")); RebornRegistry.registerItem(TRContent.SAPPHIRE_SWORD = InitUtils.setup(new ItemTRSword(TRToolTier.SAPPHIRE, "gemSapphire"), "sapphire_sword")); RebornRegistry.registerItem(TRContent.SAPPHIRE_PICKAXE = InitUtils.setup(new ItemTRPickaxe(TRToolTier.SAPPHIRE, "gemSapphire"), "sapphire_pickaxe")); @@ -157,10 +157,10 @@ public class RegistryEventHandler { RebornRegistry.registerItem(TRContent.SAPPHIRE_AXE = InitUtils.setup(new ItemTRAxe(TRToolTier.SAPPHIRE, "gemSapphire"), "sapphire_axe")); RebornRegistry.registerItem(TRContent.SAPPHIRE_HOE = InitUtils.setup(new ItemTRHoe(TRToolTier.SAPPHIRE, "gemSapphire"), "sapphire_hoe")); - RebornRegistry.registerItem(TRContent.SAPPHIRE_HELMET = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.SAPPHIRE, EntityEquipmentSlot.HEAD, "gemSapphire"), "sapphire_helmet")); - RebornRegistry.registerItem(TRContent.SAPPHIRE_CHESTPLATE = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.SAPPHIRE, EntityEquipmentSlot.CHEST, "gemSapphire"), "sapphire_chestplate")); - RebornRegistry.registerItem(TRContent.SAPPHIRE_LEGGINGS = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.SAPPHIRE, EntityEquipmentSlot.LEGS, "gemSapphire"), "sapphire_leggings")); - RebornRegistry.registerItem(TRContent.SAPPHIRE_BOOTS = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.SAPPHIRE, EntityEquipmentSlot.FEET, "gemSapphire"), "sapphire_boots")); + RebornRegistry.registerItem(TRContent.SAPPHIRE_HELMET = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.SAPPHIRE, EquipmentSlot.HEAD, "gemSapphire"), "sapphire_helmet")); + RebornRegistry.registerItem(TRContent.SAPPHIRE_CHESTPLATE = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.SAPPHIRE, EquipmentSlot.CHEST, "gemSapphire"), "sapphire_chestplate")); + RebornRegistry.registerItem(TRContent.SAPPHIRE_LEGGINGS = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.SAPPHIRE, EquipmentSlot.LEGS, "gemSapphire"), "sapphire_leggings")); + RebornRegistry.registerItem(TRContent.SAPPHIRE_BOOTS = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.SAPPHIRE, EquipmentSlot.FEET, "gemSapphire"), "sapphire_boots")); RebornRegistry.registerItem(TRContent.PERIDOT_SWORD = InitUtils.setup(new ItemTRSword(TRToolTier.PERIDOT, "gemPeridot"), "peridot_sword")); RebornRegistry.registerItem(TRContent.PERIDOT_PICKAXE = InitUtils.setup(new ItemTRPickaxe(TRToolTier.PERIDOT, "gemPeridot"), "peridot_pickaxe")); @@ -168,10 +168,10 @@ public class RegistryEventHandler { RebornRegistry.registerItem(TRContent.PERIDOT_AXE = InitUtils.setup(new ItemTRAxe(TRToolTier.PERIDOT, "gemPeridot"), "peridot_axe")); RebornRegistry.registerItem(TRContent.PERIDOT_HOE = InitUtils.setup(new ItemTRHoe(TRToolTier.PERIDOT, "gemPeridot"), "peridot_hoe")); - RebornRegistry.registerItem(TRContent.PERIDOT_HELMET = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.PERIDOT, EntityEquipmentSlot.HEAD, "gemPeridot"), "peridot_helmet")); - RebornRegistry.registerItem(TRContent.PERIDOT_CHESTPLATE = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.PERIDOT, EntityEquipmentSlot.CHEST, "gemPeridot"), "peridot_chestplate")); - RebornRegistry.registerItem(TRContent.PERIDOT_LEGGINGS = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.PERIDOT, EntityEquipmentSlot.LEGS, "gemPeridot"), "peridot_leggings")); - RebornRegistry.registerItem(TRContent.PERIDOT_BOOTS = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.PERIDOT, EntityEquipmentSlot.FEET, "gemPeridot"), "peridot_boots")); + RebornRegistry.registerItem(TRContent.PERIDOT_HELMET = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.PERIDOT, EquipmentSlot.HEAD, "gemPeridot"), "peridot_helmet")); + RebornRegistry.registerItem(TRContent.PERIDOT_CHESTPLATE = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.PERIDOT, EquipmentSlot.CHEST, "gemPeridot"), "peridot_chestplate")); + RebornRegistry.registerItem(TRContent.PERIDOT_LEGGINGS = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.PERIDOT, EquipmentSlot.LEGS, "gemPeridot"), "peridot_leggings")); + RebornRegistry.registerItem(TRContent.PERIDOT_BOOTS = InitUtils.setup(new ItemTRArmour(TRArmorMaterial.PERIDOT, EquipmentSlot.FEET, "gemPeridot"), "peridot_boots")); } // Battery @@ -222,7 +222,7 @@ public class RegistryEventHandler { } @SubscribeEvent - public static void registerTiles(RegistryEvent.Register> event) { + public static void registerTiles(RegistryEvent.Register> event) { TRTileEntities.TYPES.forEach(tileEntityType -> event.getRegistry().register(tileEntityType)); } @@ -230,7 +230,7 @@ public class RegistryEventHandler { @SubscribeEvent public static void registerEntityTypes(RegistryEvent.Register> event) { TRContent.ENTITY_NUKE = EntityType.Builder.create(EntityNukePrimed.class, EntityNukePrimed::new).build("nuke"); - TRContent.ENTITY_NUKE.setRegistryName(new ResourceLocation(TechReborn.MOD_ID, "nuke")); + TRContent.ENTITY_NUKE.setRegistryName(new Identifier(TechReborn.MOD_ID, "nuke")); event.getRegistry().register(TRContent.ENTITY_NUKE); } diff --git a/src/main/java/techreborn/events/StackToolTipEvent.java b/src/main/java/techreborn/events/StackToolTipEvent.java index e8fbbe0f5..025c0babf 100644 --- a/src/main/java/techreborn/events/StackToolTipEvent.java +++ b/src/main/java/techreborn/events/StackToolTipEvent.java @@ -24,21 +24,21 @@ package techreborn.events; +import net.minecraft.ChatFormat; import net.minecraft.block.Block; -import net.minecraft.block.BlockContainer; -import net.minecraft.block.ITileEntityProvider; -import net.minecraft.client.Minecraft; -import net.minecraft.client.util.InputMappings; +import net.minecraft.block.BlockEntityProvider; +import net.minecraft.block.BlockWithEntity; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.util.InputUtil; import net.minecraft.item.Item; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.energy.IEnergyStorage; -import net.minecraftforge.event.entity.player.ItemTooltipEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.TextComponent; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + + + import org.lwjgl.glfw.GLFW; import reborncore.api.IListInfoProvider; import reborncore.api.power.IEnergyItemInfo; @@ -51,7 +51,7 @@ import techreborn.TechReborn; public class StackToolTipEvent { @SuppressWarnings("deprecation") - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @SubscribeEvent public void handleItemTooltipEvent(ItemTooltipEvent event) { if (event.getEntityPlayer() == null) { @@ -62,41 +62,41 @@ public class StackToolTipEvent { ((IListInfoProvider) item).addInfo(event.getToolTip(), false, false); } else if (event.getItemStack().getItem() instanceof IEnergyItemInfo) { IEnergyStorage capEnergy = new ForgePowerItemManager(event.getItemStack()); - TextComponentString line1 = new TextComponentString(PowerSystem + TextComponent line1 = new TextComponent(PowerSystem .getLocaliszedPowerFormattedNoSuffix(capEnergy.getEnergyStored() / RebornCoreConfig.euPerFU)); - line1.appendText("/"); - line1.appendText(PowerSystem + line1.append("/"); + line1.append(PowerSystem .getLocaliszedPowerFormattedNoSuffix(capEnergy.getMaxEnergyStored() / RebornCoreConfig.euPerFU)); - line1.appendText(" "); - line1.appendText(PowerSystem.getDisplayPower().abbreviation); - line1.applyTextStyle(TextFormatting.GOLD); + line1.append(" "); + line1.append(PowerSystem.getDisplayPower().abbreviation); + line1.applyFormat(ChatFormat.GOLD); event.getToolTip().add(1, line1); - if (InputMappings.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT) - || InputMappings.isKeyDown(GLFW.GLFW_KEY_RIGHT_SHIFT)) { + if (InputUtil.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT) + || InputUtil.isKeyDown(GLFW.GLFW_KEY_RIGHT_SHIFT)) { int percentage = percentage(capEnergy.getMaxEnergyStored(), capEnergy.getEnergyStored()); - TextFormatting color = StringUtils.getPercentageColour(percentage); + ChatFormat color = StringUtils.getPercentageColour(percentage); event.getToolTip().add(2, - new TextComponentString(color + "" + percentage + "%" + TextFormatting.GRAY + " Charged")); + new TextComponent(color + "" + percentage + "%" + ChatFormat.GRAY + " Charged")); // TODO: show both input and output rates - event.getToolTip().add(3, new TextComponentString(TextFormatting.GRAY + "I/O Rate: " - + TextFormatting.GOLD + event.getToolTip().add(3, new TextComponent(ChatFormat.GRAY + "I/O Rate: " + + ChatFormat.GOLD + PowerSystem.getLocaliszedPowerFormatted((int) ((IEnergyItemInfo) item).getMaxInput()))); } } else { try { Block block = Block.getBlockFromItem(item); - if (block != null && (block instanceof BlockContainer || block instanceof ITileEntityProvider) + if (block != null && (block instanceof BlockWithEntity || block instanceof BlockEntityProvider) && block.getRegistryName().getNamespace().contains("techreborn")) { - TileEntity tile = block.createTileEntity(block.getDefaultState(), Minecraft.getInstance().world); + BlockEntity tile = block.createTileEntity(block.getDefaultState(), MinecraftClient.getInstance().world); boolean hasData = false; if (event.getItemStack().hasTag() && event.getItemStack().getTag().contains("tile_data")) { - NBTTagCompound tileData = event.getItemStack().getTag().getCompound("tile_data"); - tile.read(tileData); + CompoundTag tileData = event.getItemStack().getTag().getCompound("tile_data"); + tile.fromTag(tileData); hasData = true; event.getToolTip() - .add(new TextComponentString("Block data contained").applyTextStyle(TextFormatting.DARK_GREEN)); + .add(new TextComponent("Block data contained").applyFormat(ChatFormat.DARK_GREEN)); } if (tile instanceof IListInfoProvider) { ((IListInfoProvider) tile).addInfo(event.getToolTip(), false, hasData); diff --git a/src/main/java/techreborn/events/TRRecipeHandler.java b/src/main/java/techreborn/events/TRRecipeHandler.java index 7df46e08d..85a6beef1 100644 --- a/src/main/java/techreborn/events/TRRecipeHandler.java +++ b/src/main/java/techreborn/events/TRRecipeHandler.java @@ -24,17 +24,17 @@ package techreborn.events; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.Ingredient; +import net.minecraft.recipe.Ingredient; +import net.minecraft.recipe.Recipe; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.world.World; -import net.minecraftforge.common.crafting.RecipeType; -import net.minecraftforge.common.crafting.VanillaRecipeTypes; -import net.minecraftforge.common.util.FakePlayer; -import net.minecraftforge.event.entity.player.EntityItemPickupEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.registries.IForgeRegistryEntry; + + + + + + import reborncore.common.util.ItemUtils; import techreborn.TechReborn; import techreborn.init.TRContent; @@ -59,10 +59,10 @@ public class TRRecipeHandler { return; } World world = entityItemPickupEvent.getItem().world; - if (entityItemPickupEvent.getEntityPlayer() instanceof EntityPlayerMP) { + if (entityItemPickupEvent.getEntityPlayer() instanceof ServerPlayerEntity) { if (ItemUtils.isInputEqual("logWood", entityItemPickupEvent.getItem().getItem(), false, true)) { - for (IRecipe recipe : world.getRecipeManager().getRecipes()) { - if (recipe.getRecipeOutput().getItem() == TRContent.TREE_TAP) { + for (Recipe recipe : world.getRecipeManager().getRecipes()) { + if (recipe.getOutput().getItem() == TRContent.TREE_TAP) { entityItemPickupEvent.getEntityPlayer().unlockRecipes(Collections.singletonList(recipe)); } } @@ -70,9 +70,9 @@ public class TRRecipeHandler { } } - public static void unlockTRRecipes(EntityPlayerMP playerMP) { - List recipeList = new ArrayList<>(); - for (IRecipe recipe : getRecipes(playerMP.world, VanillaRecipeTypes.CRAFTING)) { + public static void unlockTRRecipes(ServerPlayerEntity playerMP) { + List recipeList = new ArrayList<>(); + for (Recipe recipe : getRecipes(playerMP.world, VanillaRecipeTypes.CRAFTING)) { if (isRecipeValid(recipe)) { recipeList.add(recipe); } @@ -80,7 +80,7 @@ public class TRRecipeHandler { playerMP.unlockRecipes(recipeList); } - public static List getRecipes(World world, RecipeType type){ + public static List getRecipes(World world, RecipeType type){ return world.getRecipeManager().getRecipes().stream().filter(iRecipe -> iRecipe.getType() == type).collect(Collectors.toList()); } @@ -89,30 +89,30 @@ public class TRRecipeHandler { * Used to get the matching output of a recipe type that only has 1 input * */ - public static ItemStack getMatchingRecipes(World world, RecipeType type, ItemStack input){ + public static ItemStack getMatchingRecipes(World world, RecipeType type, ItemStack input){ return getRecipes(world, type).stream() .filter(iRecipe -> iRecipe.getIngredients().size() == 1 && iRecipe.getIngredients().get(0).test(input)) - .map(IRecipe::getRecipeOutput) + .map(Recipe::getRecipeOutput) .findFirst() .orElse(ItemStack.EMPTY); } - private static boolean isRecipeValid(IRecipe recipe) { + private static boolean isRecipeValid(Recipe recipe) { if (recipe.getId() == null) { return false; } if (!recipe.getId().getNamespace().equals(TechReborn.MOD_ID)) { return false; } - if (!recipe.getRecipeOutput().getItem().getRegistryName().getNamespace().equals(TechReborn.MOD_ID)) { + if (!recipe.getOutput().getItem().getRegistryName().getNamespace().equals(TechReborn.MOD_ID)) { return false; } // if (hiddenEntrys.contains(recipe.getRecipeOutput().getItem())) { // return false; // } //Hide uu recipes - for (Ingredient ingredient : recipe.getIngredients()) { - if (ingredient.test(TRContent.Parts.UU_MATTER.getStack())) { + for (Ingredient ingredient : recipe.getPreviewInputs()) { + if (ingredient.method_8093(TRContent.Parts.UU_MATTER.getStack())) { return false; } } diff --git a/src/main/java/techreborn/events/TRTickHandler.java b/src/main/java/techreborn/events/TRTickHandler.java index c220fd61b..3e5d543c6 100644 --- a/src/main/java/techreborn/events/TRTickHandler.java +++ b/src/main/java/techreborn/events/TRTickHandler.java @@ -24,13 +24,13 @@ package techreborn.events; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.MobEffects; -import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.effect.StatusEffects; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; -import net.minecraftforge.eventbus.api.EventPriority; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; + + + import techreborn.init.TRContent; public class TRTickHandler { @@ -39,12 +39,12 @@ public class TRTickHandler { @SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true) public void onPlayerTick(TickEvent.PlayerTickEvent e) { - EntityPlayer player = e.player; - Item chestslot = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty() - ? player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() : null; + PlayerEntity player = e.player; + Item chestslot = !player.getEquippedStack(EquipmentSlot.CHEST).isEmpty() + ? player.getEquippedStack(EquipmentSlot.CHEST).getItem() : null; if (previouslyWearing != chestslot && previouslyWearing == TRContent.CLOAKING_DEVICE && player.isInvisible() - && !player.isPotionActive(MobEffects.INVISIBILITY)) { + && !player.hasStatusEffect(StatusEffects.INVISIBILITY)) { player.setInvisible(false); } diff --git a/src/main/java/techreborn/init/ModFluids.java b/src/main/java/techreborn/init/ModFluids.java index bbd9d527e..1de77c608 100644 --- a/src/main/java/techreborn/init/ModFluids.java +++ b/src/main/java/techreborn/init/ModFluids.java @@ -24,8 +24,8 @@ package techreborn.init; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.Fluid; +import net.minecraft.util.Identifier; + import techreborn.blocks.fluid.BlockFluidTechReborn; public enum ModFluids { BERYLLIUM, @@ -69,7 +69,7 @@ public enum ModFluids { ModFluids() { this.name = this.name().replace("_", "").toLowerCase(); //Is this ok? - fluid = new Fluid(name, new ResourceLocation("techreborn", "fixme"), new ResourceLocation("techrebonr", "alsofixme")); + fluid = new Fluid(name, new Identifier("techreborn", "fixme"), new Identifier("techrebonr", "alsofixme")); } public Fluid getFluid() { diff --git a/src/main/java/techreborn/init/ModLoot.java b/src/main/java/techreborn/init/ModLoot.java index 7d3351b0a..2b0bc394c 100644 --- a/src/main/java/techreborn/init/ModLoot.java +++ b/src/main/java/techreborn/init/ModLoot.java @@ -24,11 +24,15 @@ package techreborn.init; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Identifier; +import net.minecraft.world.loot.LootPool; +import net.minecraft.world.loot.LootTables; +import net.minecraft.world.loot.UniformLootTableRange; +import net.minecraft.world.loot.condition.LootCondition; +import net.minecraft.world.loot.entry.LootTableEntry; import net.minecraft.world.storage.loot.*; -import net.minecraft.world.storage.loot.conditions.LootCondition; -import net.minecraftforge.event.LootTableLoadEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; + + import techreborn.TechReborn; import techreborn.config.ConfigTechReborn; @@ -37,30 +41,30 @@ import java.util.List; public class ModLoot { - public static List lootTables = new ArrayList(); + public static List lootTables = new ArrayList(); public static void init() { if (ConfigTechReborn.enableOverworldLoot) { - lootTables.add(new ResourceLocation(TechReborn.MOD_ID, "chests/abandoned_mineshaft")); - lootTables.add(new ResourceLocation(TechReborn.MOD_ID, "chests/desert_pyramid")); - lootTables.add(new ResourceLocation(TechReborn.MOD_ID, "chests/igloo_chest")); - lootTables.add(new ResourceLocation(TechReborn.MOD_ID, "chests/jungle_temple")); - lootTables.add(new ResourceLocation(TechReborn.MOD_ID, "chests/simple_dungeon")); - lootTables.add(new ResourceLocation(TechReborn.MOD_ID, "chests/stronghold_corridor")); - lootTables.add(new ResourceLocation(TechReborn.MOD_ID, "chests/stronghold_crossing")); - lootTables.add(new ResourceLocation(TechReborn.MOD_ID, "chests/stronghold_library")); - lootTables.add(new ResourceLocation(TechReborn.MOD_ID, "chests/village_blacksmith")); - lootTables.add(new ResourceLocation(TechReborn.MOD_ID, "chests/woodland_mansion")); + lootTables.add(new Identifier(TechReborn.MOD_ID, "chests/abandoned_mineshaft")); + lootTables.add(new Identifier(TechReborn.MOD_ID, "chests/desert_pyramid")); + lootTables.add(new Identifier(TechReborn.MOD_ID, "chests/igloo_chest")); + lootTables.add(new Identifier(TechReborn.MOD_ID, "chests/jungle_temple")); + lootTables.add(new Identifier(TechReborn.MOD_ID, "chests/simple_dungeon")); + lootTables.add(new Identifier(TechReborn.MOD_ID, "chests/stronghold_corridor")); + lootTables.add(new Identifier(TechReborn.MOD_ID, "chests/stronghold_crossing")); + lootTables.add(new Identifier(TechReborn.MOD_ID, "chests/stronghold_library")); + lootTables.add(new Identifier(TechReborn.MOD_ID, "chests/village_blacksmith")); + lootTables.add(new Identifier(TechReborn.MOD_ID, "chests/woodland_mansion")); } if (ConfigTechReborn.enableNetherLoot) { - lootTables.add(new ResourceLocation(TechReborn.MOD_ID, "chests/nether_bridge")); + lootTables.add(new Identifier(TechReborn.MOD_ID, "chests/nether_bridge")); } if (ConfigTechReborn.enableEndLoot) { - lootTables.add(new ResourceLocation(TechReborn.MOD_ID, "chests/end_city_treasure")); + lootTables.add(new Identifier(TechReborn.MOD_ID, "chests/end_city_treasure")); } - for (ResourceLocation lootTable : lootTables) { - LootTableList.register(lootTable); + for (Identifier lootTable : lootTables) { + LootTables.registerLootTable(lootTable); } } @@ -69,7 +73,7 @@ public class ModLoot { if (!event.getName().getNamespace().equals("minecraft")) { return; } - for (ResourceLocation lootTable : lootTables) { + for (Identifier lootTable : lootTables) { if (event.getName().getNamespace().equals(lootTable.getPath())) { event.getTable().addPool(getLootPool(lootTable)); TechReborn.LOGGER.debug("Loot pool injected into " + lootTable.getPath()); @@ -83,9 +87,9 @@ public class ModLoot { * @param lootTable ResourceLocation Loot table to inject * @return LootPool Loot pool to inject */ - private LootPool getLootPool(ResourceLocation lootTable) { - LootEntry entry = new LootEntryTable(lootTable, 1, 0, new LootCondition[0], "lootEntry_" + lootTable.toString()); - LootPool pool = new LootPool(new LootEntry[] { entry }, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "lootPool_" + lootTable.toString()); + private LootPool getLootPool(Identifier lootTable) { + LootEntry entry = new LootTableEntry(lootTable, 1, 0, new LootCondition[0], "lootEntry_" + lootTable.toString()); + LootPool pool = new LootPool(new LootEntry[] { entry }, new LootCondition[0], new UniformLootTableRange(1), new UniformLootTableRange(0, 1), "lootPool_" + lootTable.toString()); return pool; } } diff --git a/src/main/java/techreborn/init/ModRecipes.java b/src/main/java/techreborn/init/ModRecipes.java index 1a497a973..6557e6c3e 100644 --- a/src/main/java/techreborn/init/ModRecipes.java +++ b/src/main/java/techreborn/init/ModRecipes.java @@ -25,10 +25,10 @@ package techreborn.init; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidUtil; +import net.minecraft.util.Identifier; + + + import reborncore.common.crafting.Recipe; import reborncore.common.crafting.RecipeManager; import reborncore.common.crafting.RecipeType; @@ -42,23 +42,23 @@ import techreborn.api.recipe.recipes.IndustrialSawmillRecipe; public class ModRecipes { - public static final RecipeType ALLOY_SMELTER = RecipeManager.newRecipeType(Recipe.class, new ResourceLocation("techreborn:alloy_smelter")); - public static final RecipeType ASSEMBLING_MACHINE = RecipeManager.newRecipeType(Recipe.class, new ResourceLocation("techreborn:assembling_machine")); - public static final RecipeType BLAST_FURNACE = RecipeManager.newRecipeType(BlastFurnaceRecipe.class, new ResourceLocation("techreborn:blast_furnace")); - public static final RecipeType CENTRIFUGE = RecipeManager.newRecipeType(Recipe.class, new ResourceLocation("techreborn:centrifuge")); - public static final RecipeType CHEMICAL_REACTOR = RecipeManager.newRecipeType(Recipe.class, new ResourceLocation("techreborn:chemical_reactor")); - public static final RecipeType COMPRESSOR = RecipeManager.newRecipeType(Recipe.class, new ResourceLocation("techreborn:compressor")); - public static final RecipeType DISTILLATION_TOWER = RecipeManager.newRecipeType(Recipe.class, new ResourceLocation("techreborn:distillation_tower")); - public static final RecipeType EXTRACTOR = RecipeManager.newRecipeType(Recipe.class, new ResourceLocation("techreborn:extractor")); - public static final RecipeType GRINDER = RecipeManager.newRecipeType(Recipe.class, new ResourceLocation("techreborn:grinder")); - public static final RecipeType IMPLOSION_COMPRESSOR = RecipeManager.newRecipeType(Recipe.class, new ResourceLocation("techreborn:implosion_compressor")); - public static final RecipeType INDUSTRIAL_ELECTROLYZER = RecipeManager.newRecipeType(Recipe.class, new ResourceLocation("techreborn:industrial_electrolyzer")); - public static final RecipeType INDUSTRIAL_GRINDER = RecipeManager.newRecipeType(IndustrialGrinderRecipe.class, new ResourceLocation("techreborn:industrial_grinder")); - public static final RecipeType INDUSTRIAL_SAWMILL = RecipeManager.newRecipeType(IndustrialSawmillRecipe.class, new ResourceLocation("techreborn:industrial_sawmill")); - public static final RecipeType RECYCLER = RecipeManager.newRecipeType(Recipe.class, new ResourceLocation("techreborn:recycler")); - public static final RecipeType SCRAPBOX = RecipeManager.newRecipeType(Recipe.class, new ResourceLocation("techreborn:scrapbox")); - public static final RecipeType VACUUM_FREEZER = RecipeManager.newRecipeType(Recipe.class, new ResourceLocation("techreborn:vacuum_freezer")); - public static final RecipeType FLUID_REPLICATOR = RecipeManager.newRecipeType(Recipe.class, new ResourceLocation("techreborn:fluid_replicator")); + public static final RecipeType ALLOY_SMELTER = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:alloy_smelter")); + public static final RecipeType ASSEMBLING_MACHINE = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:assembling_machine")); + public static final RecipeType BLAST_FURNACE = RecipeManager.newRecipeType(BlastFurnaceRecipe.class, new Identifier("techreborn:blast_furnace")); + public static final RecipeType CENTRIFUGE = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:centrifuge")); + public static final RecipeType CHEMICAL_REACTOR = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:chemical_reactor")); + public static final RecipeType COMPRESSOR = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:compressor")); + public static final RecipeType EnvTypeILLATION_TOWER = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:EnvTypeillation_tower")); + public static final RecipeType EXTRACTOR = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:extractor")); + public static final RecipeType GRINDER = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:grinder")); + public static final RecipeType IMPLOSION_COMPRESSOR = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:implosion_compressor")); + public static final RecipeType INDUSTRIAL_ELECTROLYZER = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:industrial_electrolyzer")); + public static final RecipeType INDUSTRIAL_GRINDER = RecipeManager.newRecipeType(IndustrialGrinderRecipe.class, new Identifier("techreborn:industrial_grinder")); + public static final RecipeType INDUSTRIAL_SAWMILL = RecipeManager.newRecipeType(IndustrialSawmillRecipe.class, new Identifier("techreborn:industrial_sawmill")); + public static final RecipeType RECYCLER = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:recycler")); + public static final RecipeType SCRAPBOX = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:scrapbox")); + public static final RecipeType VACUUM_FREEZER = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:vacuum_freezer")); + public static final RecipeType FLUID_REPLICATOR = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:fluid_replicator")); @@ -80,7 +80,7 @@ public class ModRecipes { ScrapboxRecipes.init(); ChemicalReactorRecipes.init(); FusionReactorRecipes.init(); - DistillationTowerRecipes.init(); + EnvTypeillationTowerRecipes.init(); AlloySmelterRecipes.init(); FluidReplicatorRecipes.init(); diff --git a/src/main/java/techreborn/init/ModSounds.java b/src/main/java/techreborn/init/ModSounds.java index 80d299324..9ff70d10f 100644 --- a/src/main/java/techreborn/init/ModSounds.java +++ b/src/main/java/techreborn/init/ModSounds.java @@ -24,11 +24,11 @@ package techreborn.init; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvent; -import net.minecraftforge.registries.GameData; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.sound.SoundCategory; +import net.minecraft.sound.SoundEvent; +import net.minecraft.util.Identifier; + import reborncore.common.recipes.ICrafterSoundHanlder; import reborncore.common.recipes.RecipeCrafter; @@ -62,7 +62,7 @@ public class ModSounds { } private static SoundEvent getSound(String str) { - ResourceLocation resourceLocation = new ResourceLocation("techreborn", str); + Identifier resourceLocation = new Identifier("techreborn", str); SoundEvent soundEvent = new SoundEvent(resourceLocation); soundEvent.setRegistryName(resourceLocation); return GameData.register_impl(soundEvent); @@ -71,7 +71,7 @@ public class ModSounds { public static class SoundHandler implements ICrafterSoundHanlder { @Override - public void playSound(boolean firstRun, TileEntity tileEntity) { + public void playSound(boolean firstRun, BlockEntity tileEntity) { tileEntity.getWorld().playSound(null, tileEntity.getPos().getX(), tileEntity.getPos().getY(), tileEntity.getPos().getZ(), ModSounds.MACHINE_RUN, SoundCategory.BLOCKS, 0.1F, 1F); diff --git a/src/main/java/techreborn/init/ModTags.java b/src/main/java/techreborn/init/ModTags.java index 725a4e967..f120bfb7f 100644 --- a/src/main/java/techreborn/init/ModTags.java +++ b/src/main/java/techreborn/init/ModTags.java @@ -25,16 +25,16 @@ package techreborn.init; import net.minecraft.block.Block; -import net.minecraft.tags.BlockTags; -import net.minecraft.tags.Tag; -import net.minecraft.util.ResourceLocation; +import net.minecraft.tag.BlockTags; +import net.minecraft.tag.Tag; +import net.minecraft.util.Identifier; public class ModTags { public static Tag FENCE_IRON = get("fence_iron"); private static Tag get(String name) { - return (Tag) new BlockTags.Wrapper(new ResourceLocation("techreborn", name)); + return (Tag) new BlockTags.CachingTag(new Identifier("techreborn", name)); } } diff --git a/src/main/java/techreborn/init/TRArmorMaterial.java b/src/main/java/techreborn/init/TRArmorMaterial.java index 77b2d1d96..09487caef 100644 --- a/src/main/java/techreborn/init/TRArmorMaterial.java +++ b/src/main/java/techreborn/init/TRArmorMaterial.java @@ -25,29 +25,28 @@ package techreborn.init; import java.util.function.Supplier; - -import net.minecraft.init.SoundEvents; -import net.minecraft.inventory.EntityEquipmentSlot; -import net.minecraft.item.IArmorMaterial; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.LazyLoadBase; -import net.minecraft.util.SoundEvent; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.item.ArmorMaterial; +import net.minecraft.recipe.Ingredient; +import net.minecraft.sound.SoundEvent; +import net.minecraft.sound.SoundEvents; +import net.minecraft.util.Lazy; import techreborn.TechReborn; -public enum TRArmorMaterial implements IArmorMaterial { +public enum TRArmorMaterial implements ArmorMaterial { BRONZE(17, new int[] { 3, 6, 5, 2 }, 8, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 0.0F, () -> { - return Ingredient.fromItems(TRContent.Ingots.BRONZE.asItem()); + return Ingredient.ofItems(TRContent.Ingots.BRONZE.asItem()); }), RUBY(16, new int[] { 2, 7, 5, 2 }, 10, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 0.0F, () -> { - return Ingredient.fromItems(TRContent.Gems.RUBY.asItem()); + return Ingredient.ofItems(TRContent.Gems.RUBY.asItem()); }), SAPPHIRE(19, new int[] { 4, 4, 4, 4 }, 8, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 0.0F, () -> { - return Ingredient.fromItems(TRContent.Gems.SAPPHIRE.asItem()); + return Ingredient.ofItems(TRContent.Gems.SAPPHIRE.asItem()); }), PERIDOT(17, new int[] { 3, 8, 3, 2 }, 16, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 0.0F, () -> { - return Ingredient.fromItems(TRContent.Gems.PERIDOT.asItem()); + return Ingredient.ofItems(TRContent.Gems.PERIDOT.asItem()); }), CLOAKING(5, new int[] { 1, 2, 3, 1 }, 0, SoundEvents.ITEM_ARMOR_EQUIP_GOLD, 0.0F, null); @@ -57,7 +56,7 @@ public enum TRArmorMaterial implements IArmorMaterial { private final int enchantability; private final SoundEvent soundEvent; private final float toughness; - private final LazyLoadBase repairMaterial; + private final Lazy repairMaterial; private TRArmorMaterial(int maxDamageFactor, int[] damageReductionAmountArray, int enchantability, SoundEvent soundEvent, float toughness, Supplier repairMaterialIn) { @@ -66,17 +65,17 @@ public enum TRArmorMaterial implements IArmorMaterial { this.enchantability = enchantability; this.soundEvent = soundEvent; this.toughness = toughness; - this.repairMaterial = new LazyLoadBase<>(repairMaterialIn); + this.repairMaterial = new Lazy<>(repairMaterialIn); } @Override - public int getDurability(EntityEquipmentSlot slotIn) { - return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * maxDamageFactor; + public int getDurability(EquipmentSlot slotIn) { + return MAX_DAMAGE_ARRAY[slotIn.getEntitySlotId()] * maxDamageFactor; } @Override - public int getDamageReductionAmount(EntityEquipmentSlot slotIn) { - return damageReductionAmountArray[slotIn.getIndex()]; + public int getProtectionAmount(EquipmentSlot slotIn) { + return damageReductionAmountArray[slotIn.getEntitySlotId()]; } @Override @@ -85,14 +84,14 @@ public enum TRArmorMaterial implements IArmorMaterial { } @Override - public SoundEvent getSoundEvent() { + public SoundEvent getEquipSound() { return soundEvent; } @Override - public Ingredient getRepairMaterial() { + public Ingredient getRepairIngredient() { if (repairMaterial != null) { - return repairMaterial.getValue(); + return repairMaterial.get(); } return null; } diff --git a/src/main/java/techreborn/init/TRContent.java b/src/main/java/techreborn/init/TRContent.java index 03435cc09..922defa18 100644 --- a/src/main/java/techreborn/init/TRContent.java +++ b/src/main/java/techreborn/init/TRContent.java @@ -27,8 +27,8 @@ package techreborn.init; import net.minecraft.block.Block; import net.minecraft.entity.EntityType; import net.minecraft.item.Item; +import net.minecraft.item.ItemConvertible; import net.minecraft.item.ItemStack; -import net.minecraft.util.IItemProvider; import reborncore.api.power.EnumPowerTier; import reborncore.api.tile.IUpgrade; import reborncore.common.powerSystem.TilePowerAcceptor; @@ -217,7 +217,7 @@ public class TRContent { } } - public static enum Cables implements IItemProvider { + public static enum Cables implements ItemConvertible { COPPER(128, 12.0, true, EnumPowerTier.MEDIUM), TIN(32, 12.0, true, EnumPowerTier.LOW), GOLD(512, 12.0, true, EnumPowerTier.HIGH), @@ -262,7 +262,7 @@ public class TRContent { } } - public static enum Ores implements IItemProvider { + public static enum Ores implements ItemConvertible { BAUXITE, CINNABAR, COPPER, GALENA, IRIDIUM, LEAD, PERIDOT, PYRITE, RUBY, SAPPHIRE, SHELDONITE, SILVER, SODALITE, SPHALERITE, TIN, TUNGSTEN; @@ -281,7 +281,7 @@ public class TRContent { } } - public static enum StorageBlocks implements IItemProvider { + public static enum StorageBlocks implements ItemConvertible { ALUMINUM, BRASS, BRONZE, CHROME, COPPER, ELECTRUM, INVAR, IRIDIUM, IRIDIUM_REINFORCED_STONE, IRIDIUM_REINFORCED_TUNGSTENSTEEL, LEAD, NICKEL, OSMIUM, PERIDOT, PLATINUM, RED_GARNET, REFINED_IRON, RUBY, SAPPHIRE, SILVER, STEEL, TIN, TITANIUM, TUNGSTEN, TUNGSTENSTEEL, YELLOW_GARNET, ZINC; @@ -328,13 +328,13 @@ public class TRContent { } - public static enum Machine implements IItemProvider { + public static enum Machine implements ItemConvertible { ALLOY_SMELTER(new BlockAlloySmelter()), ASSEMBLY_MACHINE(new BlockAssemblingMachine()), AUTO_CRAFTING_TABLE(new BlockAutoCraftingTable()), CHEMICAL_REACTOR(new BlockChemicalReactor()), COMPRESSOR(new BlockCompressor()), - DISTILLATION_TOWER(new BlockDistillationTower()), + EnvTypeILLATION_TOWER(new BlockEnvTypeillationTower()), EXTRACTOR(new BlockExtractor()), FLUID_REPLICATOR(new BlockFluidReplicator()), GRINDER(new BlockGrinder()), @@ -411,7 +411,7 @@ public class TRContent { } } - public static enum Dusts implements IItemProvider { + public static enum Dusts implements ItemConvertible { ALMANDINE, ALUMINUM, ANDESITE, ANDRADITE, ASHES, BASALT, BAUXITE, BRASS, BRONZE, CALCITE, CHARCOAL, CHROME, CINNABAR, CLAY, COAL, COPPER, DARK_ASHES, DIAMOND, DIORITE, ELECTRUM, EMERALD, ENDER_EYE, ENDER_PEARL, ENDSTONE, FLINT, GALENA, GOLD, GRANITE, GROSSULAR, INVAR, IRON, LAZURITE, LEAD, MAGNESIUM, MANGANESE, MARBLE, NETHERRACK, @@ -424,7 +424,7 @@ public class TRContent { private Dusts() { name = this.toString().toLowerCase(); - item = new Item(new Item.Properties().group(TechReborn.ITEMGROUP)); + item = new Item(new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); InitUtils.setup(item, name + "_dust"); } @@ -442,7 +442,7 @@ public class TRContent { } } - public static enum SmallDusts implements IItemProvider { + public static enum SmallDusts implements ItemConvertible { ALMANDINE, ALUMINUM, ANDESITE, ANDRADITE, ASHES, BASALT, BAUXITE, BRASS, BRONZE, CALCITE, CHARCOAL, CHROME, CINNABAR, CLAY, COAL, COPPER, DARK_ASHES, DIAMOND, DIORITE, ELECTRUM, EMERALD, ENDER_EYE, ENDER_PEARL, ENDSTONE, FLINT, GALENA, GLOWSTONE, GOLD, GRANITE, GROSSULAR, INVAR, IRON, LAZURITE, LEAD, MAGNESIUM, MANGANESE, MARBLE, @@ -455,7 +455,7 @@ public class TRContent { private SmallDusts() { name = this.toString().toLowerCase(); - item = new Item(new Item.Properties().group(TechReborn.ITEMGROUP)); + item = new Item(new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); InitUtils.setup(item, name + "_small_dust"); } @@ -473,7 +473,7 @@ public class TRContent { } } - public static enum Gems implements IItemProvider { + public static enum Gems implements ItemConvertible { PERIDOT, RED_GARNET, RUBY, SAPPHIRE, YELLOW_GARNET; public final String name; @@ -481,7 +481,7 @@ public class TRContent { private Gems() { name = this.toString().toLowerCase(); - item = new Item(new Item.Properties().group(TechReborn.ITEMGROUP)); + item = new Item(new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); InitUtils.setup(item, name + "_gem"); } @@ -499,7 +499,7 @@ public class TRContent { } } - public static enum Ingots implements IItemProvider { + public static enum Ingots implements ItemConvertible { ADVANCED_ALLOY, ALUMINUM, BRASS, BRONZE, CHROME, COPPER, ELECTRUM, HOT_TUNGSTENSTEEL, INVAR, IRIDIUM_ALLOY, IRIDIUM, LEAD, MIXED_METAL, NICKEL, PLATINUM, REFINED_IRON, SILVER, STEEL, TIN, TITANIUM, TUNGSTEN, TUNGSTENSTEEL, ZINC; @@ -508,7 +508,7 @@ public class TRContent { private Ingots() { name = this.toString().toLowerCase(); - item = new Item(new Item.Properties().group(TechReborn.ITEMGROUP)); + item = new Item(new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); InitUtils.setup(item, name + "_ingot"); } @@ -526,7 +526,7 @@ public class TRContent { } } - public static enum Nuggets implements IItemProvider { + public static enum Nuggets implements ItemConvertible { ALUMINUM, BRASS, BRONZE, CHROME, COPPER, DIAMOND, ELECTRUM, HOT_TUNGSTENSTEEL, INVAR, IRIDIUM, LEAD, NICKEL, PLATINUM, REFINED_IRON, SILVER, STEEL, TIN, TITANIUM, TUNGSTEN, TUNGSTENSTEEL, ZINC; @@ -535,7 +535,7 @@ public class TRContent { private Nuggets() { name = this.toString().toLowerCase(); - item = new Item(new Item.Properties().group(TechReborn.ITEMGROUP)); + item = new Item(new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); InitUtils.setup(item, name + "_nugget"); } @@ -553,7 +553,7 @@ public class TRContent { } } - public static enum Parts implements IItemProvider { + public static enum Parts implements ItemConvertible { CARBON_FIBER, CARBON_MESH, @@ -602,7 +602,7 @@ public class TRContent { private Parts() { name = this.toString().toLowerCase(); - item = new Item(new Item.Properties().group(TechReborn.ITEMGROUP)); + item = new Item(new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); InitUtils.setup(item, name); } @@ -620,7 +620,7 @@ public class TRContent { } } - public static enum Plates implements IItemProvider { + public static enum Plates implements ItemConvertible { ADVANCED_ALLOY, ALUMINUM, BRASS, BRONZE, CARBON, COAL, COPPER, DIAMOND, ELECTRUM, EMERALD, GOLD, INVAR, IRIDIUM_ALLOY, IRIDIUM, IRON, LAPIS, LAZURITE, LEAD, MAGNALIUM, NICKEL, OBSIDIAN, PERIDOT, PLATINUM, RED_GARNET, REDSTONE, REFINED_IRON, RUBY, SAPPHIRE, SILICON, SILVER, STEEL, TIN, TITANIUM, TUNGSTEN, TUNGSTENSTEEL, WOOD, @@ -631,7 +631,7 @@ public class TRContent { private Plates() { name = this.toString().toLowerCase(); - item = new Item(new Item.Properties().group(TechReborn.ITEMGROUP)); + item = new Item(new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); InitUtils.setup(item, name + "_plate"); } @@ -658,7 +658,7 @@ public class TRContent { @ConfigRegistry(config = "items", category = "upgrades", key = "energy_storage", comment = "Energy storage behavior extra power") public static double energyStoragePower = 40_000; - public static enum Upgrades implements IItemProvider { + public static enum Upgrades implements ItemConvertible { OVERCLOCKER((tile, handler, stack) -> { TilePowerAcceptor powerAcceptor = null; if (tile instanceof TilePowerAcceptor) { diff --git a/src/main/java/techreborn/init/TRTileEntities.java b/src/main/java/techreborn/init/TRTileEntities.java index 16a39cfad..508176851 100644 --- a/src/main/java/techreborn/init/TRTileEntities.java +++ b/src/main/java/techreborn/init/TRTileEntities.java @@ -24,9 +24,6 @@ package techreborn.init; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.ResourceLocation; import reborncore.common.tile.TileMachineBase; import techreborn.TechReborn; import techreborn.tiles.*; @@ -63,74 +60,77 @@ import techreborn.tiles.transformers.TileMVTransformer; import java.util.ArrayList; import java.util.List; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.util.Identifier; public class TRTileEntities { - public static List> TYPES = new ArrayList<>(); + public static List> TYPES = new ArrayList<>(); - public static final TileEntityType THERMAL_GEN = register(TileThermalGenerator.class, "thermal_generator"); - public static final TileEntityType QUANTUM_TANK = register(TileQuantumTank.class, "quantum_tank"); - public static final TileEntityType QUANTUM_CHEST = register(TileQuantumChest.class, "quantum_chest"); - public static final TileEntityType DIGITAL_CHEST = register(TileDigitalChest.class, "digital_chest"); - public static final TileEntityType INDUSTRIAL_CENTRIFUGE = register(TileIndustrialCentrifuge.class, "industrial_centrifuge"); - public static final TileEntityType ROLLING_MACHINE = register(TileRollingMachine.class, "rolling_machine"); - public static final TileEntityType INDUSTRIAL_BLAST_FURNACE = register(TileIndustrialBlastFurnace.class, "industrial_blast_furnace"); - public static final TileEntityType ALLOY_SMELTER = register(TileAlloySmelter.class, "alloy_smelter"); - public static final TileEntityType INDUSTRIAL_GRINDER = register(TileIndustrialGrinder.class, "industrial_grinder"); - public static final TileEntityType IMPLOSION_COMPRESSOR = register(TileImplosionCompressor.class, "implosion_compressor"); - public static final TileEntityType MATTER_FABRICATOR = register(TileMatterFabricator.class, "matter_fabricator"); - public static final TileEntityType CHUNK_LOADER = register(TileChunkLoader.class, "chunk_loader"); - public static final TileEntityType CHARGE_O_MAT = register(TileChargeOMat.class, "charge_o_mat"); - public static final TileEntityType PLAYER_DETECTOR = register(TilePlayerDectector.class, "player_detector"); - public static final TileEntityType CABLE = register(TileCable.class, "cable"); - public static final TileEntityType MACHINE_CASINGS = register(TileMachineCasing.class, "machine_casing"); - public static final TileEntityType DRAGON_EGG_SYPHON = register(TileDragonEggSyphon.class, "dragon_egg_syphon"); - public static final TileEntityType ASSEMBLY_MACHINE = register(TileAssemblingMachine.class, "assembly_machine"); - public static final TileEntityType DIESEL_GENERATOR = register(TileDieselGenerator.class, "diesel_generator"); - public static final TileEntityType INDUSTRIAL_ELECTROLYZER = register(TileIndustrialElectrolyzer.class, "industrial_electrolyzer"); - public static final TileEntityType SEMI_FLUID_GENERATOR = register(TileSemiFluidGenerator.class, "semi_fluid_generator"); - public static final TileEntityType GAS_TURBINE = register(TileGasTurbine.class, "gas_turbine"); - public static final TileEntityType IRON_ALLOY_FURNACE = register(TileIronAlloyFurnace.class, "iron_alloy_furnace"); - public static final TileEntityType CHEMICAL_REACTOR = register(TileChemicalReactor.class, "chemical_reactor"); - public static final TileEntityType INTERDIMENSIONAL_SU = register(TileInterdimensionalSU.class, "interdimensional_su"); - public static final TileEntityType ADJUSTABLE_SU = register(TileAdjustableSU.class, "adjustable_su"); - public static final TileEntityType LAPOTRONIC_SU = register(TileLapotronicSU.class, "lapotronic_su"); - public static final TileEntityType LSU_STORAGE = register(TileLSUStorage.class, "lsu_storage"); - public static final TileEntityType DISTILLATION_TOWER = register(TileDistillationTower.class, "distillation_tower"); - public static final TileEntityType VACUUM_FREEZER = register(TileVacuumFreezer.class, "vacuum_freezer"); - public static final TileEntityType FUSION_CONTROL_COMPUTER = register(TileFusionControlComputer.class, "fusion_control_computer"); - public static final TileEntityType LIGHTNING_ROD = register(TileLightningRod.class, "lightning_rod"); - public static final TileEntityType INDUSTRIAL_SAWMILL = register(TileIndustrialSawmill.class, "industrial_sawmill"); - public static final TileEntityType GRINDER = register(TileGrinder.class, "grinder"); - public static final TileEntityType SOLID_FUEL_GENEREATOR = register(TileSolidFuelGenerator.class, "solid_fuel_generator"); - public static final TileEntityType EXTRACTOR = register(TileExtractor.class, "extractor"); - public static final TileEntityType COMPRESSOR = register(TileCompressor.class, "compressor"); - public static final TileEntityType ELECTRIC_FURNACE = register(TileElectricFurnace.class, "electric_furnace"); - public static final TileEntityType SOLAR_PANEL = register(TileSolarPanel.class, "solar_panel"); - public static final TileEntityType CREATIVE_QUANTUM_TANK = register(TileCreativeQuantumTank.class, "creative_quantum_tank"); - public static final TileEntityType CREATIVE_QUANTUM_CHEST = register(TileCreativeQuantumChest.class, "creative_quantum_chest"); - public static final TileEntityType WATER_MILL = register(TileWaterMill.class, "water_mill"); - public static final TileEntityType WIND_MILL = register(TileWindMill.class, "wind_mill"); - public static final TileEntityType MACHINE_BASE = register(TileMachineBase.class, "machine_base"); - public static final TileEntityType RECYCLER = register(TileRecycler.class, "recycler"); - public static final TileEntityType LOW_VOLTAGE_SU = register(TileLowVoltageSU.class, "low_voltage_su"); - public static final TileEntityType MEDIUM_VOLTAGE_SU = register(TileMediumVoltageSU.class, "medium_voltage_su"); - public static final TileEntityType HIGH_VOLTAGE_SU = register(TileHighVoltageSU.class, "high_voltage_su"); - public static final TileEntityType LV_TRANSFORMER = register(TileLVTransformer.class, "lv_transformer"); - public static final TileEntityType MV_TRANSFORMER = register(TileMVTransformer.class, "mv_transformer"); - public static final TileEntityType HV_TRANSFORMER = register(TileHVTransformer.class, "hv_transformer"); - public static final TileEntityType AUTO_CRAFTING_TABLE = register(TileAutoCraftingTable.class, "auto_crafting_table"); - public static final TileEntityType IRON_FURNACE = register(TileIronFurnace.class, "iron_furnace"); - public static final TileEntityType SCRAPBOXINATOR = register(TileScrapboxinator.class, "scrapboxinator"); - public static final TileEntityType PLASMA_GENERATOR = register(TilePlasmaGenerator.class, "plasma_generator"); - public static final TileEntityType LAMP = register(TileLamp.class, "lamp"); - public static final TileEntityType ALARM = register(TileAlarm.class, "alarm"); - public static final TileEntityType FLUID_REPLICATOR = register(TileFluidReplicator.class, "fluid_replicator"); + public static final BlockEntityType THERMAL_GEN = register(TileThermalGenerator.class, "thermal_generator"); + public static final BlockEntityType QUANTUM_TANK = register(TileQuantumTank.class, "quantum_tank"); + public static final BlockEntityType QUANTUM_CHEST = register(TileQuantumChest.class, "quantum_chest"); + public static final BlockEntityType DIGITAL_CHEST = register(TileDigitalChest.class, "digital_chest"); + public static final BlockEntityType INDUSTRIAL_CENTRIFUGE = register(TileIndustrialCentrifuge.class, "industrial_centrifuge"); + public static final BlockEntityType ROLLING_MACHINE = register(TileRollingMachine.class, "rolling_machine"); + public static final BlockEntityType INDUSTRIAL_BLAST_FURNACE = register(TileIndustrialBlastFurnace.class, "industrial_blast_furnace"); + public static final BlockEntityType ALLOY_SMELTER = register(TileAlloySmelter.class, "alloy_smelter"); + public static final BlockEntityType INDUSTRIAL_GRINDER = register(TileIndustrialGrinder.class, "industrial_grinder"); + public static final BlockEntityType IMPLOSION_COMPRESSOR = register(TileImplosionCompressor.class, "implosion_compressor"); + public static final BlockEntityType MATTER_FABRICATOR = register(TileMatterFabricator.class, "matter_fabricator"); + public static final BlockEntityType CHUNK_LOADER = register(TileChunkLoader.class, "chunk_loader"); + public static final BlockEntityType CHARGE_O_MAT = register(TileChargeOMat.class, "charge_o_mat"); + public static final BlockEntityType PLAYER_DETECTOR = register(TilePlayerDectector.class, "player_detector"); + public static final BlockEntityType CABLE = register(TileCable.class, "cable"); + public static final BlockEntityType MACHINE_CASINGS = register(TileMachineCasing.class, "machine_casing"); + public static final BlockEntityType DRAGON_EGG_SYPHON = register(TileDragonEggSyphon.class, "dragon_egg_syphon"); + public static final BlockEntityType ASSEMBLY_MACHINE = register(TileAssemblingMachine.class, "assembly_machine"); + public static final BlockEntityType DIESEL_GENERATOR = register(TileDieselGenerator.class, "diesel_generator"); + public static final BlockEntityType INDUSTRIAL_ELECTROLYZER = register(TileIndustrialElectrolyzer.class, "industrial_electrolyzer"); + public static final BlockEntityType SEMI_FLUID_GENERATOR = register(TileSemiFluidGenerator.class, "semi_fluid_generator"); + public static final BlockEntityType GAS_TURBINE = register(TileGasTurbine.class, "gas_turbine"); + public static final BlockEntityType IRON_ALLOY_FURNACE = register(TileIronAlloyFurnace.class, "iron_alloy_furnace"); + public static final BlockEntityType CHEMICAL_REACTOR = register(TileChemicalReactor.class, "chemical_reactor"); + public static final BlockEntityType INTERDIMENSIONAL_SU = register(TileInterdimensionalSU.class, "interdimensional_su"); + public static final BlockEntityType ADJUSTABLE_SU = register(TileAdjustableSU.class, "adjustable_su"); + public static final BlockEntityType LAPOTRONIC_SU = register(TileLapotronicSU.class, "lapotronic_su"); + public static final BlockEntityType LSU_STORAGE = register(TileLSUStorage.class, "lsu_storage"); + public static final BlockEntityType EnvTypeILLATION_TOWER = register(TileEnvTypeillationTower.class, "EnvTypeillation_tower"); + public static final BlockEntityType VACUUM_FREEZER = register(TileVacuumFreezer.class, "vacuum_freezer"); + public static final BlockEntityType FUSION_CONTROL_COMPUTER = register(TileFusionControlComputer.class, "fusion_control_computer"); + public static final BlockEntityType LIGHTNING_ROD = register(TileLightningRod.class, "lightning_rod"); + public static final BlockEntityType INDUSTRIAL_SAWMILL = register(TileIndustrialSawmill.class, "industrial_sawmill"); + public static final BlockEntityType GRINDER = register(TileGrinder.class, "grinder"); + public static final BlockEntityType SOLID_FUEL_GENEREATOR = register(TileSolidFuelGenerator.class, "solid_fuel_generator"); + public static final BlockEntityType EXTRACTOR = register(TileExtractor.class, "extractor"); + public static final BlockEntityType COMPRESSOR = register(TileCompressor.class, "compressor"); + public static final BlockEntityType ELECTRIC_FURNACE = register(TileElectricFurnace.class, "electric_furnace"); + public static final BlockEntityType SOLAR_PANEL = register(TileSolarPanel.class, "solar_panel"); + public static final BlockEntityType CREATIVE_QUANTUM_TANK = register(TileCreativeQuantumTank.class, "creative_quantum_tank"); + public static final BlockEntityType CREATIVE_QUANTUM_CHEST = register(TileCreativeQuantumChest.class, "creative_quantum_chest"); + public static final BlockEntityType WATER_MILL = register(TileWaterMill.class, "water_mill"); + public static final BlockEntityType WIND_MILL = register(TileWindMill.class, "wind_mill"); + public static final BlockEntityType MACHINE_BASE = register(TileMachineBase.class, "machine_base"); + public static final BlockEntityType RECYCLER = register(TileRecycler.class, "recycler"); + public static final BlockEntityType LOW_VOLTAGE_SU = register(TileLowVoltageSU.class, "low_voltage_su"); + public static final BlockEntityType MEDIUM_VOLTAGE_SU = register(TileMediumVoltageSU.class, "medium_voltage_su"); + public static final BlockEntityType HIGH_VOLTAGE_SU = register(TileHighVoltageSU.class, "high_voltage_su"); + public static final BlockEntityType LV_TRANSFORMER = register(TileLVTransformer.class, "lv_transformer"); + public static final BlockEntityType MV_TRANSFORMER = register(TileMVTransformer.class, "mv_transformer"); + public static final BlockEntityType HV_TRANSFORMER = register(TileHVTransformer.class, "hv_transformer"); + public static final BlockEntityType AUTO_CRAFTING_TABLE = register(TileAutoCraftingTable.class, "auto_crafting_table"); + public static final BlockEntityType IRON_FURNACE = register(TileIronFurnace.class, "iron_furnace"); + public static final BlockEntityType SCRAPBOXINATOR = register(TileScrapboxinator.class, "scrapboxinator"); + public static final BlockEntityType PLASMA_GENERATOR = register(TilePlasmaGenerator.class, "plasma_generator"); + public static final BlockEntityType LAMP = register(TileLamp.class, "lamp"); + public static final BlockEntityType ALARM = register(TileAlarm.class, "alarm"); + public static final BlockEntityType FLUID_REPLICATOR = register(TileFluidReplicator.class, "fluid_replicator"); - public static TileEntityType register(Class tClass, String name) { - return register(new ResourceLocation(TechReborn.MOD_ID, name).toString(), TileEntityType.Builder.create(() -> { + public static BlockEntityType register(Class tClass, String name) { + return register(new Identifier(TechReborn.MOD_ID, name).toString(), BlockEntityType.Builder.create(() -> { //TODO clean this up try { return tClass.newInstance(); @@ -140,9 +140,9 @@ public class TRTileEntities { })); } - public static TileEntityType register(String id, TileEntityType.Builder builder) { - TileEntityType tileEntityType = builder.build(null); - tileEntityType.setRegistryName(new ResourceLocation(id)); + public static BlockEntityType register(String id, BlockEntityType.Builder builder) { + BlockEntityType tileEntityType = builder.build(null); + tileEntityType.setRegistryName(new Identifier(id)); TRTileEntities.TYPES.add(tileEntityType); return tileEntityType; } diff --git a/src/main/java/techreborn/init/TRToolTier.java b/src/main/java/techreborn/init/TRToolTier.java index 5564b8f54..977ca2f0d 100644 --- a/src/main/java/techreborn/init/TRToolTier.java +++ b/src/main/java/techreborn/init/TRToolTier.java @@ -25,21 +25,20 @@ package techreborn.init; import java.util.function.Supplier; - -import net.minecraft.item.IItemTier; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.LazyLoadBase; +import net.minecraft.item.ToolMaterial; +import net.minecraft.recipe.Ingredient; +import net.minecraft.util.Lazy; //TODO: Use tags -public enum TRToolTier implements IItemTier { +public enum TRToolTier implements ToolMaterial { BRONZE(2, 375, 6.0f, 2.25f, 8, () -> { - return Ingredient.fromItems(TRContent.Ingots.BRONZE.asItem()); + return Ingredient.ofItems(TRContent.Ingots.BRONZE.asItem()); }), RUBY(2, 320, 6.2F, 2.7F, 10, () -> { - return Ingredient.fromItems(TRContent.Gems.RUBY.asItem()); + return Ingredient.ofItems(TRContent.Gems.RUBY.asItem()); }), SAPPHIRE(3, 620, 5.0F, 2F, 8, () -> { - return Ingredient.fromItems(TRContent.Gems.SAPPHIRE.asItem()); + return Ingredient.ofItems(TRContent.Gems.SAPPHIRE.asItem()); }), PERIDOT(2, 400, 7.0F, 2.4F, 16, () -> { - return Ingredient.fromItems(TRContent.Gems.PERIDOT.asItem()); + return Ingredient.ofItems(TRContent.Gems.PERIDOT.asItem()); }); /** @@ -61,7 +60,7 @@ public enum TRToolTier implements IItemTier { private final float attackDamage; /** Defines the natural enchantability factor of the material. */ private final int enchantability; - private final LazyLoadBase repairMaterial; + private final Lazy repairMaterial; private TRToolTier(int harvestLevelIn, int maxUsesIn, float efficiencyIn, float attackDamageIn, int enchantabilityIn, Supplier repairMaterialIn) { @@ -70,16 +69,16 @@ public enum TRToolTier implements IItemTier { this.efficiency = efficiencyIn; this.attackDamage = attackDamageIn; this.enchantability = enchantabilityIn; - this.repairMaterial = new LazyLoadBase<>(repairMaterialIn); + this.repairMaterial = new Lazy<>(repairMaterialIn); } @Override - public int getMaxUses() { + public int getDurability() { return maxUses; } @Override - public float getEfficiency() { + public float getBlockBreakingSpeed() { return efficiency; } @@ -89,7 +88,7 @@ public enum TRToolTier implements IItemTier { } @Override - public int getHarvestLevel() { + public int getMiningLevel() { return harvestLevel; } @@ -99,7 +98,7 @@ public enum TRToolTier implements IItemTier { } @Override - public Ingredient getRepairMaterial() { - return repairMaterial.getValue(); + public Ingredient getRepairIngredient() { + return repairMaterial.get(); } } diff --git a/src/main/java/techreborn/init/recipes/ChemicalReactorRecipes.java b/src/main/java/techreborn/init/recipes/ChemicalReactorRecipes.java index 0904c7a21..0cdaec675 100644 --- a/src/main/java/techreborn/init/recipes/ChemicalReactorRecipes.java +++ b/src/main/java/techreborn/init/recipes/ChemicalReactorRecipes.java @@ -24,9 +24,9 @@ package techreborn.init.recipes; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; +import net.minecraft.block.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; /** * @author drcrazy diff --git a/src/main/java/techreborn/init/recipes/CraftingTableRecipes.java b/src/main/java/techreborn/init/recipes/CraftingTableRecipes.java index a005eea83..e19c1c182 100644 --- a/src/main/java/techreborn/init/recipes/CraftingTableRecipes.java +++ b/src/main/java/techreborn/init/recipes/CraftingTableRecipes.java @@ -109,7 +109,7 @@ public class CraftingTableRecipes extends RecipeMethods { // registerShaped(getStack(TRContent.INDUSTRIAL_GRINDER), "ECG", "HHH", "CBC", 'E', getStack(TRContent.INDUSTRIAL_ELECTROLYZER), 'H', "craftingDiamondGrinder", 'C', "circuitAdvanced", 'B', "machineBlockAdvanced", 'G', getStack(TRContent.GRINDER)); // registerShaped(getStack(ModBlocks.IMPLOSION_COMPRESSOR), "ABA", "CPC", "ABA", 'A', getMaterialObject("advancedAlloy", Type.INGOT), 'C', "circuitAdvanced", 'B', "machineBlockAdvanced", 'P', getStack(ModBlocks.COMPRESSOR)); // registerShaped(getStack(TRContent.VACUUM_FREEZER), "SPS", "CGC", "SPS", 'S', "plateSteel", 'C', "circuitAdvanced", 'G', "glassReinforced", 'P', getStack(TRContent.EXTRACTOR)); -// registerShaped(getStack(TRContent.DISTILLATION_TOWER), "CMC", "PBP", "EME", 'E', getStack(TRContent.INDUSTRIAL_ELECTROLYZER), 'M', "circuitMaster", 'B', "machineBlockElite", 'C', getStack(TRContent.INDUSTRIAL_CENTRIFUGE), 'P', getStack(TRContent.EXTRACTOR)); +// registerShaped(getStack(TRContent.EnvTypeILLATION_TOWER), "CMC", "PBP", "EME", 'E', getStack(TRContent.INDUSTRIAL_ELECTROLYZER), 'M', "circuitMaster", 'B', "machineBlockElite", 'C', getStack(TRContent.INDUSTRIAL_CENTRIFUGE), 'P', getStack(TRContent.EXTRACTOR)); // registerShaped(getStack(TRContent.CHEMICAL_REACTOR), "IMI", "CPC", "IEI", 'I', "plateInvar", 'C', "circuitAdvanced", 'M', getStack(TRContent.EXTRACTOR), 'P', getStack(TRContent.COMPRESSOR), 'E', getStack(TRContent.EXTRACTOR)); // registerShaped(getStack(TRContent.ROLLING_MACHINE), "PCP", "MBM", "PCP", 'P', getStack(Blocks.PISTON), 'C', "circuitAdvanced", 'M', getStack(TRContent.COMPRESSOR), 'B', "machineBlockBasic"); // registerShaped(getStack(TRContent.AUTO_CRAFTING_TABLE), "MPM", "PCP", "MPM", 'M', "circuitAdvanced", 'C', "workbench", 'P', "plateIron"); diff --git a/src/main/java/techreborn/init/recipes/DistillationTowerRecipes.java b/src/main/java/techreborn/init/recipes/DistillationTowerRecipes.java index 660fce274..9af9b5217 100644 --- a/src/main/java/techreborn/init/recipes/DistillationTowerRecipes.java +++ b/src/main/java/techreborn/init/recipes/DistillationTowerRecipes.java @@ -34,7 +34,7 @@ import java.security.InvalidParameterException; * @author drcrazy * */ -public class DistillationTowerRecipes extends RecipeMethods { +public class EnvTypeillationTowerRecipes extends RecipeMethods { public static void init() { register(ItemCells.getCellByName("oil", 16), 1400, 13, getMaterial("diesel", 16, Type.CELL), getMaterial("sulfuricAcid", 16, Type.CELL), getMaterial("glyceryl", Type.CELL)); @@ -61,18 +61,18 @@ public class DistillationTowerRecipes extends RecipeMethods { output3 = outputs[2]; output4 = outputs[3]; } else { - throw new InvalidParameterException("Invalid number of distillation tower outputs: " + outputs); + throw new InvalidParameterException("Invalid number of EnvTypeillation tower outputs: " + outputs); } int cellCount = 0; for (ItemStack stack : outputs) { if (stack.getItem() instanceof DynamicCell) { - cellCount += stack.getCount(); + cellCount += stack.getAmount(); } } if (input.getItem() instanceof DynamicCell) { - int inputCount = input.getCount(); + int inputCount = input.getAmount(); if (cellCount < inputCount) { if (output2 == null) { output2 = DynamicCell.getEmptyCell(inputCount - cellCount); @@ -90,11 +90,11 @@ public class DistillationTowerRecipes extends RecipeMethods { ItemStack cells = null; if (cellCount > 0) { if (cellCount > 64) { - throw new InvalidParameterException("Invalid distillation tower outputs: " + outputs + "(Recipe requires > 64 cells)"); + throw new InvalidParameterException("Invalid EnvTypeillation tower outputs: " + outputs + "(Recipe requires > 64 cells)"); } cells = DynamicCell.getEmptyCell(cellCount); } - // RecipeHandler.addRecipe(Reference.DISTILLATION_TOWER_RECIPE, new DistillationTowerRecipe(input, cells, output1, output2, output3, output4, ticks, euPerTick, oreDict)); + // RecipeHandler.addRecipe(Reference.EnvTypeILLATION_TOWER_RECIPE, new EnvTypeillationTowerRecipe(input, cells, output1, output2, output3, output4, ticks, euPerTick, oreDict)); } static void register(ItemStack input, int ticks, int euPerTick, ItemStack... outputs) { diff --git a/src/main/java/techreborn/init/recipes/FluidGeneratorRecipes.java b/src/main/java/techreborn/init/recipes/FluidGeneratorRecipes.java index dadd8c3ab..0e1fa3e48 100644 --- a/src/main/java/techreborn/init/recipes/FluidGeneratorRecipes.java +++ b/src/main/java/techreborn/init/recipes/FluidGeneratorRecipes.java @@ -24,7 +24,7 @@ package techreborn.init.recipes; -import net.minecraftforge.fluids.Fluid; + import techreborn.api.generator.EFluidGenerator; import techreborn.api.generator.GeneratorRecipeHelper; import techreborn.init.ModFluids; diff --git a/src/main/java/techreborn/init/recipes/ImplosionCompressorRecipes.java b/src/main/java/techreborn/init/recipes/ImplosionCompressorRecipes.java index c2ef37948..73fd3f835 100644 --- a/src/main/java/techreborn/init/recipes/ImplosionCompressorRecipes.java +++ b/src/main/java/techreborn/init/recipes/ImplosionCompressorRecipes.java @@ -24,7 +24,6 @@ package techreborn.init.recipes; -import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import java.security.InvalidParameterException; diff --git a/src/main/java/techreborn/init/recipes/IndustrialCentrifugeRecipes.java b/src/main/java/techreborn/init/recipes/IndustrialCentrifugeRecipes.java index 400e86994..becb6c71e 100644 --- a/src/main/java/techreborn/init/recipes/IndustrialCentrifugeRecipes.java +++ b/src/main/java/techreborn/init/recipes/IndustrialCentrifugeRecipes.java @@ -24,9 +24,9 @@ package techreborn.init.recipes; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; +import net.minecraft.block.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import techreborn.items.DynamicCell; import java.security.InvalidParameterException; @@ -139,14 +139,14 @@ public class IndustrialCentrifugeRecipes extends RecipeMethods { int cellCount = 0; for (ItemStack stack : outputs) { if (stack.getItem() instanceof DynamicCell) { - cellCount += stack.getCount(); + cellCount += stack.getAmount(); } } if (input instanceof ItemStack) { if (((ItemStack) input).getItem() instanceof DynamicCell) { - int inputCount = ((ItemStack) input).getCount(); + int inputCount = ((ItemStack) input).getAmount(); if (cellCount < inputCount) { if (output2 == null) { output2 = DynamicCell.getEmptyCell(inputCount - cellCount); diff --git a/src/main/java/techreborn/init/recipes/RecipeMethods.java b/src/main/java/techreborn/init/recipes/RecipeMethods.java index b4f1cdb88..f52199e98 100644 --- a/src/main/java/techreborn/init/recipes/RecipeMethods.java +++ b/src/main/java/techreborn/init/recipes/RecipeMethods.java @@ -27,7 +27,7 @@ package techreborn.init.recipes; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; +import net.minecraft.recipe.Ingredient; import reborncore.common.util.StringUtils; import techreborn.items.ItemCells; diff --git a/src/main/java/techreborn/init/recipes/RollingMachineRecipes.java b/src/main/java/techreborn/init/recipes/RollingMachineRecipes.java index 438f9d94f..78ab0f069 100644 --- a/src/main/java/techreborn/init/recipes/RollingMachineRecipes.java +++ b/src/main/java/techreborn/init/recipes/RollingMachineRecipes.java @@ -24,10 +24,10 @@ package techreborn.init.recipes; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; +import net.minecraft.block.Blocks; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; +import net.minecraft.item.Items; +import net.minecraft.util.Identifier; import techreborn.TechReborn; import techreborn.init.TRContent; @@ -36,29 +36,29 @@ import techreborn.init.TRContent; */ public class RollingMachineRecipes extends RecipeMethods { public static void init() { - register(new ResourceLocation(TechReborn.MOD_ID, "cupronickel_heating_coil"), TRContent.Parts.CUPRONICKEL_HEATING_COIL.getStack(3), "NCN", "C C", "NCN", 'N', "ingotNickel", 'C', "ingotCopper"); - register(new ResourceLocation(TechReborn.MOD_ID, "nichrome_heating_coil"), TRContent.Parts.NICHROME_HEATING_COIL.getStack(2), " N ", "NCN", " N ", 'N', "ingotNickel", 'C', "ingotChrome"); + register(new Identifier(TechReborn.MOD_ID, "cupronickel_heating_coil"), TRContent.Parts.CUPRONICKEL_HEATING_COIL.getStack(3), "NCN", "C C", "NCN", 'N', "ingotNickel", 'C', "ingotCopper"); + register(new Identifier(TechReborn.MOD_ID, "nichrome_heating_coil"), TRContent.Parts.NICHROME_HEATING_COIL.getStack(2), " N ", "NCN", " N ", 'N', "ingotNickel", 'C', "ingotChrome"); if (oresExist("ingotAluminum")) { - register(new ResourceLocation(TechReborn.MOD_ID, "kanthal_heating_coil"), TRContent.Parts.KANTHAL_HEATING_COIL.getStack(3), "RRR", "CAA", "CCA", 'R', "ingotRefinedIron", 'C', "ingotChrome", 'A', "ingotAluminum"); + register(new Identifier(TechReborn.MOD_ID, "kanthal_heating_coil"), TRContent.Parts.KANTHAL_HEATING_COIL.getStack(3), "RRR", "CAA", "CCA", 'R', "ingotRefinedIron", 'C', "ingotChrome", 'A', "ingotAluminum"); } if (oresExist("ingotAluminium")) { - register(new ResourceLocation(TechReborn.MOD_ID, "kanthal_heating_coil"), TRContent.Parts.KANTHAL_HEATING_COIL.getStack(3), "RRR", "CAA", "CCA", 'R', "ingotRefinedIron", 'C', "ingotChrome", 'A', "ingotAluminium"); + register(new Identifier(TechReborn.MOD_ID, "kanthal_heating_coil"), TRContent.Parts.KANTHAL_HEATING_COIL.getStack(3), "RRR", "CAA", "CCA", 'R', "ingotRefinedIron", 'C', "ingotChrome", 'A', "ingotAluminium"); } - register(new ResourceLocation(TechReborn.MOD_ID, "plateMagnalium"), TRContent.Plates.MAGNALIUM.getStack(3), "AAA", "MMM", "AAA", 'A', "ingotAluminum", 'M', "dustMagnesium"); - register(new ResourceLocation(TechReborn.MOD_ID, "rail"), getStack(Blocks.RAIL, 24), "I I", "ISI", "I I", 'I', "ingotIron", 'S', "stickWood"); - register(new ResourceLocation(TechReborn.MOD_ID, "gold_rail"), getStack(Blocks.POWERED_RAIL, 8), "I I", "ISI", "IRI", 'I', "ingotGold", 'S', "stickWood", 'R', "dustRedstone"); - register(new ResourceLocation(TechReborn.MOD_ID, "detector_rail"), getStack(Blocks.DETECTOR_RAIL, 8), "I I", "IPI", "IRI", 'I', "ingotIron", 'P', getStack(Blocks.STONE_PRESSURE_PLATE), 'R', "dustRedstone"); - register(new ResourceLocation(TechReborn.MOD_ID, "activator_rail"), getStack(Blocks.ACTIVATOR_RAIL, 8), "ISI", "IRI", "ISI", 'I', "ingotIron", 'S', "stickWood", 'R', getStack(Blocks.REDSTONE_TORCH)); - register(new ResourceLocation(TechReborn.MOD_ID, "iron_bars"), getStack(Blocks.IRON_BARS, 24), "III", "III", 'I', "ingotIron"); - register(new ResourceLocation(TechReborn.MOD_ID, "iron_door"), getStack(Blocks.IRON_DOOR, 4), "II ", "II ", "II ", 'I', "ingotIron"); - register(new ResourceLocation(TechReborn.MOD_ID, "minecart"), getStack(Items.MINECART, 2), "I I", "III", 'I', "ingotIron"); - register(new ResourceLocation(TechReborn.MOD_ID, "bucket"), getStack(Items.BUCKET, 2), "I I", "I I", " I ", 'I', "ingotIron"); - register(new ResourceLocation(TechReborn.MOD_ID, "tripwire_hook"), getStack(Blocks.TRIPWIRE_HOOK, 4), " I ", " S ", " W ", 'I', "ingotIron", 'S', "stickWood", 'W', "plankWood"); - register(new ResourceLocation(TechReborn.MOD_ID, "heavy_pressure_plate"), getStack(Blocks.HEAVY_WEIGHTED_PRESSURE_PLATE, 2), "II ", 'I', "ingotIron"); - register(new ResourceLocation(TechReborn.MOD_ID, "light_pressure_plate"), getStack(Blocks.LIGHT_WEIGHTED_PRESSURE_PLATE, 2), "GG ", 'G', "ingotGold"); + register(new Identifier(TechReborn.MOD_ID, "plateMagnalium"), TRContent.Plates.MAGNALIUM.getStack(3), "AAA", "MMM", "AAA", 'A', "ingotAluminum", 'M', "dustMagnesium"); + register(new Identifier(TechReborn.MOD_ID, "rail"), getStack(Blocks.RAIL, 24), "I I", "ISI", "I I", 'I', "ingotIron", 'S', "stickWood"); + register(new Identifier(TechReborn.MOD_ID, "gold_rail"), getStack(Blocks.POWERED_RAIL, 8), "I I", "ISI", "IRI", 'I', "ingotGold", 'S', "stickWood", 'R', "dustRedstone"); + register(new Identifier(TechReborn.MOD_ID, "detector_rail"), getStack(Blocks.DETECTOR_RAIL, 8), "I I", "IPI", "IRI", 'I', "ingotIron", 'P', getStack(Blocks.STONE_PRESSURE_PLATE), 'R', "dustRedstone"); + register(new Identifier(TechReborn.MOD_ID, "activator_rail"), getStack(Blocks.ACTIVATOR_RAIL, 8), "ISI", "IRI", "ISI", 'I', "ingotIron", 'S', "stickWood", 'R', getStack(Blocks.REDSTONE_TORCH)); + register(new Identifier(TechReborn.MOD_ID, "iron_bars"), getStack(Blocks.IRON_BARS, 24), "III", "III", 'I', "ingotIron"); + register(new Identifier(TechReborn.MOD_ID, "iron_door"), getStack(Blocks.IRON_DOOR, 4), "II ", "II ", "II ", 'I', "ingotIron"); + register(new Identifier(TechReborn.MOD_ID, "minecart"), getStack(Items.MINECART, 2), "I I", "III", 'I', "ingotIron"); + register(new Identifier(TechReborn.MOD_ID, "bucket"), getStack(Items.BUCKET, 2), "I I", "I I", " I ", 'I', "ingotIron"); + register(new Identifier(TechReborn.MOD_ID, "tripwire_hook"), getStack(Blocks.TRIPWIRE_HOOK, 4), " I ", " S ", " W ", 'I', "ingotIron", 'S', "stickWood", 'W', "plankWood"); + register(new Identifier(TechReborn.MOD_ID, "heavy_pressure_plate"), getStack(Blocks.HEAVY_WEIGHTED_PRESSURE_PLATE, 2), "II ", 'I', "ingotIron"); + register(new Identifier(TechReborn.MOD_ID, "light_pressure_plate"), getStack(Blocks.LIGHT_WEIGHTED_PRESSURE_PLATE, 2), "GG ", 'G', "ingotGold"); } - static void register(ResourceLocation resourceLocation, ItemStack output, Object... componentsObjects) { + static void register(Identifier resourceLocation, ItemStack output, Object... componentsObjects) { } } diff --git a/src/main/java/techreborn/init/recipes/ScrapboxRecipes.java b/src/main/java/techreborn/init/recipes/ScrapboxRecipes.java index 8ea9c6a98..df417062f 100644 --- a/src/main/java/techreborn/init/recipes/ScrapboxRecipes.java +++ b/src/main/java/techreborn/init/recipes/ScrapboxRecipes.java @@ -25,9 +25,9 @@ package techreborn.init.recipes; import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; +import net.minecraft.block.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import techreborn.init.TRContent; import techreborn.items.DynamicCell; import techreborn.utils.StackWIPHandler; diff --git a/src/main/java/techreborn/init/recipes/SmeltingRecipes.java b/src/main/java/techreborn/init/recipes/SmeltingRecipes.java index afd8f110b..3f784f864 100644 --- a/src/main/java/techreborn/init/recipes/SmeltingRecipes.java +++ b/src/main/java/techreborn/init/recipes/SmeltingRecipes.java @@ -24,8 +24,8 @@ package techreborn.init.recipes; -import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import techreborn.init.TRContent; /** diff --git a/src/main/java/techreborn/itemblocks/ItemBlockRubberSapling.java b/src/main/java/techreborn/itemblocks/ItemBlockRubberSapling.java index f144bb644..d652268e3 100644 --- a/src/main/java/techreborn/itemblocks/ItemBlockRubberSapling.java +++ b/src/main/java/techreborn/itemblocks/ItemBlockRubberSapling.java @@ -25,16 +25,16 @@ package techreborn.itemblocks; import net.minecraft.block.Block; +import net.minecraft.item.BlockItem; import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; import techreborn.TechReborn; /** * Created by modmuss50 on 20/02/2016. */ -public class ItemBlockRubberSapling extends ItemBlock { +public class ItemBlockRubberSapling extends BlockItem { public ItemBlockRubberSapling(Block block) { - super(block, new Item.Properties().group(TechReborn.ITEMGROUP)); + super(block, new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); } } diff --git a/src/main/java/techreborn/items/DynamicCell.java b/src/main/java/techreborn/items/DynamicCell.java index 47e8217f0..c7ff24287 100644 --- a/src/main/java/techreborn/items/DynamicCell.java +++ b/src/main/java/techreborn/items/DynamicCell.java @@ -25,28 +25,28 @@ package techreborn.items; import net.minecraft.block.Block; -import net.minecraft.block.BlockFlowingFluid; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; +import net.minecraft.block.FluidBlock; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundTag; import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.util.NonNullList; +import net.minecraft.util.DefaultedList; +import net.minecraft.util.Hand; +import net.minecraft.util.TypedActionResult; +import net.minecraft.util.hit.HitResult; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; -import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidUtil; -import net.minecraftforge.fluids.IFluidBlock; -import net.minecraftforge.fluids.capability.IFluidHandlerItem; -import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack; + + + + + + + import org.apache.commons.lang3.Validate; import reborncore.common.util.StringUtils; import techreborn.TechReborn; @@ -62,19 +62,19 @@ public class DynamicCell extends Item { public static final int CAPACITY = Fluid.BUCKET_VOLUME; public DynamicCell() { - super(new Item.Properties().group(TechReborn.ITEMGROUP)); + super(new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); TRRecipeHandler.hideEntry(this); } @Override - public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { + public void onEntityTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { //Clearing tag because ItemUtils.isItemEqual doesn't handle tags ForgeCaps and display //And breaks ability to use in recipes //TODO: Property ItemUtils.isItemEquals tags equality handling? if (stack.hasTag()) { - NBTTagCompound tag = stack.getTag(); - if (tag.size() != 1 || tag.contains("Fluid")) { - NBTTagCompound clearTag = new NBTTagCompound(); + CompoundTag tag = stack.getTag(); + if (tag.getSize() != 1 || tag.containsKey("Fluid")) { + CompoundTag clearTag = new CompoundTag(); clearTag.put("Fluid", tag.getCompound("Fluid")); stack.setTag(clearTag); } @@ -82,14 +82,14 @@ public class DynamicCell extends Item { } @Override - public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) { - ItemStack stack = playerIn.getHeldItem(hand); - if (!worldIn.isRemote) { - RayTraceResult result = rayTrace(worldIn, playerIn, true); + public TypedActionResult use(World worldIn, PlayerEntity playerIn, Hand hand) { + ItemStack stack = playerIn.getStackInHand(hand); + if (!worldIn.isClient) { + HitResult result = rayTrace(worldIn, playerIn, true); - if (result != null && result.type == RayTraceResult.Type.BLOCK) { + if (result != null && result.type == HitResult.Type.BLOCK) { BlockPos pos = result.getBlockPos(); - IBlockState state = worldIn.getBlockState(pos); + BlockState state = worldIn.getBlockState(pos); Block block = state.getBlock(); if (block instanceof IFluidBlock) { @@ -101,13 +101,13 @@ public class DynamicCell extends Item { if (fluid != null && fluid.amount == DynamicCell.CAPACITY) { if (tryAddCellToInventory(playerIn, stack, fluid.getFluid())) { fluidBlock.drain(worldIn, pos, true); - return ActionResult.newResult(EnumActionResult.SUCCESS, stack); + return TypedActionResult.newResult(ActionResult.SUCCESS, stack); } } } - } else if (block instanceof BlockFlowingFluid) { + } else if (block instanceof FluidBlock) { //TODO 1.13 fix me // Fluid fluid = state.getMaterial() == Material.LAVA ? Fluids.LAVA : Fluids.WATER; // @@ -119,38 +119,38 @@ public class DynamicCell extends Item { } else { ItemStack usedCell = stack.copy(); - usedCell.setCount(1); + usedCell.setAmount(1); IFluidHandlerItem fluidHandler = FluidUtil.getFluidHandler(usedCell).orElseGet(null); if (fluidHandler != null) { FluidStack fluid = fluidHandler.drain(DynamicCell.CAPACITY, false); if (fluid != null){ if(FluidUtil.tryPlaceFluid(playerIn, worldIn, pos.offset(result.sideHit), fluidHandler, fluid)){ - stack.shrink(1); - playerIn.inventory.addItemStackToInventory(getEmptyCell(1)); - return ActionResult.newResult(EnumActionResult.SUCCESS, stack); + stack.subtractAmount(1); + playerIn.inventory.insertStack(getEmptyCell(1)); + return TypedActionResult.newResult(ActionResult.SUCCESS, stack); } - return ActionResult.newResult(EnumActionResult.FAIL, stack); + return TypedActionResult.newResult(ActionResult.FAIL, stack); } - return ActionResult.newResult(EnumActionResult.FAIL, stack); + return TypedActionResult.newResult(ActionResult.FAIL, stack); } - return ActionResult.newResult(EnumActionResult.FAIL, stack); + return TypedActionResult.newResult(ActionResult.FAIL, stack); } } } - return ActionResult.newResult(EnumActionResult.FAIL, stack); + return TypedActionResult.newResult(ActionResult.FAIL, stack); } - public boolean tryAddCellToInventory(EntityPlayer player, ItemStack stack, Fluid fluid) { - if (player.inventory.addItemStackToInventory(DynamicCell.getCellWithFluid(fluid))) { - stack.shrink(1); + public boolean tryAddCellToInventory(PlayerEntity player, ItemStack stack, Fluid fluid) { + if (player.inventory.insertStack(DynamicCell.getCellWithFluid(fluid))) { + stack.subtractAmount(1); return true; } return false; } @Override - public void fillItemGroup(ItemGroup tab, NonNullList subItems) { - if (!isInGroup(tab)) { + public void appendItemsForGroup(ItemGroup tab, DefaultedList subItems) { + if (!isInItemGroup(tab)) { return; } subItems.add(getEmptyCell(1)); @@ -168,7 +168,7 @@ public class DynamicCell extends Item { } @Override - public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { + public ICapabilityProvider initCapabilities(ItemStack stack, CompoundTag nbt) { return getFluidHandler(stack); } @@ -180,7 +180,7 @@ public class DynamicCell extends Item { Validate.notNull(fluid); ItemStack stack = new ItemStack(TRContent.CELL); getFluidHandler(stack).fill(new FluidStack(fluid, CAPACITY), true); - stack.setCount(stackSize); + stack.setAmount(stackSize); return stack; } @@ -198,10 +198,10 @@ public class DynamicCell extends Item { super(container, capacity); //backwards compatibility - if (container.hasTag() && container.getTag().contains("FluidName")) { + if (container.hasTag() && container.getTag().containsKey("FluidName")) { FluidStack stack = FluidStack.loadFluidStackFromNBT(container.getTag()); if (stack != null) { - container.setTag(new NBTTagCompound()); + container.setTag(new CompoundTag()); fill(stack, true); } } diff --git a/src/main/java/techreborn/items/ItemCells.java b/src/main/java/techreborn/items/ItemCells.java index de1d0700f..14dc568ca 100644 --- a/src/main/java/techreborn/items/ItemCells.java +++ b/src/main/java/techreborn/items/ItemCells.java @@ -25,7 +25,7 @@ package techreborn.items; import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; + import org.apache.commons.lang3.Validate; import techreborn.utils.FluidUtils; diff --git a/src/main/java/techreborn/items/ItemDestructopack.java b/src/main/java/techreborn/items/ItemDestructopack.java index 7668356f4..37991e975 100644 --- a/src/main/java/techreborn/items/ItemDestructopack.java +++ b/src/main/java/techreborn/items/ItemDestructopack.java @@ -24,12 +24,12 @@ package techreborn.items; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; +import net.minecraft.util.Hand; +import net.minecraft.util.TypedActionResult; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import techreborn.TechReborn; @@ -38,16 +38,16 @@ import techreborn.client.EGui; public class ItemDestructopack extends Item { public ItemDestructopack() { - super(new Item.Properties().group(TechReborn.ITEMGROUP)); + super(new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); } @Override - public ActionResult onItemRightClick(final World world, final EntityPlayer player, final EnumHand hand) { - if (world.isRemote) { - BlockPos pos = new BlockPos(player.posX, player.posY, player.posZ); + public TypedActionResult use(final World world, final PlayerEntity player, final Hand hand) { + if (world.isClient) { + BlockPos pos = new BlockPos(player.x, player.y, player.z); EGui.DESTRUCTOPACK.open(player, pos, world); } //TODO: Add server part - return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand)); + return new TypedActionResult<>(ActionResult.SUCCESS, player.getStackInHand(hand)); } } diff --git a/src/main/java/techreborn/items/ItemFrequencyTransmitter.java b/src/main/java/techreborn/items/ItemFrequencyTransmitter.java index f178d14df..20203e7f0 100644 --- a/src/main/java/techreborn/items/ItemFrequencyTransmitter.java +++ b/src/main/java/techreborn/items/ItemFrequencyTransmitter.java @@ -24,27 +24,27 @@ package techreborn.items; -import net.minecraft.client.resources.I18n; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.IItemPropertyGetter; +import net.minecraft.ChatFormat; +import net.minecraft.client.item.TooltipContext; +import net.minecraft.client.resource.language.I18n; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; +import net.minecraft.item.ItemPropertyGetter; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.item.ItemUsageContext; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Hand; +import net.minecraft.util.Identifier; +import net.minecraft.util.TypedActionResult; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.registry.IRegistry; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.registry.Registry; import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import reborncore.client.hud.StackInfoElement; import reborncore.common.util.ChatUtils; import techreborn.TechReborn; @@ -57,13 +57,13 @@ import java.util.List; public class ItemFrequencyTransmitter extends Item { public ItemFrequencyTransmitter() { - super(new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(1)); - this.addPropertyOverride(new ResourceLocation("techreborn", "coords"), new IItemPropertyGetter() { + super(new Item.Settings().itemGroup(TechReborn.ITEMGROUP).stackSize(1)); + this.addProperty(new Identifier("techreborn", "coords"), new ItemPropertyGetter() { @Override - @OnlyIn(Dist.CLIENT) - public float call(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) { - if (!stack.isEmpty() && stack.hasTag() && stack.getTag() != null && stack.getTag().contains("x") - && stack.getTag().contains("y") && stack.getTag().contains("z") && stack.getTag().contains("dim")) { + @Environment(EnvType.CLIENT) + public float call(ItemStack stack, @Nullable World worldIn, @Nullable LivingEntity entityIn) { + if (!stack.isEmpty() && stack.hasTag() && stack.getTag() != null && stack.getTag().containsKey("x") + && stack.getTag().containsKey("y") && stack.getTag().containsKey("z") && stack.getTag().containsKey("dim")) { return 1.0F; } return 0.0F; @@ -72,64 +72,64 @@ public class ItemFrequencyTransmitter extends Item { } @Override - public EnumActionResult onItemUse(ItemUseContext context) { + public ActionResult useOnBlock(ItemUsageContext context) { World world = context.getWorld(); - BlockPos pos = context.getPos(); - ItemStack stack = context.getItem(); + BlockPos pos = context.getBlockPos(); + ItemStack stack = context.getItemStack(); - stack.setTag(new NBTTagCompound()); + stack.setTag(new CompoundTag()); stack.getTag().putInt("x", pos.getX()); stack.getTag().putInt("y", pos.getY()); stack.getTag().putInt("z", pos.getZ()); - stack.getTag().putInt("dim", world.getDimension().getType().getId()); + stack.getTag().putInt("dim", world.getDimension().getType().getRawId()); - if (!world.isRemote) { - ChatUtils.sendNoSpamMessages(MessageIDs.freqTransmitterID, new TextComponentString( - TextFormatting.GRAY + I18n.format("techreborn.message.setTo") + " X: " + - TextFormatting.GOLD + pos.getX() + - TextFormatting.GRAY + " Y: " + - TextFormatting.GOLD + pos.getY() + - TextFormatting.GRAY + " Z: " + - TextFormatting.GOLD + pos.getZ() + - TextFormatting.GRAY + " " + I18n.format("techreborn.message.in") + " " + - TextFormatting.GOLD + world.getDimension().getType().getRegistryName() + if (!world.isClient) { + ChatUtils.sendNoSpamMessages(MessageIDs.freqTransmitterID, new TextComponent( + ChatFormat.GRAY + I18n.translate("techreborn.message.setTo") + " X: " + + ChatFormat.GOLD + pos.getX() + + ChatFormat.GRAY + " Y: " + + ChatFormat.GOLD + pos.getY() + + ChatFormat.GRAY + " Z: " + + ChatFormat.GOLD + pos.getZ() + + ChatFormat.GRAY + " " + I18n.translate("techreborn.message.in") + " " + + ChatFormat.GOLD + world.getDimension().getType().getRegistryName() + " (" + world.getDimension().getType().getRegistryName() + ")")); } - return EnumActionResult.SUCCESS; + return ActionResult.SUCCESS; } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, - EnumHand hand) { - ItemStack stack = player.getHeldItem(hand); + public TypedActionResult use(World world, PlayerEntity player, + Hand hand) { + ItemStack stack = player.getStackInHand(hand); if (player.isSneaking()) { stack.setTag(null); - if (!world.isRemote) { - ChatUtils.sendNoSpamMessages(MessageIDs.freqTransmitterID, new TextComponentString( - TextFormatting.GRAY + I18n.format("techreborn.message.coordsHaveBeen") + " " - + TextFormatting.GOLD + I18n.format("techreborn.message.cleared"))); + if (!world.isClient) { + ChatUtils.sendNoSpamMessages(MessageIDs.freqTransmitterID, new TextComponent( + ChatFormat.GRAY + I18n.translate("techreborn.message.coordsHaveBeen") + " " + + ChatFormat.GOLD + I18n.translate("techreborn.message.cleared"))); } } - return new ActionResult<>(EnumActionResult.SUCCESS, stack); + return new TypedActionResult<>(ActionResult.SUCCESS, stack); } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { - if (stack.hasTag() && stack.getTag() != null && stack.getTag().contains("x") && stack.getTag().contains("y") && stack.getTag().contains("z") && stack.getTag().contains("dim")) { + public void buildTooltip(ItemStack stack, @Nullable World worldIn, List tooltip, TooltipContext flagIn) { + if (stack.hasTag() && stack.getTag() != null && stack.getTag().containsKey("x") && stack.getTag().containsKey("y") && stack.getTag().containsKey("z") && stack.getTag().containsKey("dim")) { int x = stack.getTag().getInt("x"); int y = stack.getTag().getInt("y"); int z = stack.getTag().getInt("z"); int dim = stack.getTag().getInt("dim"); - tooltip.add(new TextComponentString(TextFormatting.GRAY + "X: " + TextFormatting.GOLD + x)); - tooltip.add(new TextComponentString(TextFormatting.GRAY + "Y: " + TextFormatting.GOLD + y)); - tooltip.add(new TextComponentString(TextFormatting.GRAY + "Z: " + TextFormatting.GOLD + z)); - tooltip.add(new TextComponentString(TextFormatting.DARK_GRAY + IRegistry.DIMENSION_TYPE.get(dim).getRegistryName().toString())); + tooltip.add(new TextComponent(ChatFormat.GRAY + "X: " + ChatFormat.GOLD + x)); + tooltip.add(new TextComponent(ChatFormat.GRAY + "Y: " + ChatFormat.GOLD + y)); + tooltip.add(new TextComponent(ChatFormat.GRAY + "Z: " + ChatFormat.GOLD + z)); + tooltip.add(new TextComponent(ChatFormat.DARK_GRAY + Registry.DIMENSION.get(dim).getRegistryName().toString())); } else { - tooltip.add(new TextComponentString(TextFormatting.GRAY + I18n.format("techreborn.message.noCoordsSet"))); + tooltip.add(new TextComponent(ChatFormat.GRAY + I18n.translate("techreborn.message.noCoordsSet"))); } } @@ -141,17 +141,17 @@ public class ItemFrequencyTransmitter extends Item { @Override public String getText(ItemStack stack) { String text = ""; - TextFormatting gold = TextFormatting.GOLD; - TextFormatting grey = TextFormatting.GRAY; + ChatFormat gold = ChatFormat.GOLD; + ChatFormat grey = ChatFormat.GRAY; if (stack.getItem() instanceof ItemFrequencyTransmitter) { - if (stack.hasTag() && stack.getTag() != null && stack.getTag().contains("x") && stack.getTag().contains("y") && stack.getTag().contains("z") && stack.getTag().contains("dim")) { + if (stack.hasTag() && stack.getTag() != null && stack.getTag().containsKey("x") && stack.getTag().containsKey("y") && stack.getTag().containsKey("z") && stack.getTag().containsKey("dim")) { int coordX = stack.getTag().getInt("x"); int coordY = stack.getTag().getInt("y"); int coordZ = stack.getTag().getInt("z"); int coordDim = stack.getTag().getInt("dim"); - text = grey + "X: " + gold + coordX + grey + " Y: " + gold + coordY + grey + " Z: " + gold + coordZ + grey + " Dim: " + gold + IRegistry.DIMENSION_TYPE.get(coordDim).getRegistryName().toString() + " (" + coordDim + ")"; + text = grey + "X: " + gold + coordX + grey + " Y: " + gold + coordY + grey + " Z: " + gold + coordZ + grey + " Dim: " + gold + Registry.DIMENSION.get(coordDim).getRegistryName().toString() + " (" + coordDim + ")"; } else { - text = grey + I18n.format("techreborn.message.noCoordsSet"); + text = grey + I18n.translate("techreborn.message.noCoordsSet"); } } return text; diff --git a/src/main/java/techreborn/items/ItemManual.java b/src/main/java/techreborn/items/ItemManual.java index b9ee4270c..9abeca54f 100644 --- a/src/main/java/techreborn/items/ItemManual.java +++ b/src/main/java/techreborn/items/ItemManual.java @@ -24,11 +24,11 @@ package techreborn.items; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumHand; +import net.minecraft.util.Hand; +import net.minecraft.util.TypedActionResult; import net.minecraft.world.World; import reborncore.common.registration.config.ConfigRegistry; import techreborn.TechReborn; @@ -39,12 +39,12 @@ public class ItemManual extends Item { public static boolean allowRefund = true; public ItemManual() { - super(new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(1)); + super(new Item.Settings().itemGroup(TechReborn.ITEMGROUP).stackSize(1)); } @Override - public ActionResult onItemRightClick(final World world, final EntityPlayer player, - final EnumHand hand) { + public TypedActionResult use(final World world, final PlayerEntity player, + final Hand hand) { throw new UnsupportedOperationException("1.13 fix me"); //player.openGui(TechReborn.INSTANCE, EGui.MANUAL.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posY); diff --git a/src/main/java/techreborn/items/ItemScrapBox.java b/src/main/java/techreborn/items/ItemScrapBox.java index 928c1487a..8c4db5f17 100644 --- a/src/main/java/techreborn/items/ItemScrapBox.java +++ b/src/main/java/techreborn/items/ItemScrapBox.java @@ -24,12 +24,12 @@ package techreborn.items; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; +import net.minecraft.util.Hand; +import net.minecraft.util.TypedActionResult; import net.minecraft.world.World; import reborncore.common.crafting.Recipe; import reborncore.common.util.WorldUtils; @@ -41,19 +41,19 @@ import java.util.List; public class ItemScrapBox extends Item { public ItemScrapBox() { - super(new Item.Properties().group(TechReborn.ITEMGROUP)); + super(new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { - ItemStack stack = player.getHeldItemMainhand(); - if (!world.isRemote) { + public TypedActionResult use(World world, PlayerEntity player, Hand hand) { + ItemStack stack = player.getMainHandStack(); + if (!world.isClient) { List scrapboxRecipeList = ModRecipes.SCRAPBOX.getRecipes(world); - int random = world.rand.nextInt(scrapboxRecipeList.size()); + int random = world.random.nextInt(scrapboxRecipeList.size()); ItemStack out = scrapboxRecipeList.get(random).getOutputs().get(0); - WorldUtils.dropItem(out, world, player.getPosition()); - stack.shrink(1); + WorldUtils.dropItem(out, world, player.getBlockPos()); + stack.subtractAmount(1); } - return new ActionResult<>(EnumActionResult.SUCCESS, stack); + return new TypedActionResult<>(ActionResult.SUCCESS, stack); } } diff --git a/src/main/java/techreborn/items/ItemUpgrade.java b/src/main/java/techreborn/items/ItemUpgrade.java index 96cd6d21f..fab29ee01 100644 --- a/src/main/java/techreborn/items/ItemUpgrade.java +++ b/src/main/java/techreborn/items/ItemUpgrade.java @@ -40,7 +40,7 @@ public class ItemUpgrade extends Item implements IUpgrade { public final IUpgrade behavior; public ItemUpgrade(String name, IUpgrade process) { - super(new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(16)); + super(new Item.Settings().itemGroup(TechReborn.ITEMGROUP).stackSize(16)); this.name = name; this.behavior = process; } diff --git a/src/main/java/techreborn/items/armor/ItemCloakingDevice.java b/src/main/java/techreborn/items/armor/ItemCloakingDevice.java index eeed2e8a9..655e444b9 100644 --- a/src/main/java/techreborn/items/armor/ItemCloakingDevice.java +++ b/src/main/java/techreborn/items/armor/ItemCloakingDevice.java @@ -25,18 +25,18 @@ package techreborn.items.armor; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.MobEffects; -import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.effect.StatusEffects; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.NonNullList; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.DefaultedList; import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.energy.IEnergyStorage; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + + import reborncore.api.power.IEnergyItemInfo; import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PoweredItemContainerProvider; @@ -60,40 +60,40 @@ public class ItemCloakingDevice extends ItemTRArmour implements IEnergyItemInfo // 40M FE capacity with 10k FE\t charge rate public ItemCloakingDevice() { - super(TRArmorMaterial.CLOAKING, EntityEquipmentSlot.CHEST); + super(TRArmorMaterial.CLOAKING, EquipmentSlot.CHEST); } // Item @Override - @OnlyIn(Dist.CLIENT) - public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) { + @Environment(EnvType.CLIENT) + public String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) { return "techreborn:" + "textures/models/armor/cloaking.png"; } @Override - public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { - if (entityIn instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) entityIn; + public void onEntityTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { + if (entityIn instanceof PlayerEntity) { + PlayerEntity player = (PlayerEntity) entityIn; IEnergyStorage capEnergy = new ForgePowerItemManager(stack); if (capEnergy != null && capEnergy.getEnergyStored() >= usage) { capEnergy.extractEnergy(usage, false); player.setInvisible(true); } else { - if (!player.isPotionActive(MobEffects.INVISIBILITY)) { + if (!player.hasStatusEffect(StatusEffects.INVISIBILITY)) { player.setInvisible(false); } } } } - public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { + public void onArmorTick(World world, PlayerEntity player, ItemStack stack) { } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void fillItemGroup(ItemGroup group, NonNullList items) { - if (!isInGroup(group)) { + public void appendItemsForGroup(ItemGroup group, DefaultedList items) { + if (!isInItemGroup(group)) { return; } ItemStack uncharged = new ItemStack(TRContent.CLOAKING_DEVICE); @@ -121,7 +121,7 @@ public class ItemCloakingDevice extends ItemTRArmour implements IEnergyItemInfo @Override @Nullable - public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) { + public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { return new PoweredItemContainerProvider(stack); } diff --git a/src/main/java/techreborn/items/armor/ItemLapotronicOrbpack.java b/src/main/java/techreborn/items/armor/ItemLapotronicOrbpack.java index 18fa68e25..9b44c59ab 100644 --- a/src/main/java/techreborn/items/armor/ItemLapotronicOrbpack.java +++ b/src/main/java/techreborn/items/armor/ItemLapotronicOrbpack.java @@ -25,15 +25,15 @@ package techreborn.items.armor; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.*; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.NonNullList; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.DefaultedList; import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + import reborncore.api.power.IEnergyItemInfo; import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PoweredItemContainerProvider; @@ -45,20 +45,20 @@ import techreborn.init.TRContent; import javax.annotation.Nullable; -public class ItemLapotronicOrbpack extends ItemArmor implements IEnergyItemInfo { +public class ItemLapotronicOrbpack extends ArmorItem implements IEnergyItemInfo { // 400M FE maxCharge and 100k FE\t charge rate. Fully charged in 3 mins. public static final int maxCharge = ConfigTechReborn.LapotronPackCharge; public int transferLimit = 100_000; public ItemLapotronicOrbpack() { - super(ArmorMaterial.DIAMOND, EntityEquipmentSlot.CHEST, new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(1)); + super(ArmorMaterials.DIAMOND, EquipmentSlot.CHEST, new Item.Settings().itemGroup(TechReborn.ITEMGROUP).stackSize(1)); } // Item @Override - public void fillItemGroup(ItemGroup group, NonNullList items) { - if (!isInGroup(group)) { + public void appendItemsForGroup(ItemGroup group, DefaultedList items) { + if (!isInItemGroup(group)) { return; } ItemStack uncharged = new ItemStack(TRContent.LAPOTRONIC_ORBPACK); @@ -70,9 +70,9 @@ public class ItemLapotronicOrbpack extends ItemArmor implements IEnergyItemInfo } @Override - public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { - if (entityIn instanceof EntityPlayer) { - ItemLithiumIonBatpack.distributePowerToInventory(worldIn, (EntityPlayer) entityIn, stack, + public void onEntityTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { + if (entityIn instanceof PlayerEntity) { + ItemLithiumIonBatpack.EnvTypeributePowerToInventory(worldIn, (PlayerEntity) entityIn, stack, (int) transferLimit); } } @@ -96,13 +96,13 @@ public class ItemLapotronicOrbpack extends ItemArmor implements IEnergyItemInfo @Nullable public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable - NBTTagCompound nbt) { + CompoundTag nbt) { return new PoweredItemContainerProvider(stack); } @Override - @OnlyIn(Dist.CLIENT) - public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) { + @Environment(EnvType.CLIENT) + public String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) { return "techreborn:" + "textures/models/armor/lapotronpack.png"; } diff --git a/src/main/java/techreborn/items/armor/ItemLithiumIonBatpack.java b/src/main/java/techreborn/items/armor/ItemLithiumIonBatpack.java index 1c87d7595..e1ccb3ae3 100644 --- a/src/main/java/techreborn/items/armor/ItemLithiumIonBatpack.java +++ b/src/main/java/techreborn/items/armor/ItemLithiumIonBatpack.java @@ -25,15 +25,15 @@ package techreborn.items.armor; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.*; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.NonNullList; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.DefaultedList; import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + import reborncore.api.power.IEnergyItemInfo; import reborncore.common.powerSystem.ExternalPowerSystems; import reborncore.common.powerSystem.PowerSystem; @@ -46,35 +46,35 @@ import techreborn.init.TRContent; import javax.annotation.Nullable; -public class ItemLithiumIonBatpack extends ItemArmor implements IEnergyItemInfo { +public class ItemLithiumIonBatpack extends ArmorItem implements IEnergyItemInfo { // 8M FE maxCharge and 2k FE\t charge rate. Fully charged in 3 mins. public static final int maxCharge = ConfigTechReborn.LithiumBatpackCharge; public int transferLimit = 2_000; public ItemLithiumIonBatpack() { - super(ArmorMaterial.DIAMOND, EntityEquipmentSlot.CHEST, new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(1)); + super(ArmorMaterials.DIAMOND, EquipmentSlot.CHEST, new Item.Settings().itemGroup(TechReborn.ITEMGROUP).stackSize(1)); } - public static void distributePowerToInventory(World world, EntityPlayer player, ItemStack itemStack, int maxSend) { - if (world.isRemote) { + public static void EnvTypeributePowerToInventory(World world, PlayerEntity player, ItemStack itemStack, int maxSend) { + if (world.isClient) { return; } ForgePowerItemManager capEnergy = new ForgePowerItemManager(itemStack); - for (int i = 0; i < player.inventory.getSizeInventory(); i++) { - if (!player.inventory.getStackInSlot(i).isEmpty()) { - ExternalPowerSystems.chargeItem(capEnergy, player.inventory.getStackInSlot(i)); + for (int i = 0; i < player.inventory.getInvSize(); i++) { + if (!player.inventory.getInvStack(i).isEmpty()) { + ExternalPowerSystems.chargeItem(capEnergy, player.inventory.getInvStack(i)); } } } // Item @Override - public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { - if (entityIn instanceof EntityPlayer) { - distributePowerToInventory(worldIn, (EntityPlayer) entityIn, stack, (int) transferLimit); + public void onEntityTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { + if (entityIn instanceof PlayerEntity) { + EnvTypeributePowerToInventory(worldIn, (PlayerEntity) entityIn, stack, (int) transferLimit); } } @@ -95,20 +95,20 @@ public class ItemLithiumIonBatpack extends ItemArmor implements IEnergyItemInfo @Override @Nullable - public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) { + public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { return new PoweredItemContainerProvider(stack); } @Override - @OnlyIn(Dist.CLIENT) - public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) { + @Environment(EnvType.CLIENT) + public String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) { return "techreborn:" + "textures/models/armor/lithiumbatpack.png"; } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void fillItemGroup(ItemGroup group, NonNullList items) { - if (!isInGroup(group)) { + public void appendItemsForGroup(ItemGroup group, DefaultedList items) { + if (!isInItemGroup(group)) { return; } ItemStack uncharged = new ItemStack(TRContent.LITHIUM_ION_BATPACK); diff --git a/src/main/java/techreborn/items/armor/ItemTRArmour.java b/src/main/java/techreborn/items/armor/ItemTRArmour.java index 8c55e5554..f393e4819 100644 --- a/src/main/java/techreborn/items/armor/ItemTRArmour.java +++ b/src/main/java/techreborn/items/armor/ItemTRArmour.java @@ -24,10 +24,10 @@ package techreborn.items.armor; -import net.minecraft.inventory.EntityEquipmentSlot; -import net.minecraft.item.IArmorMaterial; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.item.ArmorItem; +import net.minecraft.item.ArmorMaterial; import net.minecraft.item.Item; -import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import reborncore.common.util.ItemUtils; import techreborn.TechReborn; @@ -36,33 +36,33 @@ import techreborn.events.TRRecipeHandler; /** * Created by modmuss50 on 26/02/2016. */ -public class ItemTRArmour extends ItemArmor { +public class ItemTRArmour extends ArmorItem { String repairOreDict = ""; - public ItemTRArmour(IArmorMaterial material, EntityEquipmentSlot slot) { + public ItemTRArmour(ArmorMaterial material, EquipmentSlot slot) { this(material, slot, ""); } - public ItemTRArmour(IArmorMaterial material, EntityEquipmentSlot slot, String repairOreDict) { - super(material, slot, (new Item.Properties()).group(TechReborn.ITEMGROUP).maxStackSize(1)); + public ItemTRArmour(ArmorMaterial material, EquipmentSlot slot, String repairOreDict) { + super(material, slot, (new Item.Settings()).itemGroup(TechReborn.ITEMGROUP).stackSize(1)); this.repairOreDict = repairOreDict; - if (slot == EntityEquipmentSlot.HEAD) + if (slot == EquipmentSlot.HEAD) //setTranslationKey(material.name().toLowerCase() + "Helmet"); - if (slot == EntityEquipmentSlot.CHEST) + if (slot == EquipmentSlot.CHEST) //setTranslationKey(material.name().toLowerCase() + "Chestplate"); - if (slot == EntityEquipmentSlot.LEGS) + if (slot == EquipmentSlot.LEGS) //setTranslationKey(material.name().toLowerCase() + "Leggings"); - if (slot == EntityEquipmentSlot.FEET) + if (slot == EquipmentSlot.FEET) //setTranslationKey(material.name().toLowerCase() + "Boots"); TRRecipeHandler.hideEntry(this); } @Override - public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { + public boolean canRepair(ItemStack toRepair, ItemStack repair) { if (toRepair.getItem() == this && !repairOreDict.isEmpty()) { return ItemUtils.isInputEqual(repairOreDict, repair, false, true); } - return super.getIsRepairable(toRepair, repair); + return super.canRepair(toRepair, repair); } } diff --git a/src/main/java/techreborn/items/battery/ItemBattery.java b/src/main/java/techreborn/items/battery/ItemBattery.java index 878ddc60a..f7a2a8ec9 100644 --- a/src/main/java/techreborn/items/battery/ItemBattery.java +++ b/src/main/java/techreborn/items/battery/ItemBattery.java @@ -24,16 +24,16 @@ package techreborn.items.battery; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.IItemPropertyGetter; +import net.minecraft.entity.LivingEntity; import net.minecraft.item.Item; +import net.minecraft.item.ItemPropertyGetter; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.Identifier; import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + import reborncore.api.power.IEnergyItemInfo; import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PoweredItemContainerProvider; @@ -49,13 +49,13 @@ public class ItemBattery extends Item implements IEnergyItemInfo { int maxTransfer = 0; public ItemBattery(int maxEnergy, int maxTransfer) { - super(new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(1).defaultMaxDamage(1)); + super(new Item.Settings().itemGroup(TechReborn.ITEMGROUP).stackSize(1).durabilityIfNotSet(1)); this.maxEnergy = maxEnergy; this.maxTransfer = maxTransfer; - this.addPropertyOverride(new ResourceLocation("techreborn:empty"), new IItemPropertyGetter() { + this.addProperty(new Identifier("techreborn:empty"), new ItemPropertyGetter() { @Override - @OnlyIn(Dist.CLIENT) - public float call(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) { + @Environment(EnvType.CLIENT) + public float call(ItemStack stack, @Nullable World worldIn, @Nullable LivingEntity entityIn) { if (!stack.isEmpty() && new ForgePowerItemManager(stack).getEnergyStored() == 0) { return 1.0F; } @@ -84,7 +84,7 @@ public class ItemBattery extends Item implements IEnergyItemInfo { @Nullable public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable - NBTTagCompound nbt) { + CompoundTag nbt) { return new PoweredItemContainerProvider(stack); } diff --git a/src/main/java/techreborn/items/battery/ItemEnergyCrystal.java b/src/main/java/techreborn/items/battery/ItemEnergyCrystal.java index df2a74abf..5129a9031 100644 --- a/src/main/java/techreborn/items/battery/ItemEnergyCrystal.java +++ b/src/main/java/techreborn/items/battery/ItemEnergyCrystal.java @@ -26,9 +26,9 @@ package techreborn.items.battery; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.util.DefaultedList; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import reborncore.common.powerSystem.forge.ForgePowerItemManager; import techreborn.config.ConfigTechReborn; import techreborn.init.TRContent; @@ -40,10 +40,10 @@ public class ItemEnergyCrystal extends ItemBattery { super(ConfigTechReborn.EnergyCrystalMaxCharge, 1_000); } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void fillItemGroup(ItemGroup group, NonNullList items) { - if (!isInGroup(group)) { + public void appendItemsForGroup(ItemGroup group, DefaultedList items) { + if (!isInItemGroup(group)) { return; } ItemStack uncharged = new ItemStack(TRContent.ENERGY_CRYSTAL); diff --git a/src/main/java/techreborn/items/battery/ItemLapotronCrystal.java b/src/main/java/techreborn/items/battery/ItemLapotronCrystal.java index bd415e5a9..490de4823 100644 --- a/src/main/java/techreborn/items/battery/ItemLapotronCrystal.java +++ b/src/main/java/techreborn/items/battery/ItemLapotronCrystal.java @@ -26,9 +26,9 @@ package techreborn.items.battery; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.util.DefaultedList; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import reborncore.common.powerSystem.forge.ForgePowerItemManager; import techreborn.config.ConfigTechReborn; import techreborn.init.TRContent; @@ -40,10 +40,10 @@ public class ItemLapotronCrystal extends ItemBattery { super(ConfigTechReborn.LapotronCrystalMaxCharge, 10_000); } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void fillItemGroup(ItemGroup group, NonNullList items) { - if (!isInGroup(group)) { + public void appendItemsForGroup(ItemGroup group, DefaultedList items) { + if (!isInItemGroup(group)) { return; } ItemStack uncharged = new ItemStack(TRContent.LAPOTRON_CRYSTAL); diff --git a/src/main/java/techreborn/items/battery/ItemLapotronicOrb.java b/src/main/java/techreborn/items/battery/ItemLapotronicOrb.java index d8361c383..75bb3cef6 100644 --- a/src/main/java/techreborn/items/battery/ItemLapotronicOrb.java +++ b/src/main/java/techreborn/items/battery/ItemLapotronicOrb.java @@ -26,9 +26,9 @@ package techreborn.items.battery; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.util.DefaultedList; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import reborncore.common.powerSystem.forge.ForgePowerItemManager; import techreborn.config.ConfigTechReborn; import techreborn.init.TRContent; @@ -40,10 +40,10 @@ public class ItemLapotronicOrb extends ItemBattery { super(ConfigTechReborn.LapotronicOrbMaxCharge, 100_000); } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void fillItemGroup(ItemGroup group, NonNullList items) { - if (!isInGroup(group)) { + public void appendItemsForGroup(ItemGroup group, DefaultedList items) { + if (!isInItemGroup(group)) { return; } ItemStack uncharged = new ItemStack(TRContent.LAPOTRONIC_ORB); diff --git a/src/main/java/techreborn/items/battery/ItemLithiumIonBattery.java b/src/main/java/techreborn/items/battery/ItemLithiumIonBattery.java index a7cc469ac..6868d4829 100644 --- a/src/main/java/techreborn/items/battery/ItemLithiumIonBattery.java +++ b/src/main/java/techreborn/items/battery/ItemLithiumIonBattery.java @@ -26,9 +26,9 @@ package techreborn.items.battery; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.util.DefaultedList; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import reborncore.common.powerSystem.forge.ForgePowerItemManager; import techreborn.init.TRContent; @@ -39,10 +39,10 @@ public class ItemLithiumIonBattery extends ItemBattery { super(400_000, 1_000); } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void fillItemGroup(ItemGroup group, NonNullList items) { - if (!isInGroup(group)) { + public void appendItemsForGroup(ItemGroup group, DefaultedList items) { + if (!isInItemGroup(group)) { return; } ItemStack uncharged = new ItemStack(TRContent.LITHIUM_ION_BATTERY); diff --git a/src/main/java/techreborn/items/battery/ItemRedCellBattery.java b/src/main/java/techreborn/items/battery/ItemRedCellBattery.java index 54f4af8b8..4b635f140 100644 --- a/src/main/java/techreborn/items/battery/ItemRedCellBattery.java +++ b/src/main/java/techreborn/items/battery/ItemRedCellBattery.java @@ -26,9 +26,9 @@ package techreborn.items.battery; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.util.DefaultedList; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import reborncore.common.powerSystem.forge.ForgePowerItemManager; import techreborn.init.TRContent; @@ -39,10 +39,10 @@ public class ItemRedCellBattery extends ItemBattery { super(40_000, 100); } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void fillItemGroup(ItemGroup group, NonNullList items) { - if (!isInGroup(group)) { + public void appendItemsForGroup(ItemGroup group, DefaultedList items) { + if (!isInItemGroup(group)) { return; } ItemStack uncharged = new ItemStack(TRContent.RED_CELL_BATTERY); diff --git a/src/main/java/techreborn/items/tool/ItemChainsaw.java b/src/main/java/techreborn/items/tool/ItemChainsaw.java index 4ddef051b..b8d7b1864 100644 --- a/src/main/java/techreborn/items/tool/ItemChainsaw.java +++ b/src/main/java/techreborn/items/tool/ItemChainsaw.java @@ -24,20 +24,20 @@ package techreborn.items.tool; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; +import net.minecraft.block.Material; import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.init.Enchantments; +import net.minecraft.enchantment.Enchantments; +import net.minecraft.entity.LivingEntity; import net.minecraft.item.*; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.common.ToolType; -import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + + import reborncore.api.power.IEnergyItemInfo; import reborncore.common.powerSystem.ExternalPowerSystems; import reborncore.common.powerSystem.PowerSystem; @@ -49,7 +49,7 @@ import techreborn.TechReborn; import javax.annotation.Nullable; import java.util.Random; -public class ItemChainsaw extends ItemAxe implements IEnergyItemInfo { +public class ItemChainsaw extends AxeItem implements IEnergyItemInfo { public int maxCharge = 1; public int cost = 250; @@ -58,17 +58,17 @@ public class ItemChainsaw extends ItemAxe implements IEnergyItemInfo { public int transferLimit = 100; public boolean isBreaking = false; - public ItemChainsaw(ItemTier material, int energyCapacity, float unpoweredSpeed) { - super(material, (int) material.getAttackDamage(), unpoweredSpeed, new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(1)); + public ItemChainsaw(ToolMaterials material, int energyCapacity, float unpoweredSpeed) { + super(material, (int) material.getAttackDamage(), unpoweredSpeed, new Item.Settings().itemGroup(TechReborn.ITEMGROUP).stackSize(1)); this.maxCharge = energyCapacity; - this.efficiency = unpoweredSpeed; + this.blockBreakingSpeed = unpoweredSpeed; - this.addPropertyOverride(new ResourceLocation("techreborn", "animated"), new IItemPropertyGetter() { + this.addProperty(new Identifier("techreborn", "animated"), new ItemPropertyGetter() { @Override - @OnlyIn(Dist.CLIENT) - public float call(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) { + @Environment(EnvType.CLIENT) + public float call(ItemStack stack, @Nullable World worldIn, @Nullable LivingEntity entityIn) { if (!stack.isEmpty() && new ForgePowerItemManager(stack).getEnergyStored() >= cost - && entityIn != null && entityIn.getHeldItemMainhand().equals(stack)) { + && entityIn != null && entityIn.getMainHandStack().equals(stack)) { return 1.0F; } return 0.0F; @@ -78,20 +78,20 @@ public class ItemChainsaw extends ItemAxe implements IEnergyItemInfo { // ItemAxe @Override - public float getDestroySpeed(ItemStack stack, IBlockState state) { + public float getBlockBreakingSpeed(ItemStack stack, BlockState state) { if (new ForgePowerItemManager(stack).getEnergyStored() >= cost && (state.getBlock().isToolEffective(state, ToolType.AXE) || state.getMaterial() == Material.WOOD)) { return this.poweredSpeed; } else { - return super.getDestroySpeed(stack, state); + return super.getBlockBreakingSpeed(stack, state); } } // ItemTool @Override - public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState blockIn, BlockPos pos, EntityLivingBase entityLiving) { + public boolean onBlockBroken(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) { Random rand = new Random(); - if (rand.nextInt(EnchantmentHelper.getEnchantmentLevel(Enchantments.UNBREAKING, stack) + 1) == 0) { + if (rand.nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) { ForgePowerItemManager capEnergy = new ForgePowerItemManager(stack); capEnergy.extractEnergy(cost, false); @@ -101,7 +101,7 @@ public class ItemChainsaw extends ItemAxe implements IEnergyItemInfo { } @Override - public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase entityliving1) { + public boolean onEntityDamaged(ItemStack itemstack, LivingEntity entityliving, LivingEntity entityliving1) { return true; } @@ -124,13 +124,13 @@ public class ItemChainsaw extends ItemAxe implements IEnergyItemInfo { @Nullable public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable - NBTTagCompound nbt) { + CompoundTag nbt) { return new PoweredItemContainerProvider(stack); } @Override public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack) { - return !(newStack.isItemEqual(oldStack)); + return !(newStack.isEqualIgnoreTags(oldStack)); } @Override @@ -155,7 +155,7 @@ public class ItemChainsaw extends ItemAxe implements IEnergyItemInfo { } @Override - public int getItemEnchantability() { + public int getEnchantability() { return 20; } } diff --git a/src/main/java/techreborn/items/tool/ItemDebugTool.java b/src/main/java/techreborn/items/tool/ItemDebugTool.java index 1f5c97003..473f97521 100644 --- a/src/main/java/techreborn/items/tool/ItemDebugTool.java +++ b/src/main/java/techreborn/items/tool/ItemDebugTool.java @@ -25,19 +25,18 @@ package techreborn.items.tool; import java.util.Map.Entry; - +import net.minecraft.ChatFormat; import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; import net.minecraft.item.Item; -import net.minecraft.item.ItemUseContext; -import net.minecraft.state.IProperty; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.Util; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.energy.CapabilityEnergy; -import net.minecraftforge.energy.IEnergyStorage; +import net.minecraft.item.ItemUsageContext; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.state.property.Property; +import net.minecraft.util.ActionResult; +import net.minecraft.util.SystemUtil; + + import reborncore.api.power.IEnergyInterfaceTile; import reborncore.common.powerSystem.PowerSystem; import techreborn.TechReborn; @@ -48,77 +47,77 @@ import techreborn.TechReborn; public class ItemDebugTool extends Item { public ItemDebugTool() { - super(new Item.Properties().group(TechReborn.ITEMGROUP)); + super(new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); } @Override - public EnumActionResult onItemUse(ItemUseContext context) { - IBlockState blockState = context.getWorld().getBlockState(context.getPos()); + public ActionResult useOnBlock(ItemUsageContext context) { + BlockState blockState = context.getWorld().getBlockState(context.getBlockPos()); Block block = blockState.getBlock(); if (block == null) { - return EnumActionResult.FAIL; + return ActionResult.FAIL; } - sendMessage(context, new TextComponentString(getRegistryName(block))); - for (Entry, Comparable> entry : blockState.getValues().entrySet()) { - sendMessage(context, new TextComponentString(getPropertyString(entry))); + sendMessage(context, new TextComponent(getRegistryName(block))); + for (Entry, Comparable> entry : blockState.getEntries().entrySet()) { + sendMessage(context, new TextComponent(getPropertyString(entry))); } - TileEntity tile = context.getWorld().getTileEntity(context.getPos()); + BlockEntity tile = context.getWorld().getBlockEntity(context.getBlockPos()); if (tile != null) { - sendMessage(context, new TextComponentString(getTileEntityType(tile))); + sendMessage(context, new TextComponent(getTileEntityType(tile))); if (tile instanceof IEnergyInterfaceTile) { - sendMessage(context, new TextComponentString(getRCPower((IEnergyInterfaceTile) tile))); + sendMessage(context, new TextComponent(getRCPower((IEnergyInterfaceTile) tile))); } else { IEnergyStorage capEnergy = tile - .getCapability(CapabilityEnergy.ENERGY, context.getPlacementHorizontalFacing()).orElseGet(null); + .getCapability(CapabilityEnergy.ENERGY, context.getPlayerHorizontalFacing()).orElseGet(null); if (capEnergy != null) { - sendMessage(context, new TextComponentString(getForgePower(capEnergy))); + sendMessage(context, new TextComponent(getForgePower(capEnergy))); } } } - return EnumActionResult.SUCCESS; + return ActionResult.SUCCESS; } - private void sendMessage(ItemUseContext context, TextComponentString string) { - if (!context.getWorld().isRemote) { + private void sendMessage(ItemUsageContext context, TextComponent string) { + if (!context.getWorld().isClient) { context.getPlayer().sendMessage(string); } } - private String getPropertyString(Entry, Comparable> entryIn) { - IProperty iproperty = entryIn.getKey(); + private String getPropertyString(Entry, Comparable> entryIn) { + Property iproperty = entryIn.getKey(); Comparable comparable = entryIn.getValue(); - String s = Util.getValueName(iproperty, comparable); + String s = SystemUtil.getValueAsString(iproperty, comparable); if (Boolean.TRUE.equals(comparable)) { - s = TextFormatting.GREEN + s; + s = ChatFormat.GREEN + s; } else if (Boolean.FALSE.equals(comparable)) { - s = TextFormatting.RED + s; + s = ChatFormat.RED + s; } return iproperty.getName() + ": " + s; } private String getRegistryName(Block block) { - String s = "" + TextFormatting.GREEN; + String s = "" + ChatFormat.GREEN; s += "Block Registry Name: "; - s += TextFormatting.BLUE; + s += ChatFormat.BLUE; s += block.getRegistryName().toString(); return s; } - private String getTileEntityType(TileEntity tile) { - String s = "" + TextFormatting.GREEN; + private String getTileEntityType(BlockEntity tile) { + String s = "" + ChatFormat.GREEN; s += "Tile Entity: "; - s += TextFormatting.BLUE; + s += ChatFormat.BLUE; s += tile.getType().toString(); return s; } private String getRCPower(IEnergyInterfaceTile tile) { - String s = "" + TextFormatting.GREEN; + String s = "" + ChatFormat.GREEN; s += "Power: "; - s += TextFormatting.BLUE; + s += ChatFormat.BLUE; s += PowerSystem.getLocaliszedPower(tile.getEnergy()); s += "/"; s += PowerSystem.getLocaliszedPower(tile.getMaxPower()); @@ -127,9 +126,9 @@ public class ItemDebugTool extends Item { } private String getForgePower(IEnergyStorage cap) { - String s = "" + TextFormatting.GREEN; + String s = "" + ChatFormat.GREEN; s += "Power: "; - s += TextFormatting.RED; + s += ChatFormat.RED; s += cap.getEnergyStored(); s += "/"; s += cap.getMaxEnergyStored(); diff --git a/src/main/java/techreborn/items/tool/ItemDrill.java b/src/main/java/techreborn/items/tool/ItemDrill.java index a15dfb514..e723a34ee 100644 --- a/src/main/java/techreborn/items/tool/ItemDrill.java +++ b/src/main/java/techreborn/items/tool/ItemDrill.java @@ -24,19 +24,19 @@ package techreborn.items.tool; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.init.Enchantments; -import net.minecraft.init.Items; -import net.minecraft.item.IItemTier; +import net.minecraft.enchantment.Enchantments; +import net.minecraft.entity.LivingEntity; import net.minecraft.item.Item; -import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.item.Items; +import net.minecraft.item.PickaxeItem; +import net.minecraft.item.ToolMaterial; +import net.minecraft.nbt.CompoundTag; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.common.capabilities.ICapabilityProvider; + import reborncore.api.power.IEnergyItemInfo; import reborncore.common.powerSystem.ExternalPowerSystems; import reborncore.common.powerSystem.PowerSystem; @@ -48,39 +48,39 @@ import techreborn.TechReborn; import javax.annotation.Nullable; import java.util.Random; -public class ItemDrill extends ItemPickaxe implements IEnergyItemInfo { +public class ItemDrill extends PickaxeItem implements IEnergyItemInfo { public int maxCharge = 1; public int cost = 250; public float unpoweredSpeed = 2.0F; public int transferLimit = 100; - public ItemDrill(IItemTier material, int energyCapacity, float unpoweredSpeed, float efficiencyOnProperMaterial) { - super(material, (int) material.getAttackDamage(), unpoweredSpeed, new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(1)); - this.efficiency = efficiencyOnProperMaterial; + public ItemDrill(ToolMaterial material, int energyCapacity, float unpoweredSpeed, float efficiencyOnProperMaterial) { + super(material, (int) material.getAttackDamage(), unpoweredSpeed, new Item.Settings().itemGroup(TechReborn.ITEMGROUP).stackSize(1)); + this.blockBreakingSpeed = efficiencyOnProperMaterial; this.maxCharge = energyCapacity; this.unpoweredSpeed = unpoweredSpeed; } // ItemPickaxe @Override - public float getDestroySpeed(ItemStack stack, IBlockState state) { + public float getBlockBreakingSpeed(ItemStack stack, BlockState state) { if (new ForgePowerItemManager(stack).getEnergyStored() < cost) { return unpoweredSpeed; } - if (Items.WOODEN_PICKAXE.getDestroySpeed(stack, state) > 1.0F - || Items.WOODEN_SHOVEL.getDestroySpeed(stack, state) > 1.0F) { - return efficiency; + if (Items.WOODEN_PICKAXE.getBlockBreakingSpeed(stack, state) > 1.0F + || Items.WOODEN_SHOVEL.getBlockBreakingSpeed(stack, state) > 1.0F) { + return blockBreakingSpeed; } else { - return super.getDestroySpeed(stack, state); + return super.getBlockBreakingSpeed(stack, state); } } // ItemTool @Override - public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState blockIn, BlockPos pos, EntityLivingBase entityLiving) { + public boolean onBlockBroken(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) { Random rand = new Random(); - if (rand.nextInt(EnchantmentHelper.getEnchantmentLevel(Enchantments.UNBREAKING, stack) + 1) == 0) { + if (rand.nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) { ForgePowerItemManager capEnergy = new ForgePowerItemManager(stack); capEnergy.extractEnergy(cost, false); @@ -90,7 +90,7 @@ public class ItemDrill extends ItemPickaxe implements IEnergyItemInfo { } @Override - public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase entityliving1) { + public boolean onEntityDamaged(ItemStack itemstack, LivingEntity entityliving, LivingEntity entityliving1) { return true; } @@ -119,13 +119,13 @@ public class ItemDrill extends ItemPickaxe implements IEnergyItemInfo { @Nullable public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable - NBTTagCompound nbt) { + CompoundTag nbt) { return new PoweredItemContainerProvider(stack); } @Override public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack) { - return !(newStack.isItemEqual(oldStack)); + return !(newStack.isEqualIgnoreTags(oldStack)); } // IEnergyItemInfo diff --git a/src/main/java/techreborn/items/tool/ItemJackhammer.java b/src/main/java/techreborn/items/tool/ItemJackhammer.java index 528fd5965..75d125c74 100644 --- a/src/main/java/techreborn/items/tool/ItemJackhammer.java +++ b/src/main/java/techreborn/items/tool/ItemJackhammer.java @@ -24,20 +24,20 @@ package techreborn.items.tool; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.Material; import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.init.Blocks; -import net.minecraft.init.Enchantments; +import net.minecraft.enchantment.Enchantments; +import net.minecraft.entity.LivingEntity; import net.minecraft.item.Item; -import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTier; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.item.PickaxeItem; +import net.minecraft.item.ToolMaterials; +import net.minecraft.nbt.CompoundTag; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.common.capabilities.ICapabilityProvider; + import reborncore.api.power.IEnergyItemInfo; import reborncore.common.powerSystem.ExternalPowerSystems; import reborncore.common.powerSystem.PowerSystem; @@ -50,24 +50,24 @@ import techreborn.utils.TagUtils; import javax.annotation.Nullable; import java.util.Random; -public class ItemJackhammer extends ItemPickaxe implements IEnergyItemInfo { +public class ItemJackhammer extends PickaxeItem implements IEnergyItemInfo { public int maxCharge = 1; public int cost = 250; public int transferLimit = 100; - public ItemJackhammer(ItemTier material, int energyCapacity) { - super(material, (int) material.getAttackDamage(), 1f, new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(1)); - efficiency = 20F; + public ItemJackhammer(ToolMaterials material, int energyCapacity) { + super(material, (int) material.getAttackDamage(), 1f, new Item.Settings().itemGroup(TechReborn.ITEMGROUP).stackSize(1)); + blockBreakingSpeed = 20F; this.maxCharge = energyCapacity; } // ItemPickaxe @Override - public float getDestroySpeed(ItemStack stack, IBlockState state) { + public float getBlockBreakingSpeed(ItemStack stack, BlockState state) { if ((TagUtils.isOre(state, "stone") || state.getBlock() == Blocks.STONE) && new ForgePowerItemManager(stack).getEnergyStored() >= cost) { - return efficiency; + return blockBreakingSpeed; } else { return 0.5F; } @@ -75,9 +75,9 @@ public class ItemJackhammer extends ItemPickaxe implements IEnergyItemInfo { // ItemTool @Override - public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState blockIn, BlockPos pos, EntityLivingBase entityLiving) { + public boolean onBlockBroken(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) { Random rand = new Random(); - if (rand.nextInt(EnchantmentHelper.getEnchantmentLevel(Enchantments.UNBREAKING, stack) + 1) == 0) { + if (rand.nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) { ForgePowerItemManager capEnergy = new ForgePowerItemManager(stack); capEnergy.extractEnergy(cost, false); @@ -87,15 +87,15 @@ public class ItemJackhammer extends ItemPickaxe implements IEnergyItemInfo { } @Override - public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase entityliving1) { + public boolean onEntityDamaged(ItemStack itemstack, LivingEntity entityliving, LivingEntity entityliving1) { return true; } // Item @Override - public boolean canHarvestBlock( final ItemStack stack, final IBlockState state) { + public boolean canHarvestBlock( final ItemStack stack, final BlockState state) { return TagUtils.isOre(state, "stone") - || state.getMaterial() == Material.ROCK && new ForgePowerItemManager(stack).getEnergyStored() >= cost; + || state.getMaterial() == Material.STONE && new ForgePowerItemManager(stack).getEnergyStored() >= cost; } @Override @@ -122,13 +122,13 @@ public class ItemJackhammer extends ItemPickaxe implements IEnergyItemInfo { @Nullable public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable - NBTTagCompound nbt) { + CompoundTag nbt) { return new PoweredItemContainerProvider(stack); } @Override public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack) { - return !(newStack.isItemEqual(oldStack)); + return !(newStack.isEqualIgnoreTags(oldStack)); } // IEnergyItemInfo diff --git a/src/main/java/techreborn/items/tool/ItemTreeTap.java b/src/main/java/techreborn/items/tool/ItemTreeTap.java index 70c23a18b..efbf24368 100644 --- a/src/main/java/techreborn/items/tool/ItemTreeTap.java +++ b/src/main/java/techreborn/items/tool/ItemTreeTap.java @@ -30,6 +30,6 @@ import techreborn.TechReborn; public class ItemTreeTap extends Item { public ItemTreeTap() { - super(new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(1).defaultMaxDamage(20)); + super(new Item.Settings().itemGroup(TechReborn.ITEMGROUP).stackSize(1).durabilityIfNotSet(20)); } } diff --git a/src/main/java/techreborn/items/tool/ItemWrench.java b/src/main/java/techreborn/items/tool/ItemWrench.java index d89edb511..617ed62b1 100644 --- a/src/main/java/techreborn/items/tool/ItemWrench.java +++ b/src/main/java/techreborn/items/tool/ItemWrench.java @@ -24,11 +24,11 @@ package techreborn.items.tool; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import net.minecraft.world.World; import reborncore.api.IToolHandler; import techreborn.TechReborn; @@ -39,11 +39,11 @@ import techreborn.TechReborn; public class ItemWrench extends Item implements IToolHandler { public ItemWrench() { - super(new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(1)); + super(new Item.Settings().itemGroup(TechReborn.ITEMGROUP).stackSize(1)); } @Override - public boolean handleTool(ItemStack stack, BlockPos pos, World world, EntityPlayer player, EnumFacing side, boolean damage) { + public boolean handleTool(ItemStack stack, BlockPos pos, World world, PlayerEntity player, Direction side, boolean damage) { if (damage) { stack.damageItem(1, player); } diff --git a/src/main/java/techreborn/items/tool/advanced/ItemAdvancedChainsaw.java b/src/main/java/techreborn/items/tool/advanced/ItemAdvancedChainsaw.java index c1ad8faf5..b637960bb 100644 --- a/src/main/java/techreborn/items/tool/advanced/ItemAdvancedChainsaw.java +++ b/src/main/java/techreborn/items/tool/advanced/ItemAdvancedChainsaw.java @@ -24,14 +24,14 @@ package techreborn.items.tool.advanced; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Items; +import net.minecraft.block.BlockState; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTier; -import net.minecraft.util.NonNullList; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.item.Items; +import net.minecraft.item.ToolMaterials; +import net.minecraft.util.DefaultedList; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import reborncore.common.powerSystem.forge.ForgePowerItemManager; import techreborn.config.ConfigTechReborn; import techreborn.init.TRContent; @@ -41,15 +41,15 @@ public class ItemAdvancedChainsaw extends ItemChainsaw { // 400k max charge with 1k charge rate public ItemAdvancedChainsaw() { - super(ItemTier.DIAMOND, ConfigTechReborn.AdvancedChainsawCharge, 1.0F); + super(ToolMaterials.DIAMOND, ConfigTechReborn.AdvancedChainsawCharge, 1.0F); this.cost = 250; this.transferLimit = 1000; } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void fillItemGroup(ItemGroup par2ItemGroup, NonNullList itemList) { - if (!isInGroup(par2ItemGroup)) { + public void appendItemsForGroup(ItemGroup par2ItemGroup, DefaultedList itemList) { + if (!isInItemGroup(par2ItemGroup)) { return; } ItemStack stack = new ItemStack(TRContent.ADVANCED_CHAINSAW); @@ -62,8 +62,8 @@ public class ItemAdvancedChainsaw extends ItemChainsaw { } @Override - public boolean canHarvestBlock(IBlockState blockIn) { - return Items.DIAMOND_AXE.canHarvestBlock(blockIn); + public boolean isEffectiveOn(BlockState blockIn) { + return Items.DIAMOND_AXE.isEffectiveOn(blockIn); } } diff --git a/src/main/java/techreborn/items/tool/advanced/ItemAdvancedDrill.java b/src/main/java/techreborn/items/tool/advanced/ItemAdvancedDrill.java index 160f939a6..ee89ea224 100644 --- a/src/main/java/techreborn/items/tool/advanced/ItemAdvancedDrill.java +++ b/src/main/java/techreborn/items/tool/advanced/ItemAdvancedDrill.java @@ -24,14 +24,14 @@ package techreborn.items.tool.advanced; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Items; +import net.minecraft.block.BlockState; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTier; -import net.minecraft.util.NonNullList; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.item.Items; +import net.minecraft.item.ToolMaterials; +import net.minecraft.util.DefaultedList; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import reborncore.common.powerSystem.forge.ForgePowerItemManager; import techreborn.config.ConfigTechReborn; import techreborn.init.TRContent; @@ -41,15 +41,15 @@ public class ItemAdvancedDrill extends ItemDrill { // 400k max charge with 1k charge rate public ItemAdvancedDrill() { - super(ItemTier.DIAMOND, ConfigTechReborn.AdvancedDrillCharge, 0.5F, 15F); + super(ToolMaterials.DIAMOND, ConfigTechReborn.AdvancedDrillCharge, 0.5F, 15F); this.cost = 250; this.transferLimit = 1000; } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void fillItemGroup(ItemGroup par2ItemGroup, NonNullList itemList) { - if (!isInGroup(par2ItemGroup)) { + public void appendItemsForGroup(ItemGroup par2ItemGroup, DefaultedList itemList) { + if (!isInItemGroup(par2ItemGroup)) { return; } ItemStack stack = new ItemStack(TRContent.ADVANCED_DRILL); @@ -62,8 +62,8 @@ public class ItemAdvancedDrill extends ItemDrill { } @Override - public boolean canHarvestBlock(IBlockState state) { - return Items.DIAMOND_PICKAXE.canHarvestBlock(state) || Items.DIAMOND_SHOVEL.canHarvestBlock(state); + public boolean isEffectiveOn(BlockState state) { + return Items.DIAMOND_PICKAXE.isEffectiveOn(state) || Items.DIAMOND_SHOVEL.isEffectiveOn(state); } } diff --git a/src/main/java/techreborn/items/tool/advanced/ItemAdvancedJackhammer.java b/src/main/java/techreborn/items/tool/advanced/ItemAdvancedJackhammer.java index 3bdbc03fd..d3a848466 100644 --- a/src/main/java/techreborn/items/tool/advanced/ItemAdvancedJackhammer.java +++ b/src/main/java/techreborn/items/tool/advanced/ItemAdvancedJackhammer.java @@ -26,10 +26,10 @@ package techreborn.items.tool.advanced; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTier; -import net.minecraft.util.NonNullList; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.item.ToolMaterials; +import net.minecraft.util.DefaultedList; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import reborncore.common.powerSystem.forge.ForgePowerItemManager; import techreborn.config.ConfigTechReborn; import techreborn.init.TRContent; @@ -39,16 +39,16 @@ public class ItemAdvancedJackhammer extends ItemJackhammer { // 400k max charge with 1k charge rate public ItemAdvancedJackhammer() { - super(ItemTier.DIAMOND, ConfigTechReborn.AdvancedJackhammerCharge); + super(ToolMaterials.DIAMOND, ConfigTechReborn.AdvancedJackhammerCharge); this.cost = 100; - this.efficiency = 16F; + this.blockBreakingSpeed = 16F; this.transferLimit = 1000; } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void fillItemGroup(ItemGroup par2ItemGroup, NonNullList itemList) { - if (!isInGroup(par2ItemGroup)) { + public void appendItemsForGroup(ItemGroup par2ItemGroup, DefaultedList itemList) { + if (!isInItemGroup(par2ItemGroup)) { return; } ItemStack stack = new ItemStack(TRContent.ADVANCED_JACKHAMMER); diff --git a/src/main/java/techreborn/items/tool/advanced/ItemRockCutter.java b/src/main/java/techreborn/items/tool/advanced/ItemRockCutter.java index b27513423..78f1ba077 100644 --- a/src/main/java/techreborn/items/tool/advanced/ItemRockCutter.java +++ b/src/main/java/techreborn/items/tool/advanced/ItemRockCutter.java @@ -24,21 +24,20 @@ package techreborn.items.tool.advanced; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Enchantments; -import net.minecraft.init.Items; +import net.minecraft.enchantment.Enchantments; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.*; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.NonNullList; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.DefaultedList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.common.ToolType; -import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + + import reborncore.api.power.IEnergyItemInfo; import reborncore.common.powerSystem.ExternalPowerSystems; import reborncore.common.powerSystem.PowerSystem; @@ -52,7 +51,7 @@ import techreborn.init.TRContent; import javax.annotation.Nullable; import java.util.Random; -public class ItemRockCutter extends ItemPickaxe implements IEnergyItemInfo { +public class ItemRockCutter extends PickaxeItem implements IEnergyItemInfo { public static final int maxCharge = ConfigTechReborn.RockCutterCharge; public int transferLimit = 1_000; @@ -60,33 +59,33 @@ public class ItemRockCutter extends ItemPickaxe implements IEnergyItemInfo { // 400k FE with 1k FE\t charge rate public ItemRockCutter() { - super(ItemTier.DIAMOND, 1, 1, new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(1)); - efficiency = 16F; + super(ToolMaterials.DIAMOND, 1, 1, new Item.Settings().itemGroup(TechReborn.ITEMGROUP).stackSize(1)); + blockBreakingSpeed = 16F; } // ItemPickaxe @Override - public boolean canHarvestBlock(IBlockState state) { - if (Items.DIAMOND_PICKAXE.canHarvestBlock(state)) { + public boolean isEffectiveOn(BlockState state) { + if (Items.DIAMOND_PICKAXE.isEffectiveOn(state)) { return true; } return false; } @Override - public float getDestroySpeed(ItemStack stack, IBlockState state) { + public float getBlockBreakingSpeed(ItemStack stack, BlockState state) { if (new ForgePowerItemManager(stack).getEnergyStored() < cost) { return 2F; } else { - return Items.DIAMOND_PICKAXE.getDestroySpeed(stack, state); + return Items.DIAMOND_PICKAXE.getBlockBreakingSpeed(stack, state); } } // ItemTool @Override - public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState blockIn, BlockPos pos, EntityLivingBase entityLiving) { + public boolean onBlockBroken(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) { Random rand = new Random(); - if (rand.nextInt(EnchantmentHelper.getEnchantmentLevel(Enchantments.UNBREAKING, stack) + 1) == 0) { + if (rand.nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) { ForgePowerItemManager capEnergy = new ForgePowerItemManager(stack); capEnergy.extractEnergy(cost, false); @@ -96,8 +95,8 @@ public class ItemRockCutter extends ItemPickaxe implements IEnergyItemInfo { } @Override - public int getHarvestLevel(ItemStack stack, ToolType toolType, @Nullable EntityPlayer player, @Nullable IBlockState blockState) { - if (!stack.isEnchanted()) { + public int getHarvestLevel(ItemStack stack, ToolType toolType, @Nullable PlayerEntity player, @Nullable BlockState blockState) { + if (!stack.hasEnchantments()) { stack.addEnchantment(Enchantments.SILK_TOUCH, 1); } return super.getHarvestLevel(stack, toolType, player, blockState); @@ -110,8 +109,8 @@ public class ItemRockCutter extends ItemPickaxe implements IEnergyItemInfo { } @Override - public void onCreated(ItemStack stack, World worldIn, EntityPlayer playerIn) { - if (!stack.isEnchanted()) { + public void onCrafted(ItemStack stack, World worldIn, PlayerEntity playerIn) { + if (!stack.hasEnchantments()) { stack.addEnchantment(Enchantments.SILK_TOUCH, 1); } } @@ -133,19 +132,19 @@ public class ItemRockCutter extends ItemPickaxe implements IEnergyItemInfo { @Override @Nullable - public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) { + public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { return new PoweredItemContainerProvider(stack); } @Override public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack) { - return !(newStack.isItemEqual(oldStack)); + return !(newStack.isEqualIgnoreTags(oldStack)); } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void fillItemGroup(ItemGroup par2ItemGroup, NonNullList itemList) { - if (!isInGroup(par2ItemGroup)) { + public void appendItemsForGroup(ItemGroup par2ItemGroup, DefaultedList itemList) { + if (!isInItemGroup(par2ItemGroup)) { return; } ItemStack uncharged = new ItemStack(this); diff --git a/src/main/java/techreborn/items/tool/basic/ItemBasicChainsaw.java b/src/main/java/techreborn/items/tool/basic/ItemBasicChainsaw.java index dd3481932..68f63a3d5 100644 --- a/src/main/java/techreborn/items/tool/basic/ItemBasicChainsaw.java +++ b/src/main/java/techreborn/items/tool/basic/ItemBasicChainsaw.java @@ -24,14 +24,14 @@ package techreborn.items.tool.basic; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Items; +import net.minecraft.block.BlockState; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTier; -import net.minecraft.util.NonNullList; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.item.Items; +import net.minecraft.item.ToolMaterials; +import net.minecraft.util.DefaultedList; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import reborncore.common.powerSystem.forge.ForgePowerItemManager; import techreborn.config.ConfigTechReborn; import techreborn.init.TRContent; @@ -40,14 +40,14 @@ import techreborn.items.tool.ItemChainsaw; public class ItemBasicChainsaw extends ItemChainsaw { public ItemBasicChainsaw() { - super(ItemTier.IRON, ConfigTechReborn.BasicChainsawCharge, 0.5F); + super(ToolMaterials.IRON, ConfigTechReborn.BasicChainsawCharge, 0.5F); this.cost = 50; } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void fillItemGroup(ItemGroup par2ItemGroup, NonNullList itemList) { - if (!isInGroup(par2ItemGroup)) { + public void appendItemsForGroup(ItemGroup par2ItemGroup, DefaultedList itemList) { + if (!isInItemGroup(par2ItemGroup)) { return; } ItemStack stack = new ItemStack(TRContent.BASIC_CHAINSAW); @@ -60,7 +60,7 @@ public class ItemBasicChainsaw extends ItemChainsaw { } @Override - public boolean canHarvestBlock(IBlockState state) { - return Items.IRON_AXE.canHarvestBlock(state); + public boolean isEffectiveOn(BlockState state) { + return Items.IRON_AXE.isEffectiveOn(state); } } diff --git a/src/main/java/techreborn/items/tool/basic/ItemBasicDrill.java b/src/main/java/techreborn/items/tool/basic/ItemBasicDrill.java index ccd618f14..cdcd5f09e 100644 --- a/src/main/java/techreborn/items/tool/basic/ItemBasicDrill.java +++ b/src/main/java/techreborn/items/tool/basic/ItemBasicDrill.java @@ -24,14 +24,14 @@ package techreborn.items.tool.basic; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Items; +import net.minecraft.block.BlockState; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTier; -import net.minecraft.util.NonNullList; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.item.Items; +import net.minecraft.item.ToolMaterials; +import net.minecraft.util.DefaultedList; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import reborncore.common.powerSystem.forge.ForgePowerItemManager; import techreborn.config.ConfigTechReborn; import techreborn.init.TRContent; @@ -40,14 +40,14 @@ import techreborn.items.tool.ItemDrill; public class ItemBasicDrill extends ItemDrill { public ItemBasicDrill() { - super(ItemTier.IRON, ConfigTechReborn.BasicDrillCharge, 0.5F, 10F); + super(ToolMaterials.IRON, ConfigTechReborn.BasicDrillCharge, 0.5F, 10F); this.cost = 50; } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void fillItemGroup(ItemGroup par2ItemGroup, NonNullList itemList) { - if (!isInGroup(par2ItemGroup)) { + public void appendItemsForGroup(ItemGroup par2ItemGroup, DefaultedList itemList) { + if (!isInItemGroup(par2ItemGroup)) { return; } ItemStack stack = new ItemStack(TRContent.BASIC_DRILL); @@ -60,7 +60,7 @@ public class ItemBasicDrill extends ItemDrill { } @Override - public boolean canHarvestBlock(IBlockState state) { - return Items.IRON_PICKAXE.canHarvestBlock(state) || Items.IRON_SHOVEL.canHarvestBlock(state); + public boolean isEffectiveOn(BlockState state) { + return Items.IRON_PICKAXE.isEffectiveOn(state) || Items.IRON_SHOVEL.isEffectiveOn(state); } } diff --git a/src/main/java/techreborn/items/tool/basic/ItemBasicJackhammer.java b/src/main/java/techreborn/items/tool/basic/ItemBasicJackhammer.java index a8dc3fe40..4a440274e 100644 --- a/src/main/java/techreborn/items/tool/basic/ItemBasicJackhammer.java +++ b/src/main/java/techreborn/items/tool/basic/ItemBasicJackhammer.java @@ -26,10 +26,10 @@ package techreborn.items.tool.basic; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTier; -import net.minecraft.util.NonNullList; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.item.ToolMaterials; +import net.minecraft.util.DefaultedList; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import reborncore.common.powerSystem.forge.ForgePowerItemManager; import techreborn.config.ConfigTechReborn; import techreborn.init.TRContent; @@ -38,15 +38,15 @@ import techreborn.items.tool.ItemJackhammer; public class ItemBasicJackhammer extends ItemJackhammer { public ItemBasicJackhammer() { - super(ItemTier.DIAMOND, ConfigTechReborn.BasicJackhammerCharge); + super(ToolMaterials.DIAMOND, ConfigTechReborn.BasicJackhammerCharge); this.cost = 50; - this.efficiency = 12F; + this.blockBreakingSpeed = 12F; } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void fillItemGroup(ItemGroup par2ItemGroup, NonNullList itemList) { - if (!isInGroup(par2ItemGroup)) { + public void appendItemsForGroup(ItemGroup par2ItemGroup, DefaultedList itemList) { + if (!isInItemGroup(par2ItemGroup)) { return; } ItemStack stack = new ItemStack(TRContent.BASIC_JACKHAMMER); diff --git a/src/main/java/techreborn/items/tool/basic/ItemElectricTreetap.java b/src/main/java/techreborn/items/tool/basic/ItemElectricTreetap.java index ac470b1bf..21b35748a 100644 --- a/src/main/java/techreborn/items/tool/basic/ItemElectricTreetap.java +++ b/src/main/java/techreborn/items/tool/basic/ItemElectricTreetap.java @@ -27,13 +27,13 @@ package techreborn.items.tool.basic; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.NonNullList; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraft.item.ItemUsageContext; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.ActionResult; +import net.minecraft.util.DefaultedList; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + import reborncore.api.power.IEnergyItemInfo; import reborncore.common.powerSystem.ExternalPowerSystems; import reborncore.common.powerSystem.PowerSystem; @@ -55,22 +55,22 @@ public class ItemElectricTreetap extends Item implements IEnergyItemInfo { public int cost = 20; public ItemElectricTreetap() { - super(new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(1)); + super(new Item.Settings().itemGroup(TechReborn.ITEMGROUP).stackSize(1)); } // Item @Override - public EnumActionResult onItemUse(ItemUseContext context) { - ForgePowerItemManager capEnergy = new ForgePowerItemManager(context.getItem()); + public ActionResult useOnBlock(ItemUsageContext context) { + ForgePowerItemManager capEnergy = new ForgePowerItemManager(context.getItemStack()); if(TechRebornAPI.ic2Helper != null && capEnergy.getEnergyStored() >= cost){ - if(TechRebornAPI.ic2Helper.extractSap(context, null) && !context.getWorld().isRemote){ + if(TechRebornAPI.ic2Helper.extractSap(context, null) && !context.getWorld().isClient){ capEnergy.extractEnergy(cost, false); ExternalPowerSystems.requestEnergyFromArmor(capEnergy, context.getPlayer()); - return EnumActionResult.SUCCESS; + return ActionResult.SUCCESS; } } - return EnumActionResult.PASS; + return ActionResult.PASS; } @Override @@ -90,14 +90,14 @@ public class ItemElectricTreetap extends Item implements IEnergyItemInfo { @Override @Nullable - public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) { + public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { return new PoweredItemContainerProvider(stack); } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void fillItemGroup(ItemGroup par2ItemGroup, NonNullList itemList) { - if (!isInGroup(par2ItemGroup)) { + public void appendItemsForGroup(ItemGroup par2ItemGroup, DefaultedList itemList) { + if (!isInItemGroup(par2ItemGroup)) { return; } ItemStack uncharged = new ItemStack(TRContent.ELECTRIC_TREE_TAP); diff --git a/src/main/java/techreborn/items/tool/industrial/ItemIndustrialChainsaw.java b/src/main/java/techreborn/items/tool/industrial/ItemIndustrialChainsaw.java index deb89b8d1..1c2efea1d 100644 --- a/src/main/java/techreborn/items/tool/industrial/ItemIndustrialChainsaw.java +++ b/src/main/java/techreborn/items/tool/industrial/ItemIndustrialChainsaw.java @@ -24,29 +24,29 @@ package techreborn.items.tool.industrial; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.resources.I18n; -import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.ChatFormat; +import net.minecraft.block.BlockState; +import net.minecraft.client.item.TooltipContext; +import net.minecraft.client.resource.language.I18n; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.inventory.InventoryHelper; +import net.minecraft.entity.ItemEntity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTier; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tags.BlockTags; +import net.minecraft.item.Items; +import net.minecraft.item.ToolMaterials; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.tag.BlockTags; import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.math.Direction; import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.common.IShearable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + import reborncore.common.powerSystem.ExternalPowerSystems; import reborncore.common.powerSystem.forge.ForgePowerItemManager; import reborncore.common.util.ChatUtils; @@ -63,20 +63,20 @@ import java.util.List; public class ItemIndustrialChainsaw extends ItemChainsaw { - private static final EnumFacing[] SEARCH_ORDER = new EnumFacing[]{EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST, EnumFacing.UP}; + private static final Direction[] SEARCH_ORDER = new Direction[]{Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST, Direction.UP}; // 4M FE max charge with 1k charge rate public ItemIndustrialChainsaw() { - super(ItemTier.DIAMOND, ConfigTechReborn.IndustrialChainsawCharge, 1.0F); + super(ToolMaterials.DIAMOND, ConfigTechReborn.IndustrialChainsawCharge, 1.0F); this.cost = 250; this.transferLimit = 1000; } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void fillItemGroup(ItemGroup par2ItemGroup, NonNullList itemList) { - if (!isInGroup(par2ItemGroup)) { + public void appendItemsForGroup(ItemGroup par2ItemGroup, DefaultedList itemList) { + if (!isInItemGroup(par2ItemGroup)) { return; } ItemStack stack = new ItemStack(TRContent.INDUSTRIAL_CHAINSAW); @@ -89,14 +89,14 @@ public class ItemIndustrialChainsaw extends ItemChainsaw { } @Override - public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState blockIn, BlockPos pos, EntityLivingBase entityLiving) { - if(ItemUtils.isActive(stack) && !worldIn.isRemote){ - IBlockState state = worldIn.getBlockState(pos); + public boolean onBlockBroken(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) { + if(ItemUtils.isActive(stack) && !worldIn.isClient){ + BlockState state = worldIn.getBlockState(pos); if(state.getBlock() instanceof IShearable){ if(((IShearable) state.getBlock()).isShearable(stack, worldIn, pos)){ List results = ((IShearable) state.getBlock()).onSheared(stack, worldIn, pos, 0); - results.forEach(itemStack -> InventoryHelper.spawnItemStack(worldIn, (double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), itemStack)); - return super.onBlockDestroyed(stack, worldIn, blockIn, pos, entityLiving); + results.forEach(itemStack -> ItemScatterer.spawn(worldIn, (double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), itemStack)); + return super.onBlockBroken(stack, worldIn, blockIn, pos, entityLiving); } } } @@ -104,7 +104,7 @@ public class ItemIndustrialChainsaw extends ItemChainsaw { List wood = new ArrayList<>(); findWood(worldIn, pos, wood, new ArrayList<>()); wood.forEach(pos1 -> breakBlock(pos1, stack, worldIn, entityLiving, pos)); - return super.onBlockDestroyed(stack, worldIn, blockIn, pos, entityLiving); + return super.onBlockBroken(stack, worldIn, blockIn, pos, entityLiving); } private void findWood(World world, BlockPos pos, List wood, List leaves){ @@ -116,10 +116,10 @@ public class ItemIndustrialChainsaw extends ItemChainsaw { if(leaves.size() >= 150){ return; } - for(EnumFacing facing : SEARCH_ORDER){ + for(Direction facing : SEARCH_ORDER){ BlockPos checkPos = pos.offset(facing); if(!wood.contains(checkPos) && !leaves.contains(checkPos)){ - IBlockState state = world.getBlockState(checkPos); + BlockState state = world.getBlockState(checkPos); if(TagUtils.hasTag(state.getBlock(), BlockTags.LOGS)){ wood.add(checkPos); findWood(world, checkPos, wood, leaves); @@ -133,71 +133,71 @@ public class ItemIndustrialChainsaw extends ItemChainsaw { } @Override - public ActionResult onItemRightClick(final World world, final EntityPlayer player, final EnumHand hand) { - final ItemStack stack = player.getHeldItem(hand); + public TypedActionResult use(final World world, final PlayerEntity player, final Hand hand) { + final ItemStack stack = player.getStackInHand(hand); if (player.isSneaking()) { if (new ForgePowerItemManager(stack).getEnergyStored() < cost) { - ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponentString( - TextFormatting.GRAY + I18n.format("techreborn.message.nanosaberEnergyErrorTo") + " " - + TextFormatting.GOLD + I18n - .format("techreborn.message.nanosaberActivate"))); + ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponent( + ChatFormat.GRAY + I18n.translate("techreborn.message.nanosaberEnergyErrorTo") + " " + + ChatFormat.GOLD + I18n + .translate("techreborn.message.nanosaberActivate"))); } else { if (!ItemUtils.isActive(stack)) { if (stack.getTag() == null) { - stack.setTag(new NBTTagCompound()); + stack.setTag(new CompoundTag()); } stack.getTag().putBoolean("isActive", true); - if (world.isRemote) { - ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponentString( - TextFormatting.GRAY + I18n.format("techreborn.message.setTo") + " " - + TextFormatting.GOLD + I18n - .format("techreborn.message.nanosaberActive"))); + if (world.isClient) { + ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponent( + ChatFormat.GRAY + I18n.translate("techreborn.message.setTo") + " " + + ChatFormat.GOLD + I18n + .translate("techreborn.message.nanosaberActive"))); } } else { stack.getTag().putBoolean("isActive", false); - if (world.isRemote) { - ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponentString( - TextFormatting.GRAY + I18n.format("techreborn.message.setTo") + " " - + TextFormatting.GOLD + I18n - .format("techreborn.message.nanosaberInactive"))); + if (world.isClient) { + ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponent( + ChatFormat.GRAY + I18n.translate("techreborn.message.setTo") + " " + + ChatFormat.GOLD + I18n + .translate("techreborn.message.nanosaberInactive"))); } } } - return new ActionResult<>(EnumActionResult.SUCCESS, stack); + return new TypedActionResult<>(ActionResult.SUCCESS, stack); } - return new ActionResult<>(EnumActionResult.PASS, stack); + return new TypedActionResult<>(ActionResult.PASS, stack); } @Override - public boolean onEntityItemUpdate(ItemStack stack, EntityItem entity) { + public boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity) { if (ItemUtils.isActive(stack) && new ForgePowerItemManager(stack).getEnergyStored() < cost) { - if(entity.world.isRemote){ - ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponentString( - TextFormatting.GRAY + I18n.format("techreborn.message.nanosaberEnergyError") + " " - + TextFormatting.GOLD + I18n - .format("techreborn.message.nanosaberDeactivating"))); + if(entity.world.isClient){ + ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponent( + ChatFormat.GRAY + I18n.translate("techreborn.message.nanosaberEnergyError") + " " + + ChatFormat.GOLD + I18n + .translate("techreborn.message.nanosaberDeactivating"))); } stack.getTag().putBoolean("isActive", false); } return false; } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { + public void buildTooltip(ItemStack stack, @Nullable World worldIn, List tooltip, TooltipContext flagIn) { if (!ItemUtils.isActive(stack)) { - tooltip.add(new TextComponentString(TextFormatting.YELLOW + "Shear: " + TextFormatting.RED + I18n.format("techreborn.message.nanosaberInactive"))); + tooltip.add(new TextComponent(ChatFormat.YELLOW + "Shear: " + ChatFormat.RED + I18n.translate("techreborn.message.nanosaberInactive"))); } else { - tooltip.add(new TextComponentString(TextFormatting.YELLOW + "Shear: " + TextFormatting.GREEN + I18n.format("techreborn.message.nanosaberActive"))); + tooltip.add(new TextComponent(ChatFormat.YELLOW + "Shear: " + ChatFormat.GREEN + I18n.translate("techreborn.message.nanosaberActive"))); } } @Override - public boolean canHarvestBlock(IBlockState blockIn) { - return Items.DIAMOND_AXE.canHarvestBlock(blockIn); + public boolean isEffectiveOn(BlockState blockIn) { + return Items.DIAMOND_AXE.isEffectiveOn(blockIn); } - public void breakBlock(BlockPos pos, ItemStack stack, World world, EntityLivingBase entityLiving, BlockPos oldPos) { + public void breakBlock(BlockPos pos, ItemStack stack, World world, LivingEntity entityLiving, BlockPos oldPos) { if (oldPos == pos) { return; } @@ -207,19 +207,19 @@ public class ItemIndustrialChainsaw extends ItemChainsaw { return; } - IBlockState blockState = world.getBlockState(pos); - if (blockState.getBlockHardness(world, pos) == -1.0F) { + BlockState blockState = world.getBlockState(pos); + if (blockState.getHardness(world, pos) == -1.0F) { return; } - if(!(entityLiving instanceof EntityPlayer)){ + if(!(entityLiving instanceof PlayerEntity)){ return; } capEnergy.extractEnergy(cost, false); ExternalPowerSystems.requestEnergyFromArmor(capEnergy, entityLiving); - blockState.getBlock().harvestBlock(world, (EntityPlayer) entityLiving, pos, blockState, world.getTileEntity(pos), stack); + blockState.getBlock().afterBreak(world, (PlayerEntity) entityLiving, pos, blockState, world.getBlockEntity(pos), stack); world.removeBlock(pos); - world.removeTileEntity(pos); + world.removeBlockEntity(pos); } } diff --git a/src/main/java/techreborn/items/tool/industrial/ItemIndustrialDrill.java b/src/main/java/techreborn/items/tool/industrial/ItemIndustrialDrill.java index 008a38bcd..996ee4b96 100644 --- a/src/main/java/techreborn/items/tool/industrial/ItemIndustrialDrill.java +++ b/src/main/java/techreborn/items/tool/industrial/ItemIndustrialDrill.java @@ -24,28 +24,29 @@ package techreborn.items.tool.industrial; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.resources.I18n; -import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.ChatFormat; +import net.minecraft.block.BlockState; +import net.minecraft.block.Material; +import net.minecraft.client.item.TooltipContext; +import net.minecraft.client.resource.language.I18n; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; +import net.minecraft.entity.ItemEntity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTier; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.item.Items; +import net.minecraft.item.ToolMaterials; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; import net.minecraft.util.*; +import net.minecraft.util.hit.HitResult; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.math.Direction; import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import reborncore.common.powerSystem.ExternalPowerSystems; import reborncore.common.powerSystem.forge.ForgePowerItemManager; import reborncore.common.util.ChatUtils; @@ -65,22 +66,22 @@ public class ItemIndustrialDrill extends ItemDrill { // 4M FE max charge with 1k charge rate public ItemIndustrialDrill() { - super(ItemTier.DIAMOND, ConfigTechReborn.IndustrialDrillCharge, 2.0F, 10F); + super(ToolMaterials.DIAMOND, ConfigTechReborn.IndustrialDrillCharge, 2.0F, 10F); this.cost = 250; this.transferLimit = 1000; } - public Set getTargetBlocks(World worldIn, BlockPos pos, @Nullable EntityPlayer playerIn) { + public Set getTargetBlocks(World worldIn, BlockPos pos, @Nullable PlayerEntity playerIn) { Set targetBlocks = new HashSet(); - if (!(playerIn instanceof EntityPlayer)) { + if (!(playerIn instanceof PlayerEntity)) { return new HashSet(); } - RayTraceResult raytrace = rayTrace(worldIn, playerIn, false); + HitResult raytrace = rayTrace(worldIn, playerIn, false); if(raytrace == null || raytrace.sideHit == null){ return Collections.emptySet(); } - EnumFacing enumfacing = raytrace.sideHit; - if (enumfacing == EnumFacing.SOUTH || enumfacing == EnumFacing.NORTH) { + Direction enumfacing = raytrace.sideHit; + if (enumfacing == Direction.SOUTH || enumfacing == Direction.NORTH) { for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { BlockPos newPos = pos.add(i, j, 0); @@ -89,7 +90,7 @@ public class ItemIndustrialDrill extends ItemDrill { } } } - } else if (enumfacing == EnumFacing.EAST || enumfacing == EnumFacing.WEST) { + } else if (enumfacing == Direction.EAST || enumfacing == Direction.WEST) { for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { BlockPos newPos = pos.add(0, j, i); @@ -98,7 +99,7 @@ public class ItemIndustrialDrill extends ItemDrill { } } } - } else if (enumfacing == EnumFacing.DOWN || enumfacing == EnumFacing.UP) { + } else if (enumfacing == Direction.DOWN || enumfacing == Direction.UP) { for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { BlockPos newPos = pos.add(j, 0, i); @@ -111,8 +112,8 @@ public class ItemIndustrialDrill extends ItemDrill { return targetBlocks; } - public void breakBlock(BlockPos pos, World world, EntityPlayer playerIn, ItemStack drill) { - IBlockState blockState = world.getBlockState(pos); + public void breakBlock(BlockPos pos, World world, PlayerEntity playerIn, ItemStack drill) { + BlockState blockState = world.getBlockState(pos); ForgePowerItemManager capEnergy = new ForgePowerItemManager(drill); @@ -121,28 +122,28 @@ public class ItemIndustrialDrill extends ItemDrill { ExternalPowerSystems.requestEnergyFromArmor(capEnergy, playerIn); blockState.getBlock().removedByPlayer(blockState, world, pos, playerIn, true, null); - blockState.getBlock().harvestBlock(world, playerIn, pos, blockState, world.getTileEntity(pos), drill); + blockState.getBlock().afterBreak(world, playerIn, pos, blockState, world.getBlockEntity(pos), drill); world.removeBlock(pos); - world.removeTileEntity(pos); + world.removeBlockEntity(pos); } } - private boolean shouldBreak(EntityPlayer playerIn, World worldIn, BlockPos originalPos, BlockPos pos) { + private boolean shouldBreak(PlayerEntity playerIn, World worldIn, BlockPos originalPos, BlockPos pos) { if (originalPos.equals(pos)) { return false; } - IBlockState blockState = worldIn.getBlockState(pos); + BlockState blockState = worldIn.getBlockState(pos); if (blockState.getMaterial() == Material.AIR) { return false; } if (blockState.getMaterial().isLiquid()) { return false; } - float blockHardness = blockState.getPlayerRelativeBlockHardness(playerIn, worldIn, pos); + float blockHardness = blockState.calcBlockBreakingDelta(playerIn, worldIn, pos); if (blockHardness == -1.0F) { return false; } - float originalHardness = worldIn.getBlockState(originalPos).getPlayerRelativeBlockHardness(playerIn, worldIn, originalPos); + float originalHardness = worldIn.getBlockState(originalPos).calcBlockBreakingDelta(playerIn, worldIn, originalPos); if ((originalHardness / blockHardness) > 10.0F) { return false; } @@ -152,90 +153,90 @@ public class ItemIndustrialDrill extends ItemDrill { // ItemDrill @Override - public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState blockIn, BlockPos pos, EntityLivingBase entityLiving) { - EntityPlayer playerIn = null; - if ((entityLiving instanceof EntityPlayer)) { - playerIn = (EntityPlayer) entityLiving; + public boolean onBlockBroken(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) { + PlayerEntity playerIn = null; + if ((entityLiving instanceof PlayerEntity)) { + playerIn = (PlayerEntity) entityLiving; } if(ItemUtils.isActive(stack)){ for (BlockPos additionalPos : getTargetBlocks(worldIn, pos, playerIn)) { breakBlock(additionalPos, worldIn, playerIn, stack); } } - return super.onBlockDestroyed(stack, worldIn, blockIn, pos, entityLiving); + return super.onBlockBroken(stack, worldIn, blockIn, pos, entityLiving); } @Override - public ActionResult onItemRightClick(final World world, final EntityPlayer player, final EnumHand hand) { - final ItemStack stack = player.getHeldItem(hand); + public TypedActionResult use(final World world, final PlayerEntity player, final Hand hand) { + final ItemStack stack = player.getStackInHand(hand); if (player.isSneaking()) { if (new ForgePowerItemManager(stack).getEnergyStored() < cost) { - ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponentString( - TextFormatting.GRAY + I18n.format("techreborn.message.nanosaberEnergyErrorTo") + " " - + TextFormatting.GOLD + I18n - .format("techreborn.message.nanosaberActivate"))); + ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponent( + ChatFormat.GRAY + I18n.translate("techreborn.message.nanosaberEnergyErrorTo") + " " + + ChatFormat.GOLD + I18n + .translate("techreborn.message.nanosaberActivate"))); } else { if (!ItemUtils.isActive(stack)) { if (stack.getTag() == null) { - stack.setTag(new NBTTagCompound()); + stack.setTag(new CompoundTag()); } stack.getTag().putBoolean("isActive", true); - if (world.isRemote) { - ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponentString( - TextFormatting.GRAY + I18n.format("techreborn.message.setTo") + " " - + TextFormatting.GOLD + I18n - .format("techreborn.message.nanosaberActive"))); + if (world.isClient) { + ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponent( + ChatFormat.GRAY + I18n.translate("techreborn.message.setTo") + " " + + ChatFormat.GOLD + I18n + .translate("techreborn.message.nanosaberActive"))); } } else { stack.getTag().putBoolean("isActive", false); - if (world.isRemote) { - ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponentString( - TextFormatting.GRAY + I18n.format("techreborn.message.setTo") + " " - + TextFormatting.GOLD + I18n - .format("techreborn.message.nanosaberInactive"))); + if (world.isClient) { + ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponent( + ChatFormat.GRAY + I18n.translate("techreborn.message.setTo") + " " + + ChatFormat.GOLD + I18n + .translate("techreborn.message.nanosaberInactive"))); } } } - return new ActionResult<>(EnumActionResult.SUCCESS, stack); + return new TypedActionResult<>(ActionResult.SUCCESS, stack); } - return new ActionResult<>(EnumActionResult.PASS, stack); + return new TypedActionResult<>(ActionResult.PASS, stack); } @Override - public boolean onEntityItemUpdate(ItemStack stack, EntityItem entity) { + public boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity) { if (ItemUtils.isActive(stack) && new ForgePowerItemManager(stack).getEnergyStored() < cost) { - if(entity.world.isRemote){ - ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponentString( - TextFormatting.GRAY + I18n.format("techreborn.message.nanosaberEnergyError") + " " - + TextFormatting.GOLD + I18n - .format("techreborn.message.nanosaberDeactivating"))); + if(entity.world.isClient){ + ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponent( + ChatFormat.GRAY + I18n.translate("techreborn.message.nanosaberEnergyError") + " " + + ChatFormat.GOLD + I18n + .translate("techreborn.message.nanosaberDeactivating"))); } stack.getTag().putBoolean("isActive", false); } return false; } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { + public void buildTooltip(ItemStack stack, @Nullable World worldIn, List tooltip, TooltipContext flagIn) { if (!ItemUtils.isActive(stack)) { - tooltip.add(new TextComponentString(TextFormatting.YELLOW + "Shear: " + TextFormatting.RED + I18n.format("techreborn.message.nanosaberInactive"))); + tooltip.add(new TextComponent(ChatFormat.YELLOW + "Shear: " + ChatFormat.RED + I18n.translate("techreborn.message.nanosaberInactive"))); } else { - tooltip.add(new TextComponentString(TextFormatting.YELLOW + "Shear: " + TextFormatting.GREEN + I18n.format("techreborn.message.nanosaberActive"))); + tooltip.add(new TextComponent(ChatFormat.YELLOW + "Shear: " + ChatFormat.GREEN + I18n.translate("techreborn.message.nanosaberActive"))); } } // ItemPickaxe @Override - public boolean canHarvestBlock(IBlockState blockIn) { - return (Items.DIAMOND_PICKAXE.canHarvestBlock(blockIn) || Items.DIAMOND_SHOVEL.canHarvestBlock(blockIn)) && !Items.DIAMOND_AXE.canHarvestBlock(blockIn); + public boolean isEffectiveOn(BlockState blockIn) { + return (Items.DIAMOND_PICKAXE.isEffectiveOn(blockIn) || Items.DIAMOND_SHOVEL.isEffectiveOn(blockIn)) && !Items.DIAMOND_AXE.isEffectiveOn(blockIn); } // Item - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void fillItemGroup(ItemGroup par2ItemGroup, NonNullList itemList) { - if (!isInGroup(par2ItemGroup)) { + public void appendItemsForGroup(ItemGroup par2ItemGroup, DefaultedList itemList) { + if (!isInItemGroup(par2ItemGroup)) { return; } ItemStack stack = new ItemStack(TRContent.INDUSTRIAL_DRILL); diff --git a/src/main/java/techreborn/items/tool/industrial/ItemIndustrialJackhammer.java b/src/main/java/techreborn/items/tool/industrial/ItemIndustrialJackhammer.java index eec36c34c..501a8eb7e 100644 --- a/src/main/java/techreborn/items/tool/industrial/ItemIndustrialJackhammer.java +++ b/src/main/java/techreborn/items/tool/industrial/ItemIndustrialJackhammer.java @@ -26,10 +26,10 @@ package techreborn.items.tool.industrial; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTier; -import net.minecraft.util.NonNullList; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.item.ToolMaterials; +import net.minecraft.util.DefaultedList; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import reborncore.common.powerSystem.forge.ForgePowerItemManager; import techreborn.config.ConfigTechReborn; import techreborn.init.TRContent; @@ -39,17 +39,17 @@ public class ItemIndustrialJackhammer extends ItemJackhammer { // 4M FE max charge with 1k charge rate public ItemIndustrialJackhammer() { - super(ItemTier.IRON, ConfigTechReborn.IndustrialJackhammerCharge); + super(ToolMaterials.IRON, ConfigTechReborn.IndustrialJackhammerCharge); this.cost = 250; - this.efficiency = 60F; + this.blockBreakingSpeed = 60F; this.transferLimit = 1000; } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void fillItemGroup( - ItemGroup par2ItemGroup, NonNullList itemList) { - if (!isInGroup(par2ItemGroup)) { + public void appendItemsForGroup( + ItemGroup par2ItemGroup, DefaultedList itemList) { + if (!isInItemGroup(par2ItemGroup)) { return; } ItemStack stack = new ItemStack(TRContent.INDUSTRIAL_JACKHAMMER); diff --git a/src/main/java/techreborn/items/tool/industrial/ItemNanosaber.java b/src/main/java/techreborn/items/tool/industrial/ItemNanosaber.java index 602c89f59..93a72aee7 100644 --- a/src/main/java/techreborn/items/tool/industrial/ItemNanosaber.java +++ b/src/main/java/techreborn/items/tool/industrial/ItemNanosaber.java @@ -26,25 +26,25 @@ package techreborn.items.tool.industrial; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; -import net.minecraft.client.resources.I18n; -import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.ChatFormat; +import net.minecraft.client.item.TooltipContext; +import net.minecraft.client.resource.language.I18n; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.ai.attributes.AttributeModifier; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.attribute.EntityAttributeModifier; +import net.minecraft.entity.attribute.EntityAttributes; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.*; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.util.*; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextComponentTranslation; -import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + import reborncore.api.power.IEnergyItemInfo; import reborncore.common.powerSystem.ExternalPowerSystems; import reborncore.common.powerSystem.PowerSystem; @@ -60,22 +60,22 @@ import techreborn.utils.MessageIDs; import javax.annotation.Nullable; import java.util.List; -public class ItemNanosaber extends ItemSword implements IEnergyItemInfo { +public class ItemNanosaber extends SwordItem implements IEnergyItemInfo { public static final int maxCharge = ConfigTechReborn.nanoSaberCharge; public int transferLimit = 1_000; public int cost = 250; // 4M FE max charge with 1k charge rate public ItemNanosaber() { - super(ItemTier.DIAMOND, 1, 1, new Item.Properties().group(TechReborn.ITEMGROUP).setNoRepair().maxStackSize(1)); - this.addPropertyOverride(new ResourceLocation("techreborn:active"), new IItemPropertyGetter() { + super(ToolMaterials.DIAMOND, 1, 1, new Item.Settings().itemGroup(TechReborn.ITEMGROUP).setNoRepair().maxStackSize(1)); + this.addProperty(new Identifier("techreborn:active"), new ItemPropertyGetter() { @Override - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) public float call(ItemStack stack, @Nullable World worldIn, @Nullable - EntityLivingBase entityIn) { + LivingEntity entityIn) { if (ItemUtils.isActive(stack)) { ForgePowerItemManager capEnergy = new ForgePowerItemManager(stack); if (capEnergy.getMaxEnergyStored() - capEnergy.getEnergyStored() >= 0.9 * capEnergy.getMaxEnergyStored()) { @@ -90,7 +90,7 @@ public class ItemNanosaber extends ItemSword implements IEnergyItemInfo { // ItemSword @Override - public boolean hitEntity(ItemStack stack, EntityLivingBase entityHit, EntityLivingBase entityHitter) { + public boolean onEntityDamaged(ItemStack stack, LivingEntity entityHit, LivingEntity entityHitter) { ForgePowerItemManager capEnergy = new ForgePowerItemManager(stack); if (capEnergy.getEnergyStored() >= cost) { capEnergy.extractEnergy(cost, false); @@ -104,65 +104,65 @@ public class ItemNanosaber extends ItemSword implements IEnergyItemInfo { // Item @Override - public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { - Multimap multimap = HashMultimap.create(); + public Multimap getAttributeModifiers(EquipmentSlot slot, ItemStack stack) { + Multimap multimap = HashMultimap.create(); int modifier = 0; if (ItemUtils.isActive(stack)) { modifier = 9; } - if (slot == EntityEquipmentSlot.MAINHAND) { - multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), - new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", (double) modifier, 0)); - multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), - new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.4000000953674316D, 0)); + if (slot == EquipmentSlot.MAINHAND) { + multimap.put(EntityAttributes.ATTACK_DAMAGE.getId(), + new EntityAttributeModifier(MODIFIER_DAMAGE, "Weapon modifier", (double) modifier, 0)); + multimap.put(EntityAttributes.ATTACK_SPEED.getId(), + new EntityAttributeModifier(MODIFIER_SWING_SPEED, "Weapon modifier", -2.4000000953674316D, 0)); } return multimap; } @Override - public ActionResult onItemRightClick(final World world, final EntityPlayer player, final EnumHand hand) { - final ItemStack stack = player.getHeldItem(hand); + public TypedActionResult use(final World world, final PlayerEntity player, final Hand hand) { + final ItemStack stack = player.getStackInHand(hand); if (player.isSneaking()) { if (new ForgePowerItemManager(stack).getEnergyStored() < cost) { - ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponentString( - TextFormatting.GRAY + I18n.format("techreborn.message.nanosaberEnergyErrorTo") + " " - + TextFormatting.GOLD + I18n - .format("techreborn.message.nanosaberActivate"))); + ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponent( + ChatFormat.GRAY + I18n.translate("techreborn.message.nanosaberEnergyErrorTo") + " " + + ChatFormat.GOLD + I18n + .translate("techreborn.message.nanosaberActivate"))); } else { if (!ItemUtils.isActive(stack)) { if (stack.getTag() == null) { - stack.setTag(new NBTTagCompound()); + stack.setTag(new CompoundTag()); } stack.getTag().putBoolean("isActive", true); - if (world.isRemote) { - ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponentString( - TextFormatting.GRAY + I18n.format("techreborn.message.setTo") + " " - + TextFormatting.GOLD + I18n - .format("techreborn.message.nanosaberActive"))); + if (world.isClient) { + ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponent( + ChatFormat.GRAY + I18n.translate("techreborn.message.setTo") + " " + + ChatFormat.GOLD + I18n + .translate("techreborn.message.nanosaberActive"))); } } else { stack.getTag().putBoolean("isActive", false); - if (world.isRemote) { - ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponentString( - TextFormatting.GRAY + I18n.format("techreborn.message.setTo") + " " - + TextFormatting.GOLD + I18n - .format("techreborn.message.nanosaberInactive"))); + if (world.isClient) { + ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponent( + ChatFormat.GRAY + I18n.translate("techreborn.message.setTo") + " " + + ChatFormat.GOLD + I18n + .translate("techreborn.message.nanosaberInactive"))); } } } - return new ActionResult<>(EnumActionResult.SUCCESS, stack); + return new TypedActionResult<>(ActionResult.SUCCESS, stack); } - return new ActionResult<>(EnumActionResult.PASS, stack); + return new TypedActionResult<>(ActionResult.PASS, stack); } @Override - public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { + public void onEntityTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if (ItemUtils.isActive(stack) && new ForgePowerItemManager(stack).getEnergyStored() < cost) { - if(worldIn.isRemote){ - ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponentString( - TextFormatting.GRAY + I18n.format("techreborn.message.nanosaberEnergyError") + " " - + TextFormatting.GOLD + I18n - .format("techreborn.message.nanosaberDeactivating"))); + if(worldIn.isClient){ + ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponent( + ChatFormat.GRAY + I18n.translate("techreborn.message.nanosaberEnergyError") + " " + + ChatFormat.GOLD + I18n + .translate("techreborn.message.nanosaberDeactivating"))); } stack.getTag().putBoolean("isActive", false); } @@ -192,29 +192,29 @@ public class ItemNanosaber extends ItemSword implements IEnergyItemInfo { @Nullable public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable - NBTTagCompound nbt) { + CompoundTag nbt) { return new PoweredItemContainerProvider(stack); } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void fillItemGroup( - ItemGroup par2ItemGroup, NonNullList itemList) { - if (!isInGroup(par2ItemGroup)) { + public void appendItemsForGroup( + ItemGroup par2ItemGroup, DefaultedList itemList) { + if (!isInItemGroup(par2ItemGroup)) { return; } ItemStack inactiveUncharged = new ItemStack(this); - inactiveUncharged.setTag(new NBTTagCompound()); + inactiveUncharged.setTag(new CompoundTag()); inactiveUncharged.getTag().putBoolean("isActive", false); ItemStack inactiveCharged = new ItemStack(TRContent.NANOSABER); - inactiveCharged.setTag(new NBTTagCompound()); + inactiveCharged.setTag(new CompoundTag()); inactiveCharged.getTag().putBoolean("isActive", false); ForgePowerItemManager capEnergy = new ForgePowerItemManager(inactiveCharged); capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored()); ItemStack activeCharged = new ItemStack(TRContent.NANOSABER); - activeCharged.setTag(new NBTTagCompound()); + activeCharged.setTag(new CompoundTag()); activeCharged.getTag().putBoolean("isActive", true); ForgePowerItemManager capEnergy2 = new ForgePowerItemManager(activeCharged); capEnergy2.setEnergyStored(capEnergy2.getMaxEnergyStored()); @@ -224,13 +224,13 @@ public class ItemNanosaber extends ItemSword implements IEnergyItemInfo { itemList.add(activeCharged); } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { + public void buildTooltip(ItemStack stack, @Nullable World worldIn, List tooltip, TooltipContext flagIn) { if (!ItemUtils.isActive(stack)) { - tooltip.add(new TextComponentTranslation("techreborn.message.nanosaberInactive").applyTextStyle(TextFormatting.GRAY)); + tooltip.add(new TranslatableComponent("techreborn.message.nanosaberInactive").applyFormat(ChatFormat.GRAY)); } else { - tooltip.add(new TextComponentTranslation("techreborn.message.nanosaberActive").applyTextStyle(TextFormatting.GRAY)); + tooltip.add(new TranslatableComponent("techreborn.message.nanosaberActive").applyFormat(ChatFormat.GRAY)); } } diff --git a/src/main/java/techreborn/items/tool/industrial/ItemOmniTool.java b/src/main/java/techreborn/items/tool/industrial/ItemOmniTool.java index 6a9337ca2..136edb991 100644 --- a/src/main/java/techreborn/items/tool/industrial/ItemOmniTool.java +++ b/src/main/java/techreborn/items/tool/industrial/ItemOmniTool.java @@ -24,24 +24,23 @@ package techreborn.items.tool.industrial; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; +import net.minecraft.ChatFormat; +import net.minecraft.block.BlockState; +import net.minecraft.client.item.TooltipContext; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.damage.DamageSource; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.*; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.DamageSource; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.NonNullList; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.util.ActionResult; +import net.minecraft.util.DefaultedList; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + import reborncore.api.power.IEnergyItemInfo; import reborncore.common.powerSystem.ExternalPowerSystems; import reborncore.common.powerSystem.PowerSystem; @@ -56,7 +55,7 @@ import techreborn.init.TRContent; import javax.annotation.Nullable; import java.util.List; -public class ItemOmniTool extends ItemPickaxe implements IEnergyItemInfo { +public class ItemOmniTool extends PickaxeItem implements IEnergyItemInfo { public static final int maxCharge = ConfigTechReborn.OmniToolCharge; public int transferLimit = 1_000; @@ -65,21 +64,21 @@ public class ItemOmniTool extends ItemPickaxe implements IEnergyItemInfo { // 4M FE max charge with 1k charge rate public ItemOmniTool() { - super(ItemTier.DIAMOND, 1, 1, new Item.Properties().group(TechReborn.ITEMGROUP).maxStackSize(1)); - efficiency = 13F; + super(ToolMaterials.DIAMOND, 1, 1, new Item.Settings().itemGroup(TechReborn.ITEMGROUP).stackSize(1)); + blockBreakingSpeed = 13F; } // ItemPickaxe @Override - public boolean canHarvestBlock(IBlockState state) { - return Items.DIAMOND_AXE.canHarvestBlock(state) || Items.DIAMOND_SWORD.canHarvestBlock(state) - || Items.DIAMOND_PICKAXE.canHarvestBlock(state) || Items.DIAMOND_SHOVEL.canHarvestBlock(state) - || Items.SHEARS.canHarvestBlock(state); + public boolean isEffectiveOn(BlockState state) { + return Items.DIAMOND_AXE.isEffectiveOn(state) || Items.DIAMOND_SWORD.isEffectiveOn(state) + || Items.DIAMOND_PICKAXE.isEffectiveOn(state) || Items.DIAMOND_SHOVEL.isEffectiveOn(state) + || Items.SHEARS.isEffectiveOn(state); } // ItemTool @Override - public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState blockIn, BlockPos pos, EntityLivingBase entityLiving) { + public boolean onBlockBroken(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) { ForgePowerItemManager capEnergy = new ForgePowerItemManager(stack); capEnergy.extractEnergy(cost, false); @@ -110,20 +109,20 @@ public class ItemOmniTool extends ItemPickaxe implements IEnergyItemInfo { // } @Override - public boolean hitEntity(ItemStack stack, EntityLivingBase entityliving, EntityLivingBase attacker) { + public boolean onEntityDamaged(ItemStack stack, LivingEntity entityliving, LivingEntity attacker) { ForgePowerItemManager capEnergy = new ForgePowerItemManager(stack); if (capEnergy.getEnergyStored() >= hitCost) { capEnergy.extractEnergy(hitCost, false); ExternalPowerSystems.requestEnergyFromArmor(capEnergy, entityliving); - entityliving.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), 8F); + entityliving.damage(DamageSource.player((PlayerEntity) attacker), 8F); } return false; } // Item @Override - public EnumActionResult onItemUse(ItemUseContext context) { + public ActionResult useOnBlock(ItemUsageContext context) { return TorchHelper.placeTorch(context); } @@ -133,8 +132,8 @@ public class ItemOmniTool extends ItemPickaxe implements IEnergyItemInfo { } @Override - public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { - tooltip.add(new TextComponentString("WIP Coming Soon").applyTextStyle(TextFormatting.RED)); + public void buildTooltip(ItemStack stack, @Nullable World worldIn, List tooltip, TooltipContext flagIn) { + tooltip.add(new TextComponent("WIP Coming Soon").applyFormat(ChatFormat.RED)); // TODO // Remember to remove WIP override and imports once complete } @@ -156,15 +155,15 @@ public class ItemOmniTool extends ItemPickaxe implements IEnergyItemInfo { @Override @Nullable - public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) { + public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { return new PoweredItemContainerProvider(stack); } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @Override - public void fillItemGroup( - ItemGroup par2ItemGroup, NonNullList itemList) { - if (!isInGroup(par2ItemGroup)) { + public void appendItemsForGroup( + ItemGroup par2ItemGroup, DefaultedList itemList) { + if (!isInItemGroup(par2ItemGroup)) { return; } ItemStack uncharged = new ItemStack(TRContent.OMNI_TOOL); diff --git a/src/main/java/techreborn/items/tool/vanilla/ItemTRAxe.java b/src/main/java/techreborn/items/tool/vanilla/ItemTRAxe.java index 3d18881ef..9d6a76018 100644 --- a/src/main/java/techreborn/items/tool/vanilla/ItemTRAxe.java +++ b/src/main/java/techreborn/items/tool/vanilla/ItemTRAxe.java @@ -24,31 +24,31 @@ package techreborn.items.tool.vanilla; -import net.minecraft.item.IItemTier; +import net.minecraft.item.AxeItem; import net.minecraft.item.Item; -import net.minecraft.item.ItemAxe; import net.minecraft.item.ItemStack; +import net.minecraft.item.ToolMaterial; import reborncore.common.util.ItemUtils; import techreborn.TechReborn; -public class ItemTRAxe extends ItemAxe { +public class ItemTRAxe extends AxeItem { String repairOreDict = ""; - public ItemTRAxe(IItemTier material) { + public ItemTRAxe(ToolMaterial material) { this(material, ""); } - public ItemTRAxe(IItemTier material, String repairOreDict) { - super(material, material.getAttackDamage() + 5.75F, (material.getAttackDamage() + 6.75F) * -0.344444F, new Item.Properties().group(TechReborn.ITEMGROUP)); + public ItemTRAxe(ToolMaterial material, String repairOreDict) { + super(material, material.getAttackDamage() + 5.75F, (material.getAttackDamage() + 6.75F) * -0.344444F, new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); this.repairOreDict = repairOreDict; } @Override - public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { + public boolean canRepair(ItemStack toRepair, ItemStack repair) { if (toRepair.getItem() == this && !repairOreDict.isEmpty()) { return ItemUtils.isInputEqual(repairOreDict, repair, false, false); } - return super.getIsRepairable(toRepair, repair); + return super.canRepair(toRepair, repair); } } diff --git a/src/main/java/techreborn/items/tool/vanilla/ItemTRHoe.java b/src/main/java/techreborn/items/tool/vanilla/ItemTRHoe.java index 96d3abd58..b80ce3541 100644 --- a/src/main/java/techreborn/items/tool/vanilla/ItemTRHoe.java +++ b/src/main/java/techreborn/items/tool/vanilla/ItemTRHoe.java @@ -24,31 +24,31 @@ package techreborn.items.tool.vanilla; -import net.minecraft.item.IItemTier; +import net.minecraft.item.HoeItem; import net.minecraft.item.Item; -import net.minecraft.item.ItemHoe; import net.minecraft.item.ItemStack; +import net.minecraft.item.ToolMaterial; import reborncore.common.util.ItemUtils; import techreborn.TechReborn; -public class ItemTRHoe extends ItemHoe { +public class ItemTRHoe extends HoeItem { String repairOreDict = ""; - public ItemTRHoe(IItemTier material) { + public ItemTRHoe(ToolMaterial material) { this(material, ""); } - public ItemTRHoe(IItemTier material, String repairOreDict) { - super(material, 1F, new Item.Properties().group(TechReborn.ITEMGROUP)); + public ItemTRHoe(ToolMaterial material, String repairOreDict) { + super(material, 1F, new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); this.repairOreDict = repairOreDict; } @Override - public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { + public boolean canRepair(ItemStack toRepair, ItemStack repair) { if (toRepair.getItem() == this && !repairOreDict.isEmpty()) { return ItemUtils.isInputEqual(repairOreDict, repair, false, true); } - return super.getIsRepairable(toRepair, repair); + return super.canRepair(toRepair, repair); } } diff --git a/src/main/java/techreborn/items/tool/vanilla/ItemTRPickaxe.java b/src/main/java/techreborn/items/tool/vanilla/ItemTRPickaxe.java index db6eb6cb5..62a0678c9 100644 --- a/src/main/java/techreborn/items/tool/vanilla/ItemTRPickaxe.java +++ b/src/main/java/techreborn/items/tool/vanilla/ItemTRPickaxe.java @@ -24,31 +24,31 @@ package techreborn.items.tool.vanilla; -import net.minecraft.item.IItemTier; import net.minecraft.item.Item; -import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; +import net.minecraft.item.PickaxeItem; +import net.minecraft.item.ToolMaterial; import reborncore.common.util.ItemUtils; import techreborn.TechReborn; -public class ItemTRPickaxe extends ItemPickaxe { +public class ItemTRPickaxe extends PickaxeItem { String repairOreDict = ""; - public ItemTRPickaxe(IItemTier material) { + public ItemTRPickaxe(ToolMaterial material) { this(material, ""); } - public ItemTRPickaxe(IItemTier material, String repairOreDict) { - super(material, 1, (material.getAttackDamage() + 6.75F) * -0.344444F, new Item.Properties().group(TechReborn.ITEMGROUP)); + public ItemTRPickaxe(ToolMaterial material, String repairOreDict) { + super(material, 1, (material.getAttackDamage() + 6.75F) * -0.344444F, new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); this.repairOreDict = repairOreDict; } @Override - public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { + public boolean canRepair(ItemStack toRepair, ItemStack repair) { if (toRepair.getItem() == this && !repairOreDict.isEmpty()) { return ItemUtils.isInputEqual(repairOreDict, repair, true, true); } - return super.getIsRepairable(toRepair, repair); + return super.canRepair(toRepair, repair); } } diff --git a/src/main/java/techreborn/items/tool/vanilla/ItemTRSpade.java b/src/main/java/techreborn/items/tool/vanilla/ItemTRSpade.java index 19c3c88da..0df862abd 100644 --- a/src/main/java/techreborn/items/tool/vanilla/ItemTRSpade.java +++ b/src/main/java/techreborn/items/tool/vanilla/ItemTRSpade.java @@ -24,31 +24,31 @@ package techreborn.items.tool.vanilla; -import net.minecraft.item.IItemTier; import net.minecraft.item.Item; -import net.minecraft.item.ItemSpade; import net.minecraft.item.ItemStack; +import net.minecraft.item.ShovelItem; +import net.minecraft.item.ToolMaterial; import reborncore.common.util.ItemUtils; import techreborn.TechReborn; -public class ItemTRSpade extends ItemSpade { +public class ItemTRSpade extends ShovelItem { String repairOreDict = ""; - public ItemTRSpade(IItemTier material) { + public ItemTRSpade(ToolMaterial material) { this(material, ""); } - public ItemTRSpade(IItemTier material, String repairOreDict) { - super(material, material.getAttackDamage() + 5.75F, (material.getAttackDamage() + 6.75F) * -0.344444F, new Item.Properties().group(TechReborn.ITEMGROUP)); + public ItemTRSpade(ToolMaterial material, String repairOreDict) { + super(material, material.getAttackDamage() + 5.75F, (material.getAttackDamage() + 6.75F) * -0.344444F, new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); this.repairOreDict = repairOreDict; } @Override - public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { + public boolean canRepair(ItemStack toRepair, ItemStack repair) { if (toRepair.getItem() == this && !repairOreDict.isEmpty()) { return ItemUtils.isInputEqual(repairOreDict, repair, false, true); } - return super.getIsRepairable(toRepair, repair); + return super.canRepair(toRepair, repair); } } diff --git a/src/main/java/techreborn/items/tool/vanilla/ItemTRSword.java b/src/main/java/techreborn/items/tool/vanilla/ItemTRSword.java index 0eeadad1e..328fce82a 100644 --- a/src/main/java/techreborn/items/tool/vanilla/ItemTRSword.java +++ b/src/main/java/techreborn/items/tool/vanilla/ItemTRSword.java @@ -24,31 +24,31 @@ package techreborn.items.tool.vanilla; -import net.minecraft.item.IItemTier; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemSword; +import net.minecraft.item.SwordItem; +import net.minecraft.item.ToolMaterial; import reborncore.common.util.ItemUtils; import techreborn.TechReborn; -public class ItemTRSword extends ItemSword { +public class ItemTRSword extends SwordItem { String repairOreDict = ""; - public ItemTRSword(IItemTier material) { + public ItemTRSword(ToolMaterial material) { this(material, ""); } - public ItemTRSword(IItemTier material, String repairOreDict) { - super(material, 1, (material.getAttackDamage() + 6.75F) * -0.344444F, new Item.Properties().group(TechReborn.ITEMGROUP)); + public ItemTRSword(ToolMaterial material, String repairOreDict) { + super(material, 1, (material.getAttackDamage() + 6.75F) * -0.344444F, new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); this.repairOreDict = repairOreDict; } @Override - public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { + public boolean canRepair(ItemStack toRepair, ItemStack repair) { if (toRepair.getItem() == this && !repairOreDict.isEmpty()) { return ItemUtils.isInputEqual(repairOreDict, repair, false, true); } - return super.getIsRepairable(toRepair, repair); + return super.canRepair(toRepair, repair); } } diff --git a/src/main/java/techreborn/multiblocks/MultiBlockCasing.java b/src/main/java/techreborn/multiblocks/MultiBlockCasing.java index 326c7ee0a..0abbd1c33 100644 --- a/src/main/java/techreborn/multiblocks/MultiBlockCasing.java +++ b/src/main/java/techreborn/multiblocks/MultiBlockCasing.java @@ -25,8 +25,8 @@ package techreborn.multiblocks; import net.minecraft.block.Block; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.nbt.CompoundTag; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import reborncore.common.multiblock.IMultiblockPart; @@ -122,7 +122,7 @@ public class MultiBlockCasing extends RectangularMultiblockControllerBase { // Now we run a simple check on each block within that volume. // Any block deviating = NO DEAL SIR - TileEntity te; + BlockEntity te; RectangularMultiblockTileEntityBase part; Class myClass = this.getClass(); @@ -131,7 +131,7 @@ public class MultiBlockCasing extends RectangularMultiblockControllerBase { for (int z = minimumCoord.getZ(); z <= maximumCoord.getZ(); z++) { // Okay, figure out what sort of block this should be. - te = this.worldObj.getTileEntity(new BlockPos(x, y, z)); + te = this.worldObj.getBlockEntity(new BlockPos(x, y, z)); if (te instanceof RectangularMultiblockTileEntityBase) { part = (RectangularMultiblockTileEntityBase) te; @@ -211,7 +211,7 @@ public class MultiBlockCasing extends RectangularMultiblockControllerBase { } @Override - public void onAttachedPartWithMultiblockData(IMultiblockPart part, NBTTagCompound data) { + public void onAttachedPartWithMultiblockData(IMultiblockPart part, CompoundTag data) { } @@ -300,22 +300,22 @@ public class MultiBlockCasing extends RectangularMultiblockControllerBase { } @Override - public void write(NBTTagCompound data) { + public void write(CompoundTag data) { } @Override - public void read(NBTTagCompound data) { + public void read(CompoundTag data) { } @Override - public void formatDescriptionPacket(NBTTagCompound data) { + public void formatDescriptionPacket(CompoundTag data) { } @Override - public void decodeDescriptionPacket(NBTTagCompound data) { + public void decodeDescriptionPacket(CompoundTag data) { } diff --git a/src/main/java/techreborn/packets/ServerboundPackets.java b/src/main/java/techreborn/packets/ServerboundPackets.java index aeb8be8c0..07c218bb3 100644 --- a/src/main/java/techreborn/packets/ServerboundPackets.java +++ b/src/main/java/techreborn/packets/ServerboundPackets.java @@ -24,13 +24,10 @@ package techreborn.packets; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; -import net.minecraftforge.fml.network.NetworkEvent; + import reborncore.common.network.ExtendedPacketBuffer; import reborncore.common.network.NetworkManager; import reborncore.common.network.NetworkPacket; @@ -47,12 +44,12 @@ import java.util.function.Consumer; public class ServerboundPackets { - public static final ResourceLocation AESU = new ResourceLocation("techreborn", "aesu"); - public static final ResourceLocation AUTO_CRAFTING_LOCK = new ResourceLocation("techreborn", "auto_crafting_lock"); - public static final ResourceLocation ROLLING_MACHINE_LOCK = new ResourceLocation("techreborn", "rolling_machine_lock"); - public static final ResourceLocation FUSION_CONTROL_SIZE = new ResourceLocation("techreborn", "fusion_control_size"); - public static final ResourceLocation IDSU = new ResourceLocation("techreborn", "idsu"); - public static final ResourceLocation REFUND = new ResourceLocation("techreborn", "refund"); + public static final Identifier AESU = new Identifier("techreborn", "aesu"); + public static final Identifier AUTO_CRAFTING_LOCK = new Identifier("techreborn", "auto_crafting_lock"); + public static final Identifier ROLLING_MACHINE_LOCK = new Identifier("techreborn", "rolling_machine_lock"); + public static final Identifier FUSION_CONTROL_SIZE = new Identifier("techreborn", "fusion_control_size"); + public static final Identifier IDSU = new Identifier("techreborn", "idsu"); + public static final Identifier REFUND = new Identifier("techreborn", "refund"); public static void init() { NetworkManager.registerPacketHandler(AESU, (extendedPacketBuffer, context) -> { diff --git a/src/main/java/techreborn/proxies/ClientProxy.java b/src/main/java/techreborn/proxies/ClientProxy.java index f22ca9d72..808074dc1 100644 --- a/src/main/java/techreborn/proxies/ClientProxy.java +++ b/src/main/java/techreborn/proxies/ClientProxy.java @@ -24,15 +24,15 @@ package techreborn.proxies; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.ChatFormat; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.client.render.entity.EntityRenderer; import net.minecraft.item.ItemStack; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.client.registry.ClientRegistry; -import net.minecraftforge.fml.client.registry.IRenderFactory; -import net.minecraftforge.fml.client.registry.RenderingRegistry; + + + + import reborncore.api.tile.IUpgradeable; import reborncore.client.IconSupplier; import reborncore.client.gui.builder.GuiBase; @@ -76,11 +76,11 @@ public class ClientProxy extends CommonProxy { @Override public String getUpgradeConfigText() { - if (Minecraft.getInstance().currentScreen instanceof GuiBase) { - GuiBase base = (GuiBase) Minecraft.getInstance().currentScreen; + if (MinecraftClient.getInstance().currentScreen instanceof GuiBase) { + GuiBase base = (GuiBase) MinecraftClient.getInstance().currentScreen; if (base.tile instanceof IUpgradeable) { if (((IUpgradeable) base.tile).canBeUpgraded()) { - return TextFormatting.LIGHT_PURPLE + "Right click to configure"; + return ChatFormat.LIGHT_PURPLE + "Right click to configure"; } } } @@ -90,14 +90,14 @@ public class ClientProxy extends CommonProxy { public class RenderManagerNuke implements IRenderFactory { @Override - public Render createRenderFor(RenderManager manager) { + public EntityRenderer createRenderFor(EntityRenderDispatcher manager) { return new RenderNukePrimed(manager); } } @Override public boolean fancyGraphics() { - return Minecraft.getInstance().gameSettings.fancyGraphics; + return MinecraftClient.getInstance().options.fancyGraphics; } } diff --git a/src/main/java/techreborn/tiles/TileAlarm.java b/src/main/java/techreborn/tiles/TileAlarm.java index 3ce069dd4..272a7e1e1 100644 --- a/src/main/java/techreborn/tiles/TileAlarm.java +++ b/src/main/java/techreborn/tiles/TileAlarm.java @@ -24,14 +24,14 @@ package techreborn.tiles; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.ChatFormat; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.sound.SoundCategory; import net.minecraft.util.ITickable; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; import reborncore.api.IToolDrop; import reborncore.common.util.ChatUtils; import reborncore.common.util.StringUtils; @@ -41,7 +41,7 @@ import techreborn.init.TRContent; import techreborn.init.TRTileEntities; import techreborn.utils.MessageIDs; -public class TileAlarm extends TileEntity +public class TileAlarm extends BlockEntity implements ITickable, IToolDrop { private int selectedSound = 1; @@ -50,33 +50,33 @@ public class TileAlarm extends TileEntity } public void rightClick() { - if (!world.isRemote) { + if (!world.isClient) { if (selectedSound < 3) { selectedSound++; } else { selectedSound = 1; } - ChatUtils.sendNoSpamMessages(MessageIDs.alarmID, new TextComponentString( - TextFormatting.GRAY + StringUtils.t("techreborn.message.alarm") + " " + "Alarm " + selectedSound)); + ChatUtils.sendNoSpamMessages(MessageIDs.alarmID, new TextComponent( + ChatFormat.GRAY + StringUtils.t("techreborn.message.alarm") + " " + "Alarm " + selectedSound)); } } // TileEntity @Override - public NBTTagCompound write(NBTTagCompound compound) { + public CompoundTag toTag(CompoundTag compound) { if (compound == null) { - compound = new NBTTagCompound(); + compound = new CompoundTag(); } compound.putInt("selectedSound", this.selectedSound); - return super.write(compound); + return super.toTag(compound); } @Override - public void read(NBTTagCompound compound) { - if (compound != null && compound.contains("selectedSound")) { + public void fromTag(CompoundTag compound) { + if (compound != null && compound.containsKey("selectedSound")) { selectedSound = compound.getInt("selectedSound"); } - super.read(compound); + super.fromTag(compound); } //TODO 1.13 seems to be gone? @@ -88,7 +88,7 @@ public class TileAlarm extends TileEntity // ITickable @Override public void tick() { - if (!world.isRemote && world.getGameTime() % 25 == 0 && world.isBlockPowered(getPos())) { + if (!world.isClient && world.getTime() % 25 == 0 && world.isReceivingRedstonePower(getPos())) { BlockAlarm.setActive(true, world, pos); switch (selectedSound) { case 1: @@ -102,14 +102,14 @@ public class TileAlarm extends TileEntity break; } - } else if (!world.isRemote && world.getGameTime() % 25 == 0) { + } else if (!world.isClient && world.getTime() % 25 == 0) { BlockAlarm.setActive(false, world, pos); } } // IToolDrop @Override - public ItemStack getToolDrop(final EntityPlayer entityPlayer) { + public ItemStack getToolDrop(final PlayerEntity entityPlayer) { return TRContent.Machine.ALARM.getStack(); } } diff --git a/src/main/java/techreborn/tiles/TileChargeOMat.java b/src/main/java/techreborn/tiles/TileChargeOMat.java index 4a7e5d447..23599fcea 100644 --- a/src/main/java/techreborn/tiles/TileChargeOMat.java +++ b/src/main/java/techreborn/tiles/TileChargeOMat.java @@ -24,9 +24,9 @@ package techreborn.tiles; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.Direction; import reborncore.api.IToolDrop; import reborncore.api.tile.ItemHandlerProvider; import reborncore.client.containerBuilder.IContainerProvider; @@ -63,11 +63,11 @@ public class TileChargeOMat extends TilePowerAcceptor public void tick() { super.tick(); - if(world.isRemote){ + if(world.isClient){ return; } for (int i = 0; i < 6; i++) { - ItemStack stack = inventory.getStackInSlot(i); + ItemStack stack = inventory.getInvStack(i); if (!stack.isEmpty()) { ExternalPowerSystems.chargeItem(this, stack); @@ -81,12 +81,12 @@ public class TileChargeOMat extends TilePowerAcceptor } @Override - public boolean canAcceptEnergy(final EnumFacing direction) { + public boolean canAcceptEnergy(final Direction direction) { return true; } @Override - public boolean canProvideEnergy(final EnumFacing direction) { + public boolean canProvideEnergy(final Direction direction) { return false; } @@ -108,7 +108,7 @@ public class TileChargeOMat extends TilePowerAcceptor // IToolDrop @Override - public ItemStack getToolDrop(final EntityPlayer entityPlayer) { + public ItemStack getToolDrop(final PlayerEntity entityPlayer) { return TRContent.Machine.CHARGE_O_MAT.getStack(); } @@ -120,7 +120,7 @@ public class TileChargeOMat extends TilePowerAcceptor // IContainerProvider @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("chargebench").player(player.inventory).inventory().hotbar().addInventory() .tile(this).energySlot(0, 62, 25).energySlot(1, 98, 25).energySlot(2, 62, 45).energySlot(3, 98, 45) .energySlot(4, 62, 65).energySlot(5, 98, 65).syncEnergyValue().addInventory().create(this); diff --git a/src/main/java/techreborn/tiles/TileDigitalChest.java b/src/main/java/techreborn/tiles/TileDigitalChest.java index a24697186..206e4b629 100644 --- a/src/main/java/techreborn/tiles/TileDigitalChest.java +++ b/src/main/java/techreborn/tiles/TileDigitalChest.java @@ -24,7 +24,7 @@ package techreborn.tiles; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.containerBuilder.builder.ContainerBuilder; @@ -44,7 +44,7 @@ public class TileDigitalChest extends TileTechStorageBase implements IContainerP } @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("digitalchest").player(player.inventory).inventory().hotbar().addInventory() .tile(this).slot(0, 80, 24).outputSlot(1, 80, 64).addInventory().create(this); } diff --git a/src/main/java/techreborn/tiles/TileGenericMachine.java b/src/main/java/techreborn/tiles/TileGenericMachine.java index 97e8bcbcb..c3bad2109 100644 --- a/src/main/java/techreborn/tiles/TileGenericMachine.java +++ b/src/main/java/techreborn/tiles/TileGenericMachine.java @@ -25,10 +25,10 @@ package techreborn.tiles; import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.Direction; import reborncore.api.IToolDrop; import reborncore.api.recipe.IRecipeCrafterProvider; import reborncore.api.tile.ItemHandlerProvider; @@ -58,7 +58,7 @@ public abstract class TileGenericMachine extends TilePowerAcceptor * @param toolDrop Block Block to drop with wrench * @param energySlot int Energy slot to use to charge machine from battery */ - public TileGenericMachine(TileEntityType tileEntityType, String name, int maxInput, int maxEnergy, Block toolDrop, int energySlot) { + public TileGenericMachine(BlockEntityType tileEntityType, String name, int maxInput, int maxEnergy, Block toolDrop, int energySlot) { super(tileEntityType); this.name = "Tile" + name; this.maxInput = maxInput; @@ -79,7 +79,7 @@ public abstract class TileGenericMachine extends TilePowerAcceptor @Override public void tick() { super.tick(); - if (!world.isRemote) { + if (!world.isClient) { charge(energySlot); } } @@ -90,12 +90,12 @@ public abstract class TileGenericMachine extends TilePowerAcceptor } @Override - public boolean canAcceptEnergy(final EnumFacing direction) { + public boolean canAcceptEnergy(final Direction direction) { return true; } @Override - public boolean canProvideEnergy(final EnumFacing direction) { + public boolean canProvideEnergy(final Direction direction) { return false; } @@ -111,7 +111,7 @@ public abstract class TileGenericMachine extends TilePowerAcceptor // IToolDrop @Override - public ItemStack getToolDrop(EntityPlayer p0) { + public ItemStack getToolDrop(PlayerEntity p0) { return new ItemStack(toolDrop, 1); } diff --git a/src/main/java/techreborn/tiles/TileIndustrialCentrifuge.java b/src/main/java/techreborn/tiles/TileIndustrialCentrifuge.java index 2b53f6ea6..2bb1abbd8 100644 --- a/src/main/java/techreborn/tiles/TileIndustrialCentrifuge.java +++ b/src/main/java/techreborn/tiles/TileIndustrialCentrifuge.java @@ -24,9 +24,6 @@ package techreborn.tiles; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; import reborncore.api.IListInfoProvider; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; @@ -43,6 +40,9 @@ import techreborn.init.TRTileEntities; import techreborn.items.DynamicCell; import java.util.List; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; @RebornRegister(TechReborn.MOD_ID) public class TileIndustrialCentrifuge extends TileGenericMachine implements IContainerProvider, IListInfoProvider { @@ -62,7 +62,7 @@ public class TileIndustrialCentrifuge extends TileGenericMachine implements ICon // IContainerProvider @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("centrifuge").player(player.inventory).inventory().hotbar() .addInventory().tile(this) .filterSlot(1, 40, 54, stack -> ItemUtils.isItemEqual(stack, DynamicCell.getEmptyCell(1), true, true)) @@ -74,8 +74,8 @@ public class TileIndustrialCentrifuge extends TileGenericMachine implements ICon // IListInfoProvider @Override - public void addInfo(final List info, final boolean isRealTile, boolean hasData) { + public void addInfo(final List info, final boolean isRealTile, boolean hasData) { super.addInfo(info, isRealTile, hasData); - info.add(new TextComponentString("Round and round it goes")); + info.add(new TextComponent("Round and round it goes")); } } \ No newline at end of file diff --git a/src/main/java/techreborn/tiles/TileTechStorageBase.java b/src/main/java/techreborn/tiles/TileTechStorageBase.java index cc0950d3c..25a8cb91b 100644 --- a/src/main/java/techreborn/tiles/TileTechStorageBase.java +++ b/src/main/java/techreborn/tiles/TileTechStorageBase.java @@ -24,18 +24,18 @@ package techreborn.tiles; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.client.network.packet.BlockEntityUpdateS2CPacket; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.play.server.SPacketUpdateTileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.common.util.NonNullSupplier; -import net.minecraftforge.items.CapabilityItemHandler; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.ClientConnection; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; + + + + import reborncore.api.IListInfoProvider; import reborncore.api.IToolDrop; import reborncore.api.tile.ItemHandlerProvider; @@ -54,36 +54,36 @@ public class TileTechStorageBase extends TileMachineBase public final Inventory inventory; public ItemStack storedItem; - public TileTechStorageBase(TileEntityType tileEntityTypeIn, String name, int maxCapacity) { + public TileTechStorageBase(BlockEntityType tileEntityTypeIn, String name, int maxCapacity) { super(tileEntityTypeIn); this.maxCapacity = maxCapacity; storedItem = ItemStack.EMPTY; inventory = new Inventory<>(3, name, maxCapacity, this).withConfiguredAccess(); } - public void readWithoutCoords(NBTTagCompound tagCompound) { + public void readWithoutCoords(CompoundTag tagCompound) { storedItem = ItemStack.EMPTY; - if (tagCompound.contains("storedStack")) { - storedItem = ItemStack.read(tagCompound.getCompound("storedStack")); + if (tagCompound.containsKey("storedStack")) { + storedItem = ItemStack.fromTag(tagCompound.getCompound("storedStack")); } if (!storedItem.isEmpty()) { - storedItem.setCount(Math.min(tagCompound.getInt("storedQuantity"), this.maxCapacity)); + storedItem.setAmount(Math.min(tagCompound.getInt("storedQuantity"), this.maxCapacity)); } inventory.read(tagCompound); } - public NBTTagCompound writeWithoutCoords(NBTTagCompound tagCompound) { + public CompoundTag writeWithoutCoords(CompoundTag tagCompound) { if (!storedItem.isEmpty()) { ItemStack temp = storedItem.copy(); - if (storedItem.getCount() > storedItem.getMaxStackSize()) { - temp.setCount(storedItem.getMaxStackSize()); + if (storedItem.getAmount() > storedItem.getMaxAmount()) { + temp.setAmount(storedItem.getMaxAmount()); } - tagCompound.put("storedStack", temp.write(new NBTTagCompound())); - tagCompound.putInt("storedQuantity", Math.min(storedItem.getCount(), maxCapacity)); + tagCompound.put("storedStack", temp.toTag(new CompoundTag())); + tagCompound.putInt("storedQuantity", Math.min(storedItem.getAmount(), maxCapacity)); } else { tagCompound.putInt("storedQuantity", 0); } @@ -92,12 +92,12 @@ public class TileTechStorageBase extends TileMachineBase } public ItemStack getDropWithNBT() { - NBTTagCompound tileEntity = new NBTTagCompound(); + CompoundTag tileEntity = new CompoundTag(); ItemStack dropStack = new ItemStack(getBlockType(), 1); writeWithoutCoords(tileEntity); - dropStack.setTag(new NBTTagCompound()); + dropStack.setTag(new CompoundTag()); dropStack.getTag().put("tileEntity", tileEntity); - storedItem.setCount(0); + storedItem.setAmount(0); inventory.setStackInSlot(1, ItemStack.EMPTY); syncWithAll(); @@ -105,25 +105,25 @@ public class TileTechStorageBase extends TileMachineBase } public int getStoredCount() { - return storedItem.getCount(); + return storedItem.getAmount(); } public List getContentDrops() { ArrayList stacks = new ArrayList<>(); if (!getStoredItemType().isEmpty()) { - if (!inventory.getStackInSlot(1).isEmpty()) { - stacks.add(inventory.getStackInSlot(1)); + if (!inventory.getInvStack(1).isEmpty()) { + stacks.add(inventory.getInvStack(1)); } - int size = storedItem.getMaxStackSize(); + int size = storedItem.getMaxAmount(); for (int i = 0; i < getStoredCount() / size; i++) { ItemStack droped = storedItem.copy(); - droped.setCount(size); + droped.setAmount(size); stacks.add(droped); } if (getStoredCount() % size != 0) { ItemStack droped = storedItem.copy(); - droped.setCount(getStoredCount() % size); + droped.setAmount(getStoredCount() % size); stacks.add(droped); } } @@ -135,27 +135,27 @@ public class TileTechStorageBase extends TileMachineBase @Override public void tick() { super.tick(); - if (!world.isRemote) { + if (!world.isClient) { ItemStack outputStack = ItemStack.EMPTY; - if (!inventory.getStackInSlot(1).isEmpty()) { - outputStack = inventory.getStackInSlot(1); + if (!inventory.getInvStack(1).isEmpty()) { + outputStack = inventory.getInvStack(1); } - if (!inventory.getStackInSlot(0).isEmpty() - && (storedItem.getCount() + outputStack.getCount()) < maxCapacity) { - ItemStack inputStack = inventory.getStackInSlot(0); + if (!inventory.getInvStack(0).isEmpty() + && (storedItem.getAmount() + outputStack.getAmount()) < maxCapacity) { + ItemStack inputStack = inventory.getInvStack(0); if (getStoredItemType().isEmpty() || (storedItem.isEmpty() && ItemUtils.isItemEqual(inputStack, outputStack, true, true))) { storedItem = inputStack; inventory.setStackInSlot(0, ItemStack.EMPTY); } else if (ItemUtils.isItemEqual(getStoredItemType(), inputStack, true, true)) { - int reminder = maxCapacity - storedItem.getCount() - outputStack.getCount(); - if (inputStack.getCount() <= reminder) { - setStoredItemCount(inputStack.getCount()); + int reminder = maxCapacity - storedItem.getAmount() - outputStack.getAmount(); + if (inputStack.getAmount() <= reminder) { + setStoredItemCount(inputStack.getAmount()); inventory.setStackInSlot(0, ItemStack.EMPTY); } else { - setStoredItemCount(maxCapacity - outputStack.getCount()); - inventory.getStackInSlot(0).shrink(reminder); + setStoredItemCount(maxCapacity - outputStack.getAmount()); + inventory.getInvStack(0).subtractAmount(reminder); } } markDirty(); @@ -166,8 +166,8 @@ public class TileTechStorageBase extends TileMachineBase if (outputStack.isEmpty()) { ItemStack delivered = storedItem.copy(); - delivered.setCount(Math.min(storedItem.getCount(), delivered.getMaxStackSize())); - storedItem.shrink(delivered.getCount()); + delivered.setAmount(Math.min(storedItem.getAmount(), delivered.getMaxAmount())); + storedItem.subtractAmount(delivered.getAmount()); if (storedItem.isEmpty()) { storedItem = ItemStack.EMPTY; @@ -177,12 +177,12 @@ public class TileTechStorageBase extends TileMachineBase markDirty(); syncWithAll(); } else if (ItemUtils.isItemEqual(storedItem, outputStack, true, true) - && outputStack.getCount() < outputStack.getMaxStackSize()) { + && outputStack.getAmount() < outputStack.getMaxAmount()) { - int wanted = Math.min(storedItem.getCount(), - outputStack.getMaxStackSize() - outputStack.getCount()); - outputStack.setCount(outputStack.getCount() + wanted); - storedItem.shrink(wanted); + int wanted = Math.min(storedItem.getAmount(), + outputStack.getMaxAmount() - outputStack.getAmount()); + outputStack.setAmount(outputStack.getAmount() + wanted); + storedItem.subtractAmount(wanted); if (storedItem.isEmpty()) { storedItem = ItemStack.EMPTY; @@ -200,20 +200,20 @@ public class TileTechStorageBase extends TileMachineBase } @Override - public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { + public void onDataPacket(ClientConnection net, BlockEntityUpdateS2CPacket packet) { world.markBlockRangeForRenderUpdate(pos.getX(), pos.getY(), pos.getZ(), pos.getX(), pos.getY(), pos.getZ()); - read(packet.getNbtCompound()); + fromTag(packet.getCompoundTag()); } @Override - public void read(NBTTagCompound tagCompound) { - super.read(tagCompound); + public void fromTag(CompoundTag tagCompound) { + super.fromTag(tagCompound); readWithoutCoords(tagCompound); } @Override - public NBTTagCompound write(NBTTagCompound tagCompound) { - super.write(tagCompound); + public CompoundTag toTag(CompoundTag tagCompound) { + super.toTag(tagCompound); writeWithoutCoords(tagCompound); return tagCompound; } @@ -242,41 +242,41 @@ public class TileTechStorageBase extends TileMachineBase // IToolDrop @Override - public ItemStack getToolDrop(EntityPlayer entityPlayer) { + public ItemStack getToolDrop(PlayerEntity entityPlayer) { return getDropWithNBT(); } // IListInfoProvider @Override - public void addInfo(List info, boolean isRealTile, boolean hasData) { + public void addInfo(List info, boolean isRealTile, boolean hasData) { if (isRealTile || hasData) { int size = 0; String name = "of nothing"; if (!storedItem.isEmpty()) { name = storedItem.getDisplayName().getString(); - size += storedItem.getCount(); + size += storedItem.getAmount(); } - if (!inventory.getStackInSlot(1).isEmpty()) { - name = inventory.getStackInSlot(1).getDisplayName().getString(); - size += inventory.getStackInSlot(1).getCount(); + if (!inventory.getInvStack(1).isEmpty()) { + name = inventory.getInvStack(1).getDisplayName().getString(); + size += inventory.getInvStack(1).getAmount(); } - info.add(new TextComponentString(size + " " + name)); + info.add(new TextComponent(size + " " + name)); } } public ItemStack getStoredItemType() { - return storedItem.isEmpty() ? inventory.getStackInSlot(1) : storedItem; + return storedItem.isEmpty() ? inventory.getInvStack(1) : storedItem; } public void setStoredItemCount(int amount) { - storedItem.grow(amount); + storedItem.addAmount(amount); markDirty(); } public void setStoredItemType(ItemStack type, int amount) { storedItem = type; - storedItem.setCount(amount); + storedItem.setAmount(amount); markDirty(); } diff --git a/src/main/java/techreborn/tiles/cable/TileCable.java b/src/main/java/techreborn/tiles/cable/TileCable.java index 53f9f8917..72cb67916 100644 --- a/src/main/java/techreborn/tiles/cable/TileCable.java +++ b/src/main/java/techreborn/tiles/cable/TileCable.java @@ -24,22 +24,22 @@ package techreborn.tiles.cable; +import net.minecraft.ChatFormat; import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.client.network.packet.BlockEntityUpdateS2CPacket; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.play.server.SPacketUpdateTileEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.ClientConnection; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; import net.minecraft.util.ITickable; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.energy.CapabilityEnergy; -import net.minecraftforge.energy.IEnergyStorage; +import net.minecraft.util.math.Direction; + + + + import reborncore.api.IListInfoProvider; import reborncore.api.IToolDrop; import reborncore.common.RebornCoreConfig; @@ -56,13 +56,13 @@ import java.util.List; * Created by modmuss50 on 19/05/2017. */ -public class TileCable extends TileEntity +public class TileCable extends BlockEntity implements ITickable, IEnergyStorage, IListInfoProvider, IToolDrop { public int power = 0; private int transferRate = 0; private TRContent.Cables cableType = null; - private ArrayList sendingFace = new ArrayList(); + private ArrayList sendingFace = new ArrayList(); int ticksSinceLastChange = 0; public TileCable() { @@ -78,7 +78,7 @@ public class TileCable extends TileEntity return TRContent.Cables.COPPER; } - public boolean canReceiveFromFace(EnumFacing face) { + public boolean canReceiveFromFace(Direction face) { if (sendingFace.contains(face)) { return false; } @@ -94,35 +94,35 @@ public class TileCable extends TileEntity } @Override - public NBTTagCompound getUpdateTag() { - return write(new NBTTagCompound()); + public CompoundTag toInitialChunkDataTag() { + return toTag(new CompoundTag()); } @Override - public SPacketUpdateTileEntity getUpdatePacket() { - NBTTagCompound nbtTag = new NBTTagCompound(); - write(nbtTag); - return new SPacketUpdateTileEntity(getPos(), 1, nbtTag); + public BlockEntityUpdateS2CPacket toUpdatePacket() { + CompoundTag nbtTag = new CompoundTag(); + toTag(nbtTag); + return new BlockEntityUpdateS2CPacket(getPos(), 1, nbtTag); } @Override - public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { - read(packet.getNbtCompound()); + public void onDataPacket(ClientConnection net, BlockEntityUpdateS2CPacket packet) { + fromTag(packet.getCompoundTag()); } @Override - public void read(NBTTagCompound compound) { - super.read(compound); - if (compound.contains("TileCable")) { + public void fromTag(CompoundTag compound) { + super.fromTag(compound); + if (compound.containsKey("TileCable")) { power = compound.getCompound("TileCable").getInt("power"); } } @Override - public NBTTagCompound write(NBTTagCompound compound) { - super.write(compound); + public CompoundTag toTag(CompoundTag compound) { + super.toTag(compound); if (power > 0) { - NBTTagCompound data = new NBTTagCompound(); + CompoundTag data = new CompoundTag(); data.putInt("power", getEnergyStored()); compound.put("TileCable", data); } @@ -132,7 +132,7 @@ public class TileCable extends TileEntity // ITickable @Override public void tick() { - if (world.isRemote) { + if (world.isClient) { return; } @@ -152,8 +152,8 @@ public class TileCable extends TileEntity } ArrayList acceptors = new ArrayList(); - for (EnumFacing face : EnumFacing.values()) { - TileEntity tile = world.getTileEntity(pos.offset(face)); + for (Direction face : Direction.values()) { + BlockEntity tile = world.getBlockEntity(pos.offset(face)); if (tile == null) { continue; @@ -239,19 +239,19 @@ public class TileCable extends TileEntity // IListInfoProvider @Override - public void addInfo(List info, boolean isRealTile, boolean hasData) { + public void addInfo(List info, boolean isRealTile, boolean hasData) { if (isRealTile) { - info.add(new TextComponentString(TextFormatting.GRAY + StringUtils.t("techreborn.tooltip.transferRate") + ": " - + TextFormatting.GOLD + info.add(new TextComponent(ChatFormat.GRAY + StringUtils.t("techreborn.tooltip.transferRate") + ": " + + ChatFormat.GOLD + PowerSystem.getLocaliszedPowerFormatted(transferRate / RebornCoreConfig.euPerFU) + "/t")); - info.add(new TextComponentString(TextFormatting.GRAY + StringUtils.t("techreborn.tooltip.tier") + ": " - + TextFormatting.GOLD + StringUtils.toFirstCapitalAllLowercase(cableType.tier.toString()))); + info.add(new TextComponent(ChatFormat.GRAY + StringUtils.t("techreborn.tooltip.tier") + ": " + + ChatFormat.GOLD + StringUtils.toFirstCapitalAllLowercase(cableType.tier.toString()))); } } // IToolDrop @Override - public ItemStack getToolDrop(EntityPlayer playerIn) { + public ItemStack getToolDrop(PlayerEntity playerIn) { return new ItemStack(getCableType().block); } } diff --git a/src/main/java/techreborn/tiles/fusionReactor/TileFusionControlComputer.java b/src/main/java/techreborn/tiles/fusionReactor/TileFusionControlComputer.java index a58778832..7645d0446 100644 --- a/src/main/java/techreborn/tiles/fusionReactor/TileFusionControlComputer.java +++ b/src/main/java/techreborn/tiles/fusionReactor/TileFusionControlComputer.java @@ -24,11 +24,11 @@ package techreborn.tiles.fusionReactor; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; +import net.minecraft.nbt.CompoundTag; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import reborncore.api.IToolDrop; import reborncore.api.tile.ItemHandlerProvider; import reborncore.client.containerBuilder.IContainerProvider; @@ -135,11 +135,11 @@ public class TileFusionControlComputer extends TilePowerAcceptor if (stack.isEmpty()) { return true; } - if (inventory.getStackInSlot(slot).isEmpty()) { + if (inventory.getInvStack(slot).isEmpty()) { return true; } - if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, tags)) { - if (stack.getCount() + inventory.getStackInSlot(slot).getCount() <= stack.getMaxStackSize()) { + if (ItemUtils.isItemEqual(inventory.getInvStack(slot), stack, true, tags)) { + if (stack.getAmount() + inventory.getInvStack(slot).getAmount() <= stack.getMaxAmount()) { return true; } } @@ -182,7 +182,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor * @return boolean True if reactor can execute recipe provided */ private boolean validateReactorRecipe(FusionReactorRecipe recipe) { - boolean validRecipe = validateReactorRecipeInputs(recipe, inventory.getStackInSlot(topStackSlot), inventory.getStackInSlot(bottomStackSlot)) || validateReactorRecipeInputs(recipe, inventory.getStackInSlot(bottomStackSlot), inventory.getStackInSlot(topStackSlot)); + boolean validRecipe = validateReactorRecipeInputs(recipe, inventory.getInvStack(topStackSlot), inventory.getInvStack(bottomStackSlot)) || validateReactorRecipeInputs(recipe, inventory.getInvStack(bottomStackSlot), inventory.getInvStack(topStackSlot)); return validRecipe && getSize() >= recipe.getMinSize(); } @@ -205,18 +205,18 @@ public class TileFusionControlComputer extends TilePowerAcceptor public void tick() { super.tick(); - if (world.isRemote) { + if (world.isClient) { return; } - if(lastTick == world.getGameTime()){ + if(lastTick == world.getTime()){ //Prevent tick accerators, blame obstinate for this. return; } - lastTick = world.getGameTime(); + lastTick = world.getTime(); // Force check every second - if (world.getGameTime() % 20 == 0) { + if (world.getTime() % 20 == 0) { checkCoils(); inventory.setChanged(); } @@ -241,9 +241,9 @@ public class TileFusionControlComputer extends TilePowerAcceptor if (canUseEnergy(currentRecipe.getStartEU())) { useEnergy(currentRecipe.getStartEU()); hasStartedCrafting = true; - inventory.shrinkSlot(topStackSlot, currentRecipe.getTopInput().getCount()); + inventory.shrinkSlot(topStackSlot, currentRecipe.getTopInput().getAmount()); if (!currentRecipe.getBottomInput().isEmpty()) { - inventory.shrinkSlot(bottomStackSlot, currentRecipe.getBottomInput().getCount()); + inventory.shrinkSlot(bottomStackSlot, currentRecipe.getBottomInput().getAmount()); } } } @@ -261,16 +261,16 @@ public class TileFusionControlComputer extends TilePowerAcceptor } } else if (crafingTickTime >= finalTickTime) { if (canFitStack(currentRecipe.getOutput(), outputStackSlot, true)) { - if (inventory.getStackInSlot(outputStackSlot).isEmpty()) { + if (inventory.getInvStack(outputStackSlot).isEmpty()) { inventory.setStackInSlot(outputStackSlot, currentRecipe.getOutput().copy()); } else { - inventory.shrinkSlot(outputStackSlot, -currentRecipe.getOutput().getCount()); + inventory.shrinkSlot(outputStackSlot, -currentRecipe.getOutput().getAmount()); } if (validateReactorRecipe(this.currentRecipe)) { crafingTickTime = 0; - inventory.shrinkSlot(topStackSlot, currentRecipe.getTopInput().getCount()); + inventory.shrinkSlot(topStackSlot, currentRecipe.getTopInput().getAmount()); if (!currentRecipe.getBottomInput().isEmpty()) { - inventory.shrinkSlot(bottomStackSlot, currentRecipe.getBottomInput().getCount()); + inventory.shrinkSlot(bottomStackSlot, currentRecipe.getBottomInput().getAmount()); } } else { resetCrafter(); @@ -296,13 +296,13 @@ public class TileFusionControlComputer extends TilePowerAcceptor } @Override - public boolean canAcceptEnergy(EnumFacing direction) { - return !(direction == EnumFacing.DOWN || direction == EnumFacing.UP); + public boolean canAcceptEnergy(Direction direction) { + return !(direction == Direction.DOWN || direction == Direction.UP); } @Override - public boolean canProvideEnergy(EnumFacing direction) { - return direction == EnumFacing.DOWN || direction == EnumFacing.UP; + public boolean canProvideEnergy(Direction direction) { + return direction == Direction.DOWN || direction == Direction.UP; } @Override @@ -322,28 +322,28 @@ public class TileFusionControlComputer extends TilePowerAcceptor } @Override - public void read(final NBTTagCompound tagCompound) { - super.read(tagCompound); + public void fromTag(final CompoundTag tagCompound) { + super.fromTag(tagCompound); this.crafingTickTime = tagCompound.getInt("crafingTickTime"); this.finalTickTime = tagCompound.getInt("finalTickTime"); this.neededPower = tagCompound.getInt("neededPower"); this.hasStartedCrafting = tagCompound.getBoolean("hasStartedCrafting"); - if(tagCompound.contains("hasActiveRecipe") && tagCompound.getBoolean("hasActiveRecipe") && this.currentRecipe == null){ + if(tagCompound.containsKey("hasActiveRecipe") && tagCompound.getBoolean("hasActiveRecipe") && this.currentRecipe == null){ for (final FusionReactorRecipe reactorRecipe : FusionReactorRecipeHelper.reactorRecipes) { if (validateReactorRecipe(reactorRecipe)) { this.currentRecipe = reactorRecipe; } } } - if(tagCompound.contains("size")){ + if(tagCompound.containsKey("size")){ this.size = tagCompound.getInt("size"); } this.size = Math.min(size, maxCoilSize);//Done here to force the samller size, will be useful if people lag out on a large one. } @Override - public NBTTagCompound write(final NBTTagCompound tagCompound) { - super.write(tagCompound); + public CompoundTag toTag(final CompoundTag tagCompound) { + super.toTag(tagCompound); tagCompound.putInt("crafingTickTime", this.crafingTickTime); tagCompound.putInt("finalTickTime", this.finalTickTime); tagCompound.putInt("neededPower", this.neededPower); @@ -367,7 +367,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor // IToolDrop @Override - public ItemStack getToolDrop(EntityPlayer playerIn) { + public ItemStack getToolDrop(PlayerEntity playerIn) { return TRContent.Machine.FUSION_CONTROL_COMPUTER.getStack(); } @@ -379,7 +379,7 @@ public class TileFusionControlComputer extends TilePowerAcceptor // IContainerProvider @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("fusionreactor").player(player.inventory).inventory().hotbar() .addInventory().tile(this).slot(0, 34, 47).slot(1, 126, 47).outputSlot(2, 80, 47).syncEnergyValue() .syncIntegerValue(this::getCoilStatus, this::setCoilStatus) diff --git a/src/main/java/techreborn/tiles/generator/TileBaseFluidGenerator.java b/src/main/java/techreborn/tiles/generator/TileBaseFluidGenerator.java index 3c5f7644b..13c5db8c5 100644 --- a/src/main/java/techreborn/tiles/generator/TileBaseFluidGenerator.java +++ b/src/main/java/techreborn/tiles/generator/TileBaseFluidGenerator.java @@ -24,10 +24,10 @@ package techreborn.tiles.generator; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.fluids.FluidStack; +import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.math.Direction; + import reborncore.api.IToolDrop; import reborncore.api.tile.ItemHandlerProvider; import reborncore.common.blocks.BlockMachineBase; @@ -59,7 +59,7 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement */ double pendingWithdraw = 0.0; - public TileBaseFluidGenerator(TileEntityType tileEntityType, EFluidGenerator type, String tileName, int tankCapacity, int euTick) { + public TileBaseFluidGenerator(BlockEntityType tileEntityType, EFluidGenerator type, String tileName, int tankCapacity, int euTick) { super(tileEntityType); recipes = GeneratorRecipeHelper.getFluidRecipesForGenerator(type); tank = new Tank(tileName, tankCapacity, this); @@ -73,14 +73,14 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement super.tick(); ticksSinceLastChange++; - if(world.isRemote){ + if(world.isClient){ return; } // Check cells input slot 2 time per second // Please, keep ticks counting on client also to report progress to GUI if (ticksSinceLastChange >= 10) { - if (!inventory.getStackInSlot(0).isEmpty()) { + if (!inventory.getInvStack(0).isEmpty()) { FluidUtils.drainContainers(tank, inventory, 0, 1); FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluidType()); } @@ -103,15 +103,15 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement final int currentWithdraw = (int) pendingWithdraw; pendingWithdraw -= currentWithdraw; tank.drain(currentWithdraw, true); - lastOutput = world.getGameTime(); + lastOutput = world.getTime(); } } } - if (world.getGameTime() - lastOutput < 30 && !isActive()) { + if (world.getTime() - lastOutput < 30 && !isActive()) { world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, true)); } - else if (world.getGameTime() - lastOutput > 30 && isActive()) { + else if (world.getTime() - lastOutput > 30 && isActive()) { world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, false)); } } @@ -136,8 +136,8 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement } protected boolean acceptFluid() { - if (!inventory.getStackInSlot(0).isEmpty()) { - FluidStack stack = FluidUtils.getFluidStackInContainer(inventory.getStackInSlot(0)); + if (!inventory.getInvStack(0).isEmpty()) { + FluidStack stack = FluidUtils.getFluidStackInContainer(inventory.getInvStack(0)); if (stack != null) return recipes.getRecipeForFluid(stack.getFluid()).isPresent(); } @@ -159,12 +159,12 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement } @Override - public boolean canAcceptEnergy(EnumFacing direction) { + public boolean canAcceptEnergy(Direction direction) { return false; } @Override - public boolean canProvideEnergy(EnumFacing direction) { + public boolean canProvideEnergy(Direction direction) { return true; } @@ -174,14 +174,14 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement } @Override - public void read(NBTTagCompound tagCompound) { - super.read(tagCompound); + public void fromTag(CompoundTag tagCompound) { + super.fromTag(tagCompound); tank.read(tagCompound); } @Override - public NBTTagCompound write(NBTTagCompound tagCompound) { - super.write(tagCompound); + public CompoundTag toTag(CompoundTag tagCompound) { + super.toTag(tagCompound); tank.write(tagCompound); return tagCompound; } diff --git a/src/main/java/techreborn/tiles/generator/TileLightningRod.java b/src/main/java/techreborn/tiles/generator/TileLightningRod.java index 16d8e0827..dd87e1b13 100644 --- a/src/main/java/techreborn/tiles/generator/TileLightningRod.java +++ b/src/main/java/techreborn/tiles/generator/TileLightningRod.java @@ -25,11 +25,11 @@ package techreborn.tiles.generator; import net.minecraft.block.Block; -import net.minecraft.entity.effect.EntityLightningBolt; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.LightningEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import reborncore.api.IToolDrop; import reborncore.common.blocks.BlockMachineBase; import reborncore.common.powerSystem.TilePowerAcceptor; @@ -67,24 +67,24 @@ public class TileLightningRod extends TilePowerAcceptor implements IToolDrop { --onStatusHoldTicks; if (onStatusHoldTicks == 0 || getEnergy() <= 0) { - if (getBlockState().getBlock() instanceof BlockMachineBase) - ((BlockMachineBase) getBlockState().getBlock()).setActive(false, world, pos); + if (getCachedState().getBlock() instanceof BlockMachineBase) + ((BlockMachineBase) getCachedState().getBlock()).setActive(false, world, pos); onStatusHoldTicks = -1; } - final float weatherStrength = world.getThunderStrength(1.0F); + final float weatherStrength = world.getThunderGradient(1.0F); if (weatherStrength > 0.2F) { //lightStrikeChance = (MAX - (CHANCE * WEATHER_STRENGTH) final float lightStrikeChance = (100F - chanceOfStrike) * 20F; final float totalChance = lightStrikeChance * getLightningStrikeMultiplier() * (1.1F - weatherStrength); - if (world.rand.nextInt((int) Math.floor(totalChance)) == 0) { + if (world.random.nextInt((int) Math.floor(totalChance)) == 0) { if (!isValidIronFence(pos.up().getY())) { onStatusHoldTicks = 400; return; } - final EntityLightningBolt lightningBolt = new EntityLightningBolt(world, + final LightningEntity lightningBolt = new LightningEntity(world, pos.getX() + 0.5F, - world.getHeight(), + world.getTopPosition(), pos.getZ() + 0.5F, false); world.addWeatherEffect(lightningBolt); world.spawnEntity(lightningBolt); @@ -98,7 +98,7 @@ public class TileLightningRod extends TilePowerAcceptor implements IToolDrop { public float getLightningStrikeMultiplier() { final float actualHeight = world.getDimension().getActualHeight(); - final float groundLevel = world.getHeight(); + final float groundLevel = world.getTopPosition(); for (int i = pos.getY() + 1; i < actualHeight; i++) { if (!isValidIronFence(i)) { if (groundLevel >= i) @@ -125,12 +125,12 @@ public class TileLightningRod extends TilePowerAcceptor implements IToolDrop { } @Override - public boolean canAcceptEnergy(final EnumFacing direction) { + public boolean canAcceptEnergy(final Direction direction) { return false; } @Override - public boolean canProvideEnergy(final EnumFacing direction) { + public boolean canProvideEnergy(final Direction direction) { return true; } @@ -145,7 +145,7 @@ public class TileLightningRod extends TilePowerAcceptor implements IToolDrop { } @Override - public ItemStack getToolDrop(EntityPlayer playerIn) { + public ItemStack getToolDrop(PlayerEntity playerIn) { return TRContent.Machine.LIGHTNING_ROD.getStack(); } } diff --git a/src/main/java/techreborn/tiles/generator/TilePlasmaGenerator.java b/src/main/java/techreborn/tiles/generator/TilePlasmaGenerator.java index 3ac535a5a..e88ab8693 100644 --- a/src/main/java/techreborn/tiles/generator/TilePlasmaGenerator.java +++ b/src/main/java/techreborn/tiles/generator/TilePlasmaGenerator.java @@ -24,7 +24,7 @@ package techreborn.tiles.generator; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; @@ -53,7 +53,7 @@ public class TilePlasmaGenerator extends TileBaseFluidGenerator implements ICont } @Override - public ItemStack getToolDrop(EntityPlayer playerIn) { + public ItemStack getToolDrop(PlayerEntity playerIn) { return TRContent.Machine.PLASMA_GENERATOR.getStack(); } @@ -68,7 +68,7 @@ public class TilePlasmaGenerator extends TileBaseFluidGenerator implements ICont } @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("plasmagenerator").player(player.inventory).inventory().hotbar().addInventory() .tile(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue() .syncIntegerValue(this::getTicksSinceLastChange, this::setTicksSinceLastChange) diff --git a/src/main/java/techreborn/tiles/generator/TileSolarPanel.java b/src/main/java/techreborn/tiles/generator/TileSolarPanel.java index 3542a558b..f186ede57 100644 --- a/src/main/java/techreborn/tiles/generator/TileSolarPanel.java +++ b/src/main/java/techreborn/tiles/generator/TileSolarPanel.java @@ -24,14 +24,14 @@ package techreborn.tiles.generator; +import net.minecraft.ChatFormat; import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.util.math.Direction; import reborncore.api.IToolDrop; import reborncore.api.power.EnumPowerTier; import reborncore.common.powerSystem.PowerSystem; @@ -55,22 +55,22 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop { } public boolean isSunOut() { - return canSeeSky && !world.isRaining() && !world.isThundering() && world.isDaytime(); + return canSeeSky && !world.isRaining() && !world.isThundering() && world.isDaylight(); } // TilePowerAcceptor @Override public void tick() { super.tick(); - if (world.isRemote) { + if (world.isClient) { return; } if (panel == TRContent.SolarPanels.CREATIVE) { setEnergy(Integer.MAX_VALUE); return; } - if (world.getGameTime() % 20 == 0) { - canSeeSky = world.canBlockSeeSky(pos.up()); + if (world.getTime() % 20 == 0) { + canSeeSky = world.method_8626(pos.up()); if (lastState != isSunOut()) { world.setBlockState(pos, world.getBlockState(pos).with(BlockSolarPanel.ACTIVE, isSunOut())); lastState = isSunOut(); @@ -94,12 +94,12 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop { } @Override - public boolean canAcceptEnergy(final EnumFacing direction) { + public boolean canAcceptEnergy(final Direction direction) { return false; } @Override - public boolean canProvideEnergy(final EnumFacing direction) { + public boolean canProvideEnergy(final Direction direction) { return true; } @@ -130,27 +130,27 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop { // TODO: Translate @Override - public void addInfo(List info, boolean isRealTile, boolean hasData) { - info.add(new TextComponentString(TextFormatting.GRAY + "Internal Energy Storage: " + TextFormatting.GOLD + public void addInfo(List info, boolean isRealTile, boolean hasData) { + info.add(new TextComponent(ChatFormat.GRAY + "Internal Energy Storage: " + ChatFormat.GOLD + PowerSystem.getLocaliszedPowerFormatted((int) getMaxPower()))); - info.add(new TextComponentString(TextFormatting.GRAY + "Generation Rate Day: " + TextFormatting.GOLD + info.add(new TextComponent(ChatFormat.GRAY + "Generation Rate Day: " + ChatFormat.GOLD + PowerSystem.getLocaliszedPowerFormatted(panel.generationRateD))); - info.add(new TextComponentString(TextFormatting.GRAY + "Generation Rate Night: " + TextFormatting.GOLD + info.add(new TextComponent(ChatFormat.GRAY + "Generation Rate Night: " + ChatFormat.GOLD + PowerSystem.getLocaliszedPowerFormatted(panel.generationRateN))); - info.add(new TextComponentString(TextFormatting.GRAY + "Tier: " + TextFormatting.GOLD + info.add(new TextComponent(ChatFormat.GRAY + "Tier: " + ChatFormat.GOLD + StringUtils.toFirstCapitalAllLowercase(getTier().toString()))); } @Override - public void read(NBTTagCompound tag) { + public void fromTag(CompoundTag tag) { if (world == null) { // We are in TileEntity.create method during chunk load. this.checkOverfill = false; } - super.read(tag); + super.fromTag(tag); } // TileMachineBase @@ -166,7 +166,7 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop { // IToolDrop @Override - public ItemStack getToolDrop(final EntityPlayer playerIn) { + public ItemStack getToolDrop(final PlayerEntity playerIn) { return new ItemStack(getBlockType()); } } \ No newline at end of file diff --git a/src/main/java/techreborn/tiles/generator/advanced/TileDieselGenerator.java b/src/main/java/techreborn/tiles/generator/advanced/TileDieselGenerator.java index 1c53de886..3784747a8 100644 --- a/src/main/java/techreborn/tiles/generator/advanced/TileDieselGenerator.java +++ b/src/main/java/techreborn/tiles/generator/advanced/TileDieselGenerator.java @@ -24,7 +24,7 @@ package techreborn.tiles.generator.advanced; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; @@ -54,7 +54,7 @@ public class TileDieselGenerator extends TileBaseFluidGenerator implements ICont } @Override - public ItemStack getToolDrop(final EntityPlayer entityPlayer) { + public ItemStack getToolDrop(final PlayerEntity entityPlayer) { return TRContent.Machine.DIESEL_GENERATOR.getStack(); } @@ -69,7 +69,7 @@ public class TileDieselGenerator extends TileBaseFluidGenerator implements ICont } @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("dieselgenerator").player(player.inventory).inventory().hotbar() .addInventory().tile(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue() .syncIntegerValue(this::getTicksSinceLastChange, this::setTicksSinceLastChange) diff --git a/src/main/java/techreborn/tiles/generator/advanced/TileDragonEggSyphon.java b/src/main/java/techreborn/tiles/generator/advanced/TileDragonEggSyphon.java index 11990469b..503180aad 100644 --- a/src/main/java/techreborn/tiles/generator/advanced/TileDragonEggSyphon.java +++ b/src/main/java/techreborn/tiles/generator/advanced/TileDragonEggSyphon.java @@ -24,11 +24,11 @@ package techreborn.tiles.generator.advanced; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; +import net.minecraft.block.Blocks; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import reborncore.api.IToolDrop; import reborncore.api.tile.ItemHandlerProvider; import reborncore.common.blocks.BlockMachineBase; @@ -74,16 +74,16 @@ public class TileDragonEggSyphon extends TilePowerAcceptor public void tick() { super.tick(); - if (!world.isRemote) { + if (!world.isClient) { if (world.getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ())) .getBlock() == Blocks.DRAGON_EGG) { if (tryAddingEnergy(energyPerTick)) - lastOutput = world.getGameTime(); + lastOutput = world.getTime(); } - if (world.getGameTime() - lastOutput < 30 && !isActive()) { + if (world.getTime() - lastOutput < 30 && !isActive()) { world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, true)); - } else if (world.getGameTime() - lastOutput > 30 && isActive()) { + } else if (world.getTime() - lastOutput > 30 && isActive()) { world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, false)); } } @@ -95,12 +95,12 @@ public class TileDragonEggSyphon extends TilePowerAcceptor } @Override - public boolean canAcceptEnergy(EnumFacing direction) { + public boolean canAcceptEnergy(Direction direction) { return false; } @Override - public boolean canProvideEnergy(EnumFacing direction) { + public boolean canProvideEnergy(Direction direction) { return true; } @@ -116,7 +116,7 @@ public class TileDragonEggSyphon extends TilePowerAcceptor // IToolDrop @Override - public ItemStack getToolDrop(EntityPlayer entityPlayer) { + public ItemStack getToolDrop(PlayerEntity entityPlayer) { return TRContent.Machine.DRAGON_EGG_SYPHON.getStack(); } diff --git a/src/main/java/techreborn/tiles/generator/advanced/TileGasTurbine.java b/src/main/java/techreborn/tiles/generator/advanced/TileGasTurbine.java index f2f594612..874a22294 100644 --- a/src/main/java/techreborn/tiles/generator/advanced/TileGasTurbine.java +++ b/src/main/java/techreborn/tiles/generator/advanced/TileGasTurbine.java @@ -24,7 +24,7 @@ package techreborn.tiles.generator.advanced; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; @@ -54,7 +54,7 @@ public class TileGasTurbine extends TileBaseFluidGenerator implements IContainer } @Override - public ItemStack getToolDrop(EntityPlayer entityPlayer) { + public ItemStack getToolDrop(PlayerEntity entityPlayer) { return TRContent.Machine.GAS_TURBINE.getStack(); } @@ -69,7 +69,7 @@ public class TileGasTurbine extends TileBaseFluidGenerator implements IContainer } @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("gasturbine").player(player.inventory).inventory().hotbar() .addInventory().tile(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue() .syncIntegerValue(this::getTicksSinceLastChange, this::setTicksSinceLastChange) diff --git a/src/main/java/techreborn/tiles/generator/advanced/TileSemiFluidGenerator.java b/src/main/java/techreborn/tiles/generator/advanced/TileSemiFluidGenerator.java index 36dc4cd8c..bd5f379ba 100644 --- a/src/main/java/techreborn/tiles/generator/advanced/TileSemiFluidGenerator.java +++ b/src/main/java/techreborn/tiles/generator/advanced/TileSemiFluidGenerator.java @@ -24,7 +24,7 @@ package techreborn.tiles.generator.advanced; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; @@ -54,7 +54,7 @@ public class TileSemiFluidGenerator extends TileBaseFluidGenerator implements IC } @Override - public ItemStack getToolDrop(EntityPlayer playerIn) { + public ItemStack getToolDrop(PlayerEntity playerIn) { return TRContent.Machine.SEMI_FLUID_GENERATOR.getStack(); } @@ -69,7 +69,7 @@ public class TileSemiFluidGenerator extends TileBaseFluidGenerator implements IC } @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("semifluidgenerator").player(player.inventory).inventory().hotbar() .addInventory().tile(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue() .syncIntegerValue(this::getTicksSinceLastChange, this::setTicksSinceLastChange) diff --git a/src/main/java/techreborn/tiles/generator/advanced/TileThermalGenerator.java b/src/main/java/techreborn/tiles/generator/advanced/TileThermalGenerator.java index 8a5e818a1..b0f59c5be 100644 --- a/src/main/java/techreborn/tiles/generator/advanced/TileThermalGenerator.java +++ b/src/main/java/techreborn/tiles/generator/advanced/TileThermalGenerator.java @@ -24,7 +24,7 @@ package techreborn.tiles.generator.advanced; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; @@ -54,7 +54,7 @@ public class TileThermalGenerator extends TileBaseFluidGenerator implements ICon } @Override - public ItemStack getToolDrop(EntityPlayer entityPlayer) { + public ItemStack getToolDrop(PlayerEntity entityPlayer) { return TRContent.Machine.THERMAL_GENERATOR.getStack(); } @@ -69,7 +69,7 @@ public class TileThermalGenerator extends TileBaseFluidGenerator implements ICon } @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("thermalgenerator").player(player.inventory).inventory().hotbar() .addInventory().tile(this).slot(0, 25, 35).outputSlot(1, 25, 55).syncEnergyValue() .syncIntegerValue(this::getTicksSinceLastChange, this::setTicksSinceLastChange) diff --git a/src/main/java/techreborn/tiles/generator/basic/TileSolidFuelGenerator.java b/src/main/java/techreborn/tiles/generator/basic/TileSolidFuelGenerator.java index 451552908..e769edad3 100644 --- a/src/main/java/techreborn/tiles/generator/basic/TileSolidFuelGenerator.java +++ b/src/main/java/techreborn/tiles/generator/basic/TileSolidFuelGenerator.java @@ -24,13 +24,13 @@ package techreborn.tiles.generator.basic; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.FurnaceBlockEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntityFurnace; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.common.ForgeMod; +import net.minecraft.item.Items; +import net.minecraft.util.math.Direction; + import reborncore.api.IToolDrop; import reborncore.api.tile.ItemHandlerProvider; import reborncore.client.containerBuilder.IContainerProvider; @@ -70,13 +70,13 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr } public static int getItemBurnTime(ItemStack stack) { - return TileEntityFurnace.getBurnTimes().get(stack) / 4; + return FurnaceBlockEntity.getBurnTimes().get(stack) / 4; } @Override public void tick() { super.tick(); - if (world.isRemote) { + if (world.isClient) { return; } if (getEnergy() < getMaxPower()) { @@ -91,12 +91,12 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr if (burnTime == 0) { updateState(); - burnTime = totalBurnTime = TileSolidFuelGenerator.getItemBurnTime(inventory.getStackInSlot(fuelSlot)); + burnTime = totalBurnTime = TileSolidFuelGenerator.getItemBurnTime(inventory.getInvStack(fuelSlot)); if (burnTime > 0) { updateState(); - burnItem = inventory.getStackInSlot(fuelSlot); - if (inventory.getStackInSlot(fuelSlot).getCount() == 1) { - if (inventory.getStackInSlot(fuelSlot).getItem() == Items.LAVA_BUCKET || inventory.getStackInSlot(fuelSlot).getItem() == ForgeMod.getInstance().universalBucket) { + burnItem = inventory.getInvStack(fuelSlot); + if (inventory.getInvStack(fuelSlot).getAmount() == 1) { + if (inventory.getInvStack(fuelSlot).getItem() == Items.LAVA_BUCKET || inventory.getInvStack(fuelSlot).getItem() == ForgeMod.getInstance().universalBucket) { inventory.setStackInSlot(fuelSlot, new ItemStack(Items.BUCKET)); } else { inventory.setStackInSlot(fuelSlot, ItemStack.EMPTY); @@ -112,7 +112,7 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr } public void updateState() { - final IBlockState BlockStateContainer = world.getBlockState(pos); + final BlockState BlockStateContainer = world.getBlockState(pos); if (BlockStateContainer.getBlock() instanceof BlockMachineBase) { final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock(); if (BlockStateContainer.get(BlockMachineBase.ACTIVE) != burnTime > 0) { @@ -127,12 +127,12 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr } @Override - public boolean canAcceptEnergy(EnumFacing direction) { + public boolean canAcceptEnergy(Direction direction) { return false; } @Override - public boolean canProvideEnergy(EnumFacing direction) { + public boolean canProvideEnergy(Direction direction) { return true; } @@ -147,7 +147,7 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr } @Override - public ItemStack getToolDrop(EntityPlayer playerIn) { + public ItemStack getToolDrop(PlayerEntity playerIn) { return TRContent.Machine.SOLID_FUEL_GENERATOR.getStack(); } @@ -177,7 +177,7 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr } @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("generator").player(player.inventory).inventory().hotbar().addInventory() .tile(this).fuelSlot(0, 80, 54).energySlot(1, 8, 72).syncEnergyValue() .syncIntegerValue(this::getBurnTime, this::setBurnTime) diff --git a/src/main/java/techreborn/tiles/generator/basic/TileWaterMill.java b/src/main/java/techreborn/tiles/generator/basic/TileWaterMill.java index aa2359569..36ab2a0a6 100644 --- a/src/main/java/techreborn/tiles/generator/basic/TileWaterMill.java +++ b/src/main/java/techreborn/tiles/generator/basic/TileWaterMill.java @@ -24,10 +24,10 @@ package techreborn.tiles.generator.basic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; +import net.minecraft.block.Blocks; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.Direction; import reborncore.api.IToolDrop; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.registration.RebornRegister; @@ -60,7 +60,7 @@ public class TileWaterMill extends TilePowerAcceptor implements IToolDrop { @Override public void tick() { super.tick(); - if (world.getGameTime() % 20 == 0) { + if (world.getTime() % 20 == 0) { checkForWater(); } if (waterblocks > 0) { @@ -74,7 +74,7 @@ public class TileWaterMill extends TilePowerAcceptor implements IToolDrop { public void checkForWater() { waterblocks = 0; - for (EnumFacing facing : EnumFacing.values()) { + for (Direction facing : Direction.values()) { if (facing.getAxis().isHorizontal() && world.getBlockState(pos.offset(facing)).getBlock() == Blocks.WATER) { waterblocks++; } @@ -87,12 +87,12 @@ public class TileWaterMill extends TilePowerAcceptor implements IToolDrop { } @Override - public boolean canAcceptEnergy(EnumFacing direction) { + public boolean canAcceptEnergy(Direction direction) { return false; } @Override - public boolean canProvideEnergy(EnumFacing direction) { + public boolean canProvideEnergy(Direction direction) { return true; } @@ -107,7 +107,7 @@ public class TileWaterMill extends TilePowerAcceptor implements IToolDrop { } @Override - public ItemStack getToolDrop(EntityPlayer playerIn) { + public ItemStack getToolDrop(PlayerEntity playerIn) { return TRContent.Machine.WATER_MILL.getStack(); } } diff --git a/src/main/java/techreborn/tiles/generator/basic/TileWindMill.java b/src/main/java/techreborn/tiles/generator/basic/TileWindMill.java index dbe25cad5..5cff54543 100644 --- a/src/main/java/techreborn/tiles/generator/basic/TileWindMill.java +++ b/src/main/java/techreborn/tiles/generator/basic/TileWindMill.java @@ -24,9 +24,9 @@ package techreborn.tiles.generator.basic; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.Direction; import reborncore.api.IToolDrop; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.registration.RebornRegister; @@ -75,12 +75,12 @@ public class TileWindMill extends TilePowerAcceptor implements IToolDrop { } @Override - public boolean canAcceptEnergy(EnumFacing direction) { + public boolean canAcceptEnergy(Direction direction) { return false; } @Override - public boolean canProvideEnergy(EnumFacing direction) { + public boolean canProvideEnergy(Direction direction) { return true; } @@ -95,7 +95,7 @@ public class TileWindMill extends TilePowerAcceptor implements IToolDrop { } @Override - public ItemStack getToolDrop(EntityPlayer playerIn) { + public ItemStack getToolDrop(PlayerEntity playerIn) { return TRContent.Machine.WIND_MILL.getStack(); } } diff --git a/src/main/java/techreborn/tiles/lighting/TileLamp.java b/src/main/java/techreborn/tiles/lighting/TileLamp.java index 6f13a04d8..44d3a759a 100644 --- a/src/main/java/techreborn/tiles/lighting/TileLamp.java +++ b/src/main/java/techreborn/tiles/lighting/TileLamp.java @@ -25,10 +25,10 @@ package techreborn.tiles.lighting; import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.Direction; import reborncore.api.IToolDrop; import reborncore.common.powerSystem.TilePowerAcceptor; import techreborn.blocks.lighting.BlockLamp; @@ -47,10 +47,10 @@ public class TileLamp extends TilePowerAcceptor @Override public void tick() { super.tick(); - if (world == null || world.isRemote) { + if (world == null || world.isClient) { return; } - IBlockState state = world.getBlockState(pos); + BlockState state = world.getBlockState(pos); Block b = state.getBlock(); if (b instanceof BlockLamp) { double cost = getEuPerTick(((BlockLamp) b).getCost()); @@ -70,13 +70,13 @@ public class TileLamp extends TilePowerAcceptor } @Override - public boolean canAcceptEnergy(final EnumFacing direction) { - EnumFacing me = BlockLamp.getFacing(world.getBlockState(pos)).getOpposite(); + public boolean canAcceptEnergy(final Direction direction) { + Direction me = BlockLamp.getFacing(world.getBlockState(pos)).getOpposite(); return direction == me; } @Override - public boolean canProvideEnergy(final EnumFacing direction) { + public boolean canProvideEnergy(final Direction direction) { return false; } @@ -92,7 +92,7 @@ public class TileLamp extends TilePowerAcceptor // IToolDrop @Override - public ItemStack getToolDrop(final EntityPlayer entityPlayer) { + public ItemStack getToolDrop(final PlayerEntity entityPlayer) { return new ItemStack(world.getBlockState(pos).getBlock()); } diff --git a/src/main/java/techreborn/tiles/machine/iron/TileIronAlloyFurnace.java b/src/main/java/techreborn/tiles/machine/iron/TileIronAlloyFurnace.java index 52c41622e..b7cb09f5e 100644 --- a/src/main/java/techreborn/tiles/machine/iron/TileIronAlloyFurnace.java +++ b/src/main/java/techreborn/tiles/machine/iron/TileIronAlloyFurnace.java @@ -24,10 +24,10 @@ package techreborn.tiles.machine.iron; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.block.entity.FurnaceBlockEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntityFurnace; -import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.Direction; import reborncore.api.IToolDrop; import reborncore.api.tile.ItemHandlerProvider; import reborncore.client.containerBuilder.IContainerProvider; @@ -71,7 +71,7 @@ public class TileIronAlloyFurnace extends TileMachineBase if (stack.isEmpty()) { return 0; } else { - return TileEntityFurnace.getBurnTimes().getOrDefault(stack.getItem(), 0); + return FurnaceBlockEntity.getBurnTimes().getOrDefault(stack.getItem(), 0); } } @@ -83,13 +83,13 @@ public class TileIronAlloyFurnace extends TileMachineBase if (this.burnTime > 0) { --this.burnTime; } - if (!this.world.isRemote) { - if (this.burnTime != 0 || !inventory.getStackInSlot(this.input1).isEmpty()&& !inventory.getStackInSlot(this.fuel).isEmpty()) { + if (!this.world.isClient) { + if (this.burnTime != 0 || !inventory.getInvStack(this.input1).isEmpty()&& !inventory.getInvStack(this.fuel).isEmpty()) { if (this.burnTime == 0 && this.canSmelt()) { - this.currentItemBurnTime = this.burnTime = TileIronAlloyFurnace.getItemBurnTime(inventory.getStackInSlot(this.fuel)); + this.currentItemBurnTime = this.burnTime = TileIronAlloyFurnace.getItemBurnTime(inventory.getInvStack(this.fuel)); if (this.burnTime > 0) { flag1 = true; - if (!inventory.getStackInSlot(this.fuel).isEmpty()) { + if (!inventory.getInvStack(this.fuel).isEmpty()) { inventory.shrinkSlot(this.fuel, 1); } } @@ -122,7 +122,7 @@ public class TileIronAlloyFurnace extends TileMachineBase for (RebornIngredient ingredient : recipeType.getRebornIngredients()) { boolean hasItem = false; for (int inputslot = 0; inputslot < 2; inputslot++) { - if (ingredient.test(inventory.getStackInSlot(inputslot))) { + if (ingredient.test(inventory.getInvStack(inputslot))) { hasItem = true; } } @@ -133,7 +133,7 @@ public class TileIronAlloyFurnace extends TileMachineBase } private boolean canSmelt() { - if (inventory.getStackInSlot(this.input1).isEmpty() || inventory.getStackInSlot(this.input2).isEmpty()) { + if (inventory.getInvStack(this.input1).isEmpty() || inventory.getInvStack(this.input2).isEmpty()) { return false; } else { ItemStack itemstack = null; @@ -146,12 +146,12 @@ public class TileIronAlloyFurnace extends TileMachineBase if (itemstack == null) return false; - if (inventory.getStackInSlot(this.output).isEmpty()) + if (inventory.getInvStack(this.output).isEmpty()) return true; - if (!inventory.getStackInSlot(this.output).isItemEqual(itemstack)) + if (!inventory.getInvStack(this.output).isEqualIgnoreTags(itemstack)) return false; - final int result = inventory.getStackInSlot(this.output).getCount() + itemstack.getCount(); - return result <= inventory.getStackLimit() && result <= inventory.getStackInSlot(this.output).getMaxStackSize(); // Forge + final int result = inventory.getInvStack(this.output).getAmount() + itemstack.getAmount(); + return result <= inventory.getStackLimit() && result <= inventory.getInvStack(this.output).getMaxAmount(); // Forge // BugFix: // Make // it @@ -179,10 +179,10 @@ public class TileIronAlloyFurnace extends TileMachineBase } } - if (inventory.getStackInSlot(this.output).isEmpty()) { + if (inventory.getInvStack(this.output).isEmpty()) { inventory.setStackInSlot(this.output, itemstack.copy()); - } else if (inventory.getStackInSlot(this.output).getItem() == itemstack.getItem()) { - inventory.shrinkSlot(this.output, -itemstack.getCount()); + } else if (inventory.getInvStack(this.output).getItem() == itemstack.getItem()) { + inventory.shrinkSlot(this.output, -itemstack.getAmount()); } for (final Recipe recipeType : ModRecipes.ALLOY_SMELTER.getRecipes(world)) { @@ -195,7 +195,7 @@ public class TileIronAlloyFurnace extends TileMachineBase if (hasAllRecipes) { for (RebornIngredient ingredient : recipeType.getRebornIngredients()) { for (int inputSlot = 0; inputSlot < 2; inputSlot++) { - if (ingredient.test(this.inventory.getStackInSlot(inputSlot))) { + if (ingredient.test(this.inventory.getInvStack(inputSlot))) { inventory.shrinkSlot(inputSlot, ingredient.getSize()); break; } @@ -228,12 +228,12 @@ public class TileIronAlloyFurnace extends TileMachineBase } @Override - public EnumFacing getFacing() { + public Direction getFacing() { return this.getFacingEnum(); } @Override - public ItemStack getToolDrop(final EntityPlayer entityPlayer) { + public ItemStack getToolDrop(final PlayerEntity entityPlayer) { return TRContent.Machine.IRON_ALLOY_FURNACE.getStack(); } @@ -272,7 +272,7 @@ public class TileIronAlloyFurnace extends TileMachineBase } @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("alloyfurnace").player(player.inventory).inventory(8, 84).hotbar(8, 142) .addInventory().tile(this) .filterSlot(0, 47, 17, diff --git a/src/main/java/techreborn/tiles/machine/iron/TileIronFurnace.java b/src/main/java/techreborn/tiles/machine/iron/TileIronFurnace.java index 834eb13e6..d759a1376 100644 --- a/src/main/java/techreborn/tiles/machine/iron/TileIronFurnace.java +++ b/src/main/java/techreborn/tiles/machine/iron/TileIronFurnace.java @@ -24,11 +24,11 @@ package techreborn.tiles.machine.iron; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.FurnaceBlockEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntityFurnace; -import net.minecraftforge.common.crafting.VanillaRecipeTypes; + import reborncore.api.tile.ItemHandlerProvider; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; @@ -76,7 +76,7 @@ public class TileIronFurnace extends TileMachineBase @Override public void tick() { super.tick(); - if(world.isRemote){ + if(world.isClient){ return; } final boolean burning = this.isBurning(); @@ -86,15 +86,15 @@ public class TileIronFurnace extends TileMachineBase this.updateState(); } if (this.fuel <= 0 && this.canSmelt()) { - this.fuel = this.fuelGague = (int) (TileEntityFurnace.getBurnTimes().getOrDefault(inventory.getStackInSlot(this.fuelslot).getItem(), 0) * 1.25); + this.fuel = this.fuelGague = (int) (FurnaceBlockEntity.getBurnTimes().getOrDefault(inventory.getInvStack(this.fuelslot).getItem(), 0) * 1.25); if (this.fuel > 0) { // Fuel slot - ItemStack fuelStack = inventory.getStackInSlot(this.fuelslot); - if (fuelStack.getItem().hasContainerItem(fuelStack)) { - inventory.setStackInSlot(this.fuelslot, new ItemStack(fuelStack.getItem().getContainerItem())); - } else if (fuelStack.getCount() > 1) { + ItemStack fuelStack = inventory.getInvStack(this.fuelslot); + if (fuelStack.getItem().hasRecipeRemainder(fuelStack)) { + inventory.setStackInSlot(this.fuelslot, new ItemStack(fuelStack.getItem().getRecipeRemainder())); + } else if (fuelStack.getAmount() > 1) { inventory.shrinkSlot(this.fuelslot, 1); - } else if (fuelStack.getCount() == 1) { + } else if (fuelStack.getAmount() == 1) { inventory.setStackInSlot(this.fuelslot, ItemStack.EMPTY); } updateInventory = true; @@ -120,14 +120,14 @@ public class TileIronFurnace extends TileMachineBase public void cookItems() { if (this.canSmelt()) { - final ItemStack itemstack = TRRecipeHandler.getMatchingRecipes(world, VanillaRecipeTypes.SMELTING, inventory.getStackInSlot(this.input1)); + final ItemStack itemstack = TRRecipeHandler.getMatchingRecipes(world, VanillaRecipeTypes.SMELTING, inventory.getInvStack(this.input1)); - if (inventory.getStackInSlot(this.output).isEmpty()) { + if (inventory.getInvStack(this.output).isEmpty()) { inventory.setStackInSlot(this.output, itemstack.copy()); - } else if (inventory.getStackInSlot(this.output).isItemEqual(itemstack)) { - inventory.getStackInSlot(this.output).grow(itemstack.getCount()); + } else if (inventory.getInvStack(this.output).isEqualIgnoreTags(itemstack)) { + inventory.getInvStack(this.output).addAmount(itemstack.getAmount()); } - if (inventory.getStackInSlot(this.input1).getCount() > 1) { + if (inventory.getInvStack(this.input1).getAmount() > 1) { inventory.shrinkSlot(this.input1, 1); } else { inventory.setStackInSlot(this.input1, ItemStack.EMPTY); @@ -136,17 +136,17 @@ public class TileIronFurnace extends TileMachineBase } public boolean canSmelt() { - if (inventory.getStackInSlot(this.input1).isEmpty()) + if (inventory.getInvStack(this.input1).isEmpty()) return false; - final ItemStack itemstack = TRRecipeHandler.getMatchingRecipes(world, VanillaRecipeTypes.SMELTING, inventory.getStackInSlot(this.input1)); + final ItemStack itemstack = TRRecipeHandler.getMatchingRecipes(world, VanillaRecipeTypes.SMELTING, inventory.getInvStack(this.input1)); if (itemstack.isEmpty()) return false; - if (inventory.getStackInSlot(this.output).isEmpty()) + if (inventory.getInvStack(this.output).isEmpty()) return true; - if (!inventory.getStackInSlot(this.output).isItemEqual(itemstack)) + if (!inventory.getInvStack(this.output).isEqualIgnoreTags(itemstack)) return false; - final int result = inventory.getStackInSlot(this.output).getCount() + itemstack.getCount(); - return result <= inventory.getStackLimit() && result <= itemstack.getMaxStackSize(); + final int result = inventory.getInvStack(this.output).getAmount() + itemstack.getAmount(); + return result <= inventory.getStackLimit() && result <= itemstack.getMaxAmount(); } public boolean isBurning() { @@ -162,7 +162,7 @@ public class TileIronFurnace extends TileMachineBase } public void updateState() { - final IBlockState BlockStateContainer = this.world.getBlockState(this.pos); + final BlockState BlockStateContainer = this.world.getBlockState(this.pos); if (BlockStateContainer.getBlock() instanceof BlockMachineBase) { final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock(); if (BlockStateContainer.get(BlockMachineBase.ACTIVE) != this.fuel > 0) @@ -178,10 +178,10 @@ public class TileIronFurnace extends TileMachineBase public static IInventoryAccess getInvetoryAccess(){ return (slotID, stack, face, direction, tile) -> { if(direction == IInventoryAccess.AccessDirection.INSERT){ - boolean isFuel = TileEntityFurnace.isItemFuel(stack); + boolean isFuel = FurnaceBlockEntity.isItemFuel(stack); if(isFuel){ - ItemStack fuelSlotStack = tile.inventory.getStackInSlot(tile.fuelslot); - if(fuelSlotStack.isEmpty() || ItemUtils.isItemEqual(stack, fuelSlotStack, true, true) && fuelSlotStack.getMaxStackSize() != fuelSlotStack.getCount()){ + ItemStack fuelSlotStack = tile.inventory.getInvStack(tile.fuelslot); + if(fuelSlotStack.isEmpty() || ItemUtils.isItemEqual(stack, fuelSlotStack, true, true) && fuelSlotStack.getMaxAmount() != fuelSlotStack.getAmount()){ return slotID == tile.fuelslot; } } @@ -221,7 +221,7 @@ public class TileIronFurnace extends TileMachineBase } @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("ironfurnace").player(player.inventory).inventory(8, 84).hotbar(8, 142) .addInventory().tile(this).fuelSlot(2, 56, 53).slot(0, 56, 17).outputSlot(1, 116, 35) .syncIntegerValue(this::getBurnTime, this::setBurnTime) diff --git a/src/main/java/techreborn/tiles/machine/multiblock/MultiblockChecker.java b/src/main/java/techreborn/tiles/machine/multiblock/MultiblockChecker.java index ad0e30b33..da6f775bd 100644 --- a/src/main/java/techreborn/tiles/machine/multiblock/MultiblockChecker.java +++ b/src/main/java/techreborn/tiles/machine/multiblock/MultiblockChecker.java @@ -25,7 +25,7 @@ package techreborn.tiles.machine.multiblock; import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import techreborn.init.TRContent; @@ -68,10 +68,10 @@ public class MultiblockChecker { public boolean checkAir(int offX, int offY, int offZ) { BlockPos pos = downCenter.add(offX, offY, offZ); - return world.isAirBlock(pos); + return world.isAir(pos); } - public IBlockState getBlock(int offX, int offY, int offZ) { + public BlockState getBlock(int offX, int offY, int offZ) { BlockPos pos = downCenter.add(offX, offY, offZ); return world.getBlockState(pos); } diff --git a/src/main/java/techreborn/tiles/machine/multiblock/TileDistillationTower.java b/src/main/java/techreborn/tiles/machine/multiblock/TileDistillationTower.java index b4609bd41..c4bc1e5b7 100644 --- a/src/main/java/techreborn/tiles/machine/multiblock/TileDistillationTower.java +++ b/src/main/java/techreborn/tiles/machine/multiblock/TileDistillationTower.java @@ -24,8 +24,8 @@ package techreborn.tiles.machine.multiblock; -import net.minecraft.block.material.Material; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.block.Material; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; @@ -41,21 +41,21 @@ import techreborn.init.TRTileEntities; import techreborn.tiles.TileGenericMachine; @RebornRegister(TechReborn.MOD_ID) -public class TileDistillationTower extends TileGenericMachine implements IContainerProvider { +public class TileEnvTypeillationTower extends TileGenericMachine implements IContainerProvider { - @ConfigRegistry(config = "machines", category = "distillation_tower", key = "DistillationTowerMaxInput", comment = "Distillation Tower Max Input (Value in EU)") + @ConfigRegistry(config = "machines", category = "EnvTypeillation_tower", key = "EnvTypeillationTowerMaxInput", comment = "EnvTypeillation Tower Max Input (Value in EU)") public static int maxInput = 128; - @ConfigRegistry(config = "machines", category = "distillation_tower", key = "DistillationTowerMaxEnergy", comment = "Distillation Tower Max Energy (Value in EU)") + @ConfigRegistry(config = "machines", category = "EnvTypeillation_tower", key = "EnvTypeillationTowerMaxEnergy", comment = "EnvTypeillation Tower Max Energy (Value in EU)") public static int maxEnergy = 10_000; public MultiblockChecker multiblockChecker; - public TileDistillationTower() { - super(TRTileEntities.DISTILLATION_TOWER,"DistillationTower", maxInput, maxEnergy, TRContent.Machine.DISTILLATION_TOWER.block, 6); + public TileEnvTypeillationTower() { + super(TRTileEntities.EnvTypeILLATION_TOWER,"EnvTypeillationTower", maxInput, maxEnergy, TRContent.Machine.EnvTypeILLATION_TOWER.block, 6); final int[] inputs = new int[] { 0, 1 }; final int[] outputs = new int[] { 2, 3, 4, 5 }; - this.inventory = new Inventory<>(7, "TileDistillationTower", 64, this).withConfiguredAccess(); - this.crafter = new RecipeCrafter(ModRecipes.DISTILLATION_TOWER, this, 2, 4, this.inventory, inputs, outputs); + this.inventory = new Inventory<>(7, "TileEnvTypeillationTower", 64, this).withConfiguredAccess(); + this.crafter = new RecipeCrafter(ModRecipes.EnvTypeILLATION_TOWER, this, 2, 4, this.inventory, inputs, outputs); } public boolean getMutliBlock() { @@ -81,15 +81,15 @@ public class TileDistillationTower extends TileGenericMachine implements IContai multiblockChecker = new MultiblockChecker(world, downCenter); } - if (!world.isRemote && getMutliBlock()){ + if (!world.isClient && getMutliBlock()){ super.tick(); } } // IContainerProvider @Override - public BuiltContainer createContainer(final EntityPlayer player) { - return new ContainerBuilder("distillationtower").player(player.inventory).inventory().hotbar().addInventory() + public BuiltContainer createContainer(final PlayerEntity player) { + return new ContainerBuilder("EnvTypeillationtower").player(player.inventory).inventory().hotbar().addInventory() .tile(this).slot(0, 35, 27).slot(1, 35, 47).outputSlot(2, 79, 37).outputSlot(3, 99, 37) .outputSlot(4, 119, 37).outputSlot(5, 139, 37).energySlot(6, 8, 72).syncEnergyValue().syncCrafterValue() .addInventory().create(this); diff --git a/src/main/java/techreborn/tiles/machine/multiblock/TileFluidReplicator.java b/src/main/java/techreborn/tiles/machine/multiblock/TileFluidReplicator.java index 5372d4ed1..1667597fc 100644 --- a/src/main/java/techreborn/tiles/machine/multiblock/TileFluidReplicator.java +++ b/src/main/java/techreborn/tiles/machine/multiblock/TileFluidReplicator.java @@ -24,8 +24,8 @@ package techreborn.tiles.machine.multiblock; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.nbt.CompoundTag; import net.minecraft.util.math.BlockPos; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; @@ -90,8 +90,8 @@ public class TileFluidReplicator extends TileGenericMachine implements IContaine ticksSinceLastChange++; // Check cells input slot 2 time per second - if (!world.isRemote && ticksSinceLastChange >= 10) { - if (!inventory.getStackInSlot(1).isEmpty()) { + if (!world.isClient && ticksSinceLastChange >= 10) { + if (!inventory.getInvStack(1).isEmpty()) { FluidUtils.fillContainers(tank, inventory, 1, 2, tank.getFluidType()); } ticksSinceLastChange = 0; @@ -111,14 +111,14 @@ public class TileFluidReplicator extends TileGenericMachine implements IContaine // TilePowerAcceptor @Override - public void read(final NBTTagCompound tagCompound) { - super.read(tagCompound); + public void fromTag(final CompoundTag tagCompound) { + super.fromTag(tagCompound); tank.read(tagCompound); } @Override - public NBTTagCompound write(final NBTTagCompound tagCompound) { - super.write(tagCompound); + public CompoundTag toTag(final CompoundTag tagCompound) { + super.toTag(tagCompound); tank.write(tagCompound); return tagCompound; } @@ -126,7 +126,7 @@ public class TileFluidReplicator extends TileGenericMachine implements IContaine private static IInventoryAccess getInventoryAccess(){ return (slotID, stack, face, direction, tile) -> { if(slotID == 0){ - return stack.isItemEqual(TRContent.Parts.UU_MATTER.getStack()); + return stack.isEqualIgnoreTags(TRContent.Parts.UU_MATTER.getStack()); } return true; }; @@ -141,9 +141,9 @@ public class TileFluidReplicator extends TileGenericMachine implements IContaine // IContainerProvider @Override - public BuiltContainer createContainer(EntityPlayer player) { + public BuiltContainer createContainer(PlayerEntity player) { return new ContainerBuilder("fluidreplicator").player(player.inventory).inventory().hotbar().addInventory() - .tile(this).fluidSlot(1, 124, 35).filterSlot(0, 55, 45, stack -> stack.isItemEqual(TRContent.Parts.UU_MATTER.getStack())) + .tile(this).fluidSlot(1, 124, 35).filterSlot(0, 55, 45, stack -> stack.isEqualIgnoreTags(TRContent.Parts.UU_MATTER.getStack())) .outputSlot(2, 124, 55).energySlot(3, 8, 72).syncEnergyValue().syncCrafterValue().addInventory() .create(this); } diff --git a/src/main/java/techreborn/tiles/machine/multiblock/TileImplosionCompressor.java b/src/main/java/techreborn/tiles/machine/multiblock/TileImplosionCompressor.java index 09d93dc0a..8bc08d6e1 100644 --- a/src/main/java/techreborn/tiles/machine/multiblock/TileImplosionCompressor.java +++ b/src/main/java/techreborn/tiles/machine/multiblock/TileImplosionCompressor.java @@ -24,7 +24,7 @@ package techreborn.tiles.machine.multiblock; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; @@ -74,14 +74,14 @@ public class TileImplosionCompressor extends TileGenericMachine implements ICont multiblockChecker = new MultiblockChecker(world, pos.down(3)); } - if (!world.isRemote && getMutliBlock()){ + if (!world.isClient && getMutliBlock()){ super.tick(); } } // IContainerProvider @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("implosioncompressor").player(player.inventory).inventory().hotbar().addInventory() .tile(this).slot(0, 50, 27).slot(1, 50, 47).outputSlot(2, 92, 36).outputSlot(3, 110, 36) .energySlot(4, 8, 72).syncEnergyValue().syncCrafterValue().addInventory().create(this); diff --git a/src/main/java/techreborn/tiles/machine/multiblock/TileIndustrialBlastFurnace.java b/src/main/java/techreborn/tiles/machine/multiblock/TileIndustrialBlastFurnace.java index 7eaca2dae..5064a843a 100644 --- a/src/main/java/techreborn/tiles/machine/multiblock/TileIndustrialBlastFurnace.java +++ b/src/main/java/techreborn/tiles/machine/multiblock/TileIndustrialBlastFurnace.java @@ -24,13 +24,13 @@ package techreborn.tiles.machine.multiblock; -import net.minecraft.block.material.Material; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.play.server.SPacketUpdateTileEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; +import net.minecraft.block.Material; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.client.network.packet.BlockEntityUpdateS2CPacket; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.network.ClientConnection; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.containerBuilder.builder.ContainerBuilder; @@ -74,7 +74,7 @@ public class TileIndustrialBlastFurnace extends TileGenericMachine implements IC // Bottom center of multiblock final BlockPos location = pos.offset(getFacing().getOpposite(), 2); - final TileEntity tileEntity = world.getTileEntity(location); + final BlockEntity tileEntity = world.getBlockEntity(location); if (tileEntity instanceof TileMachineCasing) { if (((TileMachineCasing) tileEntity).isConnected() @@ -90,11 +90,11 @@ public class TileIndustrialBlastFurnace extends TileGenericMachine implements IC } for (final IMultiblockPart part : casing.connectedParts) { - heat += BlockMachineCasing.getHeatFromState(part.getBlockState()); + heat += BlockMachineCasing.getHeatFromState(part.getCachedState()); } - if (world.getBlockState(location.offset(EnumFacing.UP, 1)).getBlock().getTranslationKey().equals("tile.lava") - && world.getBlockState(location.offset(EnumFacing.UP, 2)).getBlock().getTranslationKey().equals("tile.lava")) { + if (world.getBlockState(location.offset(Direction.UP, 1)).getBlock().getTranslationKey().equals("tile.lava") + && world.getBlockState(location.offset(Direction.UP, 2)).getBlock().getTranslationKey().equals("tile.lava")) { heat += 500; } return heat; @@ -142,14 +142,14 @@ public class TileIndustrialBlastFurnace extends TileGenericMachine implements IC // TileMachineBase @Override - public void onDataPacket(final NetworkManager net, final SPacketUpdateTileEntity packet) { + public void onDataPacket(final ClientConnection net, final BlockEntityUpdateS2CPacket packet) { world.markBlockRangeForRenderUpdate(pos.getX(), pos.getY(), pos.getZ(), pos.getX(), pos.getY(), pos.getZ()); - read(packet.getNbtCompound()); + fromTag(packet.getCompoundTag()); } // IContainerProvider @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("blastfurnace").player(player.inventory).inventory().hotbar().addInventory() .tile(this).slot(0, 50, 27).slot(1, 50, 47).outputSlot(2, 93, 37).outputSlot(3, 113, 37) .energySlot(4, 8, 72).syncEnergyValue().syncCrafterValue() diff --git a/src/main/java/techreborn/tiles/machine/multiblock/TileIndustrialGrinder.java b/src/main/java/techreborn/tiles/machine/multiblock/TileIndustrialGrinder.java index 9c04c3ea6..2537d6443 100644 --- a/src/main/java/techreborn/tiles/machine/multiblock/TileIndustrialGrinder.java +++ b/src/main/java/techreborn/tiles/machine/multiblock/TileIndustrialGrinder.java @@ -24,14 +24,14 @@ package techreborn.tiles.machine.multiblock; -import net.minecraft.block.BlockFlowingFluid; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.block.BlockState; +import net.minecraft.block.FluidBlock; +import net.minecraft.block.Material; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.nbt.CompoundTag; import net.minecraft.util.math.BlockPos; -import net.minecraftforge.fluids.IFluidBlock; -import net.minecraftforge.fluids.capability.CapabilityFluidHandler; + + import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.containerBuilder.builder.ContainerBuilder; @@ -80,8 +80,8 @@ public class TileIndustrialGrinder extends TileGenericMachine implements IContai final boolean down = multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, MultiblockChecker.ZERO_OFFSET); final boolean up = multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, new BlockPos(0, 2, 0)); final boolean blade = multiblockChecker.checkRingY(1, 1, MultiblockChecker.REINFORCED_CASING, new BlockPos(0, 1, 0)); - final IBlockState centerBlock = multiblockChecker.getBlock(0, 1, 0); - final boolean center = ((centerBlock.getBlock() instanceof BlockFlowingFluid + final BlockState centerBlock = multiblockChecker.getBlock(0, 1, 0); + final boolean center = ((centerBlock.getBlock() instanceof FluidBlock || centerBlock.getBlock() instanceof IFluidBlock) && centerBlock.getMaterial() == Material.WATER); return down && center && blade && up; @@ -106,15 +106,15 @@ public class TileIndustrialGrinder extends TileGenericMachine implements IContai ticksSinceLastChange++; // Check cells input slot 2 time per second - if (!world.isRemote && ticksSinceLastChange >= 10) { - if (!inventory.getStackInSlot(1).isEmpty()) { + if (!world.isClient && ticksSinceLastChange >= 10) { + if (!inventory.getInvStack(1).isEmpty()) { FluidUtils.drainContainers(tank, inventory, 1, 6); FluidUtils.fillContainers(tank, inventory, 1, 6, tank.getFluidType()); } ticksSinceLastChange = 0; } - if (!world.isRemote && getMultiBlock()) { + if (!world.isClient && getMultiBlock()) { super.tick(); } @@ -122,14 +122,14 @@ public class TileIndustrialGrinder extends TileGenericMachine implements IContai } @Override - public void read(final NBTTagCompound tagCompound) { - super.read(tagCompound); + public void fromTag(final CompoundTag tagCompound) { + super.fromTag(tagCompound); tank.read(tagCompound); } @Override - public NBTTagCompound write(final NBTTagCompound tagCompound) { - super.write(tagCompound); + public CompoundTag toTag(final CompoundTag tagCompound) { + super.toTag(tagCompound); tank.write(tagCompound); return tagCompound; } @@ -143,7 +143,7 @@ public class TileIndustrialGrinder extends TileGenericMachine implements IContai // IContainerProvider @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { // fluidSlot first to support automation and shift-click return new ContainerBuilder("industrialgrinder").player(player.inventory).inventory().hotbar().addInventory() .tile(this).fluidSlot(1, 34, 35).slot(0, 84, 43).outputSlot(2, 126, 18).outputSlot(3, 126, 36) diff --git a/src/main/java/techreborn/tiles/machine/multiblock/TileIndustrialSawmill.java b/src/main/java/techreborn/tiles/machine/multiblock/TileIndustrialSawmill.java index b9d174d74..b364273a4 100644 --- a/src/main/java/techreborn/tiles/machine/multiblock/TileIndustrialSawmill.java +++ b/src/main/java/techreborn/tiles/machine/multiblock/TileIndustrialSawmill.java @@ -24,14 +24,14 @@ package techreborn.tiles.machine.multiblock; -import net.minecraft.block.BlockFlowingFluid; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.block.BlockState; +import net.minecraft.block.FluidBlock; +import net.minecraft.block.Material; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.nbt.CompoundTag; import net.minecraft.util.math.BlockPos; -import net.minecraftforge.fluids.IFluidBlock; -import net.minecraftforge.fluids.capability.CapabilityFluidHandler; + + import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.containerBuilder.builder.ContainerBuilder; @@ -81,8 +81,8 @@ public class TileIndustrialSawmill extends TileGenericMachine implements IContai final boolean down = multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, MultiblockChecker.ZERO_OFFSET); final boolean up = multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, new BlockPos(0, 2, 0)); final boolean blade = multiblockChecker.checkRingY(1, 1, MultiblockChecker.REINFORCED_CASING, new BlockPos(0, 1, 0)); - final IBlockState centerBlock = multiblockChecker.getBlock(0, 1, 0); - final boolean center = ((centerBlock.getBlock() instanceof BlockFlowingFluid + final BlockState centerBlock = multiblockChecker.getBlock(0, 1, 0); + final boolean center = ((centerBlock.getBlock() instanceof FluidBlock || centerBlock.getBlock() instanceof IFluidBlock) && centerBlock.getMaterial() == Material.WATER); return down && center && blade && up; @@ -98,15 +98,15 @@ public class TileIndustrialSawmill extends TileGenericMachine implements IContai ticksSinceLastChange++; // Check cells input slot 2 time per second - if (!world.isRemote && ticksSinceLastChange >= 10) { - if (!inventory.getStackInSlot(1).isEmpty()) { + if (!world.isClient && ticksSinceLastChange >= 10) { + if (!inventory.getInvStack(1).isEmpty()) { FluidUtils.drainContainers(tank, inventory, 1, 5); FluidUtils.fillContainers(tank, inventory, 1, 5, tank.getFluidType()); } ticksSinceLastChange = 0; } - if (!world.isRemote && getMutliBlock()) { + if (!world.isClient && getMutliBlock()) { super.tick(); } @@ -115,14 +115,14 @@ public class TileIndustrialSawmill extends TileGenericMachine implements IContai // TilePowerAcceptor @Override - public void read(final NBTTagCompound tagCompound) { - super.read(tagCompound); + public void fromTag(final CompoundTag tagCompound) { + super.fromTag(tagCompound); tank.read(tagCompound); } @Override - public NBTTagCompound write(final NBTTagCompound tagCompound) { - super.write(tagCompound); + public CompoundTag toTag(final CompoundTag tagCompound) { + super.toTag(tagCompound); tank.write(tagCompound); return tagCompound; } @@ -146,7 +146,7 @@ public class TileIndustrialSawmill extends TileGenericMachine implements IContai // IContainerProvider @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("industrialsawmill").player(player.inventory).inventory().hotbar().addInventory() .tile(this).fluidSlot(1, 34, 35).slot(0, 84, 43).outputSlot(2, 126, 25).outputSlot(3, 126, 43) .outputSlot(4, 126, 61).outputSlot(5, 34, 55).energySlot(6, 8, 72).syncEnergyValue().syncCrafterValue() diff --git a/src/main/java/techreborn/tiles/machine/multiblock/TileVacuumFreezer.java b/src/main/java/techreborn/tiles/machine/multiblock/TileVacuumFreezer.java index 69ede4d52..406bb0c1d 100644 --- a/src/main/java/techreborn/tiles/machine/multiblock/TileVacuumFreezer.java +++ b/src/main/java/techreborn/tiles/machine/multiblock/TileVacuumFreezer.java @@ -24,7 +24,7 @@ package techreborn.tiles.machine.multiblock; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; @@ -70,7 +70,7 @@ public class TileVacuumFreezer extends TileGenericMachine implements IContainerP // TileGenericMachine @Override public void tick() { - if (!world.isRemote && getMultiBlock()) { + if (!world.isClient && getMultiBlock()) { super.tick(); } } @@ -84,7 +84,7 @@ public class TileVacuumFreezer extends TileGenericMachine implements IContainerP // IContainerProvider @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("vacuumfreezer").player(player.inventory).inventory().hotbar().addInventory() .tile(this).slot(0, 55, 45).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue() .syncCrafterValue().addInventory().create(this); diff --git a/src/main/java/techreborn/tiles/machine/tier1/TileAlloySmelter.java b/src/main/java/techreborn/tiles/machine/tier1/TileAlloySmelter.java index 791f31116..e2f43eb62 100644 --- a/src/main/java/techreborn/tiles/machine/tier1/TileAlloySmelter.java +++ b/src/main/java/techreborn/tiles/machine/tier1/TileAlloySmelter.java @@ -24,7 +24,7 @@ package techreborn.tiles.machine.tier1; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.containerBuilder.builder.ContainerBuilder; @@ -56,7 +56,7 @@ public class TileAlloySmelter extends TileGenericMachine implements IContainerPr // IContainerProvider @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("alloysmelter").player(player.inventory).inventory().hotbar() .addInventory().tile(this) .filterSlot(0, 34, 47, diff --git a/src/main/java/techreborn/tiles/machine/tier1/TileAssemblingMachine.java b/src/main/java/techreborn/tiles/machine/tier1/TileAssemblingMachine.java index 63646f03d..69409b314 100644 --- a/src/main/java/techreborn/tiles/machine/tier1/TileAssemblingMachine.java +++ b/src/main/java/techreborn/tiles/machine/tier1/TileAssemblingMachine.java @@ -24,7 +24,7 @@ package techreborn.tiles.machine.tier1; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.containerBuilder.builder.ContainerBuilder; @@ -56,7 +56,7 @@ public class TileAssemblingMachine extends TileGenericMachine implements IContai // IContainerProvider @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("assemblingmachine").player(player.inventory).inventory().hotbar() .addInventory().tile(this).slot(0, 55, 35).slot(1, 55, 55).outputSlot(2, 101, 45).energySlot(3, 8, 72) .syncEnergyValue().syncCrafterValue().addInventory().create(this); diff --git a/src/main/java/techreborn/tiles/machine/tier1/TileAutoCraftingTable.java b/src/main/java/techreborn/tiles/machine/tier1/TileAutoCraftingTable.java index 25aff0b07..76b676c7a 100644 --- a/src/main/java/techreborn/tiles/machine/tier1/TileAutoCraftingTable.java +++ b/src/main/java/techreborn/tiles/machine/tier1/TileAutoCraftingTable.java @@ -24,17 +24,17 @@ package techreborn.tiles.machine.tier1; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.container.Container; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.SoundCategory; -import net.minecraftforge.common.crafting.VanillaRecipeTypes; -import net.minecraftforge.items.IItemHandler; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.recipe.Ingredient; +import net.minecraft.recipe.Recipe; +import net.minecraft.sound.SoundCategory; +import net.minecraft.util.math.Direction; + + import org.apache.commons.lang3.tuple.Pair; import reborncore.api.IToolDrop; import reborncore.api.tile.ItemHandlerProvider; @@ -74,9 +74,9 @@ public class TileAutoCraftingTable extends TilePowerAcceptor public int maxProgress = 120; public int euTick = 10; - InventoryCrafting inventoryCrafting = null; - IRecipe lastCustomRecipe = null; - IRecipe lastRecipe = null; + CraftingInventory inventoryCrafting = null; + Recipe lastCustomRecipe = null; + Recipe lastRecipe = null; public boolean locked = true; @@ -85,15 +85,15 @@ public class TileAutoCraftingTable extends TilePowerAcceptor } @Nullable - public IRecipe getIRecipe() { - InventoryCrafting crafting = getCraftingInventory(); - if (!crafting.isEmpty()) { + public Recipe getIRecipe() { + CraftingInventory crafting = getCraftingInventory(); + if (!crafting.isInvEmpty()) { if (lastRecipe != null) { if (lastRecipe.matches(crafting, world)) { return lastRecipe; } } - for (IRecipe testRecipe : TRRecipeHandler.getRecipes(world, VanillaRecipeTypes.CRAFTING)) { + for (Recipe testRecipe : TRRecipeHandler.getRecipes(world, VanillaRecipeTypes.CRAFTING)) { if (testRecipe.matches(crafting, world)) { lastRecipe = testRecipe; return testRecipe; @@ -103,41 +103,41 @@ public class TileAutoCraftingTable extends TilePowerAcceptor return null; } - public InventoryCrafting getCraftingInventory() { + public CraftingInventory getCraftingInventory() { if (inventoryCrafting == null) { - inventoryCrafting = new InventoryCrafting(new Container() { + inventoryCrafting = new CraftingInventory(new Container() { @Override - public boolean canInteractWith(EntityPlayer playerIn) { + public boolean canUse(PlayerEntity playerIn) { return false; } }, 3, 3); } for (int i = 0; i < 9; i++) { - inventoryCrafting.setInventorySlotContents(i, inventory.getStackInSlot(i)); + inventoryCrafting.setInvStack(i, inventory.getInvStack(i)); } return inventoryCrafting; } - public boolean canMake(IRecipe recipe) { - if (recipe != null && recipe.canFit(3, 3)) { + public boolean canMake(Recipe recipe) { + if (recipe != null && recipe.fits(3, 3)) { boolean missingOutput = false; int[] stacksInSlots = new int[9]; for (int i = 0; i < 9; i++) { - stacksInSlots[i] = inventory.getStackInSlot(i).getCount(); + stacksInSlots[i] = inventory.getInvStack(i).getAmount(); } - for (Ingredient ingredient : recipe.getIngredients()) { + for (Ingredient ingredient : recipe.getPreviewInputs()) { if (ingredient != Ingredient.EMPTY) { boolean foundIngredient = false; for (int i = 0; i < 9; i++) { - ItemStack stack = inventory.getStackInSlot(i); + ItemStack stack = inventory.getInvStack(i); int requiredSize = locked ? 1 : 0; - if (stack.getMaxStackSize() == 1) { + if (stack.getMaxAmount() == 1) { requiredSize = 0; } if (stacksInSlots[i] > requiredSize) { - if (ingredient.test(stack)) { - if (stack.getItem().getContainerItem() != null) { - if (!hasRoomForExtraItem(stack.getItem().getContainerItem(stack))) { + if (ingredient.method_8093(stack)) { + if (stack.getItem().getRecipeRemainder() != null) { + if (!hasRoomForExtraItem(stack.getItem().getRecipeRemainder(stack))) { continue; } } @@ -153,7 +153,7 @@ public class TileAutoCraftingTable extends TilePowerAcceptor } } if (!missingOutput) { - if (hasOutputSpace(recipe.getRecipeOutput(), 9)) { + if (hasOutputSpace(recipe.getOutput(), 9)) { return true; } } @@ -163,7 +163,7 @@ public class TileAutoCraftingTable extends TilePowerAcceptor } boolean hasRoomForExtraItem(ItemStack stack) { - ItemStack extraOutputSlot = inventory.getStackInSlot(10); + ItemStack extraOutputSlot = inventory.getInvStack(10); if (extraOutputSlot.isEmpty()) { return true; } @@ -171,35 +171,35 @@ public class TileAutoCraftingTable extends TilePowerAcceptor } public boolean hasOutputSpace(ItemStack output, int slot) { - ItemStack stack = inventory.getStackInSlot(slot); + ItemStack stack = inventory.getInvStack(slot); if (stack.isEmpty()) { return true; } if (ItemUtils.isItemEqual(stack, output, true, true)) { - if (stack.getMaxStackSize() > stack.getCount() + output.getCount()) { + if (stack.getMaxAmount() > stack.getAmount() + output.getAmount()) { return true; } } return false; } - public boolean make(IRecipe recipe) { + public boolean make(Recipe recipe) { if (recipe == null || !canMake(recipe)) { return false; } - for (int i = 0; i < recipe.getIngredients().size(); i++) { - Ingredient ingredient = recipe.getIngredients().get(i); + for (int i = 0; i < recipe.getPreviewInputs().size(); i++) { + Ingredient ingredient = recipe.getPreviewInputs().get(i); // Looks for the best slot to take it from - ItemStack bestSlot = inventory.getStackInSlot(i); - if (ingredient.test(bestSlot)) { + ItemStack bestSlot = inventory.getInvStack(i); + if (ingredient.method_8093(bestSlot)) { handleContainerItem(bestSlot); - bestSlot.shrink(1); + bestSlot.subtractAmount(1); } else { for (int j = 0; j < 9; j++) { - ItemStack stack = inventory.getStackInSlot(j); - if (ingredient.test(stack)) { + ItemStack stack = inventory.getInvStack(j); + if (ingredient.method_8093(stack)) { handleContainerItem(stack); - stack.shrink(1); // TODO is this right? or do I need + stack.subtractAmount(1); // TODO is this right? or do I need // to use it as an actull // crafting grid break; @@ -207,28 +207,28 @@ public class TileAutoCraftingTable extends TilePowerAcceptor } } } - ItemStack output = inventory.getStackInSlot(9); + ItemStack output = inventory.getInvStack(9); // TODO fire forge recipe event - ItemStack ouputStack = recipe.getCraftingResult(getCraftingInventory()); + ItemStack ouputStack = recipe.craft(getCraftingInventory()); if (output.isEmpty()) { inventory.setStackInSlot(9, ouputStack.copy()); } else { // TODO use ouputStack in someway? - output.grow(recipe.getRecipeOutput().getCount()); + output.addAmount(recipe.getOutput().getAmount()); } return true; } private void handleContainerItem(ItemStack stack) { - if (stack.getItem().hasContainerItem(stack)) { - ItemStack containerItem = stack.getItem().getContainerItem(stack); - ItemStack extraOutputSlot = inventory.getStackInSlot(10); + if (stack.getItem().hasRecipeRemainder(stack)) { + ItemStack containerItem = stack.getItem().getRecipeRemainder(stack); + ItemStack extraOutputSlot = inventory.getInvStack(10); if (hasOutputSpace(containerItem, 10)) { if (extraOutputSlot.isEmpty()) { inventory.setStackInSlot(10, containerItem.copy()); } else if (ItemUtils.isItemEqual(extraOutputSlot, containerItem, true, true) - && extraOutputSlot.getMaxStackSize() < extraOutputSlot.getCount() + containerItem.getCount()) { - extraOutputSlot.grow(1); + && extraOutputSlot.getMaxAmount() < extraOutputSlot.getAmount() + containerItem.getAmount()) { + extraOutputSlot.addAmount(1); } } } @@ -236,15 +236,15 @@ public class TileAutoCraftingTable extends TilePowerAcceptor public boolean hasIngredient(Ingredient ingredient) { for (int i = 0; i < 9; i++) { - ItemStack stack = inventory.getStackInSlot(i); - if (ingredient.test(stack)) { + ItemStack stack = inventory.getInvStack(i); + if (ingredient.method_8093(stack)) { return true; } } return false; } - public boolean isItemValidForRecipeSlot(IRecipe recipe, ItemStack stack, int slotID) { + public boolean isItemValidForRecipeSlot(Recipe recipe, ItemStack stack, int slotID) { if (recipe == null) { return true; } @@ -255,19 +255,19 @@ public class TileAutoCraftingTable extends TilePowerAcceptor return true; } - public int findBestSlotForStack(IRecipe recipe, ItemStack stack) { + public int findBestSlotForStack(Recipe recipe, ItemStack stack) { if (recipe == null) { return -1; } List possibleSlots = new ArrayList<>(); - for (int i = 0; i < recipe.getIngredients().size(); i++) { - ItemStack stackInSlot = inventory.getStackInSlot(i); - Ingredient ingredient = recipe.getIngredients().get(i); - if (ingredient != Ingredient.EMPTY && ingredient.test(stack)) { + for (int i = 0; i < recipe.getPreviewInputs().size(); i++) { + ItemStack stackInSlot = inventory.getInvStack(i); + Ingredient ingredient = recipe.getPreviewInputs().get(i); + if (ingredient != Ingredient.EMPTY && ingredient.method_8093(stack)) { if (stackInSlot.isEmpty()) { possibleSlots.add(i); } else if (stackInSlot.getItem() == stack.getItem()) { - if (stackInSlot.getMaxStackSize() >= stackInSlot.getCount() + stack.getCount()) { + if (stackInSlot.getMaxAmount() >= stackInSlot.getAmount() + stack.getAmount()) { possibleSlots.add(i); } } @@ -276,14 +276,14 @@ public class TileAutoCraftingTable extends TilePowerAcceptor // Slot, count Pair smallestCount = null; for (Integer slot : possibleSlots) { - ItemStack slotStack = inventory.getStackInSlot(slot); + ItemStack slotStack = inventory.getInvStack(slot); if (slotStack.isEmpty()) { return slot; } if (smallestCount == null) { - smallestCount = Pair.of(slot, slotStack.getCount()); - } else if (smallestCount.getRight() >= slotStack.getCount()) { - smallestCount = Pair.of(slot, slotStack.getCount()); + smallestCount = Pair.of(slot, slotStack.getAmount()); + } else if (smallestCount.getRight() >= slotStack.getAmount()) { + smallestCount = Pair.of(slot, slotStack.getAmount()); } } if (smallestCount != null) { @@ -315,10 +315,10 @@ public class TileAutoCraftingTable extends TilePowerAcceptor @Override public void tick() { super.tick(); - if (world.isRemote) { + if (world.isClient) { return; } - IRecipe recipe = getIRecipe(); + Recipe recipe = getIRecipe(); if (recipe != null) { if (progress >= maxProgress) { if (make(recipe)) { @@ -369,27 +369,27 @@ public class TileAutoCraftingTable extends TilePowerAcceptor } @Override - public boolean canAcceptEnergy(EnumFacing enumFacing) { + public boolean canAcceptEnergy(Direction enumFacing) { return true; } @Override - public boolean canProvideEnergy(EnumFacing enumFacing) { + public boolean canProvideEnergy(Direction enumFacing) { return false; } @Override - public NBTTagCompound write(NBTTagCompound tag) { + public CompoundTag toTag(CompoundTag tag) { tag.putBoolean("locked", locked); - return super.write(tag); + return super.toTag(tag); } @Override - public void read(NBTTagCompound tag) { - if (tag.contains("locked")) { + public void fromTag(CompoundTag tag) { + if (tag.containsKey("locked")) { locked = tag.getBoolean("locked"); } - super.read(tag); + super.fromTag(tag); } // TileMachineBase @@ -419,13 +419,13 @@ public class TileAutoCraftingTable extends TilePowerAcceptor // This machine doesnt have a facing @Override - public EnumFacing getFacingEnum() { - return EnumFacing.NORTH; + public Direction getFacingEnum() { + return Direction.NORTH; } // IToolDrop @Override - public ItemStack getToolDrop(EntityPlayer playerIn) { + public ItemStack getToolDrop(PlayerEntity playerIn) { return TRContent.Machine.AUTO_CRAFTING_TABLE.getStack(); } @@ -437,7 +437,7 @@ public class TileAutoCraftingTable extends TilePowerAcceptor // IContainerProvider @Override - public BuiltContainer createContainer(EntityPlayer player) { + public BuiltContainer createContainer(PlayerEntity player) { return new ContainerBuilder("autocraftingtable").player(player.inventory).inventory().hotbar().addInventory() .tile(this).slot(0, 28, 25).slot(1, 46, 25).slot(2, 64, 25).slot(3, 28, 43).slot(4, 46, 43) .slot(5, 64, 43).slot(6, 28, 61).slot(7, 46, 61).slot(8, 64, 61).outputSlot(9, 145, 42) diff --git a/src/main/java/techreborn/tiles/machine/tier1/TileChemicalReactor.java b/src/main/java/techreborn/tiles/machine/tier1/TileChemicalReactor.java index 8d2b33e63..8012aa9b9 100644 --- a/src/main/java/techreborn/tiles/machine/tier1/TileChemicalReactor.java +++ b/src/main/java/techreborn/tiles/machine/tier1/TileChemicalReactor.java @@ -24,7 +24,7 @@ package techreborn.tiles.machine.tier1; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.containerBuilder.builder.ContainerBuilder; @@ -56,7 +56,7 @@ public class TileChemicalReactor extends TileGenericMachine implements IContaine // IContainerProvider @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("chemicalreactor").player(player.inventory).inventory().hotbar() .addInventory().tile(this).slot(0, 34, 47).slot(1, 126, 47).outputSlot(2, 80, 47).energySlot(3, 8, 72) .syncEnergyValue().syncCrafterValue().addInventory().create(this); diff --git a/src/main/java/techreborn/tiles/machine/tier1/TileCompressor.java b/src/main/java/techreborn/tiles/machine/tier1/TileCompressor.java index c7ff5e50c..bec0f13c4 100644 --- a/src/main/java/techreborn/tiles/machine/tier1/TileCompressor.java +++ b/src/main/java/techreborn/tiles/machine/tier1/TileCompressor.java @@ -24,7 +24,7 @@ package techreborn.tiles.machine.tier1; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.containerBuilder.builder.ContainerBuilder; @@ -56,7 +56,7 @@ public class TileCompressor extends TileGenericMachine implements IContainerProv // IContainerProvider @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("compressor").player(player.inventory).inventory().hotbar().addInventory() .tile(this).slot(0, 55, 45).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue() .syncCrafterValue().addInventory().create(this); diff --git a/src/main/java/techreborn/tiles/machine/tier1/TileElectricFurnace.java b/src/main/java/techreborn/tiles/machine/tier1/TileElectricFurnace.java index 703314a94..757e82f2a 100644 --- a/src/main/java/techreborn/tiles/machine/tier1/TileElectricFurnace.java +++ b/src/main/java/techreborn/tiles/machine/tier1/TileElectricFurnace.java @@ -24,11 +24,11 @@ package techreborn.tiles.machine.tier1; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.common.crafting.VanillaRecipeTypes; +import net.minecraft.util.math.Direction; + import reborncore.api.IToolDrop; import reborncore.api.tile.ItemHandlerProvider; import reborncore.client.containerBuilder.IContainerProvider; @@ -71,14 +71,14 @@ public class TileElectricFurnace extends TilePowerAcceptor public void cookItems() { if (canSmelt()) { - final ItemStack itemstack = TRRecipeHandler.getMatchingRecipes(world, VanillaRecipeTypes.SMELTING, inventory.getStackInSlot(input1)); + final ItemStack itemstack = TRRecipeHandler.getMatchingRecipes(world, VanillaRecipeTypes.SMELTING, inventory.getInvStack(input1)); - if (inventory.getStackInSlot(output).isEmpty()) { + if (inventory.getInvStack(output).isEmpty()) { inventory.setStackInSlot(output, itemstack.copy()); - } else if (inventory.getStackInSlot(output).isItemEqual(itemstack)) { - inventory.getStackInSlot(output).grow(itemstack.getCount()); + } else if (inventory.getInvStack(output).isEqualIgnoreTags(itemstack)) { + inventory.getInvStack(output).addAmount(itemstack.getAmount()); } - if (inventory.getStackInSlot(input1).getCount() > 1) { + if (inventory.getInvStack(input1).getAmount() > 1) { inventory.shrinkSlot(input1, 1); } else { inventory.setStackInSlot(input1, ItemStack.EMPTY); @@ -87,21 +87,21 @@ public class TileElectricFurnace extends TilePowerAcceptor } public boolean canSmelt() { - if (inventory.getStackInSlot(input1).isEmpty()) { + if (inventory.getInvStack(input1).isEmpty()) { return false; } - final ItemStack itemstack = TRRecipeHandler.getMatchingRecipes(world, VanillaRecipeTypes.SMELTING, inventory.getStackInSlot(input1)); + final ItemStack itemstack = TRRecipeHandler.getMatchingRecipes(world, VanillaRecipeTypes.SMELTING, inventory.getInvStack(input1)); if (itemstack.isEmpty()) { return false; } - if (inventory.getStackInSlot(output).isEmpty()) { + if (inventory.getInvStack(output).isEmpty()) { return true; } - if (!inventory.getStackInSlot(output).isItemEqual(itemstack)) { + if (!inventory.getInvStack(output).isEqualIgnoreTags(itemstack)) { return false; } - final int result = inventory.getStackInSlot(output).getCount() + itemstack.getCount(); - return result <= this.inventory.getStackLimit() && result <= itemstack.getMaxStackSize(); + final int result = inventory.getInvStack(output).getAmount() + itemstack.getAmount(); + return result <= this.inventory.getStackLimit() && result <= itemstack.getMaxAmount(); } public boolean isBurning() { @@ -124,7 +124,7 @@ public class TileElectricFurnace extends TilePowerAcceptor wasBurning = true; return; } - final IBlockState BlockStateContainer = world.getBlockState(pos); + final BlockState BlockStateContainer = world.getBlockState(pos); if (BlockStateContainer.getBlock() instanceof BlockMachineBase) { final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock(); if (BlockStateContainer.get(BlockMachineBase.ACTIVE) != progress > 0) @@ -146,7 +146,7 @@ public class TileElectricFurnace extends TilePowerAcceptor // TilePowerAcceptor @Override public void tick() { - if (world.isRemote) { + if (world.isClient) { return; } @@ -183,12 +183,12 @@ public class TileElectricFurnace extends TilePowerAcceptor } @Override - public boolean canAcceptEnergy(final EnumFacing direction) { + public boolean canAcceptEnergy(final Direction direction) { return true; } @Override - public boolean canProvideEnergy(final EnumFacing direction) { + public boolean canProvideEnergy(final Direction direction) { return false; } @@ -204,7 +204,7 @@ public class TileElectricFurnace extends TilePowerAcceptor // IToolDrop @Override - public ItemStack getToolDrop(final EntityPlayer entityPlayer) { + public ItemStack getToolDrop(final PlayerEntity entityPlayer) { return TRContent.Machine.ELECTRIC_FURNACE.getStack(); } @@ -216,7 +216,7 @@ public class TileElectricFurnace extends TilePowerAcceptor // IContainerProvider @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("electricfurnace").player(player.inventory).inventory().hotbar().addInventory() .tile(this).slot(0, 55, 45).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue() .syncIntegerValue(this::getBurnTime, this::setBurnTime).addInventory().create(this); diff --git a/src/main/java/techreborn/tiles/machine/tier1/TileExtractor.java b/src/main/java/techreborn/tiles/machine/tier1/TileExtractor.java index e13d6c814..d2e8206ea 100644 --- a/src/main/java/techreborn/tiles/machine/tier1/TileExtractor.java +++ b/src/main/java/techreborn/tiles/machine/tier1/TileExtractor.java @@ -24,7 +24,7 @@ package techreborn.tiles.machine.tier1; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.containerBuilder.builder.ContainerBuilder; @@ -56,7 +56,7 @@ public class TileExtractor extends TileGenericMachine implements IContainerProvi // IContainerProvider @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("extractor").player(player.inventory).inventory().hotbar().addInventory().tile(this) .slot(0, 55, 45).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue().syncCrafterValue() .addInventory().create(this); diff --git a/src/main/java/techreborn/tiles/machine/tier1/TileGrinder.java b/src/main/java/techreborn/tiles/machine/tier1/TileGrinder.java index 9d9df2d5f..6097828b0 100644 --- a/src/main/java/techreborn/tiles/machine/tier1/TileGrinder.java +++ b/src/main/java/techreborn/tiles/machine/tier1/TileGrinder.java @@ -24,7 +24,7 @@ package techreborn.tiles.machine.tier1; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.containerBuilder.builder.ContainerBuilder; @@ -56,7 +56,7 @@ public class TileGrinder extends TileGenericMachine implements IContainerProvide // IContainerProvider @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("grinder").player(player.inventory).inventory().hotbar().addInventory().tile(this) .slot(0, 55, 45).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue().syncCrafterValue() .addInventory().create(this); diff --git a/src/main/java/techreborn/tiles/machine/tier1/TileIndustrialElectrolyzer.java b/src/main/java/techreborn/tiles/machine/tier1/TileIndustrialElectrolyzer.java index 8aa73aa8c..d5b1101f3 100644 --- a/src/main/java/techreborn/tiles/machine/tier1/TileIndustrialElectrolyzer.java +++ b/src/main/java/techreborn/tiles/machine/tier1/TileIndustrialElectrolyzer.java @@ -24,7 +24,7 @@ package techreborn.tiles.machine.tier1; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.containerBuilder.builder.ContainerBuilder; @@ -58,7 +58,7 @@ public class TileIndustrialElectrolyzer extends TileGenericMachine implements IC // IContainerProvider @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("industrialelectrolyzer").player(player.inventory).inventory().hotbar() .addInventory().tile(this) .filterSlot(1, 47, 72, stack -> ItemUtils.isItemEqual(stack, DynamicCell.getEmptyCell(1), true, true)) diff --git a/src/main/java/techreborn/tiles/machine/tier1/TilePlayerDectector.java b/src/main/java/techreborn/tiles/machine/tier1/TilePlayerDectector.java index 47fb00276..fe2dafed0 100644 --- a/src/main/java/techreborn/tiles/machine/tier1/TilePlayerDectector.java +++ b/src/main/java/techreborn/tiles/machine/tier1/TilePlayerDectector.java @@ -24,10 +24,10 @@ package techreborn.tiles.machine.tier1; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.math.Direction; import reborncore.api.IToolDrop; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.registration.RebornRegister; @@ -65,24 +65,24 @@ public class TilePlayerDectector extends TilePowerAcceptor implements IToolDrop @Override public void tick() { super.tick(); - if (!world.isRemote && world.getGameTime() % 20 == 0) { + if (!world.isClient && world.getTime() % 20 == 0) { boolean lastRedstone = redstone; redstone = false; if (canUseEnergy(euPerTick)) { - Iterator tIterator = super.world.playerEntities.iterator(); + Iterator tIterator = super.world.playerEntities.iterator(); while (tIterator.hasNext()) { - EntityPlayer player = tIterator.next(); - if (player.getDistanceSq((double) super.getPos().getX() + 0.5D, + PlayerEntity player = tIterator.next(); + if (player.squaredEnvTypeanceTo((double) super.getPos().getX() + 0.5D, (double) super.getPos().getY() + 0.5D, (double) super.getPos().getZ() + 0.5D) <= 256.0D) { String type = world.getBlockState(pos).get(BlockPlayerDetector.TYPE); if (type.equals("all")) {// ALL redstone = true; } else if (type.equals("others")) {// Others - if (!owenerUdid.isEmpty() && !owenerUdid.equals(player.getUniqueID().toString())) { + if (!owenerUdid.isEmpty() && !owenerUdid.equals(player.getUuid().toString())) { redstone = true; } } else {// You - if (!owenerUdid.isEmpty() && owenerUdid.equals(player.getUniqueID().toString())) { + if (!owenerUdid.isEmpty() && owenerUdid.equals(player.getUuid().toString())) { redstone = true; } } @@ -92,7 +92,7 @@ public class TilePlayerDectector extends TilePowerAcceptor implements IToolDrop } if (lastRedstone != redstone) { WorldUtils.updateBlock(world, pos); - world.notifyNeighborsOfStateChange(pos, world.getBlockState(pos).getBlock()); + world.updateNeighborsAlways(pos, world.getBlockState(pos).getBlock()); } } } @@ -103,12 +103,12 @@ public class TilePlayerDectector extends TilePowerAcceptor implements IToolDrop } @Override - public boolean canAcceptEnergy(EnumFacing direction) { + public boolean canAcceptEnergy(Direction direction) { return true; } @Override - public boolean canProvideEnergy(EnumFacing direction) { + public boolean canProvideEnergy(Direction direction) { return false; } @@ -123,21 +123,21 @@ public class TilePlayerDectector extends TilePowerAcceptor implements IToolDrop } @Override - public void read(NBTTagCompound tag) { - super.read(tag); + public void fromTag(CompoundTag tag) { + super.fromTag(tag); owenerUdid = tag.getString("ownerID"); } @Override - public NBTTagCompound write(NBTTagCompound tag) { - super.write(tag); + public CompoundTag toTag(CompoundTag tag) { + super.toTag(tag); tag.putString("ownerID", owenerUdid); return tag; } // IToolDrop @Override - public ItemStack getToolDrop(EntityPlayer p0) { + public ItemStack getToolDrop(PlayerEntity p0) { return TRContent.Machine.PLAYER_DETECTOR.getStack(); } } diff --git a/src/main/java/techreborn/tiles/machine/tier1/TileRecycler.java b/src/main/java/techreborn/tiles/machine/tier1/TileRecycler.java index 98460142c..4b2157ca6 100644 --- a/src/main/java/techreborn/tiles/machine/tier1/TileRecycler.java +++ b/src/main/java/techreborn/tiles/machine/tier1/TileRecycler.java @@ -24,10 +24,10 @@ package techreborn.tiles.machine.tier1; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.Direction; import reborncore.api.IToolDrop; import reborncore.api.tile.IUpgrade; import reborncore.api.tile.ItemHandlerProvider; @@ -79,27 +79,27 @@ public class TileRecycler extends TilePowerAcceptor public void recycleItems() { ItemStack itemstack = TRContent.Parts.SCRAP.getStack(); - final int randomchance = this.world.rand.nextInt(chance); + final int randomchance = this.world.random.nextInt(chance); if (randomchance == 1) { - if (inventory.getStackInSlot(1).isEmpty()) { + if (inventory.getInvStack(1).isEmpty()) { inventory.setStackInSlot(1, itemstack.copy()); } else { - inventory.getStackInSlot(1).grow(itemstack.getCount()); + inventory.getInvStack(1).addAmount(itemstack.getAmount()); } } inventory.shrinkSlot(0, 1); } public boolean canRecycle() { - return !inventory.getStackInSlot(0) .isEmpty() && hasSlotGotSpace(1); + return !inventory.getInvStack(0) .isEmpty() && hasSlotGotSpace(1); } public boolean hasSlotGotSpace(int slot) { - if (inventory.getStackInSlot(slot).isEmpty()) { + if (inventory.getInvStack(slot).isEmpty()) { return true; - } else if (inventory.getStackInSlot(slot).getCount() < inventory.getStackInSlot(slot).getMaxStackSize()) { + } else if (inventory.getInvStack(slot).getAmount() < inventory.getInvStack(slot).getMaxAmount()) { return true; } return false; @@ -114,7 +114,7 @@ public class TileRecycler extends TilePowerAcceptor } public void updateState() { - final IBlockState BlockStateContainer = world.getBlockState(pos); + final BlockState BlockStateContainer = world.getBlockState(pos); if (BlockStateContainer.getBlock() instanceof BlockMachineBase) { final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock(); boolean shouldBurn = isBurning || (canRecycle() && canUseEnergy(getEuPerTick(cost))); @@ -128,7 +128,7 @@ public class TileRecycler extends TilePowerAcceptor @Override public void tick() { super.tick(); - if (world.isRemote) { + if (world.isClient) { return; } charge(2); @@ -163,12 +163,12 @@ public class TileRecycler extends TilePowerAcceptor } @Override - public boolean canAcceptEnergy(EnumFacing direction) { + public boolean canAcceptEnergy(Direction direction) { return true; } @Override - public boolean canProvideEnergy(EnumFacing direction) { + public boolean canProvideEnergy(Direction direction) { return false; } @@ -190,7 +190,7 @@ public class TileRecycler extends TilePowerAcceptor // IToolDrop @Override - public ItemStack getToolDrop(EntityPlayer entityPlayer) { + public ItemStack getToolDrop(PlayerEntity entityPlayer) { return TRContent.Machine.RECYCLER.getStack(); } @@ -202,7 +202,7 @@ public class TileRecycler extends TilePowerAcceptor // IContainerProvider @Override - public BuiltContainer createContainer(EntityPlayer player) { + public BuiltContainer createContainer(PlayerEntity player) { return new ContainerBuilder("recycler").player(player.inventory).inventory().hotbar().addInventory() .tile(this).slot(0, 55, 45, itemStack -> itemStack.getItem() instanceof IUpgrade).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue() .syncIntegerValue(this::getProgress, this::setProgress).addInventory().create(this); diff --git a/src/main/java/techreborn/tiles/machine/tier1/TileRollingMachine.java b/src/main/java/techreborn/tiles/machine/tier1/TileRollingMachine.java index 735f9dc9c..b8945cf19 100644 --- a/src/main/java/techreborn/tiles/machine/tier1/TileRollingMachine.java +++ b/src/main/java/techreborn/tiles/machine/tier1/TileRollingMachine.java @@ -24,14 +24,14 @@ package techreborn.tiles.machine.tier1; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.container.Container; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.recipe.Ingredient; +import net.minecraft.recipe.Recipe; +import net.minecraft.util.math.Direction; import org.apache.commons.lang3.tuple.Pair; import reborncore.api.IToolDrop; import reborncore.api.tile.ItemHandlerProvider; @@ -72,13 +72,13 @@ public class TileRollingMachine extends TilePowerAcceptor public static int maxEnergy = 10000; public int[] craftingSlots = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; - private InventoryCrafting craftCache; + private CraftingInventory craftCache; public Inventory inventory = new Inventory<>(12, "TileRollingMachine", 64, this).withConfiguredAccess(); public boolean isRunning; public int tickTime; @Nonnull public ItemStack currentRecipeOutput; - public IRecipe currentRecipe; + public Recipe currentRecipe; private int outputSlot; public boolean locked = false; public int balanceSlot = 0; @@ -94,12 +94,12 @@ public class TileRollingMachine extends TilePowerAcceptor } @Override - public boolean canAcceptEnergy(final EnumFacing direction) { + public boolean canAcceptEnergy(final Direction direction) { return true; } @Override - public boolean canProvideEnergy(final EnumFacing direction) { + public boolean canProvideEnergy(final Direction direction) { return false; } @@ -116,22 +116,22 @@ public class TileRollingMachine extends TilePowerAcceptor @Override public void tick() { super.tick(); - if (world.isRemote) { + if (world.isClient) { return; } charge(10); - InventoryCrafting craftMatrix = getCraftingMatrix(); + CraftingInventory craftMatrix = getCraftingMatrix(); currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, world); if (currentRecipe != null) { setIsActive(true); - if (world.getGameTime() % 2 == 0) { - Optional balanceResult = balanceRecipe(craftMatrix); + if (world.getTime() % 2 == 0) { + Optional balanceResult = balanceRecipe(craftMatrix); if (balanceResult.isPresent()) { craftMatrix = balanceResult.get(); } } - currentRecipeOutput = currentRecipe.getCraftingResult(craftMatrix); + currentRecipeOutput = currentRecipe.craft(craftMatrix); } else { currentRecipeOutput = ItemStack.EMPTY; } @@ -141,15 +141,15 @@ public class TileRollingMachine extends TilePowerAcceptor currentRecipeOutput = RollingMachineRecipe.instance.findMatchingRecipeOutput(craftMatrix, world); if (!currentRecipeOutput.isEmpty()) { boolean hasCrafted = false; - if (inventory.getStackInSlot(outputSlot).isEmpty()) { + if (inventory.getInvStack(outputSlot).isEmpty()) { inventory.setStackInSlot(outputSlot, currentRecipeOutput); tickTime = 0; hasCrafted = true; } else { - if (inventory.getStackInSlot(outputSlot).getCount() - + currentRecipeOutput.getCount() <= currentRecipeOutput.getMaxStackSize()) { - final ItemStack stack = inventory.getStackInSlot(outputSlot); - stack.setCount(stack.getCount() + currentRecipeOutput.getCount()); + if (inventory.getInvStack(outputSlot).getAmount() + + currentRecipeOutput.getAmount() <= currentRecipeOutput.getMaxAmount()) { + final ItemStack stack = inventory.getInvStack(outputSlot); + stack.setAmount(stack.getAmount() + currentRecipeOutput.getAmount()); inventory.setStackInSlot(outputSlot, stack); tickTime = 0; hasCrafted = true; @@ -158,7 +158,7 @@ public class TileRollingMachine extends TilePowerAcceptor } } if (hasCrafted) { - for (int i = 0; i < craftMatrix.getSizeInventory(); i++) { + for (int i = 0; i < craftMatrix.getInvSize(); i++) { inventory.shrinkSlot(i, 1); } currentRecipeOutput = ItemStack.EMPTY; @@ -195,36 +195,36 @@ public class TileRollingMachine extends TilePowerAcceptor BlockMachineBase blockMachineBase = (BlockMachineBase)this.getWorld().getBlockState(this.getPos()).getBlock(); blockMachineBase.setActive(active, this.getWorld(), this.getPos()); } - this.getWorld().notifyBlockUpdate(this.getPos(), this.getWorld().getBlockState(this.getPos()), this.getWorld().getBlockState(this.getPos()), 3); + this.getWorld().updateListeners(this.getPos(), this.getWorld().getBlockState(this.getPos()), this.getWorld().getBlockState(this.getPos()), 3); } - public Optional balanceRecipe(InventoryCrafting craftCache) { + public Optional balanceRecipe(CraftingInventory craftCache) { if (currentRecipe == null) { return Optional.empty(); } - if (world.isRemote) { + if (world.isClient) { return Optional.empty(); } if (!locked) { return Optional.empty(); } - if (craftCache.isEmpty()) { + if (craftCache.isInvEmpty()) { return Optional.empty(); } balanceSlot++; - if (balanceSlot > craftCache.getSizeInventory()) { + if (balanceSlot > craftCache.getInvSize()) { balanceSlot = 0; } //Find the best slot for each item in a recipe, and move it if needed - ItemStack sourceStack = inventory.getStackInSlot(balanceSlot); + ItemStack sourceStack = inventory.getInvStack(balanceSlot); if (sourceStack.isEmpty()) { return Optional.empty(); } List possibleSlots = new ArrayList<>(); - for (int s = 0; s < currentRecipe.getIngredients().size(); s++) { - ItemStack stackInSlot = inventory.getStackInSlot(s); - Ingredient ingredient = currentRecipe.getIngredients().get(s); - if (ingredient != Ingredient.EMPTY && ingredient.test(sourceStack)) { + for (int s = 0; s < currentRecipe.getPreviewInputs().size(); s++) { + ItemStack stackInSlot = inventory.getInvStack(s); + Ingredient ingredient = currentRecipe.getPreviewInputs().get(s); + if (ingredient != Ingredient.EMPTY && ingredient.method_8093(sourceStack)) { if (stackInSlot.isEmpty()) { possibleSlots.add(s); } else if (stackInSlot.getItem() == sourceStack.getItem()) { @@ -235,10 +235,10 @@ public class TileRollingMachine extends TilePowerAcceptor if(!possibleSlots.isEmpty()){ int totalItems = possibleSlots.stream() - .mapToInt(value -> inventory.getStackInSlot(value).getCount()).sum(); + .mapToInt(value -> inventory.getInvStack(value).getAmount()).sum(); int slots = possibleSlots.size(); - //This makes an array of ints with the best possible slot distribution + //This makes an array of ints with the best possible slot EnvTyperibution int[] split = new int[slots]; int remainder = totalItems % slots; Arrays.fill(split, totalItems / slots); @@ -251,16 +251,16 @@ public class TileRollingMachine extends TilePowerAcceptor } } - List slotDistrubution = possibleSlots.stream() - .mapToInt(value -> inventory.getStackInSlot(value).getCount()) + List slotEnvTyperubution = possibleSlots.stream() + .mapToInt(value -> inventory.getInvStack(value).getAmount()) .boxed().collect(Collectors.toList()); boolean needsBalance = false; for (int i = 0; i < split.length; i++) { int required = split[i]; - if(slotDistrubution.contains(required)){ + if(slotEnvTyperubution.contains(required)){ //We need to remove the int, not at the int, this seems to work around that - slotDistrubution.remove(new Integer(required)); + slotEnvTyperubution.remove(new Integer(required)); } else { needsBalance = true; } @@ -275,49 +275,49 @@ public class TileRollingMachine extends TilePowerAcceptor //Slot, count Pair bestSlot = null; for (Integer slot : possibleSlots) { - ItemStack slotStack = inventory.getStackInSlot(slot); + ItemStack slotStack = inventory.getInvStack(slot); if (slotStack.isEmpty()) { bestSlot = Pair.of(slot, 0); } if (bestSlot == null) { - bestSlot = Pair.of(slot, slotStack.getCount()); - } else if (bestSlot.getRight() >= slotStack.getCount()) { - bestSlot = Pair.of(slot, slotStack.getCount()); + bestSlot = Pair.of(slot, slotStack.getAmount()); + } else if (bestSlot.getRight() >= slotStack.getAmount()) { + bestSlot = Pair.of(slot, slotStack.getAmount()); } } if (bestSlot == null || bestSlot.getLeft() == balanceSlot - || bestSlot.getRight() == sourceStack.getCount() - || inventory.getStackInSlot(bestSlot.getLeft()).isEmpty() - || !ItemUtils.isItemEqual(sourceStack, inventory.getStackInSlot(bestSlot.getLeft()), true, true)) { + || bestSlot.getRight() == sourceStack.getAmount() + || inventory.getInvStack(bestSlot.getLeft()).isEmpty() + || !ItemUtils.isItemEqual(sourceStack, inventory.getInvStack(bestSlot.getLeft()), true, true)) { return Optional.empty(); } - sourceStack.shrink(1); - inventory.getStackInSlot(bestSlot.getLeft()).grow(1); + sourceStack.subtractAmount(1); + inventory.getInvStack(bestSlot.getLeft()).addAmount(1); inventory.setChanged(); return Optional.of(getCraftingMatrix()); } - private InventoryCrafting getCraftingMatrix() { + private CraftingInventory getCraftingMatrix() { if (craftCache == null) { - craftCache = new InventoryCrafting(new RollingTileContainer(), 3, 3); + craftCache = new CraftingInventory(new RollingTileContainer(), 3, 3); } if (inventory.hasChanged()) { for (int i = 0; i < 9; i++) { - craftCache.setInventorySlotContents(i, inventory.getStackInSlot(i).copy()); + craftCache.setInvStack(i, inventory.getInvStack(i).copy()); } inventory.resetChanged(); } return craftCache; } - public boolean canMake(InventoryCrafting craftMatrix) { + public boolean canMake(CraftingInventory craftMatrix) { ItemStack stack = RollingMachineRecipe.instance.findMatchingRecipeOutput(craftMatrix, this.world); if (locked) { - for (int i = 0; i < craftMatrix.getSizeInventory(); i++) { - ItemStack stack1 = craftMatrix.getStackInSlot(i); - if (!stack1.isEmpty() && stack1.getCount() < 2) { + for (int i = 0; i < craftMatrix.getInvSize(); i++) { + ItemStack stack1 = craftMatrix.getInvStack(i); + if (!stack1.isEmpty() && stack1.getAmount() < 2) { return false; } } @@ -325,7 +325,7 @@ public class TileRollingMachine extends TilePowerAcceptor if (stack.isEmpty()) { return false; } - ItemStack output = inventory.getStackInSlot(outputSlot); + ItemStack output = inventory.getInvStack(outputSlot); if (output.isEmpty()) { return true; } @@ -333,21 +333,21 @@ public class TileRollingMachine extends TilePowerAcceptor } @Override - public ItemStack getToolDrop(final EntityPlayer entityPlayer) { + public ItemStack getToolDrop(final PlayerEntity entityPlayer) { return TRContent.Machine.ROLLING_MACHINE.getStack(); } @Override - public void read(final NBTTagCompound tagCompound) { - super.read(tagCompound); + public void fromTag(final CompoundTag tagCompound) { + super.fromTag(tagCompound); this.isRunning = tagCompound.getBoolean("isRunning"); this.tickTime = tagCompound.getInt("tickTime"); this.locked = tagCompound.getBoolean("locked"); } @Override - public NBTTagCompound write(final NBTTagCompound tagCompound) { - super.write(tagCompound); + public CompoundTag toTag(final CompoundTag tagCompound) { + super.toTag(tagCompound); tagCompound.putBoolean("isRunning", this.isRunning); tagCompound.putInt("tickTime", this.tickTime); tagCompound.putBoolean("locked", locked); @@ -375,7 +375,7 @@ public class TileRollingMachine extends TilePowerAcceptor } @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("rollingmachine").player(player.inventory) .inventory().hotbar() .addInventory().tile(this) @@ -407,7 +407,7 @@ public class TileRollingMachine extends TilePowerAcceptor private static class RollingTileContainer extends Container { @Override - public boolean canInteractWith(final EntityPlayer entityplayer) { + public boolean canUse(final PlayerEntity entityplayer) { return true; } diff --git a/src/main/java/techreborn/tiles/machine/tier1/TileScrapboxinator.java b/src/main/java/techreborn/tiles/machine/tier1/TileScrapboxinator.java index 32823ca42..23178a241 100644 --- a/src/main/java/techreborn/tiles/machine/tier1/TileScrapboxinator.java +++ b/src/main/java/techreborn/tiles/machine/tier1/TileScrapboxinator.java @@ -24,7 +24,7 @@ package techreborn.tiles.machine.tier1; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.containerBuilder.builder.ContainerBuilder; @@ -61,7 +61,7 @@ public class TileScrapboxinator extends TileGenericMachine implements IContainer // IContainerProvider @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("scrapboxinator").player(player.inventory).inventory().hotbar().addInventory() .tile(this).filterSlot(0, 55, 45, stack -> stack.getItem() == TRContent.SCRAP_BOX).outputSlot(1, 101, 45) .energySlot(2, 8, 72).syncEnergyValue().syncCrafterValue().addInventory().create(this); diff --git a/src/main/java/techreborn/tiles/machine/tier3/TileChunkLoader.java b/src/main/java/techreborn/tiles/machine/tier3/TileChunkLoader.java index a8e08ce80..4816a9f24 100644 --- a/src/main/java/techreborn/tiles/machine/tier3/TileChunkLoader.java +++ b/src/main/java/techreborn/tiles/machine/tier3/TileChunkLoader.java @@ -24,9 +24,9 @@ package techreborn.tiles.machine.tier3; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.Direction; import reborncore.api.IToolDrop; import reborncore.api.tile.ItemHandlerProvider; import reborncore.client.containerBuilder.IContainerProvider; @@ -60,7 +60,7 @@ public class TileChunkLoader extends TilePowerAcceptor implements IToolDrop, Ite } @Override - public ItemStack getToolDrop(final EntityPlayer entityPlayer) { + public ItemStack getToolDrop(final PlayerEntity entityPlayer) { return TRContent.Machine.CHUNK_LOADER.getStack(); } @@ -74,12 +74,12 @@ public class TileChunkLoader extends TilePowerAcceptor implements IToolDrop, Ite } @Override - public boolean canAcceptEnergy(final EnumFacing direction) { + public boolean canAcceptEnergy(final Direction direction) { return true; } @Override - public boolean canProvideEnergy(final EnumFacing direction) { + public boolean canProvideEnergy(final Direction direction) { return false; } @@ -99,7 +99,7 @@ public class TileChunkLoader extends TilePowerAcceptor implements IToolDrop, Ite } @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("chunkloader").player(player.inventory).inventory(8,84).hotbar(8,142).addInventory() .create(this); } diff --git a/src/main/java/techreborn/tiles/machine/tier3/TileCreativeQuantumChest.java b/src/main/java/techreborn/tiles/machine/tier3/TileCreativeQuantumChest.java index c9bdab428..74b95d332 100644 --- a/src/main/java/techreborn/tiles/machine/tier3/TileCreativeQuantumChest.java +++ b/src/main/java/techreborn/tiles/machine/tier3/TileCreativeQuantumChest.java @@ -36,13 +36,13 @@ public class TileCreativeQuantumChest extends TileQuantumChest { @Override public void tick() { super.tick(); - ItemStack stack = inventory.getStackInSlot(1); + ItemStack stack = inventory.getInvStack(1); if (!stack.isEmpty() && storedItem.isEmpty()) { - stack.setCount(stack.getMaxStackSize()); + stack.setAmount(stack.getMaxAmount()); storedItem = stack.copy(); } - storedItem.setCount(maxCapacity - storedItem.getMaxStackSize()); + storedItem.setAmount(maxCapacity - storedItem.getMaxAmount()); } @Override diff --git a/src/main/java/techreborn/tiles/machine/tier3/TileMatterFabricator.java b/src/main/java/techreborn/tiles/machine/tier3/TileMatterFabricator.java index 5b5578f8a..695344a91 100644 --- a/src/main/java/techreborn/tiles/machine/tier3/TileMatterFabricator.java +++ b/src/main/java/techreborn/tiles/machine/tier3/TileMatterFabricator.java @@ -24,9 +24,9 @@ package techreborn.tiles.machine.tier3; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.Direction; import reborncore.api.IToolDrop; import reborncore.api.tile.ItemHandlerProvider; import reborncore.client.containerBuilder.IContainerProvider; @@ -71,9 +71,9 @@ public class TileMatterFabricator extends TilePowerAcceptor } private boolean spaceForOutput(int slot) { - return inventory.getStackInSlot(slot).isEmpty() - || ItemUtils.isItemEqual(inventory.getStackInSlot(slot), TRContent.Parts.UU_MATTER.getStack(), true, true) - && inventory.getStackInSlot(slot).getCount() < 64; + return inventory.getInvStack(slot).isEmpty() + || ItemUtils.isItemEqual(inventory.getInvStack(slot), TRContent.Parts.UU_MATTER.getStack(), true, true) + && inventory.getInvStack(slot).getAmount() < 64; } private void addOutputProducts() { @@ -86,11 +86,11 @@ public class TileMatterFabricator extends TilePowerAcceptor } private void addOutputProducts(int slot) { - if (inventory.getStackInSlot(slot).isEmpty()) { + if (inventory.getInvStack(slot).isEmpty()) { inventory.setStackInSlot(slot, TRContent.Parts.UU_MATTER.getStack()); } - else if (ItemUtils.isItemEqual(this.inventory.getStackInSlot(slot), TRContent.Parts.UU_MATTER.getStack(), true, true)) { - inventory.getStackInSlot(slot).setCount((Math.min(64, 1 + inventory.getStackInSlot(slot).getCount()))); + else if (ItemUtils.isItemEqual(this.inventory.getInvStack(slot), TRContent.Parts.UU_MATTER.getStack(), true, true)) { + inventory.getInvStack(slot).setAmount((Math.min(64, 1 + inventory.getInvStack(slot).getAmount()))); } } @@ -109,7 +109,7 @@ public class TileMatterFabricator extends TilePowerAcceptor } public int getValue(ItemStack itemStack) { - if (itemStack.isItemEqual(TRContent.Parts.SCRAP.getStack())) { + if (itemStack.isEqualIgnoreTags(TRContent.Parts.SCRAP.getStack())) { return 200; } else if (itemStack.getItem() == TRContent.SCRAP_BOX) { return 2000; @@ -135,7 +135,7 @@ public class TileMatterFabricator extends TilePowerAcceptor // TilePowerAcceptor @Override public void tick() { - if (world.isRemote) { + if (world.isClient) { return; } @@ -143,7 +143,7 @@ public class TileMatterFabricator extends TilePowerAcceptor this.charge(11); for (int i = 0; i < 6; i++) { - final ItemStack stack = inventory.getStackInSlot(i); + final ItemStack stack = inventory.getInvStack(i); if (!stack.isEmpty() && spaceForOutput()) { final int amp = getValue(stack); final int euNeeded = amp * energyPerAmp; @@ -169,12 +169,12 @@ public class TileMatterFabricator extends TilePowerAcceptor } @Override - public boolean canAcceptEnergy(EnumFacing direction) { + public boolean canAcceptEnergy(Direction direction) { return true; } @Override - public boolean canProvideEnergy(EnumFacing direction) { + public boolean canProvideEnergy(Direction direction) { return false; } @@ -196,7 +196,7 @@ public class TileMatterFabricator extends TilePowerAcceptor // IToolDrop @Override - public ItemStack getToolDrop(EntityPlayer entityPlayer) { + public ItemStack getToolDrop(PlayerEntity entityPlayer) { return TRContent.Machine.MATTER_FABRICATOR.getStack(); } @@ -208,7 +208,7 @@ public class TileMatterFabricator extends TilePowerAcceptor // IContainerProvider @Override - public BuiltContainer createContainer(EntityPlayer player) { + public BuiltContainer createContainer(PlayerEntity player) { return new ContainerBuilder("matterfabricator").player(player.inventory).inventory().hotbar().addInventory() .tile(this).slot(0, 30, 20).slot(1, 50, 20).slot(2, 70, 20).slot(3, 90, 20).slot(4, 110, 20) .slot(5, 130, 20).outputSlot(6, 40, 66).outputSlot(7, 60, 66).outputSlot(8, 80, 66) diff --git a/src/main/java/techreborn/tiles/machine/tier3/TileQuantumChest.java b/src/main/java/techreborn/tiles/machine/tier3/TileQuantumChest.java index 88b594fbb..59e79d762 100644 --- a/src/main/java/techreborn/tiles/machine/tier3/TileQuantumChest.java +++ b/src/main/java/techreborn/tiles/machine/tier3/TileQuantumChest.java @@ -24,8 +24,8 @@ package techreborn.tiles.machine.tier3; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntityType; +import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.entity.player.PlayerEntity; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.containerBuilder.builder.ContainerBuilder; @@ -45,12 +45,12 @@ public class TileQuantumChest extends TileTechStorageBase implements IContainerP this(TRTileEntities.QUANTUM_CHEST); } - public TileQuantumChest(TileEntityType tileEntityType) { + public TileQuantumChest(BlockEntityType tileEntityType) { super(tileEntityType, "TileQuantumChest", maxStorage); } @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("quantumchest").player(player.inventory).inventory().hotbar().addInventory() .tile(this).slot(0, 80, 24).outputSlot(1, 80, 64).addInventory().create(this); } diff --git a/src/main/java/techreborn/tiles/machine/tier3/TileQuantumTank.java b/src/main/java/techreborn/tiles/machine/tier3/TileQuantumTank.java index 5f2466074..a1ca5d6d9 100644 --- a/src/main/java/techreborn/tiles/machine/tier3/TileQuantumTank.java +++ b/src/main/java/techreborn/tiles/machine/tier3/TileQuantumTank.java @@ -24,14 +24,14 @@ package techreborn.tiles.machine.tier3; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.client.network.packet.BlockEntityUpdateS2CPacket; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.play.server.SPacketUpdateTileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.ClientConnection; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; import reborncore.api.IListInfoProvider; import reborncore.api.IToolDrop; import reborncore.api.tile.ItemHandlerProvider; @@ -64,24 +64,24 @@ public class TileQuantumTank extends TileMachineBase this(TRTileEntities.QUANTUM_TANK); } - public TileQuantumTank(TileEntityType tileEntityTypeIn) { + public TileQuantumTank(BlockEntityType tileEntityTypeIn) { super(tileEntityTypeIn); } - public void readWithoutCoords(final NBTTagCompound tagCompound) { + public void readWithoutCoords(final CompoundTag tagCompound) { tank.read(tagCompound); } - public NBTTagCompound writeWithoutCoords(final NBTTagCompound tagCompound) { + public CompoundTag writeWithoutCoords(final CompoundTag tagCompound) { tank.write(tagCompound); return tagCompound; } public ItemStack getDropWithNBT() { - final NBTTagCompound tileEntity = new NBTTagCompound(); + final CompoundTag tileEntity = new CompoundTag(); final ItemStack dropStack = TRContent.Machine.QUANTUM_TANK.getStack(); this.writeWithoutCoords(tileEntity); - dropStack.setTag(new NBTTagCompound()); + dropStack.setTag(new CompoundTag()); dropStack.getTag().put("tileEntity", tileEntity); return dropStack; } @@ -90,7 +90,7 @@ public class TileQuantumTank extends TileMachineBase @Override public void tick() { super.tick(); - if (!world.isRemote) { + if (!world.isClient) { // TODO: Fix in 1.13 // if (FluidUtils.drainContainers(tank, inventory, 0, 1) // || FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluidType())) { @@ -107,22 +107,22 @@ public class TileQuantumTank extends TileMachineBase } @Override - public void read(final NBTTagCompound tagCompound) { - super.read(tagCompound); + public void fromTag(final CompoundTag tagCompound) { + super.fromTag(tagCompound); readWithoutCoords(tagCompound); } @Override - public NBTTagCompound write(final NBTTagCompound tagCompound) { - super.write(tagCompound); + public CompoundTag toTag(final CompoundTag tagCompound) { + super.toTag(tagCompound); writeWithoutCoords(tagCompound); return tagCompound; } @Override - public void onDataPacket(final NetworkManager net, final SPacketUpdateTileEntity packet) { + public void onDataPacket(final ClientConnection net, final BlockEntityUpdateS2CPacket packet) { world.markBlockRangeForRenderUpdate(pos.getX(), pos.getY(), pos.getZ(), pos.getX(), pos.getY(), pos.getZ()); - read(packet.getNbtCompound()); + fromTag(packet.getCompoundTag()); } // ItemHandlerProvider @@ -133,26 +133,26 @@ public class TileQuantumTank extends TileMachineBase // IToolDrop @Override - public ItemStack getToolDrop(final EntityPlayer entityPlayer) { + public ItemStack getToolDrop(final PlayerEntity entityPlayer) { return this.getDropWithNBT(); } // IListInfoProvider @Override - public void addInfo(final List info, final boolean isRealTile, boolean hasData) { + public void addInfo(final List info, final boolean isRealTile, boolean hasData) { if (isRealTile | hasData) { if (this.tank.getFluid() != null) { - info.add(new TextComponentString(this.tank.getFluidAmount() + " of " + this.tank.getFluidType().getName())); + info.add(new TextComponent(this.tank.getFluidAmount() + " of " + this.tank.getFluidType().getName())); } else { - info.add(new TextComponentString("Empty")); + info.add(new TextComponent("Empty")); } } - info.add(new TextComponentString("Capacity " + this.tank.getCapacity() + " mb")); + info.add(new TextComponent("Capacity " + this.tank.getCapacity() + " mb")); } // IContainerProvider @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("quantumtank").player(player.inventory).inventory().hotbar() .addInventory().tile(this).fluidSlot(0, 80, 17).outputSlot(1, 80, 53).addInventory() .create(this); diff --git a/src/main/java/techreborn/tiles/storage/TileAdjustableSU.java b/src/main/java/techreborn/tiles/storage/TileAdjustableSU.java index 531d5112f..557a4ff66 100644 --- a/src/main/java/techreborn/tiles/storage/TileAdjustableSU.java +++ b/src/main/java/techreborn/tiles/storage/TileAdjustableSU.java @@ -24,9 +24,9 @@ package techreborn.tiles.storage; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.CompoundTag; import reborncore.api.power.EnumPowerTier; import reborncore.api.tile.IUpgrade; import reborncore.client.containerBuilder.IContainerProvider; @@ -64,7 +64,7 @@ public class TileAdjustableSU extends TileEnergyStorage implements IContainerPro superconductors = 0; for (int i = 0; i < getUpgradeSlotCount(); i++) { - ItemStack stack = getUpgradeInvetory().getStackInSlot(i); + ItemStack stack = getUpgradeInvetory().getInvStack(i); if(false){ //TODO 1.13 superconductors++; } @@ -72,7 +72,7 @@ public class TileAdjustableSU extends TileEnergyStorage implements IContainerPro if (OUTPUT > getMaxConfigOutput()) { OUTPUT = getMaxConfigOutput(); } - if(world.getGameTime() % 20 == 0){ + if(world.getTime() % 20 == 0){ checkTier(); } } @@ -114,10 +114,10 @@ public class TileAdjustableSU extends TileEnergyStorage implements IContainerPro } public ItemStack getDropWithNBT() { - NBTTagCompound tileEntity = new NBTTagCompound(); + CompoundTag tileEntity = new CompoundTag(); ItemStack dropStack = TRContent.Machine.ADJUSTABLE_SU.getStack(); writeWithoutCoords(tileEntity); - dropStack.setTag(new NBTTagCompound()); + dropStack.setTag(new CompoundTag()); dropStack.getTag().put("tileEntity", tileEntity); return dropStack; } @@ -132,7 +132,7 @@ public class TileAdjustableSU extends TileEnergyStorage implements IContainerPro // TileEnergyStorage @Override - public ItemStack getToolDrop(EntityPlayer entityPlayer) { + public ItemStack getToolDrop(PlayerEntity entityPlayer) { return getDropWithNBT(); } @@ -162,23 +162,23 @@ public class TileAdjustableSU extends TileEnergyStorage implements IContainerPro // TilePowerAcceptor @Override - public NBTTagCompound write(NBTTagCompound tagCompound) { - super.write(tagCompound); + public CompoundTag toTag(CompoundTag tagCompound) { + super.toTag(tagCompound); tagCompound.putInt("output", OUTPUT); inventory.write(tagCompound); return tagCompound; } @Override - public void read(NBTTagCompound nbttagcompound) { - super.read(nbttagcompound); + public void fromTag(CompoundTag nbttagcompound) { + super.fromTag(nbttagcompound); this.OUTPUT = nbttagcompound.getInt("output"); inventory.read(nbttagcompound); } // IContainerProvider @Override - public BuiltContainer createContainer(EntityPlayer player) { + public BuiltContainer createContainer(PlayerEntity player) { return new ContainerBuilder("aesu").player(player.inventory).inventory().hotbar().armor() .complete(8, 18).addArmor().addInventory().tile(this).energySlot(0, 62, 45).energySlot(1, 98, 45) .syncEnergyValue().syncIntegerValue(this::getCurrentOutput, this::setCurentOutput).addInventory().create(this); diff --git a/src/main/java/techreborn/tiles/storage/TileEnergyStorage.java b/src/main/java/techreborn/tiles/storage/TileEnergyStorage.java index 96cbcfc43..b49676d71 100644 --- a/src/main/java/techreborn/tiles/storage/TileEnergyStorage.java +++ b/src/main/java/techreborn/tiles/storage/TileEnergyStorage.java @@ -25,10 +25,10 @@ package techreborn.tiles.storage; import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.Direction; import reborncore.api.IToolDrop; import reborncore.api.power.EnumPowerTier; import reborncore.api.tile.ItemHandlerProvider; @@ -51,7 +51,7 @@ public class TileEnergyStorage extends TilePowerAcceptor public int maxOutput; public int maxStorage; - public TileEnergyStorage(TileEntityType tileEntityType, String name, int invSize, Block wrenchDrop, EnumPowerTier tier, int maxInput, int maxOuput, int maxStorage) { + public TileEnergyStorage(BlockEntityType tileEntityType, String name, int invSize, Block wrenchDrop, EnumPowerTier tier, int maxInput, int maxOuput, int maxStorage) { super(tileEntityType); inventory = new Inventory<>(invSize, "Tile" + name, 64, this).withConfiguredAccess(); this.wrenchDrop = wrenchDrop; @@ -66,14 +66,14 @@ public class TileEnergyStorage extends TilePowerAcceptor @Override public void tick() { super.tick(); - if (!inventory.getStackInSlot(0).isEmpty()) { - ItemStack stack = inventory.getStackInSlot(0); + if (!inventory.getInvStack(0).isEmpty()) { + ItemStack stack = inventory.getInvStack(0); if (ExternalPowerSystems.isPoweredItem(stack)) { ExternalPowerSystems.chargeItem(this, stack); } } - if (!inventory.getStackInSlot(1).isEmpty()) { + if (!inventory.getInvStack(1).isEmpty()) { charge(1); } } @@ -84,12 +84,12 @@ public class TileEnergyStorage extends TilePowerAcceptor } @Override - public boolean canAcceptEnergy(EnumFacing direction) { + public boolean canAcceptEnergy(Direction direction) { return getFacing() != direction; } @Override - public boolean canProvideEnergy(EnumFacing direction) { + public boolean canProvideEnergy(Direction direction) { return getFacing() == direction; } @@ -110,12 +110,12 @@ public class TileEnergyStorage extends TilePowerAcceptor // TileMachineBase @Override - public void setFacing(EnumFacing enumFacing) { + public void setFacing(Direction enumFacing) { world.setBlockState(pos, world.getBlockState(pos).with(BlockEnergyStorage.FACING, enumFacing)); } @Override - public EnumFacing getFacingEnum() { + public Direction getFacingEnum() { Block block = world.getBlockState(pos).getBlock(); if (block instanceof BlockEnergyStorage) { return ((BlockEnergyStorage) block).getFacing(world.getBlockState(pos)); @@ -130,7 +130,7 @@ public class TileEnergyStorage extends TilePowerAcceptor // IToolDrop @Override - public ItemStack getToolDrop(EntityPlayer entityPlayer) { + public ItemStack getToolDrop(PlayerEntity entityPlayer) { return new ItemStack(wrenchDrop); } diff --git a/src/main/java/techreborn/tiles/storage/TileHighVoltageSU.java b/src/main/java/techreborn/tiles/storage/TileHighVoltageSU.java index 78a537430..6e5851796 100644 --- a/src/main/java/techreborn/tiles/storage/TileHighVoltageSU.java +++ b/src/main/java/techreborn/tiles/storage/TileHighVoltageSU.java @@ -24,7 +24,7 @@ package techreborn.tiles.storage; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.api.power.EnumPowerTier; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; @@ -46,7 +46,7 @@ public class TileHighVoltageSU extends TileEnergyStorage implements IContainerPr } @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("mfsu").player(player.inventory).inventory().hotbar().armor() .complete(8, 18).addArmor().addInventory().tile(this).energySlot(0, 62, 45).energySlot(1, 98, 45) .syncEnergyValue().addInventory().create(this); diff --git a/src/main/java/techreborn/tiles/storage/TileLowVoltageSU.java b/src/main/java/techreborn/tiles/storage/TileLowVoltageSU.java index b97986c9b..de25fca96 100644 --- a/src/main/java/techreborn/tiles/storage/TileLowVoltageSU.java +++ b/src/main/java/techreborn/tiles/storage/TileLowVoltageSU.java @@ -24,7 +24,7 @@ package techreborn.tiles.storage; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.api.power.EnumPowerTier; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; @@ -42,7 +42,7 @@ public class TileLowVoltageSU extends TileEnergyStorage implements IContainerPro } @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("batbox").player(player.inventory).inventory().hotbar().addInventory() .tile(this).energySlot(0, 62, 45).energySlot(1, 98, 45).syncEnergyValue().addInventory().create(this); } diff --git a/src/main/java/techreborn/tiles/storage/TileMediumVoltageSU.java b/src/main/java/techreborn/tiles/storage/TileMediumVoltageSU.java index f987224c8..13a01a49b 100644 --- a/src/main/java/techreborn/tiles/storage/TileMediumVoltageSU.java +++ b/src/main/java/techreborn/tiles/storage/TileMediumVoltageSU.java @@ -24,7 +24,7 @@ package techreborn.tiles.storage; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import reborncore.api.power.EnumPowerTier; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; @@ -46,7 +46,7 @@ public class TileMediumVoltageSU extends TileEnergyStorage implements IContainer } @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("mfe").player(player.inventory).inventory().hotbar().armor() .complete(8, 18).addArmor().addInventory().tile(this).energySlot(0, 62, 45).energySlot(1, 98, 45) .syncEnergyValue().addInventory().create(this); diff --git a/src/main/java/techreborn/tiles/storage/idsu/IDSUSaveManger.java b/src/main/java/techreborn/tiles/storage/idsu/IDSUSaveManger.java index 74fca62e0..af796d135 100644 --- a/src/main/java/techreborn/tiles/storage/idsu/IDSUSaveManger.java +++ b/src/main/java/techreborn/tiles/storage/idsu/IDSUSaveManger.java @@ -24,25 +24,25 @@ package techreborn.tiles.storage.idsu; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.storage.WorldSavedData; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.PersistentState; import techreborn.TechReborn; /** * Created by modmuss50 on 13/06/2017. */ -public class IDSUSaveManger extends WorldSavedData implements IDataIDSU { +public class IDSUSaveManger extends PersistentState implements IDataIDSU { public IDSUSaveManger(String name) { super(TechReborn.MOD_ID + "_IDSU"); } @Override - public void read(NBTTagCompound nbt) { + public void fromTag(CompoundTag nbt) { power = nbt.getDouble("power"); } @Override - public NBTTagCompound write(NBTTagCompound compound) { + public CompoundTag toTag(CompoundTag compound) { compound.putDouble("power", power); return compound; } diff --git a/src/main/java/techreborn/tiles/storage/idsu/TileInterdimensionalSU.java b/src/main/java/techreborn/tiles/storage/idsu/TileInterdimensionalSU.java index 44f9e6eaa..f99ef1180 100644 --- a/src/main/java/techreborn/tiles/storage/idsu/TileInterdimensionalSU.java +++ b/src/main/java/techreborn/tiles/storage/idsu/TileInterdimensionalSU.java @@ -24,8 +24,8 @@ package techreborn.tiles.storage.idsu; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.nbt.CompoundTag; import org.apache.commons.lang3.StringUtils; import reborncore.api.power.EnumPowerTier; import reborncore.client.containerBuilder.IContainerProvider; @@ -94,14 +94,14 @@ public class TileInterdimensionalSU extends TileEnergyStorage implements IContai } @Override - public void read(NBTTagCompound nbttagcompound) { - super.read(nbttagcompound); + public void fromTag(CompoundTag nbttagcompound) { + super.fromTag(nbttagcompound); this.ownerUdid = nbttagcompound.getString("ownerUdid"); } @Override - public NBTTagCompound write(NBTTagCompound nbttagcompound) { - super.write(nbttagcompound); + public CompoundTag toTag(CompoundTag nbttagcompound) { + super.toTag(nbttagcompound); if (ownerUdid == null && StringUtils.isBlank(ownerUdid) || StringUtils.isEmpty(ownerUdid)) { return nbttagcompound; } @@ -110,7 +110,7 @@ public class TileInterdimensionalSU extends TileEnergyStorage implements IContai } @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("idsu").player(player.inventory).inventory().hotbar().armor() .complete(8, 18).addArmor().addInventory().tile(this).energySlot(0, 62, 45).energySlot(1, 98, 45) .syncEnergyValue().addInventory().create(this); diff --git a/src/main/java/techreborn/tiles/storage/lesu/TileLSUStorage.java b/src/main/java/techreborn/tiles/storage/lesu/TileLSUStorage.java index df46ddcfc..6cbdf9fc6 100644 --- a/src/main/java/techreborn/tiles/storage/lesu/TileLSUStorage.java +++ b/src/main/java/techreborn/tiles/storage/lesu/TileLSUStorage.java @@ -24,10 +24,10 @@ package techreborn.tiles.storage.lesu; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import net.minecraft.world.World; import reborncore.api.IToolDrop; import reborncore.common.tile.TileMachineBase; @@ -46,11 +46,11 @@ public class TileLSUStorage extends TileMachineBase public final void findAndJoinNetwork(World world, int x, int y, int z) { network = new LesuNetwork(); network.addElement(this); - for (EnumFacing direction : EnumFacing.values()) { - if (world.getTileEntity(new BlockPos(x + direction.getXOffset(), y + direction.getYOffset(), - z + direction.getZOffset())) instanceof TileLSUStorage) { - TileLSUStorage lesu = (TileLSUStorage) world.getTileEntity(new BlockPos(x + direction.getXOffset(), - y + direction.getYOffset(), z + direction.getZOffset())); + for (Direction direction : Direction.values()) { + if (world.getBlockEntity(new BlockPos(x + direction.getOffsetX(), y + direction.getOffsetY(), + z + direction.getOffsetZ())) instanceof TileLSUStorage) { + TileLSUStorage lesu = (TileLSUStorage) world.getBlockEntity(new BlockPos(x + direction.getOffsetX(), + y + direction.getOffsetY(), z + direction.getOffsetZ())); if (lesu.network != null) { lesu.network.merge(network); } @@ -90,7 +90,7 @@ public class TileLSUStorage extends TileMachineBase findAndJoinNetwork(world, pos.getX(), pos.getY(), pos.getZ()); } else { if (network.master != null - && network.master.getWorld().getTileEntity(new BlockPos(network.master.getPos().getX(), + && network.master.getWorld().getBlockEntity(new BlockPos(network.master.getPos().getX(), network.master.getPos().getY(), network.master.getPos().getZ())) != network.master) { network.master = null; } @@ -99,7 +99,7 @@ public class TileLSUStorage extends TileMachineBase // IToolDrop @Override - public ItemStack getToolDrop(EntityPlayer entityPlayer) { + public ItemStack getToolDrop(PlayerEntity entityPlayer) { return TRContent.Machine.LSU_STORAGE.getStack(); } } diff --git a/src/main/java/techreborn/tiles/storage/lesu/TileLapotronicSU.java b/src/main/java/techreborn/tiles/storage/lesu/TileLapotronicSU.java index 8fda3b1c6..918b3b498 100644 --- a/src/main/java/techreborn/tiles/storage/lesu/TileLapotronicSU.java +++ b/src/main/java/techreborn/tiles/storage/lesu/TileLapotronicSU.java @@ -25,10 +25,10 @@ package techreborn.tiles.storage.lesu; import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import reborncore.api.power.EnumPowerTier; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; @@ -67,15 +67,15 @@ public class TileLapotronicSU extends TileEnergyStorage implements IContainerPro @Override public void tick() { super.tick(); - if (world.isRemote) { + if (world.isClient) { return; } countedNetworks.clear(); connectedBlocks = 0; - for (EnumFacing dir : EnumFacing.values()) { - BlockPos adjucentBlockPos = new BlockPos(pos.getX() + dir.getXOffset(), - pos.getY() + dir.getXOffset(), pos.getZ() + dir.getXOffset()); - TileEntity adjucentTile = world.getTileEntity(adjucentBlockPos); + for (Direction dir : Direction.values()) { + BlockPos adjucentBlockPos = new BlockPos(pos.getX() + dir.getOffsetX(), + pos.getY() + dir.getOffsetX(), pos.getZ() + dir.getOffsetX()); + BlockEntity adjucentTile = world.getBlockEntity(adjucentBlockPos); if (adjucentTile == null || !(adjucentTile instanceof TileLSUStorage)) { continue; } @@ -98,7 +98,7 @@ public class TileLapotronicSU extends TileEnergyStorage implements IContainerPro } @Override - public EnumFacing getFacingEnum() { + public Direction getFacingEnum() { Block block = world.getBlockState(pos).getBlock(); if (block instanceof BlockLapotronicSU) { return ((BlockLapotronicSU) block).getFacing(world.getBlockState(pos)); @@ -120,7 +120,7 @@ public class TileLapotronicSU extends TileEnergyStorage implements IContainerPro public void setConnectedBlocksNum(int value) { this.connectedBlocks = value; - if (world.isRemote) { + if (world.isClient) { setMaxStorage(); } } @@ -133,7 +133,7 @@ public class TileLapotronicSU extends TileEnergyStorage implements IContainerPro } @Override - public BuiltContainer createContainer(final EntityPlayer player) { + public BuiltContainer createContainer(final PlayerEntity player) { return new ContainerBuilder("lesu").player(player.inventory).inventory().hotbar().armor().complete(8, 18) .addArmor().addInventory().tile(this).energySlot(0, 62, 45).energySlot(1, 98, 45).syncEnergyValue() .syncIntegerValue(this::getOutputRate, this::setOutputRate) diff --git a/src/main/java/techreborn/tiles/transformers/TileTransformer.java b/src/main/java/techreborn/tiles/transformers/TileTransformer.java index c2e070914..b33b0b0bf 100644 --- a/src/main/java/techreborn/tiles/transformers/TileTransformer.java +++ b/src/main/java/techreborn/tiles/transformers/TileTransformer.java @@ -24,14 +24,14 @@ package techreborn.tiles.transformers; +import net.minecraft.ChatFormat; import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.util.math.Direction; import reborncore.api.IListInfoProvider; import reborncore.api.IToolDrop; import reborncore.api.power.EnumPowerTier; @@ -63,7 +63,7 @@ public class TileTransformer extends TilePowerAcceptor public int maxOutput; public int maxStorage; - public TileTransformer(TileEntityType tileEntityType, String name, Block wrenchDrop, EnumPowerTier tier) { + public TileTransformer(BlockEntityType tileEntityType, String name, Block wrenchDrop, EnumPowerTier tier) { super(tileEntityType); this.wrenchDrop = wrenchDrop; this.inputTier = tier; @@ -88,7 +88,7 @@ public class TileTransformer extends TilePowerAcceptor } @Override - public boolean canAcceptEnergy(EnumFacing direction) { + public boolean canAcceptEnergy(Direction direction) { if (IC2TransformersStyle == true){ return getFacingEnum() == direction; } @@ -96,7 +96,7 @@ public class TileTransformer extends TilePowerAcceptor } @Override - public boolean canProvideEnergy(EnumFacing direction) { + public boolean canProvideEnergy(Direction direction) { if (IC2TransformersStyle == true){ return getFacingEnum() != direction; } @@ -130,7 +130,7 @@ public class TileTransformer extends TilePowerAcceptor // TileMachineBase @Override - public EnumFacing getFacingEnum() { + public Direction getFacingEnum() { Block block = world.getBlockState(pos).getBlock(); if (block instanceof BlockTransformer) { return ((BlockTransformer) block).getFacing(world.getBlockState(pos)); @@ -140,17 +140,17 @@ public class TileTransformer extends TilePowerAcceptor // IToolDrop @Override - public ItemStack getToolDrop(EntityPlayer playerIn) { + public ItemStack getToolDrop(PlayerEntity playerIn) { return new ItemStack(wrenchDrop); } // IListInfoProvider @Override - public void addInfo(List info, boolean isRealTile, boolean hasData) { - info.add(new TextComponentString(TextFormatting.GRAY + "Input Rate: " + TextFormatting.GOLD + PowerSystem.getLocaliszedPowerFormatted((int) getMaxInput()))); - info.add(new TextComponentString(TextFormatting.GRAY + "Input Tier: " + TextFormatting.GOLD + StringUtils.toFirstCapitalAllLowercase(inputTier.toString()))); - info.add(new TextComponentString(TextFormatting.GRAY + "Output Rate: " + TextFormatting.GOLD + PowerSystem.getLocaliszedPowerFormatted((int) getMaxOutput()))); - info.add(new TextComponentString(TextFormatting.GRAY + "Output Tier: " + TextFormatting.GOLD + StringUtils.toFirstCapitalAllLowercase(ouputTier.toString()))); + public void addInfo(List info, boolean isRealTile, boolean hasData) { + info.add(new TextComponent(ChatFormat.GRAY + "Input Rate: " + ChatFormat.GOLD + PowerSystem.getLocaliszedPowerFormatted((int) getMaxInput()))); + info.add(new TextComponent(ChatFormat.GRAY + "Input Tier: " + ChatFormat.GOLD + StringUtils.toFirstCapitalAllLowercase(inputTier.toString()))); + info.add(new TextComponent(ChatFormat.GRAY + "Output Rate: " + ChatFormat.GOLD + PowerSystem.getLocaliszedPowerFormatted((int) getMaxOutput()))); + info.add(new TextComponent(ChatFormat.GRAY + "Output Tier: " + ChatFormat.GOLD + StringUtils.toFirstCapitalAllLowercase(ouputTier.toString()))); } } diff --git a/src/main/java/techreborn/utils/BehaviorDispenseScrapbox.java b/src/main/java/techreborn/utils/BehaviorDispenseScrapbox.java index 363e060e3..9d364dd49 100644 --- a/src/main/java/techreborn/utils/BehaviorDispenseScrapbox.java +++ b/src/main/java/techreborn/utils/BehaviorDispenseScrapbox.java @@ -24,14 +24,14 @@ package techreborn.utils; -import net.minecraft.block.BlockDispenser; -import net.minecraft.dispenser.BehaviorDefaultDispenseItem; -import net.minecraft.dispenser.IBlockSource; -import net.minecraft.dispenser.IPosition; +import net.minecraft.block.DispenserBlock; +import net.minecraft.block.dispenser.ItemDispenserBehavior; +import net.minecraft.block.entity.DispenserBlockEntity; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntityDispenser; -import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPointer; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.util.math.Position; import reborncore.common.crafting.Recipe; import reborncore.common.registration.RebornRegister; import reborncore.common.registration.config.ConfigRegistry; @@ -42,23 +42,23 @@ import java.util.List; import java.util.Random; @RebornRegister(TechReborn.MOD_ID) -public class BehaviorDispenseScrapbox extends BehaviorDefaultDispenseItem { +public class BehaviorDispenseScrapbox extends ItemDispenserBehavior { @ConfigRegistry(config = "misc", category = "general", key = "DispenserScrapbox", comment = "Dispensers will open scrapboxes") public static boolean dispenseScrapboxes = true; @Override - protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) { + protected ItemStack dispenseStack(BlockPointer source, ItemStack stack) { if (dispenseScrapboxes) { List scrapboxRecipeList = ModRecipes.SCRAPBOX.getRecipes(source.getWorld()); int random = new Random().nextInt(scrapboxRecipeList.size()); ItemStack out = scrapboxRecipeList.get(random).getOutputs().get(0); stack.split(1); - TileEntityDispenser tile = source.getBlockTileEntity(); - EnumFacing enumfacing = tile.getWorld().getBlockState(new BlockPos(source.getX(), source.getY(), source.getZ())).get(BlockDispenser.FACING); - IPosition iposition = BlockDispenser.getDispensePosition(source); - doDispense(source.getWorld(), out, 6, enumfacing, iposition); + DispenserBlockEntity tile = source.getBlockEntity(); + Direction enumfacing = tile.getWorld().getBlockState(new BlockPos(source.getX(), source.getY(), source.getZ())).get(DispenserBlock.FACING); + Position iposition = DispenserBlock.getOutputLocation(source); + dispenseItem(source.getWorld(), out, 6, enumfacing, iposition); } return stack; } diff --git a/src/main/java/techreborn/utils/FluidUtils.java b/src/main/java/techreborn/utils/FluidUtils.java index 73466aa31..a0b8ea768 100644 --- a/src/main/java/techreborn/utils/FluidUtils.java +++ b/src/main/java/techreborn/utils/FluidUtils.java @@ -25,7 +25,7 @@ package techreborn.utils; import net.minecraft.block.Block; -import net.minecraftforge.fluids.Fluid; + import java.util.Collections; import java.util.List; diff --git a/src/main/java/techreborn/utils/InitUtils.java b/src/main/java/techreborn/utils/InitUtils.java index eadbf7960..d6667b84d 100644 --- a/src/main/java/techreborn/utils/InitUtils.java +++ b/src/main/java/techreborn/utils/InitUtils.java @@ -26,17 +26,17 @@ package techreborn.utils; import net.minecraft.block.Block; import net.minecraft.item.Item; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Identifier; import techreborn.TechReborn; public class InitUtils { public static I setup(I item, String name) { - item.setRegistryName(new ResourceLocation(TechReborn.MOD_ID, name)); + item.setRegistryName(new Identifier(TechReborn.MOD_ID, name)); return item; } public static B setup(B block, String name) { - block.setRegistryName(new ResourceLocation(TechReborn.MOD_ID, name)); + block.setRegistryName(new Identifier(TechReborn.MOD_ID, name)); return block; } } diff --git a/src/main/java/techreborn/utils/StackWIPHandler.java b/src/main/java/techreborn/utils/StackWIPHandler.java index fb31901c6..c75cea971 100644 --- a/src/main/java/techreborn/utils/StackWIPHandler.java +++ b/src/main/java/techreborn/utils/StackWIPHandler.java @@ -24,17 +24,17 @@ package techreborn.utils; +import net.minecraft.ChatFormat; import net.minecraft.block.Block; -import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagString; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.event.entity.player.ItemTooltipEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraft.item.Items; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.StringTag; +import net.minecraft.network.chat.TextComponent; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + + import reborncore.common.util.StringUtils; import techreborn.init.TRContent; @@ -60,21 +60,21 @@ public class StackWIPHandler { private void addHead(String name) { ItemStack head = new ItemStack(Items.PLAYER_HEAD, 3); - head.setTag(new NBTTagCompound()); - head.getTag().put("SkullOwner", new NBTTagString(name)); + head.setTag(new CompoundTag()); + head.getTag().put("SkullOwner", new StringTag(name)); devHeads.add(head); } - @OnlyIn(Dist.CLIENT) + @Environment(EnvType.CLIENT) @SubscribeEvent public void toolTip(ItemTooltipEvent event) { Block block = Block.getBlockFromItem(event.getItemStack().getItem()); if (block != null && wipBlocks.contains(block)) { - event.getToolTip().add(new TextComponentString(TextFormatting.RED + StringUtils.t("techreborn.tooltip.wip"))); + event.getToolTip().add(new TextComponent(ChatFormat.RED + StringUtils.t("techreborn.tooltip.wip"))); } if (devHeads.contains(event.getItemStack())) { - event.getToolTip().add(new TextComponentString(TextFormatting.GOLD + "TechReborn Developer")); + event.getToolTip().add(new TextComponent(ChatFormat.GOLD + "TechReborn Developer")); } } } diff --git a/src/main/java/techreborn/utils/TagUtils.java b/src/main/java/techreborn/utils/TagUtils.java index 54b73e1ea..f1be5ab08 100644 --- a/src/main/java/techreborn/utils/TagUtils.java +++ b/src/main/java/techreborn/utils/TagUtils.java @@ -25,12 +25,12 @@ package techreborn.utils; import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; +import net.minecraft.block.BlockState; import net.minecraft.fluid.Fluid; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.tags.Tag; -import net.minecraft.tags.TagCollection; +import net.minecraft.tag.Tag; +import net.minecraft.tag.TagContainer; import net.minecraft.world.World; import javax.annotation.Nonnull; @@ -41,16 +41,16 @@ public class TagUtils { return tag.contains(type); } - public static TagCollection getAllBlockTags(World world) { - return world.getTags().getBlocks(); + public static TagContainer getAllBlockTags(World world) { + return world.getTagManager().blocks(); } - public static TagCollection getAllItemTags(World world) { - return world.getTags().getItems(); + public static TagContainer getAllItemTags(World world) { + return world.getTagManager().items(); } - public static TagCollection getAllFluidTags(World world) { - return world.getTags().getFluids(); + public static TagContainer getAllFluidTags(World world) { + return world.getTagManager().fluids(); } public static String toFirstLower(String string) { @@ -105,7 +105,7 @@ public class TagUtils { @Deprecated - public static boolean isOre(IBlockState state, String oreName) { + public static boolean isOre(BlockState state, String oreName) { throw new UnsupportedOperationException("Move to tags"); } diff --git a/src/main/java/techreborn/utils/damageSources/ElectrialShockSource.java b/src/main/java/techreborn/utils/damageSources/ElectrialShockSource.java index 9862c9ac8..3777cae17 100644 --- a/src/main/java/techreborn/utils/damageSources/ElectrialShockSource.java +++ b/src/main/java/techreborn/utils/damageSources/ElectrialShockSource.java @@ -24,7 +24,7 @@ package techreborn.utils.damageSources; -import net.minecraft.util.DamageSource; +import net.minecraft.entity.damage.DamageSource; /** * Created by modmuss50 on 06/03/2016. diff --git a/src/main/java/techreborn/utils/damageSources/FusionDamageSource.java b/src/main/java/techreborn/utils/damageSources/FusionDamageSource.java index 6dc82dfcc..5bc5b5f5a 100644 --- a/src/main/java/techreborn/utils/damageSources/FusionDamageSource.java +++ b/src/main/java/techreborn/utils/damageSources/FusionDamageSource.java @@ -24,7 +24,7 @@ package techreborn.utils.damageSources; -import net.minecraft.util.DamageSource; +import net.minecraft.entity.damage.DamageSource; /** * Created by modmuss50 on 05/03/2016. diff --git a/src/main/java/techreborn/world/OilLakeGenerator.java b/src/main/java/techreborn/world/OilLakeGenerator.java index a4fc46821..39d7480ed 100644 --- a/src/main/java/techreborn/world/OilLakeGenerator.java +++ b/src/main/java/techreborn/world/OilLakeGenerator.java @@ -25,9 +25,9 @@ package techreborn.world; import net.minecraft.world.World; -import net.minecraft.world.chunk.IChunkProvider; -import net.minecraft.world.gen.IChunkGenerator; -import net.minecraftforge.fml.common.IWorldGenerator; +import net.minecraft.world.chunk.ChunkManager; +import net.minecraft.world.gen.chunk.ChunkGenerator; + import reborncore.common.registration.RebornRegister; import reborncore.common.registration.config.ConfigRegistry; import techreborn.TechReborn; @@ -51,11 +51,11 @@ public class OilLakeGenerator implements IWorldGenerator { public static int rareity = 30; @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { + public void generate(Random random, int chunkX, int chunkZ, World world, ChunkGenerator chunkGenerator, ChunkManager chunkProvider) { if (!enable) { return; } - if (!world.getDimension().isSurfaceWorld()) { + if (!world.getDimension().hasVisibleSky()) { return; } if (random.nextInt(rareity) != 0) { diff --git a/src/main/java/techreborn/world/RubberTreeGenerator.java b/src/main/java/techreborn/world/RubberTreeGenerator.java index 3fe2f3077..58063f230 100644 --- a/src/main/java/techreborn/world/RubberTreeGenerator.java +++ b/src/main/java/techreborn/world/RubberTreeGenerator.java @@ -24,19 +24,19 @@ package techreborn.world; -import net.minecraft.block.trees.AbstractTree; +import net.minecraft.block.sapling.SaplingGenerator; import net.minecraft.world.IWorld; import net.minecraft.world.World; -import net.minecraft.world.chunk.IChunkProvider; -import net.minecraft.world.gen.IChunkGenerator; +import net.minecraft.world.chunk.ChunkManager; +import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.AbstractTreeFeature; -import net.minecraft.world.gen.feature.NoFeatureConfig; -import net.minecraftforge.fml.common.IWorldGenerator; +import net.minecraft.world.gen.feature.DefaultFeatureConfig; + import javax.annotation.Nullable; import java.util.Random; -public class RubberTreeGenerator extends AbstractTree implements IWorldGenerator { +public class RubberTreeGenerator extends SaplingGenerator implements IWorldGenerator { boolean isWorldGen = true; @@ -46,7 +46,7 @@ public class RubberTreeGenerator extends AbstractTree implements IWorldGenerator @Nullable @Override - protected AbstractTreeFeature getTreeFeature(Random random) { + protected AbstractTreeFeature createTreeFeature(Random random) { return null; } @@ -180,7 +180,7 @@ public class RubberTreeGenerator extends AbstractTree implements IWorldGenerator } @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { + public void generate(Random random, int chunkX, int chunkZ, World world, ChunkGenerator chunkGenerator, ChunkManager chunkProvider) { } } diff --git a/src/main/java/techreborn/world/feature/RubberTreeFeature.java b/src/main/java/techreborn/world/feature/RubberTreeFeature.java index 51a10f2f2..c82077ef5 100644 --- a/src/main/java/techreborn/world/feature/RubberTreeFeature.java +++ b/src/main/java/techreborn/world/feature/RubberTreeFeature.java @@ -26,14 +26,13 @@ package techreborn.world.feature; import java.util.Random; import java.util.Set; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.tags.BlockTags; -import net.minecraft.util.EnumFacing; +import net.minecraft.block.BlockState; +import net.minecraft.tag.BlockTags; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; import net.minecraft.world.IWorld; import net.minecraft.world.gen.feature.AbstractTreeFeature; -import net.minecraft.world.gen.feature.NoFeatureConfig; +import net.minecraft.world.gen.feature.DefaultFeatureConfig; import techreborn.blocks.BlockRubberLog; import techreborn.init.TRContent; @@ -41,13 +40,13 @@ import techreborn.init.TRContent; * @author drcrazy * */ -public class RubberTreeFeature extends AbstractTreeFeature { +public class RubberTreeFeature extends AbstractTreeFeature { //TODO: Configs private int treeBaseHeight = 5; private int sapRarity = 10; private int spireHeight = 4; - final IBlockState leafState = TRContent.RUBBER_LEAVES.getDefaultState(); + final BlockState leafState = TRContent.RUBBER_LEAVES.getDefaultState(); public RubberTreeFeature() { super(false); @@ -56,7 +55,7 @@ public class RubberTreeFeature extends AbstractTreeFeature { @Override protected boolean place(Set changedBlocks, IWorld worldIn, Random rand, BlockPos saplingPos) { int treeHeight = rand.nextInt(5) + treeBaseHeight; - int worldHeight = worldIn.getWorld().getHeight(); + int worldHeight = worldIn.getWorld().getTopPosition(); int baseY = saplingPos.getY(); int baseX = saplingPos.getX(); @@ -64,10 +63,10 @@ public class RubberTreeFeature extends AbstractTreeFeature { if (baseY <= 1 && baseY + treeHeight + 1 >= worldHeight) { return false; } BlockPos rootBlockPos = saplingPos.down(); - IBlockState rootBlockState = worldIn.getBlockState(rootBlockPos); + BlockState rootBlockState = worldIn.getBlockState(rootBlockPos); boolean isSoil = rootBlockState.canSustainPlant(worldIn, rootBlockPos, - net.minecraft.util.EnumFacing.UP, - (net.minecraft.block.BlockSapling) TRContent.RUBBER_SAPLING.getBlock()); + net.minecraft.util.math.Direction.UP, + (net.minecraft.block.SaplingBlock) TRContent.RUBBER_SAPLING.getBlock()); if (!isSoil) { return false; } int yOffset; @@ -82,10 +81,10 @@ public class RubberTreeFeature extends AbstractTreeFeature { radius = 2; } - BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); + BlockPos.Mutable blockpos$mutableblockpos = new BlockPos.Mutable(); for (xOffset = baseX - radius; xOffset <= baseX + radius; ++xOffset) { for (zOffset = baseZ - radius; zOffset <= baseZ + radius; ++zOffset) { - if (!this.canGrowInto(worldIn, blockpos$mutableblockpos.setPos(xOffset, yOffset, xOffset))) { + if (!this.canGrowInto(worldIn, blockpos$mutableblockpos.set(xOffset, yOffset, xOffset))) { return false; } } @@ -114,15 +113,15 @@ public class RubberTreeFeature extends AbstractTreeFeature { // Trunk BlockPos topLogPos = null; - IBlockState logState = TRContent.RUBBER_LOG.getDefaultState(); + BlockState logState = TRContent.RUBBER_LOG.getDefaultState(); for (yOffset = 0; yOffset < treeHeight; ++yOffset) { BlockPos blockpos = new BlockPos(baseX, baseY + yOffset, baseZ); - IBlockState state1 = worldIn.getBlockState(blockpos); - if (state1.isAir(worldIn, blockpos) || state1.isIn(BlockTags.LEAVES)) { + BlockState state1 = worldIn.getBlockState(blockpos); + if (state1.isAir(worldIn, blockpos) || state1.matches(BlockTags.LEAVES)) { if (rand.nextInt(sapRarity) == 0) { logState = logState.with(BlockRubberLog.HAS_SAP, true) - .with(BlockRubberLog.SAP_SIDE, EnumFacing.byHorizontalIndex(rand.nextInt(4))); + .with(BlockRubberLog.SAP_SIDE, Direction.fromHorizontal(rand.nextInt(4))); } //setBlockState(worldIn, blockpos, logState); @@ -149,7 +148,7 @@ public class RubberTreeFeature extends AbstractTreeFeature { } private boolean growLeaves(IWorld worldIn, BlockPos pos) { - IBlockState state1 = worldIn.getBlockState(pos); + BlockState state1 = worldIn.getBlockState(pos); if (state1.canBeReplacedByLeaves(worldIn, pos)) { this.setBlockState(worldIn, pos, leafState); return true; diff --git a/src/main/java/techreborn/world/village/ModLootTables.java b/src/main/java/techreborn/world/village/ModLootTables.java index d2cde62d2..75cfb0b0c 100644 --- a/src/main/java/techreborn/world/village/ModLootTables.java +++ b/src/main/java/techreborn/world/village/ModLootTables.java @@ -24,12 +24,12 @@ package techreborn.world.village; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.storage.loot.LootTableList; +import net.minecraft.util.Identifier; +import net.minecraft.world.loot.LootTables; import techreborn.TechReborn; public class ModLootTables { - public static final ResourceLocation CHESTS_RUBBER_PLANTATION = LootTableList.register(new ResourceLocation(TechReborn.MOD_ID, "chests/rubber_plantation")); + public static final Identifier CHESTS_RUBBER_PLANTATION = LootTables.registerLootTable(new Identifier(TechReborn.MOD_ID, "chests/rubber_plantation")); } diff --git a/src/main/java/techreborn/world/village/VillageComponentRubberPlantaion.java b/src/main/java/techreborn/world/village/VillageComponentRubberPlantaion.java index 3b3bcf7d3..b584decd9 100644 --- a/src/main/java/techreborn/world/village/VillageComponentRubberPlantaion.java +++ b/src/main/java/techreborn/world/village/VillageComponentRubberPlantaion.java @@ -24,38 +24,38 @@ package techreborn.world.village; -import net.minecraft.block.BlockCrops; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.util.EnumFacing; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.CropBlock; +import net.minecraft.structure.StructurePiece; +import net.minecraft.structure.VillageGenerator; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.math.MutableBoundingBox; +import net.minecraft.util.math.Direction; +import net.minecraft.util.math.MutableIntBoundingBox; import net.minecraft.world.IWorld; -import net.minecraft.world.gen.feature.structure.StructurePiece; -import net.minecraft.world.gen.feature.structure.VillagePieces; import techreborn.init.TRContent; import techreborn.world.RubberTreeGenerator; import java.util.List; import java.util.Random; -public class VillageComponentRubberPlantaion extends VillagePieces.Field1 { +public class VillageComponentRubberPlantaion extends VillageGenerator.Field1 { - public static VillagePieces.Village buildComponent(VillagePieces.PieceWeight villagePiece, VillagePieces.Start startPiece, List pieces, Random random, int p1, int p2, int p3, EnumFacing facing, int p5) { - MutableBoundingBox structureboundingbox = MutableBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, 13, 4, 9, facing); - return canVillageGoDeeper(structureboundingbox) && StructurePiece.findIntersecting(pieces, structureboundingbox) == null ? new VillageComponentRubberPlantaion(startPiece, p5, random, structureboundingbox, facing) : null; + public static VillageGenerator.Piece buildComponent(VillageGenerator.PieceWeight villagePiece, VillageGenerator.Start startPiece, List pieces, Random random, int p1, int p2, int p3, Direction facing, int p5) { + MutableIntBoundingBox structureboundingbox = MutableIntBoundingBox.createRotated(p1, p2, p3, 0, 0, 0, 13, 4, 9, facing); + return canVillageGoDeeper(structureboundingbox) && StructurePiece.method_14932(pieces, structureboundingbox) == null ? new VillageComponentRubberPlantaion(startPiece, p5, random, structureboundingbox, facing) : null; } public VillageComponentRubberPlantaion() { } - public VillageComponentRubberPlantaion(VillagePieces.Start start, int type, Random rand, MutableBoundingBox structureBoundingBox, EnumFacing facing) { + public VillageComponentRubberPlantaion(VillageGenerator.Start start, int type, Random rand, MutableIntBoundingBox structureBoundingBox, Direction facing) { super(start, type, rand, structureBoundingBox, facing); } @Override - protected void fillWithBlocks(IWorld worldIn, MutableBoundingBox boundingboxIn, int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, IBlockState boundaryBlockState, IBlockState insideBlockState, boolean existingOnly) { + protected void fillWithBlocks(IWorld worldIn, MutableIntBoundingBox boundingboxIn, int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, BlockState boundaryBlockState, BlockState insideBlockState, boolean existingOnly) { //Replaces farmland with dirt, its not great but it works. if (boundaryBlockState.getBlock() == Blocks.FARMLAND) { boundaryBlockState = Blocks.GRASS.getDefaultState(); @@ -70,7 +70,7 @@ public class VillageComponentRubberPlantaion extends VillagePieces.Field1 { } @Override - protected void setBlockState(IWorld worldIn, IBlockState blockstateIn, int x, int y, int z, MutableBoundingBox boundingboxIn) { + protected void setBlockState(IWorld worldIn, BlockState blockstateIn, int x, int y, int z, MutableIntBoundingBox boundingboxIn) { if (isCrop(blockstateIn)) { blockstateIn = TRContent.RUBBER_SAPLING.getDefaultState(); } @@ -78,7 +78,7 @@ public class VillageComponentRubberPlantaion extends VillagePieces.Field1 { } @Override - public boolean addComponentParts(IWorld worldIn, Random randomIn, MutableBoundingBox structureBoundingBoxIn, ChunkPos chunkPos) { + public boolean addComponentParts(IWorld worldIn, Random randomIn, MutableIntBoundingBox structureBoundingBoxIn, ChunkPos chunkPos) { super.addComponentParts(worldIn, randomIn, structureBoundingBoxIn, chunkPos); for (int i = 1; i < 7; i++) { growRandom(i, 1, structureBoundingBoxIn, randomIn, worldIn); @@ -94,7 +94,7 @@ public class VillageComponentRubberPlantaion extends VillagePieces.Field1 { return true; } - private void growRandom(int coloum, int row, MutableBoundingBox structureBoundingBox, Random random, IWorld world) { + private void growRandom(int coloum, int row, MutableIntBoundingBox structureBoundingBox, Random random, IWorld world) { if (random.nextInt(10) == 0) { setBlockState(world, Blocks.AIR.getDefaultState(), row, 1, coloum, structureBoundingBox); BlockPos pos = new BlockPos(this.getXWithOffset(row, coloum), this.getYWithOffset(1), this.getZWithOffset(row, coloum)); @@ -105,8 +105,8 @@ public class VillageComponentRubberPlantaion extends VillagePieces.Field1 { } } - private boolean isCrop(IBlockState state) { - if (state.getBlock() instanceof BlockCrops) { + private boolean isCrop(BlockState state) { + if (state.getBlock() instanceof CropBlock) { return true; } return false; diff --git a/src/main/java/techreborn/world/village/VillagePlantaionHandler.java b/src/main/java/techreborn/world/village/VillagePlantaionHandler.java index 16869c60e..831d12ea0 100644 --- a/src/main/java/techreborn/world/village/VillagePlantaionHandler.java +++ b/src/main/java/techreborn/world/village/VillagePlantaionHandler.java @@ -24,10 +24,10 @@ package techreborn.world.village; -import net.minecraft.util.EnumFacing; -import net.minecraft.world.gen.feature.structure.StructurePiece; -import net.minecraft.world.gen.feature.structure.VillagePieces; -import net.minecraftforge.fml.common.registry.VillagerRegistry; +import net.minecraft.structure.StructurePiece; +import net.minecraft.structure.VillageGenerator; +import net.minecraft.util.math.Direction; + import java.util.List; import java.util.Random; @@ -35,8 +35,8 @@ import java.util.Random; public class VillagePlantaionHandler implements VillagerRegistry.IVillageCreationHandler { @Override - public VillagePieces.PieceWeight getVillagePieceWeight(Random random, int i) { - return new VillagePieces.PieceWeight(VillageComponentRubberPlantaion.class, 5, 1); + public VillageGenerator.PieceWeight getVillagePieceWeight(Random random, int i) { + return new VillageGenerator.PieceWeight(VillageComponentRubberPlantaion.class, 5, 1); } @Override @@ -46,7 +46,7 @@ public class VillagePlantaionHandler implements VillagerRegistry.IVillageCreatio @Override - public VillagePieces.Village buildComponent(VillagePieces.PieceWeight villagePiece, VillagePieces.Start startPiece, List pieces, Random random, int p1, int p2, int p3, EnumFacing facing, int p5) { + public VillageGenerator.Piece buildComponent(VillageGenerator.PieceWeight villagePiece, VillageGenerator.Start startPiece, List pieces, Random random, int p1, int p2, int p3, Direction facing, int p5) { return VillageComponentRubberPlantaion.buildComponent(villagePiece, startPiece, pieces, random, p1, p2, p3, facing, p5); } }