diff options
Diffstat (limited to 'src/main/java/kubatech/loaders')
23 files changed, 2827 insertions, 0 deletions
diff --git a/src/main/java/kubatech/loaders/BlockLoader.java b/src/main/java/kubatech/loaders/BlockLoader.java new file mode 100644 index 0000000000..fcb077ff15 --- /dev/null +++ b/src/main/java/kubatech/loaders/BlockLoader.java @@ -0,0 +1,51 @@ +/* + * spotless:off + * KubaTech - Gregtech Addon + * Copyright (C) 2022 - 2024 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/>. + * spotless:on + */ + +package kubatech.loaders; + +import net.minecraft.block.material.Material; +import net.minecraft.item.ItemBlock; + +import cpw.mods.fml.common.registry.GameRegistry; +import kubatech.api.enums.ItemList; +import kubatech.loaders.block.defc.DEFCCasingBlock; +import kubatech.loaders.block.kubablock.KubaBlock; +import kubatech.loaders.block.kubablock.KubaItemBlock; +import kubatech.loaders.block.kubablock.blocks.TeaAcceptor; +import kubatech.loaders.block.kubablock.blocks.TeaStorage; +import kubatech.tileentity.TeaAcceptorTile; +import kubatech.tileentity.TeaStorageTile; + +public class BlockLoader { + + public static final KubaBlock kubaBlock = new KubaBlock(Material.anvil); + public static final ItemBlock kubaItemBlock = new KubaItemBlock(kubaBlock); + public static final DEFCCasingBlock defcCasingBlock = new DEFCCasingBlock(); + + public static void registerBlocks() { + GameRegistry.registerTileEntity(TeaAcceptorTile.class, "KT_TeaAcceptor"); + GameRegistry.registerTileEntity(TeaStorageTile.class, "KT_TeaStorage"); + GameRegistry.registerBlock(kubaBlock, null, "kubablocks"); + GameRegistry.registerItem(kubaItemBlock, "kubablocks"); + + ItemList.TeaAcceptor.set(kubaBlock.registerProxyBlock(new TeaAcceptor())); + ItemList.TeaStorage.set(kubaBlock.registerProxyBlock(new TeaStorage())); + } +} diff --git a/src/main/java/kubatech/loaders/DEFCRecipes.java b/src/main/java/kubatech/loaders/DEFCRecipes.java new file mode 100644 index 0000000000..ebea8d751f --- /dev/null +++ b/src/main/java/kubatech/loaders/DEFCRecipes.java @@ -0,0 +1,331 @@ +package kubatech.loaders; + +import static gregtech.api.enums.Mods.AdvancedSolarPanel; +import static gregtech.api.enums.Mods.DraconicEvolution; +import static gregtech.api.enums.Mods.ElectroMagicTools; +import static gregtech.api.enums.Mods.NewHorizonsCoreMod; +import static gregtech.api.enums.Mods.SuperSolarPanels; +import static gregtech.api.enums.Mods.Witchery; +import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; +import static gregtech.api.recipe.RecipeMaps.mixerRecipes; +import static gregtech.api.util.GT_RecipeConstants.DEFC_CASING_TIER; + +import java.util.Arrays; + +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import com.gtnewhorizons.modularui.api.drawable.UITexture; + +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMapBackend; +import gregtech.api.recipe.RecipeMapBuilder; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.nei.formatter.SimpleSpecialValueFormatter; +import gtPlusPlus.xmod.forestry.bees.handler.GTPP_CombType; +import kubatech.Tags; + +public class DEFCRecipes { + + public static final RecipeMap<RecipeMapBackend> fusionCraftingRecipes = RecipeMapBuilder + .of("kubatech.defusioncrafter") + .maxIO(9, 1, 1, 1) + .minInputs(1, 0) + .neiSpecialInfoFormatter(new SimpleSpecialValueFormatter("kubatech.defusioncrafter.tier")) + .slotOverlays( + (index, isFluid, isOutput, + isSpecial) -> !isFluid && !isOutput ? UITexture.fullImage(Tags.MODID, "gui/slot/fusion_crafter") : null) + .build(); + + public static void addRecipes() { + + // Dragonblood recipe for magics haters + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(Blocks.dragon_egg, 1), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DraconiumAwakened, 64L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DraconiumAwakened, 64L)) + .fluidInputs(Materials.Radon.getPlasma(144)) + .itemOutputs(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Ash, 8L)) + .fluidOutputs(new FluidStack(FluidRegistry.getFluid("molten.dragonblood"), 288)) + .eut(TierEU.RECIPE_UHV) + .duration(14_000) + .addTo(mixerRecipes); + + // Casings + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.NaquadahAlloy, 6L), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.NaquadahAlloy, 6L)) + .fluidInputs(Materials.Void.getMolten(1152L)) + .itemOutputs(kubatech.api.enums.ItemList.DEFCCasingBase.get(1)) + .eut(TierEU.RECIPE_UV) + .duration(24000) + .addTo(assemblerRecipes); + GT_Values.RA.stdBuilder() + .itemInputs( + GT_ModHandler.getModItem(NewHorizonsCoreMod.ID, "tile.BloodyIchorium", 1, 0), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Osmiridium, 6L)) + .fluidInputs(Materials.Void.getMolten(1152L)) + .itemOutputs(kubatech.api.enums.ItemList.DEFCCasingT1.get(1)) + .eut(TierEU.RECIPE_UV) + .duration(24000) + .addTo(assemblerRecipes); + GT_Values.RA.stdBuilder() + .itemInputs( + kubatech.api.enums.ItemList.DEFCCasingT1.get(1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Draconium, 6L), + GT_ModHandler.getModItem(DraconicEvolution.ID, "draconicCore", 1, 0)) + .fluidInputs(Materials.Void.getMolten(2304L)) + .itemOutputs(kubatech.api.enums.ItemList.DEFCCasingT2.get(1)) + .eut(TierEU.RECIPE_UV) + .duration(24000) + .addTo(assemblerRecipes); + GT_Values.RA.stdBuilder() + .itemInputs( + kubatech.api.enums.ItemList.DEFCCasingT2.get(1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.CosmicNeutronium, 6L), + GT_ModHandler.getModItem(DraconicEvolution.ID, "wyvernCore", 2, 0)) + .fluidInputs(Materials.Void.getMolten(4608L)) + .itemOutputs(kubatech.api.enums.ItemList.DEFCCasingT3.get(1)) + .eut(TierEU.RECIPE_UHV) + .duration(12000) + .addTo(assemblerRecipes); + GT_Values.RA.stdBuilder() + .itemInputs( + kubatech.api.enums.ItemList.DEFCCasingT3.get(1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.DraconiumAwakened, 6L), + GT_ModHandler.getModItem(DraconicEvolution.ID, "awakenedCore", 3, 0)) + .fluidInputs(Materials.Void.getMolten(9216L)) + .itemOutputs(kubatech.api.enums.ItemList.DEFCCasingT4.get(1)) + .eut(TierEU.RECIPE_UEV) + .duration(12000) + .addTo(assemblerRecipes); + GT_Values.RA.stdBuilder() + .itemInputs( + kubatech.api.enums.ItemList.DEFCCasingT4.get(1), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Infinity, 6L), + GT_ModHandler.getModItem(DraconicEvolution.ID, "chaoticCore", 4, 0)) + .fluidInputs(Materials.Void.getMolten(18432L)) + .itemOutputs(kubatech.api.enums.ItemList.DEFCCasingT5.get(1)) + .eut(TierEU.RECIPE_UIV) + .duration(12000) + .addTo(assemblerRecipes); + + fusionRecipes(); + conversionRecipes(); + } + + private static final Item EMTItems = GameRegistry.findItem("EMT", "EMTItems"); + + private static void addOldHiddenRecipe(GT_Recipe recipe) { + if (!ElectroMagicTools.isModLoaded()) return; + recipe = recipe.copy(); + recipe.mInputs = Arrays.stream(recipe.mInputs) + .map(i -> { + if (i != null && i.getItem() == ItemLoader.kubaitems) { + return new ItemStack( + EMTItems, + 0, + 16 + (i.getItemDamage() - kubatech.api.enums.ItemList.DEFCDraconicSchematic.get(1) + .getItemDamage())); + } else return i; + }) + .toArray(ItemStack[]::new); + recipe.mHidden = true; + fusionCraftingRecipes.add(recipe); + } + + private static void conversionRecipes() { + if (!ElectroMagicTools.isModLoaded()) return; + GameRegistry.addShapelessRecipe( + kubatech.api.enums.ItemList.DEFCDraconicSchematic.get(1), + new ItemStack(EMTItems, 1, 16)); + GameRegistry + .addShapelessRecipe(kubatech.api.enums.ItemList.DEFCWyvernSchematic.get(1), new ItemStack(EMTItems, 1, 17)); + GameRegistry.addShapelessRecipe( + kubatech.api.enums.ItemList.DEFCAwakenedSchematic.get(1), + new ItemStack(EMTItems, 1, 18)); + GameRegistry.addShapelessRecipe( + kubatech.api.enums.ItemList.DEFCChaoticSchematic.get(1), + new ItemStack(EMTItems, 1, 19)); + } + + private static void fusionRecipes() { + // CORES + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmiridium, 4), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Ichorium, 1), + ItemList.QuantumEye.get(1L), + kubatech.api.enums.ItemList.DEFCDraconicSchematic.get(0L)) + .fluidInputs(Materials.Sunnarium.getMolten(1440)) + .itemOutputs(GT_ModHandler.getModItem(DraconicEvolution.ID, "draconicCore", 1, 0)) + .eut(TierEU.RECIPE_UV) + .duration(400) + .metadata(DEFC_CASING_TIER, 1) + .addTo(fusionCraftingRecipes) + .forEach(DEFCRecipes::addOldHiddenRecipe); + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Draconium, 8), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 4), + GT_ModHandler.getModItem(DraconicEvolution.ID, "draconicCore", 4, 0), + ItemList.QuantumStar.get(1L), + kubatech.api.enums.ItemList.DEFCWyvernSchematic.get(0L)) + .fluidInputs(Materials.Neutronium.getMolten(1440)) + .itemOutputs(GT_ModHandler.getModItem(DraconicEvolution.ID, "wyvernCore", 1, 0)) + .eut(TierEU.RECIPE_UHV) + .duration(800) + .metadata(DEFC_CASING_TIER, 2) + .addTo(fusionCraftingRecipes) + .forEach(DEFCRecipes::addOldHiddenRecipe); + + if (Loader.isModLoaded("supersolarpanel")) { + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.DraconiumAwakened, 12), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Draconium, 4), + GT_ModHandler.getModItem(DraconicEvolution.ID, "wyvernCore", 4, 0), + GT_ModHandler.getModItem(SuperSolarPanels.ID, "enderquantumcomponent", 1, 0), + kubatech.api.enums.ItemList.DEFCAwakenedSchematic.get(0L)) + .fluidInputs(Materials.Infinity.getMolten(1440)) + .itemOutputs(GT_ModHandler.getModItem(DraconicEvolution.ID, "awakenedCore", 1, 0)) + .eut(TierEU.RECIPE_UEV) + .duration(1600) + .metadata(DEFC_CASING_TIER, 3) + .addTo(fusionCraftingRecipes) + .forEach(DEFCRecipes::addOldHiddenRecipe); + } else { + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.DraconiumAwakened, 12), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Draconium, 4), + GT_ModHandler.getModItem(DraconicEvolution.ID, "wyvernCore", 4, 0), + GT_ModHandler.getModItem(NewHorizonsCoreMod.ID, "item.ManyullynCrystal", 1, 0), + kubatech.api.enums.ItemList.DEFCAwakenedSchematic.get(0L)) + .fluidInputs(Materials.Infinity.getMolten(1440)) + .itemOutputs(GT_ModHandler.getModItem(DraconicEvolution.ID, "awakenedCore", 1, 0)) + .eut(TierEU.RECIPE_UEV) + .duration(1600) + .metadata(DEFC_CASING_TIER, 3) + .addTo(fusionCraftingRecipes) + .forEach(DEFCRecipes::addOldHiddenRecipe); + } + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.DraconiumAwakened, 16), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlackPlutonium, 4), + GT_ModHandler.getModItem(DraconicEvolution.ID, "awakenedCore", 4, 0), + GT_ModHandler.getModItem(DraconicEvolution.ID, "chaosFragment", 2, 2), + kubatech.api.enums.ItemList.DEFCChaoticSchematic.get(0L)) + .fluidInputs(MaterialsUEVplus.SpaceTime.getMolten(1440)) + .itemOutputs(GT_ModHandler.getModItem(DraconicEvolution.ID, "chaoticCore", 1, 0)) + .eut(24_000_000) + .duration(3200) + .metadata(DEFC_CASING_TIER, 4) + .addTo(fusionCraftingRecipes) + .forEach(DEFCRecipes::addOldHiddenRecipe); + + // ENERGY CORES + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Draconium, 8), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.StellarAlloy, 4), + GT_ModHandler.getModItem(AdvancedSolarPanel.ID, "asp_crafting_items", 4, 1), + GT_ModHandler.getModItem(DraconicEvolution.ID, "draconicCore", 1, 0), + kubatech.api.enums.ItemList.DEFCWyvernSchematic.get(0L)) + .itemOutputs(GT_ModHandler.getModItem(DraconicEvolution.ID, "draconiumEnergyCore", 1, 0)) + .eut(TierEU.RECIPE_UV) + .duration(1000) + .metadata(DEFC_CASING_TIER, 2) + .addTo(fusionCraftingRecipes) + .forEach(DEFCRecipes::addOldHiddenRecipe); + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.DraconiumAwakened, 8), + GT_ModHandler.getModItem(DraconicEvolution.ID, "draconiumEnergyCore", 4, 0), + GT_ModHandler.getModItem(AdvancedSolarPanel.ID, "asp_crafting_items", 4, 4), + GT_ModHandler.getModItem(DraconicEvolution.ID, "wyvernCore", 1, 0), + kubatech.api.enums.ItemList.DEFCAwakenedSchematic.get(0L)) + .itemOutputs(GT_ModHandler.getModItem(DraconicEvolution.ID, "draconiumEnergyCore", 1, 1)) + .eut(TierEU.RECIPE_UHV) + .duration(2000) + .metadata(DEFC_CASING_TIER, 3) + .addTo(fusionCraftingRecipes) + .forEach(DEFCRecipes::addOldHiddenRecipe); + + // Dragon Blood + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(Blocks.dragon_egg, 0), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DraconiumAwakened, 64), + GT_Utility.getIntegratedCircuit(1)) + .fluidInputs(Materials.Radon.getPlasma(144)) + .fluidOutputs(new FluidStack(FluidRegistry.getFluid("molten.dragonblood"), 288)) + .eut(TierEU.RECIPE_UHV) + .duration(4200) + .metadata(DEFC_CASING_TIER, 3) + .noOptimize() + .addTo(fusionCraftingRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_ModHandler.getModItem(Witchery.ID, "infinityegg", 0), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DraconiumAwakened, 64), + GT_Utility.getIntegratedCircuit(1)) + .fluidInputs(Materials.Radon.getPlasma(72)) + .fluidOutputs(new FluidStack(FluidRegistry.getFluid("molten.dragonblood"), 432)) + .eut(TierEU.RECIPE_UHV) + .duration(3600) + .metadata(DEFC_CASING_TIER, 3) + .noOptimize() + .addTo(fusionCraftingRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + new ItemStack(Blocks.dragon_egg, 0), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DraconiumAwakened, 64), + GTPP_CombType.DRAGONBLOOD.getStackForType(1)) + .fluidInputs(Materials.Radon.getPlasma(216)) + .fluidOutputs(new FluidStack(FluidRegistry.getFluid("molten.dragonblood"), 432)) + .eut(TierEU.RECIPE_UHV) + .duration(2800) + .metadata(DEFC_CASING_TIER, 3) + .noOptimize() + .addTo(fusionCraftingRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs( + GT_ModHandler.getModItem(Witchery.ID, "infinityegg", 0), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DraconiumAwakened, 64), + GTPP_CombType.DRAGONBLOOD.getStackForType(1)) + .fluidInputs(Materials.Radon.getPlasma(108)) + .fluidOutputs(new FluidStack(FluidRegistry.getFluid("molten.dragonblood"), 648)) + .eut(TierEU.RECIPE_UHV) + .duration(2400) + .metadata(DEFC_CASING_TIER, 3) + .noOptimize() + .addTo(fusionCraftingRecipes); + } +} diff --git a/src/main/java/kubatech/loaders/EIGBucketLoader.java b/src/main/java/kubatech/loaders/EIGBucketLoader.java new file mode 100644 index 0000000000..4dbf83112b --- /dev/null +++ b/src/main/java/kubatech/loaders/EIGBucketLoader.java @@ -0,0 +1,27 @@ +package kubatech.loaders; + +import static gregtech.api.enums.Mods.ThaumicBases; + +import kubatech.api.enums.EIGModes; +import kubatech.tileentity.gregtech.multiblock.eigbuckets.EIGFlowerBucket; +import kubatech.tileentity.gregtech.multiblock.eigbuckets.EIGIC2Bucket; +import kubatech.tileentity.gregtech.multiblock.eigbuckets.EIGRainbowCactusBucket; +import kubatech.tileentity.gregtech.multiblock.eigbuckets.EIGSeedBucket; +import kubatech.tileentity.gregtech.multiblock.eigbuckets.EIGStemBucket; + +public class EIGBucketLoader { + + public static void LoadEIGBuckets() { + // IC2 buckets + EIGModes.IC2.addLowPriorityFactory(EIGIC2Bucket.factory); + + // Regular Mode Buckets + if (ThaumicBases.isModLoaded()) { + EIGModes.Normal.addLowPriorityFactory(EIGRainbowCactusBucket.factory); + } + EIGModes.Normal.addLowPriorityFactory(EIGFlowerBucket.factory); + EIGModes.Normal.addLowPriorityFactory(EIGStemBucket.factory); + EIGModes.Normal.addLowPriorityFactory(EIGSeedBucket.factory); + } + +} diff --git a/src/main/java/kubatech/loaders/ItemLoader.java b/src/main/java/kubatech/loaders/ItemLoader.java new file mode 100644 index 0000000000..d8218ea873 --- /dev/null +++ b/src/main/java/kubatech/loaders/ItemLoader.java @@ -0,0 +1,149 @@ +/* + * spotless:off + * KubaTech - Gregtech Addon + * Copyright (C) 2022 - 2024 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/>. + * spotless:on + */ + +package kubatech.loaders; + +import static kubatech.api.enums.ItemList.Beeeeee; +import static kubatech.api.enums.ItemList.BlackTea; +import static kubatech.api.enums.ItemList.BlackTeaLeaf; +import static kubatech.api.enums.ItemList.BruisedTeaLeaf; +import static kubatech.api.enums.ItemList.DEFCAwakenedSchematic; +import static kubatech.api.enums.ItemList.DEFCChaoticSchematic; +import static kubatech.api.enums.ItemList.DEFCDraconicSchematic; +import static kubatech.api.enums.ItemList.DEFCWyvernSchematic; +import static kubatech.api.enums.ItemList.EarlGrayTea; +import static kubatech.api.enums.ItemList.FermentedTeaLeaf; +import static kubatech.api.enums.ItemList.GreenTea; +import static kubatech.api.enums.ItemList.GreenTeaLeaf; +import static kubatech.api.enums.ItemList.LegendaryBlackTea; +import static kubatech.api.enums.ItemList.LegendaryButterflyTea; +import static kubatech.api.enums.ItemList.LegendaryEarlGrayTea; +import static kubatech.api.enums.ItemList.LegendaryGreenTea; +import static kubatech.api.enums.ItemList.LegendaryLemonTea; +import static kubatech.api.enums.ItemList.LegendaryMilkTea; +import static kubatech.api.enums.ItemList.LegendaryOolongTea; +import static kubatech.api.enums.ItemList.LegendaryPeppermintTea; +import static kubatech.api.enums.ItemList.LegendaryPuerhTea; +import static kubatech.api.enums.ItemList.LegendaryRedTea; +import static kubatech.api.enums.ItemList.LegendaryUltimateTea; +import static kubatech.api.enums.ItemList.LegendaryWhiteTea; +import static kubatech.api.enums.ItemList.LegendaryYellowTea; +import static kubatech.api.enums.ItemList.LemonTea; +import static kubatech.api.enums.ItemList.MilkTea; +import static kubatech.api.enums.ItemList.OolongTea; +import static kubatech.api.enums.ItemList.OolongTeaLeaf; +import static kubatech.api.enums.ItemList.OxidizedTeaLeaf; +import static kubatech.api.enums.ItemList.PartiallyOxidizedTeaLeaf; +import static kubatech.api.enums.ItemList.PeppermintTea; +import static kubatech.api.enums.ItemList.PuerhTea; +import static kubatech.api.enums.ItemList.PuerhTeaLeaf; +import static kubatech.api.enums.ItemList.RolledTeaLeaf; +import static kubatech.api.enums.ItemList.SteamedTeaLeaf; +import static kubatech.api.enums.ItemList.TeaAcceptorResearchNote; +import static kubatech.api.enums.ItemList.TeaLeafDehydrated; +import static kubatech.api.enums.ItemList.WhiteTea; +import static kubatech.api.enums.ItemList.WhiteTeaLeaf; +import static kubatech.api.enums.ItemList.YellowTea; +import static kubatech.api.enums.ItemList.YellowTeaLeaf; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; + +import cpw.mods.fml.common.registry.GameRegistry; +import kubatech.loaders.item.ItemProxy; +import kubatech.loaders.item.KubaItems; +import kubatech.loaders.item.items.Tea; +import kubatech.loaders.item.items.TeaCollection; +import kubatech.loaders.item.items.TeaIngredient; +import kubatech.loaders.item.items.TeaUltimate; + +public class ItemLoader { + + public static final KubaItems kubaitems = new KubaItems(); + + public static void registerItems() { + GameRegistry.registerItem(kubaitems, "kubaitems"); + + // DON'T EVER CHANGE ORDER IN HERE, ADD NEW ITEMS ON BOTTOM + + LegendaryBlackTea.set(kubaitems.registerProxyItem(new TeaCollection("black_tea"))); + LegendaryButterflyTea.set(kubaitems.registerProxyItem(new TeaCollection("butterfly_tea"))); + LegendaryEarlGrayTea.set(kubaitems.registerProxyItem(new TeaCollection("earl_gray_tea"))); + LegendaryGreenTea.set(kubaitems.registerProxyItem(new TeaCollection("green_tea"))); + LegendaryLemonTea.set(kubaitems.registerProxyItem(new TeaCollection("lemon_tea"))); + LegendaryMilkTea.set(kubaitems.registerProxyItem(new TeaCollection("milk_tea"))); + LegendaryOolongTea.set(kubaitems.registerProxyItem(new TeaCollection("oolong_tea"))); + LegendaryPeppermintTea.set(kubaitems.registerProxyItem(new TeaCollection("peppermint_tea"))); + LegendaryPuerhTea.set(kubaitems.registerProxyItem(new TeaCollection("pu-erh_tea"))); + LegendaryRedTea.set(kubaitems.registerProxyItem(new TeaCollection("red_tea"))); + LegendaryWhiteTea.set(kubaitems.registerProxyItem(new TeaCollection("white_tea"))); + LegendaryYellowTea.set(kubaitems.registerProxyItem(new TeaCollection("yellow_tea"))); + LegendaryUltimateTea.set(kubaitems.registerProxyItem(new TeaUltimate())); + + BlackTea.set(kubaitems.registerProxyItem(new Tea("black_tea", 4, 0.3f))); + EarlGrayTea.set(kubaitems.registerProxyItem(new Tea("earl_gray_tea", 4, 0.3f))); + GreenTea.set(kubaitems.registerProxyItem(new Tea("green_tea", 4, 0.3f))); + LemonTea.set(kubaitems.registerProxyItem(new Tea("lemon_tea", 4, 0.3f))); + MilkTea.set(kubaitems.registerProxyItem(new Tea("milk_tea", 4, 0.3f))); + OolongTea.set(kubaitems.registerProxyItem(new Tea("oolong_tea", 4, 0.3f))); + PeppermintTea.set(kubaitems.registerProxyItem(new Tea("peppermint_tea", 4, 0.3f))); + PuerhTea.set(kubaitems.registerProxyItem(new Tea("pu-erh_tea", 4, 0.3f))); + WhiteTea.set(kubaitems.registerProxyItem(new Tea("white_tea", 4, 0.3f))); + YellowTea.set(kubaitems.registerProxyItem(new Tea("yellow_tea", 4, 0.3f))); + + BlackTeaLeaf.set(kubaitems.registerProxyItem(new TeaIngredient("black_tea_leaf"))); + GreenTeaLeaf.set(kubaitems.registerProxyItem(new TeaIngredient("green_tea_leaf"))); + OolongTeaLeaf.set(kubaitems.registerProxyItem(new TeaIngredient("oolong_tea_leaf"))); + PuerhTeaLeaf.set(kubaitems.registerProxyItem(new TeaIngredient("pu-erh_tea_leaf"))); + WhiteTeaLeaf.set(kubaitems.registerProxyItem(new TeaIngredient("white_tea_leaf"))); + YellowTeaLeaf.set(kubaitems.registerProxyItem(new TeaIngredient("yellow_tea_leaf"))); + + TeaLeafDehydrated.set(kubaitems.registerProxyItem(new TeaIngredient("tea_leaf_dehydrated"))); + SteamedTeaLeaf.set(kubaitems.registerProxyItem(new TeaIngredient("steamed_tea_leaf"))); + RolledTeaLeaf.set(kubaitems.registerProxyItem(new TeaIngredient("rolled_tea_leaf"))); + OxidizedTeaLeaf.set(kubaitems.registerProxyItem(new TeaIngredient("oxidized_tea_leaf"))); + FermentedTeaLeaf.set(kubaitems.registerProxyItem(new TeaIngredient("fermented_tea_leaf"))); + 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"))); + Beeeeee.set(kubaitems.registerProxyItem(new ItemProxy("beeeeee"))); + + // DEFC stuff + DEFCDraconicSchematic.set(kubaitems.registerProxyItem(new ItemProxy("defc_schematic_t1") { + + @Override + public void addInformation(ItemStack stack, EntityPlayer entity, List<String> tooltipList, + boolean showDebugInfo) { + tooltipList + .add(EnumChatFormatting.GOLD + StatCollector.translateToLocal("kubaitem.defc_schematic_t1.tip")); + } + })); + DEFCWyvernSchematic.set(kubaitems.registerProxyItem(new ItemProxy("defc_schematic_t2"))); + DEFCAwakenedSchematic.set(kubaitems.registerProxyItem(new ItemProxy("defc_schematic_t3"))); + DEFCChaoticSchematic.set(kubaitems.registerProxyItem(new ItemProxy("defc_schematic_t4"))); + + } +} diff --git a/src/main/java/kubatech/loaders/MTLoader.java b/src/main/java/kubatech/loaders/MTLoader.java new file mode 100644 index 0000000000..dbc5bb43fe --- /dev/null +++ b/src/main/java/kubatech/loaders/MTLoader.java @@ -0,0 +1,44 @@ +/* + * spotless:off + * KubaTech - Gregtech Addon + * Copyright (C) 2022 - 2024 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/>. + * spotless:on + */ + +package kubatech.loaders; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import kubatech.Tags; +import minetweaker.MineTweakerImplementationAPI; + +public class MTLoader { + + private static final Logger LOG = LogManager.getLogger(Tags.MODID + "[MT Loader]"); + public static MTLoader instance = null; + + public static void init() { + if (instance == null) { + instance = new MTLoader(); + MineTweakerImplementationAPI.onPostReload(instance::MTOnPostReload); + } + } + + public void MTOnPostReload(MineTweakerImplementationAPI.ReloadEvent reloadEvent) { + LOG.info("MT Recipes Loaded!"); + } +} diff --git a/src/main/java/kubatech/loaders/MobHandlerLoader.java b/src/main/java/kubatech/loaders/MobHandlerLoader.java new file mode 100644 index 0000000000..c7932dd00c --- /dev/null +++ b/src/main/java/kubatech/loaders/MobHandlerLoader.java @@ -0,0 +1,242 @@ +/* + * spotless:off + * KubaTech - Gregtech Addon + * Copyright (C) 2022 - 2024 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/>. + * spotless:on + */ + +package kubatech.loaders; + +import static gregtech.api.enums.Mods.InfernalMobs; +import static kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeEntityCrusher.DIAMOND_SPIKES_DAMAGE; +import static kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeEntityCrusher.MOB_SPAWN_INTERVAL; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; + +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.EntityLiving; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.MinecraftForge; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import com.kuba6000.mobsinfo.api.IChanceModifier; +import com.kuba6000.mobsinfo.api.MobDrop; +import com.kuba6000.mobsinfo.api.MobRecipe; +import com.kuba6000.mobsinfo.api.event.MobNEIRegistrationEvent; +import com.kuba6000.mobsinfo.api.event.PostMobRegistrationEvent; +import com.kuba6000.mobsinfo.api.event.PreMobsRegistrationEvent; + +import atomicstryker.infernalmobs.common.InfernalMobsCore; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gregtech.api.util.GT_Utility; +import kubatech.Tags; +import kubatech.config.Config; +import kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeEntityCrusher; + +public class MobHandlerLoader { + + private static final Logger LOG = LogManager.getLogger(Tags.MODID + "[Mob Handler Loader]"); + + private static MobHandlerLoader instance = null; + + public static void init() { + instance = new MobHandlerLoader(); + MinecraftForge.EVENT_BUS.register(instance); + } + + public static Map<String, MobEECRecipe> recipeMap = new HashMap<>(); + + public static class MobEECRecipe { + + public final List<MobDrop> mOutputs; + + public final MobRecipe recipe; + + public final int mEUt = 2000; + public final int mDuration; + public final EntityLiving entityCopy; + + public MobEECRecipe(List<MobDrop> transformedDrops, MobRecipe recipe) { + this.mOutputs = transformedDrops; + this.recipe = recipe; + try { + this.entityCopy = this.recipe.createEntityCopy(); + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException + | IllegalAccessException e) { + throw new RuntimeException(e); + } + mDuration = Math.max(MOB_SPAWN_INTERVAL, (int) ((recipe.maxEntityHealth / DIAMOND_SPIKES_DAMAGE) * 10d)); + } + + public ItemStack[] generateOutputs(Random rnd, GT_MetaTileEntity_ExtremeEntityCrusher MTE, double attackDamage, + int lootinglevel, boolean preferInfernalDrops, boolean voidAllDamagedAndEnchantedItems) { + MTE.lEUt = mEUt; + MTE.mMaxProgresstime = Math.max(MOB_SPAWN_INTERVAL, (int) ((recipe.maxEntityHealth / attackDamage) * 10d)); + ArrayList<ItemStack> stacks = new ArrayList<>(this.mOutputs.size()); + this.entityCopy.setPosition( + MTE.getBaseMetaTileEntity() + .getXCoord(), + MTE.getBaseMetaTileEntity() + .getYCoord(), + MTE.getBaseMetaTileEntity() + .getZCoord()); + for (MobDrop o : this.mOutputs) { + if (voidAllDamagedAndEnchantedItems && (o.damages != null || o.enchantable != null)) continue; + int chance = o.chance; + + double dChance = (double) chance / 100d; + for (IChanceModifier chanceModifier : o.chanceModifiers) { + dChance = chanceModifier.apply( + dChance, + MTE.getBaseMetaTileEntity() + .getWorld(), + stacks, + MTE.EECPlayer, + this.entityCopy); + } + + chance = (int) (dChance * 100d); + if (chance == 0) continue; + + if (o.playerOnly) { + chance = (int) ((double) chance * Config.MobHandler.playerOnlyDropsModifier); + if (chance < 1) chance = 1; + } + int amount = o.stack.stackSize; + if (o.lootable && lootinglevel > 0) { + chance += lootinglevel * 5000; + if (chance > 10000) { + int div = (int) Math.ceil(chance / 10000d); + amount *= div; + chance /= div; + } + } + if (chance == 10000 || rnd.nextInt(10000) < chance) { + ItemStack s = o.stack.copy(); + s.stackSize = amount; + if (o.enchantable != null) EnchantmentHelper.addRandomEnchantment(rnd, s, o.enchantable); + if (o.damages != null) { + int rChance = rnd.nextInt(recipe.mMaxDamageChance); + int cChance = 0; + for (Map.Entry<Integer, Integer> damage : o.damages.entrySet()) { + cChance += damage.getValue(); + if (rChance <= cChance) { + s.setItemDamage(damage.getKey()); + break; + } + } + } + stacks.add(s); + } + } + + if (InfernalMobs.isModLoaded()) { + InfernalMobsCore infernalMobsCore = InfernalMobsCore.instance(); + if (recipe.infernalityAllowed && mEUt * 8 <= MTE.getMaxInputEu() + && !infernalMobsCore.getDimensionBlackList() + .contains( + MTE.getBaseMetaTileEntity() + .getWorld().provider.dimensionId)) { + int p = 0; + int mods = 0; + if (recipe.alwaysinfernal + || (preferInfernalDrops && rnd.nextInt(infernalMobsCore.getEliteRarity()) == 0)) { + p = 1; + if (rnd.nextInt(infernalMobsCore.getUltraRarity()) == 0) { + p = 2; + if (rnd.nextInt(infernalMobsCore.getInfernoRarity()) == 0) p = 3; + } + } + ArrayList<ItemStack> infernalstacks = null; + if (p > 0) if (p == 1) { + infernalstacks = infernalMobsCore.getDropIdListElite(); + mods = infernalMobsCore.getMinEliteModifiers(); + } else if (p == 2) { + infernalstacks = infernalMobsCore.getDropIdListUltra(); + mods = infernalMobsCore.getMinUltraModifiers(); + } else { + infernalstacks = infernalMobsCore.getDropIdListInfernal(); + mods = infernalMobsCore.getMinInfernoModifiers(); + } + if (infernalstacks != null) { + ItemStack infernalstack = infernalstacks.get(rnd.nextInt(infernalstacks.size())) + .copy(); + // noinspection ConstantConditions + EnchantmentHelper.addRandomEnchantment( + rnd, + infernalstack, + infernalstack.getItem() + .getItemEnchantability()); + stacks.add(infernalstack); + MTE.lEUt *= 8L; + MTE.mMaxProgresstime *= mods * InfernalMobsCore.instance() + .getMobModHealthFactor(); + } + } + } + + return stacks.toArray(new ItemStack[0]); + } + + } + + @SubscribeEvent + @SuppressWarnings("unused") + public void onPreMobsRegistration(PreMobsRegistrationEvent event) { + recipeMap.clear(); + } + + @SubscribeEvent + @SuppressWarnings("unused") + public void onPostMobRegistration(PostMobRegistrationEvent event) { + if (!event.drops.isEmpty() && event.recipe.isUsableInVial) { + for (MobDrop drop : event.drops) { + if (drop.playerOnly) { + drop.additionalInfo.add( + StatCollector.translateToLocalFormatted( + "kubatech.mobhandler.eec_chance", + (((double) drop.chance / 100d) * Config.MobHandler.playerOnlyDropsModifier))); + } + } + @SuppressWarnings("unchecked") + ArrayList<MobDrop> drops = (ArrayList<MobDrop>) event.drops.clone(); + if (!drops.isEmpty()) { + recipeMap.put(event.currentMob, new MobEECRecipe(drops, event.recipe)); + } + } + } + + @SubscribeEvent + @SuppressWarnings("unused") + public void onMobNEIRegistration(MobNEIRegistrationEvent event) { + MobEECRecipe recipe = recipeMap.get(event.mobName); + if (recipe != null) { + event.additionalInformation.addAll( + Arrays.asList( + GT_Utility.trans("153", "Usage: ") + GT_Utility.formatNumbers(recipe.mEUt) + " EU/t", + GT_Utility.trans("158", "Time: ") + GT_Utility.formatNumbers(recipe.mDuration / 20d) + " secs")); + } + } +} diff --git a/src/main/java/kubatech/loaders/RecipeLoader.java b/src/main/java/kubatech/loaders/RecipeLoader.java new file mode 100644 index 0000000000..995583aad4 --- /dev/null +++ b/src/main/java/kubatech/loaders/RecipeLoader.java @@ -0,0 +1,355 @@ +/* + * spotless:off + * KubaTech - Gregtech Addon + * Copyright (C) 2022 - 2024 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/>. + * spotless:on + */ + +package kubatech.loaders; + +import static gregtech.api.enums.ItemList.FluidExtractorUHV; +import static gregtech.api.enums.MetaTileEntityIDs.DraconicEvolutionFusionCrafterController; +import static gregtech.api.enums.MetaTileEntityIDs.ExtremeEntityCrusherController; +import static gregtech.api.enums.MetaTileEntityIDs.ExtremeIndustrialApiaryController; +import static gregtech.api.enums.MetaTileEntityIDs.ExtremeIndustrialGreenhouseController; +import static gregtech.api.enums.Mods.Avaritia; +import static gregtech.api.enums.Mods.DraconicEvolution; +import static gregtech.api.enums.Mods.EnderIO; +import static gregtech.api.enums.Mods.Forestry; +import static gregtech.api.enums.Mods.NewHorizonsCoreMod; +import static gregtech.api.enums.Mods.OpenBlocks; +import static gregtech.api.enums.Mods.PamsHarvestCraft; +import static gregtech.api.recipe.RecipeMaps.benderRecipes; +import static gregtech.api.recipe.RecipeMaps.cutterRecipes; +import static gregtech.api.recipe.RecipeMaps.mixerRecipes; +import static gregtech.api.util.GT_RecipeBuilder.MINUTES; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; +import static gregtech.api.util.GT_RecipeConstants.AssemblyLine; +import static gregtech.api.util.GT_RecipeConstants.RESEARCH_ITEM; +import static gregtech.api.util.GT_RecipeConstants.RESEARCH_TIME; +import static gregtech.api.util.GT_RecipeConstants.UniversalChemical; +import static gtPlusPlus.api.recipe.GTPPRecipeMaps.chemicalDehydratorRecipes; +import static kubatech.api.enums.ItemList.BlackTea; +import static kubatech.api.enums.ItemList.BlackTeaLeaf; +import static kubatech.api.enums.ItemList.BruisedTeaLeaf; +import static kubatech.api.enums.ItemList.DraconicEvolutionFusionCrafter; +import static kubatech.api.enums.ItemList.EarlGrayTea; +import static kubatech.api.enums.ItemList.ExtremeEntityCrusher; +import static kubatech.api.enums.ItemList.ExtremeIndustrialApiary; +import static kubatech.api.enums.ItemList.ExtremeIndustrialGreenhouse; +import static kubatech.api.enums.ItemList.FermentedTeaLeaf; +import static kubatech.api.enums.ItemList.GreenTea; +import static kubatech.api.enums.ItemList.GreenTeaLeaf; +import static kubatech.api.enums.ItemList.LegendaryUltimateTea; +import static kubatech.api.enums.ItemList.LemonTea; +import static kubatech.api.enums.ItemList.MilkTea; +import static kubatech.api.enums.ItemList.OolongTea; +import static kubatech.api.enums.ItemList.OolongTeaLeaf; +import static kubatech.api.enums.ItemList.OxidizedTeaLeaf; +import static kubatech.api.enums.ItemList.PartiallyOxidizedTeaLeaf; +import static kubatech.api.enums.ItemList.PeppermintTea; +import static kubatech.api.enums.ItemList.PuerhTea; +import static kubatech.api.enums.ItemList.PuerhTeaLeaf; +import static kubatech.api.enums.ItemList.RolledTeaLeaf; +import static kubatech.api.enums.ItemList.SteamedTeaLeaf; +import static kubatech.api.enums.ItemList.TeaAcceptor; +import static kubatech.api.enums.ItemList.TeaAcceptorResearchNote; +import static kubatech.api.enums.ItemList.TeaLeafDehydrated; +import static kubatech.api.enums.ItemList.WhiteTea; +import static kubatech.api.enums.ItemList.WhiteTeaLeaf; +import static kubatech.api.enums.ItemList.YellowTea; +import static kubatech.api.enums.ItemList.YellowTeaLeaf; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; + +import cpw.mods.fml.common.registry.GameRegistry; +import forestry.plugins.PluginCore; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import ic2.core.Ic2Items; +import kubatech.api.enums.ItemList; +import kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_DEFusionCrafter; +import kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeEntityCrusher; +import kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeIndustrialGreenhouse; +import kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_MegaIndustrialApiary; + +public class RecipeLoader { + + protected static final long bitsd = GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE + | GT_ModHandler.RecipeBits.BUFFERED + | GT_ModHandler.RecipeBits.DISMANTLEABLE; + + public static void registerMTEs() { + if (EnderIO.isModLoaded()) { + ExtremeEntityCrusher.set( + new GT_MetaTileEntity_ExtremeEntityCrusher( + ExtremeEntityCrusherController.ID, + "multimachine.entitycrusher", + "Extreme Entity Crusher").getStackForm(1)); + } + + if (Forestry.isModLoaded()) { + ExtremeIndustrialApiary.set( + new GT_MetaTileEntity_MegaIndustrialApiary( + ExtremeIndustrialApiaryController.ID, + "multimachine.extremeapiary", + "Industrial Apicultural Acclimatiser and Drone Domestication Station").getStackForm(1)); + } + + ExtremeIndustrialGreenhouse.set( + new GT_MetaTileEntity_ExtremeIndustrialGreenhouse( + ExtremeIndustrialGreenhouseController.ID, + "multimachine.extremegreenhouse", + "Extreme Industrial Greenhouse").getStackForm(1)); + + if (DraconicEvolution.isModLoaded()) { + DraconicEvolutionFusionCrafter.set( + new GT_MetaTileEntity_DEFusionCrafter( + DraconicEvolutionFusionCrafterController.ID, + "multimachine.defusioncrafter", + "Draconic Evolution Fusion Crafter").getStackForm(1)); + } + } + + public static void addRecipes() { + + if (EnderIO.isModLoaded()) { + GT_ModHandler.addCraftingRecipe( + ItemList.ExtremeEntityCrusher.get(1), + bitsd, + new Object[] { "RCR", "CHC", "VVV", 'R', gregtech.api.enums.ItemList.Robot_Arm_EV, 'C', + OrePrefixes.circuit.get(Materials.EV), 'H', gregtech.api.enums.ItemList.Hull_EV, 'V', + GT_ModHandler.getModItem(OpenBlocks.ID, "vacuumhopper", 1, new ItemStack(Blocks.hopper)) }); + } + + if (Forestry.isModLoaded()) { + GT_Values.RA.stdBuilder() + .metadata(RESEARCH_ITEM, gregtech.api.enums.ItemList.Machine_IndustrialApiary.get(1)) + .metadata(RESEARCH_TIME, 8 * MINUTES + 20 * SECONDS) + .itemInputs( + 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.UV), 4L }, + new Object[] { OrePrefixes.circuit.get(Materials.UV), 4L }, + new Object[] { OrePrefixes.circuit.get(Materials.UV), 4L }, + new Object[] { OrePrefixes.circuit.get(Materials.UV), 4L }) + .fluidInputs( + FluidRegistry.getFluidStack("molten.indalloy140", 28800), + FluidRegistry.getFluidStack("for.honey", 20000)) + .itemOutputs(ExtremeIndustrialApiary.get(1)) + .eut(TierEU.RECIPE_UHV) + .duration(5 * MINUTES) + .addTo(AssemblyLine); + + GT_MetaTileEntity_ExtremeIndustrialGreenhouse + .addFertilizerItem(PluginCore.items.fertilizerCompound.getItemStack(1)); + } + + GT_ModHandler.addCraftingRecipe( + ExtremeIndustrialGreenhouse.get(1), + bitsd, + new Object[] { "AZA", "BRB", "AZA", 'B', gregtech.api.enums.ItemList.Casing_CleanStainlessSteel, 'R', + GT_ModHandler.getModItem(EnderIO.ID, "blockFarmStation", 1, new ItemStack(Items.diamond_hoe)), 'A', + gregtech.api.enums.ItemList.AcceleratorIV.get(1), 'Z', OrePrefixes.circuit.get(Materials.ZPM) }); + + // Vanilla should always be loaded + GT_MetaTileEntity_ExtremeIndustrialGreenhouse.addFertilizerItem(new ItemStack(Items.dye, 1, 15)); + // IC2 should always be loaded + GT_MetaTileEntity_ExtremeIndustrialGreenhouse.addFertilizerItem(Ic2Items.fertilizer); + + if (DraconicEvolution.isModLoaded()) { + // Controller recipe added in TecTech + DEFCRecipes.addRecipes(); + } + RegisterTeaLine(); + } + + private static boolean lateRecipesInitialized = false; + + public static void addRecipesLate() { + // Runs on server start + if (lateRecipesInitialized) return; + lateRecipesInitialized = true; + } + + private static void RegisterTeaLine() { + // TEA LINE // + if (PamsHarvestCraft.isModLoaded()) { + GT_Values.RA.stdBuilder() + .itemInputs(GameRegistry.findItemStack("harvestcraft", "tealeafItem", 1)) + .itemOutputs(TeaLeafDehydrated.get(1)) + .eut(TierEU.RECIPE_LV) + .duration(5 * SECONDS) + .addTo(chemicalDehydratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(TeaLeafDehydrated.get(1)) + .itemOutputs(WhiteTeaLeaf.get(1)) + .eut(TierEU.RECIPE_LV) + .duration(5 * SECONDS) + .addTo(chemicalDehydratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(TeaLeafDehydrated.get(1)) + .itemOutputs(SteamedTeaLeaf.get(1)) + .fluidInputs(FluidRegistry.getFluidStack("water", 50)) + .eut(TierEU.RECIPE_LV) + .duration(5 * SECONDS) + .addTo(mixerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(SteamedTeaLeaf.get(1)) + .itemOutputs(YellowTeaLeaf.get(1)) + .eut(TierEU.RECIPE_LV) + .duration(5 * SECONDS) + .addTo(chemicalDehydratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(TeaLeafDehydrated.get(1), GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(RolledTeaLeaf.get(1)) + .eut(TierEU.RECIPE_LV) + .duration(5 * SECONDS) + .addTo(benderRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(RolledTeaLeaf.get(1)) + .itemOutputs(GreenTeaLeaf.get(1)) + .eut(TierEU.RECIPE_LV) + .duration(5 * SECONDS) + .addTo(chemicalDehydratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(RolledTeaLeaf.get(1), GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(OxidizedTeaLeaf.get(1)) + .eut(TierEU.RECIPE_LV) + .duration(5 * SECONDS) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(OxidizedTeaLeaf.get(1)) + .itemOutputs(BlackTeaLeaf.get(1)) + .eut(TierEU.RECIPE_LV) + .duration(5 * SECONDS) + .addTo(chemicalDehydratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(RolledTeaLeaf.get(1), GT_Utility.getIntegratedCircuit(2)) + .itemOutputs(FermentedTeaLeaf.get(1)) + .eut(TierEU.RECIPE_LV) + .duration(10 * SECONDS) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(FermentedTeaLeaf.get(1)) + .itemOutputs(PuerhTeaLeaf.get(1)) + .eut(TierEU.RECIPE_LV) + .duration(5 * SECONDS) + .addTo(chemicalDehydratorRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(TeaLeafDehydrated.get(1)) + .itemOutputs(BruisedTeaLeaf.get(1)) + .eut(TierEU.RECIPE_LV) + .duration(5 * SECONDS) + .addTo(cutterRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(BruisedTeaLeaf.get(1), GT_Utility.getIntegratedCircuit(1)) + .itemOutputs(PartiallyOxidizedTeaLeaf.get(1)) + .eut(TierEU.RECIPE_LV) + .duration(2 * SECONDS + 10 * TICKS) + .addTo(UniversalChemical); + + GT_Values.RA.stdBuilder() + .itemInputs(PartiallyOxidizedTeaLeaf.get(1)) + .itemOutputs(OolongTeaLeaf.get(1)) + .eut(TierEU.RECIPE_LV) + .duration(5 * SECONDS) + .addTo(chemicalDehydratorRecipes); + + // Tea Assembly + GameRegistry.addSmelting(BlackTeaLeaf.get(1), BlackTea.get(1), 10); + + GT_Values.RA.stdBuilder() + .itemInputs(BlackTea.get(1), GameRegistry.findItemStack("harvestcraft", "limejuiceItem", 1)) + .itemOutputs(EarlGrayTea.get(1)) + .eut(TierEU.RECIPE_LV) + .duration(5 * SECONDS) + .addTo(mixerRecipes); + + GameRegistry.addSmelting(GreenTeaLeaf.get(1), GreenTea.get(1), 10); + + GT_Values.RA.stdBuilder() + .itemInputs(BlackTea.get(1)) + .itemOutputs(LemonTea.get(1)) + .fluidInputs(FluidRegistry.getFluidStack("potion.lemonjuice", 1000)) + .eut(TierEU.RECIPE_LV) + .duration(5 * SECONDS) + .addTo(mixerRecipes); + + GT_Values.RA.stdBuilder() + .itemInputs(BlackTea.get(1)) + .itemOutputs(MilkTea.get(1)) + .fluidInputs(FluidRegistry.getFluidStack("milk", 1000)) + .eut(TierEU.RECIPE_LV) + .duration(5 * SECONDS) + .addTo(mixerRecipes); + + GameRegistry.addSmelting(OolongTeaLeaf.get(1), OolongTea.get(1), 10); + + GT_Values.RA.stdBuilder() + .itemInputs(GameRegistry.findItemStack("harvestcraft", "peppermintItem", 1)) + .itemOutputs(PeppermintTea.get(1)) + .fluidInputs(FluidRegistry.getFluidStack("water", 1000)) + .eut(TierEU.RECIPE_LV) + .duration(5 * SECONDS) + .addTo(mixerRecipes); + + GameRegistry.addSmelting(PuerhTeaLeaf.get(1), PuerhTea.get(1), 10); + GameRegistry.addSmelting(WhiteTeaLeaf.get(1), WhiteTea.get(1), 10); + GameRegistry.addSmelting(YellowTeaLeaf.get(1), YellowTea.get(1), 10); + } + if (Avaritia.isModLoaded() && NewHorizonsCoreMod.isModLoaded()) { + GT_Values.RA.stdBuilder() + .metadata(RESEARCH_ITEM, TeaAcceptorResearchNote.get(1)) + .metadata(RESEARCH_TIME, 8 * MINUTES + 20 * SECONDS) + .itemInputs( + LegendaryUltimateTea.get(0), + GameRegistry.findItemStack("Avaritia", "Neutronium_Compressor", 1), + gregtech.api.enums.ItemList.Quantum_Tank_EV.get(1), + FluidExtractorUHV.get(10), + new Object[] { OrePrefixes.circuit.get(Materials.UV), 4L }, + new Object[] { OrePrefixes.circuit.get(Materials.UV), 4L }, + new Object[] { OrePrefixes.circuit.get(Materials.UV), 4L }, + new Object[] { OrePrefixes.circuit.get(Materials.UV), 4L }) + .fluidInputs(FluidRegistry.getFluidStack("molten.indalloy140", 28800)) + .itemOutputs(TeaAcceptor.get(1)) + .eut(TierEU.RECIPE_UHV) + .duration(5 * MINUTES) + .addTo(AssemblyLine); + } + } +} diff --git a/src/main/java/kubatech/loaders/TCLoader.java b/src/main/java/kubatech/loaders/TCLoader.java new file mode 100644 index 0000000000..f6ff1cac9f --- /dev/null +++ b/src/main/java/kubatech/loaders/TCLoader.java @@ -0,0 +1,153 @@ +/* + * spotless:off + * KubaTech - Gregtech Addon + * Copyright (C) 2022 - 2024 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/>. + * spotless:on + */ + +package kubatech.loaders; + +import static gregtech.api.enums.Mods.DraconicEvolution; +import static gregtech.api.enums.Mods.NewHorizonsCoreMod; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.stream.Collectors; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import com.kuba6000.mobsinfo.api.utils.ItemID; + +import cpw.mods.fml.common.registry.GameRegistry; +import kubatech.api.enums.ItemList; +import kubatech.loaders.item.items.TeaUltimate; +import thaumcraft.api.ThaumcraftApi; +import thaumcraft.api.ThaumcraftApiHelper; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.api.crafting.InfusionRecipe; +import thaumcraft.api.research.ResearchCategories; +import thaumcraft.api.research.ResearchItem; +import thaumcraft.api.research.ResearchPage; + +public class TCLoader { + + public static final String TCCategoryKey = "KUBATECH"; + + public static void init() { + /* + * ResearchCategories.registerCategory( + * TCCategoryKey, + * new ResourceLocation(Tags.MODID, "textures/gui/green_tea.png"), + * new ResourceLocation("thaumcraft", "textures/gui/gui_researchback.png")); + */ + if (!NewHorizonsCoreMod.isModLoaded() || !DraconicEvolution.isModLoaded()) return; + registerRecipe(); + registerResearch(); + } + + private static InfusionRecipe ultimateTeaRecipe = null; + + @SuppressWarnings("unchecked") + 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) }; + + final HashSet<ItemID> componentsHashed = Arrays.stream(components) + .map(stack -> ItemID.createNoCopy(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.createNoCopy(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" /* TCCategoryKey */, + 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); + } + ResearchCategories.addResearch(ultimateTeaResearch); + } +} diff --git a/src/main/java/kubatech/loaders/block/defc/DEFCCasingBlock.java b/src/main/java/kubatech/loaders/block/defc/DEFCCasingBlock.java new file mode 100644 index 0000000000..5a6b95acfe --- /dev/null +++ b/src/main/java/kubatech/loaders/block/defc/DEFCCasingBlock.java @@ -0,0 +1,63 @@ +package kubatech.loaders.block.defc; + +import static kubatech.kubatech.KT; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Block_Casings_Abstract; +import kubatech.Tags; +import kubatech.api.enums.ItemList; + +public class DEFCCasingBlock extends GT_Block_Casings_Abstract { + + @SideOnly(Side.CLIENT) + private IIcon[] texture; + + public DEFCCasingBlock() { + super(DEFCCasingItemBlock.class, "defc.casing", Material.anvil); + this.setHardness(15.0F); + this.setResistance(30.0F); + this.setCreativeTab(KT); + + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Naquadah Alloy Fusion Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Bloody Ichorium Fusion Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Draconium Fusion Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Wyvern Fusion Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Awakened Draconium Fusion Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Chaotic Fusion Casing"); + + ItemList.DEFCCasingBase.set(new ItemStack(this, 1, 7)); + ItemList.DEFCCasingT1.set(new ItemStack(this, 1, 8)); + ItemList.DEFCCasingT2.set(new ItemStack(this, 1, 9)); + ItemList.DEFCCasingT3.set(new ItemStack(this, 1, 10)); + ItemList.DEFCCasingT4.set(new ItemStack(this, 1, 11)); + ItemList.DEFCCasingT5.set(new ItemStack(this, 1, 12)); + + // Taking one texture slot :P + Textures.BlockIcons.setCasingTexture((byte) 1, (byte) (15 + 48), TextureFactory.of(this, 0)); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + if (meta < 7 || meta > 12) return texture[0]; + return texture[meta - 7]; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister aIconRegister) { + texture = new IIcon[6]; + for (int i = 0; i < texture.length; i++) { + texture[i] = aIconRegister.registerIcon(Tags.MODID + ":casing/defc_" + i); + } + } +} diff --git a/src/main/java/kubatech/loaders/block/defc/DEFCCasingItemBlock.java b/src/main/java/kubatech/loaders/block/defc/DEFCCasingItemBlock.java new file mode 100644 index 0000000000..669e3a6dc8 --- /dev/null +++ b/src/main/java/kubatech/loaders/block/defc/DEFCCasingItemBlock.java @@ -0,0 +1,36 @@ +package kubatech.loaders.block.defc; + +import static kubatech.kubatech.KT; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; + +import gregtech.common.blocks.GT_Item_Casings_Abstract; + +public class DEFCCasingItemBlock extends GT_Item_Casings_Abstract { + + public DEFCCasingItemBlock(Block block) { + super(block); + this.setMaxDamage(0); + this.setHasSubtypes(true); + this.setCreativeTab(KT); + } + + @Override + @SuppressWarnings("unchecked") + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + if (getDamage(aStack) > 7) + aList.add(StatCollector.translateToLocalFormatted("defc.casing.tip", getDamage(aStack) - 7)); + super.addInformation(aStack, aPlayer, aList, aF3_H); + } + + @Override + public IIcon getIconFromDamage(int p_77617_1_) { + return this.field_150939_a.getIcon(0, p_77617_1_); + } +} diff --git a/src/main/java/kubatech/loaders/block/kubablock/BlockProxy.java b/src/main/java/kubatech/loaders/block/kubablock/BlockProxy.java new file mode 100644 index 0000000000..5aef5135a3 --- /dev/null +++ b/src/main/java/kubatech/loaders/block/kubablock/BlockProxy.java @@ -0,0 +1,111 @@ +/* + * spotless:off + * KubaTech - Gregtech Addon + * Copyright (C) 2022 - 2024 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/>. + * spotless:on + */ + +package kubatech.loaders.block.kubablock; + +import static kubatech.loaders.block.kubablock.KubaBlock.defaultTileEntityUI; + +import java.util.List; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; + +import kubatech.Tags; + +public class BlockProxy { + + private final String unlocalizedName; + private final String sideTexturePath; + private final String topBottomTexturePath; + private IIcon sideIcon; + private IIcon topBottomIcon; + + public BlockProxy(String unlocalizedName, String texture) { + this.unlocalizedName = "kubablock." + unlocalizedName; + sideTexturePath = topBottomTexturePath = Tags.MODID + ":" + texture; + } + + public BlockProxy(String unlocalizedName, String sideTexture, String topBottomTexture) { + this.unlocalizedName = "kubablock." + unlocalizedName; + sideTexturePath = Tags.MODID + ":" + sideTexture; + topBottomTexturePath = Tags.MODID + ":" + topBottomTexture; + } + + public void itemInit(int ID) {} + + public boolean onActivated(World world, int x, int y, int z, EntityPlayer player) { + if (this instanceof IProxyTileEntityProvider) { + TileEntity te = world.getTileEntity(x, y, z); + if (te instanceof ITileWithModularUI) { + if (world.isRemote) return true; + if (te instanceof KubaBlock.IModularUIProvider) ((KubaBlock.IModularUIProvider) te).getUI() + .open(player, world, x, y, z); + else defaultTileEntityUI.open(player, world, x, y, z); + return true; + } + } + return false; + } + + public void onBlockPlaced(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {} + + public void registerIcon(IIconRegister iconRegister) { + sideIcon = iconRegister.registerIcon(sideTexturePath); + if (sideTexturePath.equals(topBottomTexturePath)) topBottomIcon = sideIcon; + else topBottomIcon = iconRegister.registerIcon(topBottomTexturePath); + } + + public IIcon getIcon(int side) { + if (side <= 1) return topBottomIcon; + else return sideIcon; + } + + public String getUnlocalizedName() { + return this.unlocalizedName; + } + + public String getDisplayName(ItemStack stack) { + return StatCollector.translateToLocal(this.unlocalizedName + ".name") + .trim(); + } + + public void addInformation(ItemStack stack, EntityPlayer entity, List<String> tooltipList, boolean showDebugInfo) {} + + public float getHardness() { + return 10.f; + } + + public Material getMaterial() { + return Material.anvil; + } + + public float getResistance() { + return 5.f; + } +} diff --git a/src/main/java/kubatech/loaders/block/kubablock/IProxyTileEntityProvider.java b/src/main/java/kubatech/loaders/block/kubablock/IProxyTileEntityProvider.java new file mode 100644 index 0000000000..c9fb1e8da9 --- /dev/null +++ b/src/main/java/kubatech/loaders/block/kubablock/IProxyTileEntityProvider.java @@ -0,0 +1,29 @@ +/* + * spotless:off + * KubaTech - Gregtech Addon + * Copyright (C) 2022 - 2024 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/>. + * spotless:on + */ + +package kubatech.loaders.block.kubablock; + +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/KubaBlock.java b/src/main/java/kubatech/loaders/block/kubablock/KubaBlock.java new file mode 100644 index 0000000000..d6349d88ff --- /dev/null +++ b/src/main/java/kubatech/loaders/block/kubablock/KubaBlock.java @@ -0,0 +1,198 @@ +/* + * spotless:off + * KubaTech - Gregtech Addon + * Copyright (C) 2022 - 2024 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/>. + * spotless:on + */ + +package kubatech.loaders.block.kubablock; + +import static kubatech.kubatech.KT; + +import java.lang.ref.WeakReference; +import java.util.HashMap; +import java.util.List; +import java.util.function.Function; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +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; + +import kubatech.loaders.BlockLoader; + +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) { + final UIBuildContext buildContext = new UIBuildContext(player); + final 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) { + final UIBuildContext buildContext = new UIBuildContext(player); + final 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); + + static final HashMap<Integer, BlockProxy> blocks = new HashMap<>(); + private static int idCounter = 0; + + public KubaBlock(Material p_i45394_1_) { + super(p_i45394_1_); + setCreativeTab(KT); + } + + public ItemStack registerProxyBlock(BlockProxy block) { + blocks.put(idCounter, block); + block.itemInit(idCounter); + return new ItemStack(BlockLoader.kubaItemBlock, 1, idCounter++); + } + + private BlockProxy getBlock(int id) { + return blocks.get(id); + } + + WeakReference<World> lastAccessor = null; + int X, Y, Z; + + public void setLastBlockAccess(World accessor, int x, int y, int z) { + lastAccessor = new WeakReference<>(accessor); + X = x; + Y = y; + Z = z; + } + + @Override + public boolean hasTileEntity(int meta) { + return getBlock(meta) instanceof IProxyTileEntityProvider; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) { + for (int i = 0; i < blocks.size(); i++) p_149666_3_.add(new ItemStack(p_149666_1_, 1, i)); + } + + @Override + public int damageDropped(int meta) { + return meta; + } + + @Override + public void registerBlockIcons(IIconRegister p_149651_1_) { + blocks.values() + .forEach(b -> b.registerIcon(p_149651_1_)); + } + + @Override + public IIcon getIcon(int p_149691_1_, int p_149691_2_) { + return blocks.get(p_149691_2_) + .getIcon(p_149691_1_); + } + + @Override + public String getLocalizedName() { + return "KUBABLOCK"; + } + + @Override + public TileEntity createTileEntity(World world, int metadata) { + if (!hasTileEntity(metadata)) return null; + return ((IProxyTileEntityProvider) getBlock(metadata)).createTileEntity(world); + } + + @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_) { + 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_) { + 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(); + } + + @Override + public Material getMaterial() { + if (lastAccessor == null) return super.getMaterial(); + World world = lastAccessor.get(); + if (world == null) { + lastAccessor = null; + return super.getMaterial(); + } + if (world.getBlock(X, Y, Z) != this) return super.getMaterial(); + return getBlock(world.getBlockMetadata(X, Y, Z)).getMaterial(); + } + + @Override + 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/kubablock/KubaItemBlock.java b/src/main/java/kubatech/loaders/block/kubablock/KubaItemBlock.java new file mode 100644 index 0000000000..bd5c9d1119 --- /dev/null +++ b/src/main/java/kubatech/loaders/block/kubablock/KubaItemBlock.java @@ -0,0 +1,73 @@ +/* + * spotless:off + * KubaTech - Gregtech Addon + * Copyright (C) 2022 - 2024 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/>. + * spotless:on + */ + +package kubatech.loaders.block.kubablock; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class KubaItemBlock extends ItemBlock { + + public KubaItemBlock(Block p_i45328_1_) { + super(p_i45328_1_); + setHasSubtypes(true); + } + + @Override + public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, + float hitX, float hitY, float hitZ, int metadata) { + return super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); + } + + @Override + public void registerIcons(IIconRegister p_94581_1_) { + super.registerIcons(p_94581_1_); + } + + @Override + public String getUnlocalizedName(ItemStack p_77667_1_) { + return KubaBlock.blocks.get(p_77667_1_.getItemDamage()) + .getUnlocalizedName(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + return KubaBlock.blocks.get(p_77653_1_.getItemDamage()) + .getDisplayName(p_77653_1_); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { + KubaBlock.blocks.get(p_77624_1_.getItemDamage()) + .addInformation(p_77624_1_, p_77624_2_, p_77624_3_, p_77624_4_); + } + + @Override + public int getMetadata(int p_77647_1_) { + return p_77647_1_; + } +} diff --git a/src/main/java/kubatech/loaders/block/kubablock/blocks/TeaAcceptor.java b/src/main/java/kubatech/loaders/block/kubablock/blocks/TeaAcceptor.java new file mode 100644 index 0000000000..06ee3490b1 --- /dev/null +++ b/src/main/java/kubatech/loaders/block/kubablock/blocks/TeaAcceptor.java @@ -0,0 +1,64 @@ +/* + * spotless:off + * KubaTech - Gregtech Addon + * Copyright (C) 2022 - 2024 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/>. + * spotless:on + */ + +package kubatech.loaders.block.kubablock.blocks; + +import java.util.List; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import kubatech.loaders.block.kubablock.BlockProxy; +import kubatech.loaders.block.kubablock.IProxyTileEntityProvider; +import kubatech.tileentity.TeaAcceptorTile; + +public class TeaAcceptor extends BlockProxy implements IProxyTileEntityProvider { + + public TeaAcceptor() { + super("tea_acceptor", "tea_acceptor", "blank"); + } + + @Override + public TileEntity createTileEntity(World world) { + return new TeaAcceptorTile(); + } + + @Override + public void onBlockPlaced(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { + if (world.isRemote) return; + if (!(player instanceof EntityPlayerMP)) return; + ((TeaAcceptorTile) world.getTileEntity(x, y, z)).setTeaOwner(player.getPersistentID()); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer entity, List<String> tooltipList, boolean showDebugInfo) { + tooltipList.add("Accepts Tea items and adds them to your network"); + tooltipList.add("Can accept up to 10 stacks per tick"); + } + + @Override + public float getResistance() { + return 999999999999.f; + } +} diff --git a/src/main/java/kubatech/loaders/block/kubablock/blocks/TeaStorage.java b/src/main/java/kubatech/loaders/block/kubablock/blocks/TeaStorage.java new file mode 100644 index 0000000000..436af9a4e2 --- /dev/null +++ b/src/main/java/kubatech/loaders/block/kubablock/blocks/TeaStorage.java @@ -0,0 +1,66 @@ +/* + * spotless:off + * KubaTech - Gregtech Addon + * Copyright (C) 2022 - 2024 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/>. + * spotless:on + */ + +package kubatech.loaders.block.kubablock.blocks; + +import static kubatech.api.Variables.numberFormat; + +import java.util.List; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +import kubatech.loaders.block.kubablock.BlockProxy; +import kubatech.loaders.block.kubablock.IProxyTileEntityProvider; +import kubatech.tileentity.TeaStorageTile; + +public class TeaStorage extends BlockProxy implements IProxyTileEntityProvider { + + public TeaStorage() { + super("tea_storage", "tea_storage"); + } + + @Override + public TileEntity createTileEntity(World world) { + return new TeaStorageTile(); + } + + @Override + public void onBlockPlaced(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { + if (world.isRemote) return; + if (!(player instanceof EntityPlayerMP)) return; + ((TeaStorageTile) world.getTileEntity(x, y, z)).setTeaOwner(player.getPersistentID()); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer entity, List<String> tooltipList, boolean showDebugInfo) { + tooltipList.add("Extends Tea Storage by " + EnumChatFormatting.RED + numberFormat.format(Long.MAX_VALUE)); + } + + @Override + public float getResistance() { + return 999999999999.f; + } +} diff --git a/src/main/java/kubatech/loaders/item/IItemProxyGUI.java b/src/main/java/kubatech/loaders/item/IItemProxyGUI.java new file mode 100644 index 0000000000..80462e7a3a --- /dev/null +++ b/src/main/java/kubatech/loaders/item/IItemProxyGUI.java @@ -0,0 +1,31 @@ +/* + * spotless:off + * KubaTech - Gregtech Addon + * Copyright (C) 2022 - 2024 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/>. + * spotless:on + */ + +package kubatech.loaders.item; + +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 new file mode 100644 index 0000000000..402e68fa70 --- /dev/null +++ b/src/main/java/kubatech/loaders/item/ItemProxy.java @@ -0,0 +1,122 @@ +/* + * spotless:off + * KubaTech - Gregtech Addon + * Copyright (C) 2022 - 2024 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/>. + * spotless:on + */ + +package kubatech.loaders.item; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.ItemStack; +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; + +import kubatech.Tags; + +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 final String unlocalizedName; + private final String texturepath; + private IIcon icon; + + public ItemProxy(String unlocalizedName, String texture) { + this.unlocalizedName = "kubaitem." + unlocalizedName; + texturepath = Tags.MODID + ":" + texture; + } + + public ItemProxy(String unlocalizedNameAndTexture) { + this(unlocalizedNameAndTexture, unlocalizedNameAndTexture); + } + + public void ItemInit(int index) {} + + public String getUnlocalizedName() { + return unlocalizedName; + } + + public String getDisplayName(ItemStack stack) { + return StatCollector.translateToLocal(this.unlocalizedName + ".name") + .trim(); + } + + public void registerIcon(IIconRegister iconRegister) { + icon = iconRegister.registerIcon(texturepath); + } + + public IIcon getIcon() { + return icon; + } + + public void addInformation(ItemStack stack, EntityPlayer entity, List<String> tooltipList, boolean showDebugInfo) {} + + public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean isCurrentItem) {} + + public EnumAction getItemUseAction(ItemStack stack) { + return EnumAction.none; + } + + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer entity) { + return stack; + } + + public ItemStack onEaten(ItemStack stack, World world, EntityPlayer entity) { + return stack; + } + + public int getMaxItemUseDuration() { + return 0; + } + + public static void openHeldItemGUI(EntityPlayer player) { + ItemStack stack = player.getHeldItem(); + if (KubaItems.getItemProxy(stack) instanceof IItemProxyGUI) HeldItemUIInfo.open(player); + } +} diff --git a/src/main/java/kubatech/loaders/item/KubaItems.java b/src/main/java/kubatech/loaders/item/KubaItems.java new file mode 100644 index 0000000000..3dde241ff5 --- /dev/null +++ b/src/main/java/kubatech/loaders/item/KubaItems.java @@ -0,0 +1,144 @@ +/* + * spotless:off + * KubaTech - Gregtech Addon + * Copyright (C) 2022 - 2024 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/>. + * spotless:on + */ + +package kubatech.loaders.item; + +import static kubatech.kubatech.KT; + +import java.util.HashMap; +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +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; +import kubatech.loaders.ItemLoader; + +public class KubaItems extends Item { + + private static final HashMap<Integer, ItemProxy> items = new HashMap<>(); + private static int idCounter = 0; + + public KubaItems() { + this.setMaxDamage(0); + this.setHasSubtypes(true); + this.setCreativeTab(KT); + this.setUnlocalizedName("kubaitems"); + } + + public ItemStack registerProxyItem(ItemProxy item) { + items.put(idCounter, item); + item.ItemInit(idCounter); + return new ItemStack(this, 1, idCounter++); + } + + private ItemProxy getItem(ItemStack stack) { + return items.get(stack.getItemDamage()); + } + + public static ItemProxy getItemProxy(ItemStack stack) { + if (!(stack.getItem() instanceof KubaItems)) return null; + return ItemLoader.kubaitems.getItem(stack); + } + + private ItemProxy getItem(int damage) { + return items.get(damage); + } + + @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_) { + return false; + } + + @Override + public EnumAction getItemUseAction(ItemStack p_77661_1_) { + return getItem(p_77661_1_).getItemUseAction(p_77661_1_); + } + + @Override + public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { + return getItem(p_77659_1_).onItemRightClick(p_77659_1_, p_77659_2_, p_77659_3_); + } + + @Override + public ItemStack onEaten(ItemStack p_77654_1_, World p_77654_2_, EntityPlayer p_77654_3_) { + return getItem(p_77654_1_).onEaten(p_77654_1_, p_77654_2_, p_77654_3_); + } + + @Override + public int getMaxItemUseDuration(ItemStack p_77626_1_) { + return getItem(p_77626_1_).getMaxItemUseDuration(); + } + + @Override + public int getMetadata(int p_77647_1_) { + return p_77647_1_; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { + getItem(p_77624_1_).addInformation(p_77624_1_, p_77624_2_, (List<String>) p_77624_3_, p_77624_4_); + } + + @Override + public String getUnlocalizedName(ItemStack p_77667_1_) { + return getItem(p_77667_1_).getUnlocalizedName(); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + return getItem(p_77653_1_).getDisplayName(p_77653_1_); + } + + @SideOnly(Side.CLIENT) + @Override + public void registerIcons(IIconRegister p_94581_1_) { + items.values() + .forEach(t -> t.registerIcon(p_94581_1_)); + } + + @SideOnly(Side.CLIENT) + @Override + public IIcon getIconFromDamage(int damage) { + return getItem(damage).getIcon(); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_) { + for (int i = 0; i < items.size(); i++) p_150895_3_.add(new ItemStack(p_150895_1_, 1, i)); + } + + @Override + 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 new file mode 100644 index 0000000000..f1b3ae3d0b --- /dev/null +++ b/src/main/java/kubatech/loaders/item/items/Tea.java @@ -0,0 +1,72 @@ +/* + * spotless:off + * KubaTech - Gregtech Addon + * Copyright (C) 2022 - 2024 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/>. + * spotless:on + */ + +package kubatech.loaders.item.items; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import kubatech.loaders.item.ItemProxy; + +public class Tea extends ItemProxy { + + private final int heal; + private final float saturation; + + public Tea(String unlocalizedName, int heal, float saturation) { + super("tea." + unlocalizedName, "tea/" + unlocalizedName); + this.heal = heal; + this.saturation = saturation; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer entity, List<String> tooltipList, boolean showDebugInfo) { + tooltipList.add("Tea"); + } + + @Override + public EnumAction getItemUseAction(ItemStack stack) { + return EnumAction.drink; + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer entity) { + entity.setItemInUse(stack, getMaxItemUseDuration()); + return stack; + } + + @Override + public ItemStack onEaten(ItemStack stack, World world, EntityPlayer entity) { + if (!entity.capabilities.isCreativeMode) --stack.stackSize; + entity.getFoodStats() + .addStats(heal, saturation); + world.playSoundAtEntity(entity, "random.burp", 0.5F, world.rand.nextFloat() * 0.1F + 0.9F); + return stack; + } + + @Override + public int getMaxItemUseDuration() { + return 32; + } +} diff --git a/src/main/java/kubatech/loaders/item/items/TeaCollection.java b/src/main/java/kubatech/loaders/item/items/TeaCollection.java new file mode 100644 index 0000000000..efa390c517 --- /dev/null +++ b/src/main/java/kubatech/loaders/item/items/TeaCollection.java @@ -0,0 +1,209 @@ +/* + * spotless:off + * KubaTech - Gregtech Addon + * Copyright (C) 2022 - 2024 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/>. + * spotless:on + */ + +package kubatech.loaders.item.items; + +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.EnumAction; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagString; +import net.minecraft.stats.Achievement; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.AchievementPage; + +import kubatech.api.utils.ModUtils; +import kubatech.loaders.ItemLoader; +import kubatech.loaders.item.ItemProxy; + +public class TeaCollection extends ItemProxy { + + protected static TeaPage teapage; + protected static LinkedList<Achievement> achievements; + protected Achievement achievement; + private final String achievementname; + + public TeaCollection(String unlocalizedName) { + super("teacollection." + unlocalizedName, "tea/" + unlocalizedName); + 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 } }; + + boolean checkTeaOwner(ItemStack stack, UUID player) { + NBTTagCompound tag = stack.stackTagCompound; + if (tag == null || !stack.stackTagCompound.hasKey("TeaOwnerUUID")) return true; + return stack.stackTagCompound.getString("TeaOwnerUUID") + .equals(player.toString()); + } + + boolean checkTeaOwner(ItemStack stack, String player) { + NBTTagCompound tag = stack.stackTagCompound; + if (tag == null || !stack.stackTagCompound.hasKey("TeaOwner")) return true; + return stack.stackTagCompound.getString("TeaOwner") + .equals(player); + } + + private boolean checkOrSetTeaOwner(ItemStack stack, EntityPlayer player) { + NBTTagCompound tag = stack.stackTagCompound; + if (tag == null || !stack.stackTagCompound.hasKey("TeaOwnerUUID")) { + stack.setTagInfo( + "TeaOwnerUUID", + new NBTTagString( + player.getPersistentID() + .toString())); + stack.setTagInfo("TeaOwner", new NBTTagString(player.getCommandSenderName())); + return true; + } + if (stack.stackTagCompound.getString("TeaOwnerUUID") + .equals( + player.getPersistentID() + .toString())) { + stack.setTagInfo("TeaOwner", new NBTTagString(player.getCommandSenderName())); + return true; + } else return false; + } + + @Override + public void ItemInit(int index) { + super.ItemInit(index); + if (teapage == null) { + teapage = new TeaPage(); + AchievementPage.registerAchievementPage(teapage); + achievements = teapage.getAchievementsOriginal(); + } + achievements.add( + achievement = new Achievement( + 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")); + return; + } + tooltipList.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("kubaitem.fromcollection")); + tooltipList.add( + EnumChatFormatting.GRAY + "" + + EnumChatFormatting.BOLD + + "" + + EnumChatFormatting.ITALIC + + "" + + EnumChatFormatting.UNDERLINE + + StatCollector.translateToLocal("kubaitem.teacollection")); + } + + @Override + public EnumAction getItemUseAction(ItemStack stack) { + return EnumAction.drink; + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer entity) { + if (!checkTeaOwner(stack, entity.getCommandSenderName())) return stack; + entity.setItemInUse(stack, 32); + return stack; + } + + @Override + 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.triggerAchievement(achievement); + return stack; + } + + @Override + public int getMaxItemUseDuration() { + return 32; + } + + @Override + public String getDisplayName(ItemStack stack) { + if (!ModUtils.isClientSided || Minecraft.getMinecraft().thePlayer == null) { + return super.getDisplayName(stack); + } + // UUID is different on client if in offline mode I think + if (checkTeaOwner(stack, Minecraft.getMinecraft().thePlayer.getCommandSenderName())) { + return super.getDisplayName(stack); + } + return EnumChatFormatting.GOLD + "" + EnumChatFormatting.BOLD + "" + EnumChatFormatting.ITALIC + "???????"; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean isCurrentItem) { + if (world.isRemote) return; + if (!(entity instanceof EntityPlayerMP)) return; + checkOrSetTeaOwner(stack, (EntityPlayer) entity); + NBTTagCompound tag = stack.stackTagCompound; + if (tag.hasKey("display")) tag.removeTag("display"); + } + + private static class TeaPage extends AchievementPage { + + public TeaPage() { + super("Tea"); + } + + final LinkedList<Achievement> unlockedAchievements = new LinkedList<>(); + + @Override + public List<Achievement> getAchievements() { + if (!ModUtils.isClientSided) return super.getAchievements(); + + if (new Throwable().getStackTrace()[1].getMethodName() + .equals("isAchievementInPages")) return super.getAchievements(); // 5HEAD FIX + + unlockedAchievements.clear(); + for (Achievement achievement : achievements) if (Minecraft.getMinecraft().thePlayer.getStatFileWriter() + .hasAchievementUnlocked(achievement)) unlockedAchievements.add(achievement); + return unlockedAchievements; + } + + private LinkedList<Achievement> getAchievementsOriginal() { + return (LinkedList<Achievement>) super.getAchievements(); + } + } +} diff --git a/src/main/java/kubatech/loaders/item/items/TeaIngredient.java b/src/main/java/kubatech/loaders/item/items/TeaIngredient.java new file mode 100644 index 0000000000..4ff248ea37 --- /dev/null +++ b/src/main/java/kubatech/loaders/item/items/TeaIngredient.java @@ -0,0 +1,41 @@ +/* + * spotless:off + * KubaTech - Gregtech Addon + * Copyright (C) 2022 - 2024 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/>. + * spotless:on + */ + +package kubatech.loaders.item.items; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import kubatech.loaders.item.ItemProxy; + +public class TeaIngredient extends ItemProxy { + + public TeaIngredient(String unlocalizedName) { + super("teaingredient." + unlocalizedName, "teaingredient/" + unlocalizedName); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer entity, List<String> tooltipList, boolean showDebugInfo) { + tooltipList.add(EnumChatFormatting.GRAY + "This is Tea ingredient"); + } +} diff --git a/src/main/java/kubatech/loaders/item/items/TeaUltimate.java b/src/main/java/kubatech/loaders/item/items/TeaUltimate.java new file mode 100644 index 0000000000..cee7eba132 --- /dev/null +++ b/src/main/java/kubatech/loaders/item/items/TeaUltimate.java @@ -0,0 +1,216 @@ +/* + * spotless:off + * KubaTech - Gregtech Addon + * Copyright (C) 2022 - 2024 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/>. + * spotless:on + */ + +package kubatech.loaders.item.items; + +import static kubatech.api.Variables.numberFormat; +import static kubatech.api.Variables.numberFormatScientific; + +import java.math.BigInteger; +import java.text.NumberFormat; +import java.util.concurrent.atomic.AtomicReference; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +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.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DynamicTextWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.MultiChildWidget; +import com.gtnewhorizons.modularui.common.widget.TabButton; +import com.gtnewhorizons.modularui.common.widget.TabContainer; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import codechicken.nei.NEIClientUtils; +import kubatech.api.enums.ItemList; +import kubatech.api.tea.TeaNetwork; +import kubatech.api.utils.ModUtils; +import kubatech.api.utils.StringUtils; +import kubatech.loaders.item.IItemProxyGUI; + +public class TeaUltimate extends TeaCollection implements IItemProxyGUI { + + public TeaUltimate() { + super("ultimate_tea"); + } + + private static String name = ""; + private static long timeCounter = 0; + private static int colorCounter = 0; + + public static String getUltimateTeaDisplayName(String displayName) { + long current = System.currentTimeMillis(); + if (current - timeCounter > 100) { + timeCounter = current; + name = StringUtils.applyRainbow( + "ULTIMATE", + colorCounter++, + EnumChatFormatting.BOLD.toString() + EnumChatFormatting.OBFUSCATED); + } + return String.format(displayName, name + EnumChatFormatting.RESET); + } + + @Override + public String getDisplayName(ItemStack stack) { + if (!ModUtils.isClientSided || Minecraft.getMinecraft().thePlayer == null) return super.getDisplayName(stack); + if (checkTeaOwner(stack, Minecraft.getMinecraft().thePlayer.getCommandSenderName())) { + return getUltimateTeaDisplayName(super.getDisplayName(stack)); + } + return EnumChatFormatting.GOLD + "" + EnumChatFormatting.BOLD + "" + EnumChatFormatting.ITALIC + "???????"; + } + + @Override + public ModularWindow createWindow(ItemStack stack, EntityPlayer player) { + ModularWindow.Builder builder = ModularWindow.builder(200, 150); + builder.setBackground(ModularUITextures.VANILLA_BACKGROUND); + final TeaNetwork teaNetwork = TeaNetwork.getNetwork(player.getPersistentID()); + 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); + AtomicReference<BigInteger> teaAmount = new AtomicReference<>(BigInteger.ZERO); + AtomicReference<BigInteger> teaLimit = new AtomicReference<>(BigInteger.ZERO); + 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: " + (NEIClientUtils.shiftKey() ? numberFormat.format(teaAmount.get()) + : numberFormatScientific.format(teaAmount.get()))).color(Color.GREEN.dark(3))) + .setSynced(false) + .setPos(20, 20) + .attachSyncer( + new FakeSyncWidget.BigIntegerSyncer( + () -> teaNetwork.teaAmount, + teaAmount::set), + builder)) + .addChild( + new DynamicTextWidget( + () -> new Text( + "Tea limit: " + (NEIClientUtils.shiftKey() ? numberFormat.format(teaLimit.get()) + : numberFormatScientific.format(teaLimit.get()))).color(Color.GREEN.dark(3))) + .setSynced(false) + .setPos(20, 30) + .attachSyncer( + new FakeSyncWidget.BigIntegerSyncer( + () -> teaNetwork.teaLimit, + teaLimit::set), + builder))) + .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 (!teaNetwork.canAfford(50_000, true)) return; + 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(); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer entity) { + if (world.isRemote) return stack; + if (!(entity instanceof EntityPlayerMP)) return stack; + if (!checkTeaOwner(stack, entity.getPersistentID())) return stack; + openHeldItemGUI(entity); + return stack; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean isCurrentItem) { + if (world.isRemote) return; + if (!(entity instanceof EntityPlayerMP)) return; + super.onUpdate(stack, world, entity, slot, isCurrentItem); + if (checkTeaOwner(stack, entity.getPersistentID())) { + TeaNetwork teaNetwork = TeaNetwork.getNetwork(entity.getPersistentID()); + teaNetwork.addTea(1); + + /* + * if (playerData.autoRegen && playerData.teaAmount > 75_000) { if (((EntityPlayerMP) + * entity).getActivePotionEffect(Potion.regeneration) == null) { ((EntityPlayerMP) + * entity).addPotionEffect(new PotionEffect(Potion.regeneration.id, 1200, 0, true)); playerData.teaAmount -= + * 75_000; } } + */ + } + } +} |