diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/gregtech/api/fluid/GT_FluidFactory.java | 1 | ||||
-rw-r--r-- | src/main/java/gregtech/api/interfaces/fluid/IGT_Fluid.java | 12 | ||||
-rw-r--r-- | src/main/java/gregtech/api/interfaces/fluid/IGT_FluidBuilder.java | 1 | ||||
-rw-r--r-- | src/main/java/gregtech/common/fluid/GT_Fluid.java | 93 | ||||
-rw-r--r-- | src/main/java/gregtech/common/fluid/GT_FluidBuilder.java | 22 | ||||
-rw-r--r-- | src/main/resources/assets/gregtech/textures/blocks/fluids/fluid.molten.autogenerated.png | bin | 1558 -> 2267 bytes |
6 files changed, 72 insertions, 57 deletions
diff --git a/src/main/java/gregtech/api/fluid/GT_FluidFactory.java b/src/main/java/gregtech/api/fluid/GT_FluidFactory.java index 0db1aec7e6..4aa39095ec 100644 --- a/src/main/java/gregtech/api/fluid/GT_FluidFactory.java +++ b/src/main/java/gregtech/api/fluid/GT_FluidFactory.java @@ -29,6 +29,7 @@ import net.minecraftforge.fluids.FluidRegistry; * </li> * </ol> */ +@SuppressWarnings("unused") // API might legitimately expose unused methods within this local project's scope public class GT_FluidFactory { /** diff --git a/src/main/java/gregtech/api/interfaces/fluid/IGT_Fluid.java b/src/main/java/gregtech/api/interfaces/fluid/IGT_Fluid.java index 1a34b44b5a..5529e111bb 100644 --- a/src/main/java/gregtech/api/interfaces/fluid/IGT_Fluid.java +++ b/src/main/java/gregtech/api/interfaces/fluid/IGT_Fluid.java @@ -8,10 +8,11 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; +@SuppressWarnings("unused") // API might legitimately expose unused methods within this local project's scope public interface IGT_Fluid { /** - * Registers this {@link IGT_Fluid} to ths {@link FluidRegistry} + * Adds this {@link IGT_Fluid} to the {@link FluidRegistry} and internally-implemented registrations * * @return {@link IGT_Fluid} self for call chaining */ @@ -24,6 +25,8 @@ public interface IGT_Fluid { * @param emptyContainer The empty fluid container * @param containerSize The size of the container * @return The {@link IGT_Fluid} for chaining + * + * @throws IllegalStateException on attempt to register containers for an unregistered fluid */ IGT_Fluid registerContainers( final ItemStack fullContainer, final ItemStack emptyContainer, final int containerSize); @@ -34,6 +37,8 @@ public interface IGT_Fluid { * @param fullContainer The full container to associate with this {@link IGT_Fluid} * @param emptyContainer The empty container associate with this {@link IGT_Fluid} * @return {@link IGT_Fluid} self for call chaining + * + * @throws IllegalStateException on attempt to register containers for an unregistered fluid */ IGT_Fluid registerBContainers(final ItemStack fullContainer, final ItemStack emptyContainer); @@ -43,6 +48,8 @@ public interface IGT_Fluid { * @param fullContainer The full container to associate with this {@link IGT_Fluid} * @param emptyContainer The empty container associate with this {@link IGT_Fluid} * @return {@link IGT_Fluid} self for call chaining + * + * @throws IllegalStateException on attempt to register containers for an unregistered fluid */ IGT_Fluid registerPContainers(final ItemStack fullContainer, final ItemStack emptyContainer); @@ -51,6 +58,9 @@ public interface IGT_Fluid { * * @param material the {@link Materials} to configure based on this {@link IGT_Fluid} and {@link FluidState} * @return The {@link IGT_Fluid} for chaining + * + * @throws IllegalStateException on unknown {@link FluidState} + * @throws IllegalStateException on attempt to register containers for an unregistered fluid */ IGT_Fluid configureMaterials(final Materials material); diff --git a/src/main/java/gregtech/api/interfaces/fluid/IGT_FluidBuilder.java b/src/main/java/gregtech/api/interfaces/fluid/IGT_FluidBuilder.java index 1e5ec60fa0..4010a465ce 100644 --- a/src/main/java/gregtech/api/interfaces/fluid/IGT_FluidBuilder.java +++ b/src/main/java/gregtech/api/interfaces/fluid/IGT_FluidBuilder.java @@ -6,6 +6,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; +@SuppressWarnings("unused") // API might legitimately expose unused methods within this local project's scope public interface IGT_FluidBuilder { /** * @param colorRGBA The {@code short[]} RGBA color of the {@link Fluid} or {@code null} for no defined RGBA color diff --git a/src/main/java/gregtech/common/fluid/GT_Fluid.java b/src/main/java/gregtech/common/fluid/GT_Fluid.java index 4e4131bb2f..6d5231fe00 100644 --- a/src/main/java/gregtech/common/fluid/GT_Fluid.java +++ b/src/main/java/gregtech/common/fluid/GT_Fluid.java @@ -22,6 +22,7 @@ public class GT_Fluid extends Fluid implements IGT_Fluid, Runnable { private final short[] colorRGBA; private final FluidState fluidState; private final int temperature; + private Fluid registeredFluid; /** * Constructs this {@link IGT_Fluid} implementation from an {@link GT_FluidBuilder} instance @@ -41,7 +42,7 @@ public class GT_Fluid extends Fluid implements IGT_Fluid, Runnable { } /** - * @inheritDoc from {@link Fluid#getColor()} + * @inheritDoc */ @Override public int getColor() { @@ -54,7 +55,7 @@ public class GT_Fluid extends Fluid implements IGT_Fluid, Runnable { * This {@link Runnable#run()} implementation is scheduled within the {@link GregTech_API#sGTBlockIconload} * to load this {@link IGT_Fluid}'s texture icons. * - * @inheritDoc from {@link Runnable#run()} + * @see Runnable#run() */ @Override public void run() { @@ -68,29 +69,40 @@ public class GT_Fluid extends Fluid implements IGT_Fluid, Runnable { } /** - * @inheritDoc from {@link IGT_Fluid#addFluid()} + * @inheritDoc */ @Override public IGT_Fluid addFluid() { - // Adds self the block icons loader run() tasks - GregTech_API.sGTBlockIconload.add(this); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(), localizedName); - final Fluid registeredFluid = registerFluid(); - if (registeredFluid.getTemperature() == new Fluid("test").getTemperature()) { - registeredFluid.setTemperature(temperature); + if (FluidRegistry.registerFluid(this)) { + // Registered as a new Fluid + // Adds self as Runnable to the block icons loader run() tasks + GregTech_API.sGTBlockIconload.add(this); + // Adds a server-side localized-name + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(), localizedName); + registeredFluid = this; + } else { + // Promotes Fluid from the registry to enable GT_Fluid methods + registeredFluid = FluidRegistry.getFluid(fluidName); + // Sets temperature of already registered fluids if they use the default (temperature = 300) + if (registeredFluid.getTemperature() == new Fluid("test").getTemperature()) { + registeredFluid.setTemperature(temperature); + } } return this; } /** - * @inheritDoc from {@link IGT_Fluid#registerContainers(ItemStack, ItemStack, int)} + * @inheritDoc */ @Override public IGT_Fluid registerContainers( final ItemStack fullContainer, final ItemStack emptyContainer, final int containerSize) { if (fullContainer == null || emptyContainer == null) return this; - final FluidStack fluidStack = new FluidStack(this, containerSize); + if (registeredFluid == null) { + throw new IllegalStateException("Cannot register containers for an unregistered fluid"); + } + final FluidStack fluidStack = new FluidStack(registeredFluid, containerSize); if (!FluidContainerRegistry.registerFluidContainer(fluidStack, fullContainer, emptyContainer)) { GT_Values.RA.addFluidCannerRecipe( fullContainer, GT_Utility.getContainerItem(fullContainer, false), null, fluidStack); @@ -99,7 +111,7 @@ public class GT_Fluid extends Fluid implements IGT_Fluid, Runnable { } /** - * @inheritDoc from {@link IGT_Fluid#registerBContainers(ItemStack, ItemStack)} + * @inheritDoc */ @Override public IGT_Fluid registerBContainers(final ItemStack fullContainer, final ItemStack emptyContainer) { @@ -107,7 +119,7 @@ public class GT_Fluid extends Fluid implements IGT_Fluid, Runnable { } /** - * @inheritDoc from {@link IGT_Fluid#registerPContainers(ItemStack, ItemStack)} + * @inheritDoc */ @Override public IGT_Fluid registerPContainers(final ItemStack fullContainer, final ItemStack emptyContainer) { @@ -115,7 +127,7 @@ public class GT_Fluid extends Fluid implements IGT_Fluid, Runnable { } /** - * @inheritDoc from {@link IGT_Fluid#getStillIconResourceLocation()} + * @inheritDoc */ @Override public ResourceLocation getStillIconResourceLocation() { @@ -123,7 +135,7 @@ public class GT_Fluid extends Fluid implements IGT_Fluid, Runnable { } /** - * @inheritDoc from {@link IGT_Fluid#getFlowingIconResourceLocation()} + * @inheritDoc */ @Override public ResourceLocation getFlowingIconResourceLocation() { @@ -131,26 +143,29 @@ public class GT_Fluid extends Fluid implements IGT_Fluid, Runnable { } /** - * @throws IllegalStateException if {@link FluidState} in invalid - * @inheritDoc from {@link IGT_Fluid#configureMaterials(Materials)} + * @inheritDoc */ @Override public IGT_Fluid configureMaterials(final Materials material) { + if (registeredFluid == null) { + throw new IllegalStateException("Cannot configure Materials with an unregistered fluid"); + } + switch (fluidState) { case SLURRY: - material.mSolid = this; + material.mSolid = registeredFluid; break; case LIQUID: - material.mFluid = this; + material.mFluid = registeredFluid; break; case GAS: - material.mGas = this; + material.mGas = registeredFluid; break; case PLASMA: - material.mPlasma = this; + material.mPlasma = registeredFluid; break; case MOLTEN: - material.mStandardMoltenFluid = this; + material.mStandardMoltenFluid = registeredFluid; break; default: throw new IllegalStateException("Unexpected FluidState: " + fluidState); @@ -159,49 +174,37 @@ public class GT_Fluid extends Fluid implements IGT_Fluid, Runnable { } /** - * @inheritDoc from {@link IGT_Fluid#asFluid()} + * @inheritDoc */ @Override public Fluid asFluid() { - return this; + return registeredFluid == null ? this : registeredFluid; } /** * Adjusts this {@link Fluid}'s settings based on this {@link IGT_Fluid}'s state * - * @throws IllegalStateException if {@link FluidState} in invalid + * @throws IllegalStateException if {@link FluidState} is unknown */ protected void configureFromStateTemperature() { switch (fluidState) { - case SLURRY: // Solid + case SLURRY: setGaseous(false).setViscosity(10000); break; - case LIQUID: // Fluid - case MOLTEN: // Molten - setGaseous(false) - .setViscosity(1000) - .setLuminosity( - temperature >= 5000 - ? 15 - : temperature < 1000 ? 0 : 14 * (temperature - 1000) / 4000 + 1); + case LIQUID: + case MOLTEN: + final int luminosity = + temperature >= 3500 ? 15 : temperature < 1000 ? 0 : 14 * (temperature - 1000) / 2500 + 1; + setGaseous(false).setViscosity(1000).setLuminosity(luminosity); break; - case GAS: // Gas + case GAS: setGaseous(true).setDensity(-100).setViscosity(200); break; - case PLASMA: // Plasma + case PLASMA: setGaseous(true).setDensity(55536).setViscosity(10).setLuminosity(15); break; default: throw new IllegalStateException("Unexpected FluidState: " + fluidState); } } - - /** - * Registers this {@link IGT_Fluid} to the {@link FluidRegistry} - * - * @return the {@link Fluid} from the {@link FluidRegistry} - */ - protected Fluid registerFluid() { - return FluidRegistry.registerFluid(this) ? this : FluidRegistry.getFluid(this.fluidName); - } } diff --git a/src/main/java/gregtech/common/fluid/GT_FluidBuilder.java b/src/main/java/gregtech/common/fluid/GT_FluidBuilder.java index 91db377ce0..b484f7aacb 100644 --- a/src/main/java/gregtech/common/fluid/GT_FluidBuilder.java +++ b/src/main/java/gregtech/common/fluid/GT_FluidBuilder.java @@ -24,7 +24,7 @@ public class GT_FluidBuilder implements IGT_FluidBuilder { } /** - * @inheritDoc from {@link IGT_FluidBuilder#withColorRGBA(short[])} + * @inheritDoc */ @Override public IGT_FluidBuilder withColorRGBA(final short[] colorRGBA) { @@ -33,7 +33,7 @@ public class GT_FluidBuilder implements IGT_FluidBuilder { } /** - * @inheritDoc from {@link IGT_FluidBuilder#withLocalizedName(String)} + * @inheritDoc */ @Override public IGT_FluidBuilder withLocalizedName(final String localizedName) { @@ -42,7 +42,7 @@ public class GT_FluidBuilder implements IGT_FluidBuilder { } /** - * @inheritDoc from {@link IGT_FluidBuilder#withStateAndTemperature(FluidState, int)} + * @inheritDoc */ @Override public IGT_FluidBuilder withStateAndTemperature(final FluidState fluidState, final int temperature) { @@ -52,7 +52,7 @@ public class GT_FluidBuilder implements IGT_FluidBuilder { } /** - * @inheritDoc from {@link IGT_FluidBuilder#withStillIconResourceLocation(ResourceLocation)} + * @inheritDoc */ @Override public IGT_FluidBuilder withStillIconResourceLocation(final ResourceLocation stillIconResourceLocation) { @@ -61,7 +61,7 @@ public class GT_FluidBuilder implements IGT_FluidBuilder { } /** - * @inheritDoc from {@link IGT_FluidBuilder#withFlowingIconResourceLocation(ResourceLocation)} + * @inheritDoc */ @Override public IGT_FluidBuilder withFlowingIconResourceLocation(final ResourceLocation flowingIconResourceLocation) { @@ -70,7 +70,7 @@ public class GT_FluidBuilder implements IGT_FluidBuilder { } /** - * @inheritDoc from {@link IGT_FluidBuilder#withTextureName(String)} + * @inheritDoc */ @Override public IGT_FluidBuilder withTextureName(final String textureName) { @@ -80,7 +80,7 @@ public class GT_FluidBuilder implements IGT_FluidBuilder { } /** - * @inheritDoc from {@link IGT_FluidBuilder#withTextureFrom(IGT_Fluid)} + * @inheritDoc */ @Override public IGT_FluidBuilder withTextureFrom(final IGT_Fluid fromGTFluid) { @@ -90,7 +90,7 @@ public class GT_FluidBuilder implements IGT_FluidBuilder { } /** - * @inheritDoc from {@link IGT_FluidBuilder#withFluidBlock} + * @inheritDoc */ @Override public IGT_FluidBuilder withFluidBlock(final Block fluidBlock) { @@ -99,7 +99,7 @@ public class GT_FluidBuilder implements IGT_FluidBuilder { } /** - * @inheritDoc from {@link IGT_FluidBuilder#withTextures(ResourceLocation, ResourceLocation)} + * @inheritDoc */ @Override public IGT_FluidBuilder withTextures( @@ -110,7 +110,7 @@ public class GT_FluidBuilder implements IGT_FluidBuilder { } /** - * @inheritDoc from {@link IGT_FluidBuilder#build() + * @inheritDoc */ @Override public IGT_Fluid build() { @@ -121,7 +121,7 @@ public class GT_FluidBuilder implements IGT_FluidBuilder { } /** - * @inheritDoc from {@link IGT_FluidBuilder#buildAndRegister() + * @inheritDoc */ @Override public IGT_Fluid buildAndRegister() { diff --git a/src/main/resources/assets/gregtech/textures/blocks/fluids/fluid.molten.autogenerated.png b/src/main/resources/assets/gregtech/textures/blocks/fluids/fluid.molten.autogenerated.png Binary files differindex ee40545a46..a792bee413 100644 --- a/src/main/resources/assets/gregtech/textures/blocks/fluids/fluid.molten.autogenerated.png +++ b/src/main/resources/assets/gregtech/textures/blocks/fluids/fluid.molten.autogenerated.png |