From 83bf6add1e61dd60e63d005a3b409141c4f96828 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Tue, 23 Jul 2019 20:46:07 +0100 Subject: [PATCH] Large amount of fluid work --- src/main/java/techreborn/TechReborn.java | 2 - .../FluidReplicatorRecipe.java | 2 +- .../FluidReplicatorRecipeCrafter.java | 4 +- .../FluidReplicatorRecipeList.java | 2 +- .../api/generator/FluidGeneratorRecipe.java | 2 +- .../generator/FluidGeneratorRecipeList.java | 2 +- .../api/generator/GeneratorRecipeHelper.java | 2 +- .../recipes/IndustrialGrinderRecipe.java | 2 +- .../recipes/IndustrialSawmillRecipe.java | 2 +- .../BaseFluidGeneratorBlockEntity.java | 2 +- .../blocks/fluid/BlockFluidBase.java | 49 ------------------- .../blocks/fluid/BlockFluidTechReborn.java | 43 ---------------- .../techreborn/client/gui/GuiQuantumTank.java | 2 +- .../java/techreborn/events/ModRegistry.java | 7 +++ src/main/java/techreborn/init/ModFluids.java | 37 +++++++++----- src/main/java/techreborn/init/ModRecipes.java | 6 +-- .../init/recipes/FluidGeneratorRecipes.java | 2 +- .../java/techreborn/items/DynamicCell.java | 2 +- src/main/java/techreborn/items/ItemCells.java | 2 +- .../java/techreborn/utils/FluidUtils.java | 4 +- 20 files changed, 52 insertions(+), 124 deletions(-) delete mode 100644 src/main/java/techreborn/blocks/fluid/BlockFluidBase.java delete mode 100644 src/main/java/techreborn/blocks/fluid/BlockFluidTechReborn.java diff --git a/src/main/java/techreborn/TechReborn.java b/src/main/java/techreborn/TechReborn.java index d239f1314..bbd5bf6c8 100644 --- a/src/main/java/techreborn/TechReborn.java +++ b/src/main/java/techreborn/TechReborn.java @@ -64,8 +64,6 @@ public class TechReborn implements ModInitializer { @SuppressWarnings("unused") RegistrationManager registrationManager = new RegistrationManager("techreborn", getClass()); // TechRebornAPI.subItemRetriever = new SubItemRetriever(); - // Done like this to load them here - ModFluids.values(); // Done to force the class to load ModRecipes.GRINDER.getName(); diff --git a/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipe.java b/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipe.java index 371331378..4626dfc23 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 reborncore.fluid.Fluid; +import reborncore.common.fluid.Fluid; import techreborn.init.TRContent; import techreborn.blockentity.machine.multiblock.FluidReplicatorBlockEntity; import techreborn.utils.FluidUtils; diff --git a/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeCrafter.java b/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeCrafter.java index bca5335e7..007833be4 100644 --- a/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeCrafter.java +++ b/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeCrafter.java @@ -29,8 +29,8 @@ import net.minecraft.item.ItemStack; import reborncore.common.recipes.RecipeCrafter; import reborncore.common.util.RebornInventory; import reborncore.common.util.Tank; -import reborncore.fluid.Fluid; -import reborncore.fluid.FluidStack; +import reborncore.common.fluid.Fluid; +import reborncore.common.fluid.FluidStack; import techreborn.init.ModRecipes; import techreborn.init.TRContent; import techreborn.blockentity.machine.multiblock.FluidReplicatorBlockEntity; diff --git a/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeList.java b/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeList.java index c32e567ec..6a098910f 100644 --- a/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeList.java +++ b/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeList.java @@ -25,7 +25,7 @@ package techreborn.api.fluidreplicator; import org.apache.commons.lang3.Validate; -import reborncore.fluid.Fluid; +import reborncore.common.fluid.Fluid; import techreborn.utils.FluidUtils; import java.util.ArrayList; diff --git a/src/main/java/techreborn/api/generator/FluidGeneratorRecipe.java b/src/main/java/techreborn/api/generator/FluidGeneratorRecipe.java index 3c380c41b..941cc0e13 100644 --- a/src/main/java/techreborn/api/generator/FluidGeneratorRecipe.java +++ b/src/main/java/techreborn/api/generator/FluidGeneratorRecipe.java @@ -25,7 +25,7 @@ package techreborn.api.generator; -import reborncore.fluid.Fluid; +import reborncore.common.fluid.Fluid; import techreborn.utils.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 bb8e3c028..b11f575c9 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 reborncore.fluid.Fluid; +import reborncore.common.fluid.Fluid; import techreborn.utils.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 b40a42e87..349e36b60 100644 --- a/src/main/java/techreborn/api/generator/GeneratorRecipeHelper.java +++ b/src/main/java/techreborn/api/generator/GeneratorRecipeHelper.java @@ -26,7 +26,7 @@ package techreborn.api.generator; -import reborncore.fluid.Fluid; +import reborncore.common.fluid.Fluid; import java.util.EnumMap; import java.util.Optional; diff --git a/src/main/java/techreborn/api/recipe/recipes/IndustrialGrinderRecipe.java b/src/main/java/techreborn/api/recipe/recipes/IndustrialGrinderRecipe.java index b3faaa2da..54c1c6331 100644 --- a/src/main/java/techreborn/api/recipe/recipes/IndustrialGrinderRecipe.java +++ b/src/main/java/techreborn/api/recipe/recipes/IndustrialGrinderRecipe.java @@ -28,7 +28,7 @@ import net.minecraft.block.entity.BlockEntity; import net.minecraft.util.Identifier; import reborncore.common.crafting.RebornRecipe; import reborncore.common.crafting.RebornRecipeType; -import reborncore.fluid.FluidStack; +import reborncore.common.fluid.FluidStack; import techreborn.blockentity.machine.multiblock.IndustrialGrinderBlockEntity; public class IndustrialGrinderRecipe extends RebornRecipe { diff --git a/src/main/java/techreborn/api/recipe/recipes/IndustrialSawmillRecipe.java b/src/main/java/techreborn/api/recipe/recipes/IndustrialSawmillRecipe.java index 650114776..e4fad427c 100644 --- a/src/main/java/techreborn/api/recipe/recipes/IndustrialSawmillRecipe.java +++ b/src/main/java/techreborn/api/recipe/recipes/IndustrialSawmillRecipe.java @@ -28,7 +28,7 @@ import net.minecraft.block.entity.BlockEntity; import net.minecraft.util.Identifier; import reborncore.common.crafting.RebornRecipe; import reborncore.common.crafting.RebornRecipeType; -import reborncore.fluid.FluidStack; +import reborncore.common.fluid.FluidStack; import techreborn.blockentity.machine.multiblock.IndustrialSawmillBlockEntity; public class IndustrialSawmillRecipe extends RebornRecipe { diff --git a/src/main/java/techreborn/blockentity/generator/BaseFluidGeneratorBlockEntity.java b/src/main/java/techreborn/blockentity/generator/BaseFluidGeneratorBlockEntity.java index c098a13b7..7cbc5a5e9 100644 --- a/src/main/java/techreborn/blockentity/generator/BaseFluidGeneratorBlockEntity.java +++ b/src/main/java/techreborn/blockentity/generator/BaseFluidGeneratorBlockEntity.java @@ -33,7 +33,7 @@ import reborncore.common.blocks.BlockMachineBase; import reborncore.common.powerSystem.PowerAcceptorBlockEntity; import reborncore.common.util.RebornInventory; import reborncore.common.util.Tank; -import reborncore.fluid.FluidStack; +import reborncore.common.fluid.FluidStack; import techreborn.api.generator.EFluidGenerator; import techreborn.api.generator.FluidGeneratorRecipe; import techreborn.api.generator.FluidGeneratorRecipeList; diff --git a/src/main/java/techreborn/blocks/fluid/BlockFluidBase.java b/src/main/java/techreborn/blocks/fluid/BlockFluidBase.java deleted file mode 100644 index 80c3e163c..000000000 --- a/src/main/java/techreborn/blocks/fluid/BlockFluidBase.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of TechReborn, licensed under the MIT License (MIT). - * - * Copyright (c) 2018 TechReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package techreborn.blocks.fluid; - -import net.minecraft.block.FluidBlock; -import net.minecraft.fluid.BaseFluid; - -public class BlockFluidBase extends FluidBlock { - - public BlockFluidBase(BaseFluid fluid, Settings properties) { - super(fluid, properties); - } - -// @Override -// public boolean canDisplace(IBlockAccess world, BlockPos pos) { -// if (world.getBlockState(pos).getMaterial().isLiquid()) -// return false; -// return super.canDisplace(world, pos); -// } -// -// @Override -// public boolean displaceIfPossible(World world, BlockPos pos) { -// if (world.getBlockState(pos).getMaterial().isLiquid()) -// return false; -// return super.displaceIfPossible(world, pos); -// } -} diff --git a/src/main/java/techreborn/blocks/fluid/BlockFluidTechReborn.java b/src/main/java/techreborn/blocks/fluid/BlockFluidTechReborn.java deleted file mode 100644 index 1d82a28ea..000000000 --- a/src/main/java/techreborn/blocks/fluid/BlockFluidTechReborn.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is part of TechReborn, licensed under the MIT License (MIT). - * - * Copyright (c) 2018 TechReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package techreborn.blocks.fluid; - -import net.minecraft.fluid.BaseFluid; - -public class BlockFluidTechReborn extends BlockFluidBase { - - String name; - - public BlockFluidTechReborn(BaseFluid fluid, Settings properties, String name) { - super(fluid, properties); - //setTranslationKey(name); - this.name = name; - } -// -// @Override -// public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing side) { -// return BlockFaceShape.UNDEFINED; -// } -} diff --git a/src/main/java/techreborn/client/gui/GuiQuantumTank.java b/src/main/java/techreborn/client/gui/GuiQuantumTank.java index 7ffe5b4bc..a72051439 100644 --- a/src/main/java/techreborn/client/gui/GuiQuantumTank.java +++ b/src/main/java/techreborn/client/gui/GuiQuantumTank.java @@ -26,7 +26,7 @@ package techreborn.client.gui; import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; -import reborncore.fluid.FluidStack; +import reborncore.common.fluid.FluidStack; import techreborn.blockentity.machine.tier3.QuantumTankBlockEntity; public class GuiQuantumTank extends GuiBase { diff --git a/src/main/java/techreborn/events/ModRegistry.java b/src/main/java/techreborn/events/ModRegistry.java index a785f5c9e..e30f55318 100644 --- a/src/main/java/techreborn/events/ModRegistry.java +++ b/src/main/java/techreborn/events/ModRegistry.java @@ -40,6 +40,7 @@ import techreborn.blocks.misc.BlockRubberPlankSlab; import techreborn.blocks.misc.BlockRubberPlankStair; import techreborn.blocks.misc.BlockRubberSapling; import techreborn.config.ConfigTechReborn; +import techreborn.init.ModFluids; import techreborn.init.TRArmorMaterial; import techreborn.init.TRContent; import techreborn.init.TRContent.*; @@ -69,6 +70,7 @@ import techreborn.items.tool.vanilla.*; import techreborn.utils.InitUtils; import java.util.Arrays; +import java.util.function.Consumer; /** * @author drcrazy @@ -80,6 +82,7 @@ public class ModRegistry { public static void setupShit(){ registerBlocks(); registerItems(); + registerFluids(); } public static void registerBlocks() { @@ -208,4 +211,8 @@ public class ModRegistry { TechReborn.LOGGER.debug("TechReborns Items Loaded"); } + + public static void registerFluids() { + Arrays.stream(ModFluids.values()).forEach(ModFluids::register); + } } diff --git a/src/main/java/techreborn/init/ModFluids.java b/src/main/java/techreborn/init/ModFluids.java index cac6f67bd..da7829eac 100644 --- a/src/main/java/techreborn/init/ModFluids.java +++ b/src/main/java/techreborn/init/ModFluids.java @@ -24,9 +24,14 @@ package techreborn.init; +import net.fabricmc.fabric.api.block.FabricBlockSettings; +import net.minecraft.block.Material; +import net.minecraft.item.Item; import net.minecraft.util.Identifier; -import reborncore.fluid.Fluid; -import techreborn.blocks.fluid.BlockFluidTechReborn; +import net.minecraft.util.registry.Registry; +import reborncore.common.fluid.*; +import techreborn.TechReborn; + public enum ModFluids { BERYLLIUM, CALCIUM, @@ -63,24 +68,34 @@ public enum ModFluids { COMPRESSED_AIR, ELECTROLYZED_WATER; - public Fluid fluid; - public BlockFluidTechReborn block; - public String name; + private final RebornFluid fluid; + private RebornFluidBlock block; + private RebornBucketItem bucket; + private final Identifier identifier; ModFluids() { - this.name = this.name().replace("_", "").toLowerCase(); //Is this ok? - fluid = new Fluid(name, new Identifier("techreborn", "fixme"), new Identifier("techrebonr", "alsofixme")); + this.identifier = new Identifier("techreborn", this.name().replace("_", "").toLowerCase()); + fluid = new RebornFluid(FluidSettings.create(), () -> block, () -> bucket); + block = new RebornFluidBlock(fluid, FabricBlockSettings.of(Material.WATER).noCollision().hardness(100.0F).dropsNothing().build()); + bucket = new RebornBucketItem(fluid, new Item.Settings().group(TechReborn.ITEMGROUP)); } + public void register() { + RebornFluidManager.register(fluid, identifier); + Registry.register(Registry.BLOCK, identifier, block); + Registry.register(Registry.ITEM, identifier, bucket); + } + + @Deprecated //TODO this is bad! public Fluid getFluid() { - return fluid; + return new Fluid(); } - public BlockFluidTechReborn getBlock() { + public RebornFluidBlock getBlock() { return block; } - public String getName() { - return name; + public Identifier getIdentifier() { + return identifier; } } diff --git a/src/main/java/techreborn/init/ModRecipes.java b/src/main/java/techreborn/init/ModRecipes.java index cce5f07e6..737318366 100644 --- a/src/main/java/techreborn/init/ModRecipes.java +++ b/src/main/java/techreborn/init/ModRecipes.java @@ -30,9 +30,9 @@ import reborncore.common.crafting.RebornRecipe; import reborncore.common.crafting.RebornRecipeType; import reborncore.common.crafting.RecipeManager; import reborncore.common.registration.RebornRegister; -import reborncore.fluid.Fluid; -import reborncore.fluid.FluidStack; -import reborncore.fluid.FluidUtil; +import reborncore.common.fluid.Fluid; +import reborncore.common.fluid.FluidStack; +import reborncore.common.fluid.FluidUtil; import techreborn.TechReborn; import techreborn.api.recipe.recipes.BlastFurnaceRecipe; import techreborn.api.recipe.recipes.IndustrialGrinderRecipe; diff --git a/src/main/java/techreborn/init/recipes/FluidGeneratorRecipes.java b/src/main/java/techreborn/init/recipes/FluidGeneratorRecipes.java index 7c91a353e..52c755bdb 100644 --- a/src/main/java/techreborn/init/recipes/FluidGeneratorRecipes.java +++ b/src/main/java/techreborn/init/recipes/FluidGeneratorRecipes.java @@ -25,7 +25,7 @@ package techreborn.init.recipes; -import reborncore.fluid.Fluid; +import reborncore.common.fluid.Fluid; import techreborn.api.generator.EFluidGenerator; import techreborn.api.generator.GeneratorRecipeHelper; import techreborn.init.ModFluids; diff --git a/src/main/java/techreborn/items/DynamicCell.java b/src/main/java/techreborn/items/DynamicCell.java index 1aaa39265..7a6c4af6e 100644 --- a/src/main/java/techreborn/items/DynamicCell.java +++ b/src/main/java/techreborn/items/DynamicCell.java @@ -33,7 +33,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.util.DefaultedList; import net.minecraft.world.World; import org.apache.commons.lang3.Validate; -import reborncore.fluid.Fluid; +import reborncore.common.fluid.Fluid; import techreborn.TechReborn; import techreborn.init.TRContent; import techreborn.utils.FluidUtils; diff --git a/src/main/java/techreborn/items/ItemCells.java b/src/main/java/techreborn/items/ItemCells.java index 6541d184f..4850d8ad5 100644 --- a/src/main/java/techreborn/items/ItemCells.java +++ b/src/main/java/techreborn/items/ItemCells.java @@ -26,7 +26,7 @@ package techreborn.items; import net.minecraft.item.ItemStack; import org.apache.commons.lang3.Validate; -import reborncore.fluid.Fluid; +import reborncore.common.fluid.Fluid; import techreborn.utils.FluidUtils; public class ItemCells { diff --git a/src/main/java/techreborn/utils/FluidUtils.java b/src/main/java/techreborn/utils/FluidUtils.java index 234020fa8..8b1184dd4 100644 --- a/src/main/java/techreborn/utils/FluidUtils.java +++ b/src/main/java/techreborn/utils/FluidUtils.java @@ -28,8 +28,8 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import reborncore.common.util.RebornInventory; import reborncore.common.util.Tank; -import reborncore.fluid.Fluid; -import reborncore.fluid.FluidStack; +import reborncore.common.fluid.Fluid; +import reborncore.common.fluid.FluidStack; import java.util.Collections; import java.util.List;