diff --git a/src/main/java/StevenDimDoors/experimental/LiquidCorium.java b/src/main/java/StevenDimDoors/experimental/LiquidCorium.java new file mode 100644 index 0000000..955765b --- /dev/null +++ b/src/main/java/StevenDimDoors/experimental/LiquidCorium.java @@ -0,0 +1,13 @@ +package StevenDimDoors.experimental; + +import net.minecraftforge.fluids.Fluid; + +public class LiquidCorium extends Fluid +{ + + public LiquidCorium(String fluidName) + { + super(fluidName); + } + +} diff --git a/src/main/java/StevenDimDoors/experimental/LiquidCoriumBlock.java b/src/main/java/StevenDimDoors/experimental/LiquidCoriumBlock.java new file mode 100644 index 0000000..4ea1c12 --- /dev/null +++ b/src/main/java/StevenDimDoors/experimental/LiquidCoriumBlock.java @@ -0,0 +1,106 @@ +package StevenDimDoors.experimental; + +import java.util.Random; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import StevenDimDoors.mod_pocketDim.Point3D; +import StevenDimDoors.mod_pocketDim.mod_pocketDim; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.fluids.BlockFluidBase; +import net.minecraftforge.fluids.BlockFluidFinite; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +public class LiquidCoriumBlock extends BlockFluidFinite +{ + private Icon iconFlowing; + private Icon iconStill; + + public static Point3D[] spreadPoints= new Point3D[4]; + public LiquidCoriumBlock(int id, Fluid fluid, Material material) + { + super(id, fluid, material); + this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab); + } + + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) + { + par1World.setBlock(par2, par3, par4, this.blockID,15,2); + } + + @Override + public void updateTick(World world, int x, int y, int z, Random rand) + { + boolean didChange=false; + int fluid = this.getQuantaValue(world, x, y, z); + int blockBeneath = world.getBlockId(x, y-1,z); + + if(!(blockBeneath==0||blockBeneath==this.blockID)) + { + for(int xCount=-1;xCount<2;xCount++) + { + for(int yCount=-1;yCount<1;yCount++) + { + for(int zCount=-1;zCount<2;zCount++) + { + int id= world.getBlockId(x+xCount, y+yCount, z+zCount); + if(!(id ==0||id==this.blockID||id==Block.bedrock.blockID)&&!(Math.abs(zCount)+Math.abs(yCount)+Math.abs(xCount)>1)) + { + Block block =Block.blocksList[id]; + if(block.getUnlocalizedName().contains("ore")) + { + world.setBlock(x+xCount, y+yCount, z+zCount,this.blockID,6,2); + } + if(fluid>block.blockHardness*2&&yCount==0&&rand.nextInt(3)==0) + { + didChange=true;; + world.setBlock(x+xCount, y+yCount, z+zCount,0); + } + else if(fluid>block.blockHardness*2+1&&yCount==-1&&!didChange&&rand.nextBoolean()) + { + world.setBlock(x+xCount, y+yCount, z+zCount, 0); + } + + + } + } + } + } + } + + if((fluid==1)&&blockBeneath!=this.blockID&&blockBeneath!=Block.bedrock.blockID) + { + world.setBlockToAir(x, y, z); + world.setBlock(x, y-1, z,Block.bedrock.blockID); + } + super.updateTick(world, x, y, z, rand); + + } + + @SideOnly(Side.CLIENT) + @Override + public void registerIcons(IconRegister ir) + { + + iconStill = ir.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName()+"_still"); + iconFlowing = ir.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName()+"_flowing"); + } + @Override + public Icon getIcon(int side, int meta) + { + return side <= 1 ? iconStill : iconFlowing; + } + + +} diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java b/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java index b522e9a..95e61ee 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java @@ -274,8 +274,6 @@ public class DDTeleporter { throw new IllegalArgumentException("destination cannot be null."); } - - //This beautiful teleport method is based off of xCompWiz's teleport function. WorldServer oldWorld = (WorldServer) entity.worldObj; @@ -372,6 +370,10 @@ public class DDTeleporter NBTTagCompound entityNBT = new NBTTagCompound(); entity.isDead = false; entity.writeMountToNBT(entityNBT); + if(entityNBT.hasNoTags()) + { + return entity; + } entity.isDead = true; entity = EntityList.createEntityFromNBT(entityNBT, newWorld); @@ -411,6 +413,7 @@ public class DDTeleporter // Let's try doing this down here in case this is what's killing NEI. GameRegistry.onPlayerChangedDimension((EntityPlayer)entity); + } DDTeleporter.placeInPortal(entity, newWorld, destination, properties, checkOrientation); return entity; diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/dungeon/DungeonSchematic.java b/src/main/java/StevenDimDoors/mod_pocketDim/dungeon/DungeonSchematic.java index 84ff4a4..6fc3a52 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/dungeon/DungeonSchematic.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/dungeon/DungeonSchematic.java @@ -87,7 +87,6 @@ public class DungeonSchematic extends Schematic { public static DungeonSchematic readFromFile(File schematicFile) throws FileNotFoundException, InvalidSchematicException { - // TODO: fix resource leak return readFromStream(new FileInputStream(schematicFile)); } @@ -168,6 +167,7 @@ public class DungeonSchematic extends Schematic { mapping.put((short) properties.PermaFabricBlockID, STANDARD_ETERNAL_FABRIC_ID); mapping.put((short) properties.WarpDoorID, STANDARD_WARP_DOOR_ID); mapping.put((short) properties.DimensionalDoorID, STANDARD_DIMENSIONAL_DOOR_ID); + mapping.put((short) properties.TransientDoorID, STANDARD_TRANSIENT_DOOR_ID); return mapping; } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/mod_pocketDim.java b/src/main/java/StevenDimDoors/mod_pocketDim/mod_pocketDim.java index 5f4fe93..f8770b5 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/mod_pocketDim.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/mod_pocketDim.java @@ -1,5 +1,7 @@ package StevenDimDoors.mod_pocketDim; +import StevenDimDoors.experimental.LiquidCorium; +import StevenDimDoors.experimental.LiquidCoriumBlock; import StevenDimDoors.mod_pocketDim.blocks.BlockDimWall; import StevenDimDoors.mod_pocketDim.blocks.BlockDimWallPerm; import StevenDimDoors.mod_pocketDim.blocks.BlockDoorGold; @@ -76,6 +78,7 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityEggInfo; import net.minecraft.entity.EntityList; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumToolMaterial; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -84,6 +87,8 @@ import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.ForgeChunkManager; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; @Mod(modid = mod_pocketDim.modid, name = "Dimensional Doors", version = mod_pocketDim.version) @@ -138,6 +143,9 @@ public class mod_pocketDim public static MonolithSpawner spawner; //Added this field temporarily. Will be refactored out later. public static GatewayGenerator riftGen; public static PlayerTracker tracker; + + public static Block coriumBlock; + public static Fluid coriumFluid; public static CreativeTabs dimDoorsCreativeTab = new CreativeTabs("dimDoorsCreativeTab") { @@ -232,7 +240,7 @@ public class mod_pocketDim DimensionManager.registerProviderType(properties.PocketProviderID, PocketProvider.class, false); DimensionManager.registerProviderType(properties.LimboProviderID, LimboProvider.class, false); DimensionManager.registerDimension(properties.LimboDimensionID, properties.LimboProviderID); - + LanguageRegistry.addName(goldDoor, "Golden Door"); LanguageRegistry.addName(goldDimDoor, "Golden Dimensional Door"); LanguageRegistry.addName(transientDoor , "transientDoor"); @@ -282,8 +290,16 @@ public class mod_pocketDim DungeonHelper.initialize(); this.riftGen.initGateways(); + coriumFluid = new LiquidCorium("Corium").setDensity(1000).setTemperature(3473).setDensity(9400).setLuminosity(6).setRarity(EnumRarity.rare); + coriumBlock = new LiquidCoriumBlock(900, coriumFluid, Material.lava).setQuantaPerBlock(16).setTickRate(20).setTickRandomly(true).setUnlocalizedName("Corium"); + FluidRegistry.registerFluid(coriumFluid); + GameRegistry.registerBlock(coriumBlock,"Corium"); + LanguageRegistry.addName(coriumBlock, "Corium"); + + + // Register loot chests DDLoot.registerInfo(properties); proxy.loadTextures(); diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/schematic/Schematic.java b/src/main/java/StevenDimDoors/mod_pocketDim/schematic/Schematic.java index 230075c..bc866fe 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/schematic/Schematic.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/schematic/Schematic.java @@ -378,7 +378,6 @@ public class Schematic { { for (dx = 0; dx < width; dx++) { - setBlockDirectly(world, x + dx, y + dy, z + dz, blocks[index], metadata[index]); index++; } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/ticking/MobMonolith.java b/src/main/java/StevenDimDoors/mod_pocketDim/ticking/MobMonolith.java index 1cbb356..74b3cc9 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/ticking/MobMonolith.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/ticking/MobMonolith.java @@ -2,6 +2,8 @@ package StevenDimDoors.mod_pocketDim.ticking; import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraft.entity.DataWatcher; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityFlying; @@ -29,7 +31,7 @@ public class MobMonolith extends EntityFlying implements IMob float soundTime = 0; int aggro = 0; byte textureState = 0; - + float entityCollisionReduction = 100; float scaleFactor = 0; int aggroMax; int destX = 0; // unused fields? @@ -99,6 +101,39 @@ public class MobMonolith extends EntityFlying implements IMob super.entityInit(); this.dataWatcher.addObject(16, Byte.valueOf((byte)0)); } + + public boolean isClipping() + { + + int i = MathHelper.floor_double(this.boundingBox.minX); + int j = MathHelper.floor_double(this.boundingBox.maxX + 1.0D); + int k = MathHelper.floor_double(this.boundingBox.minY); + int l = MathHelper.floor_double(this.boundingBox.maxY + 1.0D); + int i1 = MathHelper.floor_double(this.boundingBox.minZ); + int j1 = MathHelper.floor_double(this.boundingBox.maxZ + 1.0D); + + for (int k1 = i; k1 < j; ++k1) + { + for (int l1 = k; l1 < l; ++l1) + { + for (int i2 = i1; i2 < j1; ++i2) + { + if(!this.worldObj.isAirBlock(k1, l1, i2)) + { + return true; + } + } + } + } + + + return false; + } + @Override + public boolean isEntityAlive() + { + return false; + } @Override public void onEntityUpdate() @@ -107,12 +142,11 @@ public class MobMonolith extends EntityFlying implements IMob { this.setDead(); } - + super.onEntityUpdate(); - - if (this.isEntityAlive() && this.isEntityInsideOpaqueBlock()) + if(this.isClipping()) { - this.setDead(); + this.moveEntity(0, .1, 0); } EntityPlayer entityPlayer = this.worldObj.getClosestPlayerToEntity(this, 30); diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/ticking/MonolithSpawner.java b/src/main/java/StevenDimDoors/mod_pocketDim/ticking/MonolithSpawner.java index fac59e4..8b58f37 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/ticking/MonolithSpawner.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/ticking/MonolithSpawner.java @@ -129,8 +129,8 @@ public class MonolithSpawner implements IRegularTickReceiver { } while (!pocket.isAirBlock(x,jumpHeight+6 , z)&&jumpSanity<20); - Entity monolith = new MobMonolith(pocket); - monolith.setLocationAndAngles(x, jumpHeight, z, 1, 1); + MobMonolith monolith = new MobMonolith(pocket); + monolith.setLocationAndAngles(x, jumpHeight-(5-monolith.getRenderSizeModifier()*5), z, 1, 1); pocket.spawnEntityInWorld(monolith); didSpawn = true; } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityRift.java b/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityRift.java index 5b5f14d..442d4e1 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityRift.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityRift.java @@ -36,6 +36,8 @@ public class TileEntityRift extends TileEntity private static final int MAX_ANCESTOR_LINKS = 3; private static final int ENDERMAN_SPAWNING_CHANCE = 1; private static final int MAX_ENDERMAN_SPAWNING_CHANCE = 32; + private static final int RIFT_SPREAD_CHANCE = 1; + private static final int MAX_RIFT_SPREAD_CHANCE = 256; private static Random random = new Random(); @@ -299,20 +301,13 @@ public class TileEntityRift extends TileEntity public void grow(DDProperties properties) { - if (worldObj.isRemote || hasGrownRifts || !properties.RiftSpreadEnabled || random.nextInt(5) == 0) + if (worldObj.isRemote || hasGrownRifts || !properties.RiftSpreadEnabled + || random.nextInt(MAX_RIFT_SPREAD_CHANCE) < RIFT_SPREAD_CHANCE) { return; } NewDimData dimension = PocketManager.getDimensionData(worldObj); - - if(random.nextInt(dimension.findRiftsInRange(this.worldObj, 5, xCoord, yCoord, zCoord).size()+1)<2) - { - if(random.nextInt(7)!=0) - { - return; - } - } DimLink link = dimension.getLink(xCoord, yCoord, zCoord); if (countAncestorLinks(link) > MAX_ANCESTOR_LINKS) @@ -320,8 +315,11 @@ public class TileEntityRift extends TileEntity return; } - //FIXME: This condition would prevent people from creating rooms of densely packed rifts... ~SenseiKiwi - if (updateNearestRift()) + // The probability of rifts trying to spread increases if more rifts are nearby + // Players should see rifts spread faster within clusters than at the edges of clusters + // Also, single rifts CANNOT spread. + int nearRifts = dimension.findRiftsInRange(this.worldObj, 5, xCoord, yCoord, zCoord).size(); + if (nearRifts == 0 || random.nextInt(nearRifts) == 0) { return; } @@ -343,7 +341,7 @@ public class TileEntityRift extends TileEntity { dimension.createChildLink(x, y, z, link); hasGrownRifts = true; - return; + break; } else { diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/world/GatewayGenerator.java b/src/main/java/StevenDimDoors/mod_pocketDim/world/GatewayGenerator.java index 75a65db..8d7f303 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/world/GatewayGenerator.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/world/GatewayGenerator.java @@ -16,6 +16,7 @@ import StevenDimDoors.mod_pocketDim.core.NewDimData; import StevenDimDoors.mod_pocketDim.core.PocketManager; import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor; import StevenDimDoors.mod_pocketDim.world.gateways.BaseGateway; +import StevenDimDoors.mod_pocketDim.world.gateways.GatewaySandstonePillars; import StevenDimDoors.mod_pocketDim.world.gateways.GatewayTwoPillars; import cpw.mods.fml.common.IWorldGenerator; @@ -36,6 +37,7 @@ public class GatewayGenerator implements IWorldGenerator private static final int END_DIMENSION_ID = 1; private static ArrayList gateways; + private static BaseGateway defaultGateway; private final DDProperties properties; @@ -48,7 +50,11 @@ public class GatewayGenerator implements IWorldGenerator public void initGateways() { gateways=new ArrayList(); - gateways.add(new GatewayTwoPillars(this.properties)); + this.defaultGateway=new GatewayTwoPillars(this.properties); + + //add gateways here + gateways.add(new GatewaySandstonePillars(this.properties)); + } @Override @@ -146,25 +152,23 @@ public class GatewayGenerator implements IWorldGenerator //Build the gateway if we found a valid location if (valid) { - this.gateways.get(random.nextInt(gateways.size())).generate(world, x, y, z); - /** - //Create a partial link to a dungeon. - dimension = PocketManager.getDimensionData(world); - link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON, 0); - - //If the current dimension isn't Limbo, build a Rift Gateway out of Stone Bricks - if (dimension.id() != properties.LimboDimensionID) + //TODO I feel like this is slow and should be optimized. We are linear time with total # of generation restrictions + //Create an array and copy valid gateways into it + ArrayList validGateways = new ArrayList(); + for(BaseGateway gateway:gateways) { - createStoneGateway(world, x, y, z, random); + if(gateway.isLocationValid(world, x, y, z, world.getBiomeGenForCoords(x, z))) + { + validGateways.add(gateway); + } } - else + //Add default gateway if we where unable to find a suitable gateway + if(validGateways.isEmpty()) { - createLimboGateway(world, x, y, z, properties.LimboBlockID); + validGateways.add(this.defaultGateway); } - - //Place the shiny transient door into a dungeon - ItemDimensionalDoor.placeDoorBlock(world, x, y, z, 0, mod_pocketDim.transientDoor); - **/ + //randomly select a gateway from the pool of viable gateways + validGateways.get(random.nextInt(validGateways.size())).generate(world, x, y, z); } } } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/BaseGateway.java b/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/BaseGateway.java index 358c01f..58f6da7 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/BaseGateway.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/BaseGateway.java @@ -21,19 +21,41 @@ import net.minecraft.world.biome.BiomeGenBase; public abstract class BaseGateway { + //This pack is what the dungeon initially generates into from this gateway. protected DungeonPack startingPack; + + /**Flag that determines if this gateway is tied to a specific biome. + *For compatabilities sake, we are just using string comparison to check. + **/ protected boolean isBiomeSpecific; - protected ArrayList allowedBiomeNames; + + /** + * List of biome names that we check against. Is by default a whitelist, but the isBiomeValid method + * can be overriden for specific gateways. For example, any biome containing 'forest' would be valid if we added 'forest', + * even from other mods. + */ + protected ArrayList biomeNames = new ArrayList(); + + /** + * List containing all the .schematics attached to this gateway. Selection is random by default, + * but can be overriden for specific gateways in getSchematicToBuild + */ + protected ArrayList schematicPaths= new ArrayList(); + + //TODO not yet implemented protected boolean surfaceGateway; + + //TODO not yet implemented protected int generationWeight; - protected String schematicPath; + + //Used to find the doorway for the .schematic protected GatewayBlockFilter filter; public BaseGateway(DDProperties properties) { - //not using DD properties because sometimes its IDS can be wrong, but require it so we dont init too early - filter = new GatewayBlockFilter((short) mod_pocketDim.dimensionalDoor.blockID,(short) mod_pocketDim.transientDoor.blockID); + filter = new GatewayBlockFilter((short) properties.DimensionalDoorID, (short) properties.TransientDoorID, + (short) properties.WarpDoorID); } /** @@ -45,41 +67,25 @@ public abstract class BaseGateway */ public boolean generate(World world, int x, int y, int z) { - /** - * We have two cases here. The gateway may or may not specify a schematic to load from. If it does, we need to line up the door in the schematic with the given rift. - * I tried doing this by taking the difference between the selected coords for the door, and the position of the door relative to the bounds of the .schematic, - * but it doesnt work. It seems like it should, though. Odd. - * - * Now we have a new issue- we get an index array out of bounds. One of the exported *blocks* is -69. - * - */ - Point3D doorLocation= new Point3D(0,0,0); int orientation = 0; - try + + if (this.hasSchematic()) { - if(this.schematicPath!=null) - { - Schematic schematic = Schematic.readFromResource(schematicPath); - schematic.applyFilter(filter); - - doorLocation = filter.getEntranceDoorLocation(); - orientation = filter.getEntranceOrientation(); - - schematic.copyToWorld(world, x-schematic.getWidth()+doorLocation.getX(), y-schematic.getHeight()+doorLocation.getY(), z-schematic.getLength()+doorLocation.getZ()); - - //TODO debug code to easily locate the rifts - for(int c = 0; c<240; c++) - { - world.setBlock(x, y+c, z,Block.glowStone.blockID); - } - } - } - catch (Exception e) - { - e.printStackTrace(); - return false; + Schematic schematic = this.getSchematicToBuild(world, x, y, z); + + schematic.applyFilter(filter); + Point3D doorLocation = filter.getEntranceDoorLocation(); + orientation = filter.getEntranceOrientation(); + + // I suspect that the location used below is wrong. Gateways should be placed vertically based on + // the Y position of the surface where they belong. I'm pretty sure including doorLocation.getY() + // messes up the calculation. ~SenseiKiwi + + //schematic.copyToWorld(world, x - doorLocation.getX(), y, z - doorLocation.getZ()); + schematic.copyToWorld(world, x - doorLocation.getX(), y + 1 - doorLocation.getY(), z - doorLocation.getZ()); } - this.generateRandomBits(world, x,y,z); + + this.generateRandomBits(world, x, y, z); DimLink link = PocketManager.getDimensionData(world).createLink(x, y + 1, z, LinkTypes.DUNGEON, orientation); PocketBuilder.generateSelectedDungeonPocket(link, mod_pocketDim.properties, this.getStartingDungeon(world.rand)); @@ -87,6 +93,29 @@ public abstract class BaseGateway return true; } + /** + * Gets a .schematic to generate for this gateway + * @param world + * @param x + * @param y + * @param z + * @return + */ + public Schematic getSchematicToBuild(World world, int x, int y, int z) + { + //TODO- refine selection criteria here, this is the default case + try + { + return Schematic.readFromResource(schematicPaths.get(world.rand.nextInt(schematicPaths.size()))); + } + catch (Exception e) + { + e.printStackTrace(); + System.err.println("Could not load schematic for gateway"); + return null; + } + } + /** * Use this function to generate randomized bits of the structure. * @param world @@ -116,17 +145,22 @@ public abstract class BaseGateway */ public boolean isLocationValid(World world, int x, int y, int z, BiomeGenBase biome) { - return false; + //TODO- refine condition here as warranted + return this.isBiomeValid(biome); } public boolean shouldGenUnderground() { return !surfaceGateway; } + public boolean isBiomeValid(BiomeGenBase biome) { - return this.isBiomeSpecific||this.allowedBiomeNames.contains(biome.biomeName.toLowerCase()); + return !this.isBiomeSpecific || this.biomeNames.contains(biome.biomeName.toLowerCase()); + } + + public boolean hasSchematic() + { + return this.schematicPaths != null && !this.schematicPaths.isEmpty(); } - - } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/GatewayBlockFilter.java b/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/GatewayBlockFilter.java index 5098f94..ed66c61 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/GatewayBlockFilter.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/GatewayBlockFilter.java @@ -9,20 +9,21 @@ import StevenDimDoors.mod_pocketDim.schematic.SchematicFilter; public class GatewayBlockFilter extends SchematicFilter { private short dimensionalDoorID; + private int transientDoorID; + private int warpDoorID; private int entranceOrientation; private Schematic schematic; private Point3D entranceDoorLocation; - private int transientDoorID; - - public GatewayBlockFilter(short dimensionalDoorID,short transientDoorID) + public GatewayBlockFilter(short dimensionalDoorID, short transientDoorID, short warpDoorID) { - super("GatewayEnteranceFinder"); - this.dimensionalDoorID = dimensionalDoorID; + super("GatewayEntranceFinder"); this.entranceDoorLocation = null; this.entranceOrientation = 0; this.schematic = null; - this.transientDoorID=transientDoorID; + this.dimensionalDoorID = dimensionalDoorID; + this.transientDoorID = transientDoorID; + this.warpDoorID = warpDoorID; } public int getEntranceOrientation() { @@ -45,7 +46,6 @@ public class GatewayBlockFilter extends SchematicFilter { { int indexBelow; int indexDoubleBelow; - System.out.println(blocks[index]); if (blocks[index] == dimensionalDoorID) { indexBelow = schematic.calculateIndexBelow(index); @@ -66,8 +66,17 @@ public class GatewayBlockFilter extends SchematicFilter { return true; } } + if (blocks[index] == warpDoorID) + { + indexBelow = schematic.calculateIndexBelow(index); + if (indexBelow >= 0 && blocks[indexBelow] == warpDoorID) + { + entranceDoorLocation = schematic.calculatePoint(index); + entranceOrientation = (metadata[indexBelow] & 3); + return true; + } + } return false; - } @Override diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/GatewaySandstonePillars.java b/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/GatewaySandstonePillars.java new file mode 100644 index 0000000..e124908 --- /dev/null +++ b/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/GatewaySandstonePillars.java @@ -0,0 +1,42 @@ +package StevenDimDoors.mod_pocketDim.world.gateways; + +import java.util.ArrayList; +import java.util.Random; + +import StevenDimDoors.mod_pocketDim.DDProperties; +import StevenDimDoors.mod_pocketDim.mod_pocketDim; +import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack; +import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper; +import net.minecraft.block.Block; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + +public class GatewaySandstonePillars extends BaseGateway +{ + + private static final int GATEWAY_RADIUS = 4; + + public GatewaySandstonePillars(DDProperties properties) + { + super(properties); + super.startingPack=DungeonHelper.instance().getDungeonPack("RUINS"); + super.isBiomeSpecific=true; + super.biomeNames.add("desert"); + surfaceGateway=true; + generationWeight = 0; + schematicPaths.add("/schematics/gateways/sandstonePillars.schematic"); + + } + @Override + public boolean generate(World world, int x, int y, int z) + { + //simple to transform the generation location here. + //Do you think this is the best way to do this? + return super.generate(world, x, y+2, z); + } + @Override + public void generateRandomBits(World world, int x, int y, int z) + { + } + +} diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/GatewayTwoPillars.java b/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/GatewayTwoPillars.java index eda1b8e..6444898 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/GatewayTwoPillars.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/world/gateways/GatewayTwoPillars.java @@ -6,28 +6,55 @@ import StevenDimDoors.mod_pocketDim.DDProperties; import StevenDimDoors.mod_pocketDim.mod_pocketDim; import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack; import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper; +import net.minecraft.block.Block; import net.minecraft.world.World; public class GatewayTwoPillars extends BaseGateway { - private GatewayBlockFilter filter; + private static final int GATEWAY_RADIUS = 4; public GatewayTwoPillars(DDProperties properties) { super(properties); super.startingPack=DungeonHelper.instance().getDungeonPack("RUINS"); super.isBiomeSpecific=false; - super.allowedBiomeNames=null; + super.biomeNames=null; surfaceGateway=true; generationWeight = 0; - schematicPath="/schematics/gateways/twoPillars.schematic"; + schematicPaths.add("/schematics/gateways/twoPillars.schematic"); } @Override void generateRandomBits(World world, int x, int y, int z) { + final int blockID = Block.stoneBrick.blockID; + //Replace some of the ground around the gateway with bricks + for (int xc = -GATEWAY_RADIUS; xc <= GATEWAY_RADIUS; xc++) + { + for (int zc= -GATEWAY_RADIUS; zc <= GATEWAY_RADIUS; zc++) + { + //Check that the block is supported by an opaque block. + //This prevents us from building over a cliff, on the peak of a mountain, + //or the surface of the ocean or a frozen lake. + if (world.isBlockOpaqueCube(x + xc, y - 2, z + zc)) + { + //Randomly choose whether to place bricks or not. The math is designed so that the + //chances of placing a block decrease as we get farther from the gateway's center. + if (Math.abs(xc) + Math.abs(zc) < world.rand.nextInt(2) + 3) + { + //Place Stone Bricks + world.setBlock(x + xc, y - 1, z + zc, blockID, 0, 3); + } + else if (Math.abs(xc) + Math.abs(zc) < world.rand.nextInt(3) + 3) + { + //Place Cracked Stone Bricks + world.setBlock(x + xc, y - 1, z + zc, blockID, 2, 3); + } + } + } + } } } diff --git a/src/main/resources/assets/dimdoors/textures/blocks/tile.Corium_flowing.png b/src/main/resources/assets/dimdoors/textures/blocks/tile.Corium_flowing.png new file mode 100644 index 0000000..af07f91 Binary files /dev/null and b/src/main/resources/assets/dimdoors/textures/blocks/tile.Corium_flowing.png differ diff --git a/src/main/resources/assets/dimdoors/textures/blocks/tile.Corium_flowing.png.mcmeta b/src/main/resources/assets/dimdoors/textures/blocks/tile.Corium_flowing.png.mcmeta new file mode 100644 index 0000000..b374392 --- /dev/null +++ b/src/main/resources/assets/dimdoors/textures/blocks/tile.Corium_flowing.png.mcmeta @@ -0,0 +1,27 @@ +{ + "animation": + { + "frametime": 3, + "frames": + [ + +0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15 + + ] + } +} \ No newline at end of file diff --git a/src/main/resources/assets/dimdoors/textures/blocks/tile.Corium_still.png b/src/main/resources/assets/dimdoors/textures/blocks/tile.Corium_still.png new file mode 100644 index 0000000..78bb29d Binary files /dev/null and b/src/main/resources/assets/dimdoors/textures/blocks/tile.Corium_still.png differ diff --git a/src/main/resources/assets/dimdoors/textures/blocks/tile.Corium_still.png.mcmeta b/src/main/resources/assets/dimdoors/textures/blocks/tile.Corium_still.png.mcmeta new file mode 100644 index 0000000..2b28937 --- /dev/null +++ b/src/main/resources/assets/dimdoors/textures/blocks/tile.Corium_still.png.mcmeta @@ -0,0 +1,51 @@ +{ + "animation": + { + "frametime": 3, + "frames": + [ + +0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +18, +17, +16, +15, +14, +13, +12, +11, +10, +9, +8, +7, +6, +5, +4, +3, +2, +1 + + ] + } +} + + diff --git a/src/main/resources/schematics/gateways/sandstonePillars.schematic b/src/main/resources/schematics/gateways/sandstonePillars.schematic new file mode 100644 index 0000000..30315b5 Binary files /dev/null and b/src/main/resources/schematics/gateways/sandstonePillars.schematic differ diff --git a/src/main/resources/schematics/gateways/twoPillars.schematic b/src/main/resources/schematics/gateways/twoPillars.schematic index bef0704..75f538d 100644 Binary files a/src/main/resources/schematics/gateways/twoPillars.schematic and b/src/main/resources/schematics/gateways/twoPillars.schematic differ