forked from TAIGA/TAIGA
general code cleanup
added new StateMatcher
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -126,6 +126,8 @@ local.properties
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
.idea/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
|
16
build.gradle
16
build.gradle
@@ -13,25 +13,13 @@ buildscript {
|
||||
}
|
||||
}
|
||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||
repositories {
|
||||
maven {
|
||||
name "DVS1 Maven FS'"
|
||||
url 'http://dvs1.progwml6.com/files/maven'
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// for people who want stable - not yet functional for MC 1.8.8 - we require the forgegradle 2.1 snapshot
|
||||
//plugins {
|
||||
// id "net.minecraftforge.gradle.forge" version "2.0.2"
|
||||
//}
|
||||
*/
|
||||
version = "0.1"
|
||||
group= "com.sosnitzka.zcompression" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "zcompression"
|
||||
|
||||
minecraft {
|
||||
version = "1.9-12.16.0.1865-1.9"
|
||||
version = "1.9-12.16.0.1867-1.9"
|
||||
runDir = "run"
|
||||
|
||||
// the mappings can be changed at any time, and must be in the following format.
|
||||
@@ -64,7 +52,7 @@ dependencies {
|
||||
// for more info...
|
||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
||||
compile "tconstruct:TConstruct:1.9-2.2.2.jenkins159:deobf"
|
||||
// compile "tconstruct:TConstruct:1.9-2.2.2.jenkins159:deobf"
|
||||
}
|
||||
|
||||
processResources
|
||||
|
@@ -12,5 +12,4 @@ public class BasicBlock extends Block{
|
||||
setHardness(hardness);
|
||||
setResistance(resistance);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -7,7 +7,4 @@ public class BlockAdamantiteOre extends BasicBlock{
|
||||
public BlockAdamantiteOre() {
|
||||
super("adamantite_ore", Material.ROCK, 3.0f, 5.0f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -7,7 +7,4 @@ public class BlockArcaniteOre extends BasicBlock{
|
||||
public BlockArcaniteOre() {
|
||||
super("arcanite_ore", Material.ROCK, 3.0f, 5.0f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -7,7 +7,4 @@ public class BlockBasalt extends BasicBlock{
|
||||
public BlockBasalt() {
|
||||
super("basalt", Material.ROCK, 12.0f, 2.0f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -7,7 +7,4 @@ public class BlockBismuthOre extends BasicBlock{
|
||||
public BlockBismuthOre() {
|
||||
super("bismuth_ore", Material.ROCK, 3.0f, 5.0f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -7,7 +7,4 @@ public class BlockEterniteOre extends BasicBlock{
|
||||
public BlockEterniteOre() {
|
||||
super("eternite_ore", Material.ROCK, 3.0f, 5.0f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -7,7 +7,4 @@ public class BlockKarmesineOre extends BasicBlock{
|
||||
public BlockKarmesineOre() {
|
||||
super("karmesine_ore", Material.ROCK, 3.0f, 5.0f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -7,7 +7,4 @@ public class BlockLigniteOre extends BasicBlock{
|
||||
public BlockLigniteOre() {
|
||||
super("lignite_ore", Material.ROCK, 3.0f, 5.0f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -7,7 +7,4 @@ public class BlockMeteoriteOre extends BasicBlock{
|
||||
public BlockMeteoriteOre() {
|
||||
super("meteorite_ore", Material.ROCK, 3.0f, 5.0f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -7,7 +7,4 @@ public class BlockMindoriteOre extends BasicBlock{
|
||||
public BlockMindoriteOre() {
|
||||
super("mindorite_ore", Material.ROCK, 3.0f, 5.0f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -7,7 +7,4 @@ public class BlockMythrilOre extends BasicBlock{
|
||||
public BlockMythrilOre() {
|
||||
super("mythril_ore", Material.ROCK, 3.0f, 5.0f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -7,7 +7,4 @@ public class BlockPalladiumOre extends BasicBlock{
|
||||
public BlockPalladiumOre() {
|
||||
super("palladium_ore", Material.ROCK, 3.0f, 5.0f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -7,7 +7,4 @@ public class BlockPrometheumOre extends BasicBlock{
|
||||
public BlockPrometheumOre() {
|
||||
super("prometheum_ore", Material.ROCK, 3.0f, 5.0f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -7,7 +7,4 @@ public class BlockRottenGround extends BasicBlock{
|
||||
public BlockRottenGround() {
|
||||
super("rotten_ground", Material.GROUND, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -7,7 +7,4 @@ public class BlockSlagironOre extends BasicBlock{
|
||||
public BlockSlagironOre() {
|
||||
super("slagiron_ore", Material.ROCK, 3.0f, 5.0f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -7,7 +7,4 @@ public class BlockTiberiumOre extends BasicBlock{
|
||||
public BlockTiberiumOre() {
|
||||
super("tiberium_ore", Material.ROCK, 3.0f, 5.0f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -7,7 +7,4 @@ public class BlockVibraniumre extends BasicBlock{
|
||||
public BlockVibraniumre() {
|
||||
super("vibranium_ore", Material.ROCK, 3.0f, 5.0f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@@ -4,9 +4,8 @@ import net.minecraft.item.Item;
|
||||
|
||||
public class BasicItem extends Item {
|
||||
|
||||
public BasicItem(String name) {
|
||||
BasicItem(String name) {
|
||||
setUnlocalizedName(name);
|
||||
setRegistryName(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -5,6 +5,4 @@ public class ItemSlagiron extends BasicItem{
|
||||
public ItemSlagiron() {
|
||||
super("slagiron");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -32,11 +32,11 @@ import proxy.ServerProxy;
|
||||
@Mod(modid = ZCompression.MODID, version = ZCompression.VERSION)
|
||||
public class ZCompression {
|
||||
|
||||
public static final String MODID = "zcompression";
|
||||
public static final String VERSION = "1.0";
|
||||
static final String MODID = "zcompression";
|
||||
static final String VERSION = "1.0";
|
||||
|
||||
@SidedProxy(clientSide = "proxy.ClientProxy", serverSide = "proxy.ServerProxy")
|
||||
public static ServerProxy proxy;
|
||||
private static ServerProxy proxy;
|
||||
|
||||
// Items
|
||||
public static ItemSlagiron slagiron = new ItemSlagiron();
|
||||
@@ -61,15 +61,6 @@ public class ZCompression {
|
||||
public static BlockVibraniumre vibraniumOre = new BlockVibraniumre();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent e) {
|
||||
GameRegistry.register(slagiron);
|
||||
@@ -104,11 +95,10 @@ public class ZCompression {
|
||||
|
||||
}
|
||||
|
||||
public static void registerBlock(BasicBlock block){
|
||||
private static void registerBlock(BasicBlock block) {
|
||||
GameRegistry.register(block);
|
||||
GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,29 +1,25 @@
|
||||
package main.util;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.state.pattern.BlockMatcher;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.WorldGenMinable;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Generator {
|
||||
|
||||
public static void generateOre(IBlockState state, Random random, int x, int z, World world, int chance, int minY, int maxY, int minSize, int maxSize) {
|
||||
generateOre(state, Blocks.STONE, random, x, z, world, chance, minY, maxY, minSize, maxSize);
|
||||
generateOre(state, Blocks.STONE.getDefaultState(), random, x, z, world, chance, minY, maxY, minSize, maxSize);
|
||||
}
|
||||
|
||||
public static void generateNetherOre(IBlockState state, Random random, int x, int z, World world, int chance, int minY, int maxY, int minSize, int maxSize) {
|
||||
generateOre(state, Blocks.NETHERRACK, random, x, z, world, chance, minY, maxY, minSize, maxSize);
|
||||
generateOre(state, Blocks.NETHERRACK.getDefaultState(), random, x, z, world, chance, minY, maxY, minSize, maxSize);
|
||||
}
|
||||
|
||||
|
||||
public static void generateOre(IBlockState state, Block replace, Random random, int chunkX, int chunkZ, World world, int chance, int minY, int maxY, int minSize, int maxSize){
|
||||
public static void generateOre(IBlockState state, IBlockState replace, Random random, int chunkX, int chunkZ, World world, int chance, int minY, int maxY, int minSize, int maxSize) {
|
||||
int size = minSize + random.nextInt(maxSize - minSize);
|
||||
int height = maxY - minY;
|
||||
|
||||
@@ -31,9 +27,7 @@ public class Generator {
|
||||
int posX = chunkX + random.nextInt(16);
|
||||
int posY = random.nextInt(height) + minY;
|
||||
int posZ = chunkZ + random.nextInt(16);
|
||||
new WorldGenMinable(state, size, BlockMatcher.forBlock(replace)).generate(world, random, new BlockPos(posX, posY, posZ));
|
||||
new WorldGenMinable(state, size, StateMatcher.forState(replace)).generate(world, random, new BlockPos(posX, posY, posZ));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
21
src/main/java/main/util/StateMatcher.java
Normal file
21
src/main/java/main/util/StateMatcher.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package main.util;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
||||
|
||||
public class StateMatcher implements Predicate<IBlockState> {
|
||||
private final IBlockState state;
|
||||
|
||||
private StateMatcher(IBlockState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public static StateMatcher forState(IBlockState state) {
|
||||
return new StateMatcher(state);
|
||||
}
|
||||
|
||||
public boolean apply(IBlockState state) {
|
||||
return state != null && state.getBlock() == this.state.getBlock() && state.getMaterial() == this.state.getMaterial();
|
||||
}
|
||||
}
|
@@ -1,21 +1,16 @@
|
||||
package main.world;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import main.ZCompression;
|
||||
import main.util.Generator;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkGenerator;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraftforge.fml.common.IWorldGenerator;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class ZWorldGen implements IWorldGenerator {
|
||||
|
||||
|
||||
private void nether(Random random, int x, int z, World world) {
|
||||
Generator.generateNetherOre(ZCompression.adamantiteOre.getDefaultState(), random, x, z, world, 24, 1, 32, 2, 5);
|
||||
Generator.generateNetherOre(ZCompression.tiberiumOre.getDefaultState(), random, x, z, world, 60, 1, 128, 2, 10);
|
||||
@@ -24,17 +19,16 @@ public class ZWorldGen implements IWorldGenerator {
|
||||
}
|
||||
|
||||
private void world(Random random, int x, int z, World world) {
|
||||
// Regular
|
||||
Generator.generateOre(ZCompression.slagironOre.getDefaultState(), random, x, z, world, 40, 8, 96, 5, 16);
|
||||
Generator.generateOre(ZCompression.ligniteOre.getDefaultState(), random, x, z, world, 40, 8, 96, 5, 15);
|
||||
Generator.generateOre(Blocks.IRON_ORE.getDefaultState(), random, x, z, world, 40, 8, 96, 2, 10);
|
||||
Generator.generateOre(ZCompression.basalt.getDefaultState(), Blocks.LAVA, random, x, z, world, 20, 8, 24, 2, 5);
|
||||
Generator.generateOre(ZCompression.rottenGround.getDefaultState(), Blocks.DIRT, random, x, z, world, 25, 50, 70, 2, 15);
|
||||
Generator.generateOre(ZCompression.basalt.getDefaultState(), Blocks.LAVA.getDefaultState(), random, x, z, world, 20, 8, 24, 2, 5);
|
||||
Generator.generateOre(ZCompression.rottenGround.getDefaultState(), Blocks.DIRT.getDefaultState(), random, x, z, world, 25, 50, 70, 2, 15);
|
||||
|
||||
Generator.generateOre(ZCompression.vibraniumOre.getDefaultState(), random, x, z, world, 16, 48, 64, 2, 4);
|
||||
Generator.generateOre(ZCompression.mythrilOre.getDefaultState(), random, x, z, world, 16, 16, 32, 2, 4);
|
||||
Generator.generateOre(ZCompression.meteoriteOre.getDefaultState(), random, x, z, world, 25, 0, 32, 3, 6);
|
||||
Generator.generateOre(ZCompression.mindoriteOre.getDefaultState(), Blocks.STONE, random, x, z, world, 450, 32, 96, 3, 6);
|
||||
Generator.generateOre(ZCompression.mindoriteOre.getDefaultState(), Blocks.STONE.getDefaultState(), random, x, z, world, 450, 32, 96, 3, 6);
|
||||
}
|
||||
|
||||
private void end(Random random, int x, int z, World world) {
|
||||
@@ -42,7 +36,6 @@ public class ZWorldGen implements IWorldGenerator {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,
|
||||
IChunkProvider chunkProvider) {
|
||||
@@ -59,7 +52,5 @@ public class ZWorldGen implements IWorldGenerator {
|
||||
end(random, x, z, world);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,7 +1,5 @@
|
||||
package proxy;
|
||||
|
||||
import blocks.BasicBlock;
|
||||
import items.BasicItem;
|
||||
import main.ZCompression;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -32,15 +30,13 @@ public class ClientProxy extends ServerProxy{
|
||||
registerBlockModel(ZCompression.slagironOre);
|
||||
registerBlockModel(ZCompression.tiberiumOre);
|
||||
registerBlockModel(ZCompression.vibraniumOre);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void registerItemModel(Item item){
|
||||
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
|
||||
}
|
||||
|
||||
public static void registerBlockModel(Block block){
|
||||
private static void registerBlockModel(Block block) {
|
||||
registerItemModel(Item.getItemFromBlock(block));
|
||||
}
|
||||
|
||||
private static void registerItemModel(Item item) {
|
||||
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package proxy;
|
||||
|
||||
public class ServerProxy {
|
||||
|
||||
public void registerClientStuff() {}
|
||||
public void registerClientStuff() {
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user