Compare commits

...

10 commits

Author SHA1 Message Date
a6d21ce33a Add liquid light 2015-03-28 01:38:22 +01:00
ea34f55a12 Add glowfoo 2014-09-14 15:06:43 +02:00
5fffbad158 Add Schnitzel trees 2014-07-27 16:57:32 +02:00
kaulquake
e002973c2e added schnitzeltree textures 2014-07-09 17:38:08 +02:00
0581f1c7b3 Change raddish render type 2014-05-28 23:50:05 +02:00
3989b6b622 Add raddish 2014-05-28 23:13:45 +02:00
kaulquake
4100702536 raddish! 2014-05-28 22:38:39 +02:00
0b3e9e6ffe Proper big trees 2014-05-28 02:36:56 +02:00
a5803b1320 Add cucumbers 2014-05-27 20:22:33 +02:00
492e1e9ece Generalize biome decorator 2014-05-27 20:15:58 +02:00
64 changed files with 1105 additions and 253 deletions

View file

@ -0,0 +1,135 @@
package net.universe_factory.minecraft.test;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.FillBucketEvent;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class LiquidLight extends Fluid {
private class BlockLiquidLight extends BlockFluidClassic {
@SideOnly(Side.CLIENT)
protected IIcon stillIcon;
@SideOnly(Side.CLIENT)
protected IIcon flowingIcon;
public BlockLiquidLight() {
super(LiquidLight.this, Material.water);
setCreativeTab(CreativeTabs.tabMisc);
}
@Override
public IIcon getIcon(int side, int meta) {
return (side == 0 || side == 1) ? stillIcon : flowingIcon;
}
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister register) {
stillIcon = register.registerIcon(Test.MODID + ":liquid_light_still");
flowingIcon = register.registerIcon(Test.MODID + ":liquid_light_flow");
}
@Override
public boolean canDisplace(IBlockAccess world, int x, int y, int z) {
if (world.getBlock(x, y, z).getMaterial().isLiquid())
return false;
return super.canDisplace(world, x, y, z);
}
@Override
public boolean displaceIfPossible(World world, int x, int y, int z) {
if (world.getBlock(x, y, z).getMaterial().isLiquid())
return false;
return super.displaceIfPossible(world, x, y, z);
}
}
private class ItemBucketLight extends ItemBucket {
public ItemBucketLight(Block block) {
super(block);
setUnlocalizedName("bucket_light");
setContainerItem(Items.bucket);
setTextureName(Test.MODID + ":bucket_light");
}
}
public static class BucketHandler {
public static BucketHandler INSTANCE = new BucketHandler();
public Map<Block, Item> buckets = new HashMap<Block, Item>();
public BucketHandler() {
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent
public void onBucketFill(FillBucketEvent event) {
ItemStack result = fillCustomBucket(event.world, event.target);
if (result == null)
return;
event.result = result;
event.setResult(Result.ALLOW);
}
private ItemStack fillCustomBucket(World world, MovingObjectPosition pos) {
Block block = world.getBlock(pos.blockX, pos.blockY, pos.blockZ);
Item bucket = buckets.get(block);
if (bucket != null && world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0) {
world.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ);
return new ItemStack(bucket);
} else
return null;
}
}
public LiquidLight() {
super("liquid_light");
setDensity(1);
setLuminosity(15);
setViscosity(1000);
}
public void register() {
FluidRegistry.registerFluid(this);
BlockLiquidLight block = new BlockLiquidLight();
GameRegistry.registerBlock(block, "liquid_light");
setUnlocalizedName(block.getUnlocalizedName());
ItemBucketLight bucket = new ItemBucketLight(block);
GameRegistry.registerItem(bucket, "bucket_light");
FluidContainerRegistry.registerFluidContainer(this, new ItemStack(bucket), new ItemStack(Items.bucket));
BucketHandler.INSTANCE.buckets.put(block, bucket);
}
}

View file

