diff options
Diffstat (limited to 'src/main/java/bwcrossmod/galacticgreg')
3 files changed, 699 insertions, 0 deletions
diff --git a/src/main/java/bwcrossmod/galacticgreg/MTEVoidMinerBase.java b/src/main/java/bwcrossmod/galacticgreg/MTEVoidMinerBase.java new file mode 100644 index 0000000000..1eb6d8e312 --- /dev/null +++ b/src/main/java/bwcrossmod/galacticgreg/MTEVoidMinerBase.java @@ -0,0 +1,309 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package bwcrossmod.galacticgreg; + +import static bartworks.util.BWTooltipReference.MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS; +import static gregtech.api.enums.GTValues.VN; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.OutputBus; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.gen.ChunkProviderServer; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import com.google.common.collect.ImmutableList; + +import gregtech.api.enums.GTValues; +import gregtech.api.interfaces.IHatchElement; +import gregtech.api.objects.XSTR; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.shutdown.ShutDownReasonRegistry; +import gregtech.common.tileentities.machines.multi.MTEDrillerBase; + +public abstract class MTEVoidMinerBase extends MTEDrillerBase { + + private VoidMinerUtility.DropMap dropMap = null; + private VoidMinerUtility.DropMap extraDropMap = null; + private float totalWeight; + private int multiplier = 1; + + protected final byte TIER_MULTIPLIER; + + private boolean mBlacklist = false; + + /** + * @Deprecated Use {@link VoidMinerUtility#addBlockToDimensionList} + */ + @Deprecated + public static void addBlockToDimensionList(int dimId, Block block, int meta, float weight) { + VoidMinerUtility.addBlockToDimensionList(dimId, block, meta, weight); + } + + public MTEVoidMinerBase(int aID, String aName, String aNameRegional, int tier) { + super(aID, aName, aNameRegional); + this.TIER_MULTIPLIER = (byte) Math.max(tier, 1); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mBlacklist", this.mBlacklist); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mBlacklist = aNBT.getBoolean("mBlacklist"); + } + + public MTEVoidMinerBase(String aName, int tier) { + super(aName); + this.TIER_MULTIPLIER = (byte) tier; + } + + @Override + protected int getMinTier() { + return this.TIER_MULTIPLIER + 5; // min tier = LuV + } + + @Override + protected boolean checkHatches() { + return true; + } + + @Override + protected void setElectricityStats() { + try { + this.mEUt = this.isPickingPipes ? 60 : Math.toIntExact(GTValues.V[this.getMinTier()]); + } catch (ArithmeticException e) { + e.printStackTrace(); + this.mEUt = Integer.MAX_VALUE - 7; + } + this.mOutputItems = new ItemStack[0]; + this.mProgresstime = 0; + this.mMaxProgresstime = 10; + this.mEfficiency = this.getCurrentEfficiency(null); + this.mEfficiencyIncrease = 10000; + this.mEUt = this.mEUt > 0 ? -this.mEUt : this.mEUt; + } + + @Override + protected boolean workingAtBottom(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, + int yHead, int oldYHead) { + // if the dropMap has never been initialised or if the dropMap is empty + if (this.dropMap == null || this.totalWeight == 0) this.calculateDropMap(); + + if (this.totalWeight != 0.f) { + this.handleFluidConsumption(); + this.handleOutputs(); + return true; + } else { + this.stopMachine(ShutDownReasonRegistry.NONE); + return false; + } + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + String casings = this.getCasingBlockItem() + .get(0) + .getDisplayName(); + + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Miner") + .addInfo("Controller Block for the Void Miner " + GTValues.VN[this.getMinTier()]) + .addInfo("Consumes " + GTValues.V[this.getMinTier()] + "EU/t") + .addInfo( + "Can be supplied with 2L/s of Neon(x4), Krypton(x8), Xenon(x16) or Oganesson(x64) for higher outputs.") + .addInfo( + "Will output " + 2 * this.TIER_MULTIPLIER + + " Ores per Second depending on the Dimension it is build in") + .addInfo("Put the Ore into the input bus to set the Whitelist/Blacklist") + .addInfo("Use a screwdriver to toggle Whitelist/Blacklist") + .addInfo( + "Blacklist or non Whitelist Ore will be " + EnumChatFormatting.DARK_RED + + "VOIDED" + + EnumChatFormatting.RESET + + ".") + .addSeparator() + .beginStructureBlock(3, 7, 3, false) + .addController("Front bottom") + .addOtherStructurePart(casings, "form the 3x1x3 Base") + .addOtherStructurePart(casings, "1x3x1 pillar above the center of the base (2 minimum total)") + .addOtherStructurePart( + this.getFrameMaterial().mName + " Frame Boxes", + "Each pillar's side and 1x3x1 on top") + .addEnergyHatch(VN[this.getMinTier()] + "+, Any base casing") + .addMaintenanceHatch("Any base casing") + .addInputBus("Mining Pipes or Ores, optional, any base casing") + .addInputHatch("Optional noble gas, any base casing") + .addOutputBus("Any base casing") + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS); + return tt; + } + + @Override + protected List<IHatchElement<? super MTEDrillerBase>> getAllowedHatches() { + return ImmutableList.of(InputHatch, InputBus, OutputBus, Maintenance, Energy); + } + + /** + * method used to pick the next ore in the dropMap. + * + * @return the chosen ore + */ + private ItemStack nextOre() { + float currentWeight = 0.f; + while (true) { + float randomNumber = XSTR.XSTR_INSTANCE.nextFloat() * this.totalWeight; + for (Map.Entry<GTUtility.ItemId, Float> entry : this.dropMap.getInternalMap() + .entrySet()) { + currentWeight += entry.getValue(); + if (randomNumber < currentWeight) return entry.getKey() + .getItemStack(); + } + for (Map.Entry<GTUtility.ItemId, Float> entry : this.extraDropMap.getInternalMap() + .entrySet()) { + currentWeight += entry.getValue(); + if (randomNumber < currentWeight) return entry.getKey() + .getItemStack(); + } + } + } + + /** + * Method used to check the current gat and its corresponding multiplier + * + * @return the noble gas in the hatch. returns null if there is no noble gas found. + */ + private FluidStack getNobleGasInputAndSetMultiplier() { + for (FluidStack s : this.getStoredFluids()) { + for (int i = 0; i < VoidMinerUtility.NOBLE_GASSES.length; i++) { + FluidStack ng = VoidMinerUtility.NOBLE_GASSES[i]; + if (ng.isFluidEqual(s)) { + this.multiplier = this.TIER_MULTIPLIER * VoidMinerUtility.NOBEL_GASSES_MULTIPLIER[i]; + return s; + } + } + } + return null; + } + + /** + * method used to decrement the quantity of gas in the hatch + * + * @param gasToConsume the fluid stack in the hatch + * @return if yes or no it was able to decrement the quantity of the fluidStack + */ + private boolean consumeNobleGas(FluidStack gasToConsume) { + for (FluidStack s : this.getStoredFluids()) { + if (s.isFluidEqual(gasToConsume) && s.amount >= 1) { + s.amount -= 1; + this.updateSlots(); + return true; + } + } + return false; + } + + /** + * handler for the fluid consumption + */ + private void handleFluidConsumption() { + FluidStack storedNobleGas = this.getNobleGasInputAndSetMultiplier(); + if (storedNobleGas == null || !this.consumeNobleGas(storedNobleGas)) this.multiplier = this.TIER_MULTIPLIER; + } + + /** + * Handles the ores added manually with {@link VoidMinerUtility#addMaterialToDimensionList} + * + * @param id the specified dim id + */ + private void handleExtraDrops(int id) { + if (VoidMinerUtility.extraDropsDimMap.containsKey(id)) { + extraDropMap = VoidMinerUtility.extraDropsDimMap.get(id); + } + } + + /** + * Gets the DropMap of the dim for the specified dim id + * + * @param id the dim number + */ + private void handleModDimDef(int id) { + if (VoidMinerUtility.dropMapsByDimId.containsKey(id)) { + this.dropMap = VoidMinerUtility.dropMapsByDimId.get(id); + } else { + String chunkProviderName = ((ChunkProviderServer) this.getBaseMetaTileEntity() + .getWorld() + .getChunkProvider()).currentChunkProvider.getClass() + .getName(); + + if (VoidMinerUtility.dropMapsByChunkProviderName.containsKey(chunkProviderName)) { + this.dropMap = VoidMinerUtility.dropMapsByChunkProviderName.get(chunkProviderName); + } + } + } + + /** + * Computes first the ores related to the dim the VM is in, then the ores added manually, then it computes the + * totalWeight for normalisation + */ + private void calculateDropMap() { + this.dropMap = new VoidMinerUtility.DropMap(); + this.extraDropMap = new VoidMinerUtility.DropMap(); + int id = this.getBaseMetaTileEntity() + .getWorld().provider.dimensionId; + this.handleModDimDef(id); + this.handleExtraDrops(id); + this.totalWeight = dropMap.getTotalWeight() + extraDropMap.getTotalWeight(); + } + + /** + * Output logic of the VM + */ + private void handleOutputs() { + final List<ItemStack> inputOres = this.getStoredInputs() + .stream() + .filter(GTUtility::isOre) + .collect(Collectors.toList());; + final ItemStack output = this.nextOre(); + output.stackSize = multiplier; + if (inputOres.size() == 0 || this.mBlacklist && inputOres.stream() + .noneMatch(is -> GTUtility.areStacksEqual(is, output)) + || !this.mBlacklist && inputOres.stream() + .anyMatch(is -> GTUtility.areStacksEqual(is, output))) + this.addOutput(output); + this.updateSlots(); + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + this.mBlacklist = !this.mBlacklist; + GTUtility.sendChatToPlayer(aPlayer, "Mode: " + (this.mBlacklist ? "Blacklist" : "Whitelist")); + } +} diff --git a/src/main/java/bwcrossmod/galacticgreg/MTEVoidMiners.java b/src/main/java/bwcrossmod/galacticgreg/MTEVoidMiners.java new file mode 100644 index 0000000000..03caf26a25 --- /dev/null +++ b/src/main/java/bwcrossmod/galacticgreg/MTEVoidMiners.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package bwcrossmod.galacticgreg; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class MTEVoidMiners { + + public static class VMLUV extends MTEVoidMinerBase { + + public VMLUV(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 1); + } + + public VMLUV(String aName, int tier) { + super(aName, tier); + } + + @Override + protected ItemList getCasingBlockItem() { + return ItemList.Casing_UV; + } + + @Override + protected Materials getFrameMaterial() { + return Materials.Europium; + } + + @Override + protected int getCasingTextureIndex() { + return 8; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new VMLUV(this.mName, this.TIER_MULTIPLIER); + } + } + + public static class VMZPM extends MTEVoidMinerBase { + + public VMZPM(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 2); + } + + public VMZPM(String aName, int tier) { + super(aName, tier); + } + + @Override + protected ItemList getCasingBlockItem() { + return ItemList.Casing_MiningBlackPlutonium; + } + + @Override + protected Materials getFrameMaterial() { + return Materials.BlackPlutonium; + } + + @Override + protected int getCasingTextureIndex() { + return 179; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new VMZPM(this.mName, this.TIER_MULTIPLIER); + } + } + + public static class VMUV extends MTEVoidMinerBase { + + public VMUV(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 3); + } + + public VMUV(String aName, int tier) { + super(aName, tier); + } + + @Override + protected ItemList getCasingBlockItem() { + return ItemList.Casing_MiningNeutronium; + } + + @Override + protected Materials getFrameMaterial() { + return Materials.Neutronium; + } + + @Override + protected int getCasingTextureIndex() { + return 178; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new VMUV(this.mName, this.TIER_MULTIPLIER); + } + } +} diff --git a/src/main/java/bwcrossmod/galacticgreg/VoidMinerUtility.java b/src/main/java/bwcrossmod/galacticgreg/VoidMinerUtility.java new file mode 100644 index 0000000000..b0782f91ae --- /dev/null +++ b/src/main/java/bwcrossmod/galacticgreg/VoidMinerUtility.java @@ -0,0 +1,275 @@ +package bwcrossmod.galacticgreg; + +import static galacticgreg.registry.GalacticGregRegistry.getModContainers; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Predicate; + +import net.minecraft.block.Block; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import bartworks.common.configs.ConfigHandler; +import bartworks.system.material.Werkstoff; +import bartworks.system.material.WerkstoffLoader; +import bartworks.system.oregen.BWOreLayer; +import cpw.mods.fml.common.registry.GameRegistry; +import galacticgreg.GalacticGreg; +import galacticgreg.WorldgenOreLayerSpace; +import galacticgreg.WorldgenOreSmallSpace; +import galacticgreg.api.ModContainer; +import galacticgreg.api.ModDimensionDef; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.util.GTUtility; +import gregtech.common.WorldgenGTOreLayer; +import gregtech.common.WorldgenGTOreSmallPieces; + +public class VoidMinerUtility { + + public static final FluidStack[] NOBLE_GASSES = { WerkstoffLoader.Neon.getFluidOrGas(1), + WerkstoffLoader.Krypton.getFluidOrGas(1), WerkstoffLoader.Xenon.getFluidOrGas(1), + WerkstoffLoader.Oganesson.getFluidOrGas(1) }; + public static final int[] NOBEL_GASSES_MULTIPLIER = { 4, 8, 16, 64 }; + + public static class DropMap { + + private float totalWeight; + private final Map<GTUtility.ItemId, Float> internalMap; + + public DropMap() { + internalMap = new HashMap<>(); + totalWeight = 0; + } + + /** + * Method used to add an ore to the DropMap + * + * @param weight the non normalised weight + * @param isBWOres true for BW ores, false for GT ores + */ + public void addDrop(int meta, float weight, boolean isBWOres) { + if (isBWOres) { + addDrop(WerkstoffLoader.BWOres, meta, weight); + } else { + addDrop(GregTechAPI.sBlockOres1, meta, weight); + } + } + + /** + * Method used to add any item to the DropMap. Will be blocked if blacklisted. + * + * @param weight the non normalised weight + */ + public void addDrop(Block block, int meta, float weight) { + if (ConfigHandler.voidMinerBlacklist.contains( + String.format( + "%s:%d", + GameRegistry.findUniqueIdentifierFor(block) + .toString(), + meta))) + return; + Item item = Item.getItemFromBlock(block); + addDrop(item, meta, weight); + } + + /** + * Method used to add any item to the DropMap. Will be blocked if blacklisted. + * + * @param weight the non normalised weight + */ + public void addDrop(ItemStack itemStack, float weight) { + Item item = itemStack.getItem(); + int meta = Items.feather.getDamage(itemStack); + if (ConfigHandler.voidMinerBlacklist.contains( + String.format( + "%s:%d", + GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(item)) + .toString(), + meta))) + return; + addDrop(item, meta, weight); + } + + private void addDrop(Item item, int meta, float weight) { + GTUtility.ItemId ore = GTUtility.ItemId.createNoCopy(item, meta, null); + internalMap.merge(ore, weight, Float::sum); + totalWeight += weight; + } + + public float getTotalWeight() { + return totalWeight; + } + + public Map<GTUtility.ItemId, Float> getInternalMap() { + return internalMap; + } + } + + public static final Map<Integer, DropMap> dropMapsByDimId = new HashMap<>(); + public static final Map<String, DropMap> dropMapsByChunkProviderName = new HashMap<>(); + public static final Map<Integer, DropMap> extraDropsDimMap = new HashMap<>(); + + // Adds tellurium to OW to ensure a way to get it, as it's used in Magneto Resonatic + // Dust and Circuit Compound MK3 Dust + static { + addMaterialToDimensionList(0, Materials.Tellurium, 8.0f); + } + + /** + * Computes the ores of the dims + */ + public static void generateDropMaps() { + // vanilla dims + dropMapsByDimId.put(-1, getDropMapVanilla(-1)); + dropMapsByDimId.put(0, getDropMapVanilla(0)); + dropMapsByDimId.put(1, getDropMapVanilla(1)); + // Twilight Forest + dropMapsByDimId.put(7, getDropMapVanilla(7)); + + // ross dims + dropMapsByDimId.put(ConfigHandler.ross128BID, getDropMapRoss(ConfigHandler.ross128BID)); + dropMapsByDimId.put(ConfigHandler.ross128BAID, getDropMapRoss(ConfigHandler.ross128BAID)); + + // other space dims + for (ModContainer modContainer : getModContainers()) { + for (ModDimensionDef dimDef : modContainer.getDimensionList()) { + dropMapsByChunkProviderName.put(dimDef.getChunkProviderName(), getDropMapSpace(dimDef)); + } + } + } + + /** + * Method to generate a DropMap that contains ores of a vanilla GT worldgen + */ + private static DropMap getDropMapVanilla(int dimId) { + DropMap dropMap = new DropMap(); + + // Ore Veins + Predicate<WorldgenGTOreLayer> oreLayerPredicate = makeOreLayerPredicate(dimId); + WorldgenGTOreLayer.sList.stream() + .filter(gt_worldgen -> gt_worldgen.mEnabled && oreLayerPredicate.test(gt_worldgen)) + .forEach(element -> { + dropMap.addDrop(element.mPrimaryMeta, element.mWeight, false); + dropMap.addDrop(element.mSecondaryMeta, element.mWeight, false); + dropMap.addDrop(element.mSporadicMeta, element.mWeight / 8f, false); + dropMap.addDrop(element.mBetweenMeta, element.mWeight / 8f, false); + }); + + // Small Ores + Predicate<WorldgenGTOreSmallPieces> smallOresPredicate = makeSmallOresPredicate(dimId); + WorldgenGTOreSmallPieces.sList.stream() + .filter(gt_worldgen -> gt_worldgen.mEnabled && smallOresPredicate.test(gt_worldgen)) + .forEach(element -> dropMap.addDrop(element.mMeta, element.mAmount, false)); + return dropMap; + } + + /** + * Makes a predicate for the GT normal ore veins worldgen + * + * @return the predicate + */ + private static Predicate<WorldgenGTOreLayer> makeOreLayerPredicate(int dimensionId) { + return switch (dimensionId) { + case -1 -> gt_worldgen -> gt_worldgen.mNether; + case 0 -> gt_worldgen -> gt_worldgen.mOverworld; + case 1 -> gt_worldgen -> gt_worldgen.mEnd || gt_worldgen.mEndAsteroid; + case 7 -> gt_worldgen -> gt_worldgen.twilightForest; + default -> throw new IllegalStateException(); + }; + } + + /** + * Makes a predicate for the GT normal small ore worldgen + * + * @return the predicate + */ + private static Predicate<WorldgenGTOreSmallPieces> makeSmallOresPredicate(int dimensionId) { + return switch (dimensionId) { + case -1 -> gt_worldgen -> gt_worldgen.mNether; + case 0 -> gt_worldgen -> gt_worldgen.mOverworld; + case 1 -> gt_worldgen -> gt_worldgen.mEnd; + case 7 -> gt_worldgen -> gt_worldgen.twilightForest; + default -> throw new IllegalStateException(); + }; + } + + /** + * Create a DropMap that contains ores of Ross dims + * + * @param aID dim id of Ross128b or Ross128ba + */ + private static DropMap getDropMapRoss(int aID) { + DropMap dropMap = new DropMap(); + for (BWOreLayer oreLayer : BWOreLayer.sList) { + if (oreLayer.mEnabled && oreLayer.isGenerationAllowed("", aID, 0)) { + List<ItemStack> data = oreLayer.getStacks(); + dropMap.addDrop(data.get(0), oreLayer.mWeight); + dropMap.addDrop(data.get(1), oreLayer.mWeight); + dropMap.addDrop(data.get(2), oreLayer.mWeight / 8f); + dropMap.addDrop(data.get(3), oreLayer.mWeight / 8f); + } + } + return dropMap; + } + + /** + * Create a DropMap contains the ores from the galacticGreg space worldgen corresponding to the target dim + * + * @param finalDef ModDimensionDef corresponding to the target dim + */ + private static DropMap getDropMapSpace(ModDimensionDef finalDef) { + DropMap dropMap = new DropMap(); + + // Normal Ore Veins + GalacticGreg.oreVeinWorldgenList.stream() + .filter( + gt_worldgen -> gt_worldgen.mEnabled && gt_worldgen instanceof WorldgenOreLayerSpace oreLayerSpace + && oreLayerSpace.isEnabledForDim(finalDef)) + .map(gt_worldgen -> (WorldgenOreLayerSpace) gt_worldgen) + .forEach(element -> { + dropMap.addDrop(element.mPrimaryMeta, element.mWeight, false); + dropMap.addDrop(element.mSecondaryMeta, element.mWeight, false); + dropMap.addDrop(element.mSporadicMeta, element.mWeight / 8f, false); + dropMap.addDrop(element.mBetweenMeta, element.mWeight / 8f, false); + }); + + // Normal Small Ores + GalacticGreg.smallOreWorldgenList.stream() + .filter( + gt_worldgen -> gt_worldgen.mEnabled && gt_worldgen instanceof WorldgenOreSmallSpace oreSmallPiecesSpace + && oreSmallPiecesSpace.isEnabledForDim(finalDef)) + .map(gt_worldgen -> (WorldgenOreSmallSpace) gt_worldgen) + .forEach(element -> dropMap.addDrop(element.mMeta, element.mAmount, false)); + return dropMap; + } + + public static void addBlockToDimensionList(int dimId, Block block, int meta, float weight) { + if (!extraDropsDimMap.containsKey(dimId)) { + extraDropsDimMap.put(dimId, new DropMap()); + } + extraDropsDimMap.get(dimId) + .addDrop(block, meta, weight); + } + + /** + * Public method giving other mods the ability to add manually a material with an ore version into the external + * dropMap for a specified dim id + * + * @param DimensionID the dim id targeted + * @param Material the material with an ore version + * @param weight the non normalised version of the given weight + */ + public static void addMaterialToDimensionList(int DimensionID, ISubTagContainer Material, float weight) { + if (Material instanceof Materials gtMaterial) { + addBlockToDimensionList(DimensionID, GregTechAPI.sBlockOres1, gtMaterial.mMetaItemSubID, weight); + } else if (Material instanceof Werkstoff werkstoff) { + addBlockToDimensionList(DimensionID, WerkstoffLoader.BWOres, werkstoff.getmID(), weight); + } + } +} |