From 1b820de08a05070909a267e17f033fcf58ac8710 Mon Sep 17 00:00:00 2001 From: NotAPenguin Date: Mon, 2 Sep 2024 23:17:17 +0200 Subject: The Great Renaming (#3014) * move kekztech to a single root dir * move detrav to a single root dir * move gtnh-lanthanides to a single root dir * move tectech and delete some gross reflection in gt++ * remove more reflection inside gt5u * delete more reflection in gt++ * fix imports * move bartworks and bwcrossmod * fix proxies * move galactigreg and ggfab * move gtneioreplugin * try to fix gt++ bee loader * apply the rename rules to BW * apply rename rules to bwcrossmod * apply rename rules to detrav scanner mod * apply rename rules to galacticgreg * apply rename rules to ggfab * apply rename rules to goodgenerator * apply rename rules to gtnh-lanthanides * apply rename rules to gt++ * apply rename rules to kekztech * apply rename rules to kubatech * apply rename rules to tectech * apply rename rules to gt apply the rename rules to gt * fix tt import * fix mui hopefully * fix coremod except intergalactic * rename assline recipe class * fix a class name i stumbled on * rename StructureUtility to GTStructureUtility to prevent conflict with structurelib * temporary rename of GTTooltipDataCache to old name * fix gt client/server proxy names --- src/main/java/gregtech/common/fluid/GTFluid.java | 209 +++++++++++++++++++++ .../java/gregtech/common/fluid/GTFluidBuilder.java | 146 ++++++++++++++ src/main/java/gregtech/common/fluid/GT_Fluid.java | 209 --------------------- .../gregtech/common/fluid/GT_FluidBuilder.java | 146 -------------- 4 files changed, 355 insertions(+), 355 deletions(-) create mode 100644 src/main/java/gregtech/common/fluid/GTFluid.java create mode 100644 src/main/java/gregtech/common/fluid/GTFluidBuilder.java delete mode 100644 src/main/java/gregtech/common/fluid/GT_Fluid.java delete mode 100644 src/main/java/gregtech/common/fluid/GT_FluidBuilder.java (limited to 'src/main/java/gregtech/common/fluid') diff --git a/src/main/java/gregtech/common/fluid/GTFluid.java b/src/main/java/gregtech/common/fluid/GTFluid.java new file mode 100644 index 0000000000..3969817ee9 --- /dev/null +++ b/src/main/java/gregtech/common/fluid/GTFluid.java @@ -0,0 +1,209 @@ +package gregtech.common.fluid; + +import static gregtech.api.recipe.RecipeMaps.fluidCannerRecipes; + +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import gregtech.api.GregTechAPI; +import gregtech.api.enums.FluidState; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.fluid.IGTFluid; +import gregtech.api.interfaces.fluid.IGTRegisteredFluid; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTUtility; + +public class GTFluid extends Fluid implements IGTFluid, IGTRegisteredFluid, Runnable { + + private final String localizedName; + private final ResourceLocation stillIconResourceLocation; + private final ResourceLocation flowingIconResourceLocation; + private final short[] colorRGBA; + private final FluidState fluidState; + private final Fluid iconsFrom; + private Fluid registeredFluid; + + /** + * Constructs this {@link IGTFluid} implementation from an {@link GTFluidBuilder} instance + * + * @param builder The {@link GTFluidBuilder} instance to construct this {@link IGTFluid} implementation + */ + protected GTFluid(@Nonnull final GTFluidBuilder builder) { + super(builder.fluidName); + this.localizedName = builder.localizedName; + this.stillIconResourceLocation = builder.stillIconResourceLocation; + this.flowingIconResourceLocation = builder.flowingIconResourceLocation; + this.iconsFrom = builder.iconsFrom; + this.block = builder.fluidBlock; + this.colorRGBA = builder.colorRGBA; + this.fluidState = builder.fluidState; + this.temperature = builder.temperature; + configureFromStateTemperature(); + } + + /** + * Adjusts this {@link Fluid}'s settings based on this {@link IGTFluid}'s state + */ + protected void configureFromStateTemperature() { + switch (fluidState) { + case SLURRY: + setGaseous(false).setViscosity(10000); + break; + case GAS: + setGaseous(true).setDensity(-100) + .setViscosity(200); + break; + case PLASMA: + setGaseous(true).setDensity(55536) + .setViscosity(10) + .setLuminosity(15); + break; + case MOLTEN: + final int luminosity; + if (temperature >= 3500) { + luminosity = 15; + } else { + luminosity = temperature < 1000 ? 0 : 14 * (temperature - 1000) / 2500 + 1; + } + setLuminosity(luminosity); + case LIQUID: + default: + setGaseous(false).setViscosity(1000); + break; + } + } + + // ----- Fluid implementations ----- + + /** + * @inheritDoc + */ + @Override + public int getColor() { + return (Math.max(0, Math.min(255, colorRGBA[0])) << 16) | (Math.max(0, Math.min(255, colorRGBA[1])) << 8) + | Math.max(0, Math.min(255, colorRGBA[2])); + } + + // ----- IGTFluid interface implementations ----- + + public IGTRegisteredFluid addFluid() { + if (FluidRegistry.registerFluid(GTFluid.this)) { + // Registered as a new Fluid + registeredFluid = this; + // Adds a server-side localized-name + GTLanguageManager.addStringLocalization(getUnlocalizedName(), localizedName); + } else { + // Fluid already registered, get it from the registry + registeredFluid = FluidRegistry.getFluid(GTFluid.this.fluidName); + // Sets temperature of already registered fluids if they use the default (temperature = 300) + if (registeredFluid.getTemperature() == new Fluid("test").getTemperature()) { + registeredFluid.setTemperature(GTFluid.this.temperature); + } + } + // Schedules the fluid for the block icons loader run() tasks + GregTechAPI.sGTBlockIconload.add(this); + return this; + } + + // ----- IGT_RegisteredFluid interface implementations ----- + + /** + * @inheritDoc + */ + @Override + public IGTRegisteredFluid registerContainers(final ItemStack fullContainer, final ItemStack emptyContainer, + final int containerSize) { + if (fullContainer != null && emptyContainer != null) { + final FluidStack fluidStack = new FluidStack(registeredFluid, containerSize); + if (!FluidContainerRegistry.registerFluidContainer(fluidStack, fullContainer, emptyContainer)) { + GTValues.RA.stdBuilder() + .itemInputs(fullContainer) + .itemOutputs(GTUtility.getContainerItem(fullContainer, false)) + .fluidOutputs(fluidStack) + .duration(fluidStack.amount / 62) + .eut(1) + .addTo(fluidCannerRecipes); + } + } + return this; + } + + /** + * @inheritDoc + */ + @Override + public IGTRegisteredFluid registerBContainers(final ItemStack fullContainer, final ItemStack emptyContainer) { + return registerContainers(fullContainer, emptyContainer, 1000); + } + + /** + * @inheritDoc + */ + @Override + public IGTRegisteredFluid registerPContainers(final ItemStack fullContainer, final ItemStack emptyContainer) { + return registerContainers(fullContainer, emptyContainer, 250); + } + + /** + * @inheritDoc + */ + @Override + public IGTRegisteredFluid configureMaterials(final Materials material) { + if (material != null) { + switch (fluidState) { + case SLURRY -> material.mSolid = registeredFluid; + case GAS -> material.mGas = registeredFluid; + case PLASMA -> material.mPlasma = registeredFluid; + case MOLTEN -> material.mStandardMoltenFluid = registeredFluid; + default -> material.mFluid = registeredFluid; + } + Materials.FLUID_MAP.put(registeredFluid, material); + } + return this; + } + + /** + * @inheritDoc + */ + @Override + public Fluid asFluid() { + return registeredFluid; + } + + // ----- Runnable interface implementations ----- + + /** + * This {@link Runnable#run()} implementation is scheduled within the {@link GregTechAPI#sGTBlockIconload} to load + * this {@link IGTFluid}'s texture icons. + * + * @see Runnable#run() + */ + @Override + public void run() { + if (iconsFrom instanceof GTFluid) { + // Needs the GTFluid to have registered its icons + ((GTFluid) iconsFrom).run(); + stillIcon = iconsFrom.getStillIcon(); + flowingIcon = iconsFrom.getFlowingIcon(); + } else { + if (stillIconResourceLocation != null) { + stillIcon = GregTechAPI.sBlockIcons.registerIcon(stillIconResourceLocation.toString()); + } + if (flowingIconResourceLocation != null) { + flowingIcon = GregTechAPI.sBlockIcons.registerIcon(flowingIconResourceLocation.toString()); + } + } + } + + @Override + public String toString() { + return "GTFluid{" + "fluidName='" + fluidName + '\'' + '}'; + } +} diff --git a/src/main/java/gregtech/common/fluid/GTFluidBuilder.java b/src/main/java/gregtech/common/fluid/GTFluidBuilder.java new file mode 100644 index 0000000000..e1532f0dbf --- /dev/null +++ b/src/main/java/gregtech/common/fluid/GTFluidBuilder.java @@ -0,0 +1,146 @@ +package gregtech.common.fluid; + +import static gregtech.api.enums.Mods.GregTech; + +import java.util.Locale; + +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.Fluid; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.FluidState; +import gregtech.api.interfaces.fluid.IGTFluid; +import gregtech.api.interfaces.fluid.IGTFluidBuilder; +import gregtech.api.interfaces.fluid.IGTRegisteredFluid; + +public class GTFluidBuilder implements IGTFluidBuilder { + + final String fluidName; + String localizedName; + ResourceLocation stillIconResourceLocation = null, flowingIconResourceLocation = null; + short[] colorRGBA = Dyes._NULL.getRGBA(); + Block fluidBlock = null; + FluidState fluidState; + int temperature; + IIcon stillIcon; + IIcon flowingIcon; + Fluid iconsFrom; + + public GTFluidBuilder(final String fluidName) { + this.fluidName = fluidName.toLowerCase(Locale.ENGLISH); + } + + /** + * @inheritDoc + */ + @Override + public IGTFluidBuilder withColorRGBA(final short[] colorRGBA) { + this.colorRGBA = colorRGBA; + return this; + } + + /** + * @inheritDoc + */ + @Override + public IGTFluidBuilder withLocalizedName(final String localizedName) { + this.localizedName = localizedName; + return this; + } + + /** + * @inheritDoc + */ + @Override + public IGTFluidBuilder withStateAndTemperature(final FluidState fluidState, final int temperature) { + this.fluidState = fluidState; + this.temperature = temperature; + return this; + } + + /** + * @inheritDoc + */ + @Override + public IGTFluidBuilder withStillIconResourceLocation(final ResourceLocation stillIconResourceLocation) { + this.stillIconResourceLocation = stillIconResourceLocation; + return this; + } + + /** + * @inheritDoc + */ + @Override + public IGTFluidBuilder withFlowingIconResourceLocation(final ResourceLocation flowingIconResourceLocation) { + this.flowingIconResourceLocation = flowingIconResourceLocation; + return this; + } + + /** + * @inheritDoc + */ + @Override + public IGTFluidBuilder withTextureName(final String textureName) { + this.stillIconResourceLocation = new ResourceLocation(GregTech.ID, "fluids/fluid." + textureName); + this.flowingIconResourceLocation = null; + return this; + } + + /** + * @inheritDoc + */ + @Override + public IGTFluidBuilder withIconsFrom(@Nonnull final Fluid fromFluid) { + this.iconsFrom = fromFluid; + return this; + } + + /** + * @inheritDoc + */ + @Override + public IGTFluidBuilder withFluidBlock(final Block fluidBlock) { + this.fluidBlock = fluidBlock; + return this; + } + + /** + * @inheritDoc + */ + @Override + public IGTFluidBuilder withTextures(final ResourceLocation stillIconResourceLocation, + final ResourceLocation flowingIconResourceLocation) { + this.stillIconResourceLocation = stillIconResourceLocation; + this.flowingIconResourceLocation = flowingIconResourceLocation; + return this; + } + + /** + * @inheritDoc + */ + @Override + public IGTFluid build() { + if (colorRGBA == null) { + colorRGBA = Dyes._NULL.getRGBA(); + } + if (stillIconResourceLocation == null) { + withTextureName(fluidName.toLowerCase(Locale.ENGLISH)); + } + if (localizedName == null) { + localizedName = fluidName; + } + return new GTFluid(this); + } + + /** + * @inheritDoc + */ + @Override + public IGTRegisteredFluid buildAndRegister() { + return build().addFluid(); + } +} diff --git a/src/main/java/gregtech/common/fluid/GT_Fluid.java b/src/main/java/gregtech/common/fluid/GT_Fluid.java deleted file mode 100644 index 6ba8d7d23a..0000000000 --- a/src/main/java/gregtech/common/fluid/GT_Fluid.java +++ /dev/null @@ -1,209 +0,0 @@ -package gregtech.common.fluid; - -import static gregtech.api.recipe.RecipeMaps.fluidCannerRecipes; - -import javax.annotation.Nonnull; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidContainerRegistry; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.FluidState; -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.Materials; -import gregtech.api.interfaces.fluid.IGT_Fluid; -import gregtech.api.interfaces.fluid.IGT_RegisteredFluid; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_Utility; - -public class GT_Fluid extends Fluid implements IGT_Fluid, IGT_RegisteredFluid, Runnable { - - private final String localizedName; - private final ResourceLocation stillIconResourceLocation; - private final ResourceLocation flowingIconResourceLocation; - private final short[] colorRGBA; - private final FluidState fluidState; - private final Fluid iconsFrom; - private Fluid registeredFluid; - - /** - * Constructs this {@link IGT_Fluid} implementation from an {@link GT_FluidBuilder} instance - * - * @param builder The {@link GT_FluidBuilder} instance to construct this {@link IGT_Fluid} implementation - */ - protected GT_Fluid(@Nonnull final GT_FluidBuilder builder) { - super(builder.fluidName); - this.localizedName = builder.localizedName; - this.stillIconResourceLocation = builder.stillIconResourceLocation; - this.flowingIconResourceLocation = builder.flowingIconResourceLocation; - this.iconsFrom = builder.iconsFrom; - this.block = builder.fluidBlock; - this.colorRGBA = builder.colorRGBA; - this.fluidState = builder.fluidState; - this.temperature = builder.temperature; - configureFromStateTemperature(); - } - - /** - * Adjusts this {@link Fluid}'s settings based on this {@link IGT_Fluid}'s state - */ - protected void configureFromStateTemperature() { - switch (fluidState) { - case SLURRY: - setGaseous(false).setViscosity(10000); - break; - case GAS: - setGaseous(true).setDensity(-100) - .setViscosity(200); - break; - case PLASMA: - setGaseous(true).setDensity(55536) - .setViscosity(10) - .setLuminosity(15); - break; - case MOLTEN: - final int luminosity; - if (temperature >= 3500) { - luminosity = 15; - } else { - luminosity = temperature < 1000 ? 0 : 14 * (temperature - 1000) / 2500 + 1; - } - setLuminosity(luminosity); - case LIQUID: - default: - setGaseous(false).setViscosity(1000); - break; - } - } - - // ----- Fluid implementations ----- - - /** - * @inheritDoc - */ - @Override - public int getColor() { - return (Math.max(0, Math.min(255, colorRGBA[0])) << 16) | (Math.max(0, Math.min(255, colorRGBA[1])) << 8) - | Math.max(0, Math.min(255, colorRGBA[2])); - } - - // ----- IGT_Fluid interface implementations ----- - - public IGT_RegisteredFluid addFluid() { - if (FluidRegistry.registerFluid(GT_Fluid.this)) { - // Registered as a new Fluid - registeredFluid = this; - // Adds a server-side localized-name - GT_LanguageManager.addStringLocalization(getUnlocalizedName(), localizedName); - } else { - // Fluid already registered, get it from the registry - registeredFluid = FluidRegistry.getFluid(GT_Fluid.this.fluidName); - // Sets temperature of already registered fluids if they use the default (temperature = 300) - if (registeredFluid.getTemperature() == new Fluid("test").getTemperature()) { - registeredFluid.setTemperature(GT_Fluid.this.temperature); - } - } - // Schedules the fluid for the block icons loader run() tasks - GregTech_API.sGTBlockIconload.add(this); - return this; - } - - // ----- IGT_RegisteredFluid interface implementations ----- - - /** - * @inheritDoc - */ - @Override - public IGT_RegisteredFluid registerContainers(final ItemStack fullContainer, final ItemStack emptyContainer, - final int containerSize) { - if (fullContainer != null && emptyContainer != null) { - final FluidStack fluidStack = new FluidStack(registeredFluid, containerSize); - if (!FluidContainerRegistry.registerFluidContainer(fluidStack, fullContainer, emptyContainer)) { - GT_Values.RA.stdBuilder() - .itemInputs(fullContainer) - .itemOutputs(GT_Utility.getContainerItem(fullContainer, false)) - .fluidOutputs(fluidStack) - .duration(fluidStack.amount / 62) - .eut(1) - .addTo(fluidCannerRecipes); - } - } - return this; - } - - /** - * @inheritDoc - */ - @Override - public IGT_RegisteredFluid registerBContainers(final ItemStack fullContainer, final ItemStack emptyContainer) { - return registerContainers(fullContainer, emptyContainer, 1000); - } - - /** - * @inheritDoc - */ - @Override - public IGT_RegisteredFluid registerPContainers(final ItemStack fullContainer, final ItemStack emptyContainer) { - return registerContainers(fullContainer, emptyContainer, 250); - } - - /** - * @inheritDoc - */ - @Override - public IGT_RegisteredFluid configureMaterials(final Materials material) { - if (material != null) { - switch (fluidState) { - case SLURRY -> material.mSolid = registeredFluid; - case GAS -> material.mGas = registeredFluid; - case PLASMA -> material.mPlasma = registeredFluid; - case MOLTEN -> material.mStandardMoltenFluid = registeredFluid; - default -> material.mFluid = registeredFluid; - } - Materials.FLUID_MAP.put(registeredFluid, material); - } - return this; - } - - /** - * @inheritDoc - */ - @Override - public Fluid asFluid() { - return registeredFluid; - } - - // ----- Runnable interface implementations ----- - - /** - * This {@link Runnable#run()} implementation is scheduled within the {@link GregTech_API#sGTBlockIconload} to load - * this {@link IGT_Fluid}'s texture icons. - * - * @see Runnable#run() - */ - @Override - public void run() { - if (iconsFrom instanceof GT_Fluid) { - // Needs the GT_Fluid to have registered its icons - ((GT_Fluid) iconsFrom).run(); - stillIcon = iconsFrom.getStillIcon(); - flowingIcon = iconsFrom.getFlowingIcon(); - } else { - if (stillIconResourceLocation != null) { - stillIcon = GregTech_API.sBlockIcons.registerIcon(stillIconResourceLocation.toString()); - } - if (flowingIconResourceLocation != null) { - flowingIcon = GregTech_API.sBlockIcons.registerIcon(flowingIconResourceLocation.toString()); - } - } - } - - @Override - public String toString() { - return "GT_Fluid{" + "fluidName='" + fluidName + '\'' + '}'; - } -} diff --git a/src/main/java/gregtech/common/fluid/GT_FluidBuilder.java b/src/main/java/gregtech/common/fluid/GT_FluidBuilder.java deleted file mode 100644 index 9a18b8d812..0000000000 --- a/src/main/java/gregtech/common/fluid/GT_FluidBuilder.java +++ /dev/null @@ -1,146 +0,0 @@ -package gregtech.common.fluid; - -import static gregtech.api.enums.Mods.GregTech; - -import java.util.Locale; - -import javax.annotation.Nonnull; - -import net.minecraft.block.Block; -import net.minecraft.util.IIcon; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.Fluid; - -import gregtech.api.enums.Dyes; -import gregtech.api.enums.FluidState; -import gregtech.api.interfaces.fluid.IGT_Fluid; -import gregtech.api.interfaces.fluid.IGT_FluidBuilder; -import gregtech.api.interfaces.fluid.IGT_RegisteredFluid; - -public class GT_FluidBuilder implements IGT_FluidBuilder { - - final String fluidName; - String localizedName; - ResourceLocation stillIconResourceLocation = null, flowingIconResourceLocation = null; - short[] colorRGBA = Dyes._NULL.getRGBA(); - Block fluidBlock = null; - FluidState fluidState; - int temperature; - IIcon stillIcon; - IIcon flowingIcon; - Fluid iconsFrom; - - public GT_FluidBuilder(final String fluidName) { - this.fluidName = fluidName.toLowerCase(Locale.ENGLISH); - } - - /** - * @inheritDoc - */ - @Override - public IGT_FluidBuilder withColorRGBA(final short[] colorRGBA) { - this.colorRGBA = colorRGBA; - return this; - } - - /** - * @inheritDoc - */ - @Override - public IGT_FluidBuilder withLocalizedName(final String localizedName) { - this.localizedName = localizedName; - return this; - } - - /** - * @inheritDoc - */ - @Override - public IGT_FluidBuilder withStateAndTemperature(final FluidState fluidState, final int temperature) { - this.fluidState = fluidState; - this.temperature = temperature; - return this; - } - - /** - * @inheritDoc - */ - @Override - public IGT_FluidBuilder withStillIconResourceLocation(final ResourceLocation stillIconResourceLocation) { - this.stillIconResourceLocation = stillIconResourceLocation; - return this; - } - - /** - * @inheritDoc - */ - @Override - public IGT_FluidBuilder withFlowingIconResourceLocation(final ResourceLocation flowingIconResourceLocation) { - this.flowingIconResourceLocation = flowingIconResourceLocation; - return this; - } - - /** - * @inheritDoc - */ - @Override - public IGT_FluidBuilder withTextureName(final String textureName) { - this.stillIconResourceLocation = new ResourceLocation(GregTech.ID, "fluids/fluid." + textureName); - this.flowingIconResourceLocation = null; - return this; - } - - /** - * @inheritDoc - */ - @Override - public IGT_FluidBuilder withIconsFrom(@Nonnull final Fluid fromFluid) { - this.iconsFrom = fromFluid; - return this; - } - - /** - * @inheritDoc - */ - @Override - public IGT_FluidBuilder withFluidBlock(final Block fluidBlock) { - this.fluidBlock = fluidBlock; - return this; - } - - /** - * @inheritDoc - */ - @Override - public IGT_FluidBuilder withTextures(final ResourceLocation stillIconResourceLocation, - final ResourceLocation flowingIconResourceLocation) { - this.stillIconResourceLocation = stillIconResourceLocation; - this.flowingIconResourceLocation = flowingIconResourceLocation; - return this; - } - - /** - * @inheritDoc - */ - @Override - public IGT_Fluid build() { - if (colorRGBA == null) { - colorRGBA = Dyes._NULL.getRGBA(); - } - if (stillIconResourceLocation == null) { - withTextureName(fluidName.toLowerCase(Locale.ENGLISH)); - } - if (localizedName == null) { - localizedName = fluidName; - } - return new GT_Fluid(this); - } - - /** - * @inheritDoc - */ - @Override - public IGT_RegisteredFluid buildAndRegister() { - return build().addFluid(); - } -} -- cgit