@ -1,17 +1,32 @@
package net.universe_factory.minecraft.test; package net.universe_factory.minecraft.test;
import java.util.AbstractMap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Map.Entry;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemCloth;
import net.minecraft.item.ItemFood; import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemSeedFood;
import net.minecraft.item.ItemSeeds; import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
import net.minecraft.world.gen.feature.WorldGenBigTree;
import net.minecraft.world.gen.feature.WorldGenTrees;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.terraingen.BiomeEvent.CreateDecorator; import net.minecraftforge.event.terraingen.BiomeEvent.CreateDecorator;
import net.universe_factory.minecraft.test.blocks.BlockGlowfoo;
import net.universe_factory.minecraft.test.generic.GenericCrops; import net.universe_factory.minecraft.test.generic.GenericCrops;
import net.universe_factory.minecraft.test.generic.GenericWood; import net.universe_factory.minecraft.test.generic.GenericWood;
import net.universe_factory.minecraft.test.generic.WorldGenGenericBigTree;
import net.universe_factory.minecraft.test.generic.WorldGenGenericTrees;
import net.universe_factory.minecraft.test.world.ExtensibleBiomeDecorator;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.Instance;
@ -59,6 +74,42 @@ public class Test {
} }
}; };
public static final GenericWood schnitzelTree = new GenericWood() {
@Override
public String getName() {
return "Schnitzel";
}
@Override
public int getMinTreeHeight() {
return 4;
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int meta, int fortune) {
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
int chance = 30;
if (fortune > 0) {
chance -= 2 << fortune;
if (chance < 5)
chance = 5;
}
if (world.rand.nextInt(chance) == 0) {
final Item[] drops = { Items.beef, Items.beef, Items.chicken, Items.chicken, Items.porkchop, Items.porkchop, Items.leather };
ret.add(new ItemStack(drops[world.rand.nextInt(drops.length)], 1));
}
return ret;
}
};
WorldGenGenericTrees cherryTreeGenerator = new WorldGenGenericTrees(false, cherryTree);
WorldGenGenericBigTree cherryTreeGeneratorBig = new WorldGenGenericBigTree(false, cherryTree);
public static final GenericCrops saladField = new GenericCrops() { public static final GenericCrops saladField = new GenericCrops() {
@Override @Override
public String getName() { public String getName() {
@ -74,11 +125,67 @@ public class Test {
public Item itemSeeds() { public Item itemSeeds() {
return saladSeeds; return saladSeeds;
} }
@Override
public int getRenderType() {
return 1;
}
}; };
public static final Item saladSeeds = new ItemSeeds(saladField, Blocks.farmland).setTextureName(MODID + ":seeds_salad") public static final Item saladSeeds = new ItemSeeds(saladField, Blocks.farmland).setTextureName(MODID + ":seeds_salad")
.setUnlocalizedName("seedsSalad"); .setUnlocalizedName("seedsSalad");
public static final Item salad = new ItemFood(3, 0.8f, false).setTextureName(MODID + ":salad").setUnlocalizedName("salad"); public static final Item salad = new ItemFood(3, 0.8f, false).setTextureName(MODID + ":salad").setUnlocalizedName("salad");
public static final GenericCrops cucumberField = new GenericCrops() {
@Override
public String getName() {
return "cucumber";
}
@Override
public Item itemCrops() {
return cucumber;
}
@Override
public Item itemSeeds() {
return cucumberSeeds;
}
@Override
public int getRenderType() {
return 1;
}
};
public static final Item cucumberSeeds = new ItemSeeds(cucumberField, Blocks.farmland).setTextureName(MODID + ":seeds_cucumber").setUnlocalizedName(
"seedsCucumber");
public static final Item cucumber = new ItemFood(4, 0.4f, false).setTextureName(MODID + ":cucumber").setUnlocalizedName("cucumber");
public static final GenericCrops raddishField = new GenericCrops() {
@Override
public String getName() {
return "raddish";
}
@Override
public Item itemCrops() {
return raddish;
}
@Override
public Item itemSeeds() {
return raddish;
}
};
public static final Item raddish = new ItemSeedFood(4, 0.4f, raddishField, Blocks.farmland).setTextureName(MODID + ":raddish").setUnlocalizedName(
"raddish");
public static final Block glowfooBlock = new BlockGlowfoo();
public static final Item glowfoo = new ItemCloth(glowfooBlock);
public static final ExtensibleBiomeDecorator biomeDecorator = new ExtensibleBiomeDecorator();
public static final LiquidLight liquidLight = new LiquidLight();
@EventHandler @EventHandler
public void preInit(FMLInitializationEvent event) { public void preInit(FMLInitializationEvent event) {
MinecraftForge.TERRAIN_GEN_BUS.register(new TerrainGenHandler()); MinecraftForge.TERRAIN_GEN_BUS.register(new TerrainGenHandler());
@ -86,29 +193,47 @@ public class Test {
GameRegistry.registerItem(cherries, "cherries"); GameRegistry.registerItem(cherries, "cherries");
cherryTree.register(); cherryTree.register();
schnitzelTree.register();
GameRegistry.registerItem(saladSeeds, "seeds_salad"); GameRegistry.registerItem(saladSeeds, "seeds_salad");
GameRegistry.registerItem(salad, "salad"); GameRegistry.registerItem(salad, "salad");
GameRegistry.registerBlock(saladField, null, "salad"); GameRegistry.registerBlock(saladField, null, "salad");
GameRegistry.registerItem(cucumberSeeds, "seeds_cucumber");
GameRegistry.registerItem(cucumber, "cucumber");
GameRegistry.registerBlock(cucumberField, null, "cucumber");
GameRegistry.registerItem(raddish, "raddish");
GameRegistry.registerBlock(raddishField, null, "raddish");
GameRegistry.registerBlock(glowfooBlock, null, "glowfoo");
GameRegistry.registerItem(glowfoo, "glowfoo");
for (int i = 0; i < 16; i++)
GameRegistry.addRecipe(new ItemStack(glowfoo, 4, i), "###", "#X#", "###", '#', new ItemStack(Blocks.stained_glass_pane, 1, i), 'X',
Blocks.redstone_block);
liquidLight.register();
biomeDecorator.registerTree(new ExtensibleBiomeDecorator.Tree() {
@Override
public Entry<WorldGenAbstractTree, Float> replaceTree(World world, BiomeGenBase biome, Random random, int x, int y, int z,
WorldGenAbstractTree orig) {
if (!(orig instanceof WorldGenTrees || orig instanceof WorldGenBigTree)
|| biome.getTempCategory() != BiomeGenBase.TempCategory.MEDIUM)
return null;
WorldGenAbstractTree generator = (random.nextInt(3) == 0) ? cherryTreeGeneratorBig : cherryTreeGenerator;
return new AbstractMap.SimpleEntry(generator, 0.3f);
}
});
} }
public class TerrainGenHandler { public class TerrainGenHandler {
@SubscribeEvent @SubscribeEvent
public void handleCreateDecorator(CreateDecorator event) { public void handleCreateDecorator(CreateDecorator event) {
event.newBiomeDecorator = new TestBiomeDecorator(cherryTree); event.newBiomeDecorator = biomeDecorator.getInstance(event.originalBiomeDecorator);
event.newBiomeDecorator.bigMushroomsPerChunk = event.originalBiomeDecorator.bigMushroomsPerChunk;
event.newBiomeDecorator.cactiPerChunk = event.originalBiomeDecorator.cactiPerChunk;
event.newBiomeDecorator.clayPerChunk = event.originalBiomeDecorator.clayPerChunk;
event.newBiomeDecorator.deadBushPerChunk = event.originalBiomeDecorator.deadBushPerChunk;
event.newBiomeDecorator.flowersPerChunk = event.originalBiomeDecorator.flowersPerChunk;
event.newBiomeDecorator.generateLakes = event.originalBiomeDecorator.generateLakes;
event.newBiomeDecorator.grassPerChunk = event.originalBiomeDecorator.grassPerChunk;
event.newBiomeDecorator.mushroomsPerChunk = event.originalBiomeDecorator.mushroomsPerChunk;
event.newBiomeDecorator.reedsPerChunk = event.originalBiomeDecorator.reedsPerChunk;
event.newBiomeDecorator.sandPerChunk = event.originalBiomeDecorator.sandPerChunk;
event.newBiomeDecorator.sandPerChunk2 = event.originalBiomeDecorator.sandPerChunk2;
event.newBiomeDecorator.treesPerChunk = event.originalBiomeDecorator.treesPerChunk;
event.newBiomeDecorator.waterlilyPerChunk = event.originalBiomeDecorator.waterlilyPerChunk;
} }
} }
} }

View file

@ -1,229 +0,0 @@
package net.universe_factory.minecraft.test;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.BIG_SHROOM;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.CACTUS;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.CLAY;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.DEAD_BUSH;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.FLOWERS;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.GRASS;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.LAKE;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.LILYPAD;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.PUMPKIN;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.REED;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.SAND;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.SAND_PASS2;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.SHROOM;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.TREE;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.world.biome.BiomeDecorator;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
import net.minecraft.world.gen.feature.WorldGenDeadBush;
import net.minecraft.world.gen.feature.WorldGenLiquids;
import net.minecraft.world.gen.feature.WorldGenPumpkin;
import net.minecraft.world.gen.feature.WorldGenTrees;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.terraingen.DecorateBiomeEvent;
import net.minecraftforge.event.terraingen.TerrainGen;
import net.universe_factory.minecraft.test.generic.GenericWood;
import net.universe_factory.minecraft.test.generic.WorldGenGenericTrees;
public class TestBiomeDecorator extends BiomeDecorator {
protected WorldGenGenericTrees worldGenGenericTrees;
public TestBiomeDecorator(GenericWood genericWood) {
worldGenGenericTrees = new WorldGenGenericTrees(false, genericWood);
}
protected void genDecorations(BiomeGenBase biome) {
MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Pre(currentWorld, randomGenerator, chunk_X, chunk_Z));
this.generateOres();
int i;
int j;
int k;
boolean doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SAND);
for (i = 0; doGen && i < this.sandPerChunk2; ++i) {
j = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
this.sandGen.generate(this.currentWorld, this.randomGenerator, j, this.currentWorld.getTopSolidOrLiquidBlock(j, k), k);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, CLAY);
for (i = 0; doGen && i < this.clayPerChunk; ++i) {
j = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
this.clayGen.generate(this.currentWorld, this.randomGenerator, j, this.currentWorld.getTopSolidOrLiquidBlock(j, k), k);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SAND_PASS2);
for (i = 0; doGen && i < this.sandPerChunk; ++i) {
j = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
this.gravelAsSandGen.generate(this.currentWorld, this.randomGenerator, j, this.currentWorld.getTopSolidOrLiquidBlock(j, k), k);
}
i = this.treesPerChunk;
if (this.randomGenerator.nextInt(10) == 0) {
++i;
}
int l;
int i1;
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, TREE);
for (j = 0; doGen && j < i; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
i1 = this.currentWorld.getHeightValue(k, l);
WorldGenAbstractTree worldgenabstracttree = biome.func_150567_a(this.randomGenerator);
if (worldgenabstracttree instanceof WorldGenTrees && biome.getTempCategory() == BiomeGenBase.TempCategory.MEDIUM
&& this.randomGenerator.nextDouble() < 0.5f) {
worldgenabstracttree = this.worldGenGenericTrees;
}
worldgenabstracttree.setScale(1.0D, 1.0D, 1.0D);
if (worldgenabstracttree.generate(this.currentWorld, this.randomGenerator, k, i1, l)) {
worldgenabstracttree.func_150524_b(this.currentWorld, this.randomGenerator, k, i1, l);
}
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, BIG_SHROOM);
for (j = 0; doGen && j < this.bigMushroomsPerChunk; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
this.bigMushroomGen.generate(this.currentWorld, this.randomGenerator, k, this.currentWorld.getHeightValue(k, l), l);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, FLOWERS);
for (j = 0; doGen && j < this.flowersPerChunk; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) + 32);
String s = biome.func_150572_a(this.randomGenerator, k, i1, l);
BlockFlower blockflower = BlockFlower.func_149857_e(s);
if (blockflower.getMaterial() != Material.air) {
this.yellowFlowerGen.func_150550_a(blockflower, BlockFlower.func_149856_f(s));
this.yellowFlowerGen.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, GRASS);
for (j = 0; doGen && j < this.grassPerChunk; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2);
WorldGenerator worldgenerator = biome.getRandomWorldGenForGrass(this.randomGenerator);
worldgenerator.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, DEAD_BUSH);
for (j = 0; doGen && j < this.deadBushPerChunk; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2);
(new WorldGenDeadBush(Blocks.deadbush)).generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, LILYPAD);
for (j = 0; doGen && j < this.waterlilyPerChunk; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
for (i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2); i1 > 0
&& this.currentWorld.isAirBlock(k, i1 - 1, l); --i1) {
;
}
this.waterlilyGen.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SHROOM);
for (j = 0; doGen && j < this.mushroomsPerChunk; ++j) {
if (this.randomGenerator.nextInt(4) == 0) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
i1 = this.currentWorld.getHeightValue(k, l);
this.mushroomBrownGen.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
if (this.randomGenerator.nextInt(8) == 0) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2);
this.mushroomRedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
}
if (doGen && this.randomGenerator.nextInt(4) == 0) {
j = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
l = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(j, k) * 2);
this.mushroomBrownGen.generate(this.currentWorld, this.randomGenerator, j, l, k);
}
if (doGen && this.randomGenerator.nextInt(8) == 0) {
j = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
l = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(j, k) * 2);
this.mushroomRedGen.generate(this.currentWorld, this.randomGenerator, j, l, k);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, REED);
for (j = 0; doGen && j < this.reedsPerChunk; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2);
this.reedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
for (j = 0; doGen && j < 10; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2);
this.reedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, PUMPKIN);
if (doGen && this.randomGenerator.nextInt(32) == 0) {
j = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
l = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(j, k) * 2);
(new WorldGenPumpkin()).generate(this.currentWorld, this.randomGenerator, j, l, k);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, CACTUS);
for (j = 0; doGen && j < this.cactiPerChunk; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2);
this.cactusGen.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, LAKE);
if (doGen && this.generateLakes) {
for (j = 0; j < 50; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.randomGenerator.nextInt(this.randomGenerator.nextInt(248) + 8);
i1 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
(new WorldGenLiquids(Blocks.flowing_water)).generate(this.currentWorld, this.randomGenerator, k, l, i1);
}
for (j = 0; j < 20; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.randomGenerator.nextInt(this.randomGenerator.nextInt(this.randomGenerator.nextInt(240) + 8) + 8);
i1 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
(new WorldGenLiquids(Blocks.flowing_lava)).generate(this.currentWorld, this.randomGenerator, k, l, i1);
}
}
MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Post(currentWorld, randomGenerator, chunk_X, chunk_Z));
}
}

