diff options
| author | Connor-Colenso <52056774+Connor-Colenso@users.noreply.github.com> | 2024-08-27 22:24:31 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-27 23:24:31 +0200 |
| commit | 55a6ac375cd21584aef3d38e4770d9961f2bddb3 (patch) | |
| tree | dfee89e168156da884bb3d0a0b82a7f6bc616b0d /src/main/java/com | |
| parent | 4908d5967c3dfeff5616c65144e701859b9e30a2 (diff) | |
| download | GT5-Unofficial-55a6ac375cd21584aef3d38e4770d9961f2bddb3.tar.gz GT5-Unofficial-55a6ac375cd21584aef3d38e4770d9961f2bddb3.tar.bz2 GT5-Unofficial-55a6ac375cd21584aef3d38e4770d9961f2bddb3.zip | |
Bartworks cleaning (#2951)
* Remove added by bartworks from every single item
* Fix germanglish
* Works
* Clean up a little
* Ok, spiralled a little but hopefully worth it...
* Spotless
* Less "added by"
* Clean up tooltips somewhat
* more cleanups
* Bit more cleaning
* Spotless
* Reduce random glass crap
* Get rid of destructopack (useless)
* Magneto work
* Further refactor/cleanup
* Move Boro tags to materials
* Attempt fix
* No longer needed
* Go away
* Rename
* Remove dead recipes
* Spotless apply for branch bartTooltips for #2951 (#2952)
spotlessApply
Co-authored-by: GitHub GTNH Actions <>
* Add warded glass to HV
* remove ignored
---------
Co-authored-by: Connor Colenso <colen@CONNORSPC>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Co-authored-by: boubou19 <miisterunknown@gmail.com>
Diffstat (limited to 'src/main/java/com')
41 files changed, 456 insertions, 1371 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioVatLogicAdder.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioVatLogicAdder.java index b53638a77a..4e1728fccd 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioVatLogicAdder.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioVatLogicAdder.java @@ -13,17 +13,12 @@ package com.github.bartimaeusnek.bartworks.API; -import static cpw.mods.fml.common.registry.GameRegistry.findBlock; import static gregtech.api.enums.Mods.IndustrialCraft2; import java.util.HashMap; import java.util.HashSet; import java.util.Objects; -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; - -import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import com.github.bartimaeusnek.bartworks.system.material.BW_NonMeta_MaterialItems; @@ -207,57 +202,6 @@ public final class BioVatLogicAdder { } } - public static class BioVatGlass { - - private static final HashMap<BlockMetaPair, Byte> glasses = new HashMap<>(); - - /** - * @param sModname The modid owning the block - * @param sUnlocBlockName The name of the block itself - * @param meta The meta of the block - * @param tier the glasses Tier = Voltage tier (MIN 3) - * @return if the block was found in the Block registry - */ - public static boolean addCustomGlass(String sModname, String sUnlocBlockName, int meta, int tier) { - Block block = findBlock(sModname, sUnlocBlockName); - boolean ret = block != null; - if (ret) BioVatGlass.glasses.put(new BlockMetaPair(block, (byte) meta), (byte) tier); - else new IllegalArgumentException( - "Block: " + sUnlocBlockName + " of the Mod: " + sModname + " was NOT found!").printStackTrace(); - block = null; - return ret; - } - - /** - * @param block the block to add - * @param meta the meta of the block (0-15) - * @param tier the glasses Tier = Voltage tier (MIN 3) - */ - public static void addCustomGlass(@Nonnull Block block, @Nonnegative int meta, @Nonnegative int tier) { - BioVatGlass.glasses.put(new BlockMetaPair(block, (byte) meta), (byte) tier); - } - - /** - * @param block the block to add - * @param tier the glasses Tier = Voltage tier (MIN 3) - */ - public static void addCustomGlass(@Nonnull Block block, @Nonnegative int tier) { - BioVatGlass.glasses.put(new BlockMetaPair(block, (byte) 0), (byte) tier); - } - - /** - * @param blockBytePair the block to add and its meta as a javafx.util Pair - * @param tier the glasses Tier = Voltage tier (MIN 3) - */ - public static void addCustomGlass(@Nonnull BlockMetaPair blockBytePair, @Nonnegative byte tier) { - BioVatGlass.glasses.put(blockBytePair, tier); - } - - public static HashMap<BlockMetaPair, Byte> getGlassMap() { - return BioVatGlass.glasses; - } - } - public static class MaterialSvPair { final Materials materials; @@ -291,35 +235,4 @@ public final class BioVatLogicAdder { } } - public static class BlockMetaPair { - - final Block block; - final Byte aByte; - - public BlockMetaPair(Block block, Byte aByte) { - this.block = block; - this.aByte = aByte; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || this.getClass() != o.getClass()) return false; - BioVatLogicAdder.BlockMetaPair that = (BioVatLogicAdder.BlockMetaPair) o; - return Objects.equals(this.getBlock(), that.getBlock()) && Objects.equals(this.getaByte(), that.getaByte()); - } - - @Override - public int hashCode() { - return Objects.hash(this.getBlock(), this.getaByte()); - } - - public Block getBlock() { - return this.block; - } - - public Byte getaByte() { - return this.aByte; - } - } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BorosilicateGlass.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BorosilicateGlass.java index eb4c2a0405..aca6b16330 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/API/BorosilicateGlass.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BorosilicateGlass.java @@ -47,14 +47,14 @@ public class BorosilicateGlass { return tier > 0 && tier <= Byte.MAX_VALUE; } - private static Block getGlassBlock() { + public static Block getGlassBlock() { if (block == null) { block = GameRegistry.findBlock(BartWorks.ID, "BW_GlasBlocks"); } return block; } - private static Block getGlassBlock2() { + public static Block getGlassBlock2() { if (block2 == null) { block2 = GameRegistry.findBlock(BartWorks.ID, "BW_GlasBlocks2"); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/GlassTier.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/GlassTier.java new file mode 100644 index 0000000000..7a9493914a --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/GlassTier.java @@ -0,0 +1,78 @@ +package com.github.bartimaeusnek.bartworks.API; + +import static cpw.mods.fml.common.registry.GameRegistry.findBlock; + +import java.util.HashMap; +import java.util.Objects; + +import net.minecraft.block.Block; + +import org.jetbrains.annotations.NotNull; + +public class GlassTier { + + private static final HashMap<BlockMetaPair, Integer> glasses = new HashMap<>(); + + /** + * @param modname The modid owning the block + * @param unlocalisedBlockName The name of the block itself + * @param meta The meta of the block + * @param tier the glasses Tier = Voltage tier (MIN 3) + */ + public static void addCustomGlass(String modname, String unlocalisedBlockName, int meta, int tier) { + Block block = findBlock(modname, unlocalisedBlockName); + if (block != null) { + addCustomGlass(block, meta, tier); + } else { + new IllegalArgumentException( + "Block: " + unlocalisedBlockName + + " of the Mod: " + + modname + + " was NOT found when attempting to register a glass!").printStackTrace(); + } + } + + public static void addCustomGlass(@NotNull Block block, int meta, int tier) { + GlassTier.glasses.put(new BlockMetaPair(block, (byte) meta), tier); + } + + public static HashMap<BlockMetaPair, Integer> getGlassMap() { + return glasses; + } + + public static int getGlassTier(Block block, int meta) { + return glasses.getOrDefault(new BlockMetaPair(block, (byte) meta), 0); + } + + public static class BlockMetaPair { + + private final Block block; + private final int meta; + + public BlockMetaPair(Block block, int aByte) { + this.block = block; + this.meta = aByte; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + BlockMetaPair that = (BlockMetaPair) o; + return Objects.equals(this.getBlock(), that.getBlock()) && Objects.equals(this.getMeta(), that.getMeta()); + } + + @Override + public int hashCode() { + return Objects.hash(this.getBlock(), this.getMeta()); + } + + public Block getBlock() { + return this.block; + } + + public int getMeta() { + return this.meta; + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreStaticReplacementMethodes.java b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreStaticReplacementMethodes.java index 38a5a70d27..8802105563 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreStaticReplacementMethodes.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreStaticReplacementMethodes.java @@ -109,5 +109,4 @@ public class BWCoreStaticReplacementMethodes { return stack; } - private BWCoreStaticReplacementMethodes() {} } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java index 30c1276f97..6526eafe4b 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java @@ -15,14 +15,11 @@ package com.github.bartimaeusnek.bartworks; import static com.github.bartimaeusnek.bartworks.common.loaders.BioRecipeLoader.runOnServerStarted; import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.removeIC2Recipes; -import static gregtech.api.enums.GT_Values.VN; import static gregtech.api.enums.Mods.BartWorks; import java.io.IOException; -import java.util.Map; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import org.apache.logging.log4j.LogManager; @@ -38,15 +35,15 @@ import com.github.bartimaeusnek.bartworks.client.creativetabs.GT2Tab; import com.github.bartimaeusnek.bartworks.client.creativetabs.bartworksTab; import com.github.bartimaeusnek.bartworks.client.textures.PrefixTextureLinker; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.common.items.BW_ItemBlocks; import com.github.bartimaeusnek.bartworks.common.loaders.ArtificialMicaLine; -import com.github.bartimaeusnek.bartworks.common.loaders.BeforeGTPreload; import com.github.bartimaeusnek.bartworks.common.loaders.BioCultureLoader; import com.github.bartimaeusnek.bartworks.common.loaders.BioLabLoader; -import com.github.bartimaeusnek.bartworks.common.loaders.GTNHBlocks; import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; import com.github.bartimaeusnek.bartworks.common.loaders.LocalisationLoader; import com.github.bartimaeusnek.bartworks.common.loaders.RadioHatchMaterialLoader; import com.github.bartimaeusnek.bartworks.common.loaders.RecipeLoader; +import com.github.bartimaeusnek.bartworks.common.loaders.RegisterGlassTiers; import com.github.bartimaeusnek.bartworks.common.loaders.RegisterServerCommands; import com.github.bartimaeusnek.bartworks.common.loaders.StaticRecipeChangeLoaders; import com.github.bartimaeusnek.bartworks.common.net.BW_Network; @@ -72,12 +69,12 @@ import cpw.mods.fml.common.event.FMLServerStartedEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.registry.GameRegistry; import gregtech.GT_Version; import gregtech.api.GregTech_API; import gregtech.api.enums.Mods; import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.check.CheckRecipeResultRegistry; -import gregtech.api.util.GT_OreDictUnificator; @Mod(modid = MainMod.MOD_ID, name = MainMod.NAME, version = GT_Version.VERSION, dependencies = """ required-after:IC2;\ @@ -107,13 +104,16 @@ public final class MainMod { public static BW_Network BW_Network_instance = new BW_Network(); public MainMod() { - GregTech_API.sBeforeGTPreload.add(new BeforeGTPreload()); + } @Mod.EventHandler public void preInit(FMLPreInitializationEvent preinit) { MainMod.LOGGER.info("Found GT++, continuing"); + GameRegistry.registerBlock(ItemRegistry.bw_glasses[0], BW_ItemBlocks.class, "BW_GlasBlocks"); + GameRegistry.registerBlock(ItemRegistry.bw_glasses[1], BW_ItemBlocks.class, "BW_GlasBlocks2"); + if (API_ConfigValues.debugLog) { try { DebugLog.initDebugLog(preinit); @@ -124,9 +124,7 @@ public final class MainMod { WerkstoffLoader.setUp(); - if (ConfigHandler.BioLab) { - BioCultureLoader.run(); - } + BioCultureLoader.run(); Werkstoff.init(); GregTech_API.sAfterGTPostload.add(new CircuitPartLoader()); @@ -134,6 +132,7 @@ public final class MainMod { GregTech_API.sBeforeGTLoad.add(new PrefixTextureLinker()); } + RegisterGlassTiers.run(); } @Mod.EventHandler @@ -147,9 +146,7 @@ public final class MainMod { FMLCommonHandler.instance() .bus() .register(serverEventHandler); - if (ConfigHandler.BioLab) { - BioLabLoader.run(); - } + BioLabLoader.run(); WerkstoffLoader.runInit(); @@ -162,20 +159,7 @@ public final class MainMod { RecipeLoader.run(); NetworkRegistry.INSTANCE.registerGuiHandler(MainMod.instance, MainMod.GH); - if (ConfigHandler.BioLab) { - GTNHBlocks.run(); - for (Map.Entry<BioVatLogicAdder.BlockMetaPair, Byte> pair : BioVatLogicAdder.BioVatGlass.getGlassMap() - .entrySet()) { - GT_OreDictUnificator.registerOre( - "blockGlass" + VN[pair.getValue()], - new ItemStack( - pair.getKey() - .getBlock(), - 1, - pair.getKey() - .getaByte())); - } - } + ArtificialMicaLine.runArtificialMicaRecipe(); BioObjectAdder.regenerateBioFluids(); @@ -219,8 +203,6 @@ public final class MainMod { if (classicMode) DownTierLoader.run(); - // StaticRecipeChangeLoaders.patchEBFMapForCircuitUnification(); - recipesAdded = true; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipCache.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipCache.java deleted file mode 100644 index 969398df47..0000000000 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipCache.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek 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 com.github.bartimaeusnek.bartworks.client.ClientEventHandler; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import com.github.bartimaeusnek.bartworks.util.Pair; - -class TooltipCache { - - private static final HashMap<Pair<Integer, Short>, char[]> cache = new HashMap<>(); - - static boolean put(ItemStack itemStack, List<String> tooltip) { - Pair<Integer, Short> p = new Pair<>(Item.getIdFromItem(itemStack.getItem()), (short) itemStack.getItemDamage()); - if (TooltipCache.cache.containsKey(p) || tooltip.isEmpty()) { - return false; - } - StringBuilder sb = new StringBuilder(); - for (String s : tooltip) { - sb.append(s); - sb.append(System.lineSeparator()); - } - char[] rettype = sb.toString() - .toCharArray(); - return TooltipCache.cache.put(p, rettype) == rettype; - } - - static List<String> getTooltip(ItemStack itemStack) { - Pair<Integer, Short> p = new Pair<>(Item.getIdFromItem(itemStack.getItem()), (short) itemStack.getItemDamage()); - char[] toTest = TooltipCache.cache.get(p); - if (toTest == null) { - return new ArrayList<>(); - } - return Arrays.asList(new String(toTest).split(System.lineSeparator())); - } -} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipEventHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipEventHandler.java index 0f7cb58bae..edf9b7f07f 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipEventHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipEventHandler.java @@ -1,48 +1,17 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek 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 com.github.bartimaeusnek.bartworks.client.ClientEventHandler; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; +import static gregtech.api.util.GT_Utility.getColoredTierNameFromTier; import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraftforge.event.entity.player.ItemTooltipEvent; -import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; -import com.github.bartimaeusnek.bartworks.MainMod; -import com.github.bartimaeusnek.bartworks.common.blocks.BW_Blocks; -import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; -import com.github.bartimaeusnek.bartworks.system.oredict.OreDictHandler; -import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; -import com.github.bartimaeusnek.bartworks.util.Pair; -import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; +import com.github.bartimaeusnek.bartworks.API.GlassTier; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.ModContainer; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.enums.GT_Values; @SideOnly(Side.CLIENT) public class TooltipEventHandler { @@ -53,75 +22,16 @@ public class TooltipEventHandler { if (event == null || event.itemStack == null || event.itemStack.getItem() == null) return; - if (TooltipCache.getTooltip(event.itemStack) - .isEmpty()) { - ItemStack tmp = event.itemStack.copy(); - Pair<Integer, Short> abstractedStack = new Pair<>( - Item.getIdFromItem(tmp.getItem()), - (short) tmp.getItemDamage()); - List<String> tooAdd = new ArrayList<>(); - if (ConfigHandler.sharedItemStackTooltip && OreDictHandler.getNonBWCache() - .contains(abstractedStack)) { - for (Pair<Integer, Short> pair : OreDictHandler.getNonBWCache()) { - if (pair.equals(abstractedStack)) { - GameRegistry.UniqueIdentifier UI = GameRegistry.findUniqueIdentifierFor(tmp.getItem()); - if (UI == null) - UI = GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(tmp.getItem())); - if (UI != null) { - for (ModContainer modContainer : Loader.instance() - .getModList()) { - if (MainMod.MOD_ID.equals(UI.modId) || BartWorksCrossmod.MOD_ID.equals(UI.modId) - || "BWCore".equals(UI.modId)) break; - if (UI.modId.equals(modContainer.getModId())) { - tooAdd.add( - |
