├── iceworm.ogg ├── nice render_strip32.png ├── README.md ├── Items ├── ItemLowTempDiamonds.java ├── ItemBlockRockDeco.java ├── ItemBlockGlowingVines.java ├── ItemBlockFluxCrystal.java ├── ItemBlockVent.java ├── ItemCreepvineSeeds.java ├── ItemBlockGeoOre.java ├── ItemBlockRock.java └── ItemBlockAnyGeoVariant.java ├── .gitattributes ├── EDLTDTrade.java ├── EDVoidOpalTrade.java ├── API ├── RockProofStone.java ├── ArcticSpireGenerationEvent.java ├── RockGenerationPatterns.java └── RockGetter.java ├── World ├── BiomeKelpForest.java ├── BiomeArcticSpires.java ├── RFCrystalGenerator.java ├── BasicRockGenerator.java ├── BandedGenerator.java ├── GlowingVineGenerator.java ├── LavaRockGenerator.java ├── SimplexRockGenerator.java ├── WorldGenGeoRock.java ├── RockGenerator.java ├── VentGenerator.java ├── DecoGenerator.java ├── CreepvineGenerator.java ├── VoidOpalGenerator.java └── LavaRockGeneratorRedesign.java ├── GeoTabSlab.java ├── GeoTabStairs.java ├── GeoTradeHandler.java ├── Base └── RockWrapperSortedTab.java ├── GeoTab.java ├── GeoCommon.java ├── LTDTrade.java ├── VoidOpalTrade.java ├── GeoConfig.java ├── GeoTabOres.java ├── GeoClient.java ├── Registry ├── GeoISBRH.java ├── RockGeneratorTypes.java ├── DecoBlocks.java ├── GeoOptions.java └── RockShapes.java ├── GeoTabRock.java ├── GeoChisel.java ├── Blocks ├── BlockDecoGen.java ├── BlockRockPillar.java ├── BlockRockDeco.java ├── BlockShapedRock.java ├── BlockGeoStairs.java ├── BlockGeoSlab.java ├── BlockSmooth.java └── BlockLavaRock.java ├── TileEntityGeoBlocks.java ├── License.txt ├── GeoEDTrade.java ├── CreepvineHandler.java ├── Rendering ├── StairItemRenderer.java ├── VentRenderer.java ├── CreepvineRenderer.java ├── LavaRockRenderer.java ├── GlowVineRenderer.java └── ShapedStoneRenderer.java ├── .gitignore ├── TileEntityGeoOre.java └── GeoRecipes.java /iceworm.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReikaKalseki/GeoStrata/HEAD/iceworm.ogg -------------------------------------------------------------------------------- /nice render_strip32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReikaKalseki/GeoStrata/HEAD/nice render_strip32.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | GeoStrata 2 | ====== 3 | 4 | A realistic geological world-gen mod. 5 | 6 | @author Reika 7 | 8 | Copyright 2013 9 | 10 | All rights reserved. Distribution of the software in any form is only allowed with explicit, prior permission from the owner. 11 | -------------------------------------------------------------------------------- /Items/ItemLowTempDiamonds.java: -------------------------------------------------------------------------------- 1 | package Reika.GeoStrata.Items; 2 | 3 | import net.minecraft.item.Item; 4 | 5 | import Reika.GeoStrata.GeoStrata; 6 | 7 | import cpw.mods.fml.relauncher.Side; 8 | import cpw.mods.fml.relauncher.SideOnly; 9 | 10 | 11 | public class ItemLowTempDiamonds extends Item { 12 | 13 | public ItemLowTempDiamonds() { 14 | this.setMaxStackSize(64); 15 | this.setCreativeTab(GeoStrata.tabGeo); 16 | } 17 | 18 | @Override 19 | @SideOnly(Side.CLIENT) 20 | protected String getIconString() { 21 | return "geostrata:lowtempdiamonds"; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /EDLTDTrade.java: -------------------------------------------------------------------------------- 1 | package Reika.GeoStrata; 2 | 3 | import net.minecraft.item.ItemStack; 4 | 5 | public class EDLTDTrade extends GeoEDTrade { 6 | 7 | private static final int BASELINE_PRICE = 168000; 8 | private static final int BASELINE_PEAK = 800000; 9 | 10 | public EDLTDTrade() { 11 | super(new ItemStack(GeoStrata.lowTempDiamonds), BASELINE_PRICE, BASELINE_PEAK, 9); 12 | } 13 | 14 | @Override 15 | public String getCommodityID() { 16 | return "Low-Temperature Diamonds"; 17 | } 18 | 19 | @Override 20 | public double getChancePerVillager() { 21 | return 0.25; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /EDVoidOpalTrade.java: -------------------------------------------------------------------------------- 1 | package Reika.GeoStrata; 2 | 3 | import net.minecraft.item.ItemStack; 4 | 5 | import Reika.GeoStrata.Registry.GeoBlocks; 6 | 7 | public class EDVoidOpalTrade extends GeoEDTrade { 8 | 9 | private static final int BASELINE_PRICE = 520000; //was 540k 10 | private static final int BASELINE_PEAK = 1200000; 11 | 12 | public EDVoidOpalTrade() { 13 | super(new ItemStack(GeoBlocks.VOIDOPAL.getBlockInstance(), VoidOpalTrade.STACK_SIZE), BASELINE_PRICE, BASELINE_PEAK, 3); 14 | } 15 | 16 | @Override 17 | public String getCommodityID() { 18 | return "Void Opals"; 19 | } 20 | 21 | @Override 22 | public double getChancePerVillager() { 23 | return 0.5; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /API/RockProofStone.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.API; 11 | 12 | import net.minecraft.block.Block; 13 | import net.minecraft.world.World; 14 | 15 | /** Implement this on your block to prevent GeoStrata rock from generating through it. */ 16 | public interface RockProofStone { 17 | 18 | public boolean blockRockGeneration(World world, int x, int y, int z, Block b, int meta); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /World/BiomeKelpForest.java: -------------------------------------------------------------------------------- 1 | package Reika.GeoStrata.World; 2 | 3 | import net.minecraft.world.World; 4 | import net.minecraft.world.biome.BiomeGenBase; 5 | import net.minecraft.world.biome.BiomeGenOcean; 6 | 7 | import Reika.DragonAPI.Interfaces.CustomMapColorBiome; 8 | 9 | 10 | public class BiomeKelpForest extends BiomeGenOcean implements CustomMapColorBiome { 11 | 12 | public BiomeKelpForest(int id) { 13 | super(id); 14 | biomeName = "Kelp Forest"; 15 | this.setColor(BiomeGenBase.ocean.color); 16 | this.setHeight(height_Oceans); 17 | } 18 | 19 | @Override 20 | public int getWaterColorMultiplier() { 21 | return 0x8EE595; 22 | } 23 | 24 | @Override 25 | public int getMapColor(World world, int x, int z) { 26 | return 0x6EB5C2; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /API/ArcticSpireGenerationEvent.java: -------------------------------------------------------------------------------- 1 | package Reika.GeoStrata.API; 2 | 3 | import java.util.Random; 4 | import java.util.Set; 5 | 6 | import net.minecraft.world.World; 7 | 8 | import Reika.DragonAPI.Instantiable.Data.Immutable.Coordinate; 9 | 10 | import cpw.mods.fml.common.eventhandler.Event; 11 | 12 | 13 | public class ArcticSpireGenerationEvent extends Event { 14 | 15 | public final World world; 16 | public final int centerX; 17 | public final int baseY; 18 | public final int centerZ; 19 | public final Random chunkRand; 20 | 21 | public final Set coreColumn; 22 | public final Set underhangSnow; 23 | 24 | public ArcticSpireGenerationEvent(World w, int x, int y, int z, Random r, Set cc, Set s) { 25 | world = w; 26 | centerX = x; 27 | baseY = y; 28 | centerZ = z; 29 | underhangSnow = s; 30 | coreColumn = cc; 31 | chunkRand = r; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /GeoTabSlab.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata; 11 | 12 | import net.minecraft.item.ItemStack; 13 | 14 | import Reika.GeoStrata.Base.RockWrapperSortedTab; 15 | import Reika.GeoStrata.Registry.RockShapes; 16 | import Reika.GeoStrata.Registry.RockTypes; 17 | 18 | import cpw.mods.fml.relauncher.Side; 19 | import cpw.mods.fml.relauncher.SideOnly; 20 | 21 | public class GeoTabSlab extends RockWrapperSortedTab { 22 | 23 | public GeoTabSlab(String tabID) { 24 | super(tabID); 25 | } 26 | 27 | @Override 28 | @SideOnly(Side.CLIENT) 29 | public ItemStack getIconItemStack() { 30 | return RockTypes.MARBLE.getSlab(RockShapes.ENGRAVED); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /GeoTabStairs.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata; 11 | 12 | import net.minecraft.item.ItemStack; 13 | 14 | import Reika.GeoStrata.Base.RockWrapperSortedTab; 15 | import Reika.GeoStrata.Registry.RockShapes; 16 | import Reika.GeoStrata.Registry.RockTypes; 17 | 18 | import cpw.mods.fml.relauncher.Side; 19 | import cpw.mods.fml.relauncher.SideOnly; 20 | 21 | public class GeoTabStairs extends RockWrapperSortedTab { 22 | 23 | public GeoTabStairs(String tabID) { 24 | super(tabID); 25 | } 26 | 27 | @Override 28 | @SideOnly(Side.CLIENT) 29 | public ItemStack getIconItemStack() { 30 | return RockTypes.BASALT.getStair(RockShapes.EMBOSSED); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /GeoTradeHandler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata; 11 | 12 | import java.util.Arrays; 13 | import java.util.Collection; 14 | 15 | import Reika.DragonAPI.Auxiliary.VillageTradeHandler.SimpleTradeHandler; 16 | import Reika.DragonAPI.Auxiliary.VillageTradeHandler.TradeToAdd; 17 | 18 | 19 | public class GeoTradeHandler extends SimpleTradeHandler { 20 | 21 | public static final GeoTradeHandler instance = new GeoTradeHandler(); 22 | 23 | private GeoTradeHandler() { 24 | 25 | } 26 | 27 | @Override 28 | protected Collection getTradesToAdd() { 29 | return Arrays.asList(new TradeToAdd(VoidOpalTrade.class, 0.5, "OpalTrade"), new TradeToAdd(LTDTrade.class, 0.15, "LTDTrade")); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Base/RockWrapperSortedTab.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Base; 11 | 12 | import java.util.Comparator; 13 | 14 | import net.minecraft.item.ItemStack; 15 | 16 | import Reika.DragonAPI.Instantiable.GUI.SortedCreativeTab; 17 | 18 | public abstract class RockWrapperSortedTab extends SortedCreativeTab { 19 | 20 | public RockWrapperSortedTab(String name) { 21 | super(name); 22 | } 23 | 24 | @Override 25 | protected final Comparator getComparator() { 26 | return sorter; 27 | } 28 | 29 | private static final RockWrapperSorter sorter = new RockWrapperSorter(); 30 | 31 | private static class RockWrapperSorter implements Comparator { 32 | 33 | @Override 34 | public int compare(ItemStack o1, ItemStack o2) { 35 | return o1.getItemDamage()-o2.getItemDamage(); 36 | } 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /GeoTab.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata; 11 | 12 | import java.util.Comparator; 13 | 14 | import net.minecraft.item.ItemStack; 15 | 16 | import Reika.DragonAPI.Instantiable.GUI.SortedCreativeTab; 17 | import Reika.GeoStrata.Blocks.BlockVent.VentType; 18 | import Reika.GeoStrata.Registry.GeoBlocks; 19 | 20 | import cpw.mods.fml.relauncher.Side; 21 | import cpw.mods.fml.relauncher.SideOnly; 22 | 23 | public class GeoTab extends SortedCreativeTab { 24 | 25 | public GeoTab(String tabID) { 26 | super(tabID); 27 | } 28 | 29 | @Override 30 | @SideOnly(Side.CLIENT) 31 | public ItemStack getIconItemStack() { 32 | return GeoBlocks.VENT.getStackOfMetadata(VentType.LAVA.ordinal());//GeoBlocks.GLOWCRYS.getStackOfMetadata(0); 33 | } 34 | 35 | @Override 36 | protected Comparator getComparator() { 37 | return null; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /GeoCommon.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata; 11 | 12 | import net.minecraft.world.World; 13 | 14 | import Reika.DragonAPI.Instantiable.IO.SingleSound; 15 | import Reika.DragonAPI.Instantiable.IO.SoundLoader; 16 | 17 | public class GeoCommon { 18 | 19 | public static final SingleSound iceWormTheme = new SingleSound("iceworm", "Reika/GeoStrata/iceworm.ogg"); 20 | 21 | protected static final SoundLoader sounds = new SoundLoader(iceWormTheme); 22 | 23 | /** 24 | * Client side only register stuff... 25 | */ 26 | public void registerRenderers() 27 | { 28 | //unused server side. -- see ClientProxy for implementation 29 | } 30 | 31 | public void addArmorRenders() {} 32 | 33 | public World getClientWorld() { 34 | return null; 35 | } 36 | 37 | public void registerRenderInformation() { 38 | 39 | } 40 | 41 | public void registerSounds() { 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /LTDTrade.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata; 11 | 12 | import net.minecraft.entity.player.EntityPlayer; 13 | import net.minecraft.init.Items; 14 | import net.minecraft.item.ItemStack; 15 | import net.minecraft.village.MerchantRecipe; 16 | 17 | import Reika.DragonAPI.Interfaces.PlayerSpecificTrade; 18 | 19 | 20 | public class LTDTrade extends MerchantRecipe implements PlayerSpecificTrade { 21 | 22 | public LTDTrade() { 23 | super(new ItemStack(GeoStrata.lowTempDiamonds), new ItemStack(Items.emerald, 12, 0)); 24 | } 25 | 26 | @Override 27 | public void incrementToolUses() { 28 | //No-op to prevent expiry 29 | } 30 | 31 | @Override 32 | public boolean isValid(EntityPlayer ep) { 33 | return true; 34 | } 35 | 36 | @Override 37 | public boolean hasSameIDsAs(MerchantRecipe mr) { 38 | return mr instanceof LTDTrade; 39 | } 40 | 41 | @Override 42 | public boolean hasSameItemsAs(MerchantRecipe mr) { 43 | return mr instanceof LTDTrade; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /API/RockGenerationPatterns.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.API; 11 | 12 | import java.util.Random; 13 | 14 | import net.minecraft.world.World; 15 | 16 | import Reika.GeoStrata.Registry.RockTypes; 17 | import Reika.GeoStrata.World.RockGenerator; 18 | 19 | /** Use this to create custom rock generation "patterns". Note that multiple may be run sequentially. */ 20 | public class RockGenerationPatterns { 21 | 22 | public static void registerPattern(RockGenerationPattern p) { 23 | RockGenerator.instance.registerGenerationPattern(p); 24 | } 25 | 26 | public static interface RockGenerationPattern { 27 | 28 | /** Called once per chunk per rock type to generate the rock. X and Z are the block coordinates of the Northwest (negative XZ) corner. */ 29 | public void generateRockType(RockTypes geo, World world, Random random, int chunkX, int chunkZ); 30 | 31 | /** Used in standard comparator logic. Higher numbers run later. */ 32 | public int getOrderingIndex(); 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /VoidOpalTrade.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata; 11 | 12 | import net.minecraft.entity.player.EntityPlayer; 13 | import net.minecraft.init.Items; 14 | import net.minecraft.item.ItemStack; 15 | import net.minecraft.village.MerchantRecipe; 16 | 17 | import Reika.DragonAPI.Interfaces.PlayerSpecificTrade; 18 | import Reika.GeoStrata.Registry.GeoBlocks; 19 | 20 | 21 | public class VoidOpalTrade extends MerchantRecipe implements PlayerSpecificTrade { 22 | 23 | public static final int STACK_SIZE = 24; //was 16 24 | 25 | public VoidOpalTrade() { 26 | super(new ItemStack(GeoBlocks.VOIDOPAL.getBlockInstance(), STACK_SIZE), new ItemStack(Items.emerald, 3, 0)); 27 | } 28 | 29 | @Override 30 | public void incrementToolUses() { 31 | //No-op to prevent expiry 32 | } 33 | 34 | @Override 35 | public boolean isValid(EntityPlayer ep) { 36 | return true; 37 | } 38 | 39 | @Override 40 | public boolean hasSameIDsAs(MerchantRecipe mr) { 41 | return mr instanceof VoidOpalTrade; 42 | } 43 | 44 | @Override 45 | public boolean hasSameItemsAs(MerchantRecipe mr) { 46 | return mr instanceof VoidOpalTrade; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /GeoConfig.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata; 11 | 12 | import java.util.ArrayList; 13 | 14 | import Reika.DragonAPI.Base.DragonAPIMod; 15 | import Reika.DragonAPI.Instantiable.IO.ControlledConfig; 16 | import Reika.DragonAPI.Interfaces.Configuration.ConfigList; 17 | import Reika.DragonAPI.Interfaces.Registry.IDRegistry; 18 | import Reika.DragonAPI.Libraries.Java.ReikaJavaLibrary; 19 | import Reika.GeoStrata.Registry.RockTypes; 20 | 21 | 22 | public class GeoConfig extends ControlledConfig { 23 | 24 | private static final ArrayList entries = ReikaJavaLibrary.getEnumEntriesWithoutInitializing(RockTypes.class); 25 | private final DataElement[] rockBands = new DataElement[entries.size()]; 26 | 27 | public GeoConfig(DragonAPIMod mod, ConfigList[] option, IDRegistry[] id) { 28 | super(mod, option, id); 29 | 30 | for (int i = 0; i < entries.size(); i++) { 31 | String name = entries.get(i); 32 | rockBands[i] = this.registerAdditionalOption("Rock Band Heights", name, 0); 33 | } 34 | } 35 | 36 | public int getRockBand(RockTypes r) { 37 | int y = rockBands[r.ordinal()].getData(); 38 | if (y == 0) { 39 | y = (int)(r.minY*0.25+r.maxY*0.75); 40 | } 41 | return y; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /World/BiomeArcticSpires.java: -------------------------------------------------------------------------------- 1 | package Reika.GeoStrata.World; 2 | 3 | import net.minecraft.world.World; 4 | import net.minecraft.world.biome.BiomeGenBase; 5 | import net.minecraft.world.biome.BiomeGenSnow; 6 | 7 | import Reika.DragonAPI.Interfaces.CustomMapColorBiome; 8 | import Reika.DragonAPI.Interfaces.CustomTemperatureBiome; 9 | import Reika.DragonAPI.Libraries.MathSci.ReikaMathLibrary; 10 | 11 | 12 | public class BiomeArcticSpires extends BiomeGenSnow implements CustomMapColorBiome, CustomTemperatureBiome { 13 | 14 | public BiomeArcticSpires(int id) { 15 | super(id, false); 16 | biomeName = "Arctic Spires"; 17 | this.setColor(BiomeGenBase.icePlains.color); 18 | this.setTemperatureRainfall(0.0F, 0.5F); 19 | this.setHeight(height_LowPlains); 20 | this.setEnableSnow(); 21 | } 22 | 23 | @Override 24 | public int getMapColor(World world, int x, int z) { 25 | return 0xB2FFF7; 26 | } 27 | 28 | @Override 29 | public int getBaseAmbientTemperature() { 30 | return -25; //vs -20 31 | } 32 | 33 | @Override 34 | public float getSeasonStrength() { 35 | return 2; 36 | } 37 | 38 | @Override 39 | public int getSurfaceTemperatureModifier(World world, int x, int y, int z, float temp, float sun) { 40 | int ret = (int)(-25+sun*20); //-25 at night, -5 in day -> -50C at night, -30 in day 41 | if (world.isRaining()) 42 | ret -= 10; 43 | return ret; 44 | } 45 | 46 | @Override 47 | public int getAltitudeTemperatureModifier(World world, int x, int y, int z, float temp, int dy) { 48 | return (int)ReikaMathLibrary.linterpolate(dy, 30, 90, 0, -30, true); 49 | } 50 | 51 | @Override 52 | public float getNoiseVariationStrength(World world, int x, int y, int z, float orig) { 53 | return orig*0.5F; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /GeoTabOres.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata; 11 | 12 | import java.util.Comparator; 13 | 14 | import net.minecraft.item.ItemStack; 15 | 16 | import Reika.DragonAPI.Instantiable.GUI.SortedCreativeTab; 17 | import Reika.DragonAPI.Libraries.Registry.ReikaOreHelper; 18 | import Reika.DragonAPI.ModRegistry.ModOreList; 19 | import Reika.GeoStrata.Blocks.BlockOreTile; 20 | import Reika.GeoStrata.Registry.RockTypes; 21 | 22 | import cpw.mods.fml.relauncher.Side; 23 | import cpw.mods.fml.relauncher.SideOnly; 24 | 25 | public class GeoTabOres extends SortedCreativeTab { 26 | 27 | public GeoTabOres(String tabID) { 28 | super(tabID); 29 | } 30 | 31 | @Override 32 | @SideOnly(Side.CLIENT) 33 | public ItemStack getIconItemStack() { 34 | int list = ReikaOreHelper.oreList.length+ModOreList.oreList.length; 35 | int meta = BlockOreTile.getMetadataByTypes(RockTypes.BASALT, ReikaOreHelper.REDSTONE); 36 | return null;//new ItemStack(GeoBlocks.ORETILE.getBlockInstance(), 1, meta); 37 | } 38 | 39 | @Override 40 | protected Comparator getComparator() { 41 | return sorter; 42 | } 43 | 44 | private static final RockOreSorter sorter = new RockOreSorter(); 45 | 46 | private static class RockOreSorter implements Comparator { 47 | 48 | @Override 49 | public int compare(ItemStack o1, ItemStack o2) { 50 | return o1.getItemDamage()-o2.getItemDamage(); 51 | } 52 | 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /GeoClient.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata; 11 | 12 | import net.minecraft.client.audio.SoundCategory; 13 | import net.minecraft.item.Item; 14 | import net.minecraft.world.World; 15 | import net.minecraftforge.client.MinecraftForgeClient; 16 | 17 | import Reika.DragonAPI.Libraries.ReikaRegistryHelper; 18 | import Reika.GeoStrata.Registry.GeoBlocks; 19 | import Reika.GeoStrata.Registry.GeoISBRH; 20 | import Reika.GeoStrata.Rendering.StairItemRenderer; 21 | 22 | import cpw.mods.fml.client.FMLClientHandler; 23 | 24 | public class GeoClient extends GeoCommon { 25 | 26 | private static final StairItemRenderer stair = new StairItemRenderer(); 27 | 28 | @Override 29 | public void registerSounds() { 30 | iceWormTheme.setSoundCategory(SoundCategory.MASTER); 31 | sounds.register(); 32 | } 33 | 34 | @Override 35 | public void registerRenderers() { 36 | ReikaRegistryHelper.instantiateAndRegisterISBRHs(GeoStrata.instance, GeoISBRH.values()); 37 | 38 | MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(GeoBlocks.SLAB.getBlockInstance()), stair); 39 | MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(GeoBlocks.STAIR.getBlockInstance()), stair); 40 | } 41 | 42 | // Override any other methods that need to be handled differently client side. 43 | 44 | @Override 45 | public World getClientWorld() 46 | { 47 | return FMLClientHandler.instance().getClient().theWorld; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Items/ItemBlockRockDeco.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Items; 11 | 12 | import java.util.List; 13 | 14 | import net.minecraft.block.Block; 15 | import net.minecraft.creativetab.CreativeTabs; 16 | import net.minecraft.item.Item; 17 | import net.minecraft.item.ItemBlock; 18 | import net.minecraft.item.ItemStack; 19 | 20 | import Reika.GeoStrata.Registry.DecoBlocks; 21 | 22 | import cpw.mods.fml.relauncher.Side; 23 | import cpw.mods.fml.relauncher.SideOnly; 24 | 25 | public class ItemBlockRockDeco extends ItemBlock { 26 | 27 | public ItemBlockRockDeco(Block b) { 28 | super(b); 29 | hasSubtypes = true; 30 | this.setMaxDamage(0); 31 | } 32 | 33 | @Override 34 | @SideOnly(Side.CLIENT) 35 | public final void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) //Adds the metadata blocks to the creative inventory 36 | { 37 | for (int i = 0; i < DecoBlocks.list.length; i++) { 38 | ItemStack item = new ItemStack(par1, 1, i); 39 | par3List.add(item); 40 | } 41 | } 42 | 43 | @Override 44 | public final String getUnlocalizedName(ItemStack is) { 45 | int d = is.getItemDamage(); 46 | return super.getUnlocalizedName() + "." + d; 47 | } 48 | 49 | @Override 50 | public int getMetadata(int meta) { 51 | return meta; 52 | } 53 | 54 | @Override 55 | public String getItemStackDisplayName(ItemStack is) { 56 | return DecoBlocks.list[is.getItemDamage()].getName(); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /Items/ItemBlockGlowingVines.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Items; 11 | 12 | import net.minecraft.block.Block; 13 | import net.minecraft.entity.player.EntityPlayer; 14 | import net.minecraft.item.ItemBlock; 15 | import net.minecraft.item.ItemStack; 16 | import net.minecraft.world.World; 17 | import net.minecraftforge.common.util.ForgeDirection; 18 | 19 | import Reika.GeoStrata.Blocks.BlockGlowingVines.TileGlowingVines; 20 | import Reika.GeoStrata.Registry.GeoBlocks; 21 | 22 | 23 | public class ItemBlockGlowingVines extends ItemBlock { 24 | 25 | public ItemBlockGlowingVines(Block b) { 26 | super(b); 27 | } 28 | 29 | @Override 30 | public String getItemStackDisplayName(ItemStack is) { 31 | return GeoBlocks.GLOWVINE.hasMultiValuedName() ? GeoBlocks.GLOWVINE.getMultiValuedName(is.getItemDamage()) : GeoBlocks.GLOWVINE.getBasicName(); 32 | } 33 | 34 | @Override 35 | public boolean placeBlockAt(ItemStack is, EntityPlayer ep, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta) { 36 | Block b = world.getBlock(x, y, z); 37 | if (b == field_150939_a) { 38 | return ((TileGlowingVines)world.getTileEntity(x, y, z)).addVine(ForgeDirection.VALID_DIRECTIONS[side].getOpposite()); 39 | } 40 | else { 41 | if (super.placeBlockAt(is, ep, world, x, y, z, side, hitX, hitY, hitZ, meta)) { 42 | ((TileGlowingVines)world.getTileEntity(x, y, z)).addVine(ForgeDirection.VALID_DIRECTIONS[side].getOpposite()); 43 | return true; 44 | } 45 | return false; 46 | } 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /Items/ItemBlockFluxCrystal.java: -------------------------------------------------------------------------------- 1 | package Reika.GeoStrata.Items; 2 | 3 | import java.util.List; 4 | 5 | import net.minecraft.block.Block; 6 | import net.minecraft.entity.player.EntityPlayer; 7 | import net.minecraft.item.ItemBlock; 8 | import net.minecraft.item.ItemStack; 9 | import net.minecraft.tileentity.TileEntity; 10 | import net.minecraft.world.World; 11 | 12 | import Reika.GeoStrata.Blocks.BlockRFCrystalSeed.TileRFCrystal; 13 | import Reika.GeoStrata.Registry.GeoBlocks; 14 | import Reika.GeoStrata.Registry.GeoOptions; 15 | 16 | 17 | public class ItemBlockFluxCrystal extends ItemBlock { 18 | 19 | public ItemBlockFluxCrystal(Block b) { 20 | super(b); 21 | } 22 | 23 | @Override 24 | 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) { 25 | boolean ret = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); 26 | if (ret) { 27 | TileEntity te = world.getTileEntity(x, y, z); 28 | if (te instanceof TileRFCrystal) { 29 | if (!GeoOptions.RFACTIVATE.getState() || (stack.stackTagCompound != null && stack.stackTagCompound.getBoolean("activated"))) 30 | ((TileRFCrystal)te).activate(); 31 | } 32 | } 33 | return ret; 34 | } 35 | 36 | @Override 37 | public String getItemStackDisplayName(ItemStack is) { 38 | return GeoBlocks.RFCRYSTALSEED.hasMultiValuedName() ? GeoBlocks.RFCRYSTALSEED.getMultiValuedName(is.getItemDamage()) : GeoBlocks.RFCRYSTALSEED.getBasicName(); 39 | } 40 | 41 | @Override 42 | public void addInformation(ItemStack is, EntityPlayer ep, List li, boolean vb) { 43 | if (GeoOptions.RFACTIVATE.getState()) { 44 | if (is.stackTagCompound != null && is.stackTagCompound.getBoolean("activated")) { 45 | li.add("Activated"); 46 | } 47 | else { 48 | li.add("Needs activation"); 49 | } 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /Items/ItemBlockVent.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Items; 11 | 12 | import java.util.List; 13 | 14 | import net.minecraft.block.Block; 15 | import net.minecraft.creativetab.CreativeTabs; 16 | import net.minecraft.item.Item; 17 | import net.minecraft.item.ItemBlock; 18 | import net.minecraft.item.ItemStack; 19 | 20 | import Reika.DragonAPI.Libraries.Java.ReikaStringParser; 21 | import Reika.GeoStrata.Blocks.BlockVent.VentType; 22 | 23 | import cpw.mods.fml.relauncher.Side; 24 | import cpw.mods.fml.relauncher.SideOnly; 25 | 26 | public class ItemBlockVent extends ItemBlock { 27 | 28 | public ItemBlockVent(Block b) { 29 | super(b); 30 | hasSubtypes = true; 31 | this.setMaxDamage(0); 32 | } 33 | 34 | @Override 35 | @SideOnly(Side.CLIENT) 36 | public final void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) //Adds the metadata blocks to the creative inventory 37 | { 38 | for (int i = 0; i < VentType.list.length; i++) { 39 | ItemStack item = new ItemStack(par1, 1, i); 40 | par3List.add(item); 41 | } 42 | } 43 | 44 | @Override 45 | public final String getUnlocalizedName(ItemStack is) { 46 | int d = is.getItemDamage(); 47 | return super.getUnlocalizedName() + "." + d; 48 | } 49 | 50 | @Override 51 | public final String getItemStackDisplayName(ItemStack is) { 52 | String n = VentType.list[is.getItemDamage()].name(); 53 | return ReikaStringParser.capFirstChar(n)+" Vent"; 54 | } 55 | 56 | @Override 57 | public int getMetadata(int meta) { 58 | return meta; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /Registry/GeoISBRH.java: -------------------------------------------------------------------------------- 1 | package Reika.GeoStrata.Registry; 2 | 3 | import Reika.DragonAPI.Base.ISBRH; 4 | import Reika.DragonAPI.Interfaces.Registry.ISBRHEnum; 5 | import Reika.GeoStrata.Rendering.ConnectedStoneRenderer; 6 | import Reika.GeoStrata.Rendering.CreepvineRenderer; 7 | import Reika.GeoStrata.Rendering.DecoGenRenderer; 8 | import Reika.GeoStrata.Rendering.GlowVineRenderer; 9 | import Reika.GeoStrata.Rendering.LavaRockRenderer; 10 | import Reika.GeoStrata.Rendering.OreRenderer; 11 | import Reika.GeoStrata.Rendering.OreVeinRenderer; 12 | import Reika.GeoStrata.Rendering.VentRenderer; 13 | import Reika.GeoStrata.Rendering.VoidOpalRenderer; 14 | 15 | public enum GeoISBRH implements ISBRHEnum { 16 | 17 | connected(ConnectedStoneRenderer.class), 18 | vent(VentRenderer.class), 19 | ore(OreRenderer.class), 20 | lavarock(LavaRockRenderer.class), 21 | deco(DecoGenRenderer.class), 22 | vine(GlowVineRenderer.class), 23 | //shaped(), 24 | voidopal(VoidOpalRenderer.class), 25 | creepvine(CreepvineRenderer.class), 26 | orevein(OreVeinRenderer.class), 27 | ; 28 | 29 | private final Class renderClass; 30 | 31 | private int renderID; 32 | private ISBRH renderer; 33 | 34 | private static final GeoISBRH[] list = values(); 35 | 36 | private GeoISBRH(Class render) { 37 | renderClass = render; 38 | } 39 | 40 | @Override 41 | public int getRenderID() { 42 | return renderID; 43 | } 44 | 45 | @Override 46 | public ISBRH getRenderer() { 47 | return renderer; 48 | } 49 | 50 | @Override 51 | public void setRenderPass(int pass) { 52 | renderer.setRenderPass(pass); 53 | } 54 | 55 | @Override 56 | public Class getRenderClass() { 57 | return renderClass; 58 | } 59 | 60 | @Override 61 | public void setRenderID(int id) { 62 | renderID = id; 63 | } 64 | 65 | @Override 66 | public void setRenderer(ISBRH r) { 67 | renderer = r; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /Items/ItemCreepvineSeeds.java: -------------------------------------------------------------------------------- 1 | package Reika.GeoStrata.Items; 2 | 3 | import java.util.List; 4 | 5 | import net.minecraft.entity.player.EntityPlayer; 6 | import net.minecraft.item.Item; 7 | import net.minecraft.item.ItemStack; 8 | import net.minecraft.world.World; 9 | import net.minecraftforge.common.util.ForgeDirection; 10 | 11 | import Reika.DragonAPI.Libraries.IO.ReikaSoundHelper; 12 | import Reika.GeoStrata.GeoStrata; 13 | import Reika.GeoStrata.Blocks.BlockCreepvine; 14 | import Reika.GeoStrata.Registry.GeoBlocks; 15 | import Reika.GeoStrata.World.CreepvineGenerator; 16 | 17 | import cpw.mods.fml.relauncher.Side; 18 | import cpw.mods.fml.relauncher.SideOnly; 19 | 20 | 21 | public class ItemCreepvineSeeds extends Item { 22 | 23 | public ItemCreepvineSeeds() { 24 | this.setMaxStackSize(16); 25 | this.setCreativeTab(GeoStrata.tabGeo); 26 | } 27 | 28 | @Override 29 | @SideOnly(Side.CLIENT) 30 | protected String getIconString() { 31 | return "geostrata:creepvineseed"; 32 | } 33 | 34 | @Override 35 | public void addInformation(ItemStack is, EntityPlayer ep, List li, boolean vb) { 36 | li.add("Can be planted in sufficiently deep and open water."); 37 | } 38 | 39 | @Override 40 | public boolean onItemUse(ItemStack is, EntityPlayer ep, World world, int x, int y, int z, int s, float a, float b, float c) { 41 | ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[s]; 42 | x += dir.offsetX; 43 | y += dir.offsetY; 44 | z += dir.offsetZ; 45 | if (!world.isRemote && BlockCreepvine.canGrowOn(world, x, y-1, z) && BlockCreepvine.hasSurroundingWater(world, x, y, z, true)) { 46 | boolean flag = false; 47 | int tries = 0; 48 | while (!flag && tries < 25) { 49 | flag = CreepvineGenerator.instance.generate(world, x, y, z, itemRand, 8, 9, 0.8F, false); 50 | tries++; 51 | } 52 | if (flag) { 53 | ReikaSoundHelper.playPlaceSound(world, x, y, z, GeoBlocks.CREEPVINE.getBlockInstance()); 54 | is.stackSize--; 55 | return true; 56 | } 57 | } 58 | return false; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /GeoTabRock.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata; 11 | 12 | import java.util.Comparator; 13 | 14 | import net.minecraft.block.Block; 15 | import net.minecraft.item.ItemStack; 16 | 17 | import Reika.DragonAPI.Instantiable.GUI.SortedCreativeTab; 18 | import Reika.DragonAPI.Libraries.ReikaRegistryHelper; 19 | import Reika.GeoStrata.Base.RockBlock; 20 | import Reika.GeoStrata.Registry.RockShapes; 21 | import Reika.GeoStrata.Registry.RockTypes; 22 | 23 | import cpw.mods.fml.relauncher.Side; 24 | import cpw.mods.fml.relauncher.SideOnly; 25 | 26 | public class GeoTabRock extends SortedCreativeTab { 27 | 28 | public GeoTabRock(String tabID) { 29 | super(tabID); 30 | } 31 | 32 | @Override 33 | @SideOnly(Side.CLIENT) 34 | public ItemStack getIconItemStack() { 35 | return RockTypes.GRANITE.getItem(RockShapes.SMOOTH); 36 | } 37 | 38 | @Override 39 | protected Comparator getComparator() { 40 | return sorter; 41 | } 42 | 43 | private static final RockSorter sorter = new RockSorter(); 44 | 45 | private static class RockSorter implements Comparator { 46 | 47 | @Override 48 | public int compare(ItemStack o1, ItemStack o2) { 49 | return this.getIndex(o1)-this.getIndex(o2); 50 | } 51 | 52 | private int getIndex(ItemStack o1) { 53 | Block b = Block.getBlockFromItem(o1.getItem()); 54 | if (!(b instanceof RockBlock)) { 55 | return -1000000+1000*ReikaRegistryHelper.getRegistryForObject(b).ordinal()+o1.getItemDamage(); 56 | } 57 | RockTypes r = RockTypes.getTypeFromID(b); 58 | RockShapes s = RockShapes.getShape(b, o1.getItemDamage()); 59 | return r.ordinal()*1000+s.ordinal(); 60 | } 61 | 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /Items/ItemBlockGeoOre.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Items; 11 | 12 | import net.minecraft.block.Block; 13 | import net.minecraft.entity.player.EntityPlayer; 14 | import net.minecraft.item.ItemBlock; 15 | import net.minecraft.item.ItemStack; 16 | import net.minecraft.world.World; 17 | 18 | import Reika.GeoStrata.TileEntityGeoOre; 19 | import Reika.GeoStrata.Blocks.BlockOreTile; 20 | import Reika.GeoStrata.Registry.RockTypes; 21 | 22 | public class ItemBlockGeoOre extends ItemBlock { 23 | 24 | public ItemBlockGeoOre(Block b) { 25 | super(b); 26 | hasSubtypes = true; 27 | } 28 | 29 | @Override 30 | 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) 31 | { 32 | boolean flag = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); 33 | if (flag) { 34 | TileEntityGeoOre te = (TileEntityGeoOre)world.getTileEntity(x, y, z); 35 | ItemStack is = BlockOreTile.getOreByItemBlock(stack); 36 | Block b = Block.getBlockFromItem(is.getItem()); 37 | RockTypes rock = BlockOreTile.getRockFromItem(stack.getItemDamage()); 38 | te.initialize(rock, b, is.getItemDamage()); 39 | } 40 | return flag; 41 | } 42 | 43 | @Override 44 | public int getMetadata(int meta) { 45 | return 0; 46 | } 47 | 48 | @Override 49 | public String getItemStackDisplayName(ItemStack is) { 50 | ItemStack is2 = BlockOreTile.getOreByItemBlock(is); 51 | Block b = Block.getBlockFromItem(is2.getItem()); 52 | int meta = is2.getItemDamage(); 53 | return is2.getDisplayName()+" "+BlockOreTile.getRockFromItem(is.getItemDamage()).getName(); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Registry/RockGeneratorTypes.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2018 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Registry; 11 | 12 | import java.util.Arrays; 13 | import java.util.Locale; 14 | 15 | import Reika.DragonAPI.Exception.InstallationException; 16 | import Reika.DragonAPI.Exception.RegistrationException; 17 | import Reika.GeoStrata.GeoStrata; 18 | import Reika.GeoStrata.API.RockGenerationPatterns.RockGenerationPattern; 19 | import Reika.GeoStrata.World.BandedGenerator; 20 | import Reika.GeoStrata.World.BasicRockGenerator; 21 | import Reika.GeoStrata.World.SimplexRockGenerator; 22 | 23 | 24 | public enum RockGeneratorTypes { 25 | 26 | LEGACY(BasicRockGenerator.class), 27 | BANDED(BandedGenerator.class), 28 | SIMPLEX(SimplexRockGenerator.class); 29 | 30 | private final Class type; 31 | 32 | private RockGeneratorTypes(Class c) { 33 | type = c; 34 | } 35 | 36 | public static RockGeneratorTypes getType(String config) { 37 | try { 38 | return RockGeneratorTypes.valueOf(config.toUpperCase(Locale.ENGLISH)); 39 | } 40 | catch (IllegalArgumentException e) { 41 | throw new InstallationException(GeoStrata.instance, "Invalid selected rock generation pattern '"+config+"'; choose one of the following: "+Arrays.toString(values())); 42 | } 43 | } 44 | 45 | public RockGenerationPattern getGenerator() { 46 | try { 47 | return type.newInstance(); 48 | } 49 | catch (InstantiationException e) { 50 | throw new RegistrationException(GeoStrata.instance, "Could not create rock generator for type "+this+"!", e); 51 | } 52 | catch (IllegalAccessException e) { 53 | throw new RegistrationException(GeoStrata.instance, "Could not access constructor for rock generator for type "+this+"!", e); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /GeoChisel.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata; 11 | 12 | import com.cricketcraft.chisel.api.carving.CarvableHelper; 13 | import com.cricketcraft.chisel.api.carving.CarvingUtils; 14 | import com.cricketcraft.chisel.api.carving.CarvingUtils.SimpleCarvingGroup; 15 | import com.cricketcraft.chisel.api.carving.CarvingUtils.SimpleCarvingVariation; 16 | import com.cricketcraft.chisel.api.carving.ICarvingGroup; 17 | import com.cricketcraft.chisel.api.carving.ICarvingRegistry; 18 | import com.cricketcraft.chisel.api.carving.ICarvingVariation; 19 | 20 | import net.minecraft.block.Block; 21 | 22 | import Reika.GeoStrata.Registry.RockShapes; 23 | import Reika.GeoStrata.Registry.RockTypes; 24 | 25 | 26 | public class GeoChisel { 27 | 28 | public static void loadChiselCompat() { 29 | ICarvingRegistry chisel = CarvingUtils.getChiselRegistry(); 30 | if (chisel == null) { 31 | GeoStrata.logger.logError("Could not load Chisel Integration: Chisel's API registries are null!"); 32 | } 33 | else { 34 | for (int i = 0; i < RockTypes.rockList.length; i++) { 35 | RockTypes rock = RockTypes.rockList[i]; 36 | CarvableHelper cv = new CarvableHelper(rock.getID(RockShapes.SMOOTH)); 37 | ICarvingGroup grp = new SimpleCarvingGroup("GeoStrata_"+rock.getName()); 38 | grp.setOreName("Geo_"+rock.getName()); 39 | grp.setSound(Block.soundTypeStone.soundName); 40 | chisel.addGroup(grp); 41 | for (int k = 0; k < RockShapes.shapeList.length; k++) { 42 | RockShapes s = RockShapes.shapeList[k]; 43 | Block bk = rock.getID(s); 44 | int meta = rock.getItem(s).getItemDamage(); 45 | ICarvingVariation icv = new SimpleCarvingVariation(bk, meta, k); 46 | grp.addVariation(icv); 47 | cv.addVariation(s.name, meta, bk, meta); 48 | } 49 | } 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /Blocks/BlockDecoGen.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Blocks; 11 | 12 | import net.minecraft.block.Block; 13 | import net.minecraft.block.material.Material; 14 | import net.minecraft.client.renderer.texture.IIconRegister; 15 | import net.minecraft.util.IIcon; 16 | import net.minecraft.world.IBlockAccess; 17 | 18 | import Reika.DragonAPI.Interfaces.Block.Submergeable; 19 | import Reika.GeoStrata.GeoStrata; 20 | import Reika.GeoStrata.Registry.GeoISBRH; 21 | 22 | 23 | public class BlockDecoGen extends Block implements Submergeable { 24 | 25 | private final IIcon[] icons = new IIcon[Types.list.length]; 26 | 27 | public BlockDecoGen(Material mat) { 28 | super(mat); 29 | 30 | this.setHardness(2); 31 | this.setResistance(20); 32 | this.setCreativeTab(GeoStrata.tabGeo); 33 | } 34 | 35 | public static enum Types { 36 | CRYSTALSPIKE("Crystal Spike"), 37 | ICICLE("Icicle"); 38 | 39 | public final String name; 40 | 41 | public static final Types[] list = values(); 42 | 43 | private Types(String s) { 44 | name = s; 45 | } 46 | } 47 | 48 | @Override 49 | public IIcon getIcon(int s, int meta) { 50 | return icons[meta]; 51 | } 52 | 53 | @Override 54 | public void registerBlockIcons(IIconRegister ico) { 55 | for (int i = 0; i < Types.list.length; i++) { 56 | icons[i] = ico.registerIcon("geostrata:deco/"+i); 57 | } 58 | } 59 | 60 | @Override 61 | public boolean renderAsNormalBlock() { 62 | return false; 63 | } 64 | 65 | @Override 66 | public boolean isOpaqueCube() { 67 | return false; 68 | } 69 | 70 | @Override 71 | public int getRenderType() { 72 | return GeoISBRH.deco.getRenderID(); 73 | } 74 | 75 | @Override 76 | public boolean isSubmergeable(IBlockAccess iba, int x, int y, int z) { 77 | return iba.getBlockMetadata(x, y, z) == 0; 78 | } 79 | 80 | @Override 81 | public boolean renderLiquid(int meta) { 82 | return meta == 0; 83 | } 84 | 85 | @Override 86 | public int getRenderBlockPass() { 87 | return 1; 88 | } 89 | 90 | @Override 91 | public boolean canRenderInPass(int pass) { 92 | GeoISBRH.deco.setRenderPass(pass); 93 | return pass <= 1; 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /World/RFCrystalGenerator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.World; 11 | 12 | import java.util.Random; 13 | 14 | import net.minecraft.block.material.Material; 15 | import net.minecraft.init.Blocks; 16 | import net.minecraft.world.World; 17 | import net.minecraft.world.WorldType; 18 | import net.minecraft.world.chunk.IChunkProvider; 19 | 20 | import Reika.DragonAPI.Interfaces.RetroactiveGenerator; 21 | import Reika.DragonAPI.Libraries.World.ReikaWorldHelper; 22 | import Reika.GeoStrata.Registry.GeoBlocks; 23 | import Reika.GeoStrata.Registry.GeoOptions; 24 | 25 | public class RFCrystalGenerator implements RetroactiveGenerator { 26 | 27 | public static final RFCrystalGenerator instance = new RFCrystalGenerator(); 28 | 29 | private static final int PER_CHUNK = getCrystalAttemptsPerChunk(); //calls per chunk; vast majority fail 30 | 31 | private RFCrystalGenerator() { 32 | 33 | } 34 | 35 | private static int getCrystalAttemptsPerChunk() { 36 | return (int)(8*GeoOptions.getRFCrystalDensity()); 37 | } 38 | 39 | @Override 40 | public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { 41 | if (world.getWorldInfo().getTerrainType() != WorldType.FLAT) { 42 | chunkX *= 16; 43 | chunkZ *= 16; 44 | for (int i = 0; i < PER_CHUNK; i++) { 45 | int posX = chunkX + random.nextInt(16); 46 | int posZ = chunkZ + random.nextInt(16); 47 | int maxy = 18; 48 | int posY = 4+random.nextInt(maxy-4); 49 | if (this.canGenerateAt(world, posX, posY, posZ)) { 50 | world.setBlock(posX, posY, posZ, GeoBlocks.RFCRYSTALSEED.getBlockInstance(), 1, 2); 51 | } 52 | } 53 | } 54 | } 55 | 56 | public static boolean canGenerateAt(World world, int x, int y, int z) { 57 | return world.getBlock(x, y, z) == Blocks.redstone_ore && ReikaWorldHelper.checkForAdjMaterial(world, x, y, z, Material.air) == null; 58 | } 59 | 60 | @Override 61 | public boolean canGenerateAt(World world, int chunkX, int chunkZ) { 62 | return true; 63 | } 64 | 65 | @Override 66 | public String getIDString() { 67 | return "GeoStrata Flux Crystals"; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /World/BasicRockGenerator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.World; 11 | 12 | import java.util.Random; 13 | 14 | import net.minecraft.world.World; 15 | 16 | import Reika.GeoStrata.API.RockGenerationPatterns.RockGenerationPattern; 17 | import Reika.GeoStrata.Registry.GeoOptions; 18 | import Reika.GeoStrata.Registry.RockTypes; 19 | 20 | public class BasicRockGenerator implements RockGenerationPattern { 21 | 22 | private final WorldGenGeoRock[] generators = new WorldGenGeoRock[RockTypes.rockList.length]; 23 | 24 | public BasicRockGenerator() { 25 | for (int i = 0; i < generators.length; i++) { 26 | generators[i] = new WorldGenGeoRock(this, RockTypes.rockList[i], RockGenerator.VEIN_SIZE); 27 | RockGenerator.instance.registerProfilingSubgenerator(RockTypes.rockList[i], this, generators[i]); 28 | } 29 | } 30 | 31 | public void generateRockType(RockTypes geo, World world, Random random, int chunkX, int chunkZ) { 32 | double max = RockGenerator.BASE_GEN*geo.rarity*this.getDensityFactor(geo); 33 | //ReikaJavaLibrary.pConsole("Genning "+geo+" "+max+" times."); 34 | for (int i = 0; i < max; i++) { 35 | int posX = chunkX + random.nextInt(16); 36 | int posZ = chunkZ + random.nextInt(16); 37 | int posY = geo.minY + random.nextInt(geo.maxY-geo.minY); 38 | //GeoStrata.logger.debug(geo.name()+":"+geo.canGenerateAt(world, posX, posY, posZ, random)); 39 | if (geo.canGenerateAt(world, posX, posY, posZ, random)) { 40 | //(new WorldGenMinable(geo.getID(RockShapes.SMOOTH), VEIN_SIZE, Blocks.stone)).generate(world, random, posX, posY, posZ); 41 | generators[geo.ordinal()].generate(world, random, posX, posY, posZ); 42 | //GeoStrata.logger.log("Generating "+geo+" at "+posX+", "+posY+", "+posZ); 43 | } 44 | } 45 | } 46 | 47 | /** if compressed in small y, or lots of coincident rocks, reduce density */ 48 | protected final double getDensityFactor(RockTypes rock) { 49 | float f = GeoOptions.getRockDensity(); 50 | int h = rock.maxY-rock.minY; 51 | int d = 1; 52 | if (rock == RockTypes.ONYX) 53 | d *= 2; 54 | return f*d*h/64D*3D/(1+rock.getCoincidentTypes().size()); //+1 since it used to include itself in that list 55 | } 56 | 57 | @Override 58 | public int getOrderingIndex() { 59 | return 0; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /TileEntityGeoBlocks.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata; 11 | 12 | import net.minecraft.block.Block; 13 | import net.minecraft.init.Blocks; 14 | import net.minecraft.nbt.NBTTagCompound; 15 | import net.minecraft.network.NetworkManager; 16 | import net.minecraft.network.Packet; 17 | import net.minecraft.network.play.server.S35PacketUpdateTileEntity; 18 | import net.minecraft.tileentity.TileEntity; 19 | import net.minecraft.util.IIcon; 20 | 21 | import Reika.GeoStrata.Registry.RockShapes; 22 | import Reika.GeoStrata.Registry.RockTypes; 23 | 24 | import cpw.mods.fml.relauncher.Side; 25 | import cpw.mods.fml.relauncher.SideOnly; 26 | 27 | public class TileEntityGeoBlocks extends TileEntity { 28 | 29 | private RockShapes shape; 30 | private RockTypes type; 31 | 32 | @Override 33 | public boolean canUpdate() { 34 | return false; 35 | } 36 | 37 | public Block getImitatedBlock() { 38 | if (shape == null || type == null) 39 | return Blocks.stone; 40 | return type.getID(shape); 41 | } 42 | 43 | @SideOnly(Side.CLIENT) 44 | public IIcon getIcon() { 45 | if (type == null || shape == null) 46 | return Blocks.stone.getIcon(0, 0); 47 | return type.getIcon(shape); 48 | } 49 | 50 | @Override 51 | public void writeToNBT(NBTTagCompound NBT) { 52 | super.writeToNBT(NBT); 53 | 54 | NBT.setInteger("type", type.ordinal()); 55 | NBT.setInteger("shape", shape.ordinal()); 56 | } 57 | 58 | @Override 59 | public void readFromNBT(NBTTagCompound NBT) { 60 | super.readFromNBT(NBT); 61 | 62 | type = RockTypes.rockList[NBT.getInteger("type")]; 63 | shape = RockShapes.shapeList[NBT.getInteger("shape")]; 64 | } 65 | 66 | @Override 67 | public Packet getDescriptionPacket() { 68 | NBTTagCompound NBT = new NBTTagCompound(); 69 | this.writeToNBT(NBT); 70 | S35PacketUpdateTileEntity pack = new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, NBT); 71 | return pack; 72 | } 73 | 74 | @Override 75 | public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity p) { 76 | this.readFromNBT(p.field_148860_e); 77 | } 78 | 79 | public void setTypes(RockTypes rock, RockShapes s) { 80 | type = rock; 81 | shape = s; 82 | } 83 | 84 | public RockTypes getRockType() { 85 | return type; 86 | } 87 | 88 | public RockShapes getRockShape() { 89 | return shape; 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /World/BandedGenerator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.World; 11 | 12 | import java.util.Random; 13 | 14 | import net.minecraft.world.World; 15 | 16 | import Reika.DragonAPI.Instantiable.Math.Noise.NoiseGeneratorBase; 17 | import Reika.DragonAPI.Instantiable.Math.Noise.SimplexNoiseGenerator; 18 | import Reika.GeoStrata.GeoStrata; 19 | import Reika.GeoStrata.API.RockGenerationPatterns.RockGenerationPattern; 20 | import Reika.GeoStrata.Registry.GeoOptions; 21 | import Reika.GeoStrata.Registry.RockTypes; 22 | 23 | public class BandedGenerator implements RockGenerationPattern { 24 | 25 | private NoiseGeneratorBase bandOffsets; 26 | private static final int OFFSET_MARGIN = 16; 27 | 28 | private final WorldGenGeoRock[] generators = new WorldGenGeoRock[RockTypes.rockList.length]; 29 | 30 | public BandedGenerator() { 31 | for (int i = 0; i < generators.length; i++) { 32 | generators[i] = new WorldGenGeoRock(this, RockTypes.rockList[i], RockGenerator.VEIN_SIZE); 33 | RockGenerator.instance.registerProfilingSubgenerator(RockTypes.rockList[i], this, generators[i]); 34 | } 35 | } 36 | 37 | @Override 38 | public void generateRockType(RockTypes geo, World world, Random random, int chunkX, int chunkZ) { 39 | double max = RockGenerator.BASE_GEN*geo.rarity*GeoOptions.getRockDensity()*2; 40 | if (bandOffsets == null || bandOffsets.seed != world.getSeed()) { 41 | bandOffsets = new SimplexNoiseGenerator(world.getSeed()).setFrequency(1/64D); 42 | } 43 | //ReikaJavaLibrary.pConsole("Genning "+geo+" "+max+" times."); 44 | for (int i = 0; i < max; i++) { 45 | int posX = chunkX + random.nextInt(16); 46 | int posZ = chunkZ + random.nextInt(16); 47 | int posY = GeoStrata.config.getRockBand(geo)+(int)(OFFSET_MARGIN*bandOffsets.getValue(posX, posZ)); 48 | //GeoStrata.logger.debug(geo.name()+":"+geo.canGenerateAt(world, posX, posY, posZ, random)); 49 | if (geo.canGenerateAt(world, posX, posY, posZ, random)) { 50 | //(new WorldGenMinable(geo.getID(RockShapes.SMOOTH), VEIN_SIZE, Blocks.stone)).generate(world, random, posX, posY, posZ); 51 | generators[geo.ordinal()].generate(world, random, posX, posY, posZ); 52 | //GeoStrata.logger.log("Generating "+geo+" at "+posX+", "+posY+", "+posZ); 53 | } 54 | } 55 | } 56 | 57 | @Override 58 | public int getOrderingIndex() { 59 | return 0; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /Items/ItemBlockRock.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Items; 11 | 12 | import java.util.List; 13 | 14 | import net.minecraft.block.Block; 15 | import net.minecraft.creativetab.CreativeTabs; 16 | import net.minecraft.entity.player.EntityPlayer; 17 | import net.minecraft.init.Blocks; 18 | import net.minecraft.item.Item; 19 | import net.minecraft.item.ItemBlock; 20 | import net.minecraft.item.ItemStack; 21 | 22 | import Reika.GeoStrata.Registry.RockShapes; 23 | import Reika.GeoStrata.Registry.RockTypes; 24 | 25 | import cpw.mods.fml.relauncher.Side; 26 | import cpw.mods.fml.relauncher.SideOnly; 27 | 28 | public class ItemBlockRock extends ItemBlock { 29 | 30 | public ItemBlockRock(Block b) { 31 | super(b); 32 | hasSubtypes = true; 33 | } 34 | 35 | @Override 36 | @SideOnly(Side.CLIENT) 37 | public final void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List li) //Adds the metadata blocks to the creative inventory 38 | { 39 | Block b = Block.getBlockFromItem(par1); 40 | RockTypes type = RockTypes.getTypeFromID(b); 41 | for (int k = 0; k < 16; k++) { 42 | RockShapes shape = RockShapes.getShape(b, k); 43 | if (shape != null) { 44 | ItemStack item = type.getItem(shape); 45 | li.add(item); 46 | } 47 | } 48 | } 49 | 50 | @Override 51 | public final String getUnlocalizedName(ItemStack is) { 52 | int d = is.getItemDamage(); 53 | return super.getUnlocalizedName() + "." + d; 54 | } 55 | 56 | @Override 57 | public final String getItemStackDisplayName(ItemStack is) { 58 | RockTypes r = RockTypes.getTypeFromID(field_150939_a); 59 | RockShapes s = RockShapes.getShape(field_150939_a, is.getItemDamage()); 60 | if (s == null || r == null) { 61 | return "ERROR"; 62 | } 63 | return s.nameFirst ? r.getName()+" "+s.name : s.name+" "+r.getName(); 64 | } 65 | 66 | @Override 67 | public int getMetadata(int meta) { 68 | return meta; 69 | } 70 | 71 | @Override 72 | public void addInformation(ItemStack is, EntityPlayer ep, List li, boolean par4) { 73 | RockTypes rock = RockTypes.getTypeFromID(field_150939_a); 74 | float blast = rock.blastResistance; 75 | float more = blast/Blocks.stone.blockResistance; 76 | li.add(String.format("Blast Resistance: %.1f (%.1fx stone)", blast, more)); 77 | } 78 | 79 | @Override 80 | @SideOnly(Side.CLIENT) 81 | public int getColorFromItemStack(ItemStack is, int par2) 82 | { 83 | return 0xffffff; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /Blocks/BlockRockPillar.java: -------------------------------------------------------------------------------- 1 | package Reika.GeoStrata.Blocks; 2 | 3 | import java.util.Random; 4 | 5 | import net.minecraft.client.renderer.texture.IIconRegister; 6 | import net.minecraft.item.Item; 7 | import net.minecraft.item.ItemStack; 8 | import net.minecraft.util.IIcon; 9 | import net.minecraft.world.World; 10 | 11 | import Reika.GeoStrata.Base.RockBlock; 12 | import Reika.GeoStrata.Registry.RockTypes; 13 | 14 | import cpw.mods.fml.relauncher.Side; 15 | import cpw.mods.fml.relauncher.SideOnly; 16 | 17 | 18 | public class BlockRockPillar extends RockBlock { 19 | 20 | private IIcon sideIcon; 21 | private IIcon endIcon; 22 | 23 | public BlockRockPillar() { 24 | super(); 25 | } 26 | 27 | protected IIcon getSideIcon(int side) { 28 | return sideIcon; 29 | } 30 | 31 | protected IIcon getTopIcon(int side) { 32 | return endIcon; 33 | } 34 | 35 | @Override 36 | public void registerBlockIcons(IIconRegister ico) { 37 | RockTypes r = RockTypes.getTypeFromID(this); 38 | int offset = r.ordinal(); 39 | sideIcon = ico.registerIcon("geostrata:pillar/sheetpng/tile0_"+offset); 40 | endIcon = ico.registerIcon("geostrata:pillar/sheetpng/tile1_"+offset); 41 | } 42 | 43 | @Override 44 | public int getRenderType() { 45 | return 31; 46 | } 47 | 48 | /** 49 | * Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata 50 | */ 51 | @Override 52 | public int onBlockPlaced(World world, int x, int y, int z, int side, float a, float b, float c, int meta) { 53 | int j1 = this.damageDropped(meta); 54 | byte b0 = 0; 55 | 56 | switch (side) { 57 | case 0: 58 | case 1: 59 | b0 = 0; 60 | break; 61 | case 2: 62 | case 3: 63 | b0 = 8; 64 | break; 65 | case 4: 66 | case 5: 67 | b0 = 4; 68 | } 69 | 70 | return j1 | b0; 71 | } 72 | 73 | @Override 74 | @SideOnly(Side.CLIENT) 75 | public IIcon getIcon(int s, int meta) { 76 | int k = meta & 12; 77 | int l = meta & 3; 78 | return k == 0 && (s == 1 || s == 0) ? this.getTopIcon(l) : (k == 4 && (s == 5 || s == 4) ? this.getTopIcon(l) : (k == 8 && (s == 2 || s == 3) ? this.getTopIcon(l) : this.getSideIcon(l))); 79 | } 80 | 81 | @Override 82 | public int damageDropped(int meta) { 83 | return meta & 3; 84 | } 85 | 86 | @Override 87 | protected ItemStack createStackedBlock(int meta) { 88 | return new ItemStack(Item.getItemFromBlock(this), 1, this.damageDropped(meta)); 89 | } 90 | 91 | @Override 92 | public Item getItemDropped(int id, Random r, int fortune) { 93 | return Item.getItemFromBlock(this); 94 | } 95 | 96 | @Override 97 | public int quantityDropped(Random r) { 98 | return 1; 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # @author Reika Kalseki 3 | # 4 | # Copyright 2013-2021 5 | # 6 | # All rights reserved. 7 | # Distribution of the software in any form is only allowed with 8 | # explicit, prior permission from the owner. 9 | #------------------------------------------------------------------------------- 10 | @author Reika 11 | 12 | 13 | This code is the property of and owned and copyrighted by Reika. 14 | This code is provided under a modified visible-source license that is as follows: 15 | 16 | 17 | API Code: 18 | ============================== 19 | API code is identifiable as being in an "API" package in the respective repository or mod, and is intended to allow some level of inter-mod interactions without creating hard dependencies on the mod proper. This code is exempt from the below restrictions for "Mod Code", as it by nature will require some level of copying and redistribution. 20 | 21 | The only restrictions imposed on API code are that it remain clearly marked with its original authorship and source, that it be used for the purpose described previously, and that it not be modified from the original without first contacting Reika. 22 | 23 | 24 | Mod Code: 25 | ============================== 26 | Any and all users are permitted to use the source for educational purposes, or to create derivative works 27 | for private use only. GitHub forks and direct downloads are considered derivative works. 28 | 29 | Unless given explicit written permission - electronic writing is acceptable - no user may redistribute this 30 | source code nor any derivative works. These pre-approved works must prominently contain this copyright notice. 31 | 32 | Derivative mods using any or all of the source code or assets are EXPRESSLY FORBIDDEN. 33 | 34 | Additionally, no attempt may be made to achieve monetary gain from this code by anyone except the original author. 35 | In the case of pre-approved derivative works, any monetary gains made will be shared between the original author 36 | and the other developer(s), proportional to the ratio of derived to original code. 37 | 38 | Finally, any and all displays, duplicates or derivatives of this code must be prominently marked as such, and must 39 | contain attribution to the original author, including a link to the original source. Any attempts to claim credit 40 | for this code will be treated as intentional theft. 41 | 42 | Due to the Mojang and Minecraft Mod Terms of Service and Licensing Restrictions, compiled versions of this code 43 | must be provided for free. However, with the exception of pre-approved derivative works, only the original authoror modpacks 44 | may distribute compiled binary versions of this code. 45 | 46 | ============================== 47 | 48 | Failure to comply with these restrictions is a violation of copyright law and will be dealt with accordingly. 49 | -------------------------------------------------------------------------------- /Items/ItemBlockAnyGeoVariant.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Items; 11 | 12 | import java.util.List; 13 | 14 | import net.minecraft.block.Block; 15 | import net.minecraft.block.BlockStairs; 16 | import net.minecraft.creativetab.CreativeTabs; 17 | import net.minecraft.entity.player.EntityPlayer; 18 | import net.minecraft.item.Item; 19 | import net.minecraft.item.ItemBlock; 20 | import net.minecraft.item.ItemStack; 21 | import net.minecraft.world.World; 22 | 23 | import Reika.GeoStrata.TileEntityGeoBlocks; 24 | import Reika.GeoStrata.Registry.RockShapes; 25 | import Reika.GeoStrata.Registry.RockTypes; 26 | 27 | public class ItemBlockAnyGeoVariant extends ItemBlock { 28 | 29 | public ItemBlockAnyGeoVariant(Block b) { 30 | super(b); 31 | this.setHasSubtypes(true); 32 | } 33 | 34 | public static RockTypes getRock(ItemStack is) { 35 | return RockTypes.rockList[is.getItemDamage()/RockShapes.shapeList.length]; 36 | } 37 | 38 | public static RockShapes getShape(ItemStack is) { 39 | return RockShapes.shapeList[is.getItemDamage()%RockShapes.shapeList.length]; 40 | } 41 | 42 | public static int getStack(RockTypes r, RockShapes s) { 43 | return r.ordinal()*RockShapes.shapeList.length+s.ordinal(); 44 | } 45 | 46 | @Override 47 | public boolean placeBlockAt(ItemStack is, EntityPlayer ep, World world, int x, int y, int z, int s, float a, float b, float c, int meta) 48 | { 49 | boolean flag = super.placeBlockAt(is, ep, world, x, y, z, s, a, b, c, meta); 50 | if (flag) { 51 | TileEntityGeoBlocks te = (TileEntityGeoBlocks)world.getTileEntity(x, y, z); 52 | te.setTypes(this.getRock(is), this.getShape(is)); 53 | } 54 | return flag; 55 | } 56 | 57 | @Override 58 | public void getSubItems(Item item, CreativeTabs c, List li) { 59 | for (int i = 0; i < RockTypes.rockList.length; i++) { 60 | for (int k = 0; k < RockShapes.shapeList.length; k++) { 61 | int index = i*RockShapes.shapeList.length+k; 62 | li.add(new ItemStack(item, 1, index)); 63 | } 64 | } 65 | } 66 | 67 | @Override 68 | public final String getItemStackDisplayName(ItemStack is) { 69 | return field_150939_a instanceof BlockStairs ? "Rock Stairs" : "Rock Slab"; 70 | } 71 | 72 | @Override 73 | public void addInformation(ItemStack is, EntityPlayer ep, List li, boolean par4) { 74 | RockTypes r = this.getRock(is); 75 | RockShapes s = this.getShape(is); 76 | String s1 = s.name; 77 | String s2 = r.getName(); 78 | if (s.nameFirst) { 79 | String sg = s1; 80 | s1 = s2; 81 | s2 = sg; 82 | } 83 | li.add(String.format("Type: %s %s", s1, s2)); 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /GeoEDTrade.java: -------------------------------------------------------------------------------- 1 | package Reika.GeoStrata; 2 | 3 | import net.minecraft.entity.player.EntityPlayer; 4 | import net.minecraft.init.Items; 5 | import net.minecraft.item.ItemStack; 6 | import net.minecraft.util.MathHelper; 7 | import net.minecraft.village.MerchantRecipe; 8 | 9 | import Reika.ChromatiCraft.Magic.Artefact.UATrades.EDCommodityHook; 10 | import Reika.DragonAPI.Interfaces.PlayerSpecificTrade; 11 | import Reika.DragonAPI.Libraries.ReikaInventoryHelper; 12 | 13 | public abstract class GeoEDTrade implements EDCommodityHook { 14 | 15 | private static final int REDUCTION_THRESHOLD = 192; 16 | private static final double REDUCTION_EXPONENT = 0.998; //value raised to this power for every surplus item over thresh until thresh 2 17 | private static final int REDUCTION_THRESHOLD_2 = 1024; 18 | private static final double REDUCTION_EXPONENT_2 = 0.985; //value raised to this power for every surplus item over thresh 2 19 | 20 | private final ItemStack inputStack; 21 | private int emeraldValue; 22 | 23 | public final int baselinePrice; 24 | public final int peakPrice; 25 | 26 | protected GeoEDTrade(ItemStack input, int baseline, int peak, int defaultValue) { 27 | inputStack = input; 28 | baselinePrice = baseline; 29 | peakPrice = peak; 30 | emeraldValue = defaultValue; 31 | } 32 | 33 | @Override 34 | public void onPriceReceived(int average, int upper, int max) { 35 | double price = upper/2D+average/2D; 36 | double fac = Math.pow(price/baselinePrice, 2)*Math.pow((double)max/peakPrice, 6); //was ^2* 37 | emeraldValue = Math.min(64, MathHelper.ceiling_double_int(128*fac)); //used to be 32 and have *inputStack.stackSize/inputStack.getMaxStackSize() 38 | GeoStrata.logger.log("Received "+this.getCommodityID()+" price data: "+average+"/"+upper+"/"+max+" -> "+price+"/"+fac+" -> "+emeraldValue+"x emeralds per "+inputStack.stackSize); 39 | emeraldValue = Math.max(1, emeraldValue); 40 | } 41 | 42 | @Override 43 | public MerchantRecipe createTrade() { 44 | return new Trade(inputStack, emeraldValue); 45 | } 46 | 47 | private class Trade extends MerchantRecipe implements PlayerSpecificTrade { 48 | 49 | private final int baseValue; 50 | 51 | private int currentValue; 52 | private int currentPrice; 53 | 54 | private Trade(ItemStack in, int out) { 55 | super(in, new ItemStack(Items.emerald, out, 0)); 56 | baseValue = out; 57 | } 58 | 59 | @Override 60 | public boolean isValid(EntityPlayer ep) { 61 | float val = baseValue; 62 | currentPrice = inputStack.stackSize; 63 | int amt = ReikaInventoryHelper.countItem(inputStack.getItem(), ep.inventory.mainInventory)+Math.max(0, 2*(baseValue-1)); 64 | int over = amt-REDUCTION_THRESHOLD; 65 | if (over > 0) { 66 | int over2 = amt-REDUCTION_THRESHOLD_2; 67 | if (over2 > 0) { 68 | over -= over2; 69 | val *= Math.pow(REDUCTION_EXPONENT_2, over2); 70 | } 71 | val *= Math.pow(REDUCTION_EXPONENT, over); 72 | } 73 | currentValue = (int)Math.max(1, val); 74 | if (val < 1) { 75 | currentPrice /= val; 76 | } 77 | this.getItemToSell().stackSize = currentValue; 78 | this.getItemToBuy().stackSize = Math.min(this.getItemToBuy().getMaxStackSize(), currentPrice); 79 | return true; 80 | } 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /Blocks/BlockRockDeco.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Blocks; 11 | 12 | import net.minecraft.block.Block; 13 | import net.minecraft.block.material.Material; 14 | import net.minecraft.client.renderer.texture.IIconRegister; 15 | import net.minecraft.entity.Entity; 16 | import net.minecraft.entity.player.EntityPlayer; 17 | import net.minecraft.item.ItemStack; 18 | import net.minecraft.util.IIcon; 19 | import net.minecraft.world.IBlockAccess; 20 | import net.minecraft.world.World; 21 | 22 | import Reika.GeoStrata.GeoStrata; 23 | import Reika.GeoStrata.Registry.DecoBlocks; 24 | 25 | public class BlockRockDeco extends Block { 26 | 27 | private IIcon[] icons = new IIcon[DecoBlocks.list.length]; 28 | 29 | public BlockRockDeco(Material par2Material) { 30 | super(par2Material); 31 | this.setCreativeTab(GeoStrata.tabGeo); 32 | } 33 | 34 | @Override 35 | public void registerBlockIcons(IIconRegister ico) { 36 | for (int i = 0; i < DecoBlocks.list.length; i++) { 37 | icons[i] = ico.registerIcon("GeoStrata:"+DecoBlocks.list[i].getTex()); 38 | GeoStrata.logger.debug("Adding "+DecoBlocks.list[i].getName()+" decorative block icon "+icons[i].getIconName()); 39 | } 40 | } 41 | 42 | @Override 43 | public IIcon getIcon(int s, int m) { 44 | return icons[m]; 45 | } 46 | 47 | @Override 48 | public int damageDropped(int dmg) { 49 | return dmg; 50 | } 51 | 52 | @Override 53 | public final float getPlayerRelativeBlockHardness(EntityPlayer ep, World world, int x, int y, int z) { 54 | ItemStack is = ep.getCurrentEquippedItem(); 55 | int meta = world.getBlockMetadata(x, y, z); 56 | if (!this.canHarvestBlock(ep, meta)) 57 | return 0.0025F/DecoBlocks.getTypeAtCoords(world, x, y, z).getHardness(); 58 | if (is == null) 59 | return 0.0125F/DecoBlocks.getTypeAtCoords(world, x, y, z).getHardness(); 60 | return 0.025F/DecoBlocks.getTypeAtCoords(world, x, y, z).getHardness()*is.getItem().func_150893_a(is, this); 61 | } 62 | 63 | @Override 64 | public final float getExplosionResistance(Entity e, World world, int x, int y, int z, double eX, double eY, double eZ) { 65 | return DecoBlocks.getTypeAtCoords(world, x, y, z).getResistance()/5F; // /5F is in vanilla code 66 | } 67 | 68 | @Override 69 | public final boolean canHarvestBlock(EntityPlayer player, int meta) { 70 | if (player.capabilities.isCreativeMode) 71 | return false; 72 | return DecoBlocks.getTypeFromMetadata(meta).isHarvestable(player.getCurrentEquippedItem()); 73 | } 74 | 75 | @Override 76 | public boolean canProvidePower() 77 | { 78 | return true; 79 | } 80 | 81 | @Override 82 | public int isProvidingWeakPower(IBlockAccess iba, int x, int y, int z, int side) 83 | { 84 | return iba.getBlockMetadata(x, y, z) == DecoBlocks.REDBRICKS.ordinal() ? 15 : 0; 85 | } 86 | 87 | @Override 88 | public int getLightValue(IBlockAccess iba, int x, int y, int z) 89 | { 90 | return iba.getBlockMetadata(x, y, z) == DecoBlocks.GLOWBRICKS.ordinal() ? 15 : 0; 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /CreepvineHandler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata; 11 | 12 | import java.util.ArrayList; 13 | 14 | import net.minecraft.block.Block; 15 | import net.minecraft.item.ItemStack; 16 | import net.minecraft.world.World; 17 | 18 | import Reika.DragonAPI.ModList; 19 | import Reika.DragonAPI.Interfaces.CustomCropHandler; 20 | import Reika.DragonAPI.Interfaces.Registry.ModEntry; 21 | import Reika.GeoStrata.Blocks.BlockCreepvine.Pieces; 22 | import Reika.GeoStrata.Registry.GeoBlocks; 23 | 24 | public class CreepvineHandler implements CustomCropHandler { 25 | 26 | @Override 27 | public int getHarvestedMeta(World world, int x, int y, int z) { 28 | return Pieces.CORE_EMPTY.ordinal(); 29 | } 30 | 31 | @Override 32 | public boolean isCrop(Block id, int meta) { 33 | return id == GeoBlocks.CREEPVINE.getBlockInstance() && Pieces.list[meta].isCore(); 34 | } 35 | 36 | @Override 37 | public boolean isRipeCrop(World world, int x, int y, int z) { 38 | return Pieces.list[world.getBlockMetadata(x, y, z)].canBeHarvested(); 39 | } 40 | 41 | @Override 42 | public void makeRipe(World world, int x, int y, int z) { 43 | world.setBlockMetadataWithNotify(x, y, z, Pieces.CORE_5.ordinal(), 3); 44 | world.func_147451_t(x, y, z); 45 | } 46 | 47 | @Override 48 | public boolean isSeedItem(ItemStack is) { 49 | return is != null && is.getItem() == GeoStrata.creepvineSeeds; 50 | } 51 | 52 | @Override 53 | public ArrayList getAdditionalDrops(World world, int x, int y, int z, Block id, int meta, int fortune) { 54 | return null; 55 | } 56 | 57 | @Override 58 | public void editTileDataForHarvest(World world, int x, int y, int z) { 59 | 60 | } 61 | 62 | @Override 63 | public boolean initializedProperly() { 64 | return GeoBlocks.CREEPVINE.getBlockInstance() != null; 65 | } 66 | 67 | @Override 68 | public ArrayList getDropsOverride(World world, int x, int y, int z, Block id, int meta, int fortune) { 69 | ArrayList li = new ArrayList(); 70 | int n = Pieces.list[meta].getSeedCount(); 71 | for (int i = 0; i < n; i++) { 72 | li.add(new ItemStack(GeoStrata.creepvineSeeds)); 73 | } 74 | return li; 75 | } 76 | 77 | @Override 78 | public int getGrowthState(World world, int x, int y, int z) { 79 | return Pieces.list[world.getBlockMetadata(x, y, z)].getSeedCount(); 80 | } 81 | 82 | @Override 83 | public ModEntry getMod() { 84 | return ModList.GEOSTRATA; 85 | } 86 | 87 | @Override 88 | public int getColor() { 89 | return 0xFFC700; 90 | } 91 | 92 | @Override 93 | public String getEnumEntryName() { 94 | return "CREEPVINE"; 95 | } 96 | 97 | @Override 98 | public boolean isTileEntity() { 99 | return false; 100 | } 101 | 102 | @Override 103 | public boolean neverDropsSecondSeed() { 104 | return true; 105 | } 106 | /* 107 | @Override 108 | public CropFormat getShape() { 109 | return CropFormat.PLANT; 110 | }*/ 111 | 112 | } 113 | -------------------------------------------------------------------------------- /Rendering/StairItemRenderer.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Rendering; 11 | 12 | import net.minecraft.block.Block; 13 | import net.minecraft.block.BlockSlab; 14 | import net.minecraft.block.BlockStairs; 15 | import net.minecraft.block.material.Material; 16 | import net.minecraft.client.Minecraft; 17 | import net.minecraft.client.renderer.RenderBlocks; 18 | import net.minecraft.entity.player.EntityPlayer; 19 | import net.minecraft.item.ItemStack; 20 | import net.minecraft.util.IIcon; 21 | import net.minecraft.util.MathHelper; 22 | import net.minecraftforge.client.IItemRenderer; 23 | 24 | import Reika.GeoStrata.GeoStrata; 25 | import Reika.GeoStrata.Items.ItemBlockAnyGeoVariant; 26 | import Reika.GeoStrata.Registry.RockShapes; 27 | import Reika.GeoStrata.Registry.RockTypes; 28 | 29 | import cpw.mods.fml.relauncher.Side; 30 | import cpw.mods.fml.relauncher.SideOnly; 31 | 32 | public class StairItemRenderer implements IItemRenderer { 33 | 34 | private final DummyBlock dummy; 35 | 36 | public StairItemRenderer() { 37 | dummy = new DummyBlock(); 38 | } 39 | 40 | @Override 41 | public boolean handleRenderType(ItemStack item, ItemRenderType type) { 42 | return true; 43 | } 44 | 45 | @Override 46 | public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { 47 | return true; 48 | } 49 | 50 | @Override 51 | public void renderItem(ItemRenderType type, ItemStack item, Object... data) { 52 | ItemBlockAnyGeoVariant i = (ItemBlockAnyGeoVariant)item.getItem(); 53 | RockTypes r = i.getRock(item); 54 | RockShapes s = i.getShape(item); 55 | IIcon ico = r.getIcon(s); 56 | dummy.icon = ico; 57 | RenderBlocks rb = (RenderBlocks)data[0]; 58 | Block base = i.field_150939_a; 59 | dummy.renderType = base instanceof BlockStairs ? 10 : 0; 60 | dummy.setBounds(base instanceof BlockSlab); 61 | dummy.rock = r; 62 | rb.renderBlockAsItem(dummy, 1, 1); 63 | } 64 | 65 | private static class DummyBlock extends Block { 66 | 67 | private int renderType; 68 | private IIcon icon; 69 | private RockTypes rock; 70 | 71 | protected DummyBlock() { 72 | super(Material.rock); 73 | } 74 | 75 | @Override 76 | public int getRenderType() { 77 | return renderType; 78 | } 79 | 80 | private void setBounds(boolean half) { 81 | maxY = half ? 0.5F : 1F; 82 | } 83 | 84 | @Override 85 | public IIcon getIcon(int s, int meta) { 86 | return icon; 87 | } 88 | 89 | @Override 90 | @SideOnly(Side.CLIENT) 91 | public final int getRenderColor(int dmg) { 92 | EntityPlayer ep = Minecraft.getMinecraft().thePlayer; 93 | int x = MathHelper.floor_double(ep.posX); 94 | int y = MathHelper.floor_double(ep.posY); 95 | int z = MathHelper.floor_double(ep.posZ); 96 | if (rock == RockTypes.OPAL) { 97 | return GeoStrata.getOpalPositionColor(ep.worldObj, x, y, z); 98 | } 99 | else { 100 | return super.getRenderColor(dmg); 101 | } 102 | } 103 | 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /Blocks/BlockShapedRock.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Blocks; 11 | 12 | import java.util.Locale; 13 | import java.util.Random; 14 | 15 | import net.minecraft.client.renderer.texture.IIconRegister; 16 | import net.minecraft.item.Item; 17 | import net.minecraft.util.IIcon; 18 | import net.minecraft.world.World; 19 | 20 | import Reika.GeoStrata.Base.RockBlock; 21 | import Reika.GeoStrata.Registry.RockShapes; 22 | import Reika.GeoStrata.Registry.RockTypes; 23 | 24 | public class BlockShapedRock extends RockBlock { 25 | 26 | //public final String shapeType; 27 | 28 | private static final IIcon[][] textures = new IIcon[RockTypes.rockList.length][RockShapes.shapeList.length]; 29 | //private static boolean texturesLoaded = false; 30 | 31 | public BlockShapedRock() { 32 | super(); 33 | //shapeType = type.toLowerCase(); 34 | } 35 | 36 | @Override 37 | public final Item getItemDropped(int id, Random r, int fortune) { 38 | return Item.getItemFromBlock(this); 39 | } 40 | 41 | @Override 42 | public final int damageDropped(int meta) { 43 | return meta; 44 | } 45 | 46 | @Override 47 | public final int quantityDropped(Random r) { 48 | return 1; 49 | } 50 | 51 | @Override 52 | public int getRenderType() { 53 | return 0;//GeoStrata.proxy.shapedRender; 54 | } 55 | 56 | @Override 57 | public final IIcon getIcon(int side, int meta) { 58 | RockTypes r = RockTypes.getTypeFromID(this); 59 | RockShapes s = RockShapes.getShape(this, meta); 60 | return textures[r.ordinal()][s.ordinal()]; 61 | } 62 | 63 | @Override 64 | public void registerBlockIcons(IIconRegister ico) { 65 | for (int i = 0; i < RockTypes.rockList.length; i++) { 66 | for (int k = 0; k < RockShapes.shapeList.length; k++) { 67 | //int a = RockShapes.getShape(this).ordinal(); 68 | //int b = type.ordinal(); 69 | String suff = k+"_"+i; 70 | if (RockShapes.shapeList[k].name.toLowerCase(Locale.ENGLISH).contains("connected")) 71 | suff = "0_"+i; 72 | textures[i][k] = ico.registerIcon("GeoStrata:shaped/unstitched/tile"+suff); 73 | //GeoStrata.logger.debug("Adding "+type.getName()+" "+shapeType+" icon "+icons[i].getIconName()); 74 | //texturesLoaded = true; 75 | } 76 | } 77 | /* 78 | for (int i = 0; i < blends.length; i++) { 79 | blendicons[i] = ico.registerIcon("GeoStrata:shaped/"+blends[i]+"/"+shapeType+"base"); 80 | }*/ 81 | /* 82 | int cols = RockShapes.shapeList.length; 83 | int rows = RockTypes.rockList.length; 84 | ReikaImageLoader.unstitchIconsFromSheet(textures, ico, "geostrata:shaped/sheet", cols, rows); 85 | */ 86 | } 87 | /* 88 | @Override 89 | public Icon getIcon(int s, int meta) { 90 | RockTypes rock = RockTypes.getTypeFromIDandMeta(blockID, meta); 91 | RockShapes shape = RockShapes.getShape(this); 92 | return textures[rock.ordinal()][shape.ordinal()]; 93 | }*/ 94 | 95 | //public String getDisplayName() { 96 | // return ReikaStringParser.capFirstChar(shapeType); 97 | //} 98 | 99 | @Override 100 | public void whenInBeam(World world, int x, int y, int z, long power, int range) { 101 | RockShapes shape = RockShapes.getShape(world, x, y, z); 102 | if (shape == RockShapes.SMOOTH || shape == RockShapes.COBBLE) 103 | super.whenInBeam(world, x, y, z, power, range); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Rendering/VentRenderer.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Rendering; 11 | 12 | import org.lwjgl.opengl.GL11; 13 | 14 | import net.minecraft.block.Block; 15 | import net.minecraft.client.renderer.RenderBlocks; 16 | import net.minecraft.client.renderer.Tessellator; 17 | import net.minecraft.util.IIcon; 18 | import net.minecraft.world.IBlockAccess; 19 | 20 | import Reika.DragonAPI.Base.ISBRH; 21 | import Reika.GeoStrata.Blocks.BlockVent.VentType; 22 | 23 | public class VentRenderer extends ISBRH { 24 | 25 | public VentRenderer(int id) { 26 | super(id); 27 | } 28 | 29 | @Override 30 | public void renderInventoryBlock(Block b, int metadata, int modelId, RenderBlocks rb) { 31 | Tessellator tessellator = Tessellator.instance; 32 | 33 | rb.renderMaxX = 1; 34 | rb.renderMinY = 0; 35 | rb.renderMaxZ = 1; 36 | rb.renderMinX = 0; 37 | rb.renderMinZ = 0; 38 | rb.renderMaxY = 1; 39 | 40 | GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); 41 | GL11.glTranslatef(-0.5F, -0.5F, -0.5F); 42 | tessellator.startDrawingQuads(); 43 | tessellator.setNormal(0.0F, -1.0F, 0.0F); 44 | rb.renderFaceYNeg(b, 0.0D, 0.0D, 0.0D, b.getIcon(0, metadata)); 45 | tessellator.draw(); 46 | 47 | tessellator.startDrawingQuads(); 48 | tessellator.setNormal(0.0F, 1.0F, 0.0F); 49 | rb.renderFaceYPos(b, 0.0D, 0.0D, 0.0D, b.getIcon(1, metadata)); 50 | tessellator.draw(); 51 | 52 | tessellator.startDrawingQuads(); 53 | tessellator.setNormal(0.0F, 0.0F, -1.0F); 54 | rb.renderFaceZNeg(b, 0.0D, 0.0D, 0.0D, b.getIcon(2, metadata)); 55 | tessellator.draw(); 56 | tessellator.startDrawingQuads(); 57 | tessellator.setNormal(0.0F, 0.0F, 1.0F); 58 | rb.renderFaceZPos(b, 0.0D, 0.0D, 0.0D, b.getIcon(3, metadata)); 59 | tessellator.draw(); 60 | tessellator.startDrawingQuads(); 61 | tessellator.setNormal(-1.0F, 0.0F, 0.0F); 62 | rb.renderFaceXNeg(b, 0.0D, 0.0D, 0.0D, b.getIcon(4, metadata)); 63 | tessellator.draw(); 64 | tessellator.startDrawingQuads(); 65 | tessellator.setNormal(1.0F, 0.0F, 0.0F); 66 | rb.renderFaceXPos(b, 0.0D, 0.0D, 0.0D, b.getIcon(5, metadata)); 67 | tessellator.draw(); 68 | 69 | 70 | IIcon ico = VentType.list[metadata].getIcon(); 71 | tessellator.startDrawingQuads(); 72 | tessellator.addTranslation(0, -0.1F, 0); 73 | tessellator.setNormal(0.0F, 1.0F, 0.0F); 74 | rb.renderFaceYPos(b, 0.0D, 0.0D, 0.0D, ico); 75 | tessellator.addTranslation(0, 0.1F, 0); 76 | tessellator.draw(); 77 | 78 | GL11.glTranslatef(0.5F, 0.5F, 0.5F); 79 | } 80 | 81 | @Override 82 | public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block b, int modelId, RenderBlocks rb) { 83 | Tessellator v5 = Tessellator.instance; 84 | int meta = world.getBlockMetadata(x, y, z); 85 | rb.renderStandardBlockWithAmbientOcclusion(b, x, y, z, 1, 1, 1); 86 | VentType vent = VentType.list[meta]; 87 | IIcon ico = vent.getIcon(); 88 | if (vent.isSelfLit()) { 89 | v5.setBrightness(240); 90 | } 91 | else { 92 | v5.setBrightness(b.getMixedBrightnessForBlock(world, x, y+1, z)); 93 | } 94 | v5.setColorOpaque_F(255, 255, 255); 95 | rb.renderFaceYPos(b, x, y-0.002, z, ico); 96 | return true; 97 | } 98 | 99 | @Override 100 | public boolean shouldRender3DInInventory(int modelId) { 101 | return true; 102 | } 103 | 104 | 105 | 106 | } 107 | -------------------------------------------------------------------------------- /World/GlowingVineGenerator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.World; 11 | 12 | import java.util.Random; 13 | 14 | import net.minecraft.world.World; 15 | import net.minecraft.world.WorldType; 16 | import net.minecraft.world.biome.BiomeGenBase; 17 | import net.minecraft.world.biome.BiomeGenForest; 18 | import net.minecraft.world.biome.BiomeGenJungle; 19 | import net.minecraft.world.biome.BiomeGenTaiga; 20 | import net.minecraft.world.chunk.IChunkProvider; 21 | import net.minecraftforge.common.BiomeDictionary; 22 | import net.minecraftforge.common.BiomeDictionary.Type; 23 | 24 | import Reika.ChromatiCraft.World.BiomeGlowingCliffs; 25 | import Reika.DragonAPI.ModList; 26 | import Reika.DragonAPI.ASM.DependentMethodStripper.ModDependent; 27 | import Reika.DragonAPI.Interfaces.RetroactiveGenerator; 28 | import Reika.DragonAPI.Libraries.World.ReikaWorldHelper; 29 | import Reika.DragonAPI.ModInteract.ItemHandlers.TwilightForestHandler; 30 | import Reika.GeoStrata.Blocks.BlockGlowingVines; 31 | import Reika.GeoStrata.Registry.GeoOptions; 32 | 33 | public class GlowingVineGenerator implements RetroactiveGenerator { 34 | 35 | public static final GlowingVineGenerator instance = new GlowingVineGenerator(); 36 | 37 | private static final int PER_CHUNK = getVineAttemptsPerChunk(); //calls per chunk; vast majority fail 38 | 39 | private GlowingVineGenerator() { 40 | 41 | } 42 | 43 | private static int getVineAttemptsPerChunk() { 44 | return (int)(2*GeoOptions.getVineDensity()); 45 | } 46 | 47 | @Override 48 | public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { 49 | if (world.getWorldInfo().getTerrainType() != WorldType.FLAT) { 50 | chunkX *= 16; 51 | chunkZ *= 16; 52 | for (int i = 0; i < PER_CHUNK; i++) { 53 | int posX = chunkX + random.nextInt(16); 54 | int posZ = chunkZ + random.nextInt(16); 55 | int maxy = 60; 56 | int posY = 4+random.nextInt(maxy-4); 57 | if (this.canGenerateAt(world, posX, posY, posZ)) { 58 | if (BlockGlowingVines.place(world, posX, posY, posZ, null)) { 59 | //ReikaJavaLibrary.pConsole(posX+" "+posY+" "+posZ); 60 | } 61 | } 62 | } 63 | } 64 | } 65 | 66 | public static boolean canGenerateAt(World world, int x, int y, int z) { 67 | return isValidBiome(world, x, z) && world.getBlock(x, y, z).isAir(world, x, y, z) && ReikaWorldHelper.checkForAdjSolidBlock(world, x, y, z); 68 | } 69 | 70 | private static boolean isValidBiome(World world, int x, int z) { 71 | if (world.provider.dimensionId == TwilightForestHandler.getInstance().dimensionID) 72 | return true; 73 | BiomeGenBase b = world.getBiomeGenForCoords(x, z); 74 | if (ModList.CHROMATICRAFT.isLoaded()) { 75 | return isGlowingCliffs(b); 76 | } 77 | return b instanceof BiomeGenForest || b instanceof BiomeGenTaiga || b instanceof BiomeGenJungle || BiomeDictionary.isBiomeOfType(b, Type.FOREST) || BiomeDictionary.isBiomeOfType(b, Type.JUNGLE); 78 | } 79 | 80 | @ModDependent(ModList.CHROMATICRAFT) 81 | private static boolean isGlowingCliffs(BiomeGenBase b) { 82 | return BiomeGlowingCliffs.isGlowingCliffs(b); 83 | } 84 | 85 | @Override 86 | public boolean canGenerateAt(World world, int chunkX, int chunkZ) { 87 | return true; 88 | } 89 | 90 | @Override 91 | public String getIDString() { 92 | return "GeoStrata Glowing Vines"; 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /World/LavaRockGenerator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.World; 11 | 12 | import java.util.Random; 13 | 14 | import net.minecraft.block.Block; 15 | import net.minecraft.init.Blocks; 16 | import net.minecraft.world.World; 17 | import net.minecraft.world.WorldType; 18 | import net.minecraft.world.chunk.IChunkProvider; 19 | 20 | import Reika.DragonAPI.Instantiable.Data.BlockStruct.BlockArray; 21 | import Reika.DragonAPI.Instantiable.Data.Immutable.Coordinate; 22 | import Reika.DragonAPI.Interfaces.RetroactiveGenerator; 23 | import Reika.GeoStrata.Registry.GeoBlocks; 24 | import Reika.GeoStrata.Registry.GeoOptions; 25 | 26 | public class LavaRockGenerator implements RetroactiveGenerator { 27 | 28 | public static final LavaRockGenerator instance = new LavaRockGenerator(); 29 | 30 | private static final int BASE_CHANCE = Math.max(1, (int)(1F/GeoOptions.getLavaRockDensity())); 31 | private static final int COUNT_CHANCE = Math.max(1, (int)(2F/GeoOptions.getLavaRockDensity())); 32 | 33 | public boolean doingLavaRockGen; 34 | 35 | private LavaRockGenerator() { 36 | 37 | } 38 | 39 | @Override 40 | public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { 41 | if (world.getWorldInfo().getTerrainType() != WorldType.FLAT && Math.abs(world.provider.dimensionId) != 1 && random.nextInt(BASE_CHANCE) == 0) { 42 | chunkX *= 16; 43 | chunkZ *= 16; 44 | int n = random.nextInt(COUNT_CHANCE) == 0 ? 1 : 2; 45 | for (int i = 0; i < n; i++) { 46 | int x = chunkX + random.nextInt(16); 47 | int z = chunkZ + random.nextInt(16); 48 | int maxy = 12; 49 | int y = 4+random.nextInt(maxy-4); 50 | if (this.isValidBlock(world, x, y, z)) { 51 | this.generate(world, x, y, z); 52 | } 53 | } 54 | } 55 | } 56 | 57 | private void generate(World world, int x, int y, int z) { 58 | doingLavaRockGen = true; 59 | BlockArray b = new BlockArray(); 60 | b.maxDepth = 40; 61 | b.taxiCabDistance = true; 62 | //b.extraSpread = true; 63 | b.recursiveAddWithBounds(world, x, y, z, world.getBlock(x, y, z), x-16, y-8, z-24, x+16, y+8, z+24); 64 | BlockArray[] arrays = new BlockArray[4]; 65 | for (int i = 0; i < 4; i++) { 66 | BlockArray pre = i == 0 ? b : arrays[i-1]; 67 | arrays[i] = pre.copy(); 68 | arrays[i].expand(1, false); 69 | } 70 | for (int i = 0; i < 4; i++) { 71 | BlockArray pre = i == 0 ? b : arrays[i-1]; 72 | //arrays[i].XORWith(pre); 73 | } 74 | for (int i = 3; i >= 0; i--) { 75 | for (Coordinate c : arrays[i].keySet()) { 76 | Block bk = c.getBlock(world); 77 | if (bk.isReplaceableOreGen(world, c.xCoord, c.yCoord, c.zCoord, Blocks.stone) || bk == GeoBlocks.LAVAROCK.getBlockInstance()) { 78 | c.setBlock(world, GeoBlocks.LAVAROCK.getBlockInstance(), i); 79 | } 80 | } 81 | } 82 | doingLavaRockGen = false; 83 | } 84 | 85 | private boolean isValidBlock(World world, int x, int y, int z) { 86 | Block b = world.getBlock(x, y, z); 87 | return b == Blocks.lava || b == Blocks.flowing_lava; 88 | } 89 | 90 | @Override 91 | public boolean canGenerateAt(World world, int chunkX, int chunkZ) { 92 | return true; 93 | } 94 | 95 | @Override 96 | public String getIDString() { 97 | return "GeoStrata Lava Rock"; 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /World/SimplexRockGenerator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2018 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.World; 11 | 12 | import java.util.Random; 13 | 14 | import net.minecraft.block.Block; 15 | import net.minecraft.init.Blocks; 16 | import net.minecraft.world.World; 17 | 18 | import Reika.DragonAPI.Instantiable.Math.Noise.Simplex3DGenerator; 19 | import Reika.GeoStrata.API.RockGenerationPatterns.RockGenerationPattern; 20 | import Reika.GeoStrata.API.RockProofStone; 21 | import Reika.GeoStrata.Base.RockBlock; 22 | import Reika.GeoStrata.Registry.GeoOptions; 23 | import Reika.GeoStrata.Registry.RockShapes; 24 | import Reika.GeoStrata.Registry.RockTypes; 25 | 26 | public class SimplexRockGenerator implements RockGenerationPattern { 27 | 28 | private final RockEntry[] data = new RockEntry[RockTypes.rockList.length]; 29 | 30 | public SimplexRockGenerator() { 31 | 32 | } 33 | 34 | private RockEntry initData(World world, RockTypes geo) { 35 | RockEntry gen = data[geo.ordinal()]; 36 | if (gen == null || gen.noise.seed != world.getSeed() || true) { 37 | gen = new RockEntry(world, geo); 38 | } 39 | return gen; 40 | } 41 | 42 | @Override 43 | public void generateRockType(RockTypes geo, World world, Random rand, int chunkX, int chunkZ) { 44 | RockEntry gen = this.initData(world, geo); 45 | for (int x = chunkX; x < chunkX+16; x++) { 46 | for (int z = chunkZ; z < chunkZ+16; z++) { 47 | if (geo.canGenerateAtXZ(world, x, z, rand)) { 48 | for (int y = geo.minY; y <= geo.maxY; y++) { 49 | double val = gen.noise.getValue(x, y, z); 50 | if (val > gen.noiseThreshold && geo.canGenerateAtSkipXZ(world, x, y, z, rand)) { 51 | Block b = world.getBlock(x, y, z); 52 | int meta = world.getBlockMetadata(x, y, z); 53 | if (this.canGenerateIn(world, x, y, z, b, meta)) { 54 | world.setBlock(x, y, z, gen.blockID, 0, 2); 55 | }/* 56 | else if (RockGenerator.instance.generateOres() && ReikaBlockHelper.isOre(b, meta)) { 57 | TileEntityGeoOre te = new TileEntityGeoOre(); 58 | te.initialize(geo, b, meta); 59 | world.setBlock(x, y, z, GeoBlocks.ORETILE.getBlockInstance()); 60 | world.setTileEntity(x, y, z, te); 61 | }*/ 62 | } 63 | } 64 | } 65 | } 66 | } 67 | } 68 | 69 | private boolean canGenerateIn(World world, int x, int y, int z, Block b, int meta) { 70 | if (b instanceof RockProofStone && ((RockProofStone)b).blockRockGeneration(world, x, y, z, b, meta)) 71 | return false; 72 | if (!GeoOptions.OVERGEN.getState() && b instanceof RockBlock) 73 | return false; 74 | return b.isReplaceableOreGen(world, x, y, z, Blocks.stone); 75 | } 76 | 77 | @Override 78 | public int getOrderingIndex() { 79 | return 0; 80 | } 81 | 82 | private static class RockEntry { 83 | 84 | private final Simplex3DGenerator noise; 85 | private final Block blockID; 86 | private final double noiseThreshold; 87 | private final double noiseFrequency; 88 | 89 | private RockEntry(World world, RockTypes geo) { 90 | noise = new Simplex3DGenerator(geo.name().hashCode()); 91 | noiseThreshold = 0.5/geo.rarity; //was 0.5 then 0.75 in all cases 92 | noiseFrequency = 1/8D; //was 1/64 then 1/16 93 | noise.setFrequency(noiseFrequency); 94 | blockID = geo.getID(RockShapes.SMOOTH); 95 | } 96 | 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /Blocks/BlockGeoStairs.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Blocks; 11 | 12 | import net.minecraft.block.BlockStairs; 13 | import net.minecraft.block.material.Material; 14 | import net.minecraft.entity.player.EntityPlayer; 15 | import net.minecraft.init.Blocks; 16 | import net.minecraft.item.ItemStack; 17 | import net.minecraft.tileentity.TileEntity; 18 | import net.minecraft.util.IIcon; 19 | import net.minecraft.util.MovingObjectPosition; 20 | import net.minecraft.world.IBlockAccess; 21 | import net.minecraft.world.World; 22 | 23 | import Reika.DragonAPI.Libraries.Registry.ReikaItemHelper; 24 | import Reika.GeoStrata.GeoStrata; 25 | import Reika.GeoStrata.TileEntityGeoBlocks; 26 | import Reika.GeoStrata.Items.ItemBlockAnyGeoVariant; 27 | import Reika.GeoStrata.Registry.RockTypes; 28 | 29 | public class BlockGeoStairs extends BlockStairs { 30 | 31 | public BlockGeoStairs(Material mat) { 32 | super(Blocks.stone, 0); 33 | this.setCreativeTab(GeoStrata.tabGeoStairs); 34 | this.setHardness(2); 35 | this.setResistance(10); 36 | this.setLightOpacity(0); //fixes the dark side bug 37 | } 38 | 39 | @Override 40 | public IIcon getIcon(int s, int meta) { 41 | return Blocks.stone.getIcon(0, 0); 42 | } 43 | 44 | @Override 45 | public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { 46 | TileEntity te = world.getTileEntity(x, y, z); 47 | return te instanceof TileEntityGeoBlocks ? ((TileEntityGeoBlocks)te).getIcon() : Blocks.stone.getIcon(0, 0); 48 | } 49 | 50 | @Override 51 | public TileEntity createTileEntity(World world, int meta) { 52 | return new TileEntityGeoBlocks(); 53 | } 54 | 55 | @Override 56 | public boolean hasTileEntity(int meta) { 57 | return true; 58 | } 59 | 60 | @Override 61 | public final int colorMultiplier(IBlockAccess iba, int x, int y, int z) { 62 | TileEntityGeoBlocks te = (TileEntityGeoBlocks)iba.getTileEntity(x, y, z); 63 | //ReikaJavaLibrary.pConsole(rock); 64 | if (te != null && te.getRockType() == RockTypes.OPAL) { 65 | return GeoStrata.getOpalPositionColor(iba, x, y, z); 66 | } 67 | else { 68 | return super.colorMultiplier(iba, x, y, z); 69 | } 70 | } 71 | 72 | @Override 73 | public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean harvest) 74 | { 75 | if (harvest) 76 | this.harvestBlock(world, player, x, y, z, 0); 77 | return world.setBlockToAir(x, y, z); 78 | } 79 | 80 | @Override 81 | public void harvestBlock(World world, EntityPlayer ep, int x, int y, int z, int meta) 82 | { 83 | TileEntity tile = world.getTileEntity(x, y, z); 84 | if (tile instanceof TileEntityGeoBlocks) { 85 | TileEntityGeoBlocks te = (TileEntityGeoBlocks)tile; 86 | ItemStack is = new ItemStack(this, 1, ItemBlockAnyGeoVariant.getStack(te.getRockType(), te.getRockShape())); 87 | ReikaItemHelper.dropItem(world, x+0.5, y+0.5, z+0.5, is); 88 | } 89 | } 90 | 91 | @Override 92 | public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) 93 | { 94 | TileEntity tile = world.getTileEntity(target.blockX, target.blockY, target.blockZ); 95 | if (tile instanceof TileEntityGeoBlocks) { 96 | TileEntityGeoBlocks te = (TileEntityGeoBlocks)tile; 97 | return new ItemStack(this, 1, ItemBlockAnyGeoVariant.getStack(te.getRockType(), te.getRockShape())); 98 | } 99 | return null; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | 46 | [Dd]ebug/ 47 | [Rr]elease/ 48 | x64/ 49 | build/ 50 | [Bb]in/ 51 | [Oo]bj/ 52 | 53 | # MSTest test Results 54 | [Tt]est[Rr]esult*/ 55 | [Bb]uild[Ll]og.* 56 | 57 | *_i.c 58 | *_p.c 59 | *.ilk 60 | *.meta 61 | *.obj 62 | *.pch 63 | *.pdb 64 | *.pgc 65 | *.pgd 66 | *.rsp 67 | *.sbr 68 | *.tlb 69 | *.tli 70 | *.tlh 71 | *.tmp 72 | *.tmp_proj 73 | *.log 74 | *.vspscc 75 | *.vssscc 76 | .builds 77 | *.pidb 78 | *.log 79 | *.scc 80 | 81 | # Visual C++ cache files 82 | ipch/ 83 | *.aps 84 | *.ncb 85 | *.opensdf 86 | *.sdf 87 | *.cachefile 88 | 89 | # Visual Studio profiler 90 | *.psess 91 | *.vsp 92 | *.vspx 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | 101 | # TeamCity is a build add-in 102 | _TeamCity* 103 | 104 | # DotCover is a Code Coverage Tool 105 | *.dotCover 106 | 107 | # NCrunch 108 | *.ncrunch* 109 | .*crunch*.local.xml 110 | 111 | # Installshield output folder 112 | [Ee]xpress/ 113 | 114 | # DocProject is a documentation generator add-in 115 | DocProject/buildhelp/ 116 | DocProject/Help/*.HxT 117 | DocProject/Help/*.HxC 118 | DocProject/Help/*.hhc 119 | DocProject/Help/*.hhk 120 | DocProject/Help/*.hhp 121 | DocProject/Help/Html2 122 | DocProject/Help/html 123 | 124 | # Click-Once directory 125 | publish/ 126 | 127 | # Publish Web Output 128 | *.Publish.xml 129 | *.pubxml 130 | 131 | # NuGet Packages Directory 132 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 133 | #packages/ 134 | 135 | # Windows Azure Build Output 136 | csx 137 | *.build.csdef 138 | 139 | # Windows Store app package directory 140 | AppPackages/ 141 | 142 | # Others 143 | sql/ 144 | *.Cache 145 | ClientBin/ 146 | [Ss]tyle[Cc]op.* 147 | ~$* 148 | *~ 149 | *.dbmdl 150 | *.[Pp]ublish.xml 151 | *.pfx 152 | *.publishsettings 153 | 154 | # RIA/Silverlight projects 155 | Generated_Code/ 156 | 157 | # Backup & report files from converting an old project file to a newer 158 | # Visual Studio version. Backup files are not needed, because we have git ;-) 159 | _UpgradeReport_Files/ 160 | Backup*/ 161 | UpgradeLog*.XML 162 | UpgradeLog*.htm 163 | 164 | # SQL Server files 165 | App_Data/*.mdf 166 | App_Data/*.ldf 167 | 168 | ############# 169 | ## Windows detritus 170 | ############# 171 | 172 | # Windows image file caches 173 | Thumbs.db 174 | ehthumbs.db 175 | 176 | # Folder config file 177 | Desktop.ini 178 | 179 | # Recycle Bin used on file shares 180 | $RECYCLE.BIN/ 181 | 182 | # Mac crap 183 | .DS_Store 184 | 185 | 186 | ############# 187 | ## Python 188 | ############# 189 | 190 | *.py[co] 191 | 192 | # Packages 193 | *.egg 194 | *.egg-info 195 | dist/ 196 | build/ 197 | eggs/ 198 | parts/ 199 | var/ 200 | sdist/ 201 | develop-eggs/ 202 | .installed.cfg 203 | 204 | # Installer logs 205 | pip-log.txt 206 | 207 | # Unit test / coverage reports 208 | .coverage 209 | .tox 210 | 211 | #Translations 212 | *.mo 213 | 214 | #Mr Developer 215 | .mr.developer.cfg 216 | -------------------------------------------------------------------------------- /Blocks/BlockGeoSlab.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Blocks; 11 | 12 | import net.minecraft.block.BlockSlab; 13 | import net.minecraft.block.material.Material; 14 | import net.minecraft.entity.player.EntityPlayer; 15 | import net.minecraft.init.Blocks; 16 | import net.minecraft.item.ItemStack; 17 | import net.minecraft.tileentity.TileEntity; 18 | import net.minecraft.util.IIcon; 19 | import net.minecraft.util.MovingObjectPosition; 20 | import net.minecraft.world.IBlockAccess; 21 | import net.minecraft.world.World; 22 | 23 | import Reika.DragonAPI.Libraries.Registry.ReikaItemHelper; 24 | import Reika.GeoStrata.GeoStrata; 25 | import Reika.GeoStrata.TileEntityGeoBlocks; 26 | import Reika.GeoStrata.Items.ItemBlockAnyGeoVariant; 27 | import Reika.GeoStrata.Registry.RockTypes; 28 | 29 | public class BlockGeoSlab extends BlockSlab { 30 | 31 | public BlockGeoSlab(Material mat) { 32 | super(false, mat); 33 | this.setCreativeTab(GeoStrata.tabGeoSlabs); 34 | this.setHardness(2); 35 | this.setResistance(10); 36 | } 37 | 38 | @Override 39 | public String func_150002_b(int p_150002_1_) { 40 | return ""; 41 | } 42 | 43 | @Override 44 | public IIcon getIcon(int s, int meta) { 45 | return Blocks.stone.getIcon(0, 0); 46 | } 47 | 48 | @Override 49 | public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { 50 | TileEntity te = world.getTileEntity(x, y, z); 51 | return te instanceof TileEntityGeoBlocks ? ((TileEntityGeoBlocks)te).getIcon() : Blocks.stone.getIcon(0, 0); 52 | } 53 | 54 | @Override 55 | public TileEntity createTileEntity(World world, int meta) { 56 | return new TileEntityGeoBlocks(); 57 | } 58 | 59 | @Override 60 | public boolean hasTileEntity(int meta) { 61 | return true; 62 | } 63 | 64 | @Override 65 | public final int colorMultiplier(IBlockAccess iba, int x, int y, int z) { 66 | TileEntityGeoBlocks te = (TileEntityGeoBlocks)iba.getTileEntity(x, y, z); 67 | RockTypes rock = te.getRockType(); 68 | //ReikaJavaLibrary.pConsole(rock); 69 | if (rock == RockTypes.OPAL) { 70 | return GeoStrata.getOpalPositionColor(iba, x, y, z); 71 | } 72 | else { 73 | return super.colorMultiplier(iba, x, y, z); 74 | } 75 | } 76 | 77 | @Override 78 | public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean harvest) 79 | { 80 | if (harvest) 81 | this.harvestBlock(world, player, x, y, z, 0); 82 | return world.setBlockToAir(x, y, z); 83 | } 84 | 85 | @Override 86 | public void harvestBlock(World world, EntityPlayer ep, int x, int y, int z, int meta) 87 | { 88 | TileEntity tile = world.getTileEntity(x, y, z); 89 | if (tile instanceof TileEntityGeoBlocks) { 90 | TileEntityGeoBlocks te = (TileEntityGeoBlocks)tile; 91 | ItemStack is = new ItemStack(this, 1, ItemBlockAnyGeoVariant.getStack(te.getRockType(), te.getRockShape())); 92 | ReikaItemHelper.dropItem(world, x+0.5, y+0.5, z+0.5, is); 93 | } 94 | } 95 | 96 | @Override 97 | public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) 98 | { 99 | TileEntity tile = world.getTileEntity(target.blockX, target.blockY, target.blockZ); 100 | if (tile instanceof TileEntityGeoBlocks) { 101 | TileEntityGeoBlocks te = (TileEntityGeoBlocks)tile; 102 | return new ItemStack(this, 1, ItemBlockAnyGeoVariant.getStack(te.getRockType(), te.getRockShape())); 103 | } 104 | return null; 105 | } 106 | 107 | @Override 108 | public boolean isOpaqueCube() { 109 | return false; 110 | } 111 | 112 | @Override 113 | public boolean renderAsNormalBlock() { 114 | return false; 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /Rendering/CreepvineRenderer.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Rendering; 11 | 12 | import java.util.Random; 13 | 14 | import net.minecraft.block.Block; 15 | import net.minecraft.client.renderer.RenderBlocks; 16 | import net.minecraft.client.renderer.Tessellator; 17 | import net.minecraft.util.IIcon; 18 | import net.minecraft.world.ChunkCoordIntPair; 19 | import net.minecraft.world.IBlockAccess; 20 | 21 | import Reika.DragonAPI.Base.ISBRH; 22 | import Reika.DragonAPI.Libraries.Java.ReikaRandomHelper; 23 | import Reika.DragonAPI.Libraries.Rendering.ReikaRenderHelper; 24 | import Reika.GeoStrata.Blocks.BlockCreepvine; 25 | import Reika.GeoStrata.Blocks.BlockCreepvine.Pieces; 26 | 27 | 28 | public class CreepvineRenderer extends ISBRH { 29 | 30 | private final Random renderRand = new Random(); 31 | private final Random renderRandNoY = new Random(); 32 | 33 | public CreepvineRenderer(int id) { 34 | super(id); 35 | } 36 | 37 | @Override 38 | public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks rb) { 39 | renderRand.setSeed(ChunkCoordIntPair.chunkXZ2Int(x, z) ^ y); 40 | renderRand.nextBoolean(); 41 | renderRand.nextBoolean(); 42 | renderRandNoY.setSeed(ChunkCoordIntPair.chunkXZ2Int(x, z)); 43 | renderRandNoY.nextBoolean(); 44 | renderRandNoY.nextBoolean(); 45 | float dx0 = (float)ReikaRandomHelper.getRandomPlusMinus(0, 0.25, renderRandNoY); 46 | float dz0 = (float)ReikaRandomHelper.getRandomPlusMinus(0, 0.25, renderRandNoY); 47 | float dy0 = (float)ReikaRandomHelper.getRandomPlusMinus(0.125, 0.0625, renderRandNoY); 48 | Tessellator.instance.addTranslation(dx0, dy0, dz0); 49 | 50 | Pieces piece = Pieces.list[world.getBlockMetadata(x, y, z)]; 51 | BlockCreepvine b = (BlockCreepvine)block; 52 | 53 | IIcon ico = b.blockIcon; 54 | double r = 0.5; 55 | double w = 0.0625; 56 | switch(piece) { 57 | case ROOT: 58 | ico = b.getRandomRootIcon(renderRand); 59 | break; 60 | case STEM: 61 | case STEM_EMPTY: 62 | ico = b.getRandomStemIcon(renderRand, piece == Pieces.STEM_EMPTY); 63 | break; 64 | case TOP_YOUNG: 65 | ico = b.getRandomTopIcon(renderRand, true); 66 | w = 0; 67 | r = 0.75; 68 | break; 69 | case TOP: 70 | ico = b.getRandomTopIcon(renderRand, false); 71 | w = 0.25; 72 | break; 73 | default: 74 | break; 75 | } 76 | if (piece.isCore()) { 77 | ico = b.blockIcon; 78 | w = 0.125; 79 | } 80 | Tessellator.instance.setColorOpaque_I(0xffffff); 81 | Tessellator.instance.setBrightness(b.getMixedBrightnessForBlock(world, x, y, z)); 82 | float dx = (float)ReikaRandomHelper.getRandomPlusMinus(0, 0.03125, renderRand); 83 | float dz = (float)ReikaRandomHelper.getRandomPlusMinus(0, 0.03125, renderRand); 84 | Tessellator.instance.addTranslation(dx, 0, dz); 85 | ReikaRenderHelper.renderCropTypeTex(world, x, y, z, ico, Tessellator.instance, rb, w, 1, r); 86 | 87 | if (piece == Pieces.TOP && world.getBlock(x, y+1, z) != b) { 88 | rb.renderMaxY = 0.9375; 89 | rb.renderFaceYPos(b, x, y, z, b.getBlockTop()); 90 | } 91 | 92 | int seeds = piece.getSeedCount(); 93 | if (seeds > 0) { 94 | Tessellator.instance.setBrightness(240); 95 | for (int i = 0; i < seeds; i++) { 96 | ReikaRenderHelper.renderCropTypeTex(world, x, y, z, b.getSeedIcon(i), Tessellator.instance, rb, ReikaRandomHelper.getRandomPlusMinus(0, 0.03125, renderRand), 1); 97 | } 98 | } 99 | 100 | Tessellator.instance.addTranslation(-dx, 0, -dz); 101 | 102 | Tessellator.instance.addTranslation(-dx0, -dy0, -dz0); 103 | return true; 104 | } 105 | 106 | @Override 107 | public boolean shouldRender3DInInventory(int modelId) { 108 | return false; 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /Blocks/BlockSmooth.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Blocks; 11 | 12 | import java.util.Locale; 13 | import java.util.Random; 14 | 15 | import net.minecraft.block.Block; 16 | import net.minecraft.client.renderer.texture.IIconRegister; 17 | import net.minecraft.init.Blocks; 18 | import net.minecraft.item.Item; 19 | import net.minecraft.world.World; 20 | 21 | import Reika.GeoStrata.GeoStrata; 22 | import Reika.GeoStrata.Base.RockBlock; 23 | import Reika.GeoStrata.Registry.RockShapes; 24 | import Reika.GeoStrata.Registry.RockTypes; 25 | 26 | public class BlockSmooth extends RockBlock { 27 | 28 | public BlockSmooth() { 29 | super(); 30 | //if (RockGenerator.instance.postConvertOres()) { 31 | // this.setTickRandomly(true); 32 | //} 33 | } 34 | 35 | @Override 36 | public final Item getItemDropped(int id, Random r, int fortune) { 37 | return Item.getItemFromBlock(RockTypes.getTypeFromID(this).getID(RockShapes.COBBLE)); 38 | } 39 | 40 | @Override 41 | public final int damageDropped(int meta) { 42 | return meta; 43 | } 44 | 45 | @Override 46 | public final int quantityDropped(Random r) { 47 | return 1; 48 | } 49 | /* 50 | @Override 51 | public int tickRate(World world) 52 | { 53 | return 1; 54 | }*/ 55 | /* 56 | @Override 57 | public TileEntity createTileEntity(World world, int meta) { 58 | return new TileEntityOreConverter(); 59 | } 60 | 61 | @Override 62 | public boolean hasTileEntity(int meta) { 63 | return true; 64 | } 65 | 66 | public static class TileEntityOreConverter extends TileEntity { 67 | 68 | @Override 69 | public void updateEntity() { 70 | BlockSmooth b = (BlockSmooth)worldObj.getBlock(xCoord, yCoord, zCoord); 71 | b.tick(worldObj, xCoord, yCoord, zCoord); 72 | worldObj.setTileEntity(xCoord, yCoord, zCoord, null); //delete self 73 | } 74 | 75 | }*/ 76 | /* 77 | @Override 78 | public void updateTick(World world, int x, int y, int z, Random rand) { 79 | if (RockGenerator.instance.postConvertOres() && rand.nextInt(100) == 0) { 80 | RockTypes r = RockTypes.getTypeFromID(this); 81 | for (int i = 0; i < 6; i++) { 82 | ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[i]; 83 | int dx = x+dir.offsetX; 84 | int dy = y+dir.offsetY; 85 | int dz = z+dir.offsetZ; 86 | Block b = world.getBlock(dx, dy, dz); 87 | int meta = world.getBlockMetadata(dx, dy, dz); 88 | if (ReikaBlockHelper.isOre(b, meta)) { 89 | this.checkAndConvertOre(world, dx, dy, dz, b, meta, r); 90 | } 91 | } 92 | } 93 | } 94 | /* 95 | private void checkAndConvertOre(World world, int x, int y, int z, Block b, int meta, RockTypes r) { 96 | int count = 0; 97 | for (int i = 0; i < 6; i++) { 98 | ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[i]; 99 | int dx = x+dir.offsetX; 100 | int dy = y+dir.offsetY; 101 | int dz = z+dir.offsetZ; 102 | Block b2 = world.getBlock(dx, dy, dz); 103 | if (b2 instanceof BlockSmooth) { 104 | count++; 105 | } 106 | } 107 | if (count >= 2) { 108 | TileEntityGeoOre te = new TileEntityGeoOre(); 109 | te.initialize(r, b, meta); 110 | world.setBlock(x, y, z, GeoBlocks.ORETILE.getBlockInstance()); 111 | world.setTileEntity(x, y, z, te); 112 | } 113 | } 114 | */ 115 | @Override 116 | public void registerBlockIcons(IIconRegister ico) { 117 | for (int i = 0; i < RockTypes.rockList.length; i++) { 118 | RockTypes r = RockTypes.rockList[i]; 119 | icons[i] = ico.registerIcon("GeoStrata:rock/"+r.getName().toLowerCase(Locale.ENGLISH)); 120 | GeoStrata.logger.debug("Adding "+r.getName()+" rock icon "+icons[i].getIconName()); 121 | } 122 | } 123 | 124 | @Override 125 | public boolean isReplaceableOreGen(World world, int x, int y, int z, Block target) { 126 | return target == this || target == Blocks.stone; 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /Registry/DecoBlocks.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Registry; 11 | 12 | import java.util.Locale; 13 | 14 | import net.minecraft.block.Block; 15 | import net.minecraft.init.Blocks; 16 | import net.minecraft.item.Item; 17 | import net.minecraft.item.Item.ToolMaterial; 18 | import net.minecraft.item.ItemStack; 19 | import net.minecraft.world.World; 20 | 21 | import Reika.DragonAPI.Libraries.Registry.ReikaItemHelper; 22 | import Reika.DragonAPI.ModInteract.ItemHandlers.MekToolHandler; 23 | import Reika.DragonAPI.ModInteract.ItemHandlers.TinkerToolHandler; 24 | 25 | import cpw.mods.fml.common.registry.GameRegistry; 26 | 27 | public enum DecoBlocks { 28 | OBSIDIBRICKS("Obsidian Bricks", 30F, 2000F, 1, ToolMaterial.EMERALD, Blocks.obsidian), 29 | QUARTZBRICKS("Nether Quartz Bricks", 1.2F, 5F, 2, ToolMaterial.IRON, Blocks.quartz_block), 30 | GLOWBRICKS("Glowstone Bricks", 0.75F, 3F, 2, ToolMaterial.WOOD, Blocks.glowstone), 31 | REDBRICKS("Redstone Bricks", 1F, 4F, 4, ToolMaterial.IRON, Blocks.redstone_block), 32 | LAPISBRICKS("Lapis Lazuli Bricks", 1F, 4F, 4, ToolMaterial.STONE, Blocks.lapis_block), 33 | EMERALDBRICKS("Emerald Bricks", 1F, 4F, 8, ToolMaterial.IRON, Blocks.emerald_block); 34 | 35 | private String name; 36 | private float blockHardness; 37 | private float blastResistance; 38 | private ToolMaterial mat; 39 | public final Block material; 40 | public final int recipeMultiplier; 41 | 42 | public static final DecoBlocks[] list = values(); 43 | 44 | private DecoBlocks(String n, float hard, float blast, int recipe, ToolMaterial tool, Block b) { 45 | name = n; 46 | mat = tool; 47 | blastResistance = blast; 48 | blockHardness = hard; 49 | material = b; 50 | recipeMultiplier = recipe; 51 | } 52 | 53 | public void addCrafting(Object... data) { 54 | GameRegistry.addRecipe(this.getItem(), data); 55 | } 56 | 57 | public void addSizedCrafting(int num, Object... data) { 58 | GameRegistry.addRecipe(ReikaItemHelper.getSizedItemStack(this.getItem(), num), data); 59 | } 60 | 61 | public ItemStack getItem() { 62 | return new ItemStack(GeoBlocks.DECO.getBlockInstance(), 1, this.ordinal()); 63 | } 64 | 65 | public String getName() { 66 | return name; 67 | } 68 | 69 | public String getTex() { 70 | return this.name().toLowerCase(Locale.ENGLISH); 71 | } 72 | 73 | public float getHardness() { 74 | return blockHardness; 75 | } 76 | 77 | public float getResistance() { 78 | return blastResistance; 79 | } 80 | 81 | public ToolMaterial getHarvestMin() { 82 | return mat; 83 | } 84 | 85 | public boolean isHarvestable(ItemStack held) { 86 | if (held == null) 87 | return mat == null; 88 | if (MekToolHandler.getInstance().isPickTypeTool(held)) 89 | return true; 90 | if (TinkerToolHandler.getInstance().isPick(held) || TinkerToolHandler.getInstance().isHammer(held)) { 91 | switch(mat) { 92 | case WOOD: 93 | return true; 94 | case STONE: 95 | case GOLD: 96 | return TinkerToolHandler.getInstance().isStoneOrBetter(held); 97 | case IRON: 98 | return TinkerToolHandler.getInstance().isIronOrBetter(held); 99 | case EMERALD: 100 | return TinkerToolHandler.getInstance().isDiamondOrBetter(held); 101 | default: 102 | return false; 103 | } 104 | } 105 | Item i = held.getItem(); 106 | switch (mat) { 107 | case EMERALD: //Diamond 108 | return held.func_150998_b(Blocks.obsidian); 109 | case GOLD: 110 | return held.func_150998_b(Blocks.stone); 111 | case IRON: 112 | return held.func_150998_b(Blocks.gold_ore); 113 | case STONE: 114 | return held.func_150998_b(Blocks.iron_ore); 115 | case WOOD: 116 | return held.func_150998_b(Blocks.stone); 117 | } 118 | return false; 119 | } 120 | 121 | public static DecoBlocks getTypeAtCoords(World world, int x, int y, int z) { 122 | return list[world.getBlockMetadata(x, y, z)]; 123 | } 124 | 125 | public static DecoBlocks getTypeFromMetadata(int meta) { 126 | return list[meta]; 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /Rendering/LavaRockRenderer.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Rendering; 11 | 12 | import org.lwjgl.opengl.GL11; 13 | 14 | import net.minecraft.block.Block; 15 | import net.minecraft.client.renderer.RenderBlocks; 16 | import net.minecraft.client.renderer.Tessellator; 17 | import net.minecraft.init.Blocks; 18 | import net.minecraft.util.IIcon; 19 | import net.minecraft.world.IBlockAccess; 20 | import net.minecraftforge.common.util.ForgeDirection; 21 | 22 | import Reika.DragonAPI.Base.ISBRH; 23 | 24 | public class LavaRockRenderer extends ISBRH { 25 | 26 | public LavaRockRenderer(int id) { 27 | super(id); 28 | } 29 | 30 | @Override 31 | public void renderInventoryBlock(Block b, int metadata, int modelId, RenderBlocks rb) { 32 | Tessellator tessellator = Tessellator.instance; 33 | 34 | rb.renderMaxX = 1; 35 | rb.renderMinY = 0; 36 | rb.renderMaxZ = 1; 37 | rb.renderMinX = 0; 38 | rb.renderMinZ = 0; 39 | rb.renderMaxY = 1; 40 | 41 | GL11.glTranslatef(-0.5F, -0.5F, -0.5F); 42 | IIcon ico = Blocks.lava.getIcon(0, 0); 43 | tessellator.startDrawingQuads(); 44 | tessellator.setBrightness(240); 45 | tessellator.setNormal(0.0F, -1.0F, 0.0F); 46 | rb.renderFaceYNeg(b, 0.0D, 0.0D, 0.0D, ico); 47 | 48 | tessellator.setNormal(0.0F, 1.0F, 0.0F); 49 | rb.renderFaceYPos(b, 0.0D, 0.0D, 0.0D, ico); 50 | 51 | tessellator.setNormal(0.0F, 0.0F, -1.0F); 52 | rb.renderFaceZNeg(b, 0.0D, 0.0D, 0.0D, ico); 53 | 54 | tessellator.setNormal(0.0F, 0.0F, 1.0F); 55 | rb.renderFaceZPos(b, 0.0D, 0.0D, 0.0D, ico); 56 | 57 | tessellator.setNormal(-1.0F, 0.0F, 0.0F); 58 | rb.renderFaceXNeg(b, 0.0D, 0.0D, 0.0D, ico); 59 | 60 | tessellator.setNormal(1.0F, 0.0F, 0.0F); 61 | rb.renderFaceXPos(b, 0.0D, 0.0D, 0.0D, ico); 62 | tessellator.draw(); 63 | 64 | ico = b.getIcon(0, metadata); 65 | 66 | GL11.glTranslatef(0, 0, 1); 67 | 68 | GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); 69 | tessellator.startDrawingQuads(); 70 | tessellator.setNormal(0.0F, -1.0F, 0.0F); 71 | rb.renderFaceYNeg(b, 0.0D, -0.01D, 0.0D, ico); 72 | tessellator.draw(); 73 | 74 | tessellator.startDrawingQuads(); 75 | tessellator.setNormal(0.0F, 1.0F, 0.0F); 76 | rb.renderFaceYPos(b, 0.0D, 0.01D, 0.0D, ico); 77 | tessellator.draw(); 78 | 79 | tessellator.startDrawingQuads(); 80 | tessellator.setNormal(0.0F, 0.0F, -1.0F); 81 | rb.renderFaceZNeg(b, 0.0D, 0.0D, -0.01D, ico); 82 | tessellator.draw(); 83 | tessellator.startDrawingQuads(); 84 | tessellator.setNormal(0.0F, 0.0F, 1.0F); 85 | rb.renderFaceZPos(b, 0.0D, 0.0D, 0.01D, ico); 86 | tessellator.draw(); 87 | tessellator.startDrawingQuads(); 88 | tessellator.setNormal(-1.0F, 0.0F, 0.0F); 89 | rb.renderFaceXNeg(b, -0.01D, 0.0D, 0.0D, ico); 90 | tessellator.draw(); 91 | tessellator.startDrawingQuads(); 92 | tessellator.setNormal(1.0F, 0.0F, 0.0F); 93 | rb.renderFaceXPos(b, 0.01D, 0.0D, 0.0D, ico); 94 | tessellator.draw(); 95 | 96 | GL11.glTranslatef(0.5F, 0.5F, 0.5F); 97 | } 98 | 99 | @Override 100 | public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block b, int modelId, RenderBlocks rb) { 101 | Tessellator v5 = Tessellator.instance; 102 | int meta = world.getBlockMetadata(x, y, z); 103 | 104 | IIcon ico = Blocks.lava.getIcon(0, 0); 105 | v5.setBrightness(240); 106 | v5.setColorOpaque(255, 255, 255); 107 | if (b.shouldSideBeRendered(world, x, y-1, z, ForgeDirection.DOWN.ordinal())) 108 | rb.renderFaceYNeg(b, x, y, z, ico); 109 | if (b.shouldSideBeRendered(world, x, y+1, z, ForgeDirection.UP.ordinal())) 110 | rb.renderFaceYPos(b, x, y, z, ico); 111 | if (b.shouldSideBeRendered(world, x, y, z-1, ForgeDirection.NORTH.ordinal())) 112 | rb.renderFaceZNeg(b, x, y, z, ico); 113 | if (b.shouldSideBeRendered(world, x, y, z+1, ForgeDirection.SOUTH.ordinal())) 114 | rb.renderFaceZPos(b, x, y, z, ico); 115 | if (b.shouldSideBeRendered(world, x-1, y, z, ForgeDirection.WEST.ordinal())) 116 | rb.renderFaceXNeg(b, x, y, z, ico); 117 | if (b.shouldSideBeRendered(world, x+1, y, z, ForgeDirection.EAST.ordinal())) 118 | rb.renderFaceXPos(b, x, y, z, ico); 119 | 120 | rb.renderStandardBlockWithAmbientOcclusion(b, x, y, z, 1, 1, 1); 121 | return true; 122 | } 123 | 124 | @Override 125 | public boolean shouldRender3DInInventory(int modelId) { 126 | return true; 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /Rendering/GlowVineRenderer.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Rendering; 11 | 12 | import net.minecraft.block.Block; 13 | import net.minecraft.client.renderer.RenderBlocks; 14 | import net.minecraft.client.renderer.Tessellator; 15 | import net.minecraft.util.IIcon; 16 | import net.minecraft.world.IBlockAccess; 17 | import net.minecraftforge.common.util.ForgeDirection; 18 | 19 | import Reika.DragonAPI.Base.ISBRH; 20 | import Reika.GeoStrata.Blocks.BlockGlowingVines.TileGlowingVines; 21 | 22 | 23 | public class GlowVineRenderer extends ISBRH { 24 | 25 | public GlowVineRenderer(int id) { 26 | super(id); 27 | } 28 | 29 | @Override 30 | public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { 31 | 32 | } 33 | 34 | @Override 35 | public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks rb) { 36 | if (renderPass != 1) 37 | return false; 38 | int dx = (x%4+4)%4; 39 | int dy = (y%4+4)%4; 40 | int dz = (z%4+4)%4; 41 | Tessellator.instance.setBrightness(240); 42 | Tessellator.instance.setColorOpaque_I(0xffffff); 43 | TileGlowingVines te = (TileGlowingVines)world.getTileEntity(x, y, z); 44 | boolean flag = false; 45 | for (int i = 0; i < 6; i++) { 46 | if (te.hasSide(i)) { 47 | this.renderSide(world, x, y, z, block, rb, ForgeDirection.VALID_DIRECTIONS[i], dx, dy, dz); 48 | flag = true; 49 | } 50 | } 51 | return flag; 52 | } 53 | 54 | private void renderSide(IBlockAccess world, int x, int y, int z, Block b, RenderBlocks rb, ForgeDirection side, int dx, int dy, int dz) { 55 | Tessellator v5 = Tessellator.instance; 56 | IIcon ico = b.blockIcon; 57 | double o = 0.005; 58 | switch(side) { 59 | case DOWN: { 60 | float u = ico.getInterpolatedU(dx*4); 61 | float v = ico.getInterpolatedV(dz*4); 62 | float du = ico.getInterpolatedU((dx+1)*4); 63 | float dv = ico.getInterpolatedV((dz+1)*4); 64 | //ReikaJavaLibrary.pConsole(dx+","+dz+" ["+(dx+1)+","+(dz+1)+"] >> "+u+" & "+v+", "+du+ "& "+dv); 65 | v5.addVertexWithUV(x, y+o, z+1, u, dv); 66 | v5.addVertexWithUV(x+1, y+o, z+1, du, dv); 67 | v5.addVertexWithUV(x+1, y+o, z, du, v); 68 | v5.addVertexWithUV(x, y+o, z, u, v); 69 | break; 70 | } 71 | case UP: { 72 | float u = ico.getInterpolatedU(dx*4); 73 | float v = ico.getInterpolatedV(dz*4); 74 | float du = ico.getInterpolatedU((dx+1)*4); 75 | float dv = ico.getInterpolatedV((dz+1)*4); 76 | v5.addVertexWithUV(x, y+1-o, z, u, v); 77 | v5.addVertexWithUV(x+1, y+1-o, z, du, v); 78 | v5.addVertexWithUV(x+1, y+1-o, z+1, du, dv); 79 | v5.addVertexWithUV(x, y+1-o, z+1, u, dv); 80 | break; 81 | } 82 | case EAST: { 83 | float u = ico.getInterpolatedU(dy*4); 84 | float v = ico.getInterpolatedV(dz*4); 85 | float du = ico.getInterpolatedU((dy+1)*4); 86 | float dv = ico.getInterpolatedV((dz+1)*4); 87 | v5.addVertexWithUV(x+1-o, y, z+1, u, dv); 88 | v5.addVertexWithUV(x+1-o, y+1, z+1, du, dv); 89 | v5.addVertexWithUV(x+1-o, y+1, z, du, v); 90 | v5.addVertexWithUV(x+1-o, y, z, u, v); 91 | break; 92 | } 93 | case WEST: { 94 | float u = ico.getInterpolatedU(dy*4); 95 | float v = ico.getInterpolatedV(dz*4); 96 | float du = ico.getInterpolatedU((dy+1)*4); 97 | float dv = ico.getInterpolatedV((dz+1)*4); 98 | v5.addVertexWithUV(x+o, y, z, u, v); 99 | v5.addVertexWithUV(x+o, y+1, z, du, v); 100 | v5.addVertexWithUV(x+o, y+1, z+1, du, dv); 101 | v5.addVertexWithUV(x+o, y, z+1, u, dv); 102 | break; 103 | } 104 | case NORTH: { 105 | float u = ico.getInterpolatedU(dy*4); 106 | float v = ico.getInterpolatedV(dx*4); 107 | float du = ico.getInterpolatedU((dy+1)*4); 108 | float dv = ico.getInterpolatedV((dx+1)*4); 109 | v5.addVertexWithUV(x+1, y, z+o, u, dv); 110 | v5.addVertexWithUV(x+1, y+1, z+o, du, dv); 111 | v5.addVertexWithUV(x, y+1, z+o, du, v); 112 | v5.addVertexWithUV(x, y, z+o, u, v); 113 | break; 114 | } 115 | case SOUTH: { 116 | float u = ico.getInterpolatedU(dy*4); 117 | float v = ico.getInterpolatedV(dx*4); 118 | float du = ico.getInterpolatedU((dy+1)*4); 119 | float dv = ico.getInterpolatedV((dx+1)*4); 120 | v5.addVertexWithUV(x, y, z+1-o, u, v); 121 | v5.addVertexWithUV(x, y+1, z+1-o, du, v); 122 | v5.addVertexWithUV(x+1, y+1, z+1-o, du, dv); 123 | v5.addVertexWithUV(x+1, y, z+1-o, u, dv); 124 | break; 125 | } 126 | default: 127 | break; 128 | } 129 | } 130 | 131 | @Override 132 | public boolean shouldRender3DInInventory(int modelId) { 133 | return false; 134 | } 135 | 136 | } 137 | -------------------------------------------------------------------------------- /World/WorldGenGeoRock.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.World; 11 | 12 | import java.util.Random; 13 | 14 | import net.minecraft.block.Block; 15 | import net.minecraft.init.Blocks; 16 | import net.minecraft.util.MathHelper; 17 | import net.minecraft.world.World; 18 | import net.minecraft.world.gen.feature.WorldGenerator; 19 | 20 | import Reika.DragonAPI.Interfaces.Subgenerator; 21 | import Reika.GeoStrata.API.RockGenerationPatterns.RockGenerationPattern; 22 | import Reika.GeoStrata.API.RockProofStone; 23 | import Reika.GeoStrata.Base.RockBlock; 24 | import Reika.GeoStrata.Registry.GeoOptions; 25 | import Reika.GeoStrata.Registry.RockShapes; 26 | import Reika.GeoStrata.Registry.RockTypes; 27 | 28 | public class WorldGenGeoRock extends WorldGenerator implements Subgenerator { 29 | 30 | private final int size; 31 | private final RockTypes rock; 32 | private final Block overwrite; 33 | private final Block id; 34 | private final RockGenerationPattern generator; 35 | 36 | public WorldGenGeoRock(RockGenerationPattern p, RockTypes r, int size) { 37 | this.size = size; 38 | overwrite = Blocks.stone; 39 | rock = r; 40 | id = rock.getID(RockShapes.SMOOTH); 41 | generator = p; 42 | } 43 | 44 | @Override 45 | public boolean generate(World world, Random rand, int x, int y, int z) { 46 | int count = 0; 47 | float f = rand.nextFloat() * (float)Math.PI; 48 | double d0 = x + 8 + MathHelper.sin(f) * size / 8.0F; 49 | double d1 = x + 8 - MathHelper.sin(f) * size / 8.0F; 50 | double d2 = z + 8 + MathHelper.cos(f) * size / 8.0F; 51 | double d3 = z + 8 - MathHelper.cos(f) * size / 8.0F; 52 | double d4 = y + rand.nextInt(3) - 2; 53 | double d5 = y + rand.nextInt(3) - 2; 54 | 55 | for (int l = 0; l <= size; ++l) 56 | { 57 | double d6 = d0 + (d1 - d0) * l / size; 58 | double d7 = d4 + (d5 - d4) * l / size; 59 | double d8 = d2 + (d3 - d2) * l / size; 60 | double d9 = rand.nextDouble() * size / 16.0D; 61 | double d10 = (MathHelper.sin(l * (float)Math.PI / size) + 1.0F) * d9 + 1.0D; 62 | double d11 = (MathHelper.sin(l * (float)Math.PI / size) + 1.0F) * d9 + 1.0D; 63 | int i1 = MathHelper.floor_double(d6 - d10 / 2.0D); 64 | int j1 = MathHelper.floor_double(d7 - d11 / 2.0D); 65 | int k1 = MathHelper.floor_double(d8 - d10 / 2.0D); 66 | int l1 = MathHelper.floor_double(d6 + d10 / 2.0D); 67 | int i2 = MathHelper.floor_double(d7 + d11 / 2.0D); 68 | int j2 = MathHelper.floor_double(d8 + d10 / 2.0D); 69 | 70 | for (int dx = i1; dx <= l1; dx++) { 71 | double d12 = (dx + 0.5D - d6) / (d10 / 2.0D); 72 | if (d12 * d12 < 1.0D) { 73 | for (int dy = j1; dy <= i2; dy++) { 74 | double d13 = (dy + 0.5D - d7) / (d11 / 2.0D); 75 | if (d12 * d12 + d13 * d13 < 1.0D) { 76 | for (int dz = k1; dz <= j2; dz++) { 77 | double d14 = (dz + 0.5D - d8) / (d10 / 2.0D); 78 | if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D) { 79 | //if (this.isInChunk(x, z, dx, dz)) { 80 | Block b = world.getBlock(dx, dy, dz); 81 | int meta = world.getBlockMetadata(dx, dy, dz); 82 | if (this.canGenerateIn(world, dx, dy, dz, b, meta)) { 83 | //long time = System.nanoTime(); 84 | 85 | world.setBlock(dx, dy, dz, id, 0, 2); 86 | count++; 87 | 88 | //long time2 = System.nanoTime(); 89 | //long dur = time2-time; 90 | //ReikaJavaLibrary.pConsole(rock+" block set time for "+dx+", "+dy+", "+dz+": "+dur+" nanos: "+this.isInChunk(x, z, dx, dz)); 91 | }/* 92 | else if (RockGenerator.instance.generateOres() && ReikaBlockHelper.isOre(b, meta)) { 93 | TileEntityGeoOre te = new TileEntityGeoOre(); 94 | te.initialize(rock, b, meta); 95 | world.setBlock(dx, dy, dz, GeoBlocks.ORETILE.getBlockInstance()); 96 | world.setTileEntity(dx, dy, dz, te); 97 | }*/ 98 | //} 99 | } 100 | } 101 | } 102 | } 103 | } 104 | } 105 | } 106 | 107 | return count > 0; 108 | } 109 | 110 | /* 111 | private boolean isInChunk(int x, int z, int dx, int dz) { 112 | int cx = x >> 4; 113 | int cz = z >> 4; 114 | int dcx = dx >> 4; 115 | int dcz = dz >> 4; 116 | return cx == dcx && cz == dcz; 117 | }*/ 118 | 119 | private boolean canGenerateIn(World world, int x, int y, int z, Block b, int meta) { 120 | if (b instanceof RockProofStone && ((RockProofStone)b).blockRockGeneration(world, x, y, z, b, meta)) 121 | return false; 122 | if (!GeoOptions.OVERGEN.getState() && b instanceof RockBlock) 123 | return false; 124 | return b.isReplaceableOreGen(world, x, y, z, overwrite); 125 | } 126 | 127 | @Override 128 | public Object getParentGenerator() { 129 | return generator; 130 | } 131 | 132 | } 133 | -------------------------------------------------------------------------------- /TileEntityGeoOre.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata; 11 | 12 | import net.minecraft.block.Block; 13 | import net.minecraft.init.Blocks; 14 | import net.minecraft.item.ItemStack; 15 | import net.minecraft.nbt.NBTTagCompound; 16 | import net.minecraft.network.NetworkManager; 17 | import net.minecraft.network.Packet; 18 | import net.minecraft.network.play.server.S35PacketUpdateTileEntity; 19 | import net.minecraft.tileentity.TileEntity; 20 | import net.minecraft.util.IIcon; 21 | 22 | import Reika.DragonAPI.Interfaces.Registry.OreType; 23 | import Reika.DragonAPI.Libraries.Registry.ReikaOreHelper; 24 | import Reika.DragonAPI.ModRegistry.ModOreList; 25 | import Reika.GeoStrata.Registry.RockShapes; 26 | import Reika.GeoStrata.Registry.RockTypes; 27 | 28 | public class TileEntityGeoOre extends TileEntity { 29 | 30 | private RockTypes type; 31 | private ReikaOreHelper ore; 32 | private ModOreList modore; 33 | private Block block; 34 | private int metadata; 35 | 36 | @Override 37 | public boolean canUpdate() { 38 | return false; 39 | } 40 | 41 | public void initialize(RockTypes rock, Block b, int meta) { 42 | type = rock; 43 | ItemStack is = new ItemStack(b, 1, meta); 44 | ore = ReikaOreHelper.getFromVanillaOre(b); 45 | if (ore == null) 46 | ore = ReikaOreHelper.getEntryByOreDict(is); 47 | modore = ModOreList.getModOreFromOre(is); 48 | block = b; 49 | metadata = meta; 50 | } 51 | 52 | public RockTypes getType() { 53 | return type != null ? type : RockTypes.SHALE; 54 | } 55 | 56 | public IIcon getOreIcon(int side) { 57 | return block.getIcon(worldObj, xCoord, yCoord, zCoord, side); 58 | } 59 | 60 | public Block getOreBlock() { 61 | return block != null ? block : type != null ? type.getID(RockShapes.SMOOTH) : Blocks.stone; 62 | } 63 | 64 | public int getOreMeta() { 65 | return metadata; 66 | } 67 | 68 | @Override 69 | public void writeToNBT(NBTTagCompound NBT) { 70 | super.writeToNBT(NBT); 71 | 72 | NBT.setInteger("type", type.ordinal()); 73 | if (ore != null) 74 | NBT.setInteger("ore", ore.ordinal()); 75 | if (modore != null) 76 | NBT.setInteger("more", modore.ordinal()); 77 | NBT.setInteger("orem", metadata); 78 | NBT.setInteger("blockid", Block.getIdFromBlock(block)); 79 | } 80 | 81 | @Override 82 | public void readFromNBT(NBTTagCompound NBT) { 83 | super.readFromNBT(NBT); 84 | 85 | type = RockTypes.rockList[NBT.getInteger("type")]; 86 | modore = NBT.hasKey("more") ? ModOreList.oreList[NBT.getInteger("more")] : null; 87 | ore = NBT.hasKey("ore") ? ReikaOreHelper.oreList[NBT.getInteger("ore")] : null; 88 | metadata = NBT.getInteger("orem"); 89 | block = Block.getBlockById(NBT.getInteger("blockid")); 90 | if (block == null || block == Blocks.air) { //in case of NBT failure 91 | this.calculateBlock(); 92 | } 93 | } 94 | 95 | private void calculateBlock() { 96 | if (ore != null) { 97 | block = ore.getOreBlockInstance(); 98 | } 99 | else if (modore != null) { 100 | ItemStack is = modore.getFirstOreBlock(); 101 | block = Block.getBlockFromItem(is.getItem()); 102 | metadata = is.getItemDamage(); 103 | } 104 | } 105 | 106 | /** Single char names to minimize packet size */ 107 | private void writeToPacket(NBTTagCompound NBT) { 108 | NBT.setInteger("r", this.getType().ordinal()); 109 | if (ore != null) 110 | NBT.setInteger("a", ore.ordinal()); 111 | if (modore != null) 112 | NBT.setInteger("b", modore.ordinal()); 113 | NBT.setInteger("m", metadata); 114 | NBT.setInteger("i", Block.getIdFromBlock(block)); 115 | } 116 | 117 | private void readFromPacket(NBTTagCompound NBT) { 118 | type = RockTypes.rockList[NBT.getInteger("r")]; 119 | modore = NBT.hasKey("b") ? ModOreList.oreList[NBT.getInteger("b")] : null; 120 | ore = NBT.hasKey("a") ? ReikaOreHelper.oreList[NBT.getInteger("a")] : null; 121 | metadata = NBT.getInteger("m"); 122 | int id = NBT.getInteger("i"); 123 | block = Block.getBlockById(id); 124 | if (block == null || block == Blocks.air) { //in case of NBT failure 125 | this.calculateBlock(); 126 | } 127 | } 128 | 129 | @Override 130 | public Packet getDescriptionPacket() { 131 | NBTTagCompound NBT = new NBTTagCompound(); 132 | this.writeToPacket(NBT); 133 | S35PacketUpdateTileEntity pack = new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, NBT); 134 | return pack; 135 | } 136 | 137 | @Override 138 | public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity p) { 139 | this.readFromPacket(p.field_148860_e); 140 | } 141 | 142 | public OreType getOreType() { 143 | return modore != null ? modore : ore != null ? ore : null; 144 | } 145 | 146 | @Override 147 | public String toString() { 148 | return type+" "+block+":"+metadata+" ("+ore+" & "+modore+")"; 149 | } 150 | 151 | } 152 | -------------------------------------------------------------------------------- /World/RockGenerator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.World; 11 | 12 | import java.util.ArrayList; 13 | import java.util.Collections; 14 | import java.util.Comparator; 15 | import java.util.Random; 16 | 17 | import net.minecraft.world.World; 18 | import net.minecraft.world.chunk.IChunkProvider; 19 | 20 | import Reika.DragonAPI.Auxiliary.Trackers.WorldgenProfiler; 21 | import Reika.DragonAPI.Auxiliary.Trackers.WorldgenProfiler.WorldProfilerParent; 22 | import Reika.DragonAPI.Interfaces.RetroactiveGenerator; 23 | import Reika.DragonAPI.ModInteract.ReikaTwilightHelper; 24 | import Reika.GeoStrata.GeoStrata; 25 | import Reika.GeoStrata.API.RockGenerationPatterns.RockGenerationPattern; 26 | import Reika.GeoStrata.Registry.GeoOptions; 27 | import Reika.GeoStrata.Registry.RockTypes; 28 | 29 | public class RockGenerator implements RetroactiveGenerator { 30 | 31 | protected static final int BASE_GEN = 24; 32 | protected static final int VEIN_SIZE = 32; 33 | 34 | public static final RockGenerator instance = new RockGenerator(); 35 | 36 | //private final int oreControl; 37 | 38 | private final Comparator genSorter = new RockGenComparator(); 39 | 40 | private final ArrayList generators = new ArrayList(); 41 | 42 | private final RockParent[] parents = new RockParent[RockTypes.rockList.length]; 43 | 44 | protected RockGenerator() { 45 | //oreControl = GeoOptions.GEOORE.getValue(); 46 | 47 | for (int i = 0; i < parents.length; i++) { 48 | parents[i] = new RockParent(RockTypes.rockList[i]); 49 | } 50 | } 51 | 52 | public void registerProfilingSubgenerator(RockTypes r, RockGenerationPattern p, Object generator) { 53 | parents[r.ordinal()].pattern = p; 54 | WorldgenProfiler.registerGeneratorAsSubGenerator(parents[r.ordinal()], generator); 55 | } 56 | 57 | public void registerGenerationPattern(RockGenerationPattern p) { 58 | generators.add(p); 59 | Collections.sort(generators, genSorter); 60 | GeoStrata.logger.log("Adding rock generator "+p); 61 | } 62 | 63 | public void removeGenerator(RockGenerationPattern p) { 64 | generators.remove(p); 65 | GeoStrata.logger.log("Removing rock generator "+p); 66 | } 67 | 68 | @Override 69 | public final void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkgen, IChunkProvider provider) { 70 | if (generators.isEmpty()) { 71 | throw new IllegalStateException("No generators to run!"); 72 | } 73 | if (this.canGenInDimension(world.provider.dimensionId)) { 74 | this.generateRock(world, random, chunkX, chunkZ); 75 | } 76 | } 77 | 78 | private boolean canGenInDimension(int id) { 79 | if (id == 0) 80 | return true; 81 | if (id == 1 || id == -1) 82 | return false; 83 | if (id == ReikaTwilightHelper.getDimensionID()) 84 | return GeoOptions.TFGEN.getState(); 85 | return GeoOptions.DIMGEN.getState(); 86 | } 87 | 88 | private void generateRock(World world, Random random, int chunkX, int chunkZ) { 89 | chunkX *= 16; 90 | chunkZ *= 16; 91 | //ReikaJavaLibrary.pConsole("Calling chunk at "+chunkX+", "+chunkZ); 92 | //BiomeGenBase biome = world.getBiomeGenForCoords(chunkX, chunkZ); 93 | for (int k = 0; k < RockTypes.rockList.length; k++) { 94 | RockTypes geo = RockTypes.rockList[k]; 95 | this.generateRockType(geo, world, random, chunkX, chunkZ); 96 | } 97 | } 98 | 99 | protected void generateRockType(RockTypes geo, World world, Random random, int chunkX, int chunkZ) { 100 | for (RockGenerationPattern p : generators) { 101 | if (WorldgenProfiler.profilingEnabled()) 102 | WorldgenProfiler.startGenerator(world, parents[geo.ordinal()], chunkX >> 4, chunkZ >> 4); 103 | p.generateRockType(geo, world, random, chunkX, chunkZ); 104 | if (WorldgenProfiler.profilingEnabled()) 105 | WorldgenProfiler.onRunGenerator(world, parents[geo.ordinal()], chunkX >> 4, chunkZ >> 4); 106 | } 107 | } 108 | /* 109 | public final boolean postConvertOres() { 110 | return oreControl == 2; 111 | } 112 | 113 | public final boolean generateOres() { 114 | return oreControl >= 1; 115 | } 116 | 117 | public final boolean destroyOres() { 118 | return oreControl == -1; 119 | } 120 | */ 121 | @Override 122 | public final boolean canGenerateAt(World world, int chunkX, int chunkZ) { 123 | return true; 124 | } 125 | 126 | @Override 127 | public final String getIDString() { 128 | return "GeoStrata Rock"; 129 | } 130 | 131 | private static class RockGenComparator implements Comparator { 132 | 133 | @Override 134 | public int compare(RockGenerationPattern o1, RockGenerationPattern o2) { 135 | return o1.getOrderingIndex() == o2.getOrderingIndex() ? 0 : (o1.getOrderingIndex() > o2.getOrderingIndex() ? 1 : -1); 136 | } 137 | 138 | } 139 | 140 | private static class RockParent implements WorldProfilerParent { 141 | 142 | private final RockTypes type; 143 | private RockGenerationPattern pattern; 144 | 145 | private RockParent(RockTypes r) { 146 | this(r, null); 147 | } 148 | 149 | private RockParent(RockTypes r, RockGenerationPattern p) { 150 | type = r; 151 | pattern = p; 152 | } 153 | 154 | public final String getWorldgenProfilerID() { 155 | return type.getName()+" "+pattern.getClass().getName(); 156 | } 157 | 158 | } 159 | 160 | } 161 | -------------------------------------------------------------------------------- /Registry/GeoOptions.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Registry; 11 | 12 | import net.minecraft.util.MathHelper; 13 | 14 | import Reika.DragonAPI.Interfaces.Configuration.BooleanConfig; 15 | import Reika.DragonAPI.Interfaces.Configuration.DecimalConfig; 16 | import Reika.DragonAPI.Interfaces.Configuration.IntegerConfig; 17 | import Reika.DragonAPI.Interfaces.Configuration.StringConfig; 18 | import Reika.DragonAPI.Interfaces.Configuration.UserSpecificConfig; 19 | import Reika.GeoStrata.GeoStrata; 20 | 21 | public enum GeoOptions implements BooleanConfig, IntegerConfig, DecimalConfig, StringConfig, UserSpecificConfig { 22 | 23 | TFGEN("Generate Rock in the Twilight Forest", true), 24 | DIMGEN("Generate Rock in Other Dimensions", true), 25 | BOXRECIPES("Alternate Brick Recipes", false), 26 | DENSITY("Rock Density", 1F), 27 | VENTDENSITY("Vent Density", 1F), 28 | DECODENSITY("Decoration Density", 1F), 29 | CRYSTALDENSITY("Crystal Density", 1F), 30 | LAVAROCKDENSITY("Lava Rock Density", 1F), 31 | VINEDENSITY("Glowing Vine Density", 1F), 32 | RFDENSITY("Flux Crystal Density", 1F), 33 | //GEOORE("Ore Mode", 0), 34 | //RETROGEN("Retrogeneration", false), 35 | WAILA("Waila Overlay", true), 36 | OPALFREQ("Opal Color Frequency", 1F), 37 | OPALHUE("Opal Hue Offset (degrees)", 0), 38 | ROCKGEN("Rock Generation Pattern", "Legacy"), 39 | RFACTIVATE("Flux Crystal Requires Activation", false), //Whether a flux crystal requires activation to be used. What activation entails depends on the pack, and how the modified item is produced. 40 | OVERGEN("Rock Can Generate Into Other Rock", true), 41 | KELPBIOMEID("Kelp Forest Biome ID (0 To Disable)", 190), 42 | ARCTICBIOMEID("Arctic Spires Biome ID (0 To Disable)", 191), 43 | ; 44 | 45 | private String label; 46 | private boolean defaultState; 47 | private int defaultValue; 48 | private float defaultFloat; 49 | private String defaultString; 50 | private Class type; 51 | 52 | public static final GeoOptions[] optionList = GeoOptions.values(); 53 | 54 | private GeoOptions(String l, boolean d) { 55 | label = l; 56 | defaultState = d; 57 | type = boolean.class; 58 | } 59 | 60 | private GeoOptions(String l, int d) { 61 | label = l; 62 | defaultValue = d; 63 | type = int.class; 64 | } 65 | 66 | private GeoOptions(String l, float d) { 67 | label = l; 68 | defaultFloat = d; 69 | type = float.class; 70 | } 71 | 72 | private GeoOptions(String l, String d) { 73 | label = l; 74 | defaultString = d; 75 | type = String.class; 76 | } 77 | 78 | public boolean isBoolean() { 79 | return type == boolean.class; 80 | } 81 | 82 | public boolean isNumeric() { 83 | return type == int.class; 84 | } 85 | 86 | public boolean isDecimal() { 87 | return type == float.class; 88 | } 89 | 90 | public float getFloat() { 91 | return (Float)GeoStrata.config.getControl(this.ordinal()); 92 | } 93 | 94 | public Class getPropertyType() { 95 | return type; 96 | } 97 | 98 | public String getLabel() { 99 | return label; 100 | } 101 | 102 | public boolean getState() { 103 | return (Boolean)GeoStrata.config.getControl(this.ordinal()); 104 | } 105 | 106 | public int getValue() { 107 | return (Integer)GeoStrata.config.getControl(this.ordinal()); 108 | } 109 | 110 | public boolean isDummiedOut() { 111 | return type == null; 112 | } 113 | 114 | @Override 115 | public boolean getDefaultState() { 116 | return defaultState; 117 | } 118 | 119 | @Override 120 | public int getDefaultValue() { 121 | return defaultValue; 122 | } 123 | 124 | @Override 125 | public float getDefaultFloat() { 126 | return defaultFloat; 127 | } 128 | 129 | @Override 130 | public boolean isEnforcingDefaults() { 131 | return false; 132 | } 133 | 134 | @Override 135 | public boolean shouldLoad() { 136 | return true; 137 | } 138 | 139 | public static float getVentDensity() { 140 | return MathHelper.clamp_float(VENTDENSITY.getFloat(), 0.25F, 4F); 141 | } 142 | 143 | public static float getRockDensity() { 144 | return MathHelper.clamp_float(DENSITY.getFloat(), 0.5F, 4F); 145 | } 146 | 147 | public static float getLavaRockDensity() { 148 | return MathHelper.clamp_float(LAVAROCKDENSITY.getFloat(), 0.25F, 1F); 149 | } 150 | 151 | public static float getDecoDensity() { 152 | return MathHelper.clamp_float(DECODENSITY.getFloat(), 0.25F, 4F); 153 | } 154 | 155 | public static float getCrystalDensity() { 156 | return MathHelper.clamp_float(CRYSTALDENSITY.getFloat(), 0.25F, 2F); 157 | } 158 | 159 | public static float getVineDensity() { 160 | return MathHelper.clamp_float(VINEDENSITY.getFloat(), 0.125F, 8F); 161 | } 162 | 163 | public static float getRFCrystalDensity() { 164 | return MathHelper.clamp_float(RFDENSITY.getFloat(), 0, 2F); 165 | } 166 | 167 | @Override 168 | public boolean isUserSpecific() { 169 | switch(this) { 170 | case WAILA: 171 | case OPALFREQ: 172 | case OPALHUE: 173 | return true; 174 | default: 175 | return false; 176 | } 177 | } 178 | 179 | public boolean isString() { 180 | return type == String.class; 181 | } 182 | 183 | @Override 184 | public String getString() { 185 | return (String)GeoStrata.config.getControl(this.ordinal()); 186 | } 187 | 188 | @Override 189 | public String getDefaultString() { 190 | return defaultString; 191 | } 192 | 193 | } 194 | -------------------------------------------------------------------------------- /World/VentGenerator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.World; 11 | 12 | import java.util.Random; 13 | 14 | import net.minecraft.block.Block; 15 | import net.minecraft.init.Blocks; 16 | import net.minecraft.world.World; 17 | import net.minecraft.world.WorldType; 18 | import net.minecraft.world.chunk.IChunkProvider; 19 | 20 | import Reika.DragonAPI.Instantiable.Data.Proportionality; 21 | import Reika.DragonAPI.Instantiable.Data.WeightedRandom; 22 | import Reika.DragonAPI.Instantiable.Data.WeightedRandom.DynamicWeight; 23 | import Reika.DragonAPI.Interfaces.RetroactiveGenerator; 24 | import Reika.DragonAPI.Libraries.Java.ReikaRandomHelper; 25 | import Reika.DragonAPI.Libraries.World.ReikaBiomeHelper; 26 | import Reika.DragonAPI.Libraries.World.ReikaWorldHelper; 27 | import Reika.GeoStrata.Blocks.BlockVent.VentType; 28 | import Reika.GeoStrata.Registry.GeoBlocks; 29 | import Reika.GeoStrata.Registry.GeoOptions; 30 | 31 | public class VentGenerator implements RetroactiveGenerator { 32 | 33 | public static final VentGenerator instance = new VentGenerator(); 34 | 35 | private static final int PER_CHUNK = getVentAttemptsPerChunk(); //calls per chunk; vast majority fail 36 | 37 | private final WeightedRandom ventTypes = new WeightedRandom(); 38 | private final WeightedRandom ventTypesNether = new WeightedRandom(); 39 | 40 | private VentGenerator() { 41 | for (VentType v : VentType.list) { 42 | if (v.canGenerateInOverworld()) 43 | ventTypes.addDynamicEntry(new VentGen(v)); 44 | if (v.canGenerateInNether()) 45 | ventTypesNether.addDynamicEntry(new VentGen(v)); 46 | } 47 | } 48 | 49 | private String getRatiosAt(int y, boolean nether) { 50 | WeightedRandom wr = nether ? ventTypesNether : ventTypes; 51 | Proportionality p = new Proportionality(); 52 | for (VentGen gr : wr.getValues()) { 53 | double w = gr.type.getSpawnWeight(y, nether); 54 | p.addValue(gr.type, w); 55 | } 56 | return p.toString(); 57 | } 58 | 59 | private static int getVentAttemptsPerChunk() { 60 | return (int)(60*GeoOptions.getVentDensity()); 61 | } 62 | 63 | @Override 64 | public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { 65 | if (world.getWorldInfo().getTerrainType() != WorldType.FLAT) { 66 | chunkX *= 16; 67 | chunkZ *= 16; 68 | for (int i = 0; i < PER_CHUNK; i++) { 69 | int posX = chunkX + random.nextInt(16); 70 | int posZ = chunkZ + random.nextInt(16); 71 | int maxy = world.provider.dimensionId == -1 ? 128 : (world.provider.dimensionId == 1 ? 72 : 64); 72 | int posY = ReikaRandomHelper.getRandomBetween(4, maxy, random); 73 | if (random.nextBoolean()) { 74 | posY *= random.nextFloat(); 75 | } 76 | if (this.canGenerateAt(world, posX, posY, posZ)) { 77 | VentType v = this.getVentTypeFor(world, posX, posY, posZ, random); 78 | Block id = GeoBlocks.VENT.getBlockInstance(); 79 | int meta = v.ordinal(); 80 | world.setBlock(posX, posY, posZ, id, meta, 3); 81 | } 82 | } 83 | } 84 | } 85 | 86 | private VentType getVentTypeFor(World world, int posX, int posY, int posZ, Random random) { 87 | if (world.provider.dimensionId == 1) { 88 | return VentType.ENDER; 89 | } 90 | 91 | WeightedRandom wr = world.provider.dimensionId == -1 ? ventTypesNether : ventTypes; 92 | wr.setRNG(random); 93 | for (VentGen gr : wr.getValues()) { 94 | gr.calcWeight(world, posX, posY, posZ); 95 | } 96 | 97 | return wr.getRandomEntry().type; 98 | } 99 | 100 | public static boolean canGenerateAt(World world, int x, int y, int z) { 101 | Block ida = world.getBlock(x, y+1, z); 102 | if (ida != Blocks.air && !ReikaWorldHelper.softBlocks(world, x, y+1, z)) 103 | return false; 104 | return canGenerateIn(world, x, y, z); 105 | } 106 | 107 | public static boolean canGenerateIn(World world, int x, int y, int z) { 108 | Block id = world.getBlock(x, y, z); 109 | int meta = world.getBlockMetadata(x, y, z); 110 | if (id == Blocks.air) 111 | return false; 112 | if (id == Blocks.stone) 113 | return true; 114 | if (id == Blocks.dirt) 115 | return true; 116 | if (id == Blocks.gravel) 117 | return true; 118 | if (id == Blocks.netherrack) 119 | return true; 120 | if (id == Blocks.end_stone) 121 | return true; 122 | if (id == Blocks.cobblestone) 123 | return y < world.provider.getAverageGroundLevel()-10; 124 | return id.isReplaceableOreGen(world, x, y, z, Blocks.stone); 125 | } 126 | 127 | @Override 128 | public boolean canGenerateAt(World world, int chunkX, int chunkZ) { 129 | return true; 130 | } 131 | 132 | @Override 133 | public String getIDString() { 134 | return "GeoStrata Vents"; 135 | } 136 | 137 | private static class VentGen implements DynamicWeight { 138 | 139 | private final VentType type; 140 | 141 | private double weight; 142 | 143 | private VentGen(VentType v) { 144 | type = v; 145 | } 146 | 147 | private void calcWeight(World world, int x, int y, int z) { 148 | float f = Math.min(1, Math.max(0.25F, world.provider.getAverageGroundLevel()/64F)); 149 | weight = type.getSpawnWeight((int)(y/f), world.provider.dimensionId == -1); 150 | if (type == VentType.CRYO && !ReikaBiomeHelper.isSnowBiome(world.getBiomeGenForCoords(x, z))) { 151 | weight = 0; 152 | } 153 | } 154 | 155 | @Override 156 | public double getWeight() { 157 | return weight; 158 | } 159 | 160 | } 161 | 162 | } 163 | -------------------------------------------------------------------------------- /World/DecoGenerator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.World; 11 | 12 | import java.util.Random; 13 | 14 | import net.minecraft.init.Blocks; 15 | import net.minecraft.world.World; 16 | import net.minecraft.world.biome.BiomeGenBase; 17 | import net.minecraft.world.chunk.IChunkProvider; 18 | import net.minecraftforge.fluids.FluidRegistry; 19 | 20 | import Reika.DragonAPI.ModList; 21 | import Reika.DragonAPI.Interfaces.RetroactiveGenerator; 22 | import Reika.DragonAPI.Libraries.Java.ReikaRandomHelper; 23 | import Reika.DragonAPI.Libraries.MathSci.ReikaMathLibrary; 24 | import Reika.DragonAPI.Libraries.World.ReikaBiomeHelper; 25 | import Reika.DragonAPI.Libraries.World.ReikaWorldHelper; 26 | import Reika.GeoStrata.Blocks.BlockOreVein.VeinType; 27 | import Reika.GeoStrata.Registry.GeoBlocks; 28 | import Reika.GeoStrata.Registry.GeoOptions; 29 | 30 | public class DecoGenerator implements RetroactiveGenerator { 31 | 32 | public static final DecoGenerator instance = new DecoGenerator(); 33 | 34 | private static final int BASE_CHANCE = (int)(1/GeoOptions.getDecoDensity()); 35 | 36 | private DecoGenerator() { 37 | 38 | } 39 | 40 | @Override 41 | public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { 42 | 43 | chunkX *= 16; 44 | chunkZ *= 16; 45 | 46 | if (this.generateIn(world)) { 47 | for (int i = 0; i < Decorations.list.length; i++) { 48 | Decorations p = Decorations.list[i]; 49 | if (random.nextInt(Math.max(1, (int)(p.getGenerationChance()/GeoOptions.getDecoDensity()))) == 0) { 50 | int x = chunkX+random.nextInt(16)+8; 51 | int z = chunkZ+random.nextInt(16)+8; 52 | int y = world.getTopSolidOrLiquidBlock(x, z); 53 | if (p.isValidLocation(world, x, y, z)) { 54 | if (p.generate(world, x, y, z, random)) 55 | break; 56 | } 57 | } 58 | } 59 | } 60 | } 61 | 62 | private boolean generateIn(World world) { 63 | /* 64 | if (Math.abs(world.provider.dimensionId) <= 1) 65 | return true; 66 | if (world.provider.dimensionId == ExtraChromaIDs.DIMID.getValue()) 67 | return true; 68 | if (ModList.MYSTCRAFT.isLoaded() && ReikaMystcraftHelper.isMystAge(world)) { 69 | if (!MystPages.Pages.PLANTS.existsInWorld(world)) { 70 | return false; 71 | } 72 | }*/ 73 | return true; 74 | } 75 | 76 | @Override 77 | public boolean canGenerateAt(World world, int chunkX, int chunkZ) { 78 | return true; 79 | } 80 | 81 | @Override 82 | public String getIDString() { 83 | return "GeoStrata Decorations"; 84 | } 85 | 86 | public static enum Decorations { 87 | OCEANSPIKE(20), 88 | OCEANSPIKES(80), 89 | OREVEINS(1), 90 | ; 91 | 92 | public final int chancePerChunk; 93 | 94 | public static final Decorations[] list = values(); 95 | 96 | private Decorations(int c) { 97 | chancePerChunk = c; 98 | } 99 | 100 | public int getGenerationChance() { 101 | return chancePerChunk; 102 | } 103 | 104 | private boolean isValidLocation(World world, int x, int y, int z) { 105 | BiomeGenBase b = world.getBiomeGenForCoords(x, z); 106 | switch(this) { 107 | case OCEANSPIKE: 108 | case OCEANSPIKES: 109 | return ReikaBiomeHelper.isOcean(b) && ReikaWorldHelper.getDepthFromBelow(world, x, y-1, z, FluidRegistry.WATER) > 2; 110 | default: 111 | return true; 112 | } 113 | } 114 | 115 | private boolean generate(World world, int x, int y, int z, Random rand) { 116 | switch(this) { 117 | case OCEANSPIKE: 118 | int h = 0; 119 | int d = rand.nextInt(8); 120 | int min = ReikaRandomHelper.getRandomBetween(4, 7, rand); 121 | while (h < 15 && (world.getBlock(x, y+h+d, z) == Blocks.water || (h < min && world.getBlock(x, y+h+1, z) == Blocks.water))) { 122 | world.setBlock(x, y+h, z, GeoBlocks.DECOGEN.getBlockInstance(), 0, 3); 123 | h++; 124 | } 125 | return true; 126 | case OCEANSPIKES: 127 | int n = 4+rand.nextInt(9); 128 | for (int i = 0; i < n; i++) { 129 | int dx = ReikaRandomHelper.getRandomPlusMinus(x, 8, rand); 130 | int dz = ReikaRandomHelper.getRandomPlusMinus(z, 8, rand); 131 | int dy = world.getTopSolidOrLiquidBlock(dx, dz); 132 | OCEANSPIKE.generate(world, dx, dy, dz, rand); 133 | } 134 | return true; 135 | case OREVEINS: 136 | int amt = 16; 137 | int minY = 4; 138 | int maxY = 56; 139 | VeinType vein = VeinType.STONE; 140 | if (world.provider.dimensionId == -1) { 141 | vein = VeinType.NETHER; 142 | amt = 4; 143 | maxY = 126; 144 | } 145 | else if (world.provider.dimensionId == 1) { 146 | vein = VeinType.END; 147 | amt = 3; 148 | minY = 8; 149 | maxY = 64; 150 | } 151 | if (!vein.isEnabled()) 152 | return false; 153 | if (vein == VeinType.END && ModList.CHROMATICRAFT.isLoaded()) 154 | amt = ReikaMathLibrary.py3d(x, 0, z) <= 850 ? 0 : 6; 155 | for (int i = 0; i < amt; i++) { 156 | int dy = ReikaRandomHelper.getRandomBetween(minY, maxY, rand); 157 | int dx = ReikaRandomHelper.getRandomPlusMinus(x, 8, rand); 158 | int dz = ReikaRandomHelper.getRandomPlusMinus(z, 8, rand); 159 | if (world.getBlock(dx, dy, dz) == vein.template) { //exact block since texture match 160 | int adj = ReikaWorldHelper.countAdjacentBlocks(world, dx, dy, dz, Blocks.air, false); 161 | if (adj > 0 && adj < 3) 162 | world.setBlock(dx, dy, dz, GeoBlocks.OREVEIN.getBlockInstance(), vein.ordinal(), 3); 163 | } 164 | } 165 | return true; 166 | } 167 | return false; 168 | } 169 | } 170 | 171 | } 172 | -------------------------------------------------------------------------------- /World/CreepvineGenerator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.World; 11 | 12 | import java.util.Random; 13 | 14 | import net.minecraft.init.Blocks; 15 | import net.minecraft.world.World; 16 | import net.minecraft.world.chunk.IChunkProvider; 17 | 18 | import Reika.DragonAPI.Instantiable.Math.LobulatedCurve; 19 | import Reika.DragonAPI.Instantiable.Math.Noise.SimplexNoiseGenerator; 20 | import Reika.DragonAPI.Interfaces.RetroactiveGenerator; 21 | import Reika.DragonAPI.Libraries.Java.ReikaRandomHelper; 22 | import Reika.DragonAPI.Libraries.MathSci.ReikaMathLibrary; 23 | import Reika.DragonAPI.Libraries.World.ReikaBiomeHelper; 24 | import Reika.DragonAPI.Libraries.World.ReikaWorldHelper; 25 | import Reika.GeoStrata.GeoStrata; 26 | import Reika.GeoStrata.Blocks.BlockCreepvine; 27 | import Reika.GeoStrata.Blocks.BlockCreepvine.Pieces; 28 | import Reika.GeoStrata.Registry.GeoBlocks; 29 | 30 | public class CreepvineGenerator implements RetroactiveGenerator { 31 | 32 | public static final CreepvineGenerator instance = new CreepvineGenerator(); 33 | 34 | private SimplexNoiseGenerator mainNoise; 35 | private long seed; 36 | 37 | private CreepvineGenerator() { 38 | 39 | } 40 | 41 | @Override 42 | public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { 43 | 44 | chunkX *= 16; 45 | chunkZ *= 16; 46 | 47 | if (this.generateIn(world)) { 48 | this.setSeed(world); 49 | for (int i = 0; i < 64; i++) { 50 | int x = ReikaRandomHelper.getRandomBetween(chunkX, chunkX+15, random); 51 | int z = ReikaRandomHelper.getRandomBetween(chunkZ, chunkZ+15, random); 52 | int y = world.getTopSolidOrLiquidBlock(x, z); 53 | if (this.isValidLocation(world, x, y, z)) { 54 | if (this.generate(world, x, y, z, random, 6, 12, 0.6F, true)) { 55 | if (GeoStrata.kelpForest != null) { 56 | int maxR = 7; 57 | LobulatedCurve lb = LobulatedCurve.fromMinMaxRadii(3, maxR, 5, true); 58 | lb.generate(random); 59 | for (int a = -maxR; a <= maxR; a++) { 60 | for (int b = -maxR; b <= maxR; b++) { 61 | int dx = x+a; 62 | int dz = z+b; 63 | if (this.isValidLocation(world, dx, y, dz)) { 64 | double ang = Math.toDegrees(Math.atan2(b, a)); 65 | if (ReikaMathLibrary.py3d(a, 0, b) <= lb.getRadius(ang)) 66 | ReikaWorldHelper.setBiomeForXZ(world, dx, dz, GeoStrata.kelpForest, false); 67 | } 68 | } 69 | } 70 | } 71 | } 72 | } 73 | } 74 | } 75 | } 76 | 77 | private boolean isValidLocation(World world, int x, int y, int z) { 78 | return ReikaBiomeHelper.isOcean(world.getBiomeGenForCoords(x, z)) && instance.mainNoise.getValue(x, z) > 0.55; 79 | } 80 | 81 | public boolean generate(World world, int x, int y, int z, Random rand, int minHeight, int minHeightFertile, float fertileChance, boolean growFertile) { 82 | int y1 = y; 83 | while (y1 < 256 && world.getBlock(x, y1, z) != Blocks.water) { 84 | y1++; 85 | } 86 | int y2 = y1; 87 | while (world.getBlock(x, y2+1, z) == Blocks.water) { 88 | y2++; 89 | } 90 | if (y1 < 60 && y2 < 64 && BlockCreepvine.canGrowOn(world, x, y1-1, z)) { 91 | int diff = y2-y1; 92 | if (diff >= 8 && diff < 20) { 93 | int h = ReikaRandomHelper.getRandomBetween(minHeight, Math.min(diff-1, 16), rand); 94 | y2 = y1+h; 95 | boolean fertile = h >= minHeightFertile && rand.nextFloat() < fertileChance; 96 | world.setBlock(x, y1, z, GeoBlocks.CREEPVINE.getBlockInstance(), Pieces.ROOT.ordinal(), 2); 97 | //ReikaJavaLibrary.pConsole(h+">"+fertile); 98 | if (fertile) { 99 | int d1 = Math.min(5, h/3); 100 | int d2 = Math.min(4, h/3); 101 | int core = ReikaRandomHelper.getRandomBetween(y1+d1, y2-d2, rand); 102 | for (int dy = y1+1; dy < core; dy++) 103 | world.setBlock(x, dy, z, GeoBlocks.CREEPVINE.getBlockInstance(), Pieces.STEM_EMPTY.ordinal(), 2); 104 | world.setBlock(x, core, z, GeoBlocks.CREEPVINE.getBlockInstance(), (growFertile ? Pieces.CORE_5 : Pieces.CORE_EMPTY).ordinal(), 2); 105 | for (int dy = core+1; dy <= y2; dy++) 106 | world.setBlock(x, dy, z, GeoBlocks.CREEPVINE.getBlockInstance(), Pieces.TOP.ordinal(), 2); 107 | world.func_147451_t(x, core, z); 108 | } 109 | else { 110 | for (int dy = y1+1; dy < y2; dy++) 111 | world.setBlock(x, dy, z, GeoBlocks.CREEPVINE.getBlockInstance(), Pieces.STEM.ordinal(), 2); 112 | world.setBlock(x, y2, z, GeoBlocks.CREEPVINE.getBlockInstance(), Pieces.TOP_YOUNG.ordinal(), 2); 113 | } 114 | return true; 115 | } 116 | } 117 | return false; 118 | } 119 | 120 | private void setSeed(World world) { 121 | long s = world.getSeed(); 122 | if (seed != s || mainNoise == null) { 123 | seed = s; 124 | Random rand = new Random(seed); 125 | rand.nextBoolean(); 126 | mainNoise = (SimplexNoiseGenerator)new SimplexNoiseGenerator(seed).setFrequency(0.016); 127 | } 128 | } 129 | 130 | private boolean generateIn(World world) { 131 | /* 132 | if (Math.abs(world.provider.dimensionId) <= 1) 133 | return true; 134 | if (world.provider.dimensionId == ExtraChromaIDs.DIMID.getValue()) 135 | return true; 136 | if (ModList.MYSTCRAFT.isLoaded() && ReikaMystcraftHelper.isMystAge(world)) { 137 | if (!MystPages.Pages.PLANTS.existsInWorld(world)) { 138 | return false; 139 | } 140 | }*/ 141 | return true; 142 | } 143 | 144 | @Override 145 | public boolean canGenerateAt(World world, int chunkX, int chunkZ) { 146 | return true; 147 | } 148 | 149 | @Override 150 | public String getIDString() { 151 | return "Creepvine"; 152 | } 153 | 154 | } 155 | -------------------------------------------------------------------------------- /World/VoidOpalGenerator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.World; 11 | 12 | import java.util.HashSet; 13 | import java.util.Random; 14 | 15 | import net.minecraft.block.Block; 16 | import net.minecraft.init.Blocks; 17 | import net.minecraft.util.MathHelper; 18 | import net.minecraft.world.World; 19 | import net.minecraft.world.chunk.IChunkProvider; 20 | 21 | import Reika.ChromatiCraft.API.ChromatiAPI; 22 | import Reika.DragonAPI.ModList; 23 | import Reika.DragonAPI.Instantiable.Data.Immutable.Coordinate; 24 | import Reika.DragonAPI.Interfaces.RetroactiveGenerator; 25 | import Reika.DragonAPI.Libraries.MathSci.ReikaMathLibrary; 26 | import Reika.DragonAPI.Libraries.MathSci.ReikaPhysicsHelper; 27 | import Reika.GeoStrata.Registry.GeoBlocks; 28 | 29 | public class VoidOpalGenerator implements RetroactiveGenerator { 30 | 31 | public static final VoidOpalGenerator instance = new VoidOpalGenerator(); 32 | 33 | private VoidOpalGenerator() { 34 | 35 | } 36 | 37 | @Override 38 | public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { 39 | if (this.canGenerateAt(world, chunkX, chunkZ) && random.nextInt(3) == 0) { 40 | chunkX *= 16; 41 | chunkZ *= 16; 42 | int posX = chunkX + random.nextInt(16); 43 | int posZ = chunkZ + random.nextInt(16); 44 | int miny = 12; 45 | int maxy = 72; 46 | int posY = miny+random.nextInt(maxy-miny+1); 47 | if (this.tryGenerateAt(world, posX, posY, posZ, random)) { 48 | 49 | } 50 | } 51 | } 52 | 53 | public static boolean tryGenerateAt(World world, int x, int y, int z, Random rand) { 54 | Block ida = world.getBlock(x, y, z); 55 | if (ida != Blocks.air) 56 | return false; 57 | for (int i = 4; i <= 80; i++) { 58 | ida = world.getBlock(x, i, z); 59 | if (ida != Blocks.air) 60 | return false; 61 | } 62 | VoidOpalDeposit dep = new VoidOpalDeposit(rand.nextLong()); 63 | dep.calculate(world, x, y, z); 64 | if (dep.isEmpty(world)) { 65 | dep.generate(world); 66 | return true; 67 | } 68 | return false; 69 | } 70 | 71 | @Override 72 | public boolean canGenerateAt(World world, int chunkX, int chunkZ) { 73 | return world.provider.dimensionId == 1 && this.isAppropriateChunk(world, chunkX, chunkZ); 74 | } 75 | 76 | private boolean isAppropriateChunk(World world, int chunkX, int chunkZ) { 77 | if (ModList.CHROMATICRAFT.isLoaded() && ChromatiAPI.getAPI().worldgen().getEndIslandBias(world, chunkX, chunkZ) > 0) 78 | return false; 79 | return true; 80 | } 81 | 82 | @Override 83 | public String getIDString() { 84 | return "Void Opal"; 85 | } 86 | 87 | private static class VoidOpalDeposit { 88 | 89 | private final Random seed; 90 | 91 | private final double encasedThickness; 92 | 93 | private final HashSet blocks = new HashSet(); 94 | private final HashSet casing = new HashSet(); 95 | 96 | private VoidOpalDeposit(long s) { 97 | seed = new Random(s); 98 | seed.nextBoolean(); 99 | seed.nextBoolean(); 100 | encasedThickness = seed.nextDouble()*2+0.75;//seed.nextDouble()*4-0.5; 101 | } 102 | 103 | private void calculate(World world, int x, int y, int z) { 104 | /* 105 | double rx = 0; 106 | double ry = 0; 107 | double rz = 0; 108 | int rxi = MathHelper.ceiling_double_int(rx); 109 | int ryi = MathHelper.ceiling_double_int(ry); 110 | int rzi = MathHelper.ceiling_double_int(rz); 111 | for (int i = -rxi; i <= rxi; i++) { 112 | for (int j = -ryi; j <= ryi; j++) { 113 | for (int k = -rzi; k <= rzi; k++) { 114 | if (ReikaMathLibrary.isPointInsideEllipse(i+0.5, j+0.5, k+0.5, rx, ry, rz)) { 115 | int dx = x+i; 116 | int dy = y+j; 117 | int dz = z+k; 118 | blocks.add(new Coordinate(dx, dy, dz)); 119 | } 120 | } 121 | } 122 | } 123 | */ 124 | int nspikes = 5+seed.nextInt(6); 125 | for (int i = 0; i < nspikes; i++) { 126 | double phi = seed.nextDouble()*360; 127 | double theta = seed.nextDouble()*360; 128 | double len = 3+5*seed.nextDouble(); 129 | double r0 = 0.375+seed.nextDouble()*0.5; 130 | double r1 = r0+0.5+seed.nextDouble(); 131 | double[] xyz = ReikaPhysicsHelper.polarToCartesian(1, theta, phi); 132 | for (double d = 0; d <= len; d += 0.25) { 133 | double dx = x+xyz[0]*d; 134 | double dy = y+xyz[1]*d; 135 | double dz = z+xyz[2]*d; 136 | this.generateBallAt(world, dx, dy, dz, ReikaMathLibrary.linterpolate(d, 0, len, r1, r0)); 137 | } 138 | } 139 | } 140 | 141 | private void generateBallAt(World world, double x, double y, double z, double r) { 142 | for (double i = -r; i <= r; i += 0.5) { 143 | for (double j = -r; j <= r; j += 0.5) { 144 | for (double k = -r; k <= r; k += 0.5) { 145 | if (ReikaMathLibrary.py3d(i, j, k) <= r) { 146 | int dx = MathHelper.floor_double(x+i); 147 | int dy = MathHelper.floor_double(y+j); 148 | int dz = MathHelper.floor_double(z+k); 149 | blocks.add(new Coordinate(dx, dy, dz)); 150 | } 151 | } 152 | } 153 | } 154 | if (encasedThickness > 0) { 155 | r += encasedThickness; 156 | for (double i = -r; i <= r; i += 0.5) { 157 | for (double j = -r; j <= r; j += 0.5) { 158 | for (double k = -r; k <= r; k += 0.5) { 159 | if (ReikaMathLibrary.py3d(i, j, k) <= r) { 160 | int dx = MathHelper.floor_double(x+i); 161 | int dy = MathHelper.floor_double(y+j); 162 | int dz = MathHelper.floor_double(z+k); 163 | Coordinate cc = new Coordinate(dx, dy, dz); 164 | if (!blocks.contains(cc)) 165 | casing.add(cc); 166 | } 167 | } 168 | } 169 | } 170 | } 171 | } 172 | 173 | private boolean isEmpty(World world) { 174 | for (Coordinate c : blocks) { 175 | if (!c.isEmpty(world)) 176 | return false; 177 | } 178 | return true; 179 | } 180 | 181 | private void generate(World world) { 182 | for (Coordinate c : casing) { 183 | c.setBlock(world, Blocks.end_stone, 0, 2); 184 | } 185 | for (Coordinate c : blocks) { 186 | c.setBlock(world, GeoBlocks.VOIDOPAL.getBlockInstance(), 0, 2); 187 | } 188 | } 189 | 190 | } 191 | 192 | } 193 | -------------------------------------------------------------------------------- /GeoRecipes.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata; 11 | 12 | import net.minecraft.init.Blocks; 13 | import net.minecraft.init.Items; 14 | import net.minecraft.item.ItemStack; 15 | import net.minecraftforge.oredict.ShapedOreRecipe; 16 | 17 | import Reika.DragonAPI.ModList; 18 | import Reika.DragonAPI.ASM.DependentMethodStripper.ModDependent; 19 | import Reika.DragonAPI.Libraries.ReikaRecipeHelper; 20 | import Reika.DragonAPI.Libraries.Registry.ReikaItemHelper; 21 | import Reika.GeoStrata.Registry.DecoBlocks; 22 | import Reika.GeoStrata.Registry.GeoBlocks; 23 | import Reika.GeoStrata.Registry.GeoOptions; 24 | import Reika.GeoStrata.Registry.RockShapes; 25 | import Reika.GeoStrata.Registry.RockTypes; 26 | 27 | import buildcraft.BuildCraftCore; 28 | import cpw.mods.fml.common.registry.GameRegistry; 29 | 30 | public class GeoRecipes { 31 | 32 | public static void addRecipes() { 33 | for (int i = 0; i < RockTypes.rockList.length; i++) { 34 | RockTypes type = RockTypes.rockList[i]; 35 | ItemStack smooth = type.getItem(RockShapes.SMOOTH); 36 | ItemStack cobble = type.getItem(RockShapes.COBBLE); 37 | ItemStack brick = type.getItem(RockShapes.BRICK); 38 | ItemStack fitted = type.getItem(RockShapes.FITTED); 39 | ItemStack tile = type.getItem(RockShapes.TILE); 40 | ItemStack round = type.getItem(RockShapes.ROUND); 41 | ItemStack engraved = type.getItem(RockShapes.ENGRAVED); 42 | ItemStack inscribed = type.getItem(RockShapes.INSCRIBED); 43 | ItemStack connected = type.getItem(RockShapes.CONNECTED); 44 | ItemStack connected2 = type.getItem(RockShapes.CONNECTED2); 45 | ItemStack etched = type.getItem(RockShapes.ETCHED); 46 | ItemStack centered = type.getItem(RockShapes.CENTERED); 47 | ItemStack cubed = type.getItem(RockShapes.CUBED); 48 | ItemStack lined = type.getItem(RockShapes.LINED); 49 | ItemStack embossed = type.getItem(RockShapes.EMBOSSED); 50 | ItemStack raised = type.getItem(RockShapes.RAISED); 51 | ItemStack fan = type.getItem(RockShapes.FAN); 52 | ItemStack spiral = type.getItem(RockShapes.SPIRAL); 53 | ItemStack moss = type.getItem(RockShapes.MOSSY); 54 | ItemStack pillar = type.getItem(RockShapes.PILLAR); 55 | 56 | GameRegistry.addRecipe(ReikaItemHelper.getSizedItemStack(brick, 4), new Object[]{ 57 | "SS", "SS", 'S', smooth}); 58 | GameRegistry.addRecipe(ReikaItemHelper.getSizedItemStack(round, 4), new Object[]{ 59 | "SS", "SS", 'S', brick}); 60 | GameRegistry.addRecipe(ReikaItemHelper.getSizedItemStack(fitted, 2), new Object[]{ 61 | "SS", 'S', brick}); 62 | GameRegistry.addRecipe(ReikaItemHelper.getSizedItemStack(tile, 4), new Object[]{ 63 | " S ", "S S", " S ", 'S', smooth}); 64 | GameRegistry.addRecipe(ReikaItemHelper.getSizedItemStack(inscribed, 3), new Object[]{ 65 | "B", "S", "B", 'S', smooth, 'B', brick}); 66 | GameRegistry.addRecipe(ReikaItemHelper.getSizedItemStack(engraved, 4), new Object[]{ 67 | "SB", "BS", 'S', smooth, 'B', brick}); 68 | GameRegistry.addRecipe(ReikaItemHelper.getSizedItemStack(engraved, 4), new Object[]{ 69 | "BS", "SB", 'S', smooth, 'B', brick}); 70 | GameRegistry.addRecipe(ReikaItemHelper.getSizedItemStack(connected, 8), new Object[]{ 71 | "SSS", "S S", "SSS", 'S', smooth}); 72 | GameRegistry.addRecipe(ReikaItemHelper.getSizedItemStack(connected2, 8), new Object[]{ 73 | "SSS", "S S", "SSS", 'S', connected}); 74 | GameRegistry.addRecipe(ReikaItemHelper.getSizedItemStack(etched, 3), new Object[]{ 75 | "SSS", 'S', inscribed}); 76 | GameRegistry.addRecipe(ReikaItemHelper.getSizedItemStack(cubed, 9), new Object[]{ 77 | "SSS", "SSS", "SSS", 'S', smooth}); 78 | GameRegistry.addRecipe(ReikaItemHelper.getSizedItemStack(centered, 5), new Object[]{ 79 | " S ", "SRS", " S ", 'S', smooth, 'R', round}); 80 | GameRegistry.addRecipe(ReikaItemHelper.getSizedItemStack(lined, 5), new Object[]{ 81 | " S ", "SES", " S ", 'S', smooth, 'E', engraved}); 82 | GameRegistry.addRecipe(ReikaItemHelper.getSizedItemStack(embossed, 3), new Object[]{ 83 | "S", "T", "S", 'S', smooth, 'T', tile}); 84 | GameRegistry.addRecipe(ReikaItemHelper.getSizedItemStack(raised, 4), new Object[]{ 85 | "SS", "SS", 'S', tile}); 86 | GameRegistry.addRecipe(ReikaItemHelper.getSizedItemStack(fan, 8), new Object[]{ 87 | "AAB", "B B", "BAA", 'A', smooth, 'B', brick}); 88 | GameRegistry.addRecipe(ReikaItemHelper.getSizedItemStack(spiral, 8), new Object[]{ 89 | "ABA", "B B", "ABA", 'A', smooth, 'B', brick}); 90 | GameRegistry.addRecipe(ReikaItemHelper.getSizedItemStack(moss, 2), new Object[]{ 91 | "AB", "BA", 'A', smooth, 'B', Blocks.vine}); 92 | GameRegistry.addRecipe(ReikaItemHelper.getSizedItemStack(pillar, 3), new Object[]{ 93 | "S", "S", "S", 'S', smooth}); 94 | 95 | for (int k = 0; k < RockShapes.shapeList.length; k++) { 96 | RockShapes shape = RockShapes.shapeList[k]; 97 | ItemStack item = type.getItem(shape); 98 | if (shape != RockShapes.SMOOTH) { 99 | ReikaRecipeHelper.addSmelting(item, smooth, 0F); 100 | } 101 | ItemStack stair = ReikaItemHelper.getSizedItemStack(type.getStair(shape), 4); 102 | ItemStack slab = ReikaItemHelper.getSizedItemStack(type.getSlab(shape), 6); 103 | GameRegistry.addRecipe(slab, "BBB", 'B', item); 104 | GameRegistry.addRecipe(stair, " B", " BB", "BBB", 'B', item); 105 | GameRegistry.addRecipe(stair, "B ", "BB ", "BBB", 'B', item); 106 | GameRegistry.addRecipe(item, "B", "B", 'B', slab); 107 | } 108 | //GameRegistry.addShapelessRecipe(new ItemStack(Blocks.cobblestone), cobble); 109 | } 110 | 111 | for (int i = 0; i < DecoBlocks.list.length; i++) { 112 | DecoBlocks block = DecoBlocks.list[i]; 113 | if (GeoOptions.BOXRECIPES.getState()) 114 | block.addSizedCrafting(8*block.recipeMultiplier, "BBB", "B B", "BBB", 'B', block.material); 115 | else 116 | block.addSizedCrafting(4*block.recipeMultiplier, "BB", "BB", 'B', block.material); 117 | } 118 | 119 | ItemStack g = new ItemStack(Items.stick); 120 | if (ModList.BUILDCRAFT.isLoaded()) 121 | g = getWoodGear(); 122 | GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(GeoBlocks.PARTIAL.getBlockInstance(), 24, 0), "BSB", "SPS", "gSg", 'P', Blocks.planks, 'S', "stone", 'B', Blocks.iron_bars, 'g', g)); 123 | 124 | } 125 | 126 | @ModDependent(ModList.BUILDCRAFT) 127 | private static ItemStack getWoodGear() { 128 | return new ItemStack(BuildCraftCore.woodenGearItem); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /API/RockGetter.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.API; 11 | 12 | import java.lang.reflect.Method; 13 | import java.util.ArrayList; 14 | import java.util.Collection; 15 | 16 | import net.minecraft.block.Block; 17 | import net.minecraft.item.ItemStack; 18 | 19 | public class RockGetter { 20 | 21 | private static Class modClass; 22 | private static Block[] geoBlocks; 23 | 24 | private static ArrayList rockBlocks; 25 | 26 | private static Class typeRegistry; 27 | private static Class shapeRegistry; 28 | 29 | private static Method getStackByShape; 30 | private static Method getBlockByShape; 31 | 32 | private static boolean init = false; 33 | 34 | static { 35 | try { 36 | modClass = Class.forName("Reika.GeoStrata.GeoStrata", false, RockGetter.class.getClassLoader()); 37 | geoBlocks = (Block[])modClass.getField("blocks").get(null); 38 | rockBlocks = (ArrayList)modClass.getField("rockBlocks").get(null); 39 | 40 | typeRegistry = Class.forName("Reika.GeoStrata.Registry.RockTypes"); 41 | shapeRegistry = Class.forName("Reika.GeoStrata.Registry.RockShapes"); 42 | 43 | getStackByShape = typeRegistry.getMethod("getItem", shapeRegistry); 44 | getBlockByShape = typeRegistry.getMethod("getID", shapeRegistry); 45 | 46 | init = true; 47 | } 48 | catch (ClassNotFoundException e) { 49 | System.out.println("GeoStrata class not found!"); 50 | e.printStackTrace(); 51 | } 52 | catch (IllegalArgumentException e) { 53 | System.out.println("GeoStrata class not read correctly!"); 54 | e.printStackTrace(); 55 | } 56 | catch (IllegalAccessException e) { 57 | System.out.println("GeoStrata class not read correctly!"); 58 | e.printStackTrace(); 59 | } 60 | catch (NoSuchMethodException e) { 61 | System.out.println("GeoStrata class not read correctly!"); 62 | e.printStackTrace(); 63 | } 64 | catch (NoSuchFieldException e) { 65 | System.out.println("GeoStrata class not read correctly!"); 66 | e.printStackTrace(); 67 | } 68 | catch (SecurityException e) { 69 | System.out.println("GeoStrata class not read correctly!"); 70 | e.printStackTrace(); 71 | } 72 | } 73 | 74 | /** Returns an itemstack of the specified rock type and shape. Refer to the GeoStrata "RockTypes" and "RockShapes" classes for valid options. 75 | * Many, but not all, shapes of the same rock are submetadatas of that parent block type. No block type represents two rock types. */ 76 | public static ItemStack getRockItem(String type, String shape) { 77 | if (!init) 78 | return null; 79 | try { 80 | Object rtype = Enum.valueOf(typeRegistry, type.toUpperCase()); 81 | Object rshape = Enum.valueOf(shapeRegistry, shape.toUpperCase()); 82 | return (ItemStack)getStackByShape.invoke(rtype, rshape); 83 | } 84 | catch (IllegalArgumentException e) { 85 | System.out.println("Invalid enum parameter!"); 86 | System.out.println("Valid rock types: "); 87 | Object[] types = typeRegistry.getEnumConstants(); 88 | for (int i = 0; i < types.length; i++) 89 | System.out.println("\t"+((Enum)types[i]).name()); 90 | System.out.println(""); 91 | System.out.println("Valid rock shapes: "); 92 | Object[] shapes = shapeRegistry.getEnumConstants(); 93 | for (int i = 0; i < shapes.length; i++) 94 | System.out.println("\t"+((Enum)shapes[i]).name()); 95 | e.printStackTrace(); 96 | return null; 97 | } 98 | catch (Exception e) { 99 | System.out.println("GeoStrata rock type "+type+" and shape "+shape+" threw exception while fetching!"); 100 | e.printStackTrace(); 101 | return null; 102 | } 103 | } 104 | 105 | /** Returns the block of the specified rock type and shape. Same result, but faster, as calling Block.getBlockFromItem(getRockItem().getItem()). 106 | * Args: String names of the two enum constants. */ 107 | public static Block getRockBlock(String type, String shape) { 108 | if (!init) 109 | return null; 110 | try { 111 | Object rtype = Enum.valueOf(typeRegistry, type.toUpperCase()); 112 | Object rshape = Enum.valueOf(shapeRegistry, shape.toUpperCase()); 113 | return (Block)getBlockByShape.invoke(rtype, rshape); 114 | } 115 | catch (IllegalArgumentException e) { 116 | System.out.println("Invalid enum parameter!"); 117 | System.out.println("Valid rock types: "); 118 | Object[] types = typeRegistry.getEnumConstants(); 119 | for (int i = 0; i < types.length; i++) 120 | System.out.println("\t"+((Enum)types[i]).name()); 121 | System.out.println(""); 122 | System.out.println("Valid rock shapes: "); 123 | Object[] shapes = shapeRegistry.getEnumConstants(); 124 | for (int i = 0; i < shapes.length; i++) 125 | System.out.println("\t"+((Enum)shapes[i]).name()); 126 | e.printStackTrace(); 127 | return null; 128 | } 129 | catch (Exception e) { 130 | System.out.println("GeoStrata rock type "+type+" and shape "+shape+" threw exception while fetching!"); 131 | e.printStackTrace(); 132 | return null; 133 | } 134 | } 135 | 136 | /** Shortcut for getting smooth (worldgen) rock. */ 137 | public static Block getSmoothRock(String type) { 138 | return getRockBlock(type, "SMOOTH"); 139 | } 140 | 141 | /** Returns all blocks representing the given rock type. */ 142 | public static Collection getAllBlocksFor(String type) { 143 | if (!init) 144 | return null; 145 | Object rtype = null; 146 | Collection c = new ArrayList(); 147 | try { 148 | rtype = Enum.valueOf(typeRegistry, type.toUpperCase()); 149 | } 150 | catch (IllegalArgumentException e) { 151 | System.out.println("Invalid rock type "+type+"!"); 152 | System.out.println("Valid rock types: "); 153 | Object[] types = typeRegistry.getEnumConstants(); 154 | for (int i = 0; i < types.length; i++) 155 | System.out.println("\t"+((Enum)types[i]).name()); 156 | return null; 157 | } 158 | Object[] shapes = shapeRegistry.getEnumConstants(); 159 | for (int i = 0; i < shapes.length; i++) { 160 | try { 161 | Block b = (Block)getBlockByShape.invoke(rtype, shapes[i]); 162 | if (!c.contains(b)) 163 | c.add(b); 164 | } 165 | catch (Exception e) { 166 | System.out.println("GeoStrata rock type "+type+" and shape "+shapes[i]+" threw exception while fetching its blocks!"); 167 | e.printStackTrace(); 168 | return null; 169 | } 170 | } 171 | return c; 172 | } 173 | 174 | public static boolean isGeoStrataRock(Block b) { 175 | if (!init) 176 | return false; 177 | return rockBlocks.contains(b); 178 | } 179 | 180 | } 181 | -------------------------------------------------------------------------------- /Registry/RockShapes.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Registry; 11 | 12 | import java.util.ArrayList; 13 | import java.util.EnumMap; 14 | import java.util.HashMap; 15 | import java.util.Locale; 16 | 17 | import net.minecraft.block.Block; 18 | import net.minecraft.world.IBlockAccess; 19 | 20 | import Reika.DragonAPI.Exception.RegistrationException; 21 | import Reika.DragonAPI.Instantiable.Data.Maps.BlockMap; 22 | import Reika.DragonAPI.ModInteract.LegacyWailaHelper; 23 | import Reika.GeoStrata.GeoStrata; 24 | import Reika.GeoStrata.Blocks.BlockConnectedRock; 25 | import Reika.GeoStrata.Blocks.BlockRockPillar; 26 | import Reika.GeoStrata.Blocks.BlockShapedRock; 27 | import Reika.GeoStrata.Blocks.BlockSmooth; 28 | import Reika.GeoStrata.Items.ItemBlockRock; 29 | 30 | import cpw.mods.fml.common.registry.GameRegistry; 31 | 32 | 33 | 34 | public enum RockShapes { 35 | 36 | SMOOTH(BlockSmooth.class, "Smooth"), 37 | COBBLE(BlockShapedRock.class, 0, "#Cobblestone"), 38 | BRICK(BlockShapedRock.class, 1, "#Bricks"), 39 | ROUND(BlockShapedRock.class, 2, "Round"), 40 | FITTED(BlockShapedRock.class, 3, "Fitted"), 41 | TILE(BlockShapedRock.class, 4, "Tile"), 42 | ENGRAVED(BlockShapedRock.class, 5, "Engraved"), 43 | INSCRIBED(BlockShapedRock.class, 6, "Inscribed"), 44 | CUBED(BlockShapedRock.class, 7, "Cubed"), 45 | LINED(BlockShapedRock.class, 8, "Lined"), 46 | EMBOSSED(BlockShapedRock.class, 9, "Embossed"), 47 | CENTERED(BlockShapedRock.class, 10, "Centered"), 48 | RAISED(BlockShapedRock.class, 11, "Raised"), 49 | ETCHED(BlockShapedRock.class, 12, "Etched"), 50 | SPIRAL(BlockShapedRock.class, 13, "Spiral"), 51 | FAN(BlockShapedRock.class, 14, "Fan"), 52 | MOSSY(BlockShapedRock.class, 15, "Mossy"), 53 | CONNECTED(BlockConnectedRock.class, "Connected"), 54 | CONNECTED2(BlockConnectedRock.class, "Connected 2"), 55 | PILLAR(BlockRockPillar.class, "Pillar"), 56 | ; 57 | 58 | //public final String typeName; 59 | //private final GeoBlocks blockType; 60 | private final Class blockClass; 61 | public final boolean needsOwnBlock; 62 | public final int metadata; 63 | private final int offset; 64 | public final String name; 65 | public final boolean nameFirst; 66 | 67 | public static final RockShapes[] shapeList = values(); 68 | private static final BlockMap shapeMap = new BlockMap(); 69 | private static final EnumMap> blockMap = new EnumMap(RockShapes.class); 70 | private static final HashMap> offsetMap = new HashMap(); 71 | 72 | /* 73 | private RockShapes(GeoBlocks b, String s) { 74 | typeName = s; 75 | blockType = b; 76 | }*/ 77 | 78 | private RockShapes(Class block, int meta, String n) { 79 | blockClass = block; 80 | metadata = meta >= 0 ? meta%16 : 0; 81 | offset = meta/16; 82 | needsOwnBlock = meta == -1; 83 | name = n.replaceAll("#", ""); 84 | nameFirst = n.startsWith("#"); 85 | } 86 | 87 | private RockShapes(Class block, String n) { 88 | this(block, -1, n); 89 | } 90 | 91 | public static RockShapes getShape(IBlockAccess world, int x, int y, int z) { 92 | return getShape(world.getBlock(x, y, z), world.getBlockMetadata(x, y, z)); 93 | } 94 | 95 | public static RockShapes getShape(Block id, int meta) { 96 | return shapeMap.get(id, meta); 97 | } 98 | 99 | public Block register(RockTypes r) { 100 | EnumMap map = blockMap.get(this); 101 | if (map == null) { 102 | map = new EnumMap(RockTypes.class); 103 | blockMap.put(this, map); 104 | if (!needsOwnBlock) { 105 | ArrayList li = offsetMap.get(offset); 106 | if (li == null) 107 | throw new RegistrationException(GeoStrata.instance, "Rock shape "+this+" has no pair mappings!"); 108 | for (int i = 0; i < li.size(); i++) { 109 | RockShapes s = li.get(i); 110 | blockMap.put(s, map); 111 | } 112 | } 113 | } 114 | 115 | if (map.containsKey(r)) { 116 | throw new RegistrationException(GeoStrata.instance, "Block type for "+r+" "+this+" was created twice!"); 117 | } 118 | else { 119 | try { 120 | Block b = (Block)blockClass.newInstance(); 121 | map.put(r, b); 122 | 123 | String name = "geostrata_rock_"+(r.name()+"_"+this.name()).toLowerCase(Locale.ENGLISH); 124 | b.setBlockName(name); 125 | GameRegistry.registerBlock(b, ItemBlockRock.class, name); 126 | b.setHardness(r.blockHardness); 127 | b.setResistance(r.blastResistance/3F); //compensate for the x3 128 | b.setHarvestLevel("pickaxe", r.harvestTool.ordinal()); 129 | LegacyWailaHelper.registerLegacyWAILACompat(b); 130 | return b; 131 | } 132 | catch (Exception e) { 133 | e.printStackTrace(); 134 | throw new RegistrationException(GeoStrata.instance, "Block type for "+r+" "+this+" could not be created: "+e.getLocalizedMessage()); 135 | } 136 | } 137 | } 138 | 139 | public static void initalize() { 140 | for (int k = 0; k < RockTypes.rockList.length; k++) { 141 | RockTypes r = RockTypes.rockList[k]; 142 | for (int i = 0; i < shapeList.length; i++) { 143 | RockShapes s = shapeList[i]; 144 | shapeMap.put(s.getBlock(r), s.metadata, s); 145 | } 146 | } 147 | } 148 | 149 | public boolean isRegistered(RockTypes r) { 150 | return this.getBlock(r) != null; 151 | } 152 | 153 | public Block getBlock(RockTypes r) { 154 | EnumMap map = blockMap.get(this); 155 | if (map == null || !map.containsKey(r)) 156 | return null; //throw new RegistrationException(GeoStrata.instance, "Rock shape "+this+" has no block for "+r+"!"); 157 | else 158 | return map.get(r); 159 | } 160 | 161 | static { 162 | for (int i = 0; i < shapeList.length; i++) { 163 | RockShapes s = shapeList[i]; 164 | int offset = s.needsOwnBlock ? -1 : s.offset; 165 | ArrayList li = offsetMap.get(offset); 166 | if (li == null) { 167 | li = new ArrayList(); 168 | offsetMap.put(offset, li); 169 | } 170 | li.add(s); 171 | } 172 | } 173 | 174 | public static int getNumberBlockTypes() { 175 | int count = 0; 176 | for (int i = 0; i < shapeList.length; i++) { 177 | RockShapes s = shapeList[i]; 178 | if (s.needsOwnBlock) { 179 | count++; 180 | } 181 | } 182 | count += 1+getHighestOffset(); 183 | return count; 184 | } 185 | 186 | private static int getHighestOffset() { 187 | int max = -1; 188 | for (int i = 0; i < shapeList.length; i++) { 189 | RockShapes s = shapeList[i]; 190 | max = Math.max(s.offset, max); 191 | } 192 | return max; 193 | } 194 | 195 | } 196 | -------------------------------------------------------------------------------- /World/LavaRockGeneratorRedesign.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.World; 11 | 12 | import java.util.Random; 13 | 14 | import net.minecraft.block.Block; 15 | import net.minecraft.init.Blocks; 16 | import net.minecraft.util.MathHelper; 17 | import net.minecraft.world.World; 18 | import net.minecraft.world.WorldType; 19 | import net.minecraft.world.chunk.Chunk; 20 | import net.minecraft.world.chunk.IChunkProvider; 21 | import net.minecraftforge.common.util.ForgeDirection; 22 | 23 | import Reika.DragonAPI.Instantiable.Data.BlockStruct.BlockArray; 24 | import Reika.DragonAPI.Instantiable.Data.Immutable.Coordinate; 25 | import Reika.DragonAPI.Instantiable.Math.Noise.SimplexNoiseGenerator; 26 | import Reika.DragonAPI.Interfaces.RetroactiveGenerator; 27 | import Reika.DragonAPI.Libraries.MathSci.ReikaMathLibrary; 28 | import Reika.GeoStrata.Registry.GeoBlocks; 29 | 30 | public class LavaRockGeneratorRedesign implements RetroactiveGenerator { 31 | 32 | public static final LavaRockGeneratorRedesign instance = new LavaRockGeneratorRedesign(); 33 | 34 | private SimplexNoiseGenerator lavaRockThickness; 35 | 36 | private LavaRockGeneratorRedesign() { 37 | 38 | } 39 | 40 | private void seedNoise(World world) { 41 | if (lavaRockThickness == null || lavaRockThickness.seed != world.getSeed()) { 42 | lavaRockThickness = new SimplexNoiseGenerator(world.getSeed()); 43 | lavaRockThickness.setFrequency(0.1); 44 | } 45 | } 46 | 47 | @Override 48 | public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { 49 | this.seedNoise(world); 50 | 51 | if (world.getWorldInfo().getTerrainType() != WorldType.FLAT && Math.abs(world.provider.dimensionId) != 1) { 52 | //double t = lavaRockThickness.getValue(dx, dz); 53 | Chunk c = world.getChunkFromChunkCoords(chunkX, chunkZ); 54 | for (int x = 0; x < 16; x++) { 55 | for (int z = 0; z < 16; z++) { 56 | for (int y = 1; y <= 14; y++) { 57 | Block b = c.getBlock(x, y, z); 58 | if (b.isReplaceableOreGen(world, x+chunkX*16, y, z+chunkZ*16, Blocks.stone) || b == GeoBlocks.LAVAROCK.getBlockInstance()) { 59 | int d = this.getLavaDistance(c, x, y, z); 60 | if (d <= 4) { 61 | this.placeBlock(c, x, y, z, d-1, b); 62 | } 63 | } 64 | } 65 | } 66 | } 67 | } 68 | } 69 | 70 | private void placeBlock(Chunk c, int x, int y, int z, int meta, Block at) { 71 | if (meta > 3) 72 | return; 73 | if (at == GeoBlocks.LAVAROCK.getBlockInstance() && meta >= c.getBlockMetadata(x, y, z)) { 74 | return; 75 | } 76 | c.func_150807_a(x, y, z, GeoBlocks.LAVAROCK.getBlockInstance(), meta); 77 | if (meta < 3) { 78 | int d = 1; 79 | for (int i = 0; i < 6; i++) { 80 | ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[i]; 81 | int dx = x+d*dir.offsetX; 82 | int dy = y+d*dir.offsetY; 83 | int dz = z+d*dir.offsetZ; 84 | if (dy >= 0 && dx >= 0 && dz >= 0 && dx < 16 && dz < 16) { 85 | Block b = c.getBlock(dx, dy, dz); 86 | if (b.isReplaceableOreGen(c.worldObj, x+c.xPosition*16, y, z+c.zPosition*16, Blocks.stone) || b == GeoBlocks.LAVAROCK.getBlockInstance()) { 87 | //ReikaJavaLibrary.pConsole("Placing "+(meta+1)+" from "+meta+" at "+new Coordinate(dx, dy, dz)); 88 | this.placeBlock(c, dx, dy, dz, meta+this.getMetaStep(c, dx, dy, dz), b); 89 | } 90 | } 91 | } 92 | } 93 | } 94 | 95 | private int getMetaStep(Chunk c, int cx, int y, int cz) { 96 | int x = cx+c.xPosition*16; 97 | int z = cz+c.zPosition*16; 98 | lavaRockThickness.setFrequency(0.1); 99 | double val = lavaRockThickness.getValue(x, z); 100 | return (int)MathHelper.clamp_double(ReikaMathLibrary.normalizeToBounds(val, 0.5, 3.5), 1, 3); 101 | } 102 | 103 | private int getLavaDistance(Chunk c, int x, int y, int z) { 104 | //int ret = Integer.MAX_VALUE; 105 | for (int d = 1; d <= 4; d++) { 106 | for (int i = 0; i < 6; i++) { 107 | ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[i]; 108 | int dx = x+d*dir.offsetX; 109 | int dy = y+d*dir.offsetY; 110 | int dz = z+d*dir.offsetZ; 111 | if (dy > 0 && dy <= 11 && dx >= 0 && dz >= 0 && dx < 16 && dz < 16) { 112 | Block b = c.getBlock(dx, dy, dz); 113 | int meta = c.getBlockMetadata(dx, dy, dz); 114 | if ((b == Blocks.lava || b == Blocks.flowing_lava) && meta == 0) { 115 | return d;//ret = Math.min(ret, d); 116 | }/* 117 | else if (b == GeoBlocks.LAVAROCK.getBlockInstance() && meta < 3) { 118 | if (ret != Integer.MAX_VALUE && ret > meta+2) //+2 because one is subtracted again above 119 | ReikaJavaLibrary.pConsole("Found lava rock with meta "+meta+", setting ret from "+ret+" to "+(meta+2)); 120 | ret = Math.min(ret, meta+2); 121 | }*/ 122 | } 123 | } 124 | //if (ret != Integer.MAX_VALUE) 125 | // return ret; 126 | } 127 | return Integer.MAX_VALUE;//ret; 128 | } 129 | 130 | private int getLavaDistance(World world, int x, int y, int z) { 131 | for (int d = 1; d <= 4; d++) { 132 | for (int i = 0; i < 6; i++) { 133 | ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[i]; 134 | int dx = x+d*dir.offsetX; 135 | int dy = y+d*dir.offsetY; 136 | int dz = z+d*dir.offsetZ; 137 | Block b = world.getBlock(dx, dy, dz); 138 | if (b == Blocks.lava || b == Blocks.flowing_lava) 139 | return d; 140 | } 141 | } 142 | return -1; 143 | } 144 | 145 | private void generate(World world, int x, int y, int z) { 146 | BlockArray b = new BlockArray(); 147 | b.maxDepth = 40; 148 | b.taxiCabDistance = true; 149 | //b.extraSpread = true; 150 | b.recursiveAddWithBounds(world, x, y, z, world.getBlock(x, y, z), x-16, y-8, z-24, x+16, y+8, z+24); 151 | BlockArray[] arrays = new BlockArray[4]; 152 | for (int i = 0; i < 4; i++) { 153 | BlockArray pre = i == 0 ? b : arrays[i-1]; 154 | arrays[i] = pre.copy(); 155 | arrays[i].expand(1, false); 156 | } 157 | for (int i = 0; i < 4; i++) { 158 | BlockArray pre = i == 0 ? b : arrays[i-1]; 159 | //arrays[i].XORWith(pre); 160 | } 161 | for (int i = 3; i >= 0; i--) { 162 | for (Coordinate c : arrays[i].keySet()) { 163 | Block bk = c.getBlock(world); 164 | if (bk.isReplaceableOreGen(world, c.xCoord, c.yCoord, c.zCoord, Blocks.stone) || bk == GeoBlocks.LAVAROCK.getBlockInstance()) { 165 | c.setBlock(world, GeoBlocks.LAVAROCK.getBlockInstance(), i); 166 | } 167 | } 168 | } 169 | } 170 | 171 | private boolean isValidBlock(World world, int x, int y, int z) { 172 | Block b = world.getBlock(x, y, z); 173 | return b == Blocks.lava || b == Blocks.flowing_lava; 174 | } 175 | 176 | @Override 177 | public boolean canGenerateAt(World world, int chunkX, int chunkZ) { 178 | return true; 179 | } 180 | 181 | @Override 182 | public String getIDString() { 183 | return "GeoStrata Lava Rock"; 184 | } 185 | 186 | } 187 | -------------------------------------------------------------------------------- /Blocks/BlockLavaRock.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Blocks; 11 | 12 | import java.util.ArrayList; 13 | import java.util.Collection; 14 | import java.util.List; 15 | 16 | import net.minecraft.block.Block; 17 | import net.minecraft.block.material.Material; 18 | import net.minecraft.client.renderer.texture.IIconRegister; 19 | import net.minecraft.creativetab.CreativeTabs; 20 | import net.minecraft.entity.Entity; 21 | import net.minecraft.entity.EntityLivingBase; 22 | import net.minecraft.entity.item.EntityItem; 23 | import net.minecraft.entity.item.EntityXPOrb; 24 | import net.minecraft.entity.player.EntityPlayer; 25 | import net.minecraft.init.Blocks; 26 | import net.minecraft.item.Item; 27 | import net.minecraft.item.ItemStack; 28 | import net.minecraft.potion.Potion; 29 | import net.minecraft.util.AxisAlignedBB; 30 | import net.minecraft.util.DamageSource; 31 | import net.minecraft.util.IIcon; 32 | import net.minecraft.world.IBlockAccess; 33 | import net.minecraft.world.World; 34 | import net.minecraftforge.common.util.ForgeDirection; 35 | 36 | import Reika.ChromatiCraft.API.Interfaces.CustomExcavationStarBehavior; 37 | import Reika.DragonAPI.Instantiable.Data.Immutable.BlockKey; 38 | import Reika.DragonAPI.Libraries.World.ReikaBlockHelper; 39 | import Reika.DragonAPI.Libraries.World.ReikaWorldHelper; 40 | import Reika.GeoStrata.GeoStrata; 41 | import Reika.GeoStrata.Registry.GeoISBRH; 42 | import Reika.GeoStrata.World.LavaRockGenerator; 43 | import Reika.RotaryCraft.API.Interfaces.EnvironmentalHeatSource; 44 | 45 | 46 | public class BlockLavaRock extends Block implements EnvironmentalHeatSource, CustomExcavationStarBehavior { 47 | 48 | private final IIcon[] overlay = new IIcon[4]; 49 | 50 | public BlockLavaRock(Material mat) { 51 | super(mat); 52 | 53 | this.setHardness(Blocks.stone.blockHardness); 54 | this.setResistance(Blocks.stone.blockResistance/3F); 55 | 56 | this.setCreativeTab(GeoStrata.tabGeo); 57 | } 58 | 59 | public static enum Flags { 60 | NONREPLACEABLE(); 61 | 62 | public int flag() { 63 | return 1 << (2+this.ordinal()); 64 | } 65 | 66 | public boolean applies(int meta) { 67 | return (meta & this.flag()) != 0; 68 | } 69 | } 70 | 71 | @Override 72 | public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { 73 | float maxY = 1; 74 | int meta = world.getBlockMetadata(x, y, z)%4; 75 | if (world.getBlock(x, y+1, z).isAir(world, x, y+1, z)) { 76 | switch(meta) { 77 | case 0: 78 | maxY = 1-0.125F+0.02F; 79 | break; 80 | case 1: 81 | maxY = 1-0.09375F; 82 | break; 83 | case 2: 84 | maxY = 1-0.0625F; 85 | break; 86 | } 87 | } 88 | this.setBlockBounds(0, 0, 0, 1, maxY, 1); 89 | } 90 | 91 | @Override 92 | public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) 93 | { 94 | float maxY = 1; 95 | int meta = world.getBlockMetadata(x, y, z)%4; 96 | switch(3-meta) { 97 | case 0: 98 | maxY = 1; 99 | break; 100 | case 1: 101 | maxY = 0.9375F; 102 | break; 103 | case 2: 104 | maxY = 0.875F; 105 | break; 106 | case 3: 107 | maxY = 0.75F; 108 | break; 109 | } 110 | return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + maxY, z + 1); 111 | } 112 | 113 | @Override 114 | public void getSubBlocks(Item id, CreativeTabs tab, List li) { 115 | for (int i = 0; i < 4; i++) { 116 | li.add(new ItemStack(this, 1, i)); 117 | } 118 | } 119 | 120 | @Override 121 | public int getRenderType() { 122 | return GeoISBRH.lavarock.getRenderID(); 123 | } 124 | 125 | @Override 126 | public boolean renderAsNormalBlock() { 127 | return false; 128 | } 129 | 130 | @Override 131 | public boolean isOpaqueCube() { 132 | return false; 133 | } 134 | 135 | @Override 136 | public IIcon getIcon(int s, int meta) { 137 | return overlay[meta%4]; 138 | } 139 | 140 | @Override 141 | public void registerBlockIcons(IIconRegister ico) { 142 | for (int i = 0; i < 4; i++) { 143 | overlay[i] = ico.registerIcon("geostrata:semilava/"+i); 144 | } 145 | } 146 | 147 | @Override 148 | public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity e) { 149 | if (e instanceof EntityItem || e instanceof EntityXPOrb) 150 | return; 151 | int meta = world.getBlockMetadata(x, y, z)%4; 152 | if (meta == 3) 153 | return; 154 | boolean doEffect = true; 155 | if (e instanceof EntityLivingBase) { 156 | doEffect = !((EntityLivingBase)e).isPotionActive(Potion.fireResistance); 157 | if (e instanceof EntityPlayer) { 158 | doEffect &= !((EntityPlayer)e).capabilities.isCreativeMode; 159 | } 160 | } 161 | if (doEffect) { 162 | e.attackEntityFrom(meta == 0 ? DamageSource.lava : DamageSource.inFire, 3-meta); 163 | if (meta == 0) { //lava is 15 164 | e.setFire(8); 165 | } 166 | else if (meta == 1) { 167 | e.setFire(4); 168 | } 169 | } 170 | } 171 | 172 | @Override 173 | public boolean isReplaceableOreGen(World world, int x, int y, int z, Block target) { 174 | if (Flags.NONREPLACEABLE.applies(world.getBlockMetadata(x, y, z))) 175 | return false; 176 | return target == this || target == Blocks.stone || target.isReplaceableOreGen(world, x, y, z, Blocks.stone); 177 | } 178 | 179 | @Override 180 | public SourceType getSourceType(IBlockAccess iba, int x, int y, int z) { 181 | return iba.getBlockMetadata(x, y, z)%4 == 0 ? SourceType.LAVA : SourceType.FIRE; 182 | } 183 | 184 | @Override 185 | public boolean isActive(IBlockAccess iba, int x, int y, int z) { 186 | return true; 187 | } 188 | 189 | @Override 190 | public int damageDropped(int meta) { 191 | return meta; 192 | } 193 | 194 | @Override 195 | public void onNeighborBlockChange(World world, int x, int y, int z, Block b) { 196 | this.onBlockAdded(world, x, y, z); 197 | } 198 | 199 | @Override 200 | public void onBlockAdded(World world, int x, int y, int z) { 201 | if (LavaRockGenerator.instance.doingLavaRockGen || !ReikaWorldHelper.isChunkPastCompletelyFinishedGenerating(world, x >> 4, z >> 4)) 202 | return; 203 | int meta = world.getBlockMetadata(x, y, z)%4; 204 | for (int i = 0; i < 6; i++) { 205 | ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[i]; 206 | int dx = x+dir.offsetX; 207 | int dy = y+dir.offsetY; 208 | int dz = z+dir.offsetZ; 209 | if (world.checkChunksExist(dx, dy, dz, dx, dy, dz)) { 210 | Material mat2 = ReikaWorldHelper.getMaterial(world, dx, dy, dz); 211 | if (ReikaBlockHelper.matchMaterialsLoosely(Material.water, mat2)) { 212 | int chance = 3+3*meta*meta; // 1 in: 3, 6, 15, 30 213 | boolean obsidian = world.rand.nextInt(chance) == 0; 214 | world.setBlock(x, y, z, obsidian ? Blocks.obsidian : (meta <= 1 ? Blocks.cobblestone : Blocks.stone)); 215 | } 216 | else { 217 | 218 | } 219 | } 220 | } 221 | ReikaWorldHelper.temperatureEnvironment(world, x, y, z, this.getEffectiveTemperature(meta)); 222 | } 223 | 224 | private int getEffectiveTemperature(int meta) { //0 is lava 225 | return 750-(meta%4)*150; 226 | } 227 | 228 | @Override 229 | public int getRange(World world, int x, int y, int z, EntityPlayer ep) { 230 | return -1; 231 | } 232 | 233 | @Override 234 | public Collection getSpreadBlocks(World world, int x, int y, int z) { 235 | Collection ret = new ArrayList(); 236 | for (int i = 0; i < 16; i++) { 237 | ret.add(new BlockKey(this, i)); 238 | } 239 | return ret; 240 | } 241 | 242 | } 243 | -------------------------------------------------------------------------------- /Rendering/ShapedStoneRenderer.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * @author Reika Kalseki 3 | * 4 | * Copyright 2017 5 | * 6 | * All rights reserved. 7 | * Distribution of the software in any form is only allowed with 8 | * explicit, prior permission from the owner. 9 | ******************************************************************************/ 10 | package Reika.GeoStrata.Rendering; 11 | 12 | import java.awt.Color; 13 | 14 | import org.lwjgl.opengl.GL11; 15 | 16 | import net.minecraft.block.Block; 17 | import net.minecraft.client.renderer.RenderBlocks; 18 | import net.minecraft.client.renderer.Tessellator; 19 | import net.minecraft.init.Blocks; 20 | import net.minecraft.util.IIcon; 21 | import net.minecraft.world.IBlockAccess; 22 | import net.minecraftforge.common.util.ForgeDirection; 23 | 24 | import Reika.DragonAPI.Base.BaseBlockRenderer; 25 | import Reika.DragonAPI.Libraries.Java.ReikaGLHelper.BlendMode; 26 | import Reika.GeoStrata.Blocks.BlockShapedRock; 27 | import Reika.GeoStrata.Registry.RockTypes; 28 | 29 | public class ShapedStoneRenderer extends BaseBlockRenderer { 30 | 31 | private int blend1; 32 | private int blend2; 33 | 34 | public ShapedStoneRenderer(int ID) { 35 | super(ID); 36 | } 37 | 38 | @Override 39 | public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { 40 | Tessellator v5 = Tessellator.instance; 41 | 42 | GL11.glEnable(GL11.GL_BLEND); 43 | BlendMode.DEFAULT.apply(); 44 | GL11.glColor3f(1, 1, 1); 45 | v5.startDrawingQuads(); 46 | 47 | BlockShapedRock b = (BlockShapedRock)block; 48 | 49 | IIcon ico = RockTypes.getTypeFromID(block).getIcon();//b.getIcon(0, metadata); 50 | float u = ico.getMinU(); 51 | float du = ico.getMaxU(); 52 | float v = ico.getMinV(); 53 | float dv = ico.getMaxV(); 54 | 55 | IIcon ico2 = Blocks.glass.getIcon(0, 0);//RockShapes.getShape(block).getIcon();//b.getIconForEdge(0, RockTypes.getTypeFromID(Blocks.blockID, metadata)); 56 | float u2 = ico2.getMinU(); 57 | float du2 = ico2.getMaxU(); 58 | float v2 = ico2.getMinV(); 59 | float dv2 = ico2.getMaxV(); 60 | 61 | float dx = -0.5F; 62 | float dy = -0.5F; 63 | float dz = -0.5F; 64 | v5.addTranslation(dx, dy, dz); 65 | 66 | this.drawInventoryBlock(b, metadata, renderer, ico); 67 | 68 | v5.addTranslation(-dx, -dy, -dz); 69 | 70 | v5.draw(); 71 | 72 | v5.startDrawingQuads(); 73 | v5.addTranslation(dx, dy, dz); 74 | this.blendMode(); 75 | this.drawInventoryBlock(b, metadata, renderer, ico2); 76 | v5.addTranslation(-dx, -dy, -dz); 77 | v5.draw(); 78 | this.unblend(); 79 | } 80 | 81 | private void blendMode() { 82 | blend1 = GL11.glGetInteger(GL11.GL_BLEND_SRC); 83 | blend2 = GL11.glGetInteger(GL11.GL_BLEND_DST); 84 | GL11.glEnable(GL11.GL_BLEND); 85 | BlendMode.PREALPHA.apply(); 86 | } 87 | 88 | private void unblend() { 89 | GL11.glBlendFunc(blend1, blend2); 90 | GL11.glDisable(GL11.GL_BLEND); 91 | } 92 | 93 | private void drawInventoryBlock(BlockShapedRock b, int metadata, RenderBlocks renderer, IIcon ico) { 94 | Tessellator v5 = Tessellator.instance; 95 | int color = b.getRenderColor(metadata); 96 | Color c = new Color(color); 97 | 98 | float u = ico.getMinU(); 99 | float du = ico.getMaxU(); 100 | float v = ico.getMinV(); 101 | float dv = ico.getMaxV(); 102 | 103 | this.faceBrightnessNoWorld(ForgeDirection.DOWN, v5, c.getRed()/255F, c.getGreen()/255F, c.getBlue()/255F); 104 | v5.setNormal(0, 1, 0); 105 | v5.addVertexWithUV(1, 1, 0, u, dv); 106 | v5.addVertexWithUV(0, 1, 0, u, v); 107 | v5.addVertexWithUV(0, 1, 1, du, v); 108 | v5.addVertexWithUV(1, 1, 1, du, dv); 109 | 110 | this.faceBrightnessNoWorld(ForgeDirection.UP, v5, c.getRed()/512F, c.getGreen()/512F, c.getBlue()/512F); 111 | v5.addVertexWithUV(0, 0, 0, du, dv); 112 | v5.addVertexWithUV(1, 0, 0, du, v); 113 | v5.addVertexWithUV(1, 0, 1, u, v); 114 | v5.addVertexWithUV(0, 0, 1, u, dv); 115 | 116 | this.faceBrightnessNoWorld(ForgeDirection.EAST, v5, c.getRed()/425F, c.getGreen()/425F, c.getBlue()/425F); 117 | v5.addVertexWithUV(1, 0, 0, du, dv); 118 | v5.addVertexWithUV(1, 1, 0, du, v); 119 | v5.addVertexWithUV(1, 1, 1, u, v); 120 | v5.addVertexWithUV(1, 0, 1, u, dv); 121 | 122 | this.faceBrightnessNoWorld(ForgeDirection.WEST, v5, c.getRed()/425F, c.getGreen()/425F, c.getBlue()/425F); 123 | v5.addVertexWithUV(0, 1, 0, u, dv); 124 | v5.addVertexWithUV(0, 0, 0, u, v); 125 | v5.addVertexWithUV(0, 0, 1, du, v); 126 | v5.addVertexWithUV(0, 1, 1, du, dv); 127 | 128 | this.faceBrightnessNoWorld(ForgeDirection.SOUTH, v5, c.getRed()/364F, c.getGreen()/364F, c.getBlue()/364F); 129 | v5.addVertexWithUV(0, 1, 1, u, dv); 130 | v5.addVertexWithUV(0, 0, 1, u, v); 131 | v5.addVertexWithUV(1, 0, 1, du, v); 132 | v5.addVertexWithUV(1, 1, 1, du, dv); 133 | 134 | this.faceBrightnessNoWorld(ForgeDirection.NORTH, v5, c.getRed()/364F, c.getGreen()/364F, c.getBlue()/364F); 135 | v5.addVertexWithUV(0, 0, 0, du, dv); 136 | v5.addVertexWithUV(0, 1, 0, du, v); 137 | v5.addVertexWithUV(1, 1, 0, u, v); 138 | v5.addVertexWithUV(1, 0, 0, u, dv); 139 | } 140 | 141 | @Override 142 | public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks rb) { 143 | super.renderWorldBlock(world, x, y, z, block, modelId, rb); 144 | BlockShapedRock b = (BlockShapedRock)block; 145 | int meta = world.getBlockMetadata(x, y, z); 146 | RockTypes type = RockTypes.getTypeFromID(block); 147 | Tessellator v5 = Tessellator.instance; 148 | v5.addTranslation(x, y, z); 149 | IIcon ico = type.getIcon(); 150 | this.renderBlock(world, x, y, z, b, rb, ico); 151 | v5.addTranslation(-x, -y, -z); 152 | v5.draw(); 153 | this.blendMode(); 154 | v5.startDrawingQuads(); 155 | v5.addTranslation(x, y, z); 156 | IIcon ico2 = Blocks.glass.getIcon(0, 0);//RockShapes.getShape(block).getIcon(); 157 | this.renderBlock(world, x, y, z, b, rb, ico2); 158 | v5.addTranslation(-x, -y, -z); 159 | v5.draw(); 160 | this.unblend(); 161 | v5.startDrawingQuads(); 162 | 163 | return true; 164 | } 165 | 166 | private void renderBlock(IBlockAccess world, int x, int y, int z, BlockShapedRock b, RenderBlocks rb, IIcon ico) { 167 | Tessellator v5 = Tessellator.instance; 168 | int color = b.colorMultiplier(world, x, y, z); 169 | Color c = new Color(color); 170 | float u = ico.getMinU(); 171 | float v = ico.getMinV(); 172 | float du = ico.getMaxU(); 173 | float dv = ico.getMaxV(); 174 | 175 | for (int i = 0; i < 6; i++) { 176 | this.faceBrightnessColor(dirs[i].getOpposite(), v5, c.getRed()/255F, c.getGreen()/255F, c.getBlue()/255F); 177 | switch(i) { 178 | case 0: 179 | v5.addVertexWithUV(0, 0, 0, u, v); 180 | v5.addVertexWithUV(1, 0, 0, du, v); 181 | v5.addVertexWithUV(1, 0, 1, du, dv); 182 | v5.addVertexWithUV(0, 0, 1, u, dv); 183 | break; 184 | case 1: 185 | v5.addVertexWithUV(0, 1, 1, u, dv); 186 | v5.addVertexWithUV(1, 1, 1, du, dv); 187 | v5.addVertexWithUV(1, 1, 0, du, v); 188 | v5.addVertexWithUV(0, 1, 0, u, v); 189 | break; 190 | case 2: 191 | v5.addVertexWithUV(0, 1, 0, u, v); 192 | v5.addVertexWithUV(1, 1, 0, du, v); 193 | v5.addVertexWithUV(1, 0, 0, du, dv); 194 | v5.addVertexWithUV(0, 0, 0, u, dv); 195 | break; 196 | case 3: 197 | v5.addVertexWithUV(0, 0, 1, u, dv); 198 | v5.addVertexWithUV(1, 0, 1, du, dv); 199 | v5.addVertexWithUV(1, 1, 1, du, v); 200 | v5.addVertexWithUV(0, 1, 1, u, v); 201 | break; 202 | case 4: 203 | v5.addVertexWithUV(0, 0, 0, u, dv); 204 | v5.addVertexWithUV(0, 0, 1, du, dv); 205 | v5.addVertexWithUV(0, 1, 1, du, v); 206 | v5.addVertexWithUV(0, 1, 0, u, v); 207 | break; 208 | case 5: 209 | v5.addVertexWithUV(1, 1, 0, u, v); 210 | v5.addVertexWithUV(1, 1, 1, du, v); 211 | v5.addVertexWithUV(1, 0, 1, du, dv); 212 | v5.addVertexWithUV(1, 0, 0, u, dv); 213 | break; 214 | } 215 | } 216 | } 217 | 218 | @Override 219 | public boolean shouldRender3DInInventory(int model) { 220 | return true; 221 | } 222 | 223 | } 224 | --------------------------------------------------------------------------------