View file

@ -0,0 +1,56 @@
package net.universe_factory.minecraft.test.blocks;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.universe_factory.minecraft.test.Test;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockGlowfoo extends Block {
private static final IIcon[] textures = new IIcon[16];
public BlockGlowfoo() {
super(Material.glass);
setHardness(0.3F);
setStepSound(soundTypeGlass);
setLightLevel(1.0F);
setCreativeTab(CreativeTabs.tabDecorations);
setBlockName("glowfoo");
setBlockTextureName(Test.MODID + ":glowfoo");
}
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) {
for (int i = 0; i < textures.length; i++)
list.add(new ItemStack(item, 1, i));
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return textures[meta % textures.length];
}
@SideOnly(Side.CLIENT)
private static int negateMeta(int meta) {
return ~meta & 15;
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
for (int i = 0; i < textures.length; i++)
textures[i] = iconRegister.registerIcon(this.getTextureName() + "_" + ItemDye.field_150921_b[negateMeta(i)]);
}
public int damageDropped(int meta) {
return meta;
}
}

View file

@ -47,11 +47,6 @@ public abstract class GenericCrops extends BlockCrops {
} }
} }
@Override
public int getRenderType() {
return 1;
}
public abstract String getName(); public abstract String getName();
public abstract Item itemCrops(); public abstract Item itemCrops();

