From 6888617c1b4d6a9836b97e4234ea114ad9bd25bc Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Tue, 16 Apr 2019 00:29:22 +0200 Subject: +added World Generation feature for Ross128b +started on Ross128ba +cleaned up code +started on Werkstoff Liquids +fixed small translation failure Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Former-commit-id: a43cc5cc4ac47e49a27203595c4b8ca841a81a9a --- .../bartimaeusnek/ASM/BWCoreTransformer.java | 4 +- .../bartworks/common/commands/SummonRuin.java | 55 ++++ .../bartworks/common/configs/ConfigHandler.java | 7 +- .../bartworks/neiHandler/BW_NEI_OreHandler.java | 13 +- .../system/material/BW_MetaGenerated_Items.java | 48 +-- .../system/material/BW_MetaGenerated_Ores.java | 4 +- .../bartworks/system/material/Werkstoff.java | 10 + .../bartworks/system/material/WerkstoffLoader.java | 195 +++++++------ .../bartworks/system/oregen/BW_OreLayer.java | 181 ++++++++++++ .../bartworks/system/oregen/BW_WordGenerator.java | 125 ++++++++ .../system/oregen/BW_WorldGenRoss128b.java | 74 +++++ .../system/oregen/BW_WorldGenRoss128ba.java | 54 ++++ .../bartworks/system/worldgen/GT_WorldgenUtil.java | 106 +++++++ .../bartworks/system/worldgen/MapGenRuins.java | 325 +++++++++++++++++++++ .../bartimaeusnek/crossmod/BartWorksCrossmod.java | 6 + .../crossmod/galacticraft/GalacticraftProxy.java | 4 +- .../planets/AbstractWorldProviderSpace.java | 40 +++ .../planets/ross128/world/oregen/BW_OreLayer.java | 150 ---------- .../ross128/world/oregen/BW_WordGenerator.java | 126 -------- .../ross128/world/oregen/BW_WorldGenRoss128.java | 69 ----- .../world/worldprovider/ChunkProviderRoss128b.java | 178 ----------- .../world/worldprovider/SkyProviderRoss128b.java | 33 --- .../world/worldprovider/WorldProviderRoss128b.java | 175 ----------- .../planets/ross128b/ChunkProviderRoss128b.java | 179 ++++++++++++ .../planets/ross128b/SkyProviderRoss128b.java | 33 +++ .../planets/ross128b/WorldProviderRoss128b.java | 163 +++++++++++ .../planets/ross128ba/ChunkProviderRoss128ba.java | 66 +++++ .../planets/ross128ba/WorldProviderRoss128ba.java | 117 ++++++++ .../solarsystems/Ross128SolarSystem.java | 17 +- 29 files changed, 1685 insertions(+), 872 deletions(-) create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/common/commands/SummonRuin.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_OreLayer.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WordGenerator.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128b.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128ba.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/GT_WorldgenUtil.java create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/MapGenRuins.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/AbstractWorldProviderSpace.java delete mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_OreLayer.java delete mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_WordGenerator.java delete mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_WorldGenRoss128.java delete mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/ChunkProviderRoss128b.java delete mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/SkyProviderRoss128b.java delete mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/WorldProviderRoss128b.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/ChunkProviderRoss128b.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/SkyProviderRoss128b.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/WorldProviderRoss128b.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/ChunkProviderRoss128ba.java create mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/WorldProviderRoss128ba.java (limited to 'src/main/java') diff --git a/src/main/java/com/github/bartimaeusnek/ASM/BWCoreTransformer.java b/src/main/java/com/github/bartimaeusnek/ASM/BWCoreTransformer.java index 6a9850e4fe..e56fd65c51 100644 --- a/src/main/java/com/github/bartimaeusnek/ASM/BWCoreTransformer.java +++ b/src/main/java/com/github/bartimaeusnek/ASM/BWCoreTransformer.java @@ -143,11 +143,11 @@ public class BWCoreTransformer implements IClassTransformer { nu.add(new VarInsnNode(ALOAD, 0)); nu.add(new FieldInsnNode(GETFIELD, "net/minecraft/client/renderer/RenderGlobal", useSrc ? theWorld_src : "theWorld", "Lnet/minecraft/client/multiplayer/WorldClient;")); nu.add(new FieldInsnNode(GETFIELD, "net/minecraft/client/multiplayer/WorldClient", useSrc ? provider_src : "provider", "Lnet/minecraft/world/WorldProvider;")); - nu.add(new TypeInsnNode(INSTANCEOF, "com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/WorldProviderRoss128b")); + nu.add(new TypeInsnNode(INSTANCEOF, "com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/WorldProviderRoss128b")); nu.add(new JumpInsnNode(IFEQ, LabelNodes[0])); nu.add(new VarInsnNode(ALOAD, 0)); nu.add(new FieldInsnNode(GETFIELD, "net/minecraft/client/renderer/RenderGlobal", useSrc ? renderEngine_src : "renderEngine", "Lnet/minecraft/client/renderer/texture/TextureManager;")); - nu.add(new FieldInsnNode(GETSTATIC, "com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/SkyProviderRoss128b", "sunTex", "Lnet/minecraft/util/ResourceLocation;")); + nu.add(new FieldInsnNode(GETSTATIC, "com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/SkyProviderRoss128b", "sunTex", "Lnet/minecraft/util/ResourceLocation;")); nu.add(new MethodInsnNode(INVOKEVIRTUAL, "net/minecraft/client/renderer/texture/TextureManager", useSrc ? bindTexture_src : "bindTexture", "(Lnet/minecraft/util/ResourceLocation;)V", false)); nu.add(new JumpInsnNode(GOTO, LabelNodes[1])); nu.add(LabelNodes[0]); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/SummonRuin.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/SummonRuin.java new file mode 100644 index 0000000000..f569d62abe --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/SummonRuin.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.commands; + +import com.github.bartimaeusnek.bartworks.system.worldgen.MapGenRuins; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; + +public class SummonRuin extends CommandBase { + + @Override + public String getCommandName() { + return "SummonRuin"; + } + + @Override + public String getCommandUsage(ICommandSender p_71518_1_) { + return "SummonRuin x z"; + } + + @Override + public void processCommand(ICommandSender iCommandSender, String[] p_71515_2_) { + try { + new MapGenRuins.RuinsBase().generate( + iCommandSender.getEntityWorld(), + iCommandSender.getEntityWorld().rand, + Integer.parseInt(p_71515_2_[0]), + 256, + Integer.parseInt(p_71515_2_[1]) + ); + }catch (Exception e){ + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java index 3f27a5adcf..6676b242aa 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java @@ -38,7 +38,8 @@ public class ConfigHandler { public static boolean DEHPDirectSteam; public static int megaMachinesMax = 256; public static int mbWaterperSec = 150; - public static int ross128ID = -64; + public static int ross128BID = -64; + public static int ross128BAID = -63; public static boolean Ross128Enabled = true; public static boolean debugLog; public static boolean experimentalThreadedLoader; @@ -68,7 +69,9 @@ public class ConfigHandler { BWCoreTransformer.shouldTransform[i] = ConfigHandler.c.get("ASM fixes", BWCoreTransformer.DESCRIPTIONFORCONFIG[i] + " in class: " + BWCoreTransformer.CLASSESBEEINGTRANSFORMED[i], true).getBoolean(true); } - ConfigHandler.ross128ID = ConfigHandler.c.get("CrossMod Interactions", "DimID - Ross128b", -64, "The Dim ID for Ross128b").getInt(-64); + ConfigHandler.ross128BID = ConfigHandler.c.get("CrossMod Interactions", "DimID - Ross128b", -64, "The Dim ID for Ross128b").getInt(-64); + ConfigHandler.ross128BAID = ConfigHandler.c.get("CrossMod Interactions", "DimID - Ross128ba", -63, "The Dim ID for Ross128ba (Ross128b's Moon)").getInt(-63); + ConfigHandler.Ross128Enabled = ConfigHandler.c.get("CrossMod Interactions", "Galacticraft - Activate Ross128 System", true, "If the Ross128 System should be activated").getBoolean(true); ConfigHandler.setUpComments(); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java index 5360268200..1012cffc01 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java @@ -29,10 +29,9 @@ import codechicken.nei.recipe.TemplateRecipeHandler; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Ores; import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; -import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; -import com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128.world.oregen.BW_OreLayer; -import com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128.world.oregen.BW_WorldGenRoss128; +import com.github.bartimaeusnek.bartworks.system.oregen.BW_OreLayer; +import com.github.bartimaeusnek.bartworks.system.oregen.BW_WorldGenRoss128b; import cpw.mods.fml.common.event.FMLInterModComms; import gregtech.api.GregTech_API; import gregtech.api.enums.OrePrefixes; @@ -91,9 +90,9 @@ public class BW_NEI_OreHandler extends TemplateRecipeHandler { public List getOtherStacks() { ArrayList ret = new ArrayList<>(); for (int i = 0; i < BW_OreLayer.sList.size(); i++) { - if (BW_OreLayer.sList.get(i) instanceof BW_WorldGenRoss128) { + if (BW_OreLayer.sList.get(i) instanceof BW_WorldGenRoss128b) { int baseMeta = result.getItemDamage(); - BW_WorldGenRoss128 worldGen = ((BW_WorldGenRoss128) BW_OreLayer.sList.get(i)); + BW_WorldGenRoss128b worldGen = ((BW_WorldGenRoss128b) BW_OreLayer.sList.get(i)); if (worldGen.mPrimaryMeta == baseMeta || worldGen.mSecondaryMeta == baseMeta || worldGen.mBetweenMeta == baseMeta || worldGen.mSporadicMeta == baseMeta) { ItemStack other; other = result.copy().setStackDisplayName(result.getDisplayName().replaceAll("Ore", "Vein")); @@ -187,9 +186,9 @@ public class BW_NEI_OreHandler extends TemplateRecipeHandler { public List getOtherStacks() { ArrayList ret = new ArrayList<>(); for (int i = 0; i < BW_OreLayer.sList.size(); i++) { - if (BW_OreLayer.sList.get(i) instanceof BW_WorldGenRoss128) { + if (BW_OreLayer.sList.get(i) instanceof BW_WorldGenRoss128b) { int baseMeta = result.getItemDamage(); - BW_WorldGenRoss128 worldGen = ((BW_WorldGenRoss128) BW_OreLayer.sList.get(i)); + BW_WorldGenRoss128b worldGen = ((BW_WorldGenRoss128b) BW_OreLayer.sList.get(i)); if (worldGen.mPrimaryMeta == baseMeta || worldGen.mSecondaryMeta == baseMeta || worldGen.mBetweenMeta == baseMeta || worldGen.mSporadicMeta == baseMeta) { ItemStack other; other = result.copy().setStackDisplayName(result.getDisplayName().replaceAll("Ore", "Vein")); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java index 72db71e58d..d50081c9e9 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java @@ -76,28 +76,30 @@ public class BW_MetaGenerated_Items extends GT_MetaGenerated_Item { } public boolean onEntityItemUpdate(EntityItem aItemEntity) { - int aDamage = aItemEntity.getEntityItem().getItemDamage(); - if ((aDamage >= 0) && (!aItemEntity.worldObj.isRemote)) { - Werkstoff aMaterial = werkstoffHashMap.get((short) aDamage); - if ((aMaterial != null) && (aMaterial != Werkstoff.default_null_Werkstoff)) { - int tX = MathHelper.floor_double(aItemEntity.posX); - int tY = MathHelper.floor_double(aItemEntity.posY); - int tZ = MathHelper.floor_double(aItemEntity.posZ); - if ((orePrefixes == OrePrefixes.dustImpure) || (orePrefixes == OrePrefixes.dustPure)) { - Block tBlock = aItemEntity.worldObj.getBlock(tX, tY, tZ); - byte tMetaData = (byte) aItemEntity.worldObj.getBlockMetadata(tX, tY, tZ); - if ((tBlock == Blocks.cauldron) && (tMetaData > 0)) { - aItemEntity.setEntityItemStack(WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.dust, aMaterial, aItemEntity.getEntityItem().stackSize)); - aItemEntity.worldObj.setBlockMetadataWithNotify(tX, tY, tZ, tMetaData - 1, 3); - return true; - } - } else if (orePrefixes == OrePrefixes.crushed) { - Block tBlock = aItemEntity.worldObj.getBlock(tX, tY, tZ); - byte tMetaData = (byte) aItemEntity.worldObj.getBlockMetadata(tX, tY, tZ); - if ((tBlock == Blocks.cauldron) && (tMetaData > 0)) { - aItemEntity.setEntityItemStack(WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.crushedPurified, aMaterial, aItemEntity.getEntityItem().stackSize)); - aItemEntity.worldObj.setBlockMetadataWithNotify(tX, tY, tZ, tMetaData - 1, 3); - return true; + if (orePrefixes == OrePrefixes.dustImpure || orePrefixes == OrePrefixes.dustPure || orePrefixes == OrePrefixes.crushed) { + int aDamage = aItemEntity.getEntityItem().getItemDamage(); + if ((aDamage >= 0) && (!aItemEntity.worldObj.isRemote)) { + Werkstoff aMaterial = werkstoffHashMap.get((short) aDamage); + if ((aMaterial != null) && (aMaterial != Werkstoff.default_null_Werkstoff)) { + int tX = MathHelper.floor_double(aItemEntity.posX); + int tY = MathHelper.floor_double(aItemEntity.posY); + int tZ = MathHelper.floor_double(aItemEntity.posZ); + if ((orePrefixes == OrePrefixes.dustImpure) || (orePrefixes == OrePrefixes.dustPure)) { + Block tBlock = aItemEntity.worldObj.getBlock(tX, tY, tZ); + byte tMetaData = (byte) aItemEntity.worldObj.getBlockMetadata(tX, tY, tZ); + if ((tBlock == Blocks.cauldron) && (tMetaData > 0)) { + aItemEntity.setEntityItemStack(WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.dust, aMaterial, aItemEntity.getEntityItem().stackSize)); + aItemEntity.worldObj.setBlockMetadataWithNotify(tX, tY, tZ, tMetaData - 1, 3); + return true; + } + } else if (orePrefixes == OrePrefixes.crushed) { + Block tBlock = aItemEntity.worldObj.getBlock(tX, tY, tZ); + byte tMetaData = (byte) aItemEntity.worldObj.getBlockMetadata(tX, tY, tZ); + if ((tBlock == Blocks.cauldron) && (tMetaData > 0)) { + aItemEntity.setEntityItemStack(WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.crushedPurified, aMaterial, aItemEntity.getEntityItem().stackSize)); + aItemEntity.worldObj.setBlockMetadataWithNotify(tX, tY, tZ, tMetaData - 1, 3); + return true; + } } } } @@ -113,6 +115,8 @@ public class BW_MetaGenerated_Items extends GT_MetaGenerated_Item { if (orePrefixes == OrePrefixes.dustImpure || orePrefixes == OrePrefixes.dustPure) { aList.add(GT_LanguageManager.getTranslation("metaitem.01.tooltip.purify")); } + if (orePrefixes == OrePrefixes.crushed) + aList.add(GT_LanguageManager.getTranslation("metaitem.01.tooltip.purify.2")); aList.add(StatCollector.translateToLocal("tooltip.bw.0.name") + ChatColorHelper.DARKGREEN + " BartWorks"); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java index fd8e39ebcb..ba03007669 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java @@ -65,7 +65,7 @@ public class BW_MetaGenerated_Ores extends BW_TileEntityContainer { } } - public static boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean air) { + public static boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean air, Block block) { if (!air) { aY = Math.min(aWorld.getActualHeight(), Math.max(aY, 1)); } @@ -76,7 +76,7 @@ public class BW_MetaGenerated_Ores extends BW_TileEntityContainer { return false; } else { - if (!tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone)) { + if (!tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, block)) { return false; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java index c1bd80e0ea..a681a86270 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java @@ -28,6 +28,7 @@ import com.github.bartimaeusnek.bartworks.util.Pair; import gregtech.api.enums.*; import gregtech.api.interfaces.IColorModulationContainer; import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.objects.GT_Fluid; import gregtech.api.util.GT_OreDictUnificator; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; @@ -135,6 +136,12 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { this.stats = stats.setMass(tmpmass); this.texSet = texSet; + + if (this.getStats().meltingPoint > 0) { + this.fluid = new GT_Fluid("molten" + this.getDefaultName().replaceAll(" ", ""), "molten.autogenerated", this.getRGBA()); + this.getGenerationFeatures().toGenerate |= 16; + } + Werkstoff.werkstoffHashSet.add(this); Werkstoff.werkstoffHashMap.put(this.mID, this); } @@ -310,6 +317,7 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { metal 10 gem 100 ore 1000 + cell 1000 */ public byte toGenerate = 0b0001001; public byte blacklist; @@ -392,6 +400,8 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { public static class Stats { + public static final int NULL_KELVIN = 0; + int boilingPoint; int meltingPoint; long protons; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java index 824435461d..7256b12a43 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java @@ -42,6 +42,7 @@ import gregtech.api.enums.*; import gregtech.api.interfaces.ISubTagContainer; import gregtech.api.objects.GT_MultiTexture; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; @@ -74,9 +75,9 @@ public class WerkstoffLoader implements Runnable { 1, TextureSet.SET_FLINT, Arrays.asList(Materials.Bismuth), - new Pair(Materials.Bismuth, 2), - new Pair(Materials.Oxygen, 2), - new Pair(Materials.CarbonDioxide, 2) + new Pair<>(Materials.Bismuth, 2), + new Pair<>(Materials.Oxygen, 2), + new Pair<>(Materials.CarbonDioxide, 2) ); public static final Werkstoff Bismuthinit = new Werkstoff( new short[]{192, 192, 192, 0}, @@ -86,8 +87,8 @@ public class WerkstoffLoader implements Runnable { 2, TextureSet.SET_METALLIC, Arrays.asList(Materials.Bismuth, Materials.Sulfur), - new Pair(Materials.Bismuth, 2), - new Pair(Materials.Sulfur, 3) + new Pair<>(Materials.Bismuth, 2), + new Pair<>(Materials.Sulfur, 3) ); public static final Werkstoff Zirconium = new Werkstoff( new short[]{175, 175, 175, 0}, @@ -108,8 +109,8 @@ public class WerkstoffLoader implements Runnable { 4, TextureSet.SET_DIAMOND, Arrays.asList(Zirconium), - new Pair(Zirconium, 1), - new Pair(Materials.Oxygen, 2) + new Pair<>(Zirconium, 1), + new Pair<>(Materials.Oxygen, 2) ); public static final Werkstoff FluorBuergerit = new Werkstoff( new short[]{0x20, 0x20, 0x20, 0}, @@ -120,13 +121,13 @@ public class WerkstoffLoader implements Runnable { 5, TextureSet.SET_RUBY, Arrays.asList(Materials.Sodium, Materials.Boron, Materials.Silicon), - new Pair(Materials.Sodium, 1), - new Pair(Materials.Iron, 3), - new Pair(Materials.Aluminium, 6), - new Pair(Materials.Silicon, 6), - new Pair(Materials.Boron, 3), - new Pair(Materials.Oxygen, 30), - new Pair(Materials.Fluorine, 1) + new Pair<>(Materials.Sodium, 1), + new Pair<>(Materials.Iron, 3), + new Pair<>(Materials.Aluminium, 6), + new Pair<>(Materials.Silicon, 6), + new Pair<>(Materials.Boron, 3), + new Pair<>(Materials.Oxygen, 30), + new Pair<>(Materials.Fluorine, 1) ); public static final Werkstoff YttriumOxide = new Werkstoff( new short[]{255,255,255,0}, @@ -135,8 +136,8 @@ public class WerkstoffLoader implements Runnable { new Werkstoff.GenerationFeatures().onlyDust(), //No autoadd here to gate this material by hand 6, TextureSet.SET_DULL, - new Pair(Materials.Yttrium, 2), - new Pair(Materials.Oxygen, 3) + new Pair<>(Materials.Yttrium, 2), + new Pair<>(Materials.Oxygen, 3) ); public static final Werkstoff ChromoAluminoPovondrait = new Werkstoff( new short[]{0, 0x79, 0x6A, 0}, @@ -148,13 +149,13 @@ public class WerkstoffLoader implements Runnable { 7, TextureSet.SET_RUBY, Arrays.asList(Materials.Sodium, Materials.Boron, Materials.Silicon), - new Pair(Materials.Sodium, 1), - new Pair(Materials.Chrome, 3), - new Pair(Materials.Magnalium, 6), - new Pair(Materials.Silicon, 6), - new Pair(Materials.Boron, 3), - new Pair(Materials.Oxygen, 31), - new Pair(Materials.Hydrogen, 3) + new Pair<>(Materials.Sodium, 1), + new Pair<>(Materials.Chrome, 3), + new Pair<>(Materials.Magnalium, 6), + new Pair<>(Materials.Silicon, 6), + new Pair<>(Materials.Boron, 3), + new Pair<>(Materials.Oxygen, 31), + new Pair<>(Materials.Hydrogen, 3) ); public static final Werkstoff VanadioOxyDravit = new Werkstoff( new short[]{0x60, 0xA0, 0xA0, 0}, @@ -166,13 +167,13 @@ public class WerkstoffLoader implements Runnable { 8, TextureSet.SET_RUBY, Arrays.asList(Materials.Sodium, Materials.Boron, Materials.Silicon), - new Pair(Materials.Sodium, 1), - new Pair(Materials.Vanadium, 3), - new Pair(Materials.Magnalium, 6), - new Pair(Materials.Silicon, 6), - new Pair(Materials.Boron, 3), - new Pair(Materials.Oxygen, 31), - new Pair(Materials.Hydrogen, 3) + new Pair<>(Materials.Sodium, 1), + new Pair<>(Materials.Vanadium, 3), + new Pair<>(Materials.Magnalium, 6), + new Pair<>(Materials.Silicon, 6), + new Pair<>(Materials.Boron, 3), + new Pair<>(Materials.Oxygen, 31), + new Pair<>(Materials.Hydrogen, 3) ); public static final Werkstoff Olenit = new Werkstoff( new short[]{210, 210, 210, 0}, @@ -184,12 +185,12 @@ public class WerkstoffLoader implements Runnable { 9, TextureSet.SET_RUBY, Arrays.asList(Materials.Sodium, Materials.Boron, Materials.Silicon), - new Pair(Materials.Sodium, 1), - new Pair(Materials.Aluminium, 9), - new Pair(Materials.Silicon, 6), - new Pair(Materials.Boron, 3), - new Pair(Materials.Oxygen, 31), - new Pair(Materials.Hydrogen, 1) + new Pair<>(Materials.Sodium, 1), + new Pair<>(Materials.Aluminium, 9), + new Pair<>(Materials.Silicon, 6), + new Pair<>(Materials.Boron, 3), + new Pair<>(Materials.Oxygen, 31), + new Pair<>(Materials.Hydrogen, 1) ); public static final Werkstoff Arsenopyrite = new Werkstoff( new short[]{0xB0, 0xB0, 0xB0, 0}, @@ -199,9 +200,9 @@ public class WerkstoffLoader implements Runnable { 10, TextureSet.SET_METALLIC, Arrays.asList(Materials.Sulfur, Materials.Arsenic, Materials.Iron), - new Pair(Materials.Iron, 1), - new Pair(Materials.Arsenic, 1), - new Pair(Materials.Sulfur, 1) + new Pair<>(Materials.Iron, 1), + new Pair<>(Materials.Arsenic, 1), + new Pair<>(Materials.Sulfur, 1) ); public static final Werkstoff Ferberite = new Werkstoff( new short[]{0xB0, 0xB0, 0xB0, 0}, @@ -211,9 +212,9 @@ public class WerkstoffLoader implements Runnable { 11, TextureSet.SET_METALLIC, Arrays.asList(Materials.Iron, Materials.Tungsten), - new Pair(Materials.Iron, 1), - new Pair(Materials.Tungsten, 1), - new Pair(Materials.Oxygen, 3) + new Pair<>(Materials.Iron, 1), + new Pair<>(Materials.Tungsten, 1), + new Pair<>(Materials.Oxygen, 3) ); public static final Werkstoff Loellingit = new Werkstoff( new short[]{0xD0, 0xD0, 0xD0, 0}, @@ -223,8 +224,8 @@ public class WerkstoffLoader implements Runnable { 12, TextureSet.SET_METALLIC, Arrays.asList(Materials.Iron, Materials.Arsenic), - new Pair(Materials.Iron, 1), - new Pair(Materials.Arsenic, 2) + new Pair<>(Materials.Iron, 1), + new Pair<>(Materials.Arsenic, 2) ); public static final Werkstoff Roquesit = new Werkstoff( new short[]{0xA0, 0xA0, 0xA0, 0}, @@ -234,9 +235,9 @@ public class WerkstoffLoader implements Runnable { 13, TextureSet.SET_METALLIC, Arrays.asList(Materials.Copper, Materials.Sulfur), - new Pair(Materials.Copper, 1), - new Pair(Materials.Indium, 1), - new Pair(Materials.Sulfur, 2) + new Pair<>(Materials.Copper, 1), + new Pair<>(Materials.Indium, 1), + new Pair<>(Materials.Sulfur, 2) ); public static final Werkstoff Bornite = new Werkstoff( new short[]{0x97, 0x66, 0x2B, 0}, @@ -246,9 +247,9 @@ public class WerkstoffLoader implements Runnable { 14, TextureSet.SET_METALLIC, Arrays.asList(Materials.Copper, Materials.Iron, Materials.Sulfur), - new Pair(Materials.Copper, 5), - new Pair(Materials.Iron, 1), - new Pair(Materials.Sulfur, 4) + new Pair<>(Materials.Copper, 5), + new Pair<>(Materials.Iron, 1), + new Pair<>(Materials.Sulfur, 4) ); public static final Werkstoff Wittichenit = new Werkstoff( Materials.Copper.mRGBa, @@ -258,9 +259,9 @@ public class WerkstoffLoader implements Runnable { 15, TextureSet.SET_METALLIC, Arrays.asList(Materials.Copper, Materials.Bismuth, Materials.Sulfur), - new Pair(Materials.Copper, 5), - new Pair(Materials.Bismuth, 1), - new Pair(Materials.Sulfur, 4) + new Pair<>(Materials.Copper, 5), + new Pair<>(Materials.Bismuth, 1), + new Pair<>(Materials.Sulfur, 4) ); public static final Werkstoff Djurleit = new Werkstoff( new short[]{0x60, 0x60, 0x60, 0}, @@ -270,8 +271,8 @@ public class WerkstoffLoader implements Runnable { 16, TextureSet.SET_METALLIC, Arrays.asList(Materials.Copper, Materials.Copper, Materials.Sulfur), - new Pair(Materials.Copper, 31), - new Pair(Materials.Sulfur, 16) + new Pair<>(Materials.Copper, 31), + new Pair<>(Materials.Sulfur, 16) ); public static final Werkstoff Huebnerit = new Werkstoff( new short[]{0x80, 0x60, 0x60, 0}, @@ -281,9 +282,9 @@ public class WerkstoffLoader implements Runnable { 17, TextureSet.SET_METALLIC, Arrays.asList(Materials.Manganese, Materials.Tungsten), - new Pair(Materials.Manganese, 1), - new Pair(Materials.Tungsten, 1), - new Pair(Materials.Oxygen, 3) + new Pair<>(Materials.Manganese, 1), + new Pair<>(Materials.Tungsten, 1), + new Pair<>(Materials.Oxygen, 3) ); public static final Werkstoff Thorianit = new Werkstoff( new short[]{0x30, 0x30, 0x30, 0}, @@ -293,8 +294,8 @@ public class WerkstoffLoader implements Runnable { 18, TextureSet.SET_METALLIC, Arrays.asList(Materials.Thorium), - new Pair(Materials.Thorium, 1), - new Pair(Materials.Oxygen, 2) + new Pair<>(Materials.Thorium, 1), + new Pair<>(Materials.Oxygen, 2) ); public static final Werkstoff RedZircon = new Werkstoff( new short[]{195, 19, 19, 0}, @@ -305,9 +306,9 @@ public class WerkstoffLoader implements Runnable { 19, TextureSet.SET_GEM_VERTICAL, Arrays.asList(Zirconium,Materials.Silicon), - new Pair(Zirconium, 1), - new Pair(Materials.Silicon, 1), - new Pair(Materials.Oxygen, 4) + new Pair<>(Zirconium, 1), + new Pair<>(Materials.Silicon, 1), + new Pair<>(Materials.Oxygen, 4) ); //GT Enhancements @@ -320,7 +321,7 @@ public class WerkstoffLoader implements Runnable { 20, TextureSet.SET_FLINT, Arrays.asList(Materials.RockSalt,Materials.Borax), - new Pair(Materials.Salt, 1) + new Pair<>(Materials.Salt, 1) ); public static final Werkstoff Spodumen = new Werkstoff( Materials.Spodumene.mRGBa, @@ -331,7 +332,7 @@ public class WerkstoffLoader implements Runnable { 21, TextureSet.SET_FLINT, Arrays.asList(Materials.Spodumene), - new Pair(Materials.Spodumene, 1) + new Pair<>(Materials.Spodumene, 1) ); public static final Werkstoff RockSalt = new Werkstoff( Materials.RockSalt.mRGBa, @@ -342,7 +343,7 @@ public class WerkstoffLoader implements Runnable { 22, TextureSet.SET_FLINT, Arrays.asList(Materials.RockSalt,Materials.Borax), - new Pair(Materials.RockSalt, 1) + new Pair<>(Materials.RockSalt, 1) ); public static final Werkstoff Fayalit = new Werkstoff( new short[]{50,50,50,0}, @@ -353,9 +354,9 @@ public class WerkstoffLoader implements Runnable { 23, TextureSet.SET_QUARTZ, Arrays.asList(Materials.Iron,Materials.Silicon), - new Pair(Materials.Iron, 2), - new Pair(Materials.Silicon, 1), - new Pair(Materials.Oxygen, 4) + new Pair<>(Materials.Iron, 2), + new Pair<>(Materials.Silicon, 1), + new Pair<>(Materials.Oxygen, 4) ); public static final Werkstoff Forsterit = new Werkstoff( new short[]{255,255,255,0}, @@ -366,9 +367,9 @@ public class WerkstoffLoader implements Runnable { 24, TextureSet.SET_QUARTZ, Arrays.asList(Materials.Magnesium,Materials.Silicon), - new Pair(Materials.Magnesium, 2), - new Pair(Materials.Silicon, 1), - new Pair(Materials.Oxygen, 4) + new Pair<>(Materials.Magnesium, 2), + new Pair<>(Materials.Silicon, 1), + new Pair<>(Materials.Oxygen, 4) ); public static final Werkstoff Hedenbergit = new Werkstoff( new short[]{100,150,100,0}, @@ -379,10 +380,10 @@ public class WerkstoffLoader implements Runnable { 25, TextureSet.SET_QUARTZ, Arrays.asList(Materials.Iron,Materials.Calcium,Materials.Silicon), - new Pair(Materials.Calcium, 1), - new Pair(Materials.Iron, 1), - new Pair(Materials.Silicon, 2), - new Pair(Materials.Oxygen, 6) + new Pair<>(Materials.Calcium, 1), + new Pair<>(Materials.Iron, 1), + new Pair<>(Materials.Silicon, 2), + new Pair<>(Materials.Oxygen, 6) ); public static final Werkstoff DescloiziteZNVO4 = new Werkstoff( new short[]{0xBF,0x18,0x0F,0}, @@ -393,10 +394,10 @@ public class WerkstoffLoader implements Runnable { 26, TextureSet.SET_QUARTZ, Arrays.asList(Materials.Lead,Materials.Copper,Materials.Vanadium), - new Pair(Materials.Lead, 1), - new Pair(Materials.Zinc, 1), - new Pair(Materials.Vanadium, 1), - new Pair(Materials.Oxygen, 4) + new Pair<>(Materials.Lead, 1), + new Pair<>(Materials.Zinc, 1), + new Pair<>(Materials.Vanadium, 1), + new Pair<>(Materials.Oxygen, 4) ); public static final Werkstoff DescloiziteCUVO4 = new Werkstoff( new short[]{0xf9,0x6d,0x18,0}, @@ -407,10 +408,10 @@ public class WerkstoffLoader implements Runnable { 27, TextureSet.SET_QUARTZ, Arrays.asList(Materials.Lead,Materials.Zinc,Materials.Vanadium), - new Pair(Materials.Lead, 1), - new Pair(Materials.Copper, 1), - new Pair(Materials.Vanadium, 1), - new Pair(Materials.Oxygen, 4) + new Pair<>(Materials.Lead, 1), + new Pair<>(Materials.Copper, 1), + new Pair<>(Materials.Vanadium, 1), + new Pair<>(Materials.Oxygen, 4) ); public static final Werkstoff FuchsitAL = new Werkstoff( new short[]{0x4D,0x7F,0x64,0}, @@ -422,11 +423,11 @@ public class WerkstoffLoader implements Runnable { 28, TextureSet.SET_METALLIC, Arrays.asList(Materials.Potassium,Materials.Aluminium,Materials.Silicon), - new Pair(Materials.Potassium, 1), - new Pair(Materials.Aluminium, 3), - new Pair(Materials.Silicon, 3), - new Pair(Materials.Oxygen, 12), - new Pair(Materials.Hydrogen, 2) + new Pair<>(Materials.Potassium, 1), + new Pair<>(Materials.Aluminium, 3), + new Pair<>(Materials.Silicon, 3), + new Pair<>(Materials.Oxygen, 12), + new Pair<>(Materials.Hydrogen, 2) ); public static final Werkstoff FuchsitCR = new Werkstoff( @@ -439,11 +440,11 @@ public class WerkstoffLoader implements Runnable { 29, TextureSet.SET_METALLIC, Arrays.asList(Materials.Potassium,Materials.Chrome,Materials.Silicon), - new Pair(Materials.Potassium, 1), - new Pair(Materials.Chrome, 3), - new Pair(Materials.Silicon, 3), - new Pair(Materials.Oxygen, 12), - new Pair(Materials.Hydrogen, 2) + new Pair<>(Materials.Potassium, 1), + new Pair<>(Materials.Chrome, 3), + new Pair<>(Materials.Silicon, 3), + new Pair<>(Materials.Oxygen, 12), + new Pair<>(Materials.Hydrogen, 2) ); public static final Werkstoff Thorium232 = new Werkstoff( @@ -477,6 +478,7 @@ public class WerkstoffLoader implements Runnable { public void init() { if (WerkstoffLoader.INSTANCE == null) MainMod.LOGGER.error("INSTANCE IS NULL THIS SHOULD NEVER HAPPEN!"); + GT_LanguageManager.addStringLocalization("metaitem.01.tooltip.purify.2","Throw into Cauldron to get clean crushed Ore"); } public void runInit() { @@ -589,6 +591,11 @@ public class WerkstoffLoader implements Runnable { WerkstoffLoader.items.put(dustPure, new BW_MetaGenerated_Items(dustPure)); WerkstoffLoader.items.put(dustImpure, new BW_MetaGenerated_Items(dustImpure)); } + if ((toGenerateGlobal & 0b10000) != 0) { + WerkstoffLoader.items.put(cell, new BW_MetaGenerated_Items(cell)); + WerkstoffLoader.items.put(bottle, new BW_MetaGenerated_Items(bottle)); + WerkstoffLoader.items.put(capsule, new BW_MetaGenerated_Items(capsule)); + } } public void gameRegistryHandler(){ diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_OreLayer.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_OreLayer.java new file mode 100644 index 0000000000..92f42ad9e0 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_OreLayer.java @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.oregen; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGeneratedOreTE; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Ores; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.world.GT_Worldgen; +import gregtech.common.blocks.GT_Block_Ores; +import gregtech.common.blocks.GT_TileEntity_Ores; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +/** + * Original GT File Stripped and adjusted to work with this mod + */ +public abstract class BW_OreLayer extends GT_Worldgen { + public static final List sList = new ArrayList<>(); + private static final boolean logOregenRoss128 = false; + public static int sWeight; + public byte bwOres; + public int mMinY, mWeight, mDensity, mSize, mMaxY, mPrimaryMeta, mSecondaryMeta, mBetweenMeta, mSporadicMeta; + + public abstract Block getDefaultBlockToReplace(); + + public BW_OreLayer(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, int aSize, ISubTagContainer top, ISubTagContainer bottom, ISubTagContainer between, ISubTagContainer sprinkled) { + super(aName, BW_OreLayer.sList, aDefault); + this.mMinY = (short) aMinY; + this.mMaxY = (short) aMaxY; + this.mWeight = (short) aWeight; + this.mDensity = (short) aDensity; + this.mSize = (short) Math.max(1, aSize); + + if (this.mEnabled) + BW_OreLayer.sWeight += this.mWeight; + + if (top instanceof Werkstoff) + this.bwOres = (byte) (this.bwOres | 0b1000); + if (bottom instanceof Werkstoff) + this.bwOres = (byte) (this.bwOres | 0b0100); + if (between instanceof Werkstoff) + this.bwOres = (byte) (this.bwOres | 0b0010); + if (sprinkled instanceof Werkstoff) + this.bwOres = (byte) (this.bwOres | 0b0001); + + short aPrimary = top instanceof Materials ? + (short) ((Materials) top).mMetaItemSubID : + top instanceof Werkstoff ? + ((Werkstoff) top).getmID() : + 0; + short aSecondary = bottom instanceof Materials ? + (short) ((Materials) bottom).mMetaItemSubID : + bottom instanceof Werkstoff ? + ((Werkstoff) bottom).getmID() : + 0; + short aBetween = between instanceof Materials ? + (short) ((Materials) between).mMetaItemSubID : + between instanceof Werkstoff ? + ((Werkstoff) between).getmID() : + 0; + short aSporadic = sprinkled instanceof Materials ? + (short) ((Materials) sprinkled).mMetaItemSubID : + sprinkled instanceof Werkstoff ? + ((Werkstoff) sprinkled).getmID() : + 0; + this.mPrimaryMeta = aPrimary; + this.mSecondaryMeta = aSecondary; + this.mBetweenMeta = aBetween; + this.mSporadicMeta = aSporadic; + + } + + @Override + public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { { + int tMinY = this.mMinY + aRandom.nextInt(this.mMaxY - this.mMinY - 5); + int cX = aChunkX - aRandom.nextInt(this.mSize); + int eX = aChunkX + 16 + aRandom.nextInt(this.mSize); + + for (int tX = cX; tX <= eX; ++tX) { + int cZ = aChunkZ - aRandom.nextInt(this.mSize); + int eZ = aChunkZ + 16 + aRandom.nextInt(this.mSize); + + for (int tZ = cZ; tZ <= eZ; ++tZ) { + int i; + if (this.mSecondaryMeta > 0) { + for (i = tMinY - 1; i < tMinY + 2; ++i) { + if (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0 || aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0) { + this.setOreBlock(aWorld, tX, i, tZ, this.mSecondaryMeta, false); + } + } + } + + if (this.mBetweenMeta > 0 && (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0 || aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0)) { + this.setOreBlock(aWorld, tX, tMinY + 2 + aRandom.nextInt(2), tZ, this.mBetweenMeta, false); + } + + if (this.mPrimaryMeta > 0) { + for (i = tMinY + 3; i < tMinY + 6; ++i) { + if (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0 || aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0) { + this.setOreBlock(aWorld, tX, i, tZ, this.mPrimaryMeta, false); + } + } + } + + if (this.mSporadicMeta > 0 && (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0 || aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0)) { + this.setOreBlock(aWorld, tX, tMinY - 1 + aRandom.nextInt(7), tZ, this.mSporadicMeta, false); + } + } + } + + if (BW_OreLayer.logOregenRoss128) { + MainMod.LOGGER.info("Generated Orevein: " + this.mWorldGenName + " " + aChunkX + " " + aChunkZ); + } + + return true; + } + } + + public boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean isSmallOre) { + if ((aMetaData == this.mSporadicMeta && (this.bwOres & 0b0001) != 0) || (aMetaData == this.mBetweenMeta && (this.bwOres & 0b0010) != 0) || (aMetaData == this.mPrimaryMeta && (this.bwOres & 0b1000) != 0) || (aMetaData == this.mSecondaryMeta && (this.bwOres & 0b0100) != 0)) { + return BW_MetaGenerated_Ores.setOreBlock(aWorld, aX, aY, aZ, aMetaData, false, getDefaultBlockToReplace()); + } + return setGTOreBlockSpace(aWorld, aX, aY, aZ, aMetaData, getDefaultBlockToReplace()); + } + + public boolean setGTOreBlockSpace(World aWorld, int aX, int aY, int aZ, int aMetaData, Block block){ + if (!GT_TileEntity_Ores.setOreBlock(aWorld, aX, aY, aZ, aMetaData, false, false)) { + aY = Math.min(aWorld.getActualHeight(), Math.max(aY, 1)); + Block tBlock = aWorld.getBlock(aX, aY, aZ); + Block tOreBlock = GregTech_API.sBlockOres1; + if (aMetaData < 0 || tBlock == Blocks.air) { + return false; + } else { + if (!tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, block)) { + return false; + } + aMetaData += 5000; + aWorld.setBlock(aX, aY, aZ, tOreBlock, aMetaData, 0); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof GT_TileEntity_Ores) { + ((GT_TileEntity_Ores) tTileEntity).mMetaData = (short) aMetaData; + } + return true; + } + }else + return true; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WordGenerator.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WordGenerator.java new file mode 100644 index 0000000000..907f1eeaff --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WordGenerator.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.oregen; + + +import cpw.mods.fml.common.IWorldGenerator; +import gregtech.api.objects.XSTR; +import gregtech.api.util.GT_Log; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; + +import java.util.HashSet; +import java.util.Random; + +/** + * Original GT File Stripped and adjusted to work with this mod + */ +public class BW_WordGenerator implements IWorldGenerator { + + public BW_WordGenerator() { + //GT_NH Override... wont be actually registered to force its generation directly in the ChunkProvider + //GameRegistry.registerWorldGenerator(this, 1073741823); + } + + public synchronized void generate(Random aRandom, int aX, int aZ, World aWorld, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + new BW_WordGenerator.WorldGenContainer(aX * 16, aZ * 16, aWorld.provider.dimensionId, aWorld, aChunkGenerator, aChunkProvider).run(); + } + + public static class WorldGenContainer implements Runnable { + public static HashSet mGenerated = new HashSet<>(2000); + public final int mDimensionType; + public final World mWorld; + public final IChunkProvider mChunkGenerator; + public final IChunkProvider mChunkProvider; + public int mX; + public int mZ; + + public WorldGenContainer(int aX, int aZ, int aDimensionType, World aWorld, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + this.mX = aX; + this.mZ = aZ; + this.mDimensionType = aDimensionType; + this.mWorld = aWorld; + this.mChunkGenerator = aChunkGenerator; + this.mChunkProvider = aChunkProvider; + } + + //returns a coordinate of a center chunk of 3x3 square; the argument belongs to this square + public int getVeinCenterCoordinate(int c) { + c += c < 0 ? 1 : 3; + return c - c % 3 - 2; + } + + public boolean surroundingChunksLoaded(int xCenter, int zCenter) { + return this.mWorld.checkChunksExist(xCenter - 16, 0, zCenter - 16, xCenter + 16, 0, zCenter + 16); + } + + public XSTR getRandom(int xChunk, int zChunk) { + long worldSeed = this.mWorld.getSeed(); + XSTR fmlRandom = new XSTR(worldSeed); + long xSeed = fmlRandom.nextLong() >> 2 + 1L; + long zSeed = fmlRandom.nextLong() >> 2 + 1L; + long chunkSeed = (xSeed * xChunk + zSeed * zChunk) ^ worldSeed; + fmlRandom.setSeed(chunkSeed); + return new XSTR(fmlRandom.nextInt()); + } + + public void run() { + int xCenter = this.getVeinCenterCoordinate(this.mX >> 4); + int zCenter = this.getVeinCenterCoordinate(this.mZ >> 4); + Random random = this.getRandom(xCenter, zCenter); + xCenter <<= 4; + zCenter <<= 4; + ChunkCoordIntPair centerChunk = new ChunkCoordIntPair(xCenter, zCenter); + if (!BW_WordGenerator.WorldGenContainer.mGenerated.contains(centerChunk) && this.surroundingChunksLoaded(xCenter, zCenter)) { + BW_WordGenerator.WorldGenContainer.mGenerated.add(centerChunk); + if ((BW_OreLayer.sWeight > 0) && (BW_OreLayer.sList.size() > 0)) { + boolean temp = true; + int tRandomWeight; + for (int i = 0; (i < 256) && (temp); i++) { + tRandomWeight = random.nextInt(BW_OreLayer.sWeight); + for (BW_OreLayer tWorldGen : BW_OreLayer.sList) { + tRandomWeight -= tWorldGen.mWeight; + if (tRandomWeight <= 0) { + try { + if (tWorldGen.executeWorldgen(this.mWorld, random, "", this.mDimensionType, xCenter, zCenter, this.mChunkGenerator, this.mChunkProvider)) { + temp = false; + } + break; + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); + } + } + } + } + } + } + Chunk tChunk = this.mWorld.getChunkFromBlockCoords(this.mX, this.mZ); + if (tChunk != null) { + tChunk.isModified = true; + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128b.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128b.java new file mode 100644 index 0000000000..a1535ff8f5 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128b.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.oregen; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.ISubTagContainer; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.fluids.FluidRegistry; + +import static com.github.bartimaeusnek.crossmod.galacticraft.GalacticraftProxy.uo_dimensionList; + + +public class BW_WorldGenRoss128b extends BW_OreLayer { + + public Block getDefaultBlockToReplace(){ + return Blocks.stone; + } + + public BW_WorldGenRoss128b(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, int aSize, ISubTagContainer top, ISubTagContainer bottom, ISubTagContainer between, ISubTagContainer sprinkled) { + super(aName, aDefault, aMinY, aMaxY, aWeight, aDensity, aSize, top, bottom, between, sprinkled); + } + + public static void init_OresRoss128() { + new BW_WorldGenRoss128b("ore.mix.ross128.Thorianit", true, 30, 60, 17, 1, 16, WerkstoffLoader.Thorianit, Materials.Uraninite, Materials.Lepidolite, Materials.Spodumene); + new BW_WorldGenRoss128b("ore.mix.ross128.carbon", true, 5, 25, 5, 4, 12, Materials.Graphite, Materials.Diamond, Materials.Coal, Materials.Graphite); + new BW_WorldGenRoss128b("ore.mix.ross128.bismuth", true, 5, 80, 30, 1, 16, WerkstoffLoader.Bismuthinit, Materials.Stibnite, Materials.Bismuth, WerkstoffLoader.Bismutite); + new BW_WorldGenRoss128b("ore.mix.ross128.TurmalinAlkali", true, 5, 200, 15, 4, 48, WerkstoffLoader.Olenit, WerkstoffLoader.FluorBuergerit, WerkstoffLoader.ChromoAluminoPovondrait, WerkstoffLoader.VanadioOxyDravit); + new BW_WorldGenRoss128b("ore.mix.ross128.Roquesit", true, 5, 250, 3, 1, 12, WerkstoffLoader.Arsenopyrite, WerkstoffLoader.Ferberite, WerkstoffLoader.Loellingit, WerkstoffLoader.Roquesit); + new BW_WorldGenRoss128b("ore.mix.ross128.Tungstate", true, 5, 250, 10, 4, 14, WerkstoffLoader.Ferberite, WerkstoffLoader.Huebnerit, WerkstoffLoader.Loellingit, Materials.Scheelite); + new BW_WorldGenRoss128b("ore.mix.ross128.CopperSulfits", true, 40, 70, 80, 3, 24, WerkstoffLoader.Djurleit, WerkstoffLoader.Bornite, WerkstoffLoader.Wittichenit, Materials.Tetrahedrite); + new BW_WorldGenRoss128b("ore.mix.ross128.Forsterit", true, 20, 180, 50, 2, 32, WerkstoffLoader.Forsterit, WerkstoffLoader.Fayalit, WerkstoffLoader.DescloiziteCUVO4, WerkstoffLoader.DescloiziteZNVO4); + new BW_WorldGenRoss128b("ore.mix.ross128.Hedenbergit", true, 20, 180, 50, 2, 32, WerkstoffLoader.Hedenbergit, WerkstoffLoader.Fayalit, WerkstoffLoader.DescloiziteCUVO4, WerkstoffLoader.DescloiziteZNVO4); + new BW_WorldGenRoss128b("ore.mix.ross128.RedZircon", true, 10, 40, 40, 3, 24, WerkstoffLoader.Fayalit,WerkstoffLoader.FuchsitAL , WerkstoffLoader.RedZircon,WerkstoffLoader.FuchsitCR); +