diff options
author | Jason Mitchell <mitchej@gmail.com> | 2023-01-28 19:03:53 -0800 |
---|---|---|
committer | Jason Mitchell <mitchej@gmail.com> | 2023-01-28 19:03:53 -0800 |
commit | f51616bda220887fdd45c4bc951ff59e3398213a (patch) | |
tree | 35fdbb15b4c7ea0282773a388eff517a1d09d941 /src/main/java/kubatech/loaders | |
parent | 11216d666cbc30fc1e1dfc84e1e0c2f4252b1fc2 (diff) | |
download | GT5-Unofficial-f51616bda220887fdd45c4bc951ff59e3398213a.tar.gz GT5-Unofficial-f51616bda220887fdd45c4bc951ff59e3398213a.tar.bz2 GT5-Unofficial-f51616bda220887fdd45c4bc951ff59e3398213a.zip |
[ci skip] spotlessApply with the new settings
Diffstat (limited to 'src/main/java/kubatech/loaders')
18 files changed, 750 insertions, 874 deletions
diff --git a/src/main/java/kubatech/loaders/BlockLoader.java b/src/main/java/kubatech/loaders/BlockLoader.java index 10efcb018f..feed715fa7 100644 --- a/src/main/java/kubatech/loaders/BlockLoader.java +++ b/src/main/java/kubatech/loaders/BlockLoader.java @@ -1,33 +1,26 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders; -import cpw.mods.fml.common.registry.GameRegistry; import kubatech.api.enums.ItemList; import kubatech.loaders.block.KubaBlock; import kubatech.loaders.block.KubaItemBlock; import kubatech.loaders.block.blocks.TeaAcceptor; import kubatech.tileentity.TeaAcceptorTile; + import net.minecraft.block.material.Material; import net.minecraft.item.ItemBlock; +import cpw.mods.fml.common.registry.GameRegistry; + public class BlockLoader { public static final KubaBlock kubaBlock = new KubaBlock(Material.anvil); diff --git a/src/main/java/kubatech/loaders/ItemLoader.java b/src/main/java/kubatech/loaders/ItemLoader.java index 31bf042794..a0f28dc391 100644 --- a/src/main/java/kubatech/loaders/ItemLoader.java +++ b/src/main/java/kubatech/loaders/ItemLoader.java @@ -1,32 +1,24 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders; import static kubatech.api.enums.ItemList.*; -import cpw.mods.fml.common.registry.GameRegistry; import kubatech.loaders.item.ItemProxy; import kubatech.loaders.item.KubaItems; import kubatech.loaders.item.items.*; +import cpw.mods.fml.common.registry.GameRegistry; public class ItemLoader { + public static final KubaItems kubaitems = new KubaItems(); public static void registerItems() { @@ -74,8 +66,8 @@ public class ItemLoader { BruisedTeaLeaf.set(kubaitems.registerProxyItem(new TeaIngredient("bruised_tea_leaf"))); PartiallyOxidizedTeaLeaf.set(kubaitems.registerProxyItem(new TeaIngredient("partially_oxidized_tea_leaf"))); - TeaAcceptorResearchNote.set( - kubaitems.registerProxyItem(new ItemProxy("tea_acceptor_research_note", "research_note"))); + TeaAcceptorResearchNote + .set(kubaitems.registerProxyItem(new ItemProxy("tea_acceptor_research_note", "research_note"))); Beeeeee.set(kubaitems.registerProxyItem(new ItemProxy("beeeeee", "beeeeee"))); } } diff --git a/src/main/java/kubatech/loaders/MTLoader.java b/src/main/java/kubatech/loaders/MTLoader.java index cf0b0b1fd4..d223e83951 100644 --- a/src/main/java/kubatech/loaders/MTLoader.java +++ b/src/main/java/kubatech/loaders/MTLoader.java @@ -1,20 +1,11 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders; @@ -22,6 +13,7 @@ package kubatech.loaders; import kubatech.Tags; import kubatech.api.LoaderReference; import minetweaker.MineTweakerImplementationAPI; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/kubatech/loaders/MobRecipeLoader.java b/src/main/java/kubatech/loaders/MobRecipeLoader.java index 43fefc2a97..f530b8921b 100644 --- a/src/main/java/kubatech/loaders/MobRecipeLoader.java +++ b/src/main/java/kubatech/loaders/MobRecipeLoader.java @@ -1,20 +1,11 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders; @@ -23,16 +14,6 @@ import static kubatech.api.utils.ModUtils.isClientSided; import static kubatech.api.utils.ModUtils.isDeobfuscatedEnvironment; import static kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber.*; -import atomicstryker.infernalmobs.common.InfernalMobsCore; -import atomicstryker.infernalmobs.common.MobModifier; -import atomicstryker.infernalmobs.common.mods.api.ModifierLoader; -import com.google.common.io.Files; -import com.google.gson.Gson; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.util.GT_Utility; -import gregtech.common.GT_DummyWorld; import java.io.File; import java.io.Reader; import java.io.Writer; @@ -42,6 +23,7 @@ import java.lang.reflect.Modifier; import java.nio.charset.StandardCharsets; import java.util.*; import java.util.stream.Collectors; + import kubatech.Tags; import kubatech.api.LoaderReference; import kubatech.api.helpers.EnderIOHelper; @@ -58,6 +40,7 @@ import minetweaker.MineTweakerAPI; import minetweaker.api.entity.IEntityDefinition; import minetweaker.api.item.IItemStack; import minetweaker.mc1710.item.MCItemStack; + import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; @@ -78,10 +61,24 @@ import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.client.event.GuiOpenEvent; import net.minecraftforge.common.MinecraftForge; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; + import stanhebben.zenscript.value.IntRange; import thaumcraft.common.items.wands.ItemWandCasting; +import atomicstryker.infernalmobs.common.InfernalMobsCore; +import atomicstryker.infernalmobs.common.MobModifier; +import atomicstryker.infernalmobs.common.mods.api.ModifierLoader; + +import com.google.common.io.Files; +import com.google.gson.Gson; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.util.GT_Utility; +import gregtech.common.GT_DummyWorld; public class MobRecipeLoader { @@ -108,6 +105,7 @@ public class MobRecipeLoader { public static final String randomEnchantmentDetectedString = "RandomEnchantmentDetected"; public static class MobRecipe { + public final ArrayList<MobDrop> mOutputs; public final int mEUt = 2000; public final int mDuration; @@ -134,15 +132,8 @@ public class MobRecipeLoader { isUsable); } - private MobRecipe( - ArrayList<MobDrop> mOutputs, - int mDuration, - int mMaxDamageChance, - boolean infernalityAllowed, - boolean alwaysinfernal, - boolean isPeacefulAllowed, - EntityLiving entity, - float maxEntityHealth, + private MobRecipe(ArrayList<MobDrop> mOutputs, int mDuration, int mMaxDamageChance, boolean infernalityAllowed, + boolean alwaysinfernal, boolean isPeacefulAllowed, EntityLiving entity, float maxEntityHealth, boolean isUsable) { this.mOutputs = mOutputs; this.mDuration = mDuration; @@ -164,39 +155,38 @@ public class MobRecipeLoader { if (infernaldrops == null && LoaderReference.InfernalMobs) { infernaldrops = new droplist(); LOG.info("Generating Infernal drops"); - ArrayList<ModifierLoader<?>> modifierLoaders = (ArrayList<ModifierLoader<?>>) - InfernalHelper.getModifierLoaders().clone(); + ArrayList<ModifierLoader<?>> modifierLoaders = (ArrayList<ModifierLoader<?>>) InfernalHelper + .getModifierLoaders().clone(); int i = 0; for (ModifierLoader<?> modifierLoader : modifierLoaders) { MobModifier nextMod = modifierLoader.make(null); - if (nextMod.getBlackListMobClasses() != null) - for (Class<?> cl : nextMod.getBlackListMobClasses()) - if (e.getClass().isAssignableFrom(cl)) break; + if (nextMod.getBlackListMobClasses() != null) for (Class<?> cl : nextMod.getBlackListMobClasses()) + if (e.getClass().isAssignableFrom(cl)) break; i++; } if (i > 0) { - double chance = - InfernalHelper.checkEntityClassForced(e) ? 1d : (1d / InfernalHelper.getEliteRarity()); + double chance = InfernalHelper.checkEntityClassForced(e) ? 1d + : (1d / InfernalHelper.getEliteRarity()); ArrayList<ItemStack> elitelist = InfernalHelper.getDropIdListElite(); for (ItemStack stack : elitelist) { - dropinstance instance = infernaldrops.add( - new dropinstance(stack.copy(), infernaldrops), chance / elitelist.size()); + dropinstance instance = infernaldrops + .add(new dropinstance(stack.copy(), infernaldrops), chance / elitelist.size()); instance.isEnchatmentRandomized = true; instance.enchantmentLevel = stack.getItem().getItemEnchantability(); } ArrayList<ItemStack> ultralist = InfernalHelper.getDropIdListUltra(); chance *= 1d / InfernalHelper.getUltraRarity(); for (ItemStack stack : ultralist) { - dropinstance instance = infernaldrops.add( - new dropinstance(stack.copy(), infernaldrops), chance / ultralist.size()); + dropinstance instance = infernaldrops + .add(new dropinstance(stack.copy(), infernaldrops), chance / ultralist.size()); instance.isEnchatmentRandomized = true; instance.enchantmentLevel = stack.getItem().getItemEnchantability(); } ArrayList<ItemStack> infernallist = InfernalHelper.getDropIdListInfernal(); chance *= 1d / InfernalHelper.getInfernoRarity(); for (ItemStack stack : infernallist) { - dropinstance instance = infernaldrops.add( - new dropinstance(stack.copy(), infernaldrops), chance / infernallist.size()); + dropinstance instance = infernaldrops + .add(new dropinstance(stack.copy(), infernaldrops), chance / infernallist.size()); instance.isEnchatmentRandomized = true; instance.enchantmentLevel = stack.getItem().getItemEnchantability(); } @@ -223,12 +213,8 @@ public class MobRecipeLoader { mMaxDamageChance = maxdamagechance; } - public ItemStack[] generateOutputs( - Random rnd, - GT_MetaTileEntity_ExtremeExterminationChamber MTE, - double attackDamage, - int lootinglevel, - boolean preferInfernalDrops) { + public ItemStack[] generateOutputs(Random rnd, GT_MetaTileEntity_ExtremeExterminationChamber MTE, + double attackDamage, int lootinglevel, boolean preferInfernalDrops) { MTE.lEUt = mEUt; MTE.mMaxProgresstime = Math.max(MOB_SPAWN_INTERVAL, (int) ((maxEntityHealth / attackDamage) * 10d)); ArrayList<ItemStack> stacks = new ArrayList<>(mOutputs.size()); @@ -266,8 +252,7 @@ public class MobRecipeLoader { } } - if (infernalityAllowed - && mEUt * 8 < MTE.getMaxInputVoltage() + if (infernalityAllowed && mEUt * 8 < MTE.getMaxInputVoltage() && !InfernalHelper.getDimensionBlackList() .contains(MTE.getBaseMetaTileEntity().getWorld().provider.dimensionId)) { int p = 0; @@ -280,23 +265,20 @@ public class MobRecipeLoader { } } ArrayList<ItemStack> infernalstacks = null; - if (p > 0) - if (p == 1) { - infernalstacks = InfernalHelper.getDropIdListElite(); - mods = InfernalHelper.getMinEliteModifiers(); - } else if (p == 2) { - infernalstacks = InfernalHelper.getDropIdListUltra(); - mods = InfernalHelper.getMinUltraModifiers(); - } else if (p == 3) { - infernalstacks = InfernalHelper.getDropIdListInfernal(); - mods = InfernalHelper.getMinInfernoModifiers(); - } + if (p > 0) if (p == 1) { + infernalstacks = InfernalHelper.getDropIdListElite(); + mods = InfernalHelper.getMinEliteModifiers(); + } else if (p == 2) { + infernalstacks = InfernalHelper.getDropIdListUltra(); + mods = InfernalHelper.getMinUltraModifiers(); + } else if (p == 3) { + infernalstacks = InfernalHelper.getDropIdListInfernal(); + mods = InfernalHelper.getMinInfernoModifiers(); + } if (infernalstacks != null) { - ItemStack infernalstack = infernalstacks - .get(rnd.nextInt(infernalstacks.size())) - .copy(); - EnchantmentHelper.addRandomEnchantment( - rnd, infernalstack, infernalstack.getItem().getItemEnchantability()); + ItemStack infernalstack = infernalstacks.get(rnd.nextInt(infernalstacks.size())).copy(); + EnchantmentHelper + .addRandomEnchantment(rnd, infernalstack, infernalstack.getItem().getItemEnchantability()); stacks.add(infernalstack); MTE.mEUt *= 8L; MTE.mMaxProgresstime *= mods * InfernalMobsCore.instance().getMobModHealthFactor(); @@ -308,7 +290,9 @@ public class MobRecipeLoader { } public static class fakeRand extends Random { + private static class nexter { + private final int type; private final int bound; private int next; @@ -413,6 +397,7 @@ public class MobRecipeLoader { } private static class dropinstance { + public boolean isDamageRandomized = false; public HashMap<Integer, Integer> damagesPossible = new HashMap<>(); public boolean isEnchatmentRandomized = false; @@ -441,6 +426,7 @@ public class MobRecipeLoader { } public static class droplist { + private final ArrayList<dropinstance> drops = new ArrayList<>(); private final HashMap<GT_Utility.ItemId, Integer> dropschecker = new HashMap<>(); @@ -492,6 +478,7 @@ public class MobRecipeLoader { } private static class dropCollector { + final HashMap<GT_Utility.ItemId, Integer> damagableChecker = new HashMap<>(); private boolean booksAlwaysRandomlyEnchanted = false; @@ -500,8 +487,8 @@ public class MobRecipeLoader { ItemStack ostack = entityItem.getEntityItem(); if (ostack == null) continue; dropinstance drop; - boolean randomchomenchantdetected = - ostack.hasTagCompound() && ostack.stackTagCompound.hasKey(randomEnchantmentDetectedString); + boolean randomchomenchantdetected = ostack.hasTagCompound() + && ostack.stackTagCompound.hasKey(randomEnchantmentDetectedString); int randomenchantmentlevel = 0; if (randomchomenchantdetected) { randomenchantmentlevel = ostack.stackTagCompound.getInteger(randomEnchantmentDetectedString); @@ -559,6 +546,7 @@ public class MobRecipeLoader { } public static class GeneralMappedMob { + public final EntityLiving mob; public final MobRecipe recipe; public final ArrayList<MobDrop> drops; @@ -573,11 +561,12 @@ public class MobRecipeLoader { public static final HashMap<String, GeneralMappedMob> GeneralMobList = new HashMap<>(); private static class MobRecipeLoaderCacheStructure { + String version; Map<String, ArrayList<MobDrop>> moblist; } - @SuppressWarnings({"unchecked", "UnstableApiUsage"}) + @SuppressWarnings({ "unchecked", "UnstableApiUsage" }) public static void generateMobRecipeMap() { if (alreadyGenerated) return; @@ -585,6 +574,7 @@ public class MobRecipeLoader { if (!Config.MobHandler.mobHandlerEnabled) return; World f = new GT_DummyWorld() { + @Override public boolean blockExists(int p_72899_1_, int p_72899_2_, int p_72899_3_) { return false; @@ -598,11 +588,8 @@ public class MobRecipeLoader { @Override public Block getBlock(int aX, int aY, int aZ) { - if (LoaderReference.TwilightForest - && new Throwable() - .getStackTrace()[1] - .getClassName() - .equals("twilightforest.client.renderer.entity.RenderTFSnowQueenIceShield")) + if (LoaderReference.TwilightForest && new Throwable().getStackTrace()[1].getClassName() + .equals("twilightforest.client.renderer.entity.RenderTFSnowQueenIceShield")) return Blocks.packed_ice; return super.getBlock(aX, aY, aZ); } @@ -637,17 +624,14 @@ public class MobRecipeLoader { && !EntityList.stringToClassMapping.containsKey("witherSkeleton")) { e = new EntitySkeleton(f); ((EntitySkeleton) e).setSkeletonType(1); - } else - e = (EntityLiving) ((Class<?>) EntityList.stringToClassMapping.get(mobName)) - .getConstructor(new Class[] {World.class}) - .newInstance(new Object[] {f}); + } else e = (EntityLiving) ((Class<?>) EntityList.stringToClassMapping.get(mobName)) + .getConstructor(new Class[] { World.class }).newInstance(new Object[] { f }); ArrayList<MobDrop> drops = entry.getValue(); drops.forEach(MobDrop::reconstructStack); GeneralMobList.put( mobName, new GeneralMappedMob(e, MobRecipe.generateMobRecipe(e, mobName, drops), drops)); - } catch (Exception ignored) { - } + } catch (Exception ignored) {} } LOG.info("Parsed cached map, skipping generation"); return; @@ -657,11 +641,9 @@ public class MobRecipeLoader { } catch (Exception ignored) { LOG.warn("There was an exception while parsing cached map, generating a new one"); } finally { - if (reader != null) - try { - reader.close(); - } catch (Exception ignored) { - } + if (reader != null) try { + reader.close(); + } catch (Exception ignored) {} } } else { LOG.info("Cached map doesn't exist or config option forced, generating a new one"); @@ -702,8 +684,7 @@ public class MobRecipeLoader { dropCollector collector = new dropCollector(); // Stupid MC code, I need to cast myself - Map<String, Class<? extends Entity>> stringToClassMapping = - (Map<String, Class<? extends Entity>>) EntityList.stringToClassMapping; + Map<String, Class<? extends Entity>> stringToClassMapping = (Map<String, Class<? extends Entity>>) EntityList.stringToClassMapping; boolean registeringWitherSkeleton = !stringToClassMapping.containsKey("witherSkeleton"); if (registeringWitherSkeleton) stringToClassMapping.put("witherSkeleton", EntitySkeleton.class); @@ -717,7 +698,7 @@ public class MobRecipeLoader { EntityLiving e; try { - e = (EntityLiving) v.getConstructor(new Class[] {World.class}).newInstance(new Object[] {f}); + e = (EntityLiving) v.getConstructor(new Class[] { World.class }).newInstance(new Object[] { f }); } catch (ClassCastException ex) { // not a EntityLiving LOG.info("Entity " + k + " is not a LivingEntity, skipping"); @@ -746,13 +727,12 @@ public class MobRecipeLoader { // POWERFULL GENERATION - if (e instanceof EntitySlime) - try { - setSlimeSize.invoke(e, 1); - } catch (Exception ex) { - ex.printStackTrace(); - return; - } + if (e instanceof EntitySlime) try { + setSlimeSize.invoke(e, 1); + } catch (Exception ex) { + ex.printStackTrace(); + return; + } try { rand.set(e, frand); @@ -909,95 +889,94 @@ public class MobRecipeLoader { int max = Math.max(maxdamage - 25, 1); for (int d = Math.min(max, 25); d <= max; d++) i.damagesPossible.put(d, 1); additionaldrops.add(i, 1d); - } else - try { - Class<?> cl = e.getClass(); - boolean detectedException; - do { - detectedException = false; - try { - cl.getDeclaredMethod(addRandomArmorName); - } catch (Exception ex) { - detectedException = true; - cl = cl.getSuperclass(); - } - } while (detectedException && !cl.equals(Entity.class)); - if (cl.equals(EntityLiving.class) || cl.equals(Entity.class)) throw new Exception(); - cl = e.getClass(); - do { - detectedException = false; - try { - cl.getDeclaredMethod(enchantEquipmentName); - } catch (Exception ex) { - detectedException = true; - cl = cl.getSuperclass(); - } - } while (detectedException && !cl.equals(EntityLiving.class)); - boolean usingVanillaEnchantingMethod = cl.equals(EntityLiving.class); - double chanceModifierLocal = 1f; - if (v.getName().startsWith("twilightforest.entity")) { - frand.forceFloatValue = 0f; - chanceModifierLocal = 0.25f; + } else try { + Class<?> cl = e.getClass(); + boolean detectedException; + do { + detectedException = false; + try { + cl.getDeclaredMethod(addRandomArmorName); + } catch (Exception ex) { + detectedException = true; + cl = cl.getSuperclass(); + } + } while (detectedException && !cl.equals(Entity.class)); + if (cl.equals(EntityLiving.class) || cl.equals(Entity.class)) throw new Exception(); + cl = e.getClass(); + do { + detectedException = false; + try { + cl.getDeclaredMethod(enchantEquipmentName); + } catch (Exception ex) { + detectedException = true; + cl = cl.getSuperclass(); } - second = false; - do { - addRandomArmor.invoke(e); - if (!usingVanillaEnchantingMethod) enchantEquipment.invoke(e); - ItemStack[] lastActiveItems = e.getLastActiveItems(); - for (int j = 0, lastActiveItemsLength = lastActiveItems.length; - j < lastActiveItemsLength; - j++) { - ItemStack stack = lastActiveItems[j]; - if (stack != null) { - if (LoaderReference.Thaumcraft) - if (stack.getItem() instanceof ItemWandCasting) - continue; // crashes the game when rendering in GUI - - int randomenchant = -1; - if (stack.hasTagCompound() - && stack.stackTagCompound.hasKey(randomEnchantmentDetectedString)) { - randomenchant = stack.stackTagCompound.getInteger(randomEnchantmentDetectedString); - stack.stackTagCompound.removeTag("ench"); - } - dropinstance i = additionaldrops.add( + } while (detectedException && !cl.equals(EntityLiving.class)); + boolean usingVanillaEnchantingMethod = cl.equals(EntityLiving.class); + double chanceModifierLocal = 1f; + if (v.getName().startsWith("twilightforest.entity")) { + frand.forceFloatValue = 0f; + chanceModifierLocal = 0.25f; + } + second = false; + do { + addRandomArmor.invoke(e); + if (!usingVanillaEnchantingMethod) enchantEquipment.invoke(e); + ItemStack[] lastActiveItems = e.getLastActiveItems(); + for (int j = 0, lastActiveItemsLength = lastActiveItems.length; j < lastActiveItemsLength; j++) { + ItemStack stack = lastActiveItems[j]; + if (stack != null) { + if (LoaderReference.Thaumcraft) if (stack.getItem() instanceof ItemWandCasting) continue; // crashes + // the + // game + // when + // rendering + // in + // GUI + + int randomenchant = -1; + if (stack.hasTagCompound() + && stack.stackTagCompound.hasKey(randomEnchantmentDetectedString)) { + randomenchant = stack.stackTagCompound.getInteger(randomEnchantmentDetectedString); + stack.stackTagCompound.removeTag("ench"); + } + dropinstance i = additionaldrops.add( + new dropinstance(stack.copy(), additionaldrops), + frand.chance * chanceModifierLocal + * (usingVanillaEnchantingMethod ? (j == 0 ? 0.75d : 0.5d) : 1d)); + if (!i.isDamageRandomized && i.stack.isItemStackDamageable()) { + i.isDamageRandomized = true; + int maxdamage = i.stack.getMaxDamage(); + int max = Math.max(maxdamage - 25, 1); + for (int d = Math.min(max, 25); d <= max; d++) i.damagesPossible.put(d, 1); + } + if (!i.isEnchatmentRandomized && randomenchant != -1) { + i.isEnchatmentRandomized = true; + i.enchantmentLevel = randomenchant; + } + if (usingVanillaEnchantingMethod) { + if (!stack.hasTagCompound()) stack.stackTagCompound = new NBTTagCompound(); + stack.stackTagCompound.setInteger(randomEnchantmentDetectedString, 14); + dropinstance newdrop = additionaldrops.add( new dropinstance(stack.copy(), additionaldrops), - frand.chance - * chanceModifierLocal - * (usingVanillaEnchantingMethod ? (j == 0 ? 0.75d : 0.5d) : 1d)); - if (!i.isDamageRandomized && i.stack.isItemStackDamageable()) { - i.isDamageRandomized = true; - int maxdamage = i.stack.getMaxDamage(); - int max = Math.max(maxdamage - 25, 1); - for (int d = Math.min(max, 25); d <= max; d++) i.damagesPossible.put(d, 1); - } - if (!i.isEnchatmentRandomized && randomenchant != -1) { - i.isEnchatmentRandomized = true; - i.enchantmentLevel = randomenchant; - } - if (usingVanillaEnchantingMethod) { - if (!stack.hasTagCompound()) stack.stackTagCompound = new NBTTagCompound(); - stack.stackTagCompound.setInteger(randomEnchantmentDetectedString, 14); - dropinstance newdrop = additionaldrops.add( - new dropinstance(stack.copy(), additionaldrops), - frand.chance * chanceModifierLocal * (j == 0 ? 0.25d : 0.5d)); - newdrop.isEnchatmentRandomized = true; - newdrop.enchantmentLevel = 14; - newdrop.isDamageRandomized = i.isDamageRandomized; - newdrop.damagesPossible = (HashMap<Integer, Integer>) i.damagesPossible.clone(); - } + frand.chance * chanceModifierLocal * (j == 0 ? 0.25d : 0.5d)); + newdrop.isEnchatmentRandomized = true; + newdrop.enchantmentLevel = 14; + newdrop.isDamageRandomized = i.isDamageRandomized; + newdrop.damagesPossible = (HashMap<Integer, Integer>) i.damagesPossible.clone(); } } - Arrays.fill(e.getLastActiveItems(), null); + } + Arrays.fill(e.getLastActiveItems(), null); - if (second && frand.chance < 0.0000001d) { - LOG.warn("Skipping " + k + " additional dropmap because it's too randomized"); - break; - } - second = true; + if (second && frand.chance < 0.0000001d) { + LOG.warn("Skipping " + k + " additional dropmap because it's too randomized"); + break; + } + second = true; - } while (frand.nextRound()); - } catch (Exception ignored) { - } + } while (frand.nextRound()); + } catch (Exception ignored) {} frand.newRound(); collector.newRound(); @@ -1025,14 +1004,15 @@ public class MobRecipeLoader { chance = 1; } dropinstance dlooting = dropslooting.get(drop); - moboutputs.add(new MobDrop( - stack, - MobDrop.DropType.Normal, - chance, - drop.isEnchatmentRandomized ? drop.enchantmentLevel : null, - drop.isDamageRandomized ? drop.damagesPossible : null, - dlooting != null && dlooting.dropcount > drop.dropcount, - false)); + moboutputs.add( + new MobDrop( + stack, + MobDrop.DropType.Normal, + chance, + drop.isEnchatmentRandomized ? drop.enchantmentLevel : null, + drop.isDamageRandomized ? drop.damagesPossible : null, + dlooting != null && dlooting.dropcount > drop.dropcount, + false)); } for (dropinstance drop : raredrops.drops) { ItemStack stack = drop.stack; @@ -1047,14 +1027,15 @@ public class MobRecipeLoader { LOG.warn("Detected 0% loot, setting to 0.01%"); chance = 1; } - moboutputs.add(new MobDrop( - stack, - MobDrop.DropType.Rare, - chance, - drop.isEnchatmentRandomized ? drop.enchantmentLevel : null, - drop.isDamageRandomized ? drop.damagesPossible : null, - false, - false)); + moboutputs.add( + new MobDrop( + stack, + MobDrop.DropType.Rare, + chance, + drop.isEnchatmentRandomized ? drop.enchantmentLevel : null, + drop.isDamageRandomized ? drop.damagesPossible : null, + false, + false)); } for (dropinstance drop : superraredrops.drops) { if (raredrops.contains(drop)) continue; @@ -1070,14 +1051,15 @@ public class MobRecipeLoader { LOG.warn("Detected 0% loot, setting to 0.01%"); chance = 1; } - moboutputs.add(new MobDrop( - stack, - MobDrop.DropType.Rare, - chance, - drop.isEnchatmentRandomized ? drop.enchantmentLevel : null, - drop.isDamageRandomized ? drop.damagesPossible : null, - false, - false)); + moboutputs.add( + new MobDrop( + stack, + MobDrop.DropType.Rare, + chance, + drop.isEnchatmentRandomized ? drop.enchantmentLevel : null, + drop.isDamageRandomized ? drop.damagesPossible : null, + false, + false)); } for (dropinstance drop : additionaldrops.drops) { ItemStack stack = drop.stack; @@ -1092,14 +1074,15 @@ public class MobRecipeLoader { LOG.warn("Detected 0% loot, setting to 0.01%"); chance = 1; } - moboutputs.add(new MobDrop( - stack, - MobDrop.DropType.Additional, - chance, - drop.isEnchatmentRandomized ? drop.enchantmentLevel : null, - drop.isDamageRandomized ? drop.damagesPossible : null, - false, - false)); + moboutputs.add( + new MobDrop( + stack, + MobDrop.DropType.Additional, + chance, + drop.isEnchatmentRandomized ? drop.enchantmentLevel : null, + drop.isDamageRandomized ? drop.damagesPossible : null, + false, + false)); } GeneralMobList.put(k, new GeneralMappedMob(e, MobRecipe.generateMobRecipe(e, k, moboutputs), moboutputs)); @@ -1130,11 +1113,9 @@ public class MobRecipeLoader { } catch (Exception e) { e.printStackTrace(); } finally { - if (writer != null) - try { - writer.close(); - } catch (Exception ignored) { - } + if (writer != null) try { + writer.close(); + } catch (Exception ignored) {} } } @@ -1170,11 +1151,10 @@ public class MobRecipeLoader { if (override.removeAll) { drops.clear(); recipe.mOutputs.clear(); - } else - for (OverridesConfig.MobDropSimplified removal : override.removals) { - drops.removeIf(removal::isMatching); - recipe.mOutputs.removeIf(removal::isMatching); - } + } else for (OverridesConfig.MobDropSimplified removal : override.removals) { + drops.removeIf(removal::isMatching); + recipe.mOutputs.removeIf(removal::isMatching); + } drops.addAll(override.additions); recipe.mOutputs.addAll(override.additions); LoadConfigPacket.instance.mobsOverrides.put(k, override); @@ -1195,8 +1175,8 @@ public class MobRecipeLoader { } @SideOnly(Side.CLIENT) - public static void processMobRecipeMap( - HashSet<String> mobs, HashMap<String, OverridesConfig.MobOverride> overrides) { + public static void processMobRecipeMap(HashSet<String> mobs, + HashMap<String, OverridesConfig.MobOverride> overrides) { if (isClientSided) Mob_Handler.clearRecipes(); MobNameToRecipeMap.clear(); mobs.forEach(k -> { @@ -1216,11 +1196,10 @@ public class MobRecipeLoader { if (override.removeAll) { drops.clear(); recipe.mOutputs.clear(); - } else - for (OverridesConfig.MobDropSimplified removal : override.removals) { - drops.removeIf(removal::isMatching); - recipe.mOutputs.removeIf(removal::isMatching); - } + } else for (OverridesConfig.MobDropSimplified removal : override.removals) { + drops.removeIf(removal::isMatching); + recipe.mOutputs.removeIf(removal::isMatching); + } drops.addAll(override.additions); recipe.mOutputs.addAll(override.additions); drops.sort(Comparator.comparing(d -> d.type)); // Fix GUI @@ -1236,6 +1215,7 @@ public class MobRecipeLoader { } private static class Optionals { + private static void parseMTAdditions(String k, ArrayList<MobDrop> drops, MobRecipe recipe) { IEntityDefinition ie = MineTweakerAPI.game.getEntity(k); if (ie != null) { @@ -1251,12 +1231,17 @@ public class MobRecipeLoader { } ItemStack stack = ((ItemStack) entry.getKey().getInternal()).copy(); MobDrop drop = new MobDrop( - stack, MobDrop.DropType.Normal, (int) (chance * 10000), null, null, false, false); + stack, + MobDrop.DropType.Normal, + (int) (chance * 10000), + null, + null, + false, + false); drops.add(drop); recipe.mOutputs.add(drop); } - for (Map.Entry<IItemStack, IntRange> entry : - ie.getDropsToAddPlayerOnly().entrySet()) { + for (Map.Entry<IItemStack, IntRange> entry : ie.getDropsToAddPlayerOnly().entrySet()) { IntRange r = entry.getValue(); // Get average chance double chance; @@ -1268,12 +1253,17 @@ public class MobRecipeLoader { } ItemStack stack = ((ItemStack) entry.getKey().getInternal()).copy(); MobDrop drop = new MobDrop( - stack, MobDrop.DropType.Normal, (int) (chance * 10000), null, null, false, true); + stack, + MobDrop.DropType.Normal, + (int) (chance * 10000), + null, + null, + false, + true); drops.add(drop); } for (IItemStack istack : ie.getDropsToRemove()) { - List<MobDrop> toRemove = drops.stream() - .filter(d -> istack.matches(new MCItemStack(d.stack))) + List<MobDrop> toRemove = drops.stream().filter(d -> istack.matches(new MCItemStack(d.stack))) .collect(Collectors.toList()); drops.removeAll(toRemove); recipe.mOutputs.removeAll(toRemove); diff --git a/src/main/java/kubatech/loaders/RecipeLoader.java b/src/main/java/kubatech/loaders/RecipeLoader.java index 6fbc62c7cc..dc70c183e8 100644 --- a/src/main/java/kubatech/loaders/RecipeLoader.java +++ b/src/main/java/kubatech/loaders/RecipeLoader.java @@ -1,53 +1,48 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders; import static kubatech.api.enums.ItemList.*; -import com.dreammaster.gthandler.CustomItemList; -import cpw.mods.fml.common.registry.GameRegistry; -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.lib.CORE; import java.lang.reflect.InvocationTargetException; + import kubatech.Tags; import kubatech.api.LoaderReference; import kubatech.api.enums.ItemList; import kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber; import kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_MegaIndustrialApiary; + import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import com.dreammaster.gthandler.CustomItemList; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; + public class RecipeLoader { private static final Logger LOG = LogManager.getLogger(Tags.MODID + "[Recipe Loader]"); - protected static final long bitsd = GT_ModHandler.RecipeBits.NOT_REMOVABLE - | GT_ModHandler.RecipeBits.REVERSIBLE + protected static final long bitsd = GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.DISMANTLEABLE; @@ -61,19 +56,12 @@ public class RecipeLoader { "multimachine.exterminationchamber", "Extreme Extermination Chamber", LoaderReference.EnderIO)) { - GT_ModHandler.addCraftingRecipe(ItemList.ExtremeExterminationChamber.get(1), bitsd, new Object[] { - "RCR", - "CHC", - "VVV", - 'R', - gregtech.api.enums.ItemList.Robot_Arm_EV, - 'C', - OrePrefixes.circuit.get(Materials.Data), - 'H', - gregtech.api.enums.ItemList.Hull_EV, - 'V', - GT_ModHandler.getModItem("OpenBlocks", "vacuumhopper", 1, new ItemStack(Blocks.hopper)) - }); + GT_ModHandler.addCraftingRecipe( + ItemList.ExtremeExterminationChamber.get(1), + bitsd, + new Object[] { "RCR", "CHC", "VVV", 'R', gregtech.api.enums.ItemList.Robot_Arm_EV, 'C', + OrePrefixes.circuit.get(Materials.Data), 'H', gregtech.api.enums.ItemList.Hull_EV, 'V', + GT_ModHandler.getModItem("OpenBlocks", "vacuumhopper", 1, new ItemStack(Blocks.hopper)) }); } if (registerMTE( ExtremeIndustrialApiary, @@ -84,20 +72,16 @@ public class RecipeLoader { GT_Values.RA.addAssemblylineRecipe( gregtech.api.enums.ItemList.Machine_IndustrialApiary.get(1), 10000, - new Object[] { - gregtech.api.enums.ItemList.Machine_IndustrialApiary.get(64L), - gregtech.api.enums.ItemList.IndustrialApiary_Upgrade_Acceleration_8_Upgraded.get(64L), - gregtech.api.enums.ItemList.IndustrialApiary_Upgrade_STABILIZER.get(64L), - gregtech.api.enums.ItemList.Robot_Arm_UV.get(16L), - new Object[] {OrePrefixes.circuit.get(Materials.SuperconductorUHV), 4L}, - new Object[] {OrePrefixes.circuit.get(Materials.SuperconductorUHV), 4L}, - new Object[] {OrePrefixes.circuit.get(Materials.SuperconductorUHV), 4L}, - new Object[] {OrePrefixes.circuit.get(Materials.SuperconductorUHV), 4L}, - }, - new FluidStack[] { - FluidRegistry.getFluidStack("molten.indalloy140", 28800), - FluidRegistry.getFluidStack("for.honey", 20000) - }, + new Object[] { gregtech.api.enums.ItemList.Machine_IndustrialApiary.get(64L), + gregtech.api.enums.ItemList.IndustrialApiary_Upgrade_Acceleration_8_Upgraded.get(64L), + gregtech.api.enums.ItemList.IndustrialApiary_Upgrade_STABILIZER.get(64L), + gregtech.api.enums.ItemList.Robot_Arm_UV.get(16L), + new Object[] { OrePrefixes.circuit.get(Materials.SuperconductorUHV), 4L }, + new Object[] { OrePrefixes.circuit.get(Materials.SuperconductorUHV), 4L }, + new Object[] { OrePrefixes.circuit.get(Materials.SuperconductorUHV), 4L }, + new Object[] { OrePrefixes.circuit.get(Materials.SuperconductorUHV), 4L }, }, + new FluidStack[] { FluidRegistry.getFluidStack("molten.indalloy140", 28800), + FluidRegistry.getFluidStack("for.honey", 20000) }, ExtremeIndustrialApiary.get(1), 6000, 2_048_000); @@ -106,30 +90,29 @@ public class RecipeLoader { if (MTEID > MTEIDMax + 1) throw new RuntimeException("MTE ID's"); } - private static boolean registerMTE( - ItemList item, Class<? extends MetaTileEntity> mte, String aName, String aNameRegional) { + private static boolean registerMTE(ItemList item, Class<? extends MetaTileEntity> mte, String aName, + String aNameRegional) { return registerMTE(item, mte, aName, aNameRegional, true); } - private static boolean registerMTE( - ItemList item, Class<? extends MetaTileEntity> mte, String aName, String aNameRegional, boolean... deps) { + private static boolean registerMTE(ItemList item, Class<? extends MetaTileEntity> mte, String aName, + String aNameRegional, boolean... deps) { boolean dep = true; - for (boolean i : deps) - if (!i) { - dep = false; - break; - } + for (boolean i : deps) if (!i) { + dep = false; + break; + } return registerMTE(item, mte, aName, aNameRegional, dep); } - private static boolean registerMTE( - ItemList item, Class<? extends MetaTileEntity> mte, String aName, String aNameRegional, boolean dep) { + private static boolean registerMTE(ItemList item, Class<? extends MetaTileEntity> mte, String aName, + String aNameRegional, boolean dep) { if (MTEID > MTEIDMax) throw new RuntimeException("MTE ID's"); if (dep) { try { - item.set(mte.getConstructor(int.class, String.class, String.class) - .newInstance(MTEID, aName, aNameRegional) - .getStackForm(1)); + item.set( + mte.getConstructor(int.class, String.class, String.class) + .newInstance(MTEID, aName, aNameRegional).getStackForm(1)); } catch (InvocationTargetException ex) { Throwable original_ex = ex.getCause(); if (original_ex instanceof RuntimeException) throw (RuntimeException) original_ex; @@ -156,81 +139,93 @@ public class RecipeLoader { } private static void RegisterTeaLine() { - // TEA LINE // + // TEA LINE // if (LoaderReference.GTPlusPlus && LoaderReference.HarvestCraft) { CORE.RA.addDehydratorRecipe( - new ItemStack[] {GameRegistry.findItemStack("harvestcraft", "tealeafItem", 1)}, + new ItemStack[] { GameRegistry.findItemStack("harvestcraft", "tealeafItem", 1) }, null, null, - new ItemStack[] {TeaLeafDehydrated.get(1)}, + new ItemStack[] { TeaLeafDehydrated.get(1) }, null, 100, 32); CORE.RA.addDehydratorRecipe( - new ItemStack[] {TeaLeafDehydrated.get(1)}, + new ItemStack[] { TeaLeafDehydrated.get(1) }, null, null, - new ItemStack[] {WhiteTeaLeaf.get(1)}, + new ItemStack[] { WhiteTeaLeaf.get(1) }, null, 100, 32); GT_Values.RA.addMixerRecipe( - new ItemStack[] {TeaLeafDehydrated.get(1)}, - new FluidStack[] {FluidRegistry.getFluidStack("water", 50)}, - new ItemStack[] {SteamedTeaLeaf.get(1)}, + new ItemStack[] { TeaLeafDehydrated.get(1) }, + new FluidStack[] { FluidRegistry.getFluidStack("water", 50) }, + new ItemStack[] { SteamedTeaLeaf.get(1) }, null, 100, 32); CORE.RA.addDehydratorRecipe( - new ItemStack[] {SteamedTeaLeaf.get(1)}, + new ItemStack[] { SteamedTeaLeaf.get(1) }, null, null, - new ItemStack[] {YellowTeaLeaf.get(1)}, + new ItemStack[] { YellowTeaLeaf.get(1) }, null, 100, 32); GT_Values.RA.addBenderRecipe(TeaLeafDehydrated.get(1), RolledTeaLeaf.get(1), 100, 32); CORE.RA.addDehydratorRecipe( - new ItemStack[] {RolledTeaLeaf.get(1)}, + new ItemStack[] { RolledTeaLeaf.get(1) }, null, null, - new ItemStack[] {GreenTeaLeaf.get(1)}, + new ItemStack[] { GreenTeaLeaf.get(1) }, null, 100, 32); GT_Values.RA.addChemicalRecipe( - RolledTeaLeaf.get(1), GT_Utility.getIntegratedCircuit(1), OxidizedTeaLeaf.get(1), 100, 32); + RolledTeaLeaf.get(1), + GT_Utility.getIntegratedCircuit(1), + OxidizedTeaLeaf.get(1), + 100, + 32); CORE.RA.addDehydratorRecipe( - new ItemStack[] {OxidizedTeaLeaf.get(1)}, + new ItemStack[] { OxidizedTeaLeaf.get(1) }, null, null, - new ItemStack[] {BlackTeaLeaf.get(1)}, + new ItemStack[] { BlackTeaLeaf.get(1) }, null, 100, 32); GT_Values.RA.addChemicalRecipe( - RolledTeaLeaf.get(1), GT_Utility.getIntegratedCircuit(2), FermentedTeaLeaf.get(1), 200, 32); + RolledTeaLeaf.get(1), + GT_Utility.getIntegratedCircuit(2), + FermentedTeaLeaf.get(1), + 200, + 32); CORE.RA.addDehydratorRecipe( - new ItemStack[] {FermentedTeaLeaf.get(1)}, + new ItemStack[] { FermentedTeaLeaf.get(1) }, null, null, - new ItemStack[] {PuerhTeaLeaf.get(1)}, + new ItemStack[] { PuerhTeaLeaf.get(1) }, null, 100, 32); GT_Values.RA.addCutterRecipe( - new ItemStack[] {TeaLeafDehydrated.get(1)}, - new ItemStack[] {BruisedTeaLeaf.get(1)}, + new ItemStack[] { TeaLeafDehydrated.get(1) }, + new ItemStack[] { BruisedTeaLeaf.get(1) }, 100, 32, false); GT_Values.RA.addChemicalRecipe( - BruisedTeaLeaf.get(1), GT_Utility.getIntegratedCircuit(1), PartiallyOxidizedTeaLeaf.get(1), 50, 32); + BruisedTeaLeaf.get(1), + GT_Utility.getIntegratedCircuit(1), + PartiallyOxidizedTeaLeaf.get(1), + 50, + 32); CORE.RA.addDehydratorRecipe( - new ItemStack[] {PartiallyOxidizedTeaLeaf.get(1)}, + new ItemStack[] { PartiallyOxidizedTeaLeaf.get(1) }, null, null, - new ItemStack[] {OolongTeaLeaf.get(1)}, + new ItemStack[] { OolongTeaLeaf.get(1) }, null, 100, 32); @@ -238,32 +233,32 @@ public class RecipeLoader { // Tea Assembly GameRegistry.addSmelting(BlackTeaLeaf.get(1), BlackTea.get(1), 10); GT_Values.RA.addMixerRecipe( - new ItemStack[] {BlackTea.get(1), GameRegistry.findItemStack("harvestcraft", "limejuiceItem", 1)}, + new ItemStack[] { BlackTea.get(1), GameRegistry.findItemStack("harvestcraft", "limejuiceItem", 1) }, null, - new ItemStack[] {EarlGrayTea.get(1)}, + new ItemStack[] { EarlGrayTea.get(1) }, null, 100, 32); GameRegistry.addSmelting(GreenTeaLeaf.get(1), GreenTea.get(1), 10); GT_Values.RA.addMixerRecipe( - new ItemStack[] {BlackTea.get(1)}, - new FluidStack[] {FluidRegistry.getFluidStack("potion.lemonjuice", 1000)}, - new ItemStack[] {LemonTea.get(1)}, + new ItemStack[] { BlackTea.get(1) }, + new FluidStack[] { FluidRegistry.getFluidStack("potion.lemonjuice", 1000) }, + new ItemStack[] { LemonTea.get(1) }, null, 100, 32); GT_Values.RA.addMixerRecipe( - new ItemStack[] {BlackTea.get(1)}, - new FluidStack[] {FluidRegistry.getFluidStack("milk", 1000)}, - new ItemStack[] {MilkTea.get(1)}, + new ItemStack[] { BlackTea.get(1) }, + new FluidStack[] { FluidRegistry.getFluidStack("milk", 1000) }, + new ItemStack[] { MilkTea.get(1) }, null, 100, 32); GameRegistry.addSmelting(OolongTeaLeaf.get(1), OolongTea.get(1), 10); GT_Values.RA.addMixerRecipe( - new ItemStack[] {GameRegistry.findItemStack("harvestcraft", "peppermintItem", 1)}, - new FluidStack[] {FluidRegistry.getFluidStack("water", 1000)}, - new ItemStack[] {PeppermintTea.get(1)}, + new ItemStack[] { GameRegistry.findItemStack("harvestcraft", "peppermintItem", 1) }, + new FluidStack[] { FluidRegistry.getFluidStack("water", 1000) }, + new ItemStack[] { PeppermintTea.get(1) }, null, 100, 32); @@ -275,17 +270,15 @@ public class RecipeLoader { GT_Values.RA.addAssemblylineRecipe( TeaAcceptorResearchNote.get(1), 10000, - new Object[] { - LegendaryUltimateTea.get(0), - GameRegistry.findItemStack("Avaritia", "Neutronium_Compressor", 1), - gregtech.api.enums.ItemList.Quantum_Tank_EV.get(1), - CustomItemList.FluidExtractorUHV.get(10), - new Object[] {OrePrefixes.circuit.get(Materials.SuperconductorUHV), 4L}, - new Object[] {OrePrefixes.circuit.get(Materials.SuperconductorUHV), 4L}, - new Object[] {OrePrefixes.circuit.get(Materials.SuperconductorUHV), 4L}, - new Object[] {OrePrefixes.circuit.get(Materials.SuperconductorUHV), 4L}, - }, - new FluidStack[] {FluidRegistry.getFluidStack("molten.indalloy140", 28800)}, + new Object[] { LegendaryUltimateTea.get(0), + GameRegistry.findItemStack("Avaritia", "Neutronium_Compressor", 1), + gregtech.api.enums.ItemList.Quantum_Tank_EV.get(1), + CustomItemList.FluidExtractorUHV.get(10), + new Object[] { OrePrefixes.circuit.get(Materials.SuperconductorUHV), 4L }, + new Object[] { OrePrefixes.circuit.get(Materials.SuperconductorUHV), 4L }, + new Object[] { OrePrefixes.circuit.get(Materials.SuperconductorUHV), 4L }, + new Object[] { OrePrefixes.circuit.get(Materials.SuperconductorUHV), 4L }, }, + new FluidStack[] { FluidRegistry.getFluidStack("molten.indalloy140", 28800) }, TeaAcceptor.get(1), 6000, 2_048_000); diff --git a/src/main/java/kubatech/loaders/TCLoader.java b/src/main/java/kubatech/loaders/TCLoader.java index 2ead8998f9..fb803e0198 100644 --- a/src/main/java/kubatech/loaders/TCLoader.java +++ b/src/main/java/kubatech/loaders/TCLoader.java @@ -1,36 +1,29 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders; -import cpw.mods.fml.common.registry.GameRegistry; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.stream.Collectors; + import kubatech.api.LoaderReference; import kubatech.api.enums.ItemList; import kubatech.api.utils.ItemID; import kubatech.loaders.item.items.TeaUltimate; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; + import thaumcraft.api.ThaumcraftApi; import thaumcraft.api.ThaumcraftApiHelper; import thaumcraft.api.aspects.Aspect; @@ -39,8 +32,10 @@ import thaumcraft.api.crafting.InfusionRecipe; import thaumcraft.api.research.ResearchCategories; import thaumcraft.api.research.ResearchItem; import thaumcraft.api.research.ResearchPage; +import cpw.mods.fml.common.registry.GameRegistry; public class TCLoader { + private static boolean lateLoaded = false; public static void load() {} @@ -56,97 +51,79 @@ public class TCLoader { private static void registerRecipe() { if (ultimateTeaRecipe != null) return; final ItemStack[] components = new ItemStack[] { - // ItemList.LegendaryBlackTea.get(1), - // ItemList.LegendaryButterflyTea.get(1), - ItemList.LegendaryEarlGrayTea.get(1), // MApiary - ItemList.LegendaryGreenTea.get(1), // EIG - // ItemList.LegendaryLemonTea.get(1), - // ItemList.LegendaryMilkTea.get(1), - // ItemList.LegendaryOolongTea.get(1), - ItemList.LegendaryPeppermintTea.get(1), // HTGR - ItemList.LegendaryPuerhTea.get(1), // EEC - // ItemList.LegendaryRedTea.get(1), - // ItemList.LegendaryWhiteTea.get(1), - ItemList.LegendaryYellowTea.get(1), // IApiary - ItemList.BlackTea.get(1), - ItemList.EarlGrayTea.get(1), - ItemList.GreenTea.get(1), - ItemList.LemonTea.get(1), - ItemList.MilkTea.get(1), - ItemList.OolongTea.get(1), - ItemList.PeppermintTea.get(1), - ItemList.PuerhTea.get(1), - ItemList.WhiteTea.get(1), - ItemList.YellowTea.get(1) - }; + // ItemList.LegendaryBlackTea.get(1), + // ItemList.LegendaryButterflyTea.get(1), + ItemList.LegendaryEarlGrayTea.get(1), // MApiary + ItemList.LegendaryGreenTea.get(1), // EIG + // ItemList.LegendaryLemonTea.get(1), + // ItemList.LegendaryMilkTea.get(1), + // ItemList.LegendaryOolongTea.get(1), + ItemList.LegendaryPeppermintTea.get(1), // HTGR + ItemList.LegendaryPuerhTea.get(1), // EEC + // ItemList.LegendaryRedTea.get(1), + // ItemList.LegendaryWhiteTea.get(1), + ItemList.LegendaryYellowTea.get(1), // IApiary + ItemList.BlackTea.get(1), ItemList.EarlGrayTea.get(1), ItemList.GreenTea.get(1), + ItemList.LemonTea.get(1), ItemList.MilkTea.get(1), ItemList.OolongTea.get(1), + ItemList.PeppermintTea.get(1), ItemList.PuerhTea.get(1), ItemList.WhiteTea.get(1), + ItemList.YellowTea.get(1) }; final HashSet<ItemID> componentsHashed = Arrays.stream(components) .map(stack -> ItemID.create_NoCopy(stack, true, false, true)) .collect(Collectors.toCollection(HashSet::new)); - //noinspection unchecked - ThaumcraftApi.getCraftingRecipes() - .add( - ultimateTeaRecipe = - new InfusionRecipe( - "KT_UltimateTea", - ItemList.LegendaryUltimateTea.get(1), - 10, - new AspectList() - .add(Aspect.MAGIC, 100) - .add(Aspect.HEAL, 100) - .add(Aspect.PLANT, 100) - .add(Aspect.EXCHANGE, 100), - GameRegistry.findItemStack("DraconicEvolution", "dezilsMarshmallow", 1), - components) { - @Override - public boolean matches( - ArrayList<ItemStack> input, - ItemStack central, - World world, - EntityPlayer player) { - if (!central.isItemEqual(getRecipeInput())) return false; - if (!ThaumcraftApiHelper.isResearchComplete( - player.getCommandSenderName(), this.research)) return false; - if (componentsHashed.size() > input.size()) return false; - HashSet<ItemID> hashedInputs = input.stream() - .map(stack -> ItemID.create_NoCopy(stack, true, false, true)) - .collect(Collectors.toCollection(HashSet::new)); - return hashedInputs.containsAll(componentsHashed); - } - }); + // noinspection unchecked + ThaumcraftApi.getCraftingRecipes().add( + ultimateTeaRecipe = new InfusionRecipe( + "KT_UltimateTea", + ItemList.LegendaryUltimateTea.get(1), + 10, + new AspectList().add(Aspect.MAGIC, 100).add(Aspect.HEAL, 100).add(Aspect.PLANT, 100) + .add(Aspect.EXCHANGE, 100), + GameRegistry.findItemStack("DraconicEvolution", "dezilsMarshmallow", 1), + components) { + + @Override + public boolean matches(ArrayList<ItemStack> input, ItemStack central, World world, + EntityPlayer player) { + if (!central.isItemEqual(getRecipeInput())) return false; + if (!ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), this.research)) + return false; + if (componentsHashed.size() > input.size()) return false; + HashSet<ItemID> hashedInputs = input.stream() + .map(stack -> ItemID.create_NoCopy(stack, true, false, true)) + .collect(Collectors.toCollection(HashSet::new)); + return hashedInputs.containsAll(componentsHashed); + } + }); } private static ResearchItem ultimateTeaResearch = null; private static void registerResearch() { if (ultimateTeaResearch == null) { - ultimateTeaResearch = - new ResearchItem( - "KT_UltimateTea", - "NEWHORIZONS", - new AspectList() - .add(Aspect.MAGIC, 1) - .add(Aspect.HEAL, 1) - .add(Aspect.PLANT, 1) - .add(Aspect.EXCHANGE, 1), - -2, - 4, - 2, - ItemList.LegendaryUltimateTea.get(1)) { - @Override - public String getName() { - return TeaUltimate.getUltimateTeaDisplayName(super.getName()); - } - }; - ultimateTeaResearch.setPages( - new ResearchPage("KT.research.ultimatetea") { - @Override - public String getTranslatedText() { - return TeaUltimate.getUltimateTeaDisplayName(super.getTranslatedText()); - } - }, - new ResearchPage(ultimateTeaRecipe)); + ultimateTeaResearch = new ResearchItem( + "KT_UltimateTea", + "NEWHORIZONS", + new AspectList().add(Aspect.MAGIC, 1).add(Aspect.HEAL, 1).add(Aspect.PLANT, 1) + .add(Aspect.EXCHANGE, 1), + -2, + 4, + 2, + ItemList.LegendaryUltimateTea.get(1)) { + + @Override + public String getName() { + return TeaUltimate.getUltimateTeaDisplayName(super.getName()); + } + }; + ultimateTeaResearch.setPages(new ResearchPage("KT.research.ultimatetea") { + + @Override + public String getTranslatedText() { + return TeaUltimate.getUltimateTeaDisplayName(super.getTranslatedText()); + } + }, new ResearchPage(ultimateTeaRecipe)); ultimateTeaResearch.setParents("INFUSION", "DEZILSMARSHMALLOW"); ThaumcraftApi.addWarpToResearch("KT_UltimateTea", 20); } diff --git a/src/main/java/kubatech/loaders/block/BlockProxy.java b/src/main/java/kubatech/loaders/block/BlockProxy.java index a12acc4de7..4ce6aa820d 100644 --- a/src/main/java/kubatech/loaders/block/BlockProxy.java +++ b/src/main/java/kubatech/loaders/block/BlockProxy.java @@ -1,29 +1,21 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders.block; import static kubatech.loaders.block.KubaBlock.defaultTileEntityUI; -import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; import java.util.List; + import kubatech.Tags; + import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; @@ -34,6 +26,8 @@ import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; + public class BlockProxy { private final String unlocalizedName; diff --git a/src/main/java/kubatech/loaders/block/IProxyTileEntityProvider.java b/src/main/java/kubatech/loaders/block/IProxyTileEntityProvider.java index b2a94c09b7..f39887a9ef 100644 --- a/src/main/java/kubatech/loaders/block/IProxyTileEntityProvider.java +++ b/src/main/java/kubatech/loaders/block/IProxyTileEntityProvider.java @@ -4,5 +4,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public interface IProxyTileEntityProvider { + TileEntity createTileEntity(World world); } diff --git a/src/main/java/kubatech/loaders/block/KubaBlock.java b/src/main/java/kubatech/loaders/block/KubaBlock.java index abf1e91dd7..831757f332 100644 --- a/src/main/java/kubatech/loaders/block/KubaBlock.java +++ b/src/main/java/kubatech/loaders/block/KubaBlock.java @@ -1,39 +1,24 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders.block; import static kubatech.kubatech.KT; -import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; -import com.gtnewhorizons.modularui.api.screen.ModularUIContext; -import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.api.screen.UIBuildContext; -import com.gtnewhorizons.modularui.common.builder.UIBuilder; -import com.gtnewhorizons.modularui.common.builder.UIInfo; -import com.gtnewhorizons.modularui.common.internal.wrapper.ModularGui; -import com.gtnewhorizons.modularui.common.internal.wrapper.ModularUIContainer; import java.lang.ref.WeakReference; import java.util.HashMap; import java.util.List; import java.util.function.Function; + import kubatech.loaders.BlockLoader; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -47,32 +32,38 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; +import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; +import com.gtnewhorizons.modularui.api.screen.ModularUIContext; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.builder.UIBuilder; +import com.gtnewhorizons.modularui.common.builder.UIInfo; +import com.gtnewhorizons.modularui.common.internal.wrapper.ModularGui; +import com.gtnewhorizons.modularui.common.internal.wrapper.ModularUIContainer; + public class KubaBlock extends Block { - public static final Function<IModularUIContainerCreator, UIInfo<?, ?>> TileEntityUIFactory = - containerConstructor -> UIBuilder.of() - .container((player, world, x, y, z) -> { - TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof ITileWithModularUI) { - UIBuildContext buildContext = new UIBuildContext(player); - ModularWindow window = ((ITileWithModularUI) te).createWindow(buildContext); - return containerConstructor.createUIContainer( - new ModularUIContext(buildContext, te::markDirty), window); - } - return null; - }) - .gui(((player, world, x, y, z) -> { - if (!world.isRemote) return null; - TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof ITileWithModularUI) { - UIBuildContext buildContext = new UIBuildContext(player); - ModularWindow window = ((ITileWithModularUI) te).createWindow(buildContext); - return new ModularGui(containerConstructor.createUIContainer( - new ModularUIContext(buildContext, null), window)); - } - return null; - })) - .build(); + public static final Function<IModularUIContainerCreator, UIInfo<?, ?>> TileEntityUIFactory = containerConstructor -> UIBuilder + .of().container((player, world, x, y, z) -> { + TileEntity te = world.getTileEntity(x, y, z); + if (te instanceof ITileWithModularUI) { + UIBuildContext buildContext = new UIBuildContext(player); + ModularWindow window = ((ITileWithModularUI) te).createWindow(buildContext); + return containerConstructor + .createUIContainer(new ModularUIContext(buildContext, te::markDirty), window); + } + return null; + }).gui(((player, world, x, y, z) -> { + if (!world.isRemote) return null; + TileEntity te = world.getTileEntity(x, y, z); + if (te instanceof ITileWithModularUI) { + UIBuildContext buildContext = new UIBuildContext(player); + ModularWindow window = ((ITileWithModularUI) te).createWindow(buildContext); + return new ModularGui( + containerConstructor.createUIContainer(new ModularUIContext(buildContext, null), window)); + } + return null; + })).build(); public static final UIInfo<?, ?> defaultTileEntityUI = TileEntityUIFactory.apply(ModularUIContainer::new); @@ -137,36 +128,22 @@ public class KubaBlock extends Block { } @Override - public boolean onBlockActivated( - World p_149727_1_, - int p_149727_2_, - int p_149727_3_, - int p_149727_4_, - EntityPlayer p_149727_5_, - int p_149727_6_, - float p_149727_7_, - float p_149727_8_, - float p_149727_9_) { + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, + EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { return getBlock(p_149727_1_.getBlockMetadata(p_149727_2_, p_149727_3_, p_149727_4_)) .onActivated(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, p_149727_5_); } @Override - public void onBlockPlacedBy( - World p_149689_1_, - int p_149689_2_, - int p_149689_3_, - int p_149689_4_, - EntityLivingBase p_149689_5_, - ItemStack p_149689_6_) { + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, + EntityLivingBase p_149689_5_, ItemStack p_149689_6_) { getBlock(p_149689_6_.getItemDamage()) .onBlockPlaced(p_149689_1_, p_149689_2_, p_149689_3_, p_149689_4_, p_149689_5_, p_149689_6_); } @Override public float getBlockHardness(World p_149712_1_, int p_149712_2_, int p_149712_3_, int p_149712_4_) { - return getBlock(p_149712_1_.getBlockMetadata(p_149712_2_, p_149712_3_, p_149712_4_)) - .getHardness(); + return getBlock(p_149712_1_.getBlockMetadata(p_149712_2_, p_149712_3_, p_149712_4_)).getHardness(); } @Override @@ -182,25 +159,20 @@ public class KubaBlock extends Block { } @Override - public float getExplosionResistance( - Entity par1Entity, - World world, - int x, - int y, - int z, - double explosionX, - double explosionY, - double explosionZ) { + public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, + double explosionY, double explosionZ) { return getBlock(world.getBlockMetadata(x, y, z)).getResistance(); } @FunctionalInterface public interface IModularUIContainerCreator { + ModularUIContainer createUIContainer(ModularUIContext context, ModularWindow mainWindow); } @FunctionalInterface public interface IModularUIProvider { + UIInfo<?, ?> getUI(); } } diff --git a/src/main/java/kubatech/loaders/block/KubaItemBlock.java b/src/main/java/kubatech/loaders/block/KubaItemBlock.java index 1a9d057cd9..64f3124314 100644 --- a/src/main/java/kubatech/loaders/block/KubaItemBlock.java +++ b/src/main/java/kubatech/loaders/block/KubaItemBlock.java @@ -1,26 +1,19 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders.block; import java.util.List; + import kubatech.kubatech; + import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -28,6 +21,7 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; public class KubaItemBlock extends ItemBlock { + public KubaItemBlock(Block p_i45328_1_) { super(p_i45328_1_); setHasSubtypes(true); diff --git a/src/main/java/kubatech/loaders/block/blocks/TeaAcceptor.java b/src/main/java/kubatech/loaders/block/blocks/TeaAcceptor.java index 21d1e452f7..2f4f36db53 100644 --- a/src/main/java/kubatech/loaders/block/blocks/TeaAcceptor.java +++ b/src/main/java/kubatech/loaders/block/blocks/TeaAcceptor.java @@ -1,28 +1,21 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders.block.blocks; import java.util.List; + import kubatech.loaders.block.BlockProxy; import kubatech.loaders.block.IProxyTileEntityProvider; import kubatech.tileentity.TeaAcceptorTile; + import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; diff --git a/src/main/java/kubatech/loaders/item/IItemProxyGUI.java b/src/main/java/kubatech/loaders/item/IItemProxyGUI.java index 40020c81e9..6b16630ea1 100644 --- a/src/main/java/kubatech/loaders/item/IItemProxyGUI.java +++ b/src/main/java/kubatech/loaders/item/IItemProxyGUI.java @@ -1,9 +1,11 @@ package kubatech.loaders.item; -import com.gtnewhorizons.modularui.api.screen.ModularWindow; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; + public interface IItemProxyGUI { + ModularWindow createWindow(ItemStack stack, EntityPlayer player); } diff --git a/src/main/java/kubatech/loaders/item/ItemProxy.java b/src/main/java/kubatech/loaders/item/ItemProxy.java index 0545932cf5..a0a841760c 100644 --- a/src/main/java/kubatech/loaders/item/ItemProxy.java +++ b/src/main/java/kubatech/loaders/item/ItemProxy.java @@ -1,33 +1,19 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders.item; -import com.gtnewhorizons.modularui.api.screen.ModularUIContext; -import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.api.screen.UIBuildContext; -import com.gtnewhorizons.modularui.common.builder.UIBuilder; -import com.gtnewhorizons.modularui.common.builder.UIInfo; -import com.gtnewhorizons.modularui.common.internal.wrapper.ModularGui; -import com.gtnewhorizons.modularui.common.internal.wrapper.ModularUIContainer; import java.util.List; + import kubatech.Tags; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -37,26 +23,33 @@ import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import com.gtnewhorizons.modularui.api.screen.ModularUIContext; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.builder.UIBuilder; +import com.gtnewhorizons.modularui.common.builder.UIInfo; +import com.gtnewhorizons.modularui.common.internal.wrapper.ModularGui; +import com.gtnewhorizons.modularui.common.internal.wrapper.ModularUIContainer; + public class ItemProxy { - private static final UIInfo<?, ?> HeldItemUIInfo = UIBuilder.of() - .container((player, w, x, y, z) -> { - ItemStack stack = player.getHeldItem(); - ItemProxy proxy = KubaItems.getItemProxy(stack); - if (!(proxy instanceof IItemProxyGUI)) return null; - UIBuildContext context = new UIBuildContext(player); - ModularWindow window = ((IItemProxyGUI) proxy).createWindow(stack, player); - return new ModularUIContainer( - new ModularUIContext(context, () -> player.inventoryContainer.detectAndSendChanges()), window); - }) - .gui((player, w, x, y, z) -> { - ItemStack stack = player.getHeldItem(); - ItemProxy proxy = KubaItems.getItemProxy(stack); - if (!(proxy instanceof IItemProxyGUI)) return null; - UIBuildContext context = new UIBuildContext(player); - ModularWindow window = ((IItemProxyGUI) proxy).createWindow(stack, player); - return new ModularGui(new ModularUIContainer(new ModularUIContext(context, null), window)); - }) - .build(); + + private static final UIInfo<?, ?> HeldItemUIInfo = UIBuilder.of().container((player, w, x, y, z) -> { + ItemStack stack = player.getHeldItem(); + ItemProxy proxy = KubaItems.getItemProxy(stack); + if (!(proxy instanceof IItemProxyGUI)) return null; + UIBuildContext context = new UIBuildContext(player); + ModularWindow window = ((IItemProxyGUI) proxy).createWindow(stack, player); + return new ModularUIContainer( + new ModularUIContext(context, () -> player.inventoryContainer.detectAndSendChanges()), + window); + }).gui((player, w, x, y, z) -> { + ItemStack stack = player.getHeldItem(); + ItemProxy proxy = KubaItems.getItemProxy(stack); + if (!(proxy instanceof IItemProxyGUI)) return null; + UIBuildContext context = new UIBuildContext(player); + ModularWindow window = ((IItemProxyGUI) proxy).createWindow(stack, player); + return new ModularGui(new ModularUIContainer(new ModularUIContext(context, null), window)); + }).build(); private final String unlocalizedName; private final String texturepath; private IIcon icon; diff --git a/src/main/java/kubatech/loaders/item/KubaItems.java b/src/main/java/kubatech/loaders/item/KubaItems.java index cb738d77fa..55d835cb87 100644 --- a/src/main/java/kubatech/loaders/item/KubaItems.java +++ b/src/main/java/kubatech/loaders/item/KubaItems.java @@ -1,31 +1,22 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders.item; import static kubatech.kubatech.KT; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.HashMap; import java.util.List; + import kubatech.loaders.ItemLoader; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; @@ -36,7 +27,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + public class KubaItems extends Item { + private static final HashMap<Integer, ItemProxy> items = new HashMap<>(); private static int idCounter = 0; @@ -67,17 +62,8 @@ public class KubaItems extends Item { } @Override - public boolean onItemUse( - ItemStack p_77648_1_, - EntityPlayer p_77648_2_, - World p_77648_3_, - int p_77648_4_, - int p_77648_5_, - int p_77648_6_, - int p_77648_7_, - float p_77648_8_, - float p_77648_9_, - float p_77648_10_) { + public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, + int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { return false; } @@ -141,8 +127,8 @@ public class KubaItems extends Item { } @Override - public void onUpdate( - ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { + public void onUpdate(ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, + boolean p_77663_5_) { getItem(p_77663_1_).onUpdate(p_77663_1_, p_77663_2_, p_77663_3_, p_77663_4_, p_77663_5_); } } diff --git a/src/main/java/kubatech/loaders/item/items/Tea.java b/src/main/java/kubatech/loaders/item/items/Tea.java index a810967ed2..c127609cf9 100644 --- a/src/main/java/kubatech/loaders/item/items/Tea.java +++ b/src/main/java/kubatech/loaders/item/items/Tea.java @@ -1,32 +1,26 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders.item.items; import java.util.List; + import kubatech.loaders.item.ItemProxy; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class Tea extends ItemProxy { + private final int heal; private final float saturation; diff --git a/src/main/java/kubatech/loaders/item/items/TeaCollection.java b/src/main/java/kubatech/loaders/item/items/TeaCollection.java index 8440576fe2..5ef3995301 100644 --- a/src/main/java/kubatech/loaders/item/items/TeaCollection.java +++ b/src/main/java/kubatech/loaders/item/items/TeaCollection.java @@ -1,29 +1,22 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders.item.items; import java.util.LinkedList; import java.util.List; + import kubatech.api.utils.ModUtils; import kubatech.loaders.ItemLoader; import kubatech.loaders.item.ItemProxy; + import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.entity.Entity; @@ -41,6 +34,7 @@ import net.minecraft.world.World; import net.minecraftforge.common.AchievementPage; public class TeaCollection extends ItemProxy { + protected static TeaPage teapage; protected static LinkedList<Achievement> achievements; protected Achievement achievement; @@ -51,21 +45,8 @@ public class TeaCollection extends ItemProxy { achievementname = "teacollection." + unlocalizedName; } - private static final int[][] achievement_poses = new int[][] { - {0, 0}, - {2, 0}, - {3, 1}, - {4, 2}, - {4, 4}, - {3, 5}, - {2, 6}, - {0, 6}, - {-1, 5}, - {-2, 4}, - {-2, 2}, - {-1, 1}, - {1, 3} - }; + private static final int[][] achievement_poses = new int[][] { { 0, 0 }, { 2, 0 }, { 3, 1 }, { 4, 2 }, { 4, 4 }, + { 3, 5 }, { 2, 6 }, { 0, 6 }, { -1, 5 }, { -2, 4 }, { -2, 2 }, { -1, 1 }, { 1, 3 } }; boolean checkTeaOwner(ItemStack stack, String username) { NBTTagCompound tag = stack.stackTagCompound; @@ -92,25 +73,34 @@ public class TeaCollection extends ItemProxy { } achievements.add( achievement = new Achievement( - achievementname, - achievementname, - achievement_poses[index][0], - achievement_poses[index][1], - new ItemStack(ItemLoader.kubaitems, 1, index), - null) - .registerStat()); + achievementname, + achievementname, + achievement_poses[index][0], + achievement_poses[index][1], + new ItemStack(ItemLoader.kubaitems, 1, index), + null).registerStat()); } @Override public void addInformation(ItemStack stack, EntityPlayer entity, List<String> tooltipList, boolean showDebugInfo) { if (!checkTeaOwner(stack, entity.getCommandSenderName())) { - tooltipList.add(EnumChatFormatting.GRAY + "" + EnumChatFormatting.BOLD + "" + EnumChatFormatting.ITALIC - + StatCollector.translateToLocal("kubaitem.notyours")); + tooltipList.add( + EnumChatFormatting.GRAY + "" + + EnumChatFormatting.BOLD + + "" + + EnumChatFormatting.ITALIC + + StatCollector.translateToLocal("kubaitem.notyours")); return; } tooltipList.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("kubaitem.fromcollection")); - tooltipList.add(EnumChatFormatting.GRAY + "" + EnumChatFormatting.BOLD + "" + EnumChatFormatting.ITALIC + "" - + EnumChatFormatting.UNDERLINE + StatCollector.translateToLocal("kubaitem.teacollection")); + tooltipList.add( + EnumChatFormatting.GRAY + "" + + EnumChatFormatting.BOLD + + "" + + EnumChatFormatting.ITALIC + + "" + + EnumChatFormatting.UNDERLINE + + StatCollector.translateToLocal("kubaitem.teacollection")); } @Override @@ -129,8 +119,9 @@ public class TeaCollection extends ItemProxy { public ItemStack onEaten(ItemStack stack, World world, EntityPlayer entity) { if (world.isRemote) return stack; if (!(entity instanceof EntityPlayerMP)) return stack; - entity.addChatComponentMessage(new ChatComponentText( - EnumChatFormatting.GREEN + StatCollector.translateToLocal("kubaitem.teacollection.mmm"))); + entity.addChatComponentMessage( + new ChatComponentText( + EnumChatFormatting.GREEN + StatCollector.translateToLocal("kubaitem.teacollection.mmm"))); entity.triggerAchievement(achievement); return stack; } diff --git a/src/main/java/kubatech/loaders/item/items/TeaIngredient.java b/src/main/java/kubatech/loaders/item/items/TeaIngredient.java index 135129742a..696f004316 100644 --- a/src/main/java/kubatech/loaders/item/items/TeaIngredient.java +++ b/src/main/java/kubatech/loaders/item/items/TeaIngredient.java @@ -1,31 +1,25 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders.item.items; import java.util.List; + import kubatech.loaders.item.ItemProxy; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; public class TeaIngredient extends ItemProxy { + public TeaIngredient(String unlocalizedName) { super("teaingredient." + unlocalizedName, "teaingredient/" + unlocalizedName); } diff --git a/src/main/java/kubatech/loaders/item/items/TeaUltimate.java b/src/main/java/kubatech/loaders/item/items/TeaUltimate.java index 6356d30fbb..35b4ae28f1 100644 --- a/src/main/java/kubatech/loaders/item/items/TeaUltimate.java +++ b/src/main/java/kubatech/loaders/item/items/TeaUltimate.java @@ -1,39 +1,24 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders.item.items; -import com.gtnewhorizons.modularui.api.ModularUITextures; -import com.gtnewhorizons.modularui.api.drawable.IDrawable; -import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; -import com.gtnewhorizons.modularui.api.drawable.Text; -import com.gtnewhorizons.modularui.api.math.Color; -import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.api.widget.Widget; -import com.gtnewhorizons.modularui.common.widget.*; import java.text.NumberFormat; + import kubatech.api.enums.ItemList; import kubatech.api.utils.ModUtils; import kubatech.api.utils.StringUtils; import kubatech.loaders.item.IItemProxyGUI; import kubatech.savedata.PlayerData; import kubatech.savedata.PlayerDataManager; + import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -46,7 +31,17 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; +import com.gtnewhorizons.modularui.api.drawable.Text; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.*; + public class TeaUltimate extends TeaCollection implements IItemProxyGUI { + public TeaUltimate() { super("ultimate_tea"); } @@ -60,7 +55,9 @@ public class TeaUltimate extends TeaCollection implements IItemProxyGUI { if (current - timeCounter > 100) { timeCounter = current; name = StringUtils.applyRainbow( - "ULTIMATE", colorCounter++, EnumChatFormatting.BOLD.toString() + EnumChatFormatting.OBFUSCATED); + "ULTIMATE", + colorCounter++, + EnumChatFormatting.BOLD.toString() + EnumChatFormatting.OBFUSCATED); } return String.format(displayName, name + EnumChatFormatting.RESET); } @@ -82,79 +79,107 @@ public class TeaUltimate extends TeaCollection implements IItemProxyGUI { IDrawable tab1 = new ItemDrawable(ItemList.LegendaryUltimateTea.get(1)).withFixedSize(18, 18, 4, 6); IDrawable tab2 = new ItemDrawable(new ItemStack(Blocks.crafting_table)).withFixedSize(18, 18, 4, 6); IDrawable tab3 = new ItemDrawable(new ItemStack(Items.golden_apple)).withFixedSize(18, 18, 4, 6); - builder.widget(new TabContainer() - .setButtonSize(28, 32) - .addTabButton(new TabButton(0) - .setBackground(false, ModularUITextures.VANILLA_TAB_TOP_START.getSubArea(0, 0, 1f, 0.5f), tab1) - .setBackground(true, ModularUITextures.VANILLA_TAB_TOP_START.getSubArea(0, 0.5f, 1f, 1f), tab1) - .setPos(0, -28)) - .addTabButton(new TabButton(1) - .setBackground(false, ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), tab2) - .setBackground(true, ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), tab2) - .setPos(28, -28)) - .addTabButton(new TabButton(2) - .setBackground(false, ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), tab3) - .setBackground(true, ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), tab3) - .setPos(56, -28)) - .addPage(new MultiChildWidget() - .addChild(new TextWidget(new Text("STATUS") - .format(EnumChatFormatting.BOLD) - .format(EnumChatFormatting.GOLD) - .shadow()) - .setPos(10, 5)) - .addChild(new DynamicTextWidget(() -> new Text("Tea: " - + (playerData == null - ? "ERROR" - : NumberFormat.getInstance() - .format(playerData.teaAmount))) - .color(Color.GREEN.normal)) - .setPos(20, 20))) - .addPage(new MultiChildWidget() - .addChild(new TextWidget(new Text("EXCHANGE") - .format(EnumChatFormatting.BOLD) - .format(EnumChatFormatting.GOLD) - .shadow()) - .setPos(10, 5)) - .addChild(new ButtonWidget() - .setOnClick((Widget.ClickData clickData, Widget widget) -> { - if (!(player instanceof EntityPlayerMP)) return; - if (playerData == null || playerData.teaAmount < 50_000L) return; - playerData.teaAmount -= 50_000L; - playerData.markDirty(); - if (player.inventory.addItemStackToInventory( - ItemList.TeaAcceptorResearchNote.get(1))) return; - player.entityDropItem(ItemList.TeaAcceptorResearchNote.get(1), 0.5f); - }) - .setBackground(new ItemDrawable().setItem(ItemList.TeaAcceptorResearchNote.get(1))) - .addTooltip("Tea Acceptor Research Note") - .addTooltip(new Text("Cost: " - + NumberFormat.getInstance().format(50_000) + " Tea") - .color(Color.GRAY.normal)) - .setPos(20, 20))) - .addPage( - new MultiChildWidget() - .addChild(new TextWidget(new Text("BENEFITS") - .format(EnumChatFormatting.BOLD) - .format(EnumChatFormatting.GOLD) - .shadow()) - .setPos(10, 5)) - /*.addChild(new ButtonWidget() - .setOnClick((Widget.ClickData clickData, Widget widget) -> { - if (!(player instanceof EntityPlayerMP)) return; - if (playerData == null) return; - playerData.autoRegen = !playerData.autoRegen; - playerData.markDirty(); - }) - .setBackground(new ItemDrawable().setItem(new ItemStack(Items.potionitem, 1, 8193))) - .addTooltip("Regeneration I") - .addTooltip("For 1 minute") - .addTooltip(new Text("Cost: " - + NumberFormat.getInstance().format(75_000) + " Tea") - .color(Color.GRAY.normal)) - // .addTooltip( //Find a way to run that on server, or different approach - // new Text("Autobuy: " + (playerData == null ? "ERROR" : playerData.autoRegen)) - // .color(Color.GREY.normal)) - .setPos(20, 20))*/ )); + builder.widget( + new TabContainer() + .setButtonSize( + 28, + 32) + .addTabButton( + new TabButton(0) + .setBackground( + false, + ModularUITextures.VANILLA_TAB_TOP_START.getSubArea(0, 0, 1f, 0.5f), + tab1) + .setBackground( + true, + ModularUITextures.VANILLA_TAB_TOP_START.getSubArea(0, 0.5f, 1f, 1f), + tab1) + .setPos(0, -28)) + .addTabButton( + new TabButton(1) + .setBackground( + false, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), + tab2) + .setBackground( + true, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), + tab2) + .setPos(28, -28)) + .addTabButton( + new TabButton(2) + .setBackground( + false, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), + tab3) + .setBackground( + true, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), + tab3) + .setPos(56, -28)) + .addPage( + new MultiChildWidget() + .addChild( + new TextWidget( + new Text("STATUS").format(EnumChatFormatting.BOLD) + .format(EnumChatFormatting.GOLD).shadow()) + .setPos(10, 5)) + .addChild( + new DynamicTextWidget( + () -> new Text( + "Tea: " + (playerData == null ? "ERROR" + : NumberFormat.getInstance() + .format(playerData.teaAmount))) + .color(Color.GREEN.normal)) + .setPos(20, 20))) + .addPage( + new MultiChildWidget() + .addChild( + new TextWidget( + new Text("EXCHANGE").format(EnumChatFormatting.BOLD) + .format(EnumChatFormatting.GOLD).shadow()) + .setPos(10, 5)) + .addChild( + new ButtonWidget() + .setOnClick((Widget.ClickData clickData, Widget widget) -> { + if (!(player instanceof EntityPlayerMP)) return; + if (playerData == null || playerData.teaAmount < 50_000L) + return; + playerData.teaAmount -= 50_000L; + playerData.markDirty(); + if (player.inventory.addItemStackToInventory( + ItemList.TeaAcceptorResearchNote.get(1))) + return; + player.entityDropItem( + ItemList.TeaAcceptorResearchNote.get(1), + 0.5f); + }) + .setBackground( + new ItemDrawable().setItem( + ItemList.TeaAcceptorResearchNote.get(1))) + .addTooltip("Tea Acceptor Research Note") + .addTooltip( + new Text( + "Cost: " + NumberFormat.getInstance() + .format(50_000) + " Tea") + .color(Color.GRAY.normal)) + .setPos(20, 20))) + .addPage( + new MultiChildWidget().addChild( + new TextWidget( + new Text("BENEFITS").format(EnumChatFormatting.BOLD) + .format(EnumChatFormatting.GOLD).shadow()).setPos(10, 5)) + /* + * .addChild(new ButtonWidget() .setOnClick((Widget.ClickData clickData, Widget widget) -> { if + * (!(player instanceof EntityPlayerMP)) return; if (playerData == null) return; + * playerData.autoRegen = !playerData.autoRegen; playerData.markDirty(); }) .setBackground(new + * ItemDrawable().setItem(new ItemStack(Items.potionitem, 1, 8193))) + * .addTooltip("Regeneration I") .addTooltip("For 1 minute") .addTooltip(new Text("Cost: " + + * NumberFormat.getInstance().format(75_000) + " Tea") .color(Color.GRAY.normal)) // + * .addTooltip( //Find a way to run that on server, or different approach // new + * Text("Autobuy: " + (playerData == null ? "ERROR" : playerData.autoRegen)) // + * .color(Color.GREY.normal)) .setPos(20, 20)) + */ )); return builder.build(); } |