View file

@ -229,6 +229,9 @@ public abstract class GenericWood {
} }
private class Sapling extends BlockSapling { private class Sapling extends BlockSapling {
WorldGenerator generator = new WorldGenGenericTrees(true, GenericWood.this);
WorldGenerator generatorBig = new WorldGenGenericBigTree(true, GenericWood.this);
public Sapling() { public Sapling() {
setBlockName("sapling" + getName()); setBlockName("sapling" + getName());
@ -262,11 +265,11 @@ public abstract class GenericWood {
if (!TerrainGen.saplingGrowTree(world, random, x, y, z)) if (!TerrainGen.saplingGrowTree(world, random, x, y, z))
return; return;
WorldGenerator generator = new WorldGenGenericTrees(true, GenericWood.this); WorldGenerator treeGenerator = (random.nextInt(10) == 0) ? generatorBig : generator;
world.setBlock(x, y, z, Blocks.air, 0, 4); world.setBlock(x, y, z, Blocks.air, 0, 4);
if (!generator.generate(world, random, x, y, z)) if (!treeGenerator.generate(world, random, x, y, z))
world.setBlock(x, y, z, this, 0, 4); world.setBlock(x, y, z, this, 0, 4);
} }
} }

View file

@ -0,0 +1,442 @@
package net.universe_factory.minecraft.test.generic;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSapling;
import net.minecraft.init.Blocks;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
import net.minecraftforge.common.util.ForgeDirection;
public class WorldGenGenericBigTree extends WorldGenAbstractTree {
private final GenericWood genericWood;
public WorldGenGenericBigTree(boolean notify, GenericWood genericWood) {
super(notify);
this.genericWood = genericWood;
}
/**
* Contains three sets of two values that provide complimentary indices
* for a given 'major' index - 1 and 2 for 0, 0 and 2 for 1, and 0 and 1
* for 2.
*/
static final byte[] otherCoordPairs = new byte[] { (byte) 2, (byte) 0, (byte) 0, (byte) 1, (byte) 2, (byte) 1 };
/** random seed for GenBigTree */
Random rand = new Random();
/** Reference to the World object. */
World worldObj;
int[] basePos = new int[] { 0, 0, 0 };
int heightLimit;
int height;
double heightAttenuation = 0.618D;
double branchDensity = 1.0D;
double branchSlope = 0.381D;
double scaleWidth = 1.0D;
double leafDensity = 1.0D;
/**
* Currently always 1, can be set to 2 in the class constructor to
* generate a double-sized tree trunk for big trees.
*/
int trunkSize = 1;
/**
* Sets the limit of the random value used to initialize the height
* limit.
*/
int heightLimitLimit = 12;
/**
* Sets the distance limit for how far away the generator will populate
* leaves from the base leaf node.
*/
int leafDistanceLimit = 4;
/** Contains a list of a points at which to generate groups of leaves. */
int[][] leafNodes;
/**
* Generates a list of leaf nodes for the tree, to be populated by
* generateLeaves.
*/
void generateLeafNodeList() {
this.height = (int) ((double) this.heightLimit * this.heightAttenuation);
if (this.height >= this.heightLimit) {
this.height = this.heightLimit - 1;
}
int i = (int) (1.382D + Math.pow(this.leafDensity * (double) this.heightLimit / 13.0D, 2.0D));
if (i < 1) {
i = 1;
}
int[][] aint = new int[i * this.heightLimit][4];
int j = this.basePos[1] + this.heightLimit - this.leafDistanceLimit;
int k = 1;
int l = this.basePos[1] + this.height;
int i1 = j - this.basePos[1];
aint[0][0] = this.basePos[0];
aint[0][1] = j;
aint[0][2] = this.basePos[2];
aint[0][3] = l;
--j;
while (i1 >= 0) {
int j1 = 0;
float f = this.layerSize(i1);
if (f < 0.0F) {
--j;
--i1;
} else {
for (double d0 = 0.5D; j1 < i; ++j1) {
double d1 = this.scaleWidth * (double) f * ((double) this.rand.nextFloat() + 0.328D);
double d2 = (double) this.rand.nextFloat() * 2.0D * Math.PI;
int k1 = MathHelper.floor_double(d1 * Math.sin(d2) + (double) this.basePos[0] + d0);
int l1 = MathHelper.floor_double(d1 * Math.cos(d2) + (double) this.basePos[2] + d0);
int[] aint1 = new int[] { k1, j, l1 };
int[] aint2 = new int[] { k1, j + this.leafDistanceLimit, l1 };
if (this.checkBlockLine(aint1, aint2) == -1) {
int[] aint3 = new int[] { this.basePos[0], this.basePos[1], this.basePos[2] };
double d3 = Math.sqrt(Math.pow((double) Math.abs(this.basePos[0] - aint1[0]), 2.0D)
+ Math.pow((double) Math.abs(this.basePos[2] - aint1[2]), 2.0D));
double d4 = d3 * this.branchSlope;
if ((double) aint1[1] - d4 > (double) l) {
aint3[1] = l;
} else {
aint3[1] = (int) ((double) aint1[1] - d4);
}
if (this.checkBlockLine(aint3, aint1) == -1) {
aint[k][0] = k1;
aint[k][1] = j;
aint[k][2] = l1;
aint[k][3] = aint3[1];
++k;
}
}
}
--j;
--i1;
}
}
this.leafNodes = new int[k][4];
System.arraycopy(aint, 0, this.leafNodes, 0, k);
}
void func_150529_a(int p_150529_1_, int p_150529_2_, int p_150529_3_, float p_150529_4_, byte p_150529_5_, Block p_150529_6_) {
int l = (int) ((double) p_150529_4_ + 0.618D);
byte b1 = otherCoordPairs[p_150529_5_];
byte b2 = otherCoordPairs[p_150529_5_ + 3];
int[] aint = new int[] { p_150529_1_, p_150529_2_, p_150529_3_ };
int[] aint1 = new int[] { 0, 0, 0 };
int i1 = -l;
int j1 = -l;
for (aint1[p_150529_5_] = aint[p_150529_5_]; i1 <= l; ++i1) {
aint1[b1] = aint[b1] + i1;
j1 = -l;
while (j1 <= l) {
double d0 = Math.pow((double) Math.abs(i1) + 0.5D, 2.0D) + Math.pow((double) Math.abs(j1) + 0.5D, 2.0D);
if (d0 > (double) (p_150529_4_ * p_150529_4_)) {
++j1;
} else {
aint1[b2] = aint[b2] + j1;
Block block1 = this.worldObj.getBlock(aint1[0], aint1[1], aint1[2]);
if (!block1.isAir(worldObj, aint1[0], aint1[1], aint1[2]) && !block1.isLeaves(worldObj, aint1[0], aint1[1], aint1[2])) {
++j1;
} else {
this.setBlockAndNotifyAdequately(this.worldObj, aint1[0], aint1[1], aint1[2], p_150529_6_, 0);
++j1;
}
}
}
}
}
/**
* Gets the rough size of a layer of the tree.
*/
float layerSize(int par1) {
if ((double) par1 < (double) ((float) this.heightLimit) * 0.3D) {
return -1.618F;
} else {
float f = (float) this.heightLimit / 2.0F;
float f1 = (float) this.heightLimit / 2.0F - (float) par1;
float f2;
if (f1 == 0.0F) {
f2 = f;
} else if (Math.abs(f1) >= f) {
f2 = 0.0F;
} else {
f2 = (float) Math.sqrt(Math.pow((double) Math.abs(f), 2.0D) - Math.pow((double) Math.abs(f1), 2.0D));
}
f2 *= 0.5F;
return f2;
}
}
float leafSize(int par1) {
return par1 >= 0 && par1 < this.leafDistanceLimit ? (par1 != 0 && par1 != this.leafDistanceLimit - 1 ? 3.0F : 2.0F) : -1.0F;
}
/**
* Generates the leaves surrounding an individual entry in the leafNodes
* list.
*/
void generateLeafNode(int par1, int par2, int par3) {
int l = par2;
for (int i1 = par2 + this.leafDistanceLimit; l < i1; ++l) {
float f = this.leafSize(l - par2);
this.func_150529_a(par1, l, par3, f, (byte) 1, genericWood.leaves);
}
}
void func_150530_a(int[] p_150530_1_, int[] p_150530_2_, Block p_150530_3_) {
int[] aint2 = new int[] { 0, 0, 0 };
byte b0 = 0;
byte b1;
for (b1 = 0; b0 < 3; ++b0) {
aint2[b0] = p_150530_2_[b0] - p_150530_1_[b0];
if (Math.abs(aint2[b0]) > Math.abs(aint2[b1])) {
b1 = b0;
}
}
if (aint2[b1] != 0) {
byte b2 = otherCoordPairs[b1];
byte b3 = otherCoordPairs[b1 + 3];
byte b4;
if (aint2[b1] > 0) {
b4 = 1;
} else {
b4 = -1;
}
double d0 = (double) aint2[b2] / (double) aint2[b1];
double d1 = (double) aint2[b3] / (double) aint2[b1];
int[] aint3 = new int[] { 0, 0, 0 };
int i = 0;
for (int j = aint2[b1] + b4; i != j; i += b4) {
aint3[b1] = MathHelper.floor_double((double) (p_150530_1_[b1] + i) + 0.5D);
aint3[b2] = MathHelper.floor_double((double) p_150530_1_[b2] + (double) i * d0 + 0.5D);
aint3[b3] = MathHelper.floor_double((double) p_150530_1_[b3] + (double) i * d1 + 0.5D);
byte b5 = 0;
int k = Math.abs(aint3[0] - p_150530_1_[0]);
int l = Math.abs(aint3[2] - p_150530_1_[2]);
int i1 = Math.max(k, l);
if (i1 > 0) {
if (k == i1) {
b5 = 4;
} else if (l == i1) {
b5 = 8;
}
}
this.setBlockAndNotifyAdequately(this.worldObj, aint3[0], aint3[1], aint3[2], p_150530_3_, b5);
}
}
}
/**
* Generates the leaf portion of the tree as specified by the leafNodes
* list.
*/
void generateLeaves() {
int i = 0;
for (int j = this.leafNodes.length; i < j; ++i) {
int k = this.leafNodes[i][0];
int l = this.leafNodes[i][1];
int i1 = this.leafNodes[i][2];
this.generateLeafNode(k, l, i1);
}
}
/**
* Indicates whether or not a leaf node requires additional wood to be
* added to preserve integrity.
*/
boolean leafNodeNeedsBase(int par1) {
return (double) par1 >= (double) this.heightLimit * 0.2D;
}
/**
* Places the trunk for the big tree that is being generated. Able to
* generate double-sized trunks by changing a field that is always 1 to
* 2.
*/
void generateTrunk() {
int i = this.basePos[0];
int j = this.basePos[1];
int k = this.basePos[1] + this.height;
int l = this.basePos[2];
int[] aint = new int[] { i, j, l };
int[] aint1 = new int[] { i, k, l };
this.func_150530_a(aint, aint1, genericWood.log);
if (this.trunkSize == 2) {
++aint[0];
++aint1[0];
this.func_150530_a(aint, aint1, genericWood.log);
++aint[2];
++aint1[2];
this.func_150530_a(aint, aint1, genericWood.log);
aint[0] += -1;
aint1[0] += -1;
this.func_150530_a(aint, aint1, genericWood.log);
}
}
/**
* Generates additional wood blocks to fill out the bases of different
* leaf nodes that would otherwise degrade.
*/
void generateLeafNodeBases() {
int i = 0;
int j = this.leafNodes.length;
for (int[] aint = new int[] { this.basePos[0], this.basePos[1], this.basePos[2] }; i < j; ++i) {
int[] aint1 = this.leafNodes[i];
int[] aint2 = new int[] { aint1[0], aint1[1], aint1[2] };
aint[1] = aint1[3];
int k = aint[1] - this.basePos[1];
if (this.leafNodeNeedsBase(k)) {
this.func_150530_a(aint, aint2, genericWood.log);
}
}
}
/**
* Checks a line of blocks in the world from the first coordinate to
* triplet to the second, returning the distance (in blocks) before a
* non-air, non-leaf block is encountered and/or the end is encountered.
*/
int checkBlockLine(int[] par1ArrayOfInteger, int[] par2ArrayOfInteger) {
int[] aint2 = new int[] { 0, 0, 0 };
byte b0 = 0;
byte b1;
for (b1 = 0; b0 < 3; ++b0) {
aint2[b0] = par2ArrayOfInteger[b0] - par1ArrayOfInteger[b0];
if (Math.abs(aint2[b0]) > Math.abs(aint2[b1])) {
b1 = b0;
}
}
if (aint2[b1] == 0) {
return -1;
} else {
byte b2 = otherCoordPairs[b1];
byte b3 = otherCoordPairs[b1 + 3];
byte b4;
if (aint2[b1] > 0) {
b4 = 1;
} else {
b4 = -1;
}
double d0 = (double) aint2[b2] / (double) aint2[b1];
double d1 = (double) aint2[b3] / (double) aint2[b1];
int[] aint3 = new int[] { 0, 0, 0 };
int i = 0;
int j;
for (j = aint2[b1] + b4; i != j; i += b4) {
aint3[b1] = par1ArrayOfInteger[b1] + i;
aint3[b2] = MathHelper.floor_double((double) par1ArrayOfInteger[b2] + (double) i * d0);
aint3[b3] = MathHelper.floor_double((double) par1ArrayOfInteger[b3] + (double) i * d1);
Block block = this.worldObj.getBlock(aint3[0], aint3[1], aint3[2]);
if (!this.isReplaceable(worldObj, aint3[0], aint3[1], aint3[2])) {
break;
}
}
return i == j ? -1 : Math.abs(i);
}
}
/**
* Returns a boolean indicating whether or not the current location for
* the tree, spanning basePos to to the height limit, is valid.
*/
boolean validTreeLocation() {
int[] aint = new int[] { this.basePos[0], this.basePos[1], this.basePos[2] };
int[] aint1 = new int[] { this.basePos[0], this.basePos[1] + this.heightLimit - 1, this.basePos[2] };
Block block = this.worldObj.getBlock(this.basePos[0], this.basePos[1] - 1, this.basePos[2]);
boolean isSoil = block.canSustainPlant(worldObj, basePos[0], basePos[1] - 1, basePos[2], ForgeDirection.UP, (BlockSapling) Blocks.sapling);
if (!isSoil) {
return false;
} else {
int i = this.checkBlockLine(aint, aint1);
if (i == -1) {
return true;
} else if (i < 6) {
return false;
} else {
this.heightLimit = i;
return true;
}
}
}
/**
* Rescales the generator settings, only used in WorldGenBigTree
*/
public void setScale(double par1, double par3, double par5) {
this.heightLimitLimit = (int) (par1 * 12.0D);
if (par1 > 0.5D) {
this.leafDistanceLimit = 5;
}
this.scaleWidth = par3;
this.leafDensity = par5;
}
public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) {
this.worldObj = par1World;
long l = par2Random.nextLong();
this.rand.setSeed(l);
this.basePos[0] = par3;
this.basePos[1] = par4;
this.basePos[2] = par5;
if (this.heightLimit == 0) {
this.heightLimit = 5 + this.rand.nextInt(this.heightLimitLimit);
}
if (!this.validTreeLocation()) {
return false;
} else {
this.generateLeafNodeList();
this.generateLeaves();
this.generateTrunk();
this.generateLeafNodeBases();
return true;
}
}
}

