From 04f8246f0701d2a1802a3a0e8660055fc7966d6b Mon Sep 17 00:00:00 2001 From: jude123412 <104434396+jude123412@users.noreply.github.com> Date: Sat, 21 Dec 2024 16:43:28 +0000 Subject: [PATCH] SpotlessCheck and SpotlessApply Run ./gradlew :spotlessCheck --warning-mode all --build-cache and ./gradlew :spotlessApply --warning-mode all to fix and clean code --- src/main/java/gregtech/GregTechMod.java | 4 +- .../items/materialitem/MetaPrefixItem.java | 61 +++++---- .../gregtech/api/items/metaitem/MetaItem.java | 122 ++++++++++-------- .../api/unification/material/Material.java | 35 +++-- .../material/properties/CosmicProperty.java | 14 +- .../renderer/item/CosmicItemRenderer.java | 70 +++++----- 6 files changed, 167 insertions(+), 139 deletions(-) diff --git a/src/main/java/gregtech/GregTechMod.java b/src/main/java/gregtech/GregTechMod.java index a7cc4eada78..72b7f528cdf 100644 --- a/src/main/java/gregtech/GregTechMod.java +++ b/src/main/java/gregtech/GregTechMod.java @@ -1,7 +1,5 @@ package gregtech; -import codechicken.lib.texture.TextureUtils; - import gregtech.api.GTValues; import gregtech.api.GregTechAPI; import gregtech.api.items.metaitem.MetaItem; @@ -31,6 +29,8 @@ import net.minecraftforge.fml.common.event.FMLServerStoppedEvent; import net.minecraftforge.fml.common.event.FMLServerStoppingEvent; +import codechicken.lib.texture.TextureUtils; + import static gregtech.api.util.Mods.Avaritia; @Mod(modid = GTValues.MODID, diff --git a/src/main/java/gregtech/api/items/materialitem/MetaPrefixItem.java b/src/main/java/gregtech/api/items/materialitem/MetaPrefixItem.java index ad8ed82b3e8..a2fe30037be 100644 --- a/src/main/java/gregtech/api/items/materialitem/MetaPrefixItem.java +++ b/src/main/java/gregtech/api/items/materialitem/MetaPrefixItem.java @@ -1,13 +1,10 @@ package gregtech.api.items.materialitem; -import codechicken.lib.model.ModelRegistryHelper; -import codechicken.lib.util.TransformUtils; - import gregtech.api.GTValues; import gregtech.api.damagesources.DamageSources; import gregtech.api.items.armor.ArmorMetaItem; -import gregtech.api.items.metaitem.StandardMetaItem; import gregtech.api.items.metaitem.MetaItem.MetaValueItem.CosmicTexture; +import gregtech.api.items.metaitem.StandardMetaItem; import gregtech.api.unification.OreDictUnifier; import gregtech.api.unification.material.Material; import gregtech.api.unification.material.Materials; @@ -19,15 +16,9 @@ import gregtech.api.unification.material.registry.MaterialRegistry; import gregtech.api.unification.ore.OrePrefix; import gregtech.api.unification.stack.UnificationEntry; -import gregtech.common.creativetab.GTCreativeTabs; - import gregtech.api.util.Mods; import gregtech.client.renderer.item.CosmicItemRenderer; - -import morph.avaritia.api.ICosmicRenderItem; -import morph.avaritia.api.IHaloRenderItem; -import morph.avaritia.api.registration.IModelRegister; -import morph.avaritia.init.AvaritiaTextures; +import gregtech.common.creativetab.GTCreativeTabs; import net.minecraft.block.BlockCauldron; import net.minecraft.block.state.IBlockState; @@ -48,7 +39,13 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import codechicken.lib.model.ModelRegistryHelper; +import codechicken.lib.util.TransformUtils; import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap; +import morph.avaritia.api.ICosmicRenderItem; +import morph.avaritia.api.IHaloRenderItem; +import morph.avaritia.api.registration.IModelRegister; +import morph.avaritia.init.AvaritiaTextures; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -57,19 +54,19 @@ import static gregtech.api.util.Mods.Avaritia; @Optional.Interface( - modid = Mods.Names.AVARITIA, - iface = "morph.avaritia.api.ICosmicRenderItem") + modid = Mods.Names.AVARITIA, + iface = "morph.avaritia.api.ICosmicRenderItem") @Optional.Interface( - modid = Mods.Names.AVARITIA, - iface = "morph.avaritia.api.IHaloRenderItem") + modid = Mods.Names.AVARITIA, + iface = "morph.avaritia.api.IHaloRenderItem") @Optional.Interface( - modid = Mods.Names.AVARITIA, - iface = "morph.avaritia.api.registration.IModelRegister") + modid = Mods.Names.AVARITIA, + iface = "morph.avaritia.api.registration.IModelRegister") @Optional.Interface( - modid = Mods.Names.AVARITIA, - iface = "morph.avaritia.init.AvaritiaTextures") + modid = Mods.Names.AVARITIA, + iface = "morph.avaritia.init.AvaritiaTextures") public class MetaPrefixItem extends StandardMetaItem implements IHaloRenderItem, ICosmicRenderItem, - IModelRegister { + IModelRegister { private final MaterialRegistry registry; private final OrePrefix prefix; @@ -154,10 +151,10 @@ public void registerModels() { ModelBakery.registerItemVariants(this, resourceLocation); alreadyRegistered.put(registrationKey, new ModelResourceLocation(resourceLocation, "inventory")); - if (Avaritia.isModLoaded()) { ModelResourceLocation location = new ModelResourceLocation(resourceLocation, "inventory"); - IBakedModel wrapped = new CosmicItemRenderer(TransformUtils.DEFAULT_ITEM, (modelRegistry) -> modelRegistry.getObject(location)); + IBakedModel wrapped = new CosmicItemRenderer(TransformUtils.DEFAULT_ITEM, + (modelRegistry) -> modelRegistry.getObject(location)); ModelRegistryHelper.register(location, wrapped); String processedLocation = resourceLocation.toString().replace("gregtech:", "gregtech:items/"); @@ -312,9 +309,9 @@ protected void addMaterialTooltip(@NotNull List lines, @NotNull ItemStac } } - @Override @SideOnly(Side.CLIENT) + @Override + @SideOnly(Side.CLIENT) public boolean shouldDrawHalo(ItemStack stack) { - Material material = getMaterial(stack); assert material != null; @@ -327,9 +324,9 @@ public boolean shouldDrawHalo(ItemStack stack) { } } - @Override @SideOnly(Side.CLIENT) + @Override + @SideOnly(Side.CLIENT) public TextureAtlasSprite getHaloTexture(ItemStack stack) { - Material material = getMaterial(stack); assert material != null; @@ -342,9 +339,9 @@ public TextureAtlasSprite getHaloTexture(ItemStack stack) { } } - @Override @SideOnly(Side.CLIENT) + @Override + @SideOnly(Side.CLIENT) public int getHaloColour(ItemStack stack) { - Material material = getMaterial(stack); assert material != null; @@ -357,9 +354,9 @@ public int getHaloColour(ItemStack stack) { } } - @Override @SideOnly(Side.CLIENT) + @Override + @SideOnly(Side.CLIENT) public int getHaloSize(ItemStack stack) { - Material material = getMaterial(stack); assert material != null; @@ -370,10 +367,10 @@ public int getHaloSize(ItemStack stack) { } else { return 0; } - } - @Override @SideOnly(Side.CLIENT) + @Override + @SideOnly(Side.CLIENT) public boolean shouldDrawPulse(ItemStack stack) { Material material = getMaterial(stack); assert material != null; diff --git a/src/main/java/gregtech/api/items/metaitem/MetaItem.java b/src/main/java/gregtech/api/items/metaitem/MetaItem.java index 2e08f0ed923..bc10af80e74 100644 --- a/src/main/java/gregtech/api/items/metaitem/MetaItem.java +++ b/src/main/java/gregtech/api/items/metaitem/MetaItem.java @@ -1,9 +1,5 @@ package gregtech.api.items.metaitem; -import codechicken.lib.model.ModelRegistryHelper; -import codechicken.lib.texture.TextureUtils; -import codechicken.lib.util.TransformUtils; - import gregtech.api.GTValues; import gregtech.api.capability.GregtechCapabilities; import gregtech.api.capability.IElectricItem; @@ -41,11 +37,6 @@ import gregtech.common.covers.filter.IFilter; import gregtech.common.creativetab.GTCreativeTabs; -import morph.avaritia.api.ICosmicRenderItem; -import morph.avaritia.api.IHaloRenderItem; -import morph.avaritia.api.registration.IModelRegister; -import morph.avaritia.init.AvaritiaTextures; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ModelBakery; @@ -86,6 +77,9 @@ import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.oredict.OreDictionary; +import codechicken.lib.model.ModelRegistryHelper; +import codechicken.lib.texture.TextureUtils; +import codechicken.lib.util.TransformUtils; import com.enderio.core.common.interfaces.IOverlayRenderAware; import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableList; @@ -95,6 +89,10 @@ import it.unimi.dsi.fastutil.shorts.Short2ObjectLinkedOpenHashMap; import it.unimi.dsi.fastutil.shorts.Short2ObjectMap; import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap; +import morph.avaritia.api.ICosmicRenderItem; +import morph.avaritia.api.IHaloRenderItem; +import morph.avaritia.api.registration.IModelRegister; +import morph.avaritia.init.AvaritiaTextures; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -129,23 +127,23 @@ * rechargeable) LV battery with initial capacity 10000 EU */ @Optional.Interface( - modid = Mods.Names.ENDER_CORE, - iface = "com.enderio.core.common.interfaces.IOverlayRenderAware") + modid = Mods.Names.ENDER_CORE, + iface = "com.enderio.core.common.interfaces.IOverlayRenderAware") @Optional.Interface( - modid = Mods.Names.AVARITIA, - iface = "morph.avaritia.api.ICosmicRenderItem") + modid = Mods.Names.AVARITIA, + iface = "morph.avaritia.api.ICosmicRenderItem") @Optional.Interface( - modid = Mods.Names.AVARITIA, - iface = "morph.avaritia.api.IHaloRenderItem") + modid = Mods.Names.AVARITIA, + iface = "morph.avaritia.api.IHaloRenderItem") @Optional.Interface( - modid = Mods.Names.AVARITIA, - iface = "morph.avaritia.api.registration.IModelRegister") + modid = Mods.Names.AVARITIA, + iface = "morph.avaritia.api.registration.IModelRegister") @Optional.Interface( - modid = Mods.Names.AVARITIA, - iface = "morph.avaritia.init.AvaritiaTextures") + modid = Mods.Names.AVARITIA, + iface = "morph.avaritia.init.AvaritiaTextures") public abstract class MetaItem.MetaValueItem> extends Item - implements ItemUIFactory, IOverlayRenderAware, IHaloRenderItem, ICosmicRenderItem, - IModelRegister { + implements ItemUIFactory, IOverlayRenderAware, IHaloRenderItem, ICosmicRenderItem, + IModelRegister { private static final List> META_ITEMS = new ArrayList<>(); @@ -646,7 +644,6 @@ public String getItemStackDisplayName(ItemStack stack) { return super.getItemStackDisplayName(stack); } - @Override @SideOnly(Side.CLIENT) public void addInformation(@NotNull ItemStack itemStack, @Nullable World worldIn, @NotNull List lines, @@ -807,16 +804,18 @@ public void renderItemOverlayIntoGUI(@NotNull ItemStack stack, int xPosition, in ToolChargeBarRenderer.renderBarsItem(this, stack, xPosition, yPosition); } - @Override @SideOnly(Side.CLIENT) + @Override + @SideOnly(Side.CLIENT) public boolean shouldDrawHalo(ItemStack stack) { T metaValueItem = getItem(stack); - if (metaValueItem == null){ + if (metaValueItem == null) { return false; } return metaValueItem.registerHalo(stack); } - @Override @SideOnly(Side.CLIENT) + @Override + @SideOnly(Side.CLIENT) public TextureAtlasSprite getHaloTexture(ItemStack stack) { T metaValueItem = getItem(stack); if (metaValueItem.registerHaloTexture(stack) == null) { @@ -825,28 +824,31 @@ public TextureAtlasSprite getHaloTexture(ItemStack stack) { return MetaValueItem.CosmicTexture.haloTextures.get(metaValueItem.registerHaloTexture(stack)); } - @Override @SideOnly(Side.CLIENT) + @Override + @SideOnly(Side.CLIENT) public int getHaloColour(ItemStack stack) { T metaValueItem = getItem(stack); - if (metaValueItem == null){ + if (metaValueItem == null) { return 0; } return Integer.decode("0x7F" + metaValueItem.registerHaloColour(stack)); } - @Override @SideOnly(Side.CLIENT) + @Override + @SideOnly(Side.CLIENT) public int getHaloSize(ItemStack stack) { T metaValueItem = getItem(stack); - if (metaValueItem == null){ + if (metaValueItem == null) { return 0; } return metaValueItem.registerHaloSize(stack); } - @Override @SideOnly(Side.CLIENT) + @Override + @SideOnly(Side.CLIENT) public boolean shouldDrawPulse(ItemStack stack) { T metaValueItem = getItem(stack); - if (metaValueItem == null){ + if (metaValueItem == null) { return false; } return metaValueItem.registerHaloPulse(stack); @@ -864,7 +866,7 @@ public TextureAtlasSprite getMaskTexture(ItemStack stack, EntityLivingBase playe @SideOnly(Side.CLIENT) public float getMaskOpacity(ItemStack stack, EntityLivingBase player) { T metaValueItem = getItem(stack); - if (metaValueItem == null){ + if (metaValueItem == null) { return 0.0f; } return metaValueItem.registerMaskOpacity(stack); @@ -1003,18 +1005,25 @@ public MetaValueItem addComponents(IItemComponent... stats) { /** * This function requires the latest version of Avaritia to be Installed - * ... + * ... * - * @param shouldDrawHalo enables the Halo effect for a specified MetaItem.
- * @param haloTexture the Halo Texture for a specified MetaItem in the form of a String : Example "halo".
- * @param haloColour the Colour the Halo will have in the form of a Hex String : Example "00FF00" (hex color for green).
- * @param haloSize The size of the halo : Example 10.
+ * @param shouldDrawHalo enables the Halo effect for a specified MetaItem.
+ * @param haloTexture the Halo Texture for a specified MetaItem in the form of a String : Example + * "halo".
+ * @param haloColour the Colour the Halo will have in the form of a Hex String : Example "00FF00" (hex + * color for green).
+ * @param haloSize The size of the halo : Example 10.
* @param shouldDrawPulse Whether the MetaItem will pulse like Avaritia's Infinity Ingot : Example true.
- * @param maskTexture The String Location of the Mask texture the MetaItem will use as a Cosmic Effect : Example "nan".
- * @param maskOpacity The Opacity of the Cosmic Effect, Use in combination with maskTexture : Example 1.0f.
+ * @param maskTexture The String Location of the Mask texture the MetaItem will use as a Cosmic Effect : + * Example "nan".
+ * @param maskOpacity The Opacity of the Cosmic Effect, Use in combination with maskTexture : Example + * 1.0f.
*/ @Optional.Method(modid = Mods.Names.AVARITIA) - public MetaValueItem cosmicProperties(boolean shouldDrawHalo, String haloTexture, String haloColour, int haloSize, boolean shouldDrawPulse, String maskTexture, float maskOpacity) { + public MetaValueItem cosmicProperties(boolean shouldDrawHalo, String haloTexture, String haloColour, + int haloSize, boolean shouldDrawPulse, String maskTexture, + float maskOpacity) { if (Avaritia.isModLoaded()) { this.drawHalo = shouldDrawHalo; this.haloPath = haloTexture; @@ -1038,7 +1047,8 @@ public MetaValueItem cosmicProperties(boolean shouldDrawHalo, String haloTexture } @Optional.Method(modid = Mods.Names.AVARITIA) - public MetaValueItem cosmicProperties(boolean shouldDrawHalo, String haloTexture, String haloColour, int haloSize, String maskTexture, float maskOpacity) { + public MetaValueItem cosmicProperties(boolean shouldDrawHalo, String haloTexture, String haloColour, + int haloSize, String maskTexture, float maskOpacity) { if (Avaritia.isModLoaded()) { this.drawHalo = shouldDrawHalo; this.haloPath = haloTexture; @@ -1061,7 +1071,8 @@ public MetaValueItem cosmicProperties(boolean shouldDrawHalo, String haloTexture } @Optional.Method(modid = Mods.Names.AVARITIA) - public MetaValueItem cosmicProperties(boolean shouldDrawHalo, String haloTexture, String haloColour, int haloSize, boolean shouldDrawPulse) { + public MetaValueItem cosmicProperties(boolean shouldDrawHalo, String haloTexture, String haloColour, + int haloSize, boolean shouldDrawPulse) { if (Avaritia.isModLoaded()) { this.drawHalo = shouldDrawHalo; this.haloPath = haloTexture; @@ -1077,7 +1088,8 @@ public MetaValueItem cosmicProperties(boolean shouldDrawHalo, String haloTexture } @Optional.Method(modid = Mods.Names.AVARITIA) - public MetaValueItem cosmicProperties(boolean shouldDrawHalo, String haloTexture, String haloColour, int haloSize) { + public MetaValueItem cosmicProperties(boolean shouldDrawHalo, String haloTexture, String haloColour, + int haloSize) { if (Avaritia.isModLoaded()) { this.drawHalo = shouldDrawHalo; this.haloPath = haloTexture; @@ -1112,7 +1124,6 @@ public MetaValueItem cosmicProperties(boolean shouldDrawPulse) { return this; } - protected void addItemComponentsInternal(IItemComponent... stats) { for (IItemComponent itemComponent : stats) { if (itemComponent instanceof IItemNameProvider) { @@ -1324,36 +1335,36 @@ public String toString() { .toString(); } - public boolean registerHalo (ItemStack stack) { + public boolean registerHalo(ItemStack stack) { return drawHalo; } public String registerHaloTexture(ItemStack stack) { return haloPath; - } - public String registerHaloColour (ItemStack stack) { + public String registerHaloColour(ItemStack stack) { return haloColour; } - public int registerHaloSize (ItemStack stack) { + public int registerHaloSize(ItemStack stack) { return haloSize; } - public boolean registerHaloPulse (ItemStack stack) { + public boolean registerHaloPulse(ItemStack stack) { return haloPulse; } - public String registerMaskTexture (ItemStack stack) { + public String registerMaskTexture(ItemStack stack) { return maskPath; } - public float registerMaskOpacity (ItemStack stack) { + public float registerMaskOpacity(ItemStack stack) { return maskOpacity; } public static class CosmicTexture implements TextureUtils.IIconRegister { + public static Map haloTextures = new HashMap<>(); public static Map maskTextures = new HashMap<>(); public static Map specialMaskTextures = new HashMap<>(); @@ -1376,15 +1387,18 @@ public static void registerSpecialMaskIcon(String stack, String path) { @Override public void registerIcons(TextureMap textureMap) { haloPath.forEach(halo -> { - haloTextures.put(halo, textureMap.registerSprite(new ResourceLocation("gregtech:items/cosmic/halo/" + halo))); + haloTextures.put(halo, + textureMap.registerSprite(new ResourceLocation("gregtech:items/cosmic/halo/" + halo))); }); cosmicPath.forEach(mask -> { - maskTextures.put(mask, textureMap.registerSprite(new ResourceLocation("gregtech:items/cosmic/mask/" + mask))); + maskTextures.put(mask, + textureMap.registerSprite(new ResourceLocation("gregtech:items/cosmic/mask/" + mask))); }); specialCosmicPath.forEach((key, value) -> { specialMaskTextures.put(key, textureMap.registerSprite(new ResourceLocation(value))); - specialMaskTextures.put("fallback", textureMap.registerSprite(new ResourceLocation("gregtech:items/cosmic/mask/fallback"))); + specialMaskTextures.put("fallback", + textureMap.registerSprite(new ResourceLocation("gregtech:items/cosmic/mask/fallback"))); }); } } diff --git a/src/main/java/gregtech/api/unification/material/Material.java b/src/main/java/gregtech/api/unification/material/Material.java index b2f5976bd71..9ec9b93f41b 100644 --- a/src/main/java/gregtech/api/unification/material/Material.java +++ b/src/main/java/gregtech/api/unification/material/Material.java @@ -39,13 +39,11 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fml.common.Optional; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import crafttweaker.annotations.ZenRegister; - -import net.minecraftforge.fml.common.Optional; - import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -835,18 +833,26 @@ public Builder polymer(int harvestLevel) { /** * Add a {@link CosmicProperty} to this Material.
* This function requires the latest version of Avaritia to be Installed - * ... - * @param shouldDrawHalo enables the Halo effect for a specified Material.
- * @param haloTexture the Halo Texture for a specific Material in the form of a String : Example "halo".
- * @param haloColour the Colour the Halo will have in the form of a Hex String : Example "00FF00" (hex color for green).
- * @param haloSize The size of the halo : Example 10.
- * @param shouldDrawPulse If the Material Item will pulse like Avaritia's Infinity Ingot : Example true.
+ * ... + * + * @param shouldDrawHalo enables the Halo effect for a specified Material.
+ * @param haloTexture the Halo Texture for a specific Material in the form of a String : Example + * "halo".
+ * @param haloColour the Colour the Halo will have in the form of a Hex String : Example "00FF00" (hex + * color for green).
+ * @param haloSize The size of the halo : Example 10.
+ * @param shouldDrawPulse If the Material Item will pulse like Avaritia's Infinity Ingot : Example true.
* @param shouldDrawCosmic If the Material Item will have Avaritia's Cosmic Effect : Example true.
- * All the locations for these are autogenerated and follow the same path as the MaterialIconSet the material uses: Example "gregtech:textures/items/material_sets/dull/dust_mask - * @param maskOpacity The Opacity of the Cosmic Effect, Use in combination with shouldDrawCosmic : Example 1.0f.
+ * All the locations for these are autogenerated and follow the same path as the + * MaterialIconSet the material uses: Example + * "gregtech:textures/items/material_sets/dull/dust_mask + * @param maskOpacity The Opacity of the Cosmic Effect, Use in combination with shouldDrawCosmic : Example + * 1.0f.
*/ @Optional.Method(modid = Mods.Names.AVARITIA) - public Builder cosmic(boolean shouldDrawHalo, String haloTexture, String haloColour, int haloSize, boolean shouldDrawPulse, boolean shouldDrawCosmic, Float maskOpacity) { + public Builder cosmic(boolean shouldDrawHalo, String haloTexture, String haloColour, int haloSize, + boolean shouldDrawPulse, boolean shouldDrawCosmic, Float maskOpacity) { if (Avaritia.isModLoaded()) { properties.setProperty(PropertyKey.COSMIC, new CosmicProperty(shouldDrawHalo, haloTexture, haloColour, haloSize, shouldDrawPulse, @@ -856,7 +862,8 @@ public Builder cosmic(boolean shouldDrawHalo, String haloTexture, String haloCol } @Optional.Method(modid = Mods.Names.AVARITIA) - public Builder cosmic(boolean shouldDrawHalo, String haloTexture, String haloColour, int haloSize, boolean shouldDrawPulse) { + public Builder cosmic(boolean shouldDrawHalo, String haloTexture, String haloColour, int haloSize, + boolean shouldDrawPulse) { if (Avaritia.isModLoaded()) { properties.setProperty(PropertyKey.COSMIC, new CosmicProperty(shouldDrawHalo, haloTexture, haloColour, haloSize, shouldDrawPulse)); @@ -874,7 +881,7 @@ public Builder cosmic(boolean shouldDrawHalo, String haloTexture, String haloCol } @Optional.Method(modid = Mods.Names.AVARITIA) - public Builder cosmic( boolean shouldDrawCosmic, Float maskOpacity) { + public Builder cosmic(boolean shouldDrawCosmic, Float maskOpacity) { if (Avaritia.isModLoaded()) { properties.setProperty(PropertyKey.COSMIC, new CosmicProperty(shouldDrawCosmic, maskOpacity)); } diff --git a/src/main/java/gregtech/api/unification/material/properties/CosmicProperty.java b/src/main/java/gregtech/api/unification/material/properties/CosmicProperty.java index 08b0d09dc26..077386232a4 100644 --- a/src/main/java/gregtech/api/unification/material/properties/CosmicProperty.java +++ b/src/main/java/gregtech/api/unification/material/properties/CosmicProperty.java @@ -56,7 +56,8 @@ public class CosmicProperty implements IMaterialProperty { */ private Float maskOpacity; - public CosmicProperty(boolean shouldDrawHalo, String haloTexture, String haloColour, int haloSize, boolean shouldDrawPulse, boolean shouldDrawCosmic, Float maskOpacity) { + public CosmicProperty(boolean shouldDrawHalo, String haloTexture, String haloColour, int haloSize, + boolean shouldDrawPulse, boolean shouldDrawCosmic, Float maskOpacity) { if (Avaritia.isModLoaded()) { this.shouldDrawHalo = shouldDrawHalo; this.haloTexture = haloTexture; @@ -69,7 +70,8 @@ public CosmicProperty(boolean shouldDrawHalo, String haloTexture, String haloCol } } - public CosmicProperty(boolean shouldDrawHalo, String haloTexture, String haloColour, int haloSize, boolean shouldDrawPulse) { + public CosmicProperty(boolean shouldDrawHalo, String haloTexture, String haloColour, int haloSize, + boolean shouldDrawPulse) { if (Avaritia.isModLoaded()) { this.shouldDrawHalo = shouldDrawHalo; this.haloTexture = haloTexture; @@ -95,7 +97,6 @@ public CosmicProperty(boolean shouldDrawCosmic, Float maskOpacity) { this.shouldDrawCosmic = shouldDrawCosmic; this.maskOpacity = maskOpacity; } - } public CosmicProperty(boolean shouldDrawPulse) { @@ -127,9 +128,11 @@ public boolean getHaloPulse() { public boolean shouldDrawCosmic() { return shouldDrawCosmic; } + public Float getMaskOpacity() { return maskOpacity; } + @Override public void verifyProperty(MaterialProperties properties) { properties.ensureSet(PropertyKey.DUST, true); @@ -156,22 +159,27 @@ public Builder haloTexture(String haloTexture) { this.haloTexture = haloTexture; return this; } + public Builder haloColour(String haloColour) { this.haloColour = haloColour; return this; } + public Builder haloSize(int haloSize) { this.haloSize = haloSize; return this; } + public Builder shouldDrawPulse(boolean shouldDrawPulse) { this.shouldDrawPulse = shouldDrawPulse; return this; } + public Builder shouldDrawCosmic(boolean shouldDrawCosmic) { this.shouldDrawCosmic = shouldDrawCosmic; return this; } + public Builder maskOpacity(Float maskOpacity) { this.maskOpacity = maskOpacity; return this; diff --git a/src/main/java/gregtech/client/renderer/item/CosmicItemRenderer.java b/src/main/java/gregtech/client/renderer/item/CosmicItemRenderer.java index f4dce417740..2162f02fce8 100644 --- a/src/main/java/gregtech/client/renderer/item/CosmicItemRenderer.java +++ b/src/main/java/gregtech/client/renderer/item/CosmicItemRenderer.java @@ -1,23 +1,9 @@ package gregtech.client.renderer.item; -import codechicken.lib.colour.Colour; -import codechicken.lib.model.ItemQuadBakery; -import codechicken.lib.model.bakedmodels.ModelProperties; -import codechicken.lib.model.bakedmodels.PerspectiveAwareBakedModel; -import codechicken.lib.util.TransformUtils; -import com.google.common.collect.ImmutableList; - import gregtech.api.util.Mods; -import morph.avaritia.api.ICosmicRenderItem; -import morph.avaritia.api.IHaloRenderItem; -import morph.avaritia.client.render.item.WrappedItemRenderer; -import morph.avaritia.client.render.shader.CosmicShaderHelper; - -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.RenderItem; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.IBakedModel; @@ -30,22 +16,33 @@ import net.minecraftforge.common.model.IModelState; import net.minecraftforge.fml.common.Optional; +import codechicken.lib.colour.Colour; +import codechicken.lib.model.ItemQuadBakery; +import codechicken.lib.model.bakedmodels.ModelProperties; +import codechicken.lib.model.bakedmodels.PerspectiveAwareBakedModel; +import codechicken.lib.util.TransformUtils; +import com.google.common.collect.ImmutableList; +import morph.avaritia.api.ICosmicRenderItem; +import morph.avaritia.api.IHaloRenderItem; +import morph.avaritia.client.render.item.WrappedItemRenderer; +import morph.avaritia.client.render.shader.CosmicShaderHelper; + import java.util.HashMap; import java.util.List; import java.util.Random; @Optional.Interface( - modid = Mods.Names.AVARITIA, - iface = "morph.avaritia.api.ICosmicRenderItem") + modid = Mods.Names.AVARITIA, + iface = "morph.avaritia.api.ICosmicRenderItem") @Optional.Interface( - modid = Mods.Names.AVARITIA, - iface = "morph.avaritia.api.IHaloRenderItem") + modid = Mods.Names.AVARITIA, + iface = "morph.avaritia.api.IHaloRenderItem") @Optional.Interface( - modid = Mods.Names.AVARITIA, - iface = "morph.avaritia.client.render.item.WrappedItemRenderer") + modid = Mods.Names.AVARITIA, + iface = "morph.avaritia.client.render.item.WrappedItemRenderer") @Optional.Interface( - modid = Mods.Names.AVARITIA, - iface = "morph.avaritia.client.render.shader.CosmicShaderHelper") + modid = Mods.Names.AVARITIA, + iface = "morph.avaritia.client.render.shader.CosmicShaderHelper") public class CosmicItemRenderer extends WrappedItemRenderer { private static final HashMap spriteQuadCache = new HashMap(); @@ -68,16 +65,17 @@ public void renderItem(ItemStack stack, ItemCameraTransforms.TransformType trans Tessellator tess = Tessellator.getInstance(); BufferBuilder buffer = tess.getBuffer(); if (stack.getItem() instanceof IHaloRenderItem && transformType == ItemCameraTransforms.TransformType.GUI) { - IHaloRenderItem hri = (IHaloRenderItem)stack.getItem(); + IHaloRenderItem hri = (IHaloRenderItem) stack.getItem(); GlStateManager.pushMatrix(); GlStateManager.enableBlend(); GlStateManager.disableDepth(); - GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); + GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, + GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); GlStateManager.disableAlpha(); if (hri.shouldDrawHalo(stack)) { Colour.glColourARGB(hri.getHaloColour(stack)); TextureAtlasSprite sprite = hri.getHaloTexture(stack); - double spread = (double)hri.getHaloSize(stack) / 16.0; + double spread = (double) hri.getHaloSize(stack) / 16.0; double min = 0.0 - spread; double max = 1.0 + spread; float minU = sprite.getMinU(); @@ -85,10 +83,10 @@ public void renderItem(ItemStack stack, ItemCameraTransforms.TransformType trans float minV = sprite.getMinV(); float maxV = sprite.getMaxV(); buffer.begin(7, DefaultVertexFormats.POSITION_TEX); - buffer.pos(max, max, 0.0).tex((double)maxU, (double)minV).endVertex(); - buffer.pos(min, max, 0.0).tex((double)minU, (double)minV).endVertex(); - buffer.pos(min, min, 0.0).tex((double)minU, (double)maxV).endVertex(); - buffer.pos(max, min, 0.0).tex((double)maxU, (double)maxV).endVertex(); + buffer.pos(max, max, 0.0).tex((double) maxU, (double) minV).endVertex(); + buffer.pos(min, max, 0.0).tex((double) minU, (double) minV).endVertex(); + buffer.pos(min, min, 0.0).tex((double) minU, (double) maxV).endVertex(); + buffer.pos(max, min, 0.0).tex((double) maxU, (double) maxV).endVertex(); tess.draw(); } @@ -128,11 +126,12 @@ protected void renderSimple(ItemStack stack, EntityLivingBase player) { IBakedModel model = this.wrapped.getOverrides().handleItemState(this.wrapped, stack, world, player); renderModel(model, stack); if (stack.getItem() instanceof ICosmicRenderItem) { - ICosmicRenderItem cri = (ICosmicRenderItem)stack.getItem(); + ICosmicRenderItem cri = (ICosmicRenderItem) stack.getItem(); GlStateManager.disableAlpha(); GlStateManager.depthFunc(514); TextureAtlasSprite cosmicSprite = cri.getMaskTexture(stack, player); - IBakedModel cosmicModel = (IBakedModel)spriteQuadCache.computeIfAbsent(cosmicSprite, CosmicItemRenderer::computeModel); + IBakedModel cosmicModel = (IBakedModel) spriteQuadCache.computeIfAbsent(cosmicSprite, + CosmicItemRenderer::computeModel); CosmicShaderHelper.cosmicOpacity = cri.getMaskOpacity(stack, player); CosmicShaderHelper.useShader(); renderModel(cosmicModel, stack); @@ -144,6 +143,7 @@ protected void renderSimple(ItemStack stack, EntityLivingBase player) { GlStateManager.disableBlend(); GlStateManager.popMatrix(); } + private static IBakedModel computeModel(TextureAtlasSprite sprite) { List quads = ItemQuadBakery.bakeItem(ImmutableList.of(sprite)); return new PerspectiveAwareBakedModel(quads, TransformUtils.DEFAULT_ITEM, new ModelProperties(true, false)); @@ -159,14 +159,16 @@ protected void renderInventory(ItemStack stack, EntityLivingBase player) { IBakedModel model = this.wrapped.getOverrides().handleItemState(this.wrapped, stack, world, player); renderModel(model, stack); if (stack.getItem() instanceof ICosmicRenderItem) { - ICosmicRenderItem cri = (ICosmicRenderItem)stack.getItem(); + ICosmicRenderItem cri = (ICosmicRenderItem) stack.getItem(); GlStateManager.pushMatrix(); GlStateManager.enableBlend(); - GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); + GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, + GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); GlStateManager.disableAlpha(); GlStateManager.disableDepth(); TextureAtlasSprite sprite = cri.getMaskTexture(stack, player); - IBakedModel cosmicModel = (IBakedModel)spriteQuadCache.computeIfAbsent(sprite, CosmicItemRenderer::computeModel); + IBakedModel cosmicModel = (IBakedModel) spriteQuadCache.computeIfAbsent(sprite, + CosmicItemRenderer::computeModel); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); CosmicShaderHelper.cosmicOpacity = cri.getMaskOpacity(stack, player); CosmicShaderHelper.inventoryRender = true;