summaryrefslogtreecommitdiff
path: root/src/main/java/darkknight/jewelrycraft/worldGen
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-06-11 18:10:50 +0100
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-06-11 18:10:50 +0100
commite66ce0d4678e288d981f734fa7fdec8f9642545e (patch)
treea03554751652971e6d344bc1629b9b4cec1f30df /src/main/java/darkknight/jewelrycraft/worldGen
parent8889b2af5ad007e508adf893e2e0f7ed65e93239 (diff)
Fixed liquids on servers + other stuff
Diffstat (limited to 'src/main/java/darkknight/jewelrycraft/worldGen')
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure2.java97
-rw-r--r--src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java147
2 files changed, 127 insertions, 117 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure2.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure2.java
index f8b3094..b7662bb 100644
--- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure2.java
+++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure2.java
@@ -20,51 +20,54 @@ import darkknight.jewelrycraft.util.JewelrycraftUtil;
/**
* @author Sorin
*/
-public class WorldGenStructure2 extends WorldGenerator
-{
- public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z)
- {
- Block block = Blocks.stonebrick;
- Block stair = Blocks.stone_brick_stairs;
- int metadata = 0, slabMeta = 5;
- if (biome == BiomeGenBase.desert || biome == BiomeGenBase.desertHills){
- block = Blocks.sandstone;
- stair = Blocks.sandstone_stairs;
- metadata = 2;
- }
- for(int i = -1; i <= 1; i++)
- for(int k = -1; k <= 1; k++)
- world.setBlock(x + i, y, z + k, Blocks.air);
- for(int i = -1; i <= 1; i++)
- for(int k = -1; k <= 1; k++)
- world.setBlock(x + i, y - 1, z + k, block, metadata, 2);
- for(int i = -1; i <= 1; i++)
- for(int k = -1; k <= 1; k++)
- world.setBlock(x + i, y, z + k, stair);
- for(int i = -1; i <= 1; i++)
- for(int k = -1; k <= 1; k++)
- world.setBlockMetadataWithNotify(x + i, y, z + k, (k == -1) ? 3 : (k == 0) ? (i == 1) ? 0 : 1 : 2, 2);
- world.setBlock(x, y, z, Blocks.air);
- ItemStack stack = new ItemStack(ItemList.bucket);
- JewelryNBT.addMetal(stack, JewelrycraftUtil.metal.get(rand.nextInt(JewelrycraftUtil.metal.size())));
- try{
- if (stack != null && JewelryNBT.ingot(stack) != null){
- if (!world.isRemote) world.func_147480_a(x, y, z, true);
- int color = ItemMoltenMetalBucket.color(stack, 1);
- JewelrycraftMod.saveData.setString(x + " " + y + " " + z + " " + world.provider.dimensionId, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) + ":" + JewelryNBT.ingot(stack).getItemDamage() + ":" + color);
- JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x, y, z, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()), JewelryNBT.ingot(stack).getItemDamage(), color));
- world.setBlock(x, y, z, BlockList.moltenMetal, 0, 3);
- }
- }
- catch(IOException e){
- e.printStackTrace();
- }
- return true;
- }
-
- @Override
- public boolean generate(World world, Random rand, int x, int y, int z)
- {
- return generate(world, BiomeGenBase.plains, rand, x, y, z);
- }
+public class WorldGenStructure2 extends WorldGenerator {
+ public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) {
+ Block block = Blocks.stonebrick;
+ Block stair = Blocks.stone_brick_stairs;
+ int metadata = 0, slabMeta = 5;
+ if (biome == BiomeGenBase.desert || biome == BiomeGenBase.desertHills) {
+ block = Blocks.sandstone;
+ stair = Blocks.sandstone_stairs;
+ metadata = 2;
+ }
+ for (int i = -1; i <= 1; i++)
+ for (int k = -1; k <= 1; k++)
+ world.setBlock(x + i, y, z + k, Blocks.air);
+ for (int i = -1; i <= 1; i++)
+ for (int k = -1; k <= 1; k++)
+ world.setBlock(x + i, y - 1, z + k, block, metadata, 2);
+ for (int i = -1; i <= 1; i++)
+ for (int k = -1; k <= 1; k++)
+ world.setBlock(x + i, y, z + k, stair);
+ for (int i = -1; i <= 1; i++)
+ for (int k = -1; k <= 1; k++)
+ world.setBlockMetadataWithNotify(x + i, y, z + k, (k == -1) ? 3 : (k == 0) ? (i == 1) ? 0 : 1 : 2, 2);
+ world.setBlock(x, y, z, Blocks.air);
+ ItemStack stack = new ItemStack(ItemList.bucket);
+ JewelryNBT.addMetal(stack, JewelrycraftUtil.metal.get(rand.nextInt(JewelrycraftUtil.metal.size())));
+ try {
+ if (stack != null && JewelryNBT.ingot(stack) != null) {
+ if (!world.isRemote) world.func_147480_a(x, y, z, true);
+ if (world.isRemote) {
+ int color = ItemMoltenMetalBucket.color(stack, 1);
+ JewelrycraftMod.saveData.setString(x + " " + y + " " + z + " " + world.provider.dimensionId, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) + ":" + JewelryNBT.ingot(stack).getItemDamage() + ":" + color);
+ JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x, y, z, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()), JewelryNBT.ingot(stack).getItemDamage(), color));
+ }
+ else{
+ JewelrycraftMod.saveData.setString(x + " " + y + " " + z + " " + world.provider.dimensionId, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) + ":" + JewelryNBT.ingot(stack).getItemDamage() + ":" + rand.nextInt(16777216));
+ JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x, y, z, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()), JewelryNBT.ingot(stack).getItemDamage(), rand.nextInt(16777216)));
+ }
+ System.out.println(x + " " + y + " " + z);
+ world.setBlock(x, y, z, BlockList.moltenMetal, 0, 3);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return true;
+ }
+
+ @Override
+ public boolean generate(World world, Random rand, int x, int y, int z) {
+ return generate(world, BiomeGenBase.plains, rand, x, y, z);
+ }
}
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java
index 0533a1b..5518ef4 100644
--- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java
+++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java
@@ -5,14 +5,18 @@ package darkknight.jewelrycraft.worldGen;
import java.io.IOException;
import java.util.Random;
+
+import cpw.mods.fml.relauncher.Side;
import darkknight.jewelrycraft.JewelrycraftMod;
import darkknight.jewelrycraft.block.BlockList;
import darkknight.jewelrycraft.item.ItemList;
import darkknight.jewelrycraft.item.ItemMoltenMetalBucket;
+import darkknight.jewelrycraft.network.PacketRequestLiquidData;
import darkknight.jewelrycraft.network.PacketSendLiquidData;
import darkknight.jewelrycraft.util.JewelryNBT;
import darkknight.jewelrycraft.util.JewelrycraftUtil;
import net.minecraft.block.Block;
+import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
@@ -26,74 +30,77 @@ import net.minecraftforge.common.DungeonHooks;
/**
* @author Sorin
*/
-public class WorldGenStructure5 extends WorldGenerator
-{
- public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z)
- {
- Block slab = Blocks.stone_slab;
- Block stair = Blocks.stone_brick_stairs;
- Block block = Blocks.stonebrick;
- int metadata = 0, slabMeta = 5;
- if (biome == BiomeGenBase.desert || biome == BiomeGenBase.desertHills){
- stair = Blocks.sandstone_stairs;
- block = Blocks.sandstone;
- metadata = 2;
- slabMeta = 1;
- }
- for(int i = -2; i <= 2; i++)
- for(int j = 0; j <= 3; j++)
- for(int k = -3; k <= -1; k++)
- world.setBlock(x + i, y + j, z + k, Blocks.air);
- for(int i = -5; i <= -3; i++)
- for(int k = -3; k <= 2; k++)
- world.setBlock(x + i, y, z + k, Blocks.air);
- for(int i = -2; i <= 2; i++)
- for(int k = -3; k <= -1; k++)
- world.setBlock(x + i, y, z + k, block, metadata, 1);
- for(int i = 1; i <= 2; i++)
- for(int k = -3; k <= -1; k++)
- world.setBlock(x + i, y + 1, z + k, block, metadata, 1);
- for(int i = -5; i <= -3; i++)
- for(int k = -3; k <= 2; k++)
- world.setBlock(x + i, y - 1, z + k, block, metadata, 1);
- for(int i = -5; i <= -3; i++)
- for(int k = -3; k <= 2; k++)
- if ((i != -4 || k <= -3 || k >= 2) && !(i == -3 && k == -2)) world.setBlock(x + i, y, z + k, slab, slabMeta, 2);
- world.setBlock(x - 3, y, z - 1, stair, 0, 2);
- world.setBlock(x - 3, y, z - 3, stair, 0, 2);
- world.setBlock(x - 2, y + 1, z - 3, slab, slabMeta, 2);
- world.setBlock(x - 2, y + 1, z - 1, slab, slabMeta, 2);
- world.setBlock(x - 1, y + 1, z - 3, slab, slabMeta, 2);
- world.setBlock(x - 1, y + 1, z - 1, slab, slabMeta, 2);
- world.setBlock(x, y + 1, z - 1, stair, 0, 2);
- world.setBlock(x, y + 1, z - 3, stair, 0, 2);
- world.setBlock(x + 1, y + 2, z - 3, slab, slabMeta, 2);
- world.setBlock(x + 1, y + 2, z - 1, slab, slabMeta, 2);
- for(int k = -3; k <= -1; k++)
- world.setBlock(x + 2, y + 2, z + k, block, metadata, 1);
- if (rand.nextInt(5) == 0){
- ItemStack stack = new ItemStack(ItemList.bucket);
- JewelryNBT.addMetal(stack, new ItemStack(Items.gold_ingot));
- try{
- if (stack != null && JewelryNBT.ingot(stack) != null){
- if (!world.isRemote) world.func_147480_a(x, y, z, true);
- int color = ItemMoltenMetalBucket.color(stack, 1);
- JewelrycraftMod.saveData.setString((x + 1) + " " + (y + 2) + " " + (z - 2) + " " + world.provider.dimensionId, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) + ":" + JewelryNBT.ingot(stack).getItemDamage() + ":" + color);
- JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x + 1, y + 2, z - 2, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()), JewelryNBT.ingot(stack).getItemDamage(), color));
- world.setBlock(x + 1, y + 2, z - 2, BlockList.moltenMetal, 0, 3);
- }
- }
- catch(IOException e){
- e.printStackTrace();
- }
- }else if (rand.nextBoolean()) world.setBlock(x + 1, y + 2, z - 2, Blocks.lava, 0, 3);
- else world.setBlock(x + 1, y + 2, z - 2, Blocks.water, 0, 3);
- return true;
- }
-
- @Override
- public boolean generate(World world, Random rand, int x, int y, int z)
- {
- return generate(world, BiomeGenBase.plains, rand, x, y, z);
- }
+public class WorldGenStructure5 extends WorldGenerator {
+ public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) {
+ Block slab = Blocks.stone_slab;
+ Block stair = Blocks.stone_brick_stairs;
+ Block block = Blocks.stonebrick;
+ int metadata = 0, slabMeta = 5;
+ if (biome == BiomeGenBase.desert || biome == BiomeGenBase.desertHills) {
+ stair = Blocks.sandstone_stairs;
+ block = Blocks.sandstone;
+ metadata = 2;
+ slabMeta = 1;
+ }
+ for (int i = -2; i <= 2; i++)
+ for (int j = 0; j <= 3; j++)
+ for (int k = -3; k <= -1; k++)
+ world.setBlock(x + i, y + j, z + k, Blocks.air);
+ for (int i = -5; i <= -3; i++)
+ for (int k = -3; k <= 2; k++)
+ world.setBlock(x + i, y, z + k, Blocks.air);
+ for (int i = -2; i <= 2; i++)
+ for (int k = -3; k <= -1; k++)
+ world.setBlock(x + i, y, z + k, block, metadata, 1);
+ for (int i = 1; i <= 2; i++)
+ for (int k = -3; k <= -1; k++)
+ world.setBlock(x + i, y + 1, z + k, block, metadata, 1);
+ for (int i = -5; i <= -3; i++)
+ for (int k = -3; k <= 2; k++)
+ world.setBlock(x + i, y - 1, z + k, block, metadata, 1);
+ for (int i = -5; i <= -3; i++)
+ for (int k = -3; k <= 2; k++)
+ if ((i != -4 || k <= -3 || k >= 2) && !(i == -3 && k == -2)) world.setBlock(x + i, y, z + k, slab, slabMeta, 2);
+ world.setBlock(x - 3, y, z - 1, stair, 0, 2);
+ world.setBlock(x - 3, y, z - 3, stair, 0, 2);
+ world.setBlock(x - 2, y + 1, z - 3, slab, slabMeta, 2);
+ world.setBlock(x - 2, y + 1, z - 1, slab, slabMeta, 2);
+ world.setBlock(x - 1, y + 1, z - 3, slab, slabMeta, 2);
+ world.setBlock(x - 1, y + 1, z - 1, slab, slabMeta, 2);
+ world.setBlock(x, y + 1, z - 1, stair, 0, 2);
+ world.setBlock(x, y + 1, z - 3, stair, 0, 2);
+ world.setBlock(x + 1, y + 2, z - 3, slab, slabMeta, 2);
+ world.setBlock(x + 1, y + 2, z - 1, slab, slabMeta, 2);
+ for (int k = -3; k <= -1; k++)
+ world.setBlock(x + 2, y + 2, z + k, block, metadata, 1);
+ if (rand.nextInt(5) == 0) {
+ ItemStack stack = new ItemStack(ItemList.bucket);
+ JewelryNBT.addMetal(stack, new ItemStack(Items.gold_ingot));
+ try {
+ if (stack != null && JewelryNBT.ingot(stack) != null) {
+ if (!world.isRemote) world.func_147480_a(x, y, z, true);
+ if (world.isRemote) {
+ int color = ItemMoltenMetalBucket.color(stack, 1);
+ JewelrycraftMod.saveData.setString((x + 1) + " " + (y + 2) + " " + (z - 2) + " " + world.provider.dimensionId, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) + ":" + JewelryNBT.ingot(stack).getItemDamage() + ":" + color);
+ JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x + 1, y + 2, z - 2, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()), JewelryNBT.ingot(stack).getItemDamage(), color));
+ JewelrycraftMod.netWrapper.sendToServer(new PacketRequestLiquidData(Minecraft.getMinecraft().theWorld.provider.dimensionId, x + 1, y + 2, z - 2));
+ }
+ else{
+ JewelrycraftMod.saveData.setString(x + " " + y + " " + z + " " + world.provider.dimensionId, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) + ":" + JewelryNBT.ingot(stack).getItemDamage() + ":" + rand.nextInt(16777216));
+ JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x, y, z, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()), JewelryNBT.ingot(stack).getItemDamage(), rand.nextInt(16777216)));
+ }
+ world.setBlock(x + 1, y + 2, z - 2, BlockList.moltenMetal, 0, 3);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ } else if (rand.nextBoolean()) world.setBlock(x + 1, y + 2, z - 2, Blocks.lava, 0, 3);
+ else world.setBlock(x + 1, y + 2, z - 2, Blocks.water, 0, 3);
+ return true;
+ }
+
+ @Override
+ public boolean generate(World world, Random rand, int x, int y, int z) {
+ return generate(world, BiomeGenBase.plains, rand, x, y, z);
+ }
}