View file

@ -10,8 +10,8 @@ import net.minecraftforge.common.util.ForgeDirection;
public class WorldGenGenericTrees extends WorldGenAbstractTree { public class WorldGenGenericTrees extends WorldGenAbstractTree {
private final GenericWood genericWood; private final GenericWood genericWood;
public WorldGenGenericTrees(boolean b, GenericWood genericWood) { public WorldGenGenericTrees(boolean notify, GenericWood genericWood) {
super(b); super(notify);
this.genericWood = genericWood; this.genericWood = genericWood;
} }

View file

@ -0,0 +1,283 @@
package net.universe_factory.minecraft.test.world;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.BIG_SHROOM;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.CACTUS;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.CLAY;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.DEAD_BUSH;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.FLOWERS;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.GRASS;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.LAKE;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.LILYPAD;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.PUMPKIN;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.REED;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.SAND;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.SAND_PASS2;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.SHROOM;
import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.TREE;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeDecorator;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
import net.minecraft.world.gen.feature.WorldGenDeadBush;
import net.minecraft.world.gen.feature.WorldGenLiquids;
import net.minecraft.world.gen.feature.WorldGenPumpkin;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.terraingen.DecorateBiomeEvent;
import net.minecraftforge.event.terraingen.TerrainGen;
public class ExtensibleBiomeDecorator {
private ArrayList<Tree> trees = new ArrayList<Tree>();
public void registerTree(Tree tree) {
trees.add(tree);
}
public BiomeDecorator getInstance(BiomeDecorator base) {
BiomeDecorator decorator = new Decorator();
if (base != null) {
decorator.bigMushroomsPerChunk = base.bigMushroomsPerChunk;
decorator.cactiPerChunk = base.cactiPerChunk;
decorator.clayPerChunk = base.clayPerChunk;
decorator.deadBushPerChunk = base.deadBushPerChunk;
decorator.flowersPerChunk = base.flowersPerChunk;
decorator.generateLakes = base.generateLakes;
decorator.grassPerChunk = base.grassPerChunk;
decorator.mushroomsPerChunk = base.mushroomsPerChunk;
decorator.reedsPerChunk = base.reedsPerChunk;
decorator.sandPerChunk = base.sandPerChunk;
decorator.sandPerChunk2 = base.sandPerChunk2;
decorator.treesPerChunk = base.treesPerChunk;
decorator.waterlilyPerChunk = base.waterlilyPerChunk;
}
return decorator;
}
public interface Tree {
public Map.Entry<WorldGenAbstractTree, Float> replaceTree(World world, BiomeGenBase biome, Random random, int x, int y, int z,
WorldGenAbstractTree orig);
}
protected class Decorator extends BiomeDecorator {
protected void genDecorations(BiomeGenBase biome) {
MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Pre(currentWorld, randomGenerator, chunk_X, chunk_Z));
this.generateOres();
int i;
int j;
int k;
boolean doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SAND);
for (i = 0; doGen && i < this.sandPerChunk2; ++i) {
j = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
this.sandGen.generate(this.currentWorld, this.randomGenerator, j, this.currentWorld.getTopSolidOrLiquidBlock(j, k), k);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, CLAY);
for (i = 0; doGen && i < this.clayPerChunk; ++i) {
j = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
this.clayGen.generate(this.currentWorld, this.randomGenerator, j, this.currentWorld.getTopSolidOrLiquidBlock(j, k), k);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SAND_PASS2);
for (i = 0; doGen && i < this.sandPerChunk; ++i) {
j = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
this.gravelAsSandGen.generate(this.currentWorld, this.randomGenerator, j, this.currentWorld.getTopSolidOrLiquidBlock(j, k), k);
}
i = this.treesPerChunk;
if (this.randomGenerator.nextInt(10) == 0) {
++i;
}
int l;
int i1;
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, TREE);
for (j = 0; doGen && j < i; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
i1 = this.currentWorld.getHeightValue(k, l);
WorldGenAbstractTree defaultTreeGen = biome.func_150567_a(this.randomGenerator);
float weight = 1.0f;
Map<WorldGenAbstractTree, Float> treeWeights = new HashMap<WorldGenAbstractTree, Float>();
treeWeights.put(defaultTreeGen, 1.0f);
for (Tree tree : trees) {
Map.Entry<WorldGenAbstractTree, Float> entry = tree.replaceTree(currentWorld, biome, randomGenerator, k, i1, l,
defaultTreeGen);
if (entry != null) {
weight += entry.getValue();
treeWeights.put(entry.getKey(), entry.getValue());
}
}
WorldGenAbstractTree treeGen = null;
float p = randomGenerator.nextFloat() * weight;
for (Map.Entry<WorldGenAbstractTree, Float> entry : treeWeights.entrySet()) {
p -= entry.getValue();
if (p < 0) {
treeGen = entry.getKey();
break;
}
}
treeGen.setScale(1.0D, 1.0D, 1.0D);
if (treeGen.generate(this.currentWorld, this.randomGenerator, k, i1, l))
treeGen.func_150524_b(this.currentWorld, this.randomGenerator, k, i1, l);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, BIG_SHROOM);
for (j = 0; doGen && j < this.bigMushroomsPerChunk; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
this.bigMushroomGen.generate(this.currentWorld, this.randomGenerator, k, this.currentWorld.getHeightValue(k, l), l);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, FLOWERS);
for (j = 0; doGen && j < this.flowersPerChunk; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) + 32);
String s = biome.func_150572_a(this.randomGenerator, k, i1, l);
BlockFlower blockflower = BlockFlower.func_149857_e(s);
if (blockflower.getMaterial() != Material.air) {
this.yellowFlowerGen.func_150550_a(blockflower, BlockFlower.func_149856_f(s));
this.yellowFlowerGen.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, GRASS);
for (j = 0; doGen && j < this.grassPerChunk; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2);
WorldGenerator worldgenerator = biome.getRandomWorldGenForGrass(this.randomGenerator);
worldgenerator.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, DEAD_BUSH);
for (j = 0; doGen && j < this.deadBushPerChunk; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2);
(new WorldGenDeadBush(Blocks.deadbush)).generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, LILYPAD);
for (j = 0; doGen && j < this.waterlilyPerChunk; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
for (i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2); i1 > 0
&& this.currentWorld.isAirBlock(k, i1 - 1, l); --i1) {
;
}
this.waterlilyGen.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SHROOM);
for (j = 0; doGen && j < this.mushroomsPerChunk; ++j) {
if (this.randomGenerator.nextInt(4) == 0) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
i1 = this.currentWorld.getHeightValue(k, l);
this.mushroomBrownGen.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
if (this.randomGenerator.nextInt(8) == 0) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2);
this.mushroomRedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
}
if (doGen && this.randomGenerator.nextInt(4) == 0) {
j = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
l = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(j, k) * 2);
this.mushroomBrownGen.generate(this.currentWorld, this.randomGenerator, j, l, k);
}
if (doGen && this.randomGenerator.nextInt(8) == 0) {
j = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
l = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(j, k) * 2);
this.mushroomRedGen.generate(this.currentWorld, this.randomGenerator, j, l, k);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, REED);
for (j = 0; doGen && j < this.reedsPerChunk; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2);
this.reedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
for (j = 0; doGen && j < 10; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2);
this.reedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, PUMPKIN);
if (doGen && this.randomGenerator.nextInt(32) == 0) {
j = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
l = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(j, k) * 2);
(new WorldGenPumpkin()).generate(this.currentWorld, this.randomGenerator, j, l, k);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, CACTUS);
for (j = 0; doGen && j < this.cactiPerChunk; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2);
this.cactusGen.generate(this.currentWorld, this.randomGenerator, k, i1, l);
}
doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, LAKE);
if (doGen && this.generateLakes) {
for (j = 0; j < 50; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.randomGenerator.nextInt(this.randomGenerator.nextInt(248) + 8);
i1 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
(new WorldGenLiquids(Blocks.flowing_water)).generate(this.currentWorld, this.randomGenerator, k, l, i1);
}
for (j = 0; j < 20; ++j) {
k = this.chunk_X + this.randomGenerator.nextInt(16) + 8;
l = this.randomGenerator.nextInt(this.randomGenerator.nextInt(this.randomGenerator.nextInt(240) + 8) + 8);
i1 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8;
(new WorldGenLiquids(Blocks.flowing_lava)).generate(this.currentWorld, this.randomGenerator, k, l, i1);
}
}
MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Post(currentWorld, randomGenerator, chunk_X, chunk_Z));
}
}
}

