forked from Traincraft/Traincraft
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from canitzp/1.9
WorldGen, OilSand
- Loading branch information
Showing
14 changed files
with
270 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
/build | ||
/Traincraft-5.iws | ||
/out | ||
/gradle | ||
/.gradle | ||
/run | ||
/Traincraft-5.ipr | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
modid=traincraft | ||
modName=Traincraft | ||
modVersion=1.0.0 | ||
minecraftVersion=1.9 | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#Mon Sep 14 12:28:28 PDT 2015 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package si.meansoft.traincraft; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.init.Blocks; | ||
import si.meansoft.traincraft.blocks.BlockBase; | ||
|
||
/** | ||
* @author canitzp | ||
*/ | ||
public class BlockRegistry { | ||
|
||
public static Block oilSand; | ||
|
||
public static void preInit(){ | ||
oilSand = new BlockBase(Material.sand, "oilSand").generateBlock(Blocks.sand, 50, 80, 7, 11).addOreDict("oreOilSand").setForgeModel(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/si/meansoft/traincraft/blocks/BlockBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package si.meansoft.traincraft.blocks; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.util.ResourceLocation; | ||
import net.minecraftforge.oredict.OreDictionary; | ||
import si.meansoft.traincraft.Traincraft; | ||
import si.meansoft.traincraft.gen.WorldGen; | ||
import si.meansoft.traincraft.network.CommonProxy; | ||
|
||
/** | ||
* @author canitzp | ||
*/ | ||
public class BlockBase extends Block { | ||
|
||
public boolean forgeModel = false; | ||
|
||
public BlockBase(Material materialIn, String name) { | ||
super(materialIn); | ||
Traincraft.registerBlock(this, name); | ||
} | ||
|
||
/** | ||
* @param toSpawnInside The Block it'll spawn inside. e.g.: Coal='net.minecraft.init.Blocks.stone' | ||
* @param minY The minimal height for the Block to spawn. e.g.: Coal=0 | ||
* @param maxY The maximal height for the Block to spawn. e.g.: Coal=128 | ||
* @param maxVeinSize The maximal amount of Blocks at one place. e.g.: Coal=17 | ||
* @param chanceToSpawn The Chance to spawn the Block. e.g.: Coal=20 | ||
* The example values you'll find in the class: 'net.minecraft.world.gen.ChunkProviderSettings' | ||
*/ | ||
public BlockBase generateBlock(Block toSpawnInside, int minY, int maxY, int maxVeinSize, int chanceToSpawn){ | ||
WorldGen.addBlockToSpawn(this, toSpawnInside, minY, maxY, maxVeinSize, chanceToSpawn); | ||
return this; | ||
} | ||
|
||
public BlockBase addOreDict(String oreDict){ | ||
OreDictionary.registerOre(oreDict, this); | ||
return this; | ||
} | ||
|
||
public BlockBase setForgeModel(String name){ | ||
CommonProxy.addForgeRender(this, new ResourceLocation(name)); | ||
return this; | ||
} | ||
public BlockBase setForgeModel(){ | ||
return setForgeModel(getRegistryName()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package si.meansoft.traincraft.gen; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.state.pattern.BlockMatcher; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.WorldType; | ||
import net.minecraft.world.chunk.IChunkGenerator; | ||
import net.minecraft.world.chunk.IChunkProvider; | ||
import net.minecraft.world.gen.feature.WorldGenMinable; | ||
import net.minecraftforge.fml.common.IWorldGenerator; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Random; | ||
|
||
/** | ||
* @author canitzp | ||
*/ | ||
public class WorldGen implements IWorldGenerator { | ||
|
||
private static HashMap<Block, SpawnProps> blocksToSpawnInOverworld = new HashMap<Block, SpawnProps>(); | ||
|
||
@Override | ||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { | ||
if(world.getWorldType() != WorldType.FLAT){ | ||
switch(world.provider.getDimension()){ | ||
case 0: spawnOverworld(random, world, chunkX*16, chunkZ*16); | ||
} | ||
} | ||
} | ||
|
||
public void spawnOverworld(Random rnd, World world, int x, int z){ | ||
for(Map.Entry entry : blocksToSpawnInOverworld.entrySet()){ | ||
SpawnProps props = (SpawnProps) entry.getValue(); | ||
addOreSpawn(new ItemStack((Block) entry.getKey()), props.blockToSpawnInside, world, rnd, x, z, props.veinSize, props.chance, props.minY, props.maxY); | ||
} | ||
} | ||
|
||
public void addOreSpawn(ItemStack stack, Block blockIn, World world, Random random, int blockXPos, int blockZPos, int maxVeinSize, int chancesToSpawn, int minY, int maxY){ | ||
if(maxY > minY){ | ||
int yDiff = maxY-minY; | ||
for(int i = 0; i < chancesToSpawn; i++){ | ||
int posX = blockXPos+random.nextInt(16); | ||
int posY = minY+random.nextInt(yDiff); | ||
int posZ = blockZPos+random.nextInt(16); | ||
Block block = Block.getBlockFromItem(stack.getItem()); | ||
new WorldGenMinable(block.getStateFromMeta(stack.getMetadata()), maxVeinSize, BlockMatcher.forBlock(blockIn)).generate(world, random, new BlockPos(posX, posY, posZ)); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @param block The Block to spawn | ||
* @param minY The minimal height for the Block to spawn. e.g.: Coal=0 | ||
* @param maxY The maximal height for the Block to spawn. e.g.: Coal=128 | ||
* @param maxVeinSize The maximal amount of Blocks at one place. e.g.: Coal=17 | ||
* @param chanceToSpawn The Chance to spawn the Block. e.g.: Coal=20 | ||
* The example values you'll find in the class: 'net.minecraft.world.gen.ChunkProviderSettings' | ||
*/ | ||
public static void addBlockToSpawn(Block block, Block toSpawnInside, int minY, int maxY, int maxVeinSize, int chanceToSpawn){ | ||
if(!blocksToSpawnInOverworld.containsKey(block)) | ||
blocksToSpawnInOverworld.put(block, new SpawnProps(toSpawnInside, chanceToSpawn, maxY, minY, maxVeinSize)); | ||
} | ||
|
||
public static class SpawnProps{ | ||
public int minY, maxY, veinSize, chance; | ||
public Block blockToSpawnInside; | ||
public SpawnProps(Block blockToSpawnInside, int chance, int maxY, int minY, int veinSize) { | ||
this.chance = chance; | ||
this.maxY = maxY; | ||
this.minY = minY; | ||
this.veinSize = veinSize; | ||
this.blockToSpawnInside = blockToSpawnInside; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/resources/assets/traincraft/blockstates/oilSand.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"forge_marker": 1, | ||
"defaults": { | ||
"textures": { | ||
"all": "traincraft:blocks/blockOilSand" | ||
}, | ||
"model": "cube_all", | ||
"transform": "forge:default-block" | ||
}, | ||
"variants": { | ||
"normal": [{}], | ||
"inventory": [{}] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#Some special things: | ||
itemGroup.traincraftTab=Traincraft | ||
|
||
|
||
#Blocks: | ||
tile.traincraft:oilSand.name=Oil Sand |
Binary file added
BIN
+3.46 KB
src/main/resources/assets/traincraft/textures/blocks/blockOilSand.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.