From 40487f07fa5ef31fde99713c0b842d34a0ba3622 Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Sun, 31 May 2015 01:44:17 +0100 Subject: - Fixed an issue with the Liquids tab - Changed Entity registration so it only uses 'registerModEntity' to fix potential issues - Added crystal blocks - Changed Jewelry Tab to not override TiCon tabs (sorry TiCon, your system is good, but not for me) - The player renders in the Jewelry GUI (makes it easier for you to see how the jewelry render) - The Pentagram now has an actual effect - The Pentagram now renders beneath your feet when you look down and no longer does it in your inventory; it is also a lot smaller - Working on Structures - Created my own WeightedRandomItem (why isn't this in vanilla?) - Updated the curse API so now people can specify when a curse can be activated (I believe the world is all you need :p) - Some curses can no longer aquired in hardcore (such as Rotten Heart, Midas Touch etc) which would make it impossible to work with and require a total restart of the game (as the only way to get rid of them is by dying to replace them) Hooraaay for proper changelogs! --- .../jewelrycraft/worldGen/Generation.java | 39 +++++-------- .../jewelrycraft/worldGen/WeightedRandomItem.java | 67 ++++++++++++++++++++++ .../jewelrycraft/worldGen/WorldGenStructure1.java | 61 ++++++++++++++++++++ 3 files changed, 141 insertions(+), 26 deletions(-) create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WeightedRandomItem.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java (limited to 'src/main/java/darkknight/jewelrycraft/worldGen') diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java b/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java index 5992273..d71b44c 100644 --- a/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java @@ -9,15 +9,8 @@ import darkknight.jewelrycraft.block.BlockList; public class Generation implements IWorldGenerator { + WorldGenStructure1 STRUCTURE_1 = new WorldGenStructure1(); - /** - * @param random - * @param chunkX - * @param chunkZ - * @param world - * @param chunkGenerator - * @param chunkProvider - */ @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { @@ -35,21 +28,9 @@ public class Generation implements IWorldGenerator } } - /** - * @param world - * @param random - * @param i - * @param j - */ private void generateEnd(World world, Random random, int i, int j) {} - /** - * @param world - * @param random - * @param i - * @param j - */ private void generateSurface(World world, Random random, int i, int j) { for(int k = 0; k < 1; k++){ @@ -60,14 +41,20 @@ public class Generation implements IWorldGenerator int randX = random.nextInt(2), randY = random.nextInt(1), randZ = random.nextInt(2); if (random.nextInt(3) == 0 && world.getBlock(x + randX, y + randY, z + randZ) == Blocks.stone) world.setBlock(x + randX, y + randY, z + randZ, BlockList.shadowOre); } + for(int k = 0; k < 16; k++){ + int x = i + random.nextInt(12); + int y = 5 + random.nextInt(64); + int z = j + random.nextInt(12); + for(int r = 0; r < 12; r++){ + int randX = random.nextInt(4); + int randY = random.nextInt(2); + int randZ = random.nextInt(4); + if (world.getBlock(x + randX, y + randY - 1, z + randZ) == Blocks.stone && world.getBlock(x + randX, y + randY, z + randZ) == Blocks.air) + world.setBlock(x + randX, y + randY, z + randZ, BlockList.crystal, random.nextInt(16), 2); + } + } } - /** - * @param world - * @param random - * @param i - * @param j - */ private void generateNether(World world, Random random, int i, int j) {} } diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WeightedRandomItem.java b/src/main/java/darkknight/jewelrycraft/worldGen/WeightedRandomItem.java new file mode 100644 index 0000000..0528b66 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WeightedRandomItem.java @@ -0,0 +1,67 @@ +package darkknight.jewelrycraft.worldGen; + +import java.util.Random; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandom; + +public class WeightedRandomItem extends WeightedRandom.Item +{ + private final ItemStack item; + private int maxMeta, minMeta, minItem, maxItem; + + public WeightedRandomItem(ItemStack item, int weight) + { + super(weight); + this.item = item; + this.minItem = 1; + this.maxItem = 1; + this.maxMeta = 0; + this.minMeta = 0; + } + + public WeightedRandomItem(ItemStack item, int maxMetadata, int weight) + { + this(item, weight); + this.maxMeta = maxMetadata; + } + + public WeightedRandomItem(ItemStack item, int weight, int minItem, int maxItem) + { + this(item, weight); + this.minItem = minItem; + this.maxItem = maxItem; + } + + public WeightedRandomItem setMaxMetadata(int meta) + { + this.maxMeta = meta; + return this; + } + + public WeightedRandomItem setMinMetadata(int meta) + { + this.minMeta = meta; + return this; + } + + public WeightedRandomItem setMinItem(int min) + { + this.minItem = min; + return this; + } + + public WeightedRandomItem setMaxItem(int max) + { + this.maxItem = max; + return this; + } + + public ItemStack getItem(Random random) + { + ItemStack itemstack = this.item.copy(); + if(maxMeta > 0) itemstack.setItemDamage(minMeta + random.nextInt(maxMeta - minMeta)); + if(maxItem > 1) itemstack.stackSize = this.minItem + random.nextInt(this.maxItem - this.minItem + 1); + return itemstack; + } +} \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java new file mode 100644 index 0000000..2d11cb5 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java @@ -0,0 +1,61 @@ +/** + * + */ +package darkknight.jewelrycraft.worldGen; + +import java.util.Arrays; +import java.util.List; +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandom; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +/** + * @author Sorin + */ +public class WorldGenStructure1 extends WorldGenerator +{ + public static final WeightedRandomItem[] items = new WeightedRandomItem[] { + new WeightedRandomItem(new ItemStack(ItemList.thiefGloves), 7), + new WeightedRandomItem(new ItemStack(Items.golden_apple), 5), + new WeightedRandomItem(new ItemStack(Items.golden_apple, 1, 1), 1), + new WeightedRandomItem(new ItemStack(ItemList.guide), 10), + new WeightedRandomItem(new ItemStack(ItemList.shadowIngot), 15), + new WeightedRandomItem(new ItemStack(BlockList.shadowEye), 2), + new WeightedRandomItem(new ItemStack(Items.nether_star), 1), + new WeightedRandomItem(new ItemStack(BlockList.shadowBlock), 2), + new WeightedRandomItem(new ItemStack(BlockList.crystal), 16, 10) + }; + + @Override + public boolean generate(World world, Random rand, int x, int y, int z) + { + for(int i = -2; i <= 2; i++) + for(int j = -1; j <= 4; j++) + for(int k = -2; k <= 2; k++) + world.setBlock(x + i, y + j, z + k, Blocks.air); + + for(int i = -2; i <= 2; i++) + for(int k = -2; k <= 2; k++){ + world.setBlock(x + i, y - 1, z + k, Blocks.stonebrick); + if (i % 2 == 0 && k % 2 == 0 && i != 0 && k != 0) world.setBlock(x + i, y, z + k, BlockList.crystal); + } + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlock(x + i, y, z + k, Blocks.stone_slab, 5, 2); + + world.setBlock(x, y, z, Blocks.stonebrick); + world.setBlock(x, y+1, z, BlockList.handPedestal, 6, 2); + TileEntityHandPedestal pedestal = (TileEntityHandPedestal)world.getTileEntity(x, y+1, z); + pedestal.setHeldItemStack(((WeightedRandomItem)WeightedRandom.getRandomItem(rand, items)).getItem(rand)); + + return true; + } +} -- cgit v1.2.3