View file

@ -7,6 +7,40 @@ tile.saplingCherry.name=Cherry Tree Sapling
tile.woodSlabCherry.name=Cherry Tree Wood Slab tile.woodSlabCherry.name=Cherry Tree Wood Slab
tile.stairsWoodCherry.name=Cherry Tree Wood Stairs tile.stairsWoodCherry.name=Cherry Tree Wood Stairs
tile.woodSchnitzel.name=Schnitzel Tree Wood Planks
tile.logSchnitzel.name=Schnitzel Tree Wood
tile.leavesSchnitzel.name=Schnitzel Tree Leaves
tile.saplingSchnitzel.name=Schnitzel Tree Sapling
tile.woodSlabSchnitzel.name=Schnitzel Tree Wood Slab
tile.stairsWoodSchnitzel.name=Schnitzel Tree Wood Stairs
item.salad.name=Salad item.salad.name=Salad
item.seedsSalad.name=Salad Seeds item.seedsSalad.name=Salad Seeds
tile.salad.name=Salad tile.salad.name=Salad
item.cucumber.name=Cucumber
item.seedsCucumber.name=Cucumber Seeds
tile.cucumber.name=Cucumber
item.raddish.name=Raddish
tile.raddish.name=Raddish
tile.glowfoo.black.name=Black Light
tile.glowfoo.red.name=Red Light
tile.glowfoo.green.name=Green Light
tile.glowfoo.brown.name=Brown Light
tile.glowfoo.blue.name=Blue Light
tile.glowfoo.purple.name=Purple Light
tile.glowfoo.cyan.name=Cyan Light
tile.glowfoo.silver.name=Light Gray Light
tile.glowfoo.gray.name=Gray Light
tile.glowfoo.pink.name=Pink Light
tile.glowfoo.lime.name=Lime Light
tile.glowfoo.yellow.name=Yellow Light
tile.glowfoo.lightBlue.name=Light Blue Light
tile.glowfoo.magenta.name=Magenta Light
tile.glowfoo.orange.name=Orange Light
tile.liquid_light.name=Liquid Light
item.bucket_light.name=Light Bucket

Binary file not shown.

Before

Width:  |  Height:  |  Size: 467 B

After

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 462 B

After

Width:  |  Height:  |  Size: 581 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 501 B

After

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 644 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

View file

@ -0,0 +1,3 @@
{
"animation": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

View file

@ -0,0 +1,5 @@
{
"animation": {
"frametime": 2
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 835 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 858 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 501 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B