Flipped a Table
Replaced several core classes from DD with new classes to enforce integrity checks. Rewriting everything that depended on those classes is a massive undertaking but it should simplify our code and prevent the many bugs we've seen lately. The rewrite isn't done yet, just committing my progress so far.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityMinecart;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@@ -3,7 +3,8 @@ package StevenDimDoors.mod_pocketDim;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.NetLoginHandler;
|
||||
@@ -25,10 +26,8 @@ public class ConnectionHandler implements IConnectionHandler
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
|
||||
Collection set = new ArrayList();
|
||||
set.addAll(dimHelper.dimList.keySet());
|
||||
PacketHandler.onClientJoinPacket(manager, dimHelper.dimList);
|
||||
PacketHandler.onDimCreatedPacket(new DimData(properties.LimboDimensionID, false, 0, 0, 0, 0, 0));
|
||||
PacketHandler.onClientJoinPacket(manager, PocketManager.dimList);
|
||||
PacketHandler.onDimCreatedPacket(new NewDimData(properties.LimboDimensionID, false, 0, 0, 0, 0, 0));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -39,10 +38,7 @@ public class ConnectionHandler implements IConnectionHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionOpened(NetHandler netClientHandler,MinecraftServer server, INetworkManager manager)
|
||||
{
|
||||
|
||||
}
|
||||
public void connectionOpened(NetHandler netClientHandler,MinecraftServer server, INetworkManager manager) { }
|
||||
|
||||
@Override
|
||||
public void connectionClosed(INetworkManager manager)
|
||||
@@ -50,32 +46,17 @@ public class ConnectionHandler implements IConnectionHandler
|
||||
if (connected)
|
||||
{
|
||||
System.out.println("Clearing dim cache");
|
||||
dimHelper.instance.save();
|
||||
dimHelper.instance.unregsisterDims();
|
||||
dimHelper.dimList.clear();
|
||||
PocketManager.instance.save();
|
||||
PocketManager.instance.unregsisterDims();
|
||||
PocketManager.dimList.clear();
|
||||
|
||||
}
|
||||
connected = false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager,
|
||||
Packet1Login login)
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login) { }
|
||||
|
||||
@Override
|
||||
public void playerLoggedIn(Player player, NetHandler netHandler,
|
||||
INetworkManager manager)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager) { }
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import java.io.File;
|
||||
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.MonolithSpawner;
|
||||
import StevenDimDoors.mod_pocketDim.world.GatewayGenerator;
|
||||
|
||||
public class DDProperties
|
||||
{
|
||||
@@ -211,11 +212,11 @@ public class DDProperties
|
||||
"spawn in a given Limbo chunk. The default chance is 28.").getInt();
|
||||
|
||||
ClusterGenerationChance = config.get(Configuration.CATEGORY_GENERAL, "Cluster Generation Chance", 3,
|
||||
"Sets the chance (out of " + RiftGenerator.MAX_CLUSTER_GENERATION_CHANCE + ") that a cluster of rifts will " +
|
||||
"Sets the chance (out of " + GatewayGenerator.MAX_CLUSTER_GENERATION_CHANCE + ") that a cluster of rifts will " +
|
||||
"generate in a given chunk. The default chance is 3.").getInt();
|
||||
|
||||
GatewayGenerationChance = config.get(Configuration.CATEGORY_GENERAL, "Gateway Generation Chance", 10,
|
||||
"Sets the chance (out of " + RiftGenerator.MAX_GATEWAY_GENERATION_CHANCE + ") that a Rift Gateway will " +
|
||||
"Sets the chance (out of " + GatewayGenerator.MAX_GATEWAY_GENERATION_CHANCE + ") that a Rift Gateway will " +
|
||||
"generate in a given chunk. The default chance is 10.").getInt();
|
||||
|
||||
RiftSpreadModifier = config.get(Configuration.CATEGORY_GENERAL, "Rift Spread Modifier", 3,
|
||||
|
||||
376
StevenDimDoors/mod_pocketDim/DDTeleporter.java
Normal file
376
StevenDimDoors/mod_pocketDim/DDTeleporter.java
Normal file
@@ -0,0 +1,376 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.item.EntityMinecart;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet41EntityEffect;
|
||||
import net.minecraft.network.packet.Packet43Experience;
|
||||
import net.minecraft.network.packet.Packet9Respawn;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public class DDTeleporter
|
||||
{
|
||||
private DDTeleporter() { }
|
||||
|
||||
/**
|
||||
* Create a new portal near an entity.
|
||||
*/
|
||||
public static void placeInPortal(Entity par1Entity, WorldServer world, IDimLink link)
|
||||
{
|
||||
Point4D destination = link.destination();
|
||||
int x = destination.getX();
|
||||
int y = destination.getY();
|
||||
int z = destination.getZ();
|
||||
|
||||
//TODO Temporary workaround for mismatched door/rift metadata cases. Gives priority to the door.
|
||||
int orientation = PocketManager.getDestinationOrientation(link);
|
||||
int receivingDoorMeta = world.getBlockMetadata(x, y - 1, z);
|
||||
int receivingDoorID = world.getBlockId(x, y, z);
|
||||
if (receivingDoorMeta != orientation)
|
||||
{
|
||||
if (receivingDoorID == mod_pocketDim.dimDoor.blockID || receivingDoorID == mod_pocketDim.ExitDoor.blockID)
|
||||
{
|
||||
orientation = receivingDoorMeta;
|
||||
}
|
||||
}
|
||||
|
||||
if (par1Entity instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) par1Entity;
|
||||
player.rotationYaw=(orientation*90)+90;
|
||||
if(orientation==2||orientation==6)
|
||||
{
|
||||
player.setPositionAndUpdate( x+1.5, y-1, z+.5 );
|
||||
}
|
||||
else if(orientation==3||orientation==7)
|
||||
{
|
||||
player.setPositionAndUpdate( x+.5, y-1, z+1.5 );
|
||||
}
|
||||
else if(orientation==0||orientation==4)
|
||||
{
|
||||
player.setPositionAndUpdate(x-.5, y-1, z+.5);
|
||||
}
|
||||
else if(orientation==1||orientation==5)
|
||||
{
|
||||
player.setPositionAndUpdate(x+.5, y-1, z-.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setPositionAndUpdate(x, y-1, z);
|
||||
}
|
||||
}
|
||||
else if (par1Entity instanceof EntityMinecart)
|
||||
{
|
||||
par1Entity.motionX=0;
|
||||
par1Entity.motionZ=0;
|
||||
par1Entity.motionY=0;
|
||||
par1Entity.rotationYaw=(orientation*90)+90;
|
||||
|
||||
if(orientation==2||orientation==6)
|
||||
{
|
||||
DDTeleporter.setEntityPosition(par1Entity, x+1.5, y, z+.5 );
|
||||
par1Entity.motionX =.39;
|
||||
par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false);
|
||||
}
|
||||
else if(orientation==3||orientation==7)
|
||||
{
|
||||
DDTeleporter.setEntityPosition(par1Entity, x+.5, y, z+1.5 );
|
||||
par1Entity.motionZ =.39;
|
||||
par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false);
|
||||
}
|
||||
else if(orientation==0||orientation==4)
|
||||
{
|
||||
DDTeleporter.setEntityPosition(par1Entity,x-.5, y, z+.5);
|
||||
par1Entity.motionX =-.39;
|
||||
par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false);
|
||||
}
|
||||
else if(orientation==1||orientation==5)
|
||||
{
|
||||
DDTeleporter.setEntityPosition(par1Entity,x+.5, y, z-.5);
|
||||
par1Entity.motionZ =-.39;
|
||||
par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
DDTeleporter.setEntityPosition(par1Entity,x, y, z);
|
||||
}
|
||||
}
|
||||
else if (par1Entity instanceof Entity)
|
||||
{
|
||||
par1Entity.rotationYaw=(orientation*90)+90;
|
||||
if(orientation==2||orientation==6)
|
||||
{
|
||||
DDTeleporter.setEntityPosition(par1Entity, x+1.5, y, z+.5 );
|
||||
}
|
||||
else if(orientation==3||orientation==7)
|
||||
{
|
||||
|
||||
DDTeleporter.setEntityPosition(par1Entity, x+.5, y, z+1.5 );
|
||||
}
|
||||
else if(orientation==0||orientation==4)
|
||||
{
|
||||
DDTeleporter.setEntityPosition(par1Entity,x-.5, y, z+.5);
|
||||
}
|
||||
else if(orientation==1||orientation==5)
|
||||
{
|
||||
DDTeleporter.setEntityPosition(par1Entity,x+.5, y, z-.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
DDTeleporter.setEntityPosition(par1Entity,x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setEntityPosition(Entity entity, double x, double y, double z)
|
||||
{
|
||||
entity.lastTickPosX = entity.prevPosX = entity.posX = x;
|
||||
entity.lastTickPosY = entity.prevPosY = entity.posY = y + (double)entity.yOffset;
|
||||
entity.lastTickPosZ = entity.prevPosZ = entity.posZ = z;
|
||||
entity.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
public static Entity teleportEntity(World world, Entity entity, IDimLink link)
|
||||
{
|
||||
//This beautiful teleport method is based off of xCompWiz's teleport function.
|
||||
|
||||
WorldServer oldWorld = (WorldServer)world;
|
||||
WorldServer newWorld;
|
||||
EntityPlayerMP player = (entity instanceof EntityPlayerMP) ? (EntityPlayerMP)entity : null;
|
||||
|
||||
// Is something riding? Handle it first.
|
||||
if(entity.riddenByEntity != null)
|
||||
{
|
||||
return teleportEntity(oldWorld, entity.riddenByEntity, link);
|
||||
}
|
||||
|
||||
// Are we riding something? Dismount and tell the mount to go first.
|
||||
Entity cart = entity.ridingEntity;
|
||||
if (cart != null)
|
||||
{
|
||||
entity.mountEntity(null);
|
||||
cart = teleportEntity(oldWorld, cart, link);
|
||||
// We keep track of both so we can remount them on the other side.
|
||||
}
|
||||
|
||||
// Destination doesn't exist? We need to make it.
|
||||
if (DimensionManager.getWorld(link.destination().getDimension()) == null)
|
||||
{
|
||||
//FIXME: I think this is where I need to add initialization code for pockets!!! REALLY IMPORTANT!!!
|
||||
DimensionManager.initDimension(link.destination().getDimension());
|
||||
}
|
||||
|
||||
// Determine if our destination's in another realm.
|
||||
boolean difDest = link.source().getDimension() != link.destination().getDimension();
|
||||
if (difDest)
|
||||
{
|
||||
newWorld = DimensionManager.getWorld(link.destination().getDimension());
|
||||
}
|
||||
else
|
||||
{
|
||||
newWorld = (WorldServer) oldWorld;
|
||||
}
|
||||
|
||||
// GreyMaria: What is this even accomplishing? We're doing the exact same thing at the end of this all.
|
||||
// TODO Check to see if this is actually vital.
|
||||
DDTeleporter.placeInPortal(entity, newWorld, link);
|
||||
|
||||
if (difDest) // Are we moving our target to a new dimension?
|
||||
{
|
||||
if(player != null) // Are we working with a player?
|
||||
{
|
||||
// We need to do all this special stuff to move a player between dimensions.
|
||||
|
||||
// Set the new dimension and inform the client that it's moving to a new world.
|
||||
player.dimension = link.destination().getDimension();
|
||||
player.playerNetServerHandler.sendPacketToPlayer(new Packet9Respawn(player.dimension, (byte)player.worldObj.difficultySetting, newWorld.getWorldInfo().getTerrainType(), newWorld.getHeight(), player.theItemInWorldManager.getGameType()));
|
||||
|
||||
// GreyMaria: Used the safe player entity remover before.
|
||||
// This should fix an apparently unreported bug where
|
||||
// the last non-sleeping player leaves the Overworld
|
||||
// for a pocket dimension, causing all sleeping players
|
||||
// to remain asleep instead of progressing to day.
|
||||
oldWorld.removePlayerEntityDangerously(player);
|
||||
player.isDead=false;
|
||||
|
||||
// Creates sanity by ensuring that we're only known to exist where we're supposed to be known to exist.
|
||||
oldWorld.getPlayerManager().removePlayer(player);
|
||||
newWorld.getPlayerManager().addPlayer(player);
|
||||
|
||||
player.theItemInWorldManager.setWorld((WorldServer)newWorld);
|
||||
|
||||
// Synchronize with the server so the client knows what time it is and what it's holding.
|
||||
player.mcServer.getConfigurationManager().updateTimeAndWeatherForPlayer(player, (WorldServer)newWorld);
|
||||
player.mcServer.getConfigurationManager().syncPlayerInventory(player);
|
||||
for(Object potionEffect : player.getActivePotionEffects())
|
||||
{
|
||||
PotionEffect effect = (PotionEffect)potionEffect;
|
||||
player.playerNetServerHandler.sendPacketToPlayer(new Packet41EntityEffect(player.entityId, effect));
|
||||
}
|
||||
|
||||
player.playerNetServerHandler.sendPacketToPlayer(new Packet43Experience(player.experience, player.experienceTotal, player.experienceLevel));
|
||||
}
|
||||
|
||||
// Creates sanity by removing the entity from its old location's chunk entity list, if applicable.
|
||||
int entX = entity.chunkCoordX;
|
||||
int entZ = entity.chunkCoordZ;
|
||||
if ((entity.addedToChunk) && (oldWorld.getChunkProvider().chunkExists(entX, entZ)))
|
||||
{
|
||||
oldWorld.getChunkFromChunkCoords(entX, entZ).removeEntity(entity);
|
||||
oldWorld.getChunkFromChunkCoords(entX, entZ).isModified = true;
|
||||
}
|
||||
// Memory concerns.
|
||||
oldWorld.releaseEntitySkin(entity);
|
||||
|
||||
if (player == null) // Are we NOT working with a player?
|
||||
{
|
||||
NBTTagCompound entityNBT = new NBTTagCompound();
|
||||
entity.isDead = false;
|
||||
entity.addEntityID(entityNBT);
|
||||
entity.isDead = true;
|
||||
entity = EntityList.createEntityFromNBT(entityNBT, newWorld);
|
||||
|
||||
if (entity == null)
|
||||
{ // TODO FIXME IMPLEMENT NULL CHECKS THAT ACTUALLY DO SOMETHING.
|
||||
/*
|
||||
* shit ourselves in an organized fashion, preferably
|
||||
* in a neat pile instead of all over our users' games
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Finally, respawn the entity in its new home.
|
||||
newWorld.spawnEntityInWorld(entity);
|
||||
entity.setWorld(newWorld);
|
||||
}
|
||||
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
||||
|
||||
// Hey, remember me? It's time to remount.
|
||||
if (cart != null)
|
||||
{
|
||||
// Was there a player teleported? If there was, it's important that we update shit.
|
||||
if (player != null)
|
||||
{
|
||||
entity.worldObj.updateEntityWithOptionalForce(entity, true);
|
||||
}
|
||||
entity.mountEntity(cart);
|
||||
}
|
||||
|
||||
// Did we teleport a player? Load the chunk for them.
|
||||
if(player != null)
|
||||
{
|
||||
WorldServer.class.cast(newWorld).getChunkProvider().loadChunk(MathHelper.floor_double(entity.posX) >> 4, MathHelper.floor_double(entity.posZ) >> 4);
|
||||
|
||||
// Tell Forge we're moving its players so everyone else knows.
|
||||
// Let's try doing this down here in case this is what's killing NEI.
|
||||
GameRegistry.onPlayerChangedDimension((EntityPlayer)entity);
|
||||
|
||||
}
|
||||
DDTeleporter.placeInPortal(entity, newWorld, link);
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Primary function used to teleport the player using doors. Performs numerous null checks, and also generates the destination door/pocket if it has not done so already.
|
||||
* Also ensures correct orientation relative to the door using DDTeleporter.
|
||||
* @param world- world the player is currently in
|
||||
* @param linkData- the link the player is using to teleport, sends the player to its dest information.
|
||||
* @param player- the instance of the player to be teleported
|
||||
* @param orientation- the orientation of the door used to teleport, determines player orientation and door placement on arrival
|
||||
* @Return
|
||||
*/
|
||||
public static void traverseDimDoor(World world, IDimLink linkData, Entity entity)
|
||||
{
|
||||
DDProperties properties = DDProperties.instance();
|
||||
|
||||
if (world.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (linkData != null)
|
||||
{
|
||||
int destinationID = link.destination().getDimension();
|
||||
|
||||
if(PocketManager.dimList.containsKey(destinationID) && PocketManager.dimList.containsKey(world.provider.dimensionId))
|
||||
{
|
||||
this.generatePocket(linkData);
|
||||
|
||||
if(mod_pocketDim.teleTimer==0||entity instanceof EntityPlayer)
|
||||
{
|
||||
mod_pocketDim.teleTimer=2+rand.nextInt(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(!world.isRemote)
|
||||
{
|
||||
entity = this.teleportEntity(world, entity, linkData);
|
||||
}
|
||||
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
|
||||
|
||||
int playerXCoord=MathHelper.floor_double(entity.posX);
|
||||
int playerYCoord=MathHelper.floor_double(entity.posY);
|
||||
int playerZCoord=MathHelper.floor_double(entity.posZ);
|
||||
|
||||
if(!entity.worldObj.isBlockOpaqueCube(playerXCoord, playerYCoord-1,playerZCoord )&&PocketManager.instance.getDimData(linkData.locDimID).isDimRandomRift&&!linkData.hasGennedDoor)
|
||||
{
|
||||
for(int count=0;count<20;count++)
|
||||
{
|
||||
if(!entity.worldObj.isAirBlock(playerXCoord, playerYCoord-2-count,playerZCoord))
|
||||
{
|
||||
if(Block.blocksList[entity.worldObj.getBlockId(playerXCoord, playerYCoord-2-count,playerZCoord)].blockMaterial.isLiquid())
|
||||
{
|
||||
entity.worldObj.setBlock(playerXCoord, playerYCoord-1, playerZCoord, properties.FabricBlockID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(entity.worldObj.isBlockOpaqueCube(playerXCoord, playerYCoord-1-count,playerZCoord))
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(count==19)
|
||||
{
|
||||
entity.worldObj.setBlock(playerXCoord, playerYCoord-1, playerZCoord, properties.FabricBlockID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.generateDoor(world,linkData);
|
||||
|
||||
|
||||
if(!entity.worldObj.isAirBlock(playerXCoord,playerYCoord+1,playerZCoord))
|
||||
{
|
||||
if(Block.blocksList[entity.worldObj.getBlockId(playerXCoord,playerYCoord+1,playerZCoord)].isOpaqueCube() &&
|
||||
!mod_pocketDim.blockRift.isBlockImmune(entity.worldObj, playerXCoord+1,playerYCoord,playerZCoord))
|
||||
{
|
||||
entity.worldObj.setBlock(playerXCoord,playerYCoord+1,playerZCoord,0);
|
||||
}
|
||||
}
|
||||
if (!entity.worldObj.isAirBlock(playerXCoord,playerYCoord,playerZCoord))
|
||||
{
|
||||
if(Block.blocksList[entity.worldObj.getBlockId(playerXCoord,playerYCoord,playerZCoord)].isOpaqueCube() &&
|
||||
!mod_pocketDim.blockRift.isBlockImmune(entity.worldObj, playerXCoord,playerYCoord,playerZCoord))
|
||||
{
|
||||
entity.worldObj.setBlock(playerXCoord,playerYCoord,playerZCoord,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1,259 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
/**Class that contains all the information about a specific dim that is pertienent to Dim Doors. Holds all the rifts present in the dim sorted by x,y,z and
|
||||
* wether or not the dim is a pocket or not, along with its depth.
|
||||
* @Return
|
||||
*/
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class DimData implements Serializable
|
||||
{
|
||||
public int dimID;
|
||||
public int depth;
|
||||
public int dimOrientation;
|
||||
|
||||
public World world;
|
||||
|
||||
public NewLinkData exitDimLink;
|
||||
|
||||
public boolean isPocket;
|
||||
public boolean hasBeenFilled=false;
|
||||
public boolean hasDoor=false;
|
||||
public boolean isDimRandomRift=false;
|
||||
public DungeonGenerator dungeonGenerator = null;
|
||||
//public boolean isPrivatePocket = false;
|
||||
public HashMap<Integer, HashMap<Integer, HashMap<Integer, NewLinkData>>> linksInThisDim = new HashMap();
|
||||
HashMap<Integer, NewLinkData> dimX;
|
||||
HashMap<Integer, HashMap<Integer, NewLinkData>> dimY ;
|
||||
|
||||
static final long serialVersionUID = 454342L;
|
||||
|
||||
public DimData(int dimID, boolean isPocket, int depth, NewLinkData exitLinkData)
|
||||
{
|
||||
this.dimID=dimID;
|
||||
this.depth=depth;
|
||||
this.isPocket=isPocket;
|
||||
|
||||
this.exitDimLink= exitLinkData;
|
||||
}
|
||||
|
||||
public DimData(int dimID, boolean isPocket, int depth, int exitLinkDimID, int exitX, int exitY, int exitZ)
|
||||
{
|
||||
this(dimID, isPocket, depth, new NewLinkData(exitLinkDimID, exitX, exitY, exitZ));
|
||||
}
|
||||
|
||||
public NewLinkData findNearestRift(World world, int range, int x, int y, int z)
|
||||
{
|
||||
NewLinkData nearest=null;
|
||||
float distance=range+1;
|
||||
int i=-range;
|
||||
int j=-range;
|
||||
int k=-range;
|
||||
DDProperties properties = DDProperties.instance();
|
||||
|
||||
while (i<range)
|
||||
{
|
||||
while (j<range)
|
||||
{
|
||||
while (k<range)
|
||||
{
|
||||
if (world.getBlockId(x+i, y+j, z+k) == properties.RiftBlockID && MathHelper.abs(i)+MathHelper.abs(j)+MathHelper.abs(k)<distance)
|
||||
{
|
||||
if(MathHelper.abs(i)+MathHelper.abs(j)+MathHelper.abs(k)!=0)
|
||||
{
|
||||
nearest=this.findLinkAtCoords(x+i, y+j, z+k);
|
||||
distance=MathHelper.abs(i)+MathHelper.abs(j)+MathHelper.abs(k);
|
||||
}
|
||||
|
||||
}
|
||||
k++;
|
||||
}
|
||||
k=-range;
|
||||
j++;
|
||||
|
||||
}
|
||||
j=-range;
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
return nearest;
|
||||
|
||||
}
|
||||
|
||||
public ArrayList findRiftsInRange(World world, int range, int x, int y, int z)
|
||||
{
|
||||
NewLinkData nearest=null;
|
||||
ArrayList rifts = new ArrayList();
|
||||
int i=-range;
|
||||
int j=-range;
|
||||
int k=-range;
|
||||
DDProperties properties = DDProperties.instance();
|
||||
|
||||
while (i<range)
|
||||
{
|
||||
while (j<range)
|
||||
{
|
||||
while (k<range)
|
||||
{
|
||||
if(world.getBlockId(x+i, y+j, z+k)==properties.RiftBlockID)
|
||||
{
|
||||
if(MathHelper.abs(i)+MathHelper.abs(j)+MathHelper.abs(k)!=0)
|
||||
{
|
||||
nearest=this.findLinkAtCoords(x+i, y+j, z+k);
|
||||
if(nearest!=null)
|
||||
{
|
||||
rifts.add(nearest);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
k++;
|
||||
}
|
||||
k=-range;
|
||||
j++;
|
||||
|
||||
}
|
||||
j=-range;
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
return rifts;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public NewLinkData addLinkToDim(NewLinkData link)
|
||||
{
|
||||
if(this.linksInThisDim.containsKey(link.locZCoord))
|
||||
{
|
||||
this.dimY=this.linksInThisDim.get(link.locZCoord);
|
||||
|
||||
if(this.dimY.containsKey(link.locYCoord))
|
||||
{
|
||||
this.dimX=this.dimY.get(link.locYCoord);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dimX=new HashMap<Integer, NewLinkData>();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dimX=new HashMap<Integer, NewLinkData>();
|
||||
this.dimY=new HashMap<Integer, HashMap<Integer, NewLinkData>>();
|
||||
}
|
||||
|
||||
this.dimX.put(link.locXCoord, link);
|
||||
this.dimY.put(link.locYCoord, dimX);
|
||||
this.linksInThisDim.put(link.locZCoord, dimY);
|
||||
|
||||
//System.out.println("added link to dim "+this.dimID);
|
||||
return link;
|
||||
|
||||
}
|
||||
|
||||
public NewLinkData addLinkToDim( int destinationDimID, int locationXCoord, int locationYCoord, int locationZCoord, int destinationXCoord, int destinationYCoord, int destinationZCoord, int linkOrientation)
|
||||
{
|
||||
NewLinkData linkData= new NewLinkData(this.dimID, destinationDimID, locationXCoord, locationYCoord, locationZCoord, destinationXCoord, destinationYCoord,destinationZCoord,this.isPocket,linkOrientation);
|
||||
|
||||
return this.addLinkToDim(linkData);
|
||||
}
|
||||
|
||||
public boolean isLimbo()
|
||||
{
|
||||
return (this.dimID == DDProperties.instance().LimboDimensionID);
|
||||
}
|
||||
|
||||
public void removeLinkAtCoords(NewLinkData link)
|
||||
{
|
||||
this.removeLinkAtCoords(link.locDimID, link.locXCoord, link.locYCoord, link.locZCoord);
|
||||
}
|
||||
|
||||
public void removeLinkAtCoords(int locationID, int locationXCoord, int locationYCoord, int locationZCoord)
|
||||
{
|
||||
if (this.linksInThisDim.containsKey(locationZCoord))
|
||||
{
|
||||
this.dimY=this.linksInThisDim.get(locationZCoord);
|
||||
|
||||
if(this.dimY.containsKey(locationYCoord))
|
||||
{
|
||||
this.dimX=this.dimY.get(locationYCoord);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dimX=new HashMap<Integer, NewLinkData>();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dimX=new HashMap<Integer, NewLinkData>();
|
||||
this.dimY=new HashMap<Integer, HashMap<Integer, NewLinkData>>();
|
||||
}
|
||||
|
||||
this.dimX.remove(locationXCoord);
|
||||
this.dimY.put(locationYCoord, dimX);
|
||||
this.linksInThisDim.put(locationZCoord, dimY);
|
||||
}
|
||||
|
||||
public NewLinkData findLinkAtCoords(int locationXCoord, int locationYCoord, int locationZCoord)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(this.linksInThisDim.containsKey(locationZCoord))
|
||||
{
|
||||
this.dimY=this.linksInThisDim.get(locationZCoord);
|
||||
|
||||
if(this.dimY.containsKey(locationYCoord))
|
||||
{
|
||||
this.dimX=this.dimY.get(locationYCoord);
|
||||
|
||||
if(this.dimX.containsKey(locationXCoord))
|
||||
{
|
||||
return this.dimX.get(locationXCoord);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception E)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<NewLinkData> getLinksInDim()
|
||||
{
|
||||
//TODO: We might want to modify this function, but I'm afraid of breaking something right now.
|
||||
//To begin with, the name is wrong. This doesn't print anything! >_o ~SenseiKiwi
|
||||
|
||||
ArrayList<NewLinkData> links = new ArrayList<NewLinkData>();
|
||||
if (this.linksInThisDim == null)
|
||||
{
|
||||
return links;
|
||||
}
|
||||
for (HashMap<Integer, HashMap<Integer, NewLinkData>> first : this.linksInThisDim.values())
|
||||
{
|
||||
for (HashMap<Integer, NewLinkData> second : first.values())
|
||||
{
|
||||
for (NewLinkData linkData : second.values())
|
||||
{
|
||||
links.add(linkData);
|
||||
}
|
||||
}
|
||||
}
|
||||
return links;
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonType;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||
|
||||
public class DungeonGenerator implements Serializable
|
||||
{
|
||||
//This static field is hax so that I don't have to add an instance field to DungeonGenerator to support DungeonType.
|
||||
//Otherwise it would have to be serializable and all sorts of problems would arise.
|
||||
private static final HashMap<DungeonGenerator, DungeonType> dungeonTypes = new HashMap<DungeonGenerator, DungeonType>();
|
||||
|
||||
public int weight;
|
||||
public String schematicPath;
|
||||
public ArrayList<HashMap> sideRifts = new ArrayList<HashMap>();
|
||||
public NewLinkData exitLink;
|
||||
public boolean isOpen;
|
||||
|
||||
public int sideDoorsSoFar=0;
|
||||
public int exitDoorsSoFar=0;
|
||||
public int deadEndsSoFar=0;
|
||||
|
||||
public DungeonGenerator(int weight, String schematicPath, boolean isOpen, DungeonType dungeonType)
|
||||
{
|
||||
this.weight = weight;
|
||||
this.schematicPath = schematicPath;
|
||||
this.isOpen = isOpen;
|
||||
|
||||
dungeonTypes.put(this, dungeonType); //Hax...
|
||||
}
|
||||
|
||||
public DungeonType getDungeonType()
|
||||
{
|
||||
DungeonType type = dungeonTypes.get(this);
|
||||
if (type == null)
|
||||
{
|
||||
//Infer the dungeon's type from its file name
|
||||
//There is minimal risk of us applying this to untagged dungeons and this'll be phased out
|
||||
//when we get the new save format.
|
||||
try
|
||||
{
|
||||
File file = new File(schematicPath);
|
||||
String typeName = file.getName().split("_")[0];
|
||||
String packName = file.getParentFile().getName();
|
||||
DungeonPack pack = DungeonHelper.instance().getDungeonPack(packName);
|
||||
if (pack == null)
|
||||
{
|
||||
pack = DungeonHelper.instance().getDungeonPack("ruins");
|
||||
}
|
||||
type = pack.getType(typeName);
|
||||
}
|
||||
catch (Exception e) { }
|
||||
if (type == null)
|
||||
{
|
||||
type = DungeonType.UNKNOWN_TYPE;
|
||||
}
|
||||
dungeonTypes.put(this, type);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return (schematicPath != null) ? schematicPath.hashCode() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
return equals((DungeonGenerator) other);
|
||||
}
|
||||
|
||||
public boolean equals(DungeonGenerator other)
|
||||
{
|
||||
return ((this.schematicPath != null && this.schematicPath.equals(other.schematicPath)) ||
|
||||
(this.schematicPath == other.schematicPath));
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.sound.SoundLoadEvent;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.RiftRegenerator;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -38,38 +37,7 @@ public class EventHookContainer
|
||||
@ForgeSubscribe
|
||||
public void onWorldLoad(WorldEvent.Load event)
|
||||
{
|
||||
if (!mod_pocketDim.hasInitDims && event.world.provider.dimensionId == 0 && !event.world.isRemote)
|
||||
{
|
||||
System.out.println("Registering Pocket Dims");
|
||||
mod_pocketDim.hasInitDims = true;
|
||||
dimHelper.instance.unregsisterDims();
|
||||
dimHelper.dimList.clear();
|
||||
dimHelper.instance.interDimLinkList.clear();
|
||||
dimHelper.instance.initPockets();
|
||||
}
|
||||
|
||||
//TODO: In the future, we should iterate over DimHelper's dimension list. We ignore other dimensions anyway.
|
||||
for (int dimensionID : dimHelper.getIDs())
|
||||
{
|
||||
World world = dimHelper.getWorld(dimensionID);
|
||||
int linkCount = 0;
|
||||
|
||||
if (dimHelper.dimList.containsKey(dimensionID))
|
||||
{
|
||||
for (NewLinkData link : dimHelper.instance.getDimData(dimensionID).getLinksInDim())
|
||||
{
|
||||
if (!mod_pocketDim.blockRift.isBlockImmune(world, link.locXCoord, link.locYCoord, link.locZCoord))
|
||||
{
|
||||
world.setBlock(link.locXCoord, link.locYCoord, link.locZCoord, properties.RiftBlockID);
|
||||
}
|
||||
linkCount++;
|
||||
if (linkCount >= 100)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
RiftRegenerator.regenerateRiftsInAllWorlds();
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
@@ -88,10 +56,9 @@ public class EventHookContainer
|
||||
@ForgeSubscribe
|
||||
public void onWorldsave(WorldEvent.Save event)
|
||||
{
|
||||
|
||||
if (mod_pocketDim.hasInitDims && event.world.provider.dimensionId == 0)
|
||||
if (PocketManager.isInitialized() && event.world.provider.dimensionId == 0)
|
||||
{
|
||||
dimHelper.instance.save();
|
||||
PocketManager.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,213 +8,164 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.network.FMLNetworkHandler;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
|
||||
public class PacketHandler implements IPacketHandler
|
||||
{
|
||||
public static int regsiterDimPacketID = 3;
|
||||
public static int registerLinkPacketID = 4;
|
||||
public static int removeLinkPacketID = 5;
|
||||
public static int linkKeyPacketID = 7;
|
||||
public static int dimPacketID = 6;
|
||||
public static int dimUpdatePacketID = 1;
|
||||
private static DDProperties properties = null;
|
||||
public static byte DIM_UPDATE_PACKET_ID = 1;
|
||||
public static byte REGISTER_DIM_PACKET_ID = 3;
|
||||
public static byte REGISTER_LINK_PACKET_ID = 4;
|
||||
public static byte REMOVE_LINK_PACKET_ID = 5;
|
||||
public static byte DIM_PACKET_ID = 6;
|
||||
public static byte LINK_KEY_PACKET_ID = 7;
|
||||
|
||||
@Override
|
||||
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player)
|
||||
{
|
||||
|
||||
if (packet.channel.equals("DimDoorPackets"))
|
||||
{
|
||||
handleRandom(packet,player);
|
||||
processPacket(packet, player);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void handleRandom(Packet250CustomPayload packet, Player player)
|
||||
private void processPacket(Packet250CustomPayload packet, Player player)
|
||||
{
|
||||
ByteArrayDataInput data = ByteStreams.newDataInput(packet.data);
|
||||
|
||||
int id=data.readByte();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(id==regsiterDimPacketID)
|
||||
ByteArrayDataInput data = ByteStreams.newDataInput(packet.data);
|
||||
int id = data.readByte();
|
||||
if (id == REGISTER_DIM_PACKET_ID)
|
||||
{
|
||||
|
||||
|
||||
|
||||
int dimId = data.readInt();
|
||||
// System.out.println("regsitered dim ID" + dimId);
|
||||
try
|
||||
{
|
||||
DimData dimDataToAdd = new DimData(dimId, data.readBoolean(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt());
|
||||
|
||||
if(!dimHelper.dimList.containsKey(dimId))
|
||||
{
|
||||
dimHelper.dimList.put(dimId, dimDataToAdd);
|
||||
}
|
||||
if(dimDataToAdd.isPocket)
|
||||
{
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
|
||||
dimHelper.registerDimension(dimId, properties.PocketProviderID);
|
||||
//System.out.println("regsitered dim ID" + dimId);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// e.printStackTrace();
|
||||
if(dimId!=0)
|
||||
{
|
||||
// System.out.println(String.valueOf(dimId)+"dimID already registered");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(id==registerLinkPacketID)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
int dimId = data.readInt();
|
||||
try
|
||||
{
|
||||
DimData dimDataToAddLink= dimHelper.instance.getDimData(dimId);
|
||||
|
||||
NewLinkData linkToAdd = new NewLinkData(dimId, data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readBoolean(),data.readInt());
|
||||
linkToAdd.hasGennedDoor=data.readBoolean();
|
||||
|
||||
dimHelper.instance.createLink(linkToAdd);
|
||||
NewDimData dimDataToAdd = new NewDimData(dimId, data.readBoolean(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt());
|
||||
|
||||
if(!PocketManager.dimList.containsKey(dimId))
|
||||
{
|
||||
PocketManager.dimList.put(dimId, dimDataToAdd);
|
||||
}
|
||||
if (dimDataToAdd.isPocket)
|
||||
{
|
||||
DDProperties properties = DDProperties.instance();
|
||||
PocketManager.registerDimension(dimId, properties.PocketProviderID);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
System.out.println("Tried to update client link data & failed!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(id==removeLinkPacketID)
|
||||
else if (id == REGISTER_LINK_PACKET_ID)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
int dimId = data.readInt();
|
||||
try
|
||||
{
|
||||
DimData dimDataToRemoveFrom= dimHelper.instance.getDimData(dimId);
|
||||
NewDimData dimDataToAddLink= PocketManager.instance.getDimData(dimId);
|
||||
|
||||
NewLinkData linkToAdd = new NewLinkData(dimId, data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readBoolean(),data.readInt());
|
||||
dimDataToRemoveFrom.removeLinkAtCoords(linkToAdd.locDimID, linkToAdd.locXCoord,linkToAdd.locYCoord, linkToAdd.locZCoord);
|
||||
ILinkData linkToAdd = new ILinkData(dimId, data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readBoolean(),data.readInt());
|
||||
linkToAdd.hasGennedDoor=data.readBoolean();
|
||||
|
||||
PocketManager.instance.createLink(linkToAdd);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//e.printStackTrace();
|
||||
System.out.println("Tried to update client link data & failed!");
|
||||
System.err.println("Tried to update client link data and failed!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(id==this.linkKeyPacketID)
|
||||
else if (id == REMOVE_LINK_PACKET_ID)
|
||||
{
|
||||
NewLinkData link = new NewLinkData(data.readInt(), data.readInt(), data.readInt(), data.readInt());
|
||||
dimHelper.instance.interDimLinkList.put(data.readInt(), link);
|
||||
int dimId = data.readInt();
|
||||
try
|
||||
{
|
||||
NewDimData dimDataToRemoveFrom= PocketManager.instance.getDimData(dimId);
|
||||
|
||||
ILinkData linkToAdd = new ILinkData(dimId, data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readBoolean(),data.readInt());
|
||||
dimDataToRemoveFrom.removeLinkAtCoords(linkToAdd.locDimID, linkToAdd.locXCoord,linkToAdd.locYCoord, linkToAdd.locZCoord);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("Tried to update client link data & failed!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else if (id == LINK_KEY_PACKET_ID)
|
||||
{
|
||||
ILinkData link = new ILinkData(data.readInt(), data.readInt(), data.readInt(), data.readInt());
|
||||
dimHelper.PocketManager.interDimLinkList.put(data.readInt(), link);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static void processRegisterDimPacket()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void onClientJoinPacket(INetworkManager manager, HashMap<Integer, DimData> dimList)
|
||||
private static void processUpdateDimPacket()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private static void processRegisterLinkPacket()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private static void processRemoveLinkPacket()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void onClientJoinPacket(INetworkManager manager, HashMap<Integer, NewDimData> dimList)
|
||||
{
|
||||
Collection<Integer> dimIDs= dimList.keySet();
|
||||
Collection<DimData> dimDataSet= dimList.values();
|
||||
Collection<NewDimData> dimDataSet= dimList.values();
|
||||
Collection<Packet250CustomPayload> packetsToSend = new HashSet();
|
||||
|
||||
|
||||
|
||||
for(DimData data : dimDataSet)
|
||||
for(NewDimData data : dimDataSet)
|
||||
{
|
||||
|
||||
manager.addToSendQueue(PacketHandler.onDimCreatedPacket(data));
|
||||
|
||||
Collection <HashMap<Integer, HashMap<Integer, NewLinkData>>> linkList = data.linksInThisDim.values();
|
||||
Collection <HashMap<Integer, HashMap<Integer, ILinkData>>> linkList = data.linksInThisDim.values();
|
||||
|
||||
for(HashMap map : linkList )
|
||||
{
|
||||
|
||||
Collection <HashMap<Integer, NewLinkData>> linkList2 = map.values();
|
||||
|
||||
Collection <HashMap<Integer, ILinkData>> linkList2 = map.values();
|
||||
for(HashMap map2 : linkList2)
|
||||
{
|
||||
Collection <NewLinkData> linkList3 = map2.values();
|
||||
Collection <ILinkData> linkList3 = map2.values();
|
||||
|
||||
for(NewLinkData link : linkList3)
|
||||
for(ILinkData link : linkList3)
|
||||
{
|
||||
|
||||
packetsToSend.add(( PacketHandler.onLinkCreatedPacket(link)));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
for (Packet250CustomPayload packet : packetsToSend)
|
||||
{
|
||||
manager.addToSendQueue(packet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static Packet250CustomPayload onLinkCreatedPacket(NewLinkData link)
|
||||
public static void sendLinkCreatedPacket(ILinkData link)
|
||||
{
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream dataOut = new DataOutputStream(bos);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
dataOut.writeByte(PacketHandler.registerLinkPacketID);
|
||||
dataOut.writeInt(link.locDimID);
|
||||
dataOut.writeInt(link.destDimID);
|
||||
@@ -228,19 +179,14 @@ public class PacketHandler implements IPacketHandler
|
||||
|
||||
dataOut.writeInt(link.linkOrientation);
|
||||
dataOut.writeBoolean(link.hasGennedDoor);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Packet250CustomPayload packet= new Packet250CustomPayload();
|
||||
packet.channel="DimDoorPackets";
|
||||
packet.channel = "DimDoorPackets";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();;
|
||||
PacketDispatcher.sendPacketToAllPlayers(packet);
|
||||
@@ -248,14 +194,13 @@ public class PacketHandler implements IPacketHandler
|
||||
}
|
||||
|
||||
|
||||
public static Packet250CustomPayload linkKeyPacket(NewLinkData link, int key)
|
||||
public static void sendlinkKeyPacket(ILinkData link, int key)
|
||||
{
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream dataOut = new DataOutputStream(bos);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
dataOut.writeByte(PacketHandler.linkKeyPacketID);
|
||||
|
||||
dataOut.writeInt(link.destDimID);
|
||||
@@ -263,36 +208,27 @@ public class PacketHandler implements IPacketHandler
|
||||
dataOut.writeInt(link.destYCoord);
|
||||
dataOut.writeInt(link.destZCoord);
|
||||
dataOut.writeInt(key);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Packet250CustomPayload packet= new Packet250CustomPayload();
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
packet.channel="DimDoorPackets";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();;
|
||||
PacketDispatcher.sendPacketToAllPlayers(packet);
|
||||
return packet;
|
||||
}
|
||||
|
||||
|
||||
public static void onLinkRemovedPacket(NewLinkData link)
|
||||
public static void sendLinkRemovedPacket(ILinkData link)
|
||||
{
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream dataOut = new DataOutputStream(bos);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
dataOut.writeByte(PacketHandler.removeLinkPacketID);
|
||||
dataOut.writeInt(link.locDimID);
|
||||
dataOut.writeInt(link.destDimID);
|
||||
@@ -303,13 +239,7 @@ public class PacketHandler implements IPacketHandler
|
||||
dataOut.writeInt(link.destYCoord);
|
||||
dataOut.writeInt(link.destZCoord);
|
||||
dataOut.writeBoolean(link.isLocPocket);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
@@ -323,17 +253,13 @@ public class PacketHandler implements IPacketHandler
|
||||
}
|
||||
|
||||
|
||||
public static Packet250CustomPayload onDimCreatedPacket(DimData data)
|
||||
public static void sendDimCreatedPacket(NewDimData data)
|
||||
{
|
||||
|
||||
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream dataOut = new DataOutputStream(bos);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
dataOut.writeByte(PacketHandler.regsiterDimPacketID);
|
||||
dataOut.writeInt(data.dimID);
|
||||
dataOut.writeBoolean(data.isPocket);
|
||||
@@ -343,14 +269,7 @@ public class PacketHandler implements IPacketHandler
|
||||
dataOut.writeInt(data.exitDimLink.destXCoord);
|
||||
dataOut.writeInt(data.exitDimLink.destYCoord);
|
||||
dataOut.writeInt(data.exitDimLink.destZCoord);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
@@ -363,40 +282,9 @@ public class PacketHandler implements IPacketHandler
|
||||
|
||||
PacketDispatcher.sendPacketToAllPlayers(packet);
|
||||
return packet;
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
private void handleObjectPacket(Packet250CustomPayload packet, Player player)
|
||||
{
|
||||
ObjectInputStream data = new ObjectInputStream;
|
||||
int length = data.readInt();
|
||||
int id=data.readByte();
|
||||
System.out.println(id);
|
||||
if(id==dimPacketID)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
DimData dimData = data.read
|
||||
|
||||
dimHelper.dimList.put(key, value)
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
**/
|
||||
public static void sendDimObject(DimData dim)
|
||||
public static void sendDimObject(NewDimData dim)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -411,14 +299,8 @@ public class PacketHandler implements IPacketHandler
|
||||
PacketDispatcher.sendPacketToAllPlayers(packet);
|
||||
}
|
||||
catch (IOException e)
|
||||
|
||||
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,205 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.DungeonSchematic;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPackConfig;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.InvalidSchematicException;
|
||||
|
||||
public class SchematicLoader
|
||||
{
|
||||
private SchematicLoader() { }
|
||||
|
||||
public static boolean generateDungeonPocket(NewLinkData link, DDProperties properties)
|
||||
{
|
||||
if (link == null || properties == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
try
|
||||
{
|
||||
String schematicPath;
|
||||
int originDimID = link.locDimID;
|
||||
int destDimID = link.destDimID;
|
||||
HashMap<Integer, DimData> dimList = dimHelper.dimList;
|
||||
DungeonHelper dungeonHelper = DungeonHelper.instance();
|
||||
World world;
|
||||
|
||||
if (dimList.containsKey(destDimID))
|
||||
{
|
||||
dimList.get(destDimID).hasBeenFilled = true;
|
||||
if (dimHelper.getWorld(destDimID) == null)
|
||||
{
|
||||
dimHelper.initDimension(destDimID);
|
||||
}
|
||||
world = dimHelper.getWorld(destDimID);
|
||||
|
||||
if (dimList.get(destDimID).dungeonGenerator == null)
|
||||
{
|
||||
//TODO: We should centralize RNG initialization and world-seed modifiers for each specific application.
|
||||
final long localSeed = world.getSeed() ^ 0x2F50DB9B4A8057E4L ^ calculateDestinationSeed(link);
|
||||
final Random random = new Random(localSeed);
|
||||
|
||||
dungeonHelper.generateDungeonLink(link, dungeonHelper.getDimDungeonPack(originDimID), random);
|
||||
}
|
||||
schematicPath = dimList.get(destDimID).dungeonGenerator.schematicPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DungeonSchematic dungeon = checkSourceAndLoad(schematicPath);
|
||||
boolean valid;
|
||||
|
||||
//Validate the dungeon's dimensions
|
||||
if (hasValidDimensions(dungeon))
|
||||
{
|
||||
dungeon.applyImportFilters(properties);
|
||||
|
||||
//Check that the dungeon has an entrance or we'll have a crash
|
||||
if (dungeon.getEntranceDoorLocation() != null)
|
||||
{
|
||||
valid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
System.err.println("The following schematic file does not have an entrance: " + schematicPath);
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.err.println("The following schematic file has dimensions that exceed the maximum permitted dimensions for dungeons: " + schematicPath);
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if (!valid)
|
||||
{
|
||||
//TODO: In the future, remove this dungeon from the generation lists altogether.
|
||||
//That will have to wait until our code is updated to support that more easily.
|
||||
System.err.println("The dungeon will not be loaded.");
|
||||
DungeonGenerator defaultError = dungeonHelper.getDefaultErrorDungeon();
|
||||
dimList.get(destDimID).dungeonGenerator = defaultError;
|
||||
dungeon = checkSourceAndLoad(defaultError.schematicPath);
|
||||
dungeon.applyImportFilters(properties);
|
||||
}
|
||||
|
||||
//Adjust the height at which the dungeon is placed to prevent vertical clipping
|
||||
int fixedY = adjustDestinationY(world, link.destYCoord, dungeon);
|
||||
if (fixedY != link.destYCoord)
|
||||
{
|
||||
dimHelper helperInstance = dimHelper.instance;
|
||||
helperInstance.moveLinkDataDestination(link, link.destXCoord, fixedY, link.destZCoord, link.destDimID, true);
|
||||
}
|
||||
DungeonPackConfig packConfig = dungeonHelper.getDimDungeonPack(destDimID).getConfig();
|
||||
|
||||
dungeon.copyToWorld(world, new Point3D(link.destXCoord, link.destYCoord, link.destZCoord),
|
||||
link.linkOrientation, originDimID, destDimID, packConfig.doDistortDoorCoordinates());
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static int adjustDestinationY(World world, int y, DungeonSchematic dungeon)
|
||||
{
|
||||
//The goal here is to guarantee that the dungeon fits within the vertical bounds
|
||||
//of the world while shifting it as little as possible.
|
||||
int destY = y;
|
||||
|
||||
//Is the top of the dungeon going to be at Y < worldHeight?
|
||||
int entranceY = dungeon.getEntranceDoorLocation().getY();
|
||||
int pocketTop = (dungeon.getHeight() - 1) + destY - entranceY;
|
||||
int worldHeight = world.getHeight();
|
||||
if (pocketTop >= worldHeight)
|
||||
{
|
||||
destY = (worldHeight - 1) - (dungeon.getHeight() - 1) + entranceY;
|
||||
}
|
||||
|
||||
//Is the bottom of the dungeon at Y >= 0?
|
||||
if (destY < entranceY)
|
||||
{
|
||||
destY = entranceY;
|
||||
}
|
||||
return destY;
|
||||
}
|
||||
|
||||
private static boolean hasValidDimensions(DungeonSchematic dungeon)
|
||||
{
|
||||
return (dungeon.getWidth() <= DungeonHelper.MAX_DUNGEON_WIDTH &&
|
||||
dungeon.getHeight() <= DungeonHelper.MAX_DUNGEON_HEIGHT &&
|
||||
dungeon.getLength() <= DungeonHelper.MAX_DUNGEON_LENGTH);
|
||||
}
|
||||
|
||||
private static DungeonSchematic checkSourceAndLoad(String schematicPath) throws FileNotFoundException, InvalidSchematicException
|
||||
{
|
||||
//FIXME: Change this code once we introduce an isInternal flag in dungeon data
|
||||
DungeonSchematic dungeon;
|
||||
if ((new File(schematicPath)).exists())
|
||||
{
|
||||
dungeon = DungeonSchematic.readFromFile(schematicPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
dungeon = DungeonSchematic.readFromResource(schematicPath);
|
||||
}
|
||||
return dungeon;
|
||||
}
|
||||
|
||||
private static long calculateDestinationSeed(LinkData link)
|
||||
{
|
||||
//Time for some witchcraft.
|
||||
//The code here is inspired by a discussion on Stack Overflow regarding hash codes for 3D.
|
||||
//Source: http://stackoverflow.com/questions/9858376/hashcode-for-3d-integer-coordinates-with-high-spatial-coherence
|
||||
|
||||
//Use 8 bits from Y and 16 bits from X and Z. Mix in 8 bits from the destination dim ID too - that means
|
||||
//even if you aligned two doors perfectly between two pockets, it's unlikely they would lead to the same dungeon.
|
||||
//We map bits in reverse order to produce more varied RNG output for nearly-identical points. The reason is
|
||||
//that Java's Random outputs the 32 MSBs of its internal state to produce its output. If the differences
|
||||
//between two seeds are small (i.e. in the LSBs), then they will tend to produce similar random outputs anyway!
|
||||
|
||||
//Only bother to assign the 48 least-significant bits since Random only takes those bits from its seed.
|
||||
//NOTE: The casts to long are necessary to get the right results from the bit shifts!!!
|
||||
|
||||
int bit;
|
||||
int index;
|
||||
long hash;
|
||||
final int w = link.destDimID;
|
||||
final int x = link.destXCoord;
|
||||
final int y = link.destYCoord;
|
||||
final int z = link.destZCoord;
|
||||
|
||||
hash = 0;
|
||||
index = 48;
|
||||
for (bit = 0; bit < 8; bit++)
|
||||
{
|
||||
hash |= (long) ((w >> bit) & 1) << index;
|
||||
index--;
|
||||
hash |= (long) ((x >> bit) & 1) << index;
|
||||
index--;
|
||||
hash |= (long) ((y >> bit) & 1) << index;
|
||||
index--;
|
||||
hash |= (long) ((z >> bit) & 1) << index;
|
||||
index--;
|
||||
}
|
||||
for (; bit < 16; bit++)
|
||||
{
|
||||
hash |= (long) ((x >> bit) & 1) << index;
|
||||
index--;
|
||||
hash |= (long) ((z >> bit) & 1) << index;
|
||||
index--;
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
@@ -2,80 +2,68 @@ package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.blocks.BlockRift;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.MobMonolith;
|
||||
|
||||
import net.minecraft.entity.DataWatcher;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.monster.EntityEnderman;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet130UpdateSign;
|
||||
import net.minecraft.network.packet.Packet132TileEntityData;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public class TileEntityRift extends TileEntity
|
||||
|
||||
{
|
||||
private static Random random = new Random();
|
||||
|
||||
public int xOffset=0;
|
||||
public int yOffset=0;
|
||||
public int zOffset=0;
|
||||
public int distance=0;
|
||||
public boolean hasGrownRifts=false;
|
||||
public boolean shouldClose=false;
|
||||
//public boolean isClosing=false;
|
||||
public boolean isNearRift=false;
|
||||
private int count=200;
|
||||
private int count2 = 0;
|
||||
public int age = 0;
|
||||
|
||||
public HashMap<Integer, double[]> renderingCenters = new HashMap<Integer, double[]>();
|
||||
public NewLinkData nearestRiftData;
|
||||
public IDimLink nearestRiftData;
|
||||
public int spawnedEndermenID=0;
|
||||
Random rand;
|
||||
DataWatcher watcher = new DataWatcher();
|
||||
|
||||
|
||||
|
||||
|
||||
public void updateEntity()
|
||||
{
|
||||
if(rand == null)
|
||||
{
|
||||
rand = new Random();
|
||||
rand.setSeed(this.xCoord+this.yCoord+this.zCoord);
|
||||
}
|
||||
if(dimHelper.instance.getLinkDataFromCoords(xCoord, yCoord, zCoord, this.worldObj.provider.dimensionId)==null)//ensures that only rifts with TEs are active
|
||||
{
|
||||
this.invalidate();
|
||||
if(this.worldObj.getBlockId(xCoord, yCoord, zCoord)==mod_pocketDim.blockRift.blockID)//deletes rift TE if its behind something thats not a rift block
|
||||
{
|
||||
this.worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
this.invalidate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(this.worldObj.getBlockId(xCoord, yCoord, zCoord)!=mod_pocketDim.blockRift.blockID)//deletes rift TE if its behind something thats not a rift block
|
||||
{
|
||||
this.invalidate();
|
||||
return;
|
||||
}
|
||||
{
|
||||
//Invalidate this tile entity if it shouldn't exist
|
||||
if (PocketManager.getLink(xCoord, yCoord, zCoord, worldObj.provider.dimensionId) == null)
|
||||
{
|
||||
this.invalidate();
|
||||
if (worldObj.getBlockId(xCoord, yCoord, zCoord) == mod_pocketDim.blockRift.blockID)
|
||||
{
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
this.invalidate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//The code for the new rift rendering hooks in here, as well as in the ClientProxy to bind the TESR to the rift.
|
||||
//It is inactive for now.
|
||||
/**
|
||||
if (worldObj.getBlockId(xCoord, yCoord, zCoord) != mod_pocketDim.blockRift.blockID)
|
||||
{
|
||||
this.invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
//The code for the new rift rendering hooks in here, as well as in the ClientProxy to bind the TESR to the rift.
|
||||
//It is inactive for now.
|
||||
/**
|
||||
if(rand.nextInt(15) == 1)
|
||||
{
|
||||
age = age + 1;
|
||||
@@ -84,212 +72,218 @@ public class TileEntityRift extends TileEntity
|
||||
this.clearBlocksOnRift();
|
||||
**/
|
||||
|
||||
//This code should execute once every 10 seconds
|
||||
count++;
|
||||
if(count>200)
|
||||
{
|
||||
this.spawnEndermen();
|
||||
this.calculateOldParticleOffset(); //this also calculates the distance for the particle stuff.
|
||||
if(distance>1)//only grow if rifts are nearby
|
||||
{
|
||||
this.grow(distance);
|
||||
}
|
||||
count=0;
|
||||
}
|
||||
|
||||
if(this.shouldClose)//Determines if rift should render white closing particles and spread closing effect to other rifts nearby
|
||||
{
|
||||
closeRift();
|
||||
}
|
||||
}
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public void clearBlocksOnRift()//clears blocks for the new rending effect
|
||||
{
|
||||
|
||||
for(double[] coord: this.renderingCenters.values())
|
||||
{
|
||||
int x = MathHelper.floor_double(coord[0]+.5);
|
||||
int y = MathHelper.floor_double(coord[1]+.5);
|
||||
int z = MathHelper.floor_double(coord[2]+.5);
|
||||
|
||||
if(!BlockRift.isBlockImmune(worldObj,this.xCoord+x, this.yCoord+y, this.zCoord+z))//right side
|
||||
{
|
||||
this.worldObj.setBlockToAir(this.xCoord+x, this.yCoord+y, this.zCoord+z);
|
||||
}
|
||||
|
||||
if(!BlockRift.isBlockImmune(worldObj,this.xCoord-x, this.yCoord-y, this.zCoord-z))//left side
|
||||
{
|
||||
this.worldObj.setBlockToAir(this.xCoord-x, this.yCoord-y, this.zCoord-z);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public void spawnEndermen()
|
||||
{
|
||||
if(this.worldObj.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(dimHelper.instance.getDimData(this.worldObj.provider.dimensionId)!=null)//ensures that this rift is only spawning one enderman at a time, to prevent hordes of endermen
|
||||
{
|
||||
if(this.worldObj.getEntityByID(this.spawnedEndermenID)!=null)
|
||||
//This code should execute once every 10 seconds
|
||||
count++;
|
||||
if (count > 200)
|
||||
{
|
||||
this.spawnEndermen();
|
||||
this.calculateOldParticleOffset(); //this also calculates the distance for the particle stuff.
|
||||
if (distance > 1) //only grow if rifts are nearby
|
||||
{
|
||||
if(this.worldObj.getEntityByID(this.spawnedEndermenID) instanceof EntityEnderman)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.grow(distance);
|
||||
}
|
||||
count = 0;
|
||||
}
|
||||
|
||||
if (this.shouldClose) //Determines if rift should render white closing particles and spread closing effect to other rifts nearby
|
||||
{
|
||||
closeRift();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void clearBlocksOnRift()
|
||||
{
|
||||
//clears blocks for the new rending effect
|
||||
|
||||
for(double[] coord: this.renderingCenters.values())
|
||||
{
|
||||
int x = MathHelper.floor_double(coord[0]+.5);
|
||||
int y = MathHelper.floor_double(coord[1]+.5);
|
||||
int z = MathHelper.floor_double(coord[2]+.5);
|
||||
|
||||
if (!mod_pocketDim.blockRift.isBlockImmune(worldObj,this.xCoord+x, this.yCoord+y, this.zCoord+z))//right side
|
||||
{
|
||||
worldObj.setBlockToAir(this.xCoord+x, this.yCoord+y, this.zCoord+z);
|
||||
}
|
||||
|
||||
nearestRiftData = dimHelper.instance.getDimData(this.worldObj.provider.dimensionId).findNearestRift(worldObj, 5, xCoord, yCoord, zCoord);//enderman will only spawn in groups of rifts
|
||||
if(nearestRiftData!=null)
|
||||
{
|
||||
if(rand.nextInt(30)==0&&!this.worldObj.isRemote)
|
||||
{
|
||||
if (!mod_pocketDim.blockRift.isBlockImmune(worldObj,this.xCoord-x, this.yCoord-y, this.zCoord-z))//left side
|
||||
{
|
||||
worldObj.setBlockToAir(this.xCoord-x, this.yCoord-y, this.zCoord-z);
|
||||
}
|
||||
|
||||
List list = worldObj.getEntitiesWithinAABB(EntityEnderman.class, AxisAlignedBB.getBoundingBox( this.xCoord-9, this.yCoord-3, this.zCoord-9, this.xCoord+9, this.yCoord+3, this.zCoord+9));
|
||||
}
|
||||
}
|
||||
|
||||
if(list.size()<1)
|
||||
{
|
||||
public void spawnEndermen()
|
||||
{
|
||||
if (worldObj.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NewDimData dimension = PocketManager.getDimensionData(worldObj);
|
||||
|
||||
EntityEnderman creeper = new EntityEnderman(worldObj);
|
||||
creeper.setLocationAndAngles(this.xCoord+.5, this.yCoord-1, this.zCoord+.5, 5, 6);
|
||||
worldObj.spawnEntityInWorld(creeper);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isNearRift=false;
|
||||
}
|
||||
//Ensure that this rift is only spawning one enderman at a time, to prevent hordes of endermen
|
||||
Entity entity = worldObj.getEntityByID(this.spawnedEndermenID);
|
||||
if (entity != null && entity instanceof EntityEnderman)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public void closeRift()
|
||||
{
|
||||
if(count2>20&&count2<22)
|
||||
{
|
||||
nearestRiftData = dimHelper.instance.getDimData(this.worldObj.provider.dimensionId).findNearestRift(worldObj, 10, xCoord, yCoord, zCoord);
|
||||
if(this.nearestRiftData!=null)
|
||||
{
|
||||
TileEntityRift rift = (TileEntityRift) this.worldObj.getBlockTileEntity(nearestRiftData.locXCoord, nearestRiftData.locYCoord, nearestRiftData.locZCoord);
|
||||
if(rift!=null)
|
||||
{
|
||||
rift.shouldClose=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(count2>40)
|
||||
{
|
||||
this.invalidate();
|
||||
this.worldObj.setBlock(this.xCoord, this.yCoord, this.zCoord,0);
|
||||
if(dimHelper.instance.getLinkDataFromCoords(this.xCoord, this.yCoord, this.zCoord, this.worldObj.provider.dimensionId)!=null)
|
||||
{
|
||||
dimHelper.instance.removeLink(this.worldObj.provider.dimensionId, this.xCoord, this.yCoord, this.zCoord);
|
||||
this.worldObj.playSound(xCoord, yCoord, zCoord, "mods.DimDoors.sfx.riftClose", (float) .7, 1,true);
|
||||
//enderman will only spawn in groups of rifts
|
||||
nearestRiftData = dimension.findNearestRift(worldObj, 5, xCoord, yCoord, zCoord);
|
||||
if (nearestRiftData != null)
|
||||
{
|
||||
if (random.nextInt(30) == 0)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Entity> list = (List<Entity>) worldObj.getEntitiesWithinAABB(EntityEnderman.class,
|
||||
AxisAlignedBB.getBoundingBox(xCoord - 9, yCoord - 3, zCoord - 9, xCoord + 9, yCoord + 3, zCoord + 9));
|
||||
|
||||
}
|
||||
}
|
||||
count2++;
|
||||
}
|
||||
public void calculateOldParticleOffset()
|
||||
{
|
||||
nearestRiftData = dimHelper.instance.getDimData(this.worldObj.provider.dimensionId).findNearestRift(worldObj, 5, xCoord, yCoord, zCoord);
|
||||
if(nearestRiftData!=null)
|
||||
{
|
||||
this.xOffset=this.xCoord-nearestRiftData.locXCoord;
|
||||
this.yOffset=this.yCoord-nearestRiftData.locYCoord;
|
||||
this.zOffset=this.zCoord-nearestRiftData.locZCoord;
|
||||
this.distance=(int) (MathHelper.abs(xOffset)+MathHelper.abs(yOffset)+MathHelper.abs(zOffset));
|
||||
this.isNearRift=true;
|
||||
if (list.isEmpty())
|
||||
{
|
||||
EntityEnderman enderman = new EntityEnderman(worldObj);
|
||||
enderman.setLocationAndAngles(xCoord + 0.5, yCoord - 1, zCoord + 0.5, 5, 6);
|
||||
worldObj.spawnEntityInWorld(enderman);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isNearRift = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!this.worldObj.isRemote&&distance>1)
|
||||
{
|
||||
try
|
||||
{
|
||||
grow(distance);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
public void closeRift()
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(worldObj);
|
||||
if (count2 > 20 && count2 < 22)
|
||||
{
|
||||
nearestRiftData = dimension.findNearestRift(worldObj, 10, xCoord, yCoord, zCoord);
|
||||
if (this.nearestRiftData != null)
|
||||
{
|
||||
Point4D location = nearestRiftData.source();
|
||||
TileEntityRift rift = (TileEntityRift) worldObj.getBlockTileEntity(location.getX(), location.getY(), location.getZ());
|
||||
if (rift != null)
|
||||
{
|
||||
rift.shouldClose = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count2 > 40)
|
||||
{
|
||||
this.invalidate();
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
if (dimension.getLink(xCoord, yCoord, zCoord) != null)
|
||||
{
|
||||
dimension.deleteLink(xCoord, yCoord, zCoord);
|
||||
worldObj.playSound(xCoord, yCoord, zCoord, "mods.DimDoors.sfx.riftClose", (float) .7, 1, true);
|
||||
}
|
||||
}
|
||||
count2++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void grow(int distance)
|
||||
{
|
||||
if(this.worldObj.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int growCount=0;
|
||||
if(rand.nextInt(distance*2)==0)
|
||||
{
|
||||
public void calculateOldParticleOffset()
|
||||
{
|
||||
nearestRiftData = PocketManager.getDimensionData(worldObj).findNearestRift(worldObj, 5, xCoord, yCoord, zCoord);
|
||||
if (nearestRiftData != null)
|
||||
{
|
||||
Point4D location = nearestRiftData.source();
|
||||
this.xOffset = this.xCoord - location.getX();
|
||||
this.yOffset = this.yCoord - location.getY();
|
||||
this.zOffset = this.zCoord - location.getZ();
|
||||
this.distance = Math.abs(xOffset) + Math.abs(yOffset) + Math.abs(zOffset);
|
||||
this.isNearRift=true;
|
||||
|
||||
if (!worldObj.isRemote && distance > 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
grow(distance);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void grow(int distance)
|
||||
{
|
||||
if(worldObj.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int growCount=0;
|
||||
if(random.nextInt(distance*2)==0)
|
||||
{
|
||||
int x=0,y=0,z=0;
|
||||
while(growCount<100)
|
||||
{
|
||||
growCount++;
|
||||
x=this.xCoord+(1-(rand.nextInt(2)*2)*rand.nextInt(6));
|
||||
y=this.yCoord+(1-(rand.nextInt(2)*2)*rand.nextInt(4));
|
||||
z=this.zCoord+(1-(rand.nextInt(2)*2)*rand.nextInt(6));
|
||||
if(this.worldObj.isAirBlock(x, y, z))
|
||||
x=this.xCoord+(1-(random.nextInt(2)*2)*random.nextInt(6));
|
||||
y=this.yCoord+(1-(random.nextInt(2)*2)*random.nextInt(4));
|
||||
z=this.zCoord+(1-(random.nextInt(2)*2)*random.nextInt(6));
|
||||
if(worldObj.isAirBlock(x, y, z))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if (growCount<100)
|
||||
if (growCount < 100)
|
||||
{
|
||||
|
||||
NewLinkData link = dimHelper.instance.getLinkDataFromCoords(this.xCoord, this.yCoord, this.zCoord, worldObj);
|
||||
if(link!=null)
|
||||
NewDimData dimension = PocketManager.getDimensionData(worldObj);
|
||||
IDimLink link = dimension.getLink(xCoord, yCoord, zCoord);
|
||||
if (link != null)
|
||||
{
|
||||
if(!this.hasGrownRifts&&rand.nextInt(3)==0)
|
||||
if (!this.hasGrownRifts && random.nextInt(3) == 0)
|
||||
{
|
||||
// System.out.println(link.numberofChildren);
|
||||
link.numberofChildren++;
|
||||
dimHelper.instance.createLink(this.worldObj.provider.dimensionId, link.destDimID, x, y, z, link.destXCoord, link.destYCoord, link.destZCoord).numberofChildren=link.numberofChildren+1;
|
||||
this.hasGrownRifts=true;
|
||||
dimension.createChildLink(x, y, z, link);
|
||||
this.hasGrownRifts = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void calculateNextRenderQuad(float age, Random rand)
|
||||
{
|
||||
int maxSize = MathHelper.floor_double((Math.log(Math.pow(age+1,2))));
|
||||
int iteration=0;
|
||||
while(iteration< maxSize)
|
||||
{
|
||||
iteration++;
|
||||
double fl =Math.log(iteration+1)/(iteration);
|
||||
double[] coords= new double[4];
|
||||
double noise = ((rand.nextGaussian())/(2+iteration/3+1));
|
||||
}
|
||||
}
|
||||
|
||||
if(!this.renderingCenters.containsKey(iteration-1))
|
||||
{
|
||||
if(rand.nextBoolean())
|
||||
{
|
||||
public void calculateNextRenderQuad(float age, Random rand)
|
||||
{
|
||||
int maxSize = MathHelper.floor_double((Math.log(Math.pow(age+1,2))));
|
||||
int iteration=0;
|
||||
while(iteration< maxSize)
|
||||
{
|
||||
iteration++;
|
||||
double fl =Math.log(iteration+1)/(iteration);
|
||||
double[] coords= new double[4];
|
||||
double noise = ((rand.nextGaussian())/(2+iteration/3+1));
|
||||
|
||||
if(!this.renderingCenters.containsKey(iteration-1))
|
||||
{
|
||||
if (rand.nextBoolean())
|
||||
{
|
||||
coords[0] = fl*1.5;
|
||||
coords[1] = rand.nextGaussian()/5;
|
||||
coords[2] = 0;
|
||||
coords[3] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
coords[0] = 0;
|
||||
coords[1] = rand.nextGaussian()/5;
|
||||
coords[2] = fl*1.5;
|
||||
coords[3] = 0;
|
||||
}
|
||||
this.renderingCenters.put(iteration-1,coords);
|
||||
iteration--;
|
||||
}
|
||||
else if(!this.renderingCenters.containsKey(iteration))
|
||||
{
|
||||
}
|
||||
this.renderingCenters.put(iteration-1,coords);
|
||||
iteration--;
|
||||
}
|
||||
else if(!this.renderingCenters.containsKey(iteration))
|
||||
{
|
||||
if(this.renderingCenters.get(iteration-1)[3]==0)
|
||||
{
|
||||
coords[0]=noise/2+this.renderingCenters.get(iteration-1)[0];
|
||||
@@ -305,66 +299,66 @@ public class TileEntityRift extends TileEntity
|
||||
coords[3] = 1;
|
||||
}
|
||||
this.renderingCenters.put(iteration,coords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderInPass(int pass)
|
||||
{
|
||||
return pass == 1;
|
||||
}
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
this.renderingCenters= new HashMap<Integer, double[]>();
|
||||
this.count=nbt.getInteger("count");
|
||||
this.count2=nbt.getInteger("count2");
|
||||
this.xOffset = nbt.getInteger("xOffset");
|
||||
this.yOffset = nbt.getInteger("yOffset");
|
||||
this.zOffset = nbt.getInteger("zOffset");
|
||||
this.hasGrownRifts =nbt.getBoolean("grownRifts");
|
||||
this.age=nbt.getInteger("age");
|
||||
this.shouldClose=nbt.getBoolean("shouldClose");
|
||||
this.spawnedEndermenID = nbt.getInteger("spawnedEndermenID");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("hashMapSize", this.renderingCenters.size());
|
||||
nbt.setInteger("age", this.age);
|
||||
nbt.setInteger("count", this.count);
|
||||
nbt.setInteger("count2", this.count2);
|
||||
nbt.setBoolean("grownRifts",this.hasGrownRifts);
|
||||
nbt.setInteger("xOffset", this.xOffset);
|
||||
nbt.setInteger("yOffset", this.yOffset);
|
||||
nbt.setInteger("zOffset", this.zOffset);
|
||||
nbt.setBoolean("shouldClose", this.shouldClose);
|
||||
nbt.setInteger("spawnedEndermenID", this.spawnedEndermenID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
Packet132TileEntityData packet = new Packet132TileEntityData();
|
||||
packet.actionType = 0;
|
||||
packet.xPosition = xCoord;
|
||||
packet.yPosition = yCoord;
|
||||
packet.zPosition = zCoord;
|
||||
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
packet.customParam1 = nbt;
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt)
|
||||
{
|
||||
readFromNBT(pkt.customParam1);
|
||||
}
|
||||
@Override
|
||||
public boolean shouldRenderInPass(int pass)
|
||||
{
|
||||
return pass == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
this.renderingCenters= new HashMap<Integer, double[]>();
|
||||
this.count=nbt.getInteger("count");
|
||||
this.count2=nbt.getInteger("count2");
|
||||
this.xOffset = nbt.getInteger("xOffset");
|
||||
this.yOffset = nbt.getInteger("yOffset");
|
||||
this.zOffset = nbt.getInteger("zOffset");
|
||||
this.hasGrownRifts =nbt.getBoolean("grownRifts");
|
||||
this.age=nbt.getInteger("age");
|
||||
this.shouldClose=nbt.getBoolean("shouldClose");
|
||||
this.spawnedEndermenID = nbt.getInteger("spawnedEndermenID");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("hashMapSize", this.renderingCenters.size());
|
||||
nbt.setInteger("age", this.age);
|
||||
nbt.setInteger("count", this.count);
|
||||
nbt.setInteger("count2", this.count2);
|
||||
nbt.setBoolean("grownRifts",this.hasGrownRifts);
|
||||
nbt.setInteger("xOffset", this.xOffset);
|
||||
nbt.setInteger("yOffset", this.yOffset);
|
||||
nbt.setInteger("zOffset", this.zOffset);
|
||||
nbt.setBoolean("shouldClose", this.shouldClose);
|
||||
nbt.setInteger("spawnedEndermenID", this.spawnedEndermenID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
Packet132TileEntityData packet = new Packet132TileEntityData();
|
||||
packet.actionType = 0;
|
||||
packet.xPosition = xCoord;
|
||||
packet.yPosition = yCoord;
|
||||
packet.zPosition = zCoord;
|
||||
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
packet.customParam1 = nbt;
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt)
|
||||
{
|
||||
readFromNBT(pkt.customParam1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,27 +2,17 @@ package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.blocks.ExitDoor;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.ExitDoor;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -32,7 +22,7 @@ public class TransientDoor extends ExitDoor
|
||||
protected TransientDoor(int par1, Material material)
|
||||
{
|
||||
super(par1, Material.grass);
|
||||
// this.blockIndexInTexture = 18;
|
||||
// this.blockIndexInTexture = 18;
|
||||
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
@@ -41,113 +31,73 @@ public class TransientDoor extends ExitDoor
|
||||
private static DDProperties properties = null;
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_top");
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_top");
|
||||
|
||||
}
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
/**
|
||||
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
|
||||
*/
|
||||
public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
/**
|
||||
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
|
||||
*/
|
||||
public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
|
||||
return this.blockIcon;
|
||||
return this.blockIcon;
|
||||
|
||||
|
||||
}
|
||||
public boolean isCollidable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public boolean isCollidable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
super.onBlockAdded(par1World, par2, par3, par4);
|
||||
this.updateAttatchedTile(par1World, par2, par3, par4);
|
||||
}
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
super.onBlockAdded(par1World, par2, par3, par4);
|
||||
this.updateAttachedTile(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
{
|
||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
//TODO: Would it kill us to use REASONABLE variable names? <_< ~SenseiKiwi
|
||||
int var12 = (int) (MathHelper.floor_double((double) ((entity.rotationYaw + 90) * 4.0F / 360.0F) + 0.5D) & 3);
|
||||
|
||||
int var12 = (int) (MathHelper.floor_double((double)((par5Entity.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
|
||||
int num = par1World.getBlockMetadata(par2, par3, par4);
|
||||
// System.out.println("metadata "+num+" orientation "+var12);
|
||||
int orientation = world.getBlockMetadata(x, y - 1, z);
|
||||
if (!world.isRemote && (orientation >= 4 && orientation <= 7) && (orientation - 4) == var12 &&
|
||||
world.getBlockId(x, y - 1, z) == this.blockID)
|
||||
{
|
||||
this.onPoweredBlockChange(world, x, y, z, false);
|
||||
|
||||
if(!par1World.isRemote&&(num)==var12||!par1World.isRemote&&!(par5Entity instanceof EntityPlayer))
|
||||
IDimLink link = PocketManager.getLink(x, y, z, world.provider.dimensionId);
|
||||
if (link != null)
|
||||
{
|
||||
//Turn the transient door into a rift before teleporting the entity
|
||||
world.setBlock(x, y, z, properties.RiftBlockID);
|
||||
world.setBlockToAir(x, y - 1, z);
|
||||
PocketManager.traverseDimDoor(world, link, entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
NewLinkData linkData= dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World);
|
||||
if(linkData!=null)
|
||||
{
|
||||
if(dimHelper.dimList.containsKey(linkData.destDimID))
|
||||
{
|
||||
par1World.setBlock(par2, par3-1, par4, 0);
|
||||
par1World.setBlock(par2, par3, par4, properties.RiftBlockID);
|
||||
dimHelper.instance.traverseDimDoor(par1World, linkData, par5Entity);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
linkData= dimHelper.instance.getLinkDataFromCoords(par2, par3+1, par4, par1World);
|
||||
if(linkData!=null)
|
||||
{
|
||||
if(dimHelper.dimList.containsKey(linkData.destDimID))
|
||||
{
|
||||
par1World.setBlock(par2, par3, par4, 0);
|
||||
par1World.setBlock(par2, par3+1, par4, properties.RiftBlockID);
|
||||
dimHelper.instance.traverseDimDoor(par1World, linkData, par5Entity);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A function to open a door.
|
||||
*/
|
||||
|
||||
public int getRenderType()
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
|
||||
public int getRenderType()
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
@@ -9,14 +9,12 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import StevenDimDoors.mod_pocketDim.BlankTeleporter;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
public class BlockDimWallPerm extends Block
|
||||
{
|
||||
@@ -45,32 +43,33 @@ public class BlockDimWallPerm extends Block
|
||||
/**
|
||||
* Only matters if the player is in limbo, acts to teleport the player from limbo back to dim 0
|
||||
*/
|
||||
public void onEntityWalking(World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
public void onEntityWalking(World par1World, int par2, int par3, int par4, Entity entity)
|
||||
{
|
||||
if(!par1World.isRemote&&par1World.provider.dimensionId==properties.LimboDimensionID)
|
||||
if (!par1World.isRemote && par1World.provider.dimensionId == properties.LimboDimensionID)
|
||||
{
|
||||
Random rand = new Random();
|
||||
|
||||
NewLinkData link=dimHelper.instance.getRandomLinkData(false);
|
||||
if(link==null)
|
||||
IDimLink link = PocketManager.getRandomLinkData(false);
|
||||
if (link == null)
|
||||
{
|
||||
link =new NewLinkData(0,0,0,0);
|
||||
}
|
||||
link.destDimID = 0;
|
||||
link.locDimID = par1World.provider.dimensionId;
|
||||
World overworld = DimensionManager.getWorld(0);
|
||||
|
||||
|
||||
if(dimHelper.getWorld(0)==null)
|
||||
if (overworld == null)
|
||||
{
|
||||
dimHelper.initDimension(0);
|
||||
DimensionManager.initDimension(0);
|
||||
overworld = DimensionManager.getWorld(0);
|
||||
}
|
||||
|
||||
|
||||
if(dimHelper.getWorld(0)!=null&&par5Entity instanceof EntityPlayerMP)
|
||||
if (overworld != null && entity instanceof EntityPlayerMP)
|
||||
{
|
||||
par5Entity.fallDistance=0;
|
||||
int x = (link.destXCoord + rand.nextInt(properties.LimboReturnRange)-properties.LimboReturnRange/2);
|
||||
int z = (link.destZCoord + rand.nextInt(properties.LimboReturnRange)-properties.LimboReturnRange/2);
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
player.fallDistance = 0;
|
||||
int x = (link.destXCoord + rand.nextInt(properties.LimboReturnRange) - properties.LimboReturnRange/2);
|
||||
int z = (link.destZCoord + rand.nextInt(properties.LimboReturnRange) - properties.LimboReturnRange/2);
|
||||
|
||||
//make sure I am in the middle of a chunk, and not on a boundary, so it doesn't load the chunk next to me
|
||||
x = x + (x >> 4);
|
||||
@@ -78,46 +77,39 @@ public class BlockDimWallPerm extends Block
|
||||
|
||||
int y = yCoordHelper.getFirstUncovered(0, x, 63, z, true);
|
||||
|
||||
EntityPlayer.class.cast(par5Entity).setPositionAndUpdate( x, y, z );
|
||||
player.setPositionAndUpdate( x, y, z );
|
||||
//this complicated chunk teleports the player back to the overworld at some random location. Looks funky becaue it has to load the chunk
|
||||
link.destXCoord = x;
|
||||
link.destYCoord = y;
|
||||
link.destZCoord = z;
|
||||
dimHelper.instance.teleportEntity(par1World, par5Entity, link);
|
||||
//FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().transferPlayerToDimension((EntityPlayerMP) par5Entity, 0,new BlankTeleporter((WorldServer)par5Entity.worldObj));
|
||||
//dimHelper.instance.teleportToPocket(par1World, new LinkData(par1World.provider.dimensionId,0,x,y,z,link.locXCoord,link.locYCoord,link.locZCoord,link.isLocPocket,0),
|
||||
// EntityPlayer.class.cast(par5Entity));
|
||||
PocketManager.teleportEntity(par1World, player, link);
|
||||
|
||||
|
||||
EntityPlayer.class.cast(par5Entity).setPositionAndUpdate( x, y, z );
|
||||
player.setPositionAndUpdate( x, y, z );
|
||||
|
||||
// Make absolutely sure the player doesn't spawn inside blocks, though to be honest this shouldn't ever have to be a problem...
|
||||
dimHelper.getWorld(0).setBlock(x, y, z, 0);
|
||||
dimHelper.getWorld(0).setBlock(x, y+1, z, 0);
|
||||
overworld.setBlockToAir(x, y, z);
|
||||
overworld.setBlockToAir(x, y + 1, z);
|
||||
|
||||
int i=x;
|
||||
int j=y;
|
||||
int k=z;
|
||||
|
||||
|
||||
for(int xc=-3;xc<4;xc++)
|
||||
{
|
||||
for(int zc=-3;zc<4;zc++)
|
||||
{
|
||||
for(int yc=0;yc<200;yc++)
|
||||
{
|
||||
if(yc==0)
|
||||
if (yc==0)
|
||||
{
|
||||
|
||||
if(Math.abs(xc)+Math.abs(zc)<rand.nextInt(3)+2)
|
||||
{
|
||||
dimHelper.getWorld(0).setBlock(i+xc, j-1+yc, k+zc, properties.LimboBlockID);
|
||||
overworld.setBlock(i+xc, j-1+yc, k+zc, properties.LimboBlockID);
|
||||
}
|
||||
else if(Math.abs(xc)+Math.abs(zc)<rand.nextInt(3)+3)
|
||||
|
||||
{
|
||||
dimHelper.getWorld(0).setBlock(i+xc, j-1+yc, k+zc, properties.LimboBlockID,2,0);
|
||||
|
||||
overworld.setBlock(i+xc, j-1+yc, k+zc, properties.LimboBlockID,2,0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,16 +118,9 @@ public class BlockDimWallPerm extends Block
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
{
|
||||
EntityPlayer.class.cast(par5Entity).setPositionAndUpdate( x, y, z );
|
||||
EntityPlayer.class.cast(par5Entity).fallDistance=0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//FIXME: Why do we do this repeatedly? We also set the fall distance at the start...
|
||||
player.setPositionAndUpdate( x, y, z );
|
||||
player.fallDistance = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.LimboDecay;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.LimboDecay;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||
import StevenDimDoors.mod_pocketDim.TileEntityRift;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDimClient.ClosingRiftFX;
|
||||
import StevenDimDoors.mod_pocketDimClient.GoggleRiftFX;
|
||||
import StevenDimDoors.mod_pocketDimClient.RiftFX;
|
||||
@@ -37,7 +37,7 @@ public class BlockRift extends BlockContainer
|
||||
private static final int BLOCK_DESTRUCTION_CHANCE = 50;
|
||||
|
||||
private final DDProperties properties;
|
||||
private static ArrayList<Integer> blocksImmuneToRift;
|
||||
private final ArrayList<Integer> blocksImmuneToRift;
|
||||
|
||||
public BlockRift(int i, int j, Material par2Material, DDProperties properties)
|
||||
{
|
||||
@@ -154,7 +154,7 @@ public class BlockRift extends BlockContainer
|
||||
public void updateTick(World world, int x, int y, int z, Random random)
|
||||
{
|
||||
if (properties.RiftGriefingEnabled && !world.isRemote &&
|
||||
dimHelper.instance.getLinkDataFromCoords(x, y, z, world.provider.dimensionId) != null)
|
||||
PocketManager.getLink(x, y, z, world.provider.dimensionId) != null)
|
||||
{
|
||||
//Randomly decide whether to search for blocks to destroy. This reduces the frequency of search operations,
|
||||
//moderates performance impact, and controls the apparent speed of block destruction.
|
||||
@@ -335,7 +335,8 @@ public class BlockRift extends BlockContainer
|
||||
}
|
||||
}
|
||||
}
|
||||
public static boolean isBlockImmune(World world, int x, int y, int z)
|
||||
|
||||
public boolean isBlockImmune(World world, int x, int y, int z)
|
||||
{
|
||||
Block block = Block.blocksList[world.getBlockId(x, y, z)];
|
||||
if (block != null)
|
||||
|
||||
@@ -2,27 +2,18 @@ package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -33,114 +24,42 @@ public class ChaosDoor extends dimDoor
|
||||
|
||||
public ChaosDoor(int par1, Material material)
|
||||
{
|
||||
super(par1, Material.iron);
|
||||
super(par1, material);
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_top");
|
||||
this.blockIconBottom = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_bottom");
|
||||
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
/**
|
||||
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
|
||||
*/
|
||||
public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if(par1IBlockAccess.getBlockId(par2, par3-1, par4)==this.blockID)
|
||||
{
|
||||
return this.blockIcon;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.blockIconBottom;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if(!par1World.isRemote&&par1World.getBlockId(par2, par3-1, par4)==this.blockID)
|
||||
{
|
||||
boolean newDim=false;
|
||||
|
||||
if(dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World)==null)
|
||||
{
|
||||
newDim=true;
|
||||
}
|
||||
|
||||
if(newDim)
|
||||
{
|
||||
NewLinkData link = new NewLinkData(par1World.provider.dimensionId, properties.LimboDimensionID, par2, par3, par4, par2, par3+500, par4, false,0);
|
||||
link.linkOrientation= par1World.getBlockMetadata(par2, par3-1, par4);
|
||||
dimHelper.instance.createLink(link);
|
||||
// System.out.println(link.linkOrientation);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World)!=null)
|
||||
{
|
||||
dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World).linkOrientation=par1World.getBlockMetadata(par2, par3-1, par4);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_top");
|
||||
this.blockIconBottom = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_bottom");
|
||||
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
//uses the rift rendering list to find a random destination for the player
|
||||
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
{
|
||||
|
||||
int var12 = (int) (MathHelper.floor_double((double)((par5Entity.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
|
||||
|
||||
int num = par1World.getBlockMetadata(par2, par3-1, par4);
|
||||
if(!par1World.isRemote&&(num==5||num==4||num==6||num==7)&&(num-4)==var12&&par1World.getBlockId(par2, par3-1, par4)==properties.UnstableDoorID)
|
||||
{
|
||||
this.onPoweredBlockChange(par1World, par2, par3, par4, false);
|
||||
|
||||
boolean foundRandomDest=false;
|
||||
|
||||
int i=0;
|
||||
|
||||
|
||||
Random rand= new Random();
|
||||
|
||||
while (!foundRandomDest&&i<100)
|
||||
{
|
||||
i++;
|
||||
|
||||
NewLinkData link = (NewLinkData) dimHelper.instance.getRandomLinkData(false);
|
||||
|
||||
if(link!=null)
|
||||
{
|
||||
|
||||
if(!link.isLocPocket&&link.linkOrientation!=-10&&link.destDimID!=properties.LimboDimensionID)
|
||||
{
|
||||
foundRandomDest=true;
|
||||
|
||||
dimHelper.instance.traverseDimDoor(par1World, new NewLinkData(link.destDimID,link.locDimID,link.destXCoord,link.destYCoord,link.destZCoord,link.locXCoord,link.locYCoord,link.locZCoord,link.isLocPocket,0), par5Entity);
|
||||
|
||||
if(dimHelper.getWorld(link.locDimID)!=null)
|
||||
{
|
||||
if(dimHelper.getWorld(link.locDimID).isAirBlock(link.locXCoord,link.locYCoord,link.locZCoord))
|
||||
{
|
||||
dimHelper.getWorld(link.locDimID).setBlock(link.locXCoord,link.locYCoord,link.locZCoord, properties.RiftBlockID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
|
||||
*/
|
||||
public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if (par1IBlockAccess.getBlockId(par2, par3 - 1, par4) == this.blockID)
|
||||
{
|
||||
return this.blockIcon;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.blockIconBottom;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z)
|
||||
{
|
||||
if (!world.isRemote && world.getBlockId(x, y - 1, z) == this.blockID)
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
dimension.createLink(x, y, z).setLinkType(IDimLink.TYPE_RANDOM);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,160 +2,74 @@ package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ExitDoor extends dimDoor
|
||||
{
|
||||
|
||||
private Icon blockIconBottom;
|
||||
public ExitDoor(int par1, Material par2Material)
|
||||
|
||||
public ExitDoor(int blockID, Material material)
|
||||
{
|
||||
|
||||
super(par1, Material.wood);
|
||||
|
||||
|
||||
// TODO Auto-generated constructor stub
|
||||
super(blockID, material);
|
||||
}
|
||||
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_top");
|
||||
this.blockIconBottom = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_bottom");
|
||||
|
||||
}
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_top");
|
||||
this.blockIconBottom = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_bottom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
public void onBlockAdded(World world, int x, int y, int z)
|
||||
{
|
||||
//FIXME: We need to set door generation flags on the tile entities. Ignoring that for now. ~SenseiKiwi
|
||||
|
||||
|
||||
if(!par1World.isRemote&&par1World.getBlockId(par2, par3-1, par4)==this.blockID)
|
||||
if (!world.isRemote && world.getBlockId(x, y - 1, z) == this.blockID)
|
||||
{
|
||||
|
||||
|
||||
int locDimID=par1World.provider.dimensionId;
|
||||
|
||||
if(dimHelper.instance.dimList.containsKey(locDimID)&&dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World)==null)
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
IDimLink link = dimension.getLink(x, y, z);
|
||||
if (link == null)
|
||||
{
|
||||
DimData dimData = dimHelper.instance.getDimData(locDimID);
|
||||
int ExitDimID = dimData.exitDimLink.destDimID;
|
||||
if(dimHelper.instance.getDimData(par1World.provider.dimensionId).isPocket)
|
||||
{
|
||||
int yCoord=yCoordHelper.getFirstUncovered(ExitDimID, par2, par3, par4)-1;
|
||||
|
||||
|
||||
dimHelper.instance.createLink(locDimID, ExitDimID, par2, par3, par4, par2, yCoord, par4,par1World.getBlockMetadata(par2, par3-1, par4));
|
||||
dimHelper.instance.createLink(ExitDimID, locDimID, par2, yCoord, par4, par2, par3, par4,
|
||||
BlockRotator.transformMetadata(par1World.getBlockMetadata(par2, par3 - 1, par4), 2, Block.doorWood.blockID));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
if(dimHelper.instance.getDimDepth(locDimID)==1)
|
||||
{
|
||||
//System.out.println("exitToOverowrld from "+String.valueOf(locDimID));
|
||||
|
||||
int yCoord=yCoordHelper.getFirstUncovered(ExitDimID, par2, par3, par4);
|
||||
|
||||
|
||||
dimHelper.instance.createLink(locDimID, ExitDimID, par2, par3, par4, par2, yCoord, par4,par1World.getBlockMetadata(par2, par3-1, par4));
|
||||
dimHelper.instance.createLink(ExitDimID, locDimID, par2, yCoord, par4, par2, par3, par4,dimHelper.instance.flipDoorMetadata(par1World.getBlockMetadata(par2, par3-1, par4)));
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if(dimHelper.instance.getDimData(par1World.provider.dimensionId).isPocket)
|
||||
{
|
||||
//System.out.println("Created new dim from "+String.valueOf(par1World.provider.dimensionId));
|
||||
|
||||
LinkData link = new LinkData(par1World.provider.dimensionId, 0, par2, par3, par4, par2, par3, par4, true, par1World.getBlockMetadata(par2, par3-1, par4));
|
||||
dimHelper.instance.createPocket(link,false, false);
|
||||
|
||||
|
||||
|
||||
// dimHelper.instance.generatePocket(dimHelper.getWorld(destDimID), par2, par3, par4,par1World.getBlockMetadata(par2, par3-1, par4));
|
||||
|
||||
|
||||
}
|
||||
**/
|
||||
|
||||
dimension.createLink(x, y, z).setLinkType(IDimLink.TYPE_SAFE_EXIT);
|
||||
}
|
||||
else if (dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World)!=null)
|
||||
{
|
||||
|
||||
//System.out.println("RiftPresent at "+String.valueOf(par1World.provider.dimensionId));
|
||||
dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World).linkOrientation=par1World.getBlockMetadata(par2, par3-1, par4);
|
||||
dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World).hasGennedDoor=false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
par1World.setBlockTileEntity(par2, par3, par4, this.createNewTileEntity(par1World));
|
||||
|
||||
world.setBlockTileEntity(x, y, z, this.createNewTileEntity(world));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
/**
|
||||
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
|
||||
*/
|
||||
public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if(par1IBlockAccess.getBlockId(par2, par3-1, par4)==this.blockID)
|
||||
{
|
||||
return this.blockIcon;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.blockIconBottom;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
|
||||
*/
|
||||
public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if(par1IBlockAccess.getBlockId(par2, par3-1, par4)==this.blockID)
|
||||
{
|
||||
return this.blockIcon;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.blockIconBottom;
|
||||
}
|
||||
}
|
||||
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return Item.doorWood.itemID;
|
||||
}
|
||||
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return (par1 & 8) != 0 ? 0 : (Item.doorWood.itemID);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return Item.doorWood.itemID;
|
||||
}
|
||||
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return (par1 & 8) != 0 ? 0 : (Item.doorWood.itemID);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,13 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.world.PocketProvider;
|
||||
import net.minecraft.block.BlockTrapDoor;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.world.PocketProvider;
|
||||
|
||||
public class dimHatch extends BlockTrapDoor
|
||||
{
|
||||
@@ -21,59 +15,55 @@ public class dimHatch extends BlockTrapDoor
|
||||
public dimHatch(int par1,int par2, Material par2Material)
|
||||
{
|
||||
super(par1, Material.iron);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
// this.setTextureFile("/PocketBlockTextures.png");
|
||||
// this.blockIndexInTexture = 16;
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
// this.setTextureFile("/PocketBlockTextures.png");
|
||||
// this.blockIndexInTexture = 16;
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2());
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
|
||||
{
|
||||
int var10 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var10 ^ 4,2);
|
||||
par1World.playAuxSFXAtEntity(par5EntityPlayer, 1003, par2, par3, par4, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//Teleports the player to the exit link of that dimension, assuming it is a pocket
|
||||
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
{
|
||||
|
||||
int num = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if(!par1World.isRemote&&(num>3&&num<8||num>11)&&par1World.provider instanceof PocketProvider)
|
||||
{
|
||||
|
||||
this.onPoweredBlockChange(par1World, par2, par3, par4, false);
|
||||
|
||||
DimData dimData = (DimData) dimHelper.instance.dimList.get(par1World.provider.dimensionId);
|
||||
|
||||
NewLinkData exitLink=dimData.exitDimLink;
|
||||
exitLink.locDimID=par1World.provider.dimensionId;
|
||||
|
||||
|
||||
dimHelper.instance.traverseDimDoor(par1World, exitLink, par5Entity);
|
||||
|
||||
|
||||
int var10 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var10 ^ 4,2);
|
||||
par1World.playAuxSFXAtEntity(par5EntityPlayer, 1003, par2, par3, par4, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onPoweredBlockChange(World par1World, int par2, int par3, int par4, boolean par5)
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
boolean var7 = (var6 & 4) > 0;
|
||||
//Teleports the player to the exit link of that dimension, assuming it is a pocket
|
||||
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
{
|
||||
int num = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if (var7 != par5)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6 ^ 4,2);
|
||||
par1World.playAuxSFXAtEntity((EntityPlayer)null, 1003, par2, par3, par4, 0);
|
||||
}
|
||||
}
|
||||
if (!par1World.isRemote&&(num>3&&num<8||num>11)&&par1World.provider instanceof PocketProvider)
|
||||
{
|
||||
this.onPoweredBlockChange(par1World, par2, par3, par4, false);
|
||||
|
||||
/* FIXME: No point in fixing the following code when it's going to be rewritten later anyway. ~SenseiKiwi
|
||||
|
||||
NewDimData newDimData = (NewDimData) dimHelper.PocketManager.dimList.get(par1World.provider.dimensionId);
|
||||
ILinkData exitLink=newDimData.exitDimLink;
|
||||
exitLink.locDimID=par1World.provider.dimensionId;
|
||||
PocketManager.instance.traverseDimDoor(par1World, exitLink, par5Entity);*/
|
||||
}
|
||||
}
|
||||
|
||||
public void onPoweredBlockChange(World par1World, int par2, int par3, int par4, boolean par5)
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
boolean var7 = (var6 & 4) > 0;
|
||||
|
||||
if (var7 != par5)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6 ^ 4,2);
|
||||
par1World.playAuxSFXAtEntity((EntityPlayer)null, 1003, par2, par3, par4, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,13 @@
|
||||
package StevenDimDoors.mod_pocketDim.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import StevenDimDoors.mod_pocketDim.DungeonGenerator;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
|
||||
public class CommandCreateDungeonRift extends DDCommandBase
|
||||
{
|
||||
@@ -56,16 +55,17 @@ public class CommandCreateDungeonRift extends DDCommandBase
|
||||
}
|
||||
else
|
||||
{
|
||||
DungeonGenerator result;
|
||||
IDimLink link;
|
||||
DungeonData result;
|
||||
int x = MathHelper.floor_double(sender.posX);
|
||||
int y = MathHelper.floor_double(sender.posY);
|
||||
int z = MathHelper.floor_double (sender.posZ);
|
||||
NewLinkData link = new NewLinkData(sender.worldObj.provider.dimensionId, 0, x, y + 1, z, x, y + 1, z, true, 3);
|
||||
|
||||
if (command[0].equals("random"))
|
||||
{
|
||||
dimHelper.instance.createLink(link);
|
||||
link = dimHelper.instance.createPocket(link, true, true);
|
||||
link = new NewLinkData(sender.worldObj.provider.dimensionId, 0, x, y + 1, z, x, y + 1, z, true, 3);
|
||||
PocketManager.createLink(link);
|
||||
link = PocketManager.createPocket(link, true, true);
|
||||
sender.sendChatToPlayer("Created a rift to a random dungeon (Dimension ID = " + link.destDimID + ").");
|
||||
}
|
||||
else
|
||||
@@ -79,9 +79,10 @@ public class CommandCreateDungeonRift extends DDCommandBase
|
||||
if (result != null)
|
||||
{
|
||||
//Create a rift to our selected dungeon and notify the player
|
||||
link = dimHelper.instance.createPocket(link, true, true);
|
||||
dimHelper.instance.getDimData(link.destDimID).dungeonGenerator = result;
|
||||
sender.sendChatToPlayer("Created a rift to \"" + getSchematicName(result) + "\" dungeon (Dimension ID = " + link.destDimID + ").");
|
||||
link = new NewLinkData(sender.worldObj.provider.dimensionId, 0, x, y + 1, z, x, y + 1, z, true, 3);
|
||||
link = PocketManager.instance.createPocket(link, true, true);
|
||||
PocketManager.instance.getDimData(link.destDimID).dungeonGenerator = result;
|
||||
sender.sendChatToPlayer("Created a rift to \"" + result.schematicName() + "\" dungeon (Dimension ID = " + link.destination.getDimensionID() + ").");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -93,20 +94,20 @@ public class CommandCreateDungeonRift extends DDCommandBase
|
||||
return DDCommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
private DungeonGenerator findDungeonByPartialName(String query, Collection<DungeonGenerator> dungeons)
|
||||
private DungeonData findDungeonByPartialName(String query, Collection<DungeonData> dungeons)
|
||||
{
|
||||
//Search for the shortest dungeon name that contains the lowercase query string.
|
||||
String dungeonName;
|
||||
String normalQuery = query.toLowerCase();
|
||||
DungeonGenerator bestMatch = null;
|
||||
DungeonData bestMatch = null;
|
||||
int matchLength = Integer.MAX_VALUE;
|
||||
|
||||
for (DungeonGenerator dungeon : dungeons)
|
||||
for (DungeonData dungeon : dungeons)
|
||||
{
|
||||
//We need to extract the file's name. Comparing against schematicPath could
|
||||
//yield false matches if the query string is contained within the path.
|
||||
|
||||
dungeonName = getSchematicName(dungeon).toLowerCase();
|
||||
dungeonName = dungeon.schematicName().toLowerCase();
|
||||
if (dungeonName.length() < matchLength && dungeonName.contains(normalQuery))
|
||||
{
|
||||
matchLength = dungeonName.length();
|
||||
@@ -115,14 +116,4 @@ public class CommandCreateDungeonRift extends DDCommandBase
|
||||
}
|
||||
return bestMatch;
|
||||
}
|
||||
|
||||
private static String getSchematicName(DungeonGenerator dungeon)
|
||||
{
|
||||
//TODO: Move this to DungeonHelper and use it for all schematic name parsing.
|
||||
//In the future, we really should include the schematic's name as part of DungeonGenerator
|
||||
//to avoid redoing this work constantly.
|
||||
File schematic = new File(dungeon.schematicPath);
|
||||
String fileName = schematic.getName();
|
||||
return fileName.substring(0, fileName.length() - DungeonHelper.SCHEMATIC_FILE_EXTENSION.length());
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package StevenDimDoors.mod_pocketDim.commands;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||
|
||||
public class CommandCreatePocket extends DDCommandBase
|
||||
@@ -39,10 +38,10 @@ public class CommandCreatePocket extends DDCommandBase
|
||||
int x = (int) sender.posX;
|
||||
int y = (int) sender.posY;
|
||||
int z = (int) sender.posZ;
|
||||
NewLinkData link = DungeonHelper.instance().createCustomDungeonDoor(sender.worldObj, x, y, z);
|
||||
DungeonHelper.instance().createCustomDungeonDoor(sender.worldObj, x, y, z);
|
||||
|
||||
//Notify the player
|
||||
sender.sendChatToPlayer("Created a door to a pocket dimension (Dimension ID = " + link.destDimID + "). Please build your dungeon there.");
|
||||
sender.sendChatToPlayer("Created a door to a pocket dimension. Please build your dungeon there.");
|
||||
}
|
||||
return DDCommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.ILinkData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class CommandDeleteAllLinks extends DDCommandBase
|
||||
{
|
||||
@@ -39,7 +39,7 @@ public class CommandDeleteAllLinks extends DDCommandBase
|
||||
else if(command.length==1)
|
||||
{
|
||||
targetDim = parseInt(sender, command[0]);
|
||||
if(!dimHelper.dimList.containsKey(targetDim))
|
||||
if (!PocketManager.dimList.containsKey(targetDim))
|
||||
{
|
||||
sender.sendChatToPlayer("Error- dim "+targetDim+" not registered");
|
||||
shouldGo=false;
|
||||
@@ -54,24 +54,24 @@ public class CommandDeleteAllLinks extends DDCommandBase
|
||||
|
||||
if(shouldGo)
|
||||
{
|
||||
if(dimHelper.dimList.containsKey(targetDim))
|
||||
if(PocketManager.dimList.containsKey(targetDim))
|
||||
{
|
||||
DimData dim = dimHelper.instance.getDimData(targetDim);
|
||||
ArrayList<NewLinkData> linksInDim = dim.getLinksInDim();
|
||||
NewDimData dim = PocketManager.instance.getDimData(targetDim);
|
||||
ArrayList<ILinkData> linksInDim = dim.getLinksInDim();
|
||||
|
||||
for (NewLinkData link : linksInDim)
|
||||
for (ILinkData link : linksInDim)
|
||||
{
|
||||
World targetWorld = dimHelper.getWorld(targetDim);
|
||||
World targetWorld = PocketManager.getWorld(targetDim);
|
||||
|
||||
if(targetWorld==null)
|
||||
{
|
||||
dimHelper.initDimension(targetDim);
|
||||
PocketManager.initDimension(targetDim);
|
||||
}
|
||||
else if(targetWorld.provider==null)
|
||||
{
|
||||
dimHelper.initDimension(targetDim);
|
||||
PocketManager.initDimension(targetDim);
|
||||
}
|
||||
targetWorld = dimHelper.getWorld(targetDim);
|
||||
targetWorld = PocketManager.getWorld(targetDim);
|
||||
dim.removeLinkAtCoords(link);
|
||||
targetWorld.setBlock(link.locXCoord, link.locYCoord, link.locZCoord, 0);
|
||||
linksRemoved++;
|
||||
|
||||
@@ -4,9 +4,9 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.ILinkData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class CommandDeleteDimensionData extends DDCommandBase
|
||||
{
|
||||
@@ -39,7 +39,7 @@ public class CommandDeleteDimensionData extends DDCommandBase
|
||||
else if (command.length==1)
|
||||
{
|
||||
targetDim = parseInt(sender, command[0]);
|
||||
if(!dimHelper.dimList.containsKey(targetDim))
|
||||
if(!PocketManager.dimList.containsKey(targetDim))
|
||||
{
|
||||
sender.sendChatToPlayer("Error- dim "+targetDim+" not registered");
|
||||
shouldGo=false;
|
||||
@@ -54,23 +54,23 @@ public class CommandDeleteDimensionData extends DDCommandBase
|
||||
|
||||
if(shouldGo)
|
||||
{
|
||||
if(dimHelper.dimList.containsKey(targetDim))
|
||||
if(PocketManager.dimList.containsKey(targetDim))
|
||||
{
|
||||
try
|
||||
{
|
||||
for(DimData dimData :dimHelper.dimList.values())
|
||||
for(NewDimData newDimData :PocketManager.dimList.values())
|
||||
{
|
||||
Collection<NewLinkData> links= new ArrayList<NewLinkData>();
|
||||
links.addAll( dimData.getLinksInDim());
|
||||
Collection<ILinkData> links= new ArrayList<ILinkData>();
|
||||
links.addAll( newDimData.getLinksInDim());
|
||||
|
||||
for(NewLinkData link : links)
|
||||
for(ILinkData link : links)
|
||||
{
|
||||
if(link.destDimID==targetDim)
|
||||
{
|
||||
dimHelper.instance.getDimData(link.locDimID).removeLinkAtCoords(link);
|
||||
PocketManager.instance.getDimData(link.locDimID).removeLinkAtCoords(link);
|
||||
linksRemoved++;
|
||||
}
|
||||
if(dimData.dimID==targetDim)
|
||||
if(newDimData.dimID==targetDim)
|
||||
{
|
||||
linksRemoved++;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class CommandDeleteDimensionData extends DDCommandBase
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
dimHelper.dimList.remove(targetDim);
|
||||
PocketManager.dimList.remove(targetDim);
|
||||
sender.sendChatToPlayer("Removed dimension " + targetDim + " from DimDoors and deleted " + linksRemoved + " links");
|
||||
}
|
||||
else
|
||||
|
||||
@@ -4,10 +4,10 @@ import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.ILinkData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class CommandDeleteRifts extends DDCommandBase
|
||||
{
|
||||
@@ -40,7 +40,7 @@ public class CommandDeleteRifts extends DDCommandBase
|
||||
else if(command.length==1)
|
||||
{
|
||||
targetDim = parseInt(sender, command[0]);
|
||||
if(!dimHelper.dimList.containsKey(targetDim))
|
||||
if(!PocketManager.dimList.containsKey(targetDim))
|
||||
{
|
||||
sender.sendChatToPlayer("Error- dim "+targetDim+" not registered");
|
||||
shouldGo=false;
|
||||
@@ -55,24 +55,24 @@ public class CommandDeleteRifts extends DDCommandBase
|
||||
|
||||
if(shouldGo)
|
||||
{
|
||||
if(dimHelper.dimList.containsKey(targetDim))
|
||||
if(PocketManager.dimList.containsKey(targetDim))
|
||||
{
|
||||
DimData dim = dimHelper.instance.getDimData(targetDim);
|
||||
ArrayList<NewLinkData> linksInDim = dim.getLinksInDim();
|
||||
NewDimData dim = PocketManager.instance.getDimData(targetDim);
|
||||
ArrayList<ILinkData> linksInDim = dim.getLinksInDim();
|
||||
|
||||
for(NewLinkData link : linksInDim)
|
||||
for(ILinkData link : linksInDim)
|
||||
{
|
||||
World targetWorld = dimHelper.getWorld(targetDim);
|
||||
World targetWorld = PocketManager.getWorld(targetDim);
|
||||
|
||||
if(targetWorld==null)
|
||||
{
|
||||
dimHelper.initDimension(targetDim);
|
||||
PocketManager.initDimension(targetDim);
|
||||
}
|
||||
else if(targetWorld.provider==null)
|
||||
{
|
||||
dimHelper.initDimension(targetDim);
|
||||
PocketManager.initDimension(targetDim);
|
||||
}
|
||||
targetWorld = dimHelper.getWorld(targetDim);
|
||||
targetWorld = PocketManager.getWorld(targetDim);
|
||||
|
||||
if (targetWorld.getBlockId(link.locXCoord, link.locYCoord, link.locZCoord) == mod_pocketDim.blockRift.blockID)
|
||||
{
|
||||
|
||||
@@ -3,9 +3,9 @@ package StevenDimDoors.mod_pocketDim.commands;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.ILinkData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class CommandPrintDimensionData extends DDCommandBase
|
||||
{
|
||||
@@ -28,7 +28,7 @@ public class CommandPrintDimensionData extends DDCommandBase
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
int targetDim;
|
||||
DimData dimData;
|
||||
NewDimData newDimData;
|
||||
|
||||
if (command.length == 0)
|
||||
{
|
||||
@@ -50,17 +50,17 @@ public class CommandPrintDimensionData extends DDCommandBase
|
||||
return DDCommandResult.TOO_MANY_ARGUMENTS;
|
||||
}
|
||||
|
||||
dimData = dimHelper.instance.getDimData(targetDim);
|
||||
if (dimData == null)
|
||||
newDimData = PocketManager.instance.getDimData(targetDim);
|
||||
if (newDimData == null)
|
||||
{
|
||||
return DDCommandResult.UNREGISTERED_DIMENSION;
|
||||
}
|
||||
|
||||
ArrayList<NewLinkData> links = dimData.getLinksInDim();
|
||||
ArrayList<ILinkData> links = newDimData.getLinksInDim();
|
||||
|
||||
sender.sendChatToPlayer("Dimension ID = " + dimData.dimID);
|
||||
sender.sendChatToPlayer("Dimension Depth = " + dimData.depth);
|
||||
for (NewLinkData link : links)
|
||||
sender.sendChatToPlayer("Dimension ID = " + newDimData.dimID);
|
||||
sender.sendChatToPlayer("Dimension Depth = " + newDimData.depth);
|
||||
for (ILinkData link : links)
|
||||
{
|
||||
sender.sendChatToPlayer(link.printLinkData());
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.ILinkData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class CommandPruneDimensions extends DDCommandBase
|
||||
{
|
||||
@@ -42,31 +42,31 @@ public class CommandPruneDimensions extends DDCommandBase
|
||||
int removedCount = 0;
|
||||
boolean deleteFolders = (command.length == 1);
|
||||
Set<Integer> linkedDimensions = new HashSet<Integer>();
|
||||
Collection<DimData> allDims = new ArrayList<DimData>();
|
||||
allDims.addAll(dimHelper.dimList.values());
|
||||
Collection<NewDimData> allDims = new ArrayList<NewDimData>();
|
||||
allDims.addAll(PocketManager.dimList.values());
|
||||
|
||||
for (DimData data : allDims)
|
||||
for (NewDimData data : allDims)
|
||||
{
|
||||
for (NewLinkData link : data.getLinksInDim())
|
||||
for (ILinkData link : data.getLinksInDim())
|
||||
{
|
||||
linkedDimensions.add(link.destDimID);
|
||||
}
|
||||
}
|
||||
for (NewLinkData link : dimHelper.instance.interDimLinkList.values())
|
||||
for (ILinkData link : dimHelper.PocketManager.interDimLinkList.values())
|
||||
{
|
||||
linkedDimensions.add(link.destDimID);
|
||||
}
|
||||
for (DimData data : allDims)
|
||||
for (NewDimData data : allDims)
|
||||
{
|
||||
if (!linkedDimensions.contains(data.dimID))
|
||||
{
|
||||
if (dimHelper.instance.pruneDimension(data, deleteFolders))
|
||||
if (PocketManager.instance.pruneDimension(data, deleteFolders))
|
||||
{
|
||||
removedCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
dimHelper.instance.save();
|
||||
PocketManager.instance.save();
|
||||
sender.sendChatToPlayer("Removed " + removedCount + " unreachable pocket dims.");
|
||||
return DDCommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package StevenDimDoors.mod_pocketDim.commands;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class CommandResetDungeons extends DDCommandBase
|
||||
{
|
||||
@@ -32,12 +32,12 @@ public class CommandResetDungeons extends DDCommandBase
|
||||
int dungeonCount = 0;
|
||||
int resetCount = 0;
|
||||
|
||||
for (DimData data : dimHelper.dimList.values())
|
||||
for (NewDimData data : PocketManager.dimList.values())
|
||||
{
|
||||
if (data.isDimRandomRift)
|
||||
{
|
||||
dungeonCount++;
|
||||
if (dimHelper.instance.resetPocket(data))
|
||||
if (PocketManager.instance.resetPocket(data))
|
||||
{
|
||||
resetCount++;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.List;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.BlankTeleporter;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -39,7 +39,7 @@ public class CommandTeleportPlayer extends DDCommandBase
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
List dimensionIDs = Arrays.asList(dimHelper.getStaticDimensionIDs()); //Gets list of all registered dimensions, regardless if loaded or not
|
||||
List dimensionIDs = Arrays.asList(PocketManager.getStaticDimensionIDs()); //Gets list of all registered dimensions, regardless if loaded or not
|
||||
EntityPlayer targetPlayer = sender;
|
||||
int dimDestinationID = sender.worldObj.provider.dimensionId;
|
||||
|
||||
@@ -66,12 +66,12 @@ public class CommandTeleportPlayer extends DDCommandBase
|
||||
{
|
||||
return DDCommandResult.INVALID_DIMENSION_ID;
|
||||
}
|
||||
if(dimHelper.getWorld(dimDestinationID)==null)
|
||||
if(PocketManager.getWorld(dimDestinationID)==null)
|
||||
{
|
||||
dimHelper.initDimension(dimDestinationID);
|
||||
PocketManager.initDimension(dimDestinationID);
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().transferPlayerToDimension((EntityPlayerMP) targetPlayer, dimDestinationID, new BlankTeleporter(dimHelper.getWorld(dimDestinationID)));
|
||||
FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().transferPlayerToDimension((EntityPlayerMP) targetPlayer, dimDestinationID, new BlankTeleporter(PocketManager.getWorld(dimDestinationID)));
|
||||
targetPlayer.setPositionAndUpdate(Integer.parseInt(command[2]),Integer.parseInt(command[3]),Integer.parseInt(command[4]));
|
||||
}
|
||||
else
|
||||
|
||||
31
StevenDimDoors/mod_pocketDim/core/IDimLink.java
Normal file
31
StevenDimDoors/mod_pocketDim/core/IDimLink.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package StevenDimDoors.mod_pocketDim.core;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public interface IDimLink extends Serializable
|
||||
{
|
||||
public final int TYPE_ENUM_MIN = 0;
|
||||
public final int TYPE_ENUM_MAX = 8;
|
||||
|
||||
public final int TYPE_NORMAL = 0;
|
||||
public final int TYPE_LIMBO = 1;
|
||||
public final int TYPE_POCKET = 2;
|
||||
public final int TYPE_DUNGEON = 3;
|
||||
public final int TYPE_RANDOM = 4;
|
||||
public final int TYPE_DUNGEON_EXIT = 5;
|
||||
public final int TYPE_SAFE_EXIT = 6;
|
||||
public final int TYPE_UNSAFE_EXIT = 7;
|
||||
public final int TYPE_RANDOM_DUNGEON = 8;
|
||||
|
||||
public Point4D source();
|
||||
public Point4D destination();
|
||||
public boolean hasDestination();
|
||||
public Iterable<IDimLink> children();
|
||||
public int childCount();
|
||||
public IDimLink parent();
|
||||
public int linkType();
|
||||
public IDimLink setDestination(int x, int y, int z, NewDimData dimension);
|
||||
public IDimLink setLinkType(int linkType);
|
||||
}
|
||||
31
StevenDimDoors/mod_pocketDim/core/LinkTail.java
Normal file
31
StevenDimDoors/mod_pocketDim/core/LinkTail.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package StevenDimDoors.mod_pocketDim.core;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
class LinkTail
|
||||
{
|
||||
private Point4D destination;
|
||||
private int linkType;
|
||||
|
||||
public LinkTail(int linkType, Point4D destination)
|
||||
{
|
||||
this.linkType = linkType;
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
public Point4D getDestination() {
|
||||
return destination;
|
||||
}
|
||||
|
||||
public void setDestination(Point4D destination) {
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
public int getLinkType() {
|
||||
return linkType;
|
||||
}
|
||||
|
||||
public void setLinkType(int linkType) {
|
||||
this.linkType = linkType;
|
||||
}
|
||||
}
|
||||
496
StevenDimDoors/mod_pocketDim/core/NewDimData.java
Normal file
496
StevenDimDoors/mod_pocketDim/core/NewDimData.java
Normal file
@@ -0,0 +1,496 @@
|
||||
package StevenDimDoors.mod_pocketDim.core;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public abstract class NewDimData implements Serializable
|
||||
{
|
||||
private static class DimLink implements IDimLink
|
||||
{
|
||||
//DimLink is an inner class here to make it immutable to code outside NewDimData
|
||||
|
||||
private static final long serialVersionUID = 1462177151401498444L;
|
||||
private static final int EXPECTED_CHILDREN = 2;
|
||||
|
||||
private Point4D source;
|
||||
private DimLink parent;
|
||||
private LinkTail tail;
|
||||
private ArrayList<IDimLink> children;
|
||||
|
||||
public DimLink(Point4D source, DimLink parent)
|
||||
{
|
||||
this.parent = parent;
|
||||
this.source = source;
|
||||
this.tail = parent.tail;
|
||||
this.children = new ArrayList<IDimLink>(EXPECTED_CHILDREN);
|
||||
parent.children.add(this);
|
||||
}
|
||||
|
||||
public DimLink(Point4D source)
|
||||
{
|
||||
this.parent = null;
|
||||
this.source = source;
|
||||
this.tail = new LinkTail(0, null);
|
||||
this.children = new ArrayList<IDimLink>(EXPECTED_CHILDREN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point4D source()
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point4D destination()
|
||||
{
|
||||
return tail.getDestination();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDestination()
|
||||
{
|
||||
return (tail.getDestination() != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDimLink setDestination(int x, int y, int z, NewDimData dimension)
|
||||
{
|
||||
if (dimension == null)
|
||||
{
|
||||
throw new IllegalArgumentException("dimension cannot be null.");
|
||||
}
|
||||
|
||||
tail.setDestination(new Point4D(x, y, z, dimension.id()));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDimLink setLinkType(int linkType)
|
||||
{
|
||||
if (linkType < IDimLink.TYPE_ENUM_MIN || linkType > IDimLink.TYPE_ENUM_MAX)
|
||||
{
|
||||
throw new IllegalArgumentException("The specified link type is invalid.");
|
||||
}
|
||||
|
||||
tail.setLinkType(linkType);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IDimLink> children()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int childCount()
|
||||
{
|
||||
return children.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDimLink parent()
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int linkType()
|
||||
{
|
||||
return tail.getLinkType();
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
//Release children
|
||||
for (IDimLink child : children)
|
||||
{
|
||||
((DimLink) child).parent = null;
|
||||
}
|
||||
children.clear();
|
||||
|
||||
//Release parent
|
||||
if (parent != null)
|
||||
{
|
||||
parent.children.remove(this);
|
||||
}
|
||||
|
||||
parent = null;
|
||||
source = null;
|
||||
tail = new LinkTail(0, null);
|
||||
}
|
||||
|
||||
public void overwrite(DimLink nextParent)
|
||||
{
|
||||
if (this == nextParent)
|
||||
{
|
||||
//Ignore this request silently
|
||||
return;
|
||||
}
|
||||
|
||||
//Release children
|
||||
for (IDimLink child : children)
|
||||
{
|
||||
((DimLink) child).parent = null;
|
||||
}
|
||||
children.clear();
|
||||
|
||||
//Release parent
|
||||
if (parent != null)
|
||||
{
|
||||
parent.children.remove(this);
|
||||
}
|
||||
|
||||
//Attach to new parent
|
||||
parent = nextParent;
|
||||
if (parent != null)
|
||||
{
|
||||
tail = parent.tail;
|
||||
parent.children.add(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
tail = new LinkTail(0, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return source + " -> " + (hasDestination() ? destination() : "");
|
||||
}
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 89361974746997260L;
|
||||
private static Random random = new Random();
|
||||
|
||||
private final int id;
|
||||
private final Map<Point4D, DimLink> linkMapping;
|
||||
private final List<DimLink> linkList;
|
||||
private final boolean isDungeon;
|
||||
private boolean isFilled;
|
||||
private final int depth;
|
||||
private int packDepth;
|
||||
private final NewDimData parent;
|
||||
private final NewDimData root;
|
||||
private final List<NewDimData> children;
|
||||
private Point4D origin;
|
||||
private int orientation;
|
||||
private DungeonData dungeon;
|
||||
|
||||
protected NewDimData(int id, NewDimData parent, boolean isPocket, boolean isDungeon)
|
||||
{
|
||||
//The isPocket flag is redundant. It's meant as an integrity safeguard.
|
||||
if (isPocket == (parent != null))
|
||||
{
|
||||
throw new NullPointerException("Dimensions can be pocket dimensions if and only if they have a parent dimension.");
|
||||
}
|
||||
if (isDungeon && !isPocket)
|
||||
{
|
||||
throw new IllegalArgumentException("A dimensional dungeon must also be a pocket dimension.");
|
||||
}
|
||||
|
||||
this.id = id;
|
||||
this.linkMapping = new TreeMap<Point4D, DimLink>(); //Should be stored in oct tree -- temporary solution
|
||||
this.linkList = new ArrayList<DimLink>(); //Should be stored in oct tree -- temporary solution
|
||||
this.children = new ArrayList<NewDimData>();
|
||||
this.parent = parent;
|
||||
this.root = (parent != null ? parent.root : this);
|
||||
this.depth = (parent != null ? parent.depth + 1 : 0);
|
||||
this.packDepth = 0;
|
||||
this.isDungeon = isDungeon;
|
||||
this.isFilled = false;
|
||||
this.orientation = 0;
|
||||
this.origin = null;
|
||||
this.dungeon = null;
|
||||
|
||||
//Register with parent
|
||||
addChildDimension(this);
|
||||
}
|
||||
|
||||
private void addChildDimension(NewDimData child)
|
||||
{
|
||||
children.add(child);
|
||||
}
|
||||
|
||||
public IDimLink findNearestRift(World world, int range, int x, int y, int z)
|
||||
{
|
||||
//TODO: Rewrite this later to use an octtree, remove World parameter
|
||||
|
||||
//Sanity check...
|
||||
if (world.provider.dimensionId != id)
|
||||
{
|
||||
throw new IllegalArgumentException("Attempted to search for links in a World instance for a different dimension!");
|
||||
}
|
||||
|
||||
//Note: Only detect rifts at a distance > 1, so we ignore the rift
|
||||
//that called this function and any adjacent rifts.
|
||||
|
||||
IDimLink nearest = null;
|
||||
IDimLink link;
|
||||
|
||||
int distance;
|
||||
int minDistance = Integer.MAX_VALUE;
|
||||
int i, j, k;
|
||||
DDProperties properties = DDProperties.instance();
|
||||
|
||||
for (i = -range; i <= range; i++)
|
||||
{
|
||||
for (j = -range; j <= range; j++)
|
||||
{
|
||||
for (k = -range; k <= range; k++)
|
||||
{
|
||||
distance = getAbsoluteSum(i, j, k);
|
||||
if (distance > 1 && distance < minDistance && world.getBlockId(x + i, y + j, z + k) == properties.RiftBlockID)
|
||||
{
|
||||
link = getLink(x+i, y+j, z+k);
|
||||
if (link != null)
|
||||
{
|
||||
nearest = link;
|
||||
minDistance = distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nearest;
|
||||
}
|
||||
|
||||
private static int getAbsoluteSum(int i, int j, int k)
|
||||
{
|
||||
return Math.abs(i) + Math.abs(j) + Math.abs(k);
|
||||
}
|
||||
|
||||
public IDimLink createLink(int x, int y, int z)
|
||||
{
|
||||
return createLink(new Point4D(x, y, z, id));
|
||||
}
|
||||
|
||||
private IDimLink createLink(Point4D source)
|
||||
{
|
||||
//Return an existing link if there is one to avoid creating multiple links starting at the same point.
|
||||
DimLink link = linkMapping.get(source);
|
||||
if (link == null)
|
||||
{
|
||||
link = new DimLink(source);
|
||||
linkMapping.put(source, link);
|
||||
linkList.add(link);
|
||||
}
|
||||
else
|
||||
{
|
||||
link.overwrite(null);
|
||||
}
|
||||
return link;
|
||||
}
|
||||
|
||||
public IDimLink createChildLink(int x, int y, int z, IDimLink parent)
|
||||
{
|
||||
if (parent == null)
|
||||
{
|
||||
throw new IllegalArgumentException("parent cannot be null.");
|
||||
}
|
||||
|
||||
return createChildLink(new Point4D(x, y, z, id), (DimLink) parent);
|
||||
}
|
||||
|
||||
private IDimLink createChildLink(Point4D source, DimLink parent)
|
||||
{
|
||||
//To avoid having multiple links at a single point, if we find an existing link then we overwrite
|
||||
//its destination data instead of creating a new instance.
|
||||
|
||||
DimLink link = linkMapping.get(source);
|
||||
if (link == null)
|
||||
{
|
||||
link = new DimLink(source, parent);
|
||||
linkMapping.put(source, link);
|
||||
linkList.add(link);
|
||||
}
|
||||
else
|
||||
{
|
||||
link.overwrite(parent);
|
||||
}
|
||||
|
||||
return link;
|
||||
}
|
||||
|
||||
public boolean deleteLink(IDimLink link)
|
||||
{
|
||||
if (link.source().getDimension() != id)
|
||||
{
|
||||
throw new IllegalArgumentException("Attempted to delete a link from another dimension.");
|
||||
}
|
||||
DimLink target = linkMapping.remove(link.source());
|
||||
if (target != null)
|
||||
{
|
||||
linkList.remove(target);
|
||||
target.clear();
|
||||
}
|
||||
return (target != null);
|
||||
}
|
||||
|
||||
public boolean deleteLink(int x, int y, int z)
|
||||
{
|
||||
Point4D location = new Point4D(x, y, z, id);
|
||||
DimLink target = linkMapping.remove(location);
|
||||
if (target != null)
|
||||
{
|
||||
linkList.remove(target);
|
||||
target.clear();
|
||||
}
|
||||
return (target != null);
|
||||
}
|
||||
|
||||
public IDimLink getLink(int x, int y, int z)
|
||||
{
|
||||
Point4D location = new Point4D(x, y, z, id);
|
||||
return linkMapping.get(location);
|
||||
}
|
||||
|
||||
public IDimLink getLink(Point4D location)
|
||||
{
|
||||
if (location.getDimension() != id)
|
||||
return null;
|
||||
|
||||
return linkMapping.get(location);
|
||||
}
|
||||
|
||||
public ArrayList<IDimLink> getAllLinks()
|
||||
{
|
||||
ArrayList<IDimLink> results = new ArrayList<IDimLink>(linkMapping.size());
|
||||
results.addAll(linkMapping.values());
|
||||
return results;
|
||||
}
|
||||
|
||||
public boolean isPocketDimension()
|
||||
{
|
||||
return (parent != null);
|
||||
}
|
||||
|
||||
public boolean isDungeon()
|
||||
{
|
||||
return isDungeon;
|
||||
}
|
||||
|
||||
public boolean isFilled()
|
||||
{
|
||||
return isFilled;
|
||||
}
|
||||
|
||||
public void setFilled(boolean isFilled)
|
||||
{
|
||||
this.isFilled = isFilled;
|
||||
}
|
||||
|
||||
public int id()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public int depth()
|
||||
{
|
||||
return depth;
|
||||
}
|
||||
|
||||
public int packDepth()
|
||||
{
|
||||
return packDepth;
|
||||
}
|
||||
|
||||
public Point4D origin()
|
||||
{
|
||||
return origin;
|
||||
}
|
||||
|
||||
public NewDimData parent()
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
public NewDimData root()
|
||||
{
|
||||
return root;
|
||||
}
|
||||
|
||||
public int orientation()
|
||||
{
|
||||
return orientation;
|
||||
}
|
||||
|
||||
public DungeonData dungeon()
|
||||
{
|
||||
return dungeon;
|
||||
}
|
||||
|
||||
public boolean isInitialized()
|
||||
{
|
||||
return (origin != null);
|
||||
}
|
||||
|
||||
public int linkCount()
|
||||
{
|
||||
return linkMapping.size();
|
||||
}
|
||||
|
||||
public Iterable<NewDimData> children()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
|
||||
public void initializeDungeon(int originX, int originY, int originZ, int orientation, IDimLink link, DungeonData dungeon)
|
||||
{
|
||||
if (!isDungeon)
|
||||
{
|
||||
throw new IllegalStateException("Cannot invoke initializeDungeon() on a non-dungeon dimension.");
|
||||
}
|
||||
if (isInitialized())
|
||||
{
|
||||
throw new IllegalStateException("The dimension has already been initialized.");
|
||||
}
|
||||
|
||||
link.setDestination(originX, originY, originZ, this);
|
||||
this.origin = link.destination();
|
||||
this.orientation = orientation;
|
||||
this.dungeon = dungeon;
|
||||
}
|
||||
|
||||
public void initializePocket(int originX, int originY, int originZ, int orientation, IDimLink link)
|
||||
{
|
||||
if (!isPocketDimension())
|
||||
{
|
||||
throw new IllegalStateException("Cannot invoke initializePocket() on a non-pocket dimension.");
|
||||
}
|
||||
if (isInitialized())
|
||||
{
|
||||
throw new IllegalStateException("The dimension has already been initialized.");
|
||||
}
|
||||
|
||||
link.setDestination(originX, originY, originZ, this);
|
||||
this.origin = link.destination();
|
||||
this.orientation = orientation;
|
||||
}
|
||||
|
||||
public IDimLink getRandomLink()
|
||||
{
|
||||
if (linkMapping.isEmpty())
|
||||
{
|
||||
throw new IllegalStateException("There are no links to select from in this dimension.");
|
||||
}
|
||||
if (linkList.size() > 1)
|
||||
{
|
||||
return linkList.get(random.nextInt(linkList.size()));
|
||||
}
|
||||
else
|
||||
{
|
||||
return linkList.get(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.core;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public class NewLinkData implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1462177151401498444L;
|
||||
|
||||
private Point4D source;
|
||||
private Point4D destination;
|
||||
|
||||
public NewLinkData(int srcX, int srcY, int srcZ, int srcDimension)
|
||||
{
|
||||
source = new Point4D(srcX, srcY, srcZ, srcDimension);
|
||||
destination = null;
|
||||
}
|
||||
|
||||
public NewLinkData(int srcX, int srcY, int srcZ, int srcDimension, int dstX, int dstY, int dstZ, int dstDimension)
|
||||
{
|
||||
source = new Point4D(srcX, srcY, srcZ, srcDimension);
|
||||
destination = new Point4D(dstX, dstY, dstZ, dstDimension);
|
||||
}
|
||||
|
||||
public NewLinkData(Point4D source, Point 4D destination)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return source + " -> " + destination;
|
||||
}
|
||||
}
|
||||
623
StevenDimDoors/mod_pocketDim/core/PocketManager.java
Normal file
623
StevenDimDoors/mod_pocketDim/core/PocketManager.java
Normal file
@@ -0,0 +1,623 @@
|
||||
package StevenDimDoors.mod_pocketDim.core;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet41EntityEffect;
|
||||
import net.minecraft.network.packet.Packet43Experience;
|
||||
import net.minecraft.network.packet.Packet9Respawn;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.DDTeleporter;
|
||||
import StevenDimDoors.mod_pocketDim.ObjectSaveInputStream;
|
||||
import StevenDimDoors.mod_pocketDim.PacketHandler;
|
||||
import StevenDimDoors.mod_pocketDim.TileEntityRift;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.DeleteFolder;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
/**
|
||||
* This class regulates all the operations involving the storage and manipulation of dimensions. It handles saving dim data, teleporting the player, and
|
||||
* creating/registering new dimensions as well as loading old dimensions on startup
|
||||
*/
|
||||
public class PocketManager
|
||||
{
|
||||
private static class InnerDimData extends NewDimData
|
||||
{
|
||||
//This inner class allows us to instantiate NewDimData indirectly without exposing
|
||||
//a public constructor from NewDimData. It's meant to stop us from constructing instances
|
||||
//of NewDimData without using PocketManager's functions. In turn, that enforces that any
|
||||
//link destinations must be real dimensions controlled by PocketManager.
|
||||
|
||||
private static final long serialVersionUID = -3497038894870586232L;
|
||||
|
||||
public InnerDimData(int id, NewDimData parent, boolean isPocket, boolean isDungeon)
|
||||
{
|
||||
super(id, parent, isPocket, isDungeon);
|
||||
}
|
||||
}
|
||||
|
||||
private static int OVERWORLD_DIMENSION_ID = 0;
|
||||
|
||||
private static boolean isInitialized = false;
|
||||
private static boolean isSaving = false;
|
||||
private static Random random = new Random();
|
||||
|
||||
//HashMap containing all the dims registered with DimDoors, sorted by dim ID. loaded on startup
|
||||
private static HashMap<Integer, NewDimData> dimensionData = new HashMap<Integer, NewDimData>();
|
||||
|
||||
//HashMap for temporary storage of Link Signature damage hash values. See itemLinkSignature for more details
|
||||
private static HashMap<Integer, IDimLink> keyLinkMapping = new HashMap<Integer, IDimLink>();
|
||||
|
||||
public static boolean isInitialized()
|
||||
{
|
||||
return isInitialized;
|
||||
}
|
||||
|
||||
public ILinkData createLink(ILinkData link)
|
||||
{
|
||||
DDProperties properties = DDProperties.instance();
|
||||
|
||||
if(!PocketManager.dimList.containsKey(link.locDimID))
|
||||
{
|
||||
NewDimData locationDimData= new NewDimData(link.locDimID, false, 0, link.locDimID,link.locXCoord,link.locYCoord,link.locZCoord);
|
||||
PocketManager.dimList.put(link.locDimID, locationDimData);
|
||||
link.isLocPocket=false;
|
||||
}
|
||||
if(!dimList.containsKey(link.destDimID))
|
||||
{
|
||||
PocketManager.dimList.put(link.destDimID, new NewDimData(link.destDimID, false, 0, link.locDimID,link.locXCoord,link.locYCoord,link.locZCoord));
|
||||
}
|
||||
NewDimData locationDimData= PocketManager.instance.getDimData(link.locDimID);
|
||||
link.isLocPocket=locationDimData.isPocket;
|
||||
locationDimData.addLinkToDim(link);
|
||||
|
||||
World world = PocketManager.getWorld(link.locDimID);
|
||||
if (world != null)
|
||||
{
|
||||
if (!mod_pocketDim.blockRift.isBlockImmune(world, link.locXCoord, link.locYCoord, link.locZCoord))
|
||||
{
|
||||
world.setBlock(link.locXCoord, link.locYCoord, link.locZCoord, properties.RiftBlockID);
|
||||
}
|
||||
}
|
||||
//Notifies other players that a link has been created.
|
||||
//TODO: Couldn't we use the serverside/clientside annotations to achieve this instead? Seems safer. ~SenseiKiwi
|
||||
if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER)
|
||||
{
|
||||
PacketHandler.onLinkCreatedPacket(link);
|
||||
}
|
||||
return link;
|
||||
}
|
||||
|
||||
/**
|
||||
* properly deletes a link at the given coordinates. used by the rift remover. Also notifies clients of change.
|
||||
* @param locationDimID
|
||||
* @param locationXCoord
|
||||
* @param locationYCoord
|
||||
* @param locationZCoord
|
||||
*/
|
||||
public void removeLink( int locationDimID, int locationXCoord, int locationYCoord, int locationZCoord)
|
||||
{
|
||||
if(!PocketManager.dimList.containsKey(locationDimID))
|
||||
{
|
||||
NewDimData locationDimData= new NewDimData(locationDimID, false, 0, locationDimID,locationXCoord,locationYCoord,locationZCoord);
|
||||
PocketManager.dimList.put(locationDimID, locationDimData);
|
||||
}
|
||||
ILinkData link = this.getLinkDataFromCoords(locationXCoord, locationYCoord, locationZCoord, locationDimID);
|
||||
PocketManager.instance.getDimData(locationDimID).removeLinkAtCoords(link);
|
||||
//updates clients that a rift has been removed
|
||||
if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER)
|
||||
{
|
||||
PacketHandler.onLinkRemovedPacket(link);
|
||||
this.save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* generates a door based on what door was used to teleport. Only functions once per linking.
|
||||
* @param world- door
|
||||
* @param incLink
|
||||
*/
|
||||
public void generateDoor(World world, ILinkData incLink)
|
||||
{
|
||||
int locX = incLink.locXCoord;
|
||||
int locY = incLink.locYCoord;
|
||||
int locZ = incLink.locZCoord;
|
||||
|
||||
int destX = incLink.destXCoord;
|
||||
int destY = incLink.destYCoord;
|
||||
int destZ = incLink.destZCoord;
|
||||
|
||||
DDProperties properties = DDProperties.instance();
|
||||
|
||||
if(!incLink.hasGennedDoor)
|
||||
{
|
||||
int destinationID = incLink.destDimID;
|
||||
|
||||
int id =world.getBlockId(locX, locY, locZ);
|
||||
if(id==properties.WarpDoorID||id==properties.DimensionalDoorID||id==properties.TransientDoorID)
|
||||
{
|
||||
int doorTypeToPlace=id;
|
||||
if(DimensionManager.getWorld(destinationID)==null)
|
||||
{
|
||||
DimensionManager.initDimension(destinationID);
|
||||
}
|
||||
ILinkData destLink = this.getLinkDataFromCoords(destX, destY, destZ, destinationID);
|
||||
int destOrientation = 0;
|
||||
if(destLink!=null)
|
||||
{
|
||||
destOrientation = destLink.linkOrientation;
|
||||
destLink.hasGennedDoor=true;
|
||||
}
|
||||
int blockToReplace= DimensionManager.getWorld(destinationID).getBlockId(destX, destY, destZ);
|
||||
if(blockToReplace!=properties.DimensionalDoorID&&blockToReplace!=properties.WarpDoorID&&blockToReplace != properties.TransientDoorID)
|
||||
{
|
||||
DimensionManager.getWorld(destinationID).setBlock(destX, destY-1, destZ, doorTypeToPlace,destOrientation,2);
|
||||
DimensionManager.getWorld(destinationID).setBlock(destX, destY, destZ, doorTypeToPlace,8,2);
|
||||
}
|
||||
incLink.hasGennedDoor=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* simple method called on startup to register all dims saved in the dim list. Only tries to register pocket dims, though. Also calls load()
|
||||
* @return
|
||||
*/
|
||||
public static void initPockets()
|
||||
{
|
||||
if (isInitialized)
|
||||
{
|
||||
throw new IllegalStateException("Pocket dimensions have already been initialized!");
|
||||
}
|
||||
|
||||
DDProperties properties = DDProperties.instance();
|
||||
|
||||
isInitialized = true;
|
||||
load();
|
||||
for (NewDimData dimension : dimensionData.values())
|
||||
{
|
||||
if (dimension.isPocketDimension())
|
||||
{
|
||||
try
|
||||
{
|
||||
DimensionManager.registerDimension(dimension.id(), properties.PocketProviderID);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("Could not register pocket dimension #" + dimension.id() + ". Probably caused by a version update/save data corruption/other mods.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean resetPocket(NewDimData dimension)
|
||||
{
|
||||
if (!dimension.isPocketDimension() || DimensionManager.getWorld(dimension.id()) != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
File save = new File(DimensionManager.getCurrentSaveRootDirectory() + "/DimensionalDoors/pocketDimID" + dimension.id());
|
||||
DeleteFolder.deleteFolder(save);
|
||||
dimension.setFilled(false);
|
||||
//FIXME: Reset door information?
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean pruneDimension(NewDimData dimension, boolean deleteFolder)
|
||||
{
|
||||
//FIXME: Shouldn't the links in and out of this dimension be altered somehow? Otherwise we have links pointing
|
||||
//into a deleted dimension!
|
||||
|
||||
//Checks to see if the pocket is loaded or isn't actually a pocket.
|
||||
if (dimension.isPocketDimension() && DimensionManager.getWorld(dimension.id()) == null)
|
||||
{
|
||||
dimensionData.remove(dimension.id());
|
||||
//FIXME: I added the following line. Seems like a good idea. Is it?
|
||||
DimensionManager.unregisterDimension(dimension.id());
|
||||
if (deleteFolder)
|
||||
{
|
||||
File save = new File(DimensionManager.getCurrentSaveRootDirectory() + "/DimensionalDoors/pocketDimID" + dimension.id());
|
||||
DeleteFolder.deleteFolder(save);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void unregisterDimensions()
|
||||
{
|
||||
for (NewDimData dimension : dimensionData.values())
|
||||
{
|
||||
if (dimension.isPocketDimension())
|
||||
{
|
||||
try
|
||||
{
|
||||
DimensionManager.unregisterDimension(dimension.id());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("An unexpected error occurred while unregistering pocket dimension #" + dimension.id() + ":");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to associate a damage value on a Rift Signature with a link pair. See LinkSignature for details.
|
||||
* @return
|
||||
*/
|
||||
public static int createUniqueLinkKey()
|
||||
{
|
||||
int linkKey;
|
||||
do
|
||||
{
|
||||
linkKey = random.nextInt(30000);
|
||||
}
|
||||
while (keyLinkMapping.containsKey(linkKey));
|
||||
return linkKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to create and register a new pocket dimension. Creates a reverse link if necessary.
|
||||
* Populates the destination as well.
|
||||
*/
|
||||
private NewDimData createDestinationPocket(IDimLink link)
|
||||
{
|
||||
//First check the destination type
|
||||
if (link.linkType() != IDimLink.TYPE_DUNGEON && link.linkType() != IDimLink.TYPE_POCKET)
|
||||
{
|
||||
throw new IllegalArgumentException("The link must lead to a dimensional dungeon or a pocket dimension.");
|
||||
}
|
||||
|
||||
DDProperties properties = DDProperties.instance();
|
||||
|
||||
//FIXME: This code had a check for whether dimension 0 was null. Why? Removed it for the time being. ~SenseiKiwi
|
||||
|
||||
|
||||
if (PocketManager.getWorld(link.locDimID) == null)
|
||||
{
|
||||
PocketManager.initDimension(link.locDimID);
|
||||
}
|
||||
|
||||
int dimensionID;
|
||||
int depth = this.getDimDepth(link.locDimID);
|
||||
dimensionID = getNextFreeDimId();
|
||||
registerDimension(dimensionID, properties.PocketProviderID);
|
||||
NewDimData locationDimData;
|
||||
NewDimData destDimData;
|
||||
|
||||
|
||||
|
||||
if(PocketManager.dimList.containsKey(link.locDimID)&&!DimensionManager.getWorld(link.locDimID).isRemote) //checks to see if dim is already registered. If not, it creates a DimData entry for it later
|
||||
{
|
||||
//randomizes exit if deep enough
|
||||
locationDimData= dimList.get(DimensionManager.getWorld(link.locDimID).provider.dimensionId);
|
||||
|
||||
if(depth>5)
|
||||
{
|
||||
if(depth>=12)
|
||||
{
|
||||
depth=11;
|
||||
}
|
||||
if(rand.nextInt(13-depth)==0)
|
||||
{
|
||||
ILinkData link1=getRandomLinkData(false);
|
||||
}
|
||||
}
|
||||
if(locationDimData.isPocket) //determines the qualites of the pocket dim being created, based on parent dim.
|
||||
{
|
||||
if(isGoingDown)
|
||||
{
|
||||
destDimData= new NewDimData(dimensionID, true, locationDimData.depth+1, locationDimData.exitDimLink);
|
||||
}
|
||||
else
|
||||
{
|
||||
destDimData= new NewDimData(dimensionID, true, locationDimData.depth-1, locationDimData.exitDimLink);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
destDimData= new NewDimData(dimensionID, true, 1, link.locDimID,link.locXCoord,link.locYCoord,link.locZCoord);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
locationDimData= new NewDimData(link.locDimID, false, 0, link.locDimID,link.locXCoord,link.locYCoord,link.locZCoord);
|
||||
destDimData= new NewDimData(dimensionID, true, 1, link.locDimID,link.locXCoord,link.locYCoord,link.locZCoord);
|
||||
}
|
||||
destDimData.isDimRandomRift=isRandomRift;
|
||||
PocketManager.dimList.put(DimensionManager.getWorld(link.locDimID).provider.dimensionId, locationDimData);
|
||||
PocketManager.dimList.put(dimensionID, destDimData);
|
||||
|
||||
if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER)//sends packet to clients notifying them that a new dim has been created.
|
||||
{
|
||||
PacketHandler.onDimCreatedPacket(destDimData);
|
||||
}
|
||||
link = this.createLink(DimensionManager.getWorld(link.locDimID).provider.dimensionId,dimensionID,link.locXCoord,link.locYCoord,link.locZCoord, link.destXCoord,constrainPocketY(link.destYCoord),link.destZCoord,link.linkOrientation); //creates and registers the two rifts that link the parent and pocket dim.
|
||||
this.createLink(dimensionID,DimensionManager.getWorld(link.locDimID).provider.dimensionId, link.destXCoord,constrainPocketY(link.destYCoord),link.destZCoord, link.locXCoord,link.locYCoord,link.locZCoord, BlockRotator.transformMetadata(link.linkOrientation, 2, Block.doorWood.blockID));
|
||||
return link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that saves all dim data in a hashMap. Calling too often can cause Concurrent modification exceptions, so be careful.
|
||||
* @return
|
||||
*/
|
||||
public static void save()
|
||||
{
|
||||
//TODO change from saving serialized objects to just saving data for compatabilies sake.
|
||||
//TODO If saving is multithreaded as the concurrent modification exception implies, you should be synchronizing access. ~SenseiKiwi
|
||||
|
||||
if (isSaving)
|
||||
{
|
||||
return;
|
||||
}
|
||||
World world = DimensionManager.getWorld(OVERWORLD_DIMENSION_ID);
|
||||
if (world == null || world.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (DimensionManager.getCurrentSaveRootDirectory() != null)
|
||||
{
|
||||
isSaving = true;
|
||||
HashMap comboSave = new HashMap();
|
||||
comboSave.put("dimensionData", dimensionData);
|
||||
comboSave.put("keyLinkMapping", keyLinkMapping);
|
||||
|
||||
FileOutputStream saveFile = null;
|
||||
try
|
||||
{
|
||||
String saveFileName=DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoorsDataTEMP";
|
||||
saveFile = new FileOutputStream(saveFileName);
|
||||
|
||||
ObjectOutputStream save = new ObjectOutputStream(saveFile);
|
||||
save.writeObject(comboSave);
|
||||
save.close();
|
||||
saveFile.close();
|
||||
|
||||
if (new File(DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoorsDataOLD").exists())
|
||||
{
|
||||
new File(DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoorsDataOLD").delete();
|
||||
}
|
||||
new File(DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoorsData").renameTo(new File(DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoorsDataOLD"));
|
||||
|
||||
new File(saveFileName).renameTo( new File(DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoorsData"));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
System.err.println("Could not save data-- SEVERE");
|
||||
}
|
||||
isSaving = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* loads the dim data from the saved hashMap. Also handles compatibility with old saves, see OldSaveHandler
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static void load()
|
||||
{
|
||||
//FIXME: There are a lot of things to fix here... First, we shouldn't be created so many File instances
|
||||
//when we could just hold references and reuse them. Second, duplicate code is BAD. Loading stuff should
|
||||
//be a function so that you can apply it to the save file first, then the "backup", instead of duplicating
|
||||
//so much code. >_<
|
||||
|
||||
boolean firstRun = false;
|
||||
System.out.println("Loading DimDoors data");
|
||||
FileInputStream saveFile = null;
|
||||
|
||||
if (!DimensionManager.getWorld(OVERWORLD_DIMENSION_ID).isRemote && DimensionManager.getCurrentSaveRootDirectory()!=null)
|
||||
{
|
||||
try
|
||||
{
|
||||
File dataStore = new File( DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoorsData");
|
||||
if (!dataStore.exists())
|
||||
{
|
||||
if (!new File( DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoorsDataOLD").exists())
|
||||
{
|
||||
firstRun=true;
|
||||
}
|
||||
}
|
||||
saveFile = new FileInputStream(dataStore);
|
||||
ObjectSaveInputStream save = new ObjectSaveInputStream(saveFile);
|
||||
HashMap comboSave = ((HashMap) save.readObject());
|
||||
|
||||
try
|
||||
{
|
||||
keyLinkMapping = (HashMap<Integer, IDimLink>) comboSave.get("keyLinkMapping");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("Could not load Link Signature list. Link Sig items will lose their stored locations.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
dimensionData = (HashMap<Integer, NewDimData>) comboSave.get("dimensionData");
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
System.out.println("Could not load pocket dimension list. Saves are probably lost, but repairable. Move the files from individual pocket dim files to active ones. See MC thread for details.");
|
||||
}
|
||||
|
||||
save.close();
|
||||
saveFile.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!firstRun)
|
||||
{
|
||||
System.out.println("Save data damaged, trying backup...");
|
||||
}
|
||||
World world=FMLCommonHandler.instance().getMinecraftServerInstance().worldServers[0];
|
||||
File dataStore =new File( world.getSaveHandler().getMapFileFromName("idcounts").getParentFile().getParent()+"/DimensionalDoorsDataOLD");
|
||||
|
||||
|
||||
saveFile = new FileInputStream(dataStore);
|
||||
ObjectSaveInputStream save = new ObjectSaveInputStream(saveFile);
|
||||
HashMap comboSave =((HashMap)save.readObject());
|
||||
|
||||
try
|
||||
{
|
||||
keyLinkMapping = (HashMap<Integer, IDimLink>) comboSave.get("keyLinkMapping");
|
||||
}
|
||||
catch (Exception e2)
|
||||
{
|
||||
System.out.println("Could not load Link Signature list. Link Sig items will loose restored locations.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
dimensionData = (HashMap<Integer, NewDimData>) comboSave.get("dimensionData");
|
||||
}
|
||||
catch (Exception e2)
|
||||
{
|
||||
System.out.println("Could not load pocket dim list. Saves probably lost, but repairable. Move the files from indivual pocket dim files to active ones. See MC thread for details.");
|
||||
}
|
||||
|
||||
save.close();
|
||||
saveFile.close();
|
||||
}
|
||||
catch (Exception e2)
|
||||
{
|
||||
if (!firstRun)
|
||||
{
|
||||
System.err.println("Could not read data-- SEVERE");
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean removeRift(World world, int x, int y, int z, int range, EntityPlayer player, ItemStack item)
|
||||
{
|
||||
//Function called by rift tile entities and the rift remover to find and spread between rifts.
|
||||
//Does not actually unregister the rift data, see deleteRift for that.
|
||||
|
||||
NewDimData dimension = getDimensionData(world);
|
||||
IDimLink nearest = dimension.findNearestRift(world, range, x, y, z);
|
||||
|
||||
if (nearest != null)
|
||||
{
|
||||
Point4D location = nearest.source();
|
||||
TileEntity tileEntity = world.getBlockTileEntity(location.getX(), location.getY(), location.getZ());
|
||||
if (tileEntity != null)
|
||||
{
|
||||
TileEntityRift riftEntity = (TileEntityRift) tileEntity;
|
||||
riftEntity.shouldClose = true;
|
||||
item.damageItem(1, player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static NewDimData registerDimension(World world)
|
||||
{
|
||||
return registerDimension(world.provider.dimensionId, null, false, false);
|
||||
}
|
||||
|
||||
public static NewDimData registerPocket(NewDimData parent, boolean isDungeon)
|
||||
{
|
||||
if (parent == null)
|
||||
{
|
||||
throw new IllegalArgumentException("parent cannot be null. A pocket dimension must always have a parent dimension.");
|
||||
}
|
||||
|
||||
DDProperties properties = DDProperties.instance();
|
||||
int dimensionID = DimensionManager.getNextFreeDimId();
|
||||
DimensionManager.registerDimension(dimensionID, properties.PocketProviderID);
|
||||
return registerDimension(dimensionID, parent, true, isDungeon);
|
||||
}
|
||||
|
||||
private static NewDimData registerDimension(int dimensionID, NewDimData parent, boolean isPocket, boolean isDungeon)
|
||||
{
|
||||
if (dimensionData.containsKey(dimensionID))
|
||||
{
|
||||
throw new IllegalArgumentException("Cannot register a dimension with ID = " + dimensionID + " because it has already been registered.");
|
||||
}
|
||||
|
||||
NewDimData dimension = new InnerDimData(dimensionID, parent, isPocket, isDungeon);
|
||||
dimensionData.put(dimensionID, dimension);
|
||||
return dimension;
|
||||
}
|
||||
|
||||
public static NewDimData getDimensionData(World world)
|
||||
{
|
||||
return getDimensionData(world.provider.dimensionId);
|
||||
}
|
||||
|
||||
public static NewDimData getDimensionData(int dimensionID)
|
||||
{
|
||||
//Retrieve the data for a dimension. If we don't have a record for that dimension,
|
||||
//assume it's a non-pocket dimension that hasn't been initialized with us before
|
||||
//and create a NewDimData instance for it.
|
||||
//Any pocket dimension must be listed with PocketManager to have a dimension ID
|
||||
//assigned, so it's safe to assume that any unknown dimensions don't belong to us.
|
||||
|
||||
NewDimData dimension = PocketManager.dimensionData.get(dimensionID);
|
||||
if (dimension == null)
|
||||
{
|
||||
dimension = registerDimension(dimensionID, null, false, false);
|
||||
}
|
||||
return dimension;
|
||||
}
|
||||
|
||||
public static void unload()
|
||||
{
|
||||
save();
|
||||
unregisterDimensions();
|
||||
dimensionData.clear();
|
||||
keyLinkMapping.clear();
|
||||
}
|
||||
|
||||
public static Iterable<NewDimData> getDimensions()
|
||||
{
|
||||
return dimensionData.values();
|
||||
}
|
||||
|
||||
public static IDimLink getLink(int x, int y, int z, int dimensionID)
|
||||
{
|
||||
NewDimData dimension = dimensionData.get(dimensionID);
|
||||
if (dimension != null)
|
||||
{
|
||||
return dimension.getLink(x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
76
StevenDimDoors/mod_pocketDim/dungeon/DungeonData.java
Normal file
76
StevenDimDoors/mod_pocketDim/dungeon/DungeonData.java
Normal file
@@ -0,0 +1,76 @@
|
||||
package StevenDimDoors.mod_pocketDim.dungeon;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.Serializable;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonType;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.InvalidSchematicException;
|
||||
|
||||
public class DungeonData implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = -5624866366474710161L;
|
||||
|
||||
private final int weight;
|
||||
private final boolean isOpen;
|
||||
private final boolean isInternal;
|
||||
private final String schematicPath;
|
||||
private final String schematicName;
|
||||
private final DungeonType dungeonType;
|
||||
|
||||
public DungeonData(String schematicPath, boolean isInternal, DungeonType dungeonType, boolean isOpen, int weight)
|
||||
{
|
||||
this.schematicPath = schematicPath;
|
||||
this.schematicName = getSchematicName(schematicPath);
|
||||
this.dungeonType = dungeonType;
|
||||
this.isInternal = isInternal;
|
||||
this.isOpen = isOpen;
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
private static String getSchematicName(String schematicPath)
|
||||
{
|
||||
int indexA = schematicPath.lastIndexOf('\\');
|
||||
int indexB = schematicPath.lastIndexOf('/');
|
||||
indexA = Math.max(indexA, indexB) + 1;
|
||||
|
||||
return schematicPath.substring(indexA, schematicPath.length() - DungeonHelper.SCHEMATIC_FILE_EXTENSION.length() - indexA);
|
||||
}
|
||||
|
||||
public int weight()
|
||||
{
|
||||
return weight;
|
||||
}
|
||||
|
||||
public boolean isOpen()
|
||||
{
|
||||
return isOpen;
|
||||
}
|
||||
|
||||
public String schematicPath()
|
||||
{
|
||||
return schematicPath;
|
||||
}
|
||||
|
||||
public DungeonType dungeonType()
|
||||
{
|
||||
return dungeonType;
|
||||
}
|
||||
|
||||
public String schematicName()
|
||||
{
|
||||
return schematicName;
|
||||
}
|
||||
|
||||
public DungeonSchematic loadSchematic() throws InvalidSchematicException, FileNotFoundException
|
||||
{
|
||||
if (isInternal)
|
||||
{
|
||||
return DungeonSchematic.readFromResource(schematicPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
return DungeonSchematic.readFromFile(schematicPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.CompoundFilter;
|
||||
@@ -295,7 +295,7 @@ public class DungeonSchematic extends Schematic {
|
||||
//Set the orientation of the rift exit
|
||||
Point3D entranceRiftLocation = entrance.clone();
|
||||
BlockRotator.transformPoint(entranceRiftLocation, entrance, rotation, pocketCenter);
|
||||
NewLinkData sideLink = dimHelper.instance.getLinkDataFromCoords(
|
||||
NewLinkData sideLink = PocketManager.instance.getLinkDataFromCoords(
|
||||
entranceRiftLocation.getX(),
|
||||
entranceRiftLocation.getY(),
|
||||
entranceRiftLocation.getZ(),
|
||||
@@ -319,9 +319,9 @@ public class DungeonSchematic extends Schematic {
|
||||
int blockDirection = world.getBlockMetadata(location.getX(), location.getY() - 1, location.getZ());
|
||||
Point3D linkDestination = location.clone();
|
||||
|
||||
NewLinkData randomLink = dimHelper.instance.getRandomLinkData(false);
|
||||
NewLinkData randomLink = PocketManager.instance.getRandomLinkData(false);
|
||||
NewLinkData sideLink = new NewLinkData(destDimID,
|
||||
dimHelper.instance.getDimData(originDimID).exitDimLink.destDimID,
|
||||
PocketManager.instance.getDimData(originDimID).exitDimLink.destDimID,
|
||||
location.getX(),
|
||||
location.getY(),
|
||||
location.getZ(),
|
||||
@@ -346,7 +346,7 @@ public class DungeonSchematic extends Schematic {
|
||||
}
|
||||
sideLink.linkOrientation = world.getBlockMetadata(linkDestination.getX(), linkDestination.getY() - 1, linkDestination.getZ());
|
||||
|
||||
dimHelper.instance.createLink(sideLink);
|
||||
PocketManager.instance.createLink(sideLink);
|
||||
/**dimHelper.instance.createLink(sideLink.destDimID ,
|
||||
sideLink.locDimID,
|
||||
sideLink.destXCoord,
|
||||
@@ -377,7 +377,7 @@ public class DungeonSchematic extends Schematic {
|
||||
|
||||
private static void setUpDimensionalDoorLink(World world, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter, int originDimID, int destDimID, boolean applyNoise, Random random)
|
||||
{
|
||||
int depth = dimHelper.instance.getDimDepth(originDimID) + 1;
|
||||
int depth = PocketManager.instance.getDimDepth(originDimID) + 1;
|
||||
int forwardNoise;
|
||||
int sidewaysNoise;
|
||||
|
||||
@@ -413,7 +413,7 @@ public class DungeonSchematic extends Schematic {
|
||||
linkDestination.getY() + 1,
|
||||
linkDestination.getZ(),
|
||||
true, blockDirection);
|
||||
dimHelper.instance.createPocket(sideLink, true, true);
|
||||
PocketManager.instance.createPocket(sideLink, true, true);
|
||||
}
|
||||
|
||||
private static void spawnMonolith(World world, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter)
|
||||
|
||||
@@ -7,10 +7,9 @@ import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.WeightedRandom;
|
||||
import StevenDimDoors.mod_pocketDim.DungeonGenerator;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.util.WeightedContainer;
|
||||
|
||||
public class DungeonPack
|
||||
@@ -21,12 +20,12 @@ public class DungeonPack
|
||||
//The ID numbers would be a problem since it couldn't have a valid number, since it wasn't initialized by the pack instance.
|
||||
//FIXME: Do not release this code as an update without dealing with disowned types!
|
||||
|
||||
private static final int MAX_HISTORY_LENGTH = 1337;
|
||||
private static final int MAX_HISTORY_LENGTH = 30;
|
||||
|
||||
private final String name;
|
||||
private final HashMap<String, DungeonType> nameToTypeMapping;
|
||||
private final ArrayList<ArrayList<DungeonGenerator>> groupedDungeons;
|
||||
private final ArrayList<DungeonGenerator> allDungeons;
|
||||
private final ArrayList<ArrayList<DungeonData>> groupedDungeons;
|
||||
private final ArrayList<DungeonData> allDungeons;
|
||||
private final DungeonPackConfig config;
|
||||
private final int maxRuleLength;
|
||||
private final ArrayList<DungeonChainRule> rules;
|
||||
@@ -40,9 +39,9 @@ public class DungeonPack
|
||||
int index;
|
||||
int maxLength = 0;
|
||||
int typeCount = config.getTypeNames().size();
|
||||
this.allDungeons = new ArrayList<DungeonGenerator>();
|
||||
this.allDungeons = new ArrayList<DungeonData>();
|
||||
this.nameToTypeMapping = new HashMap<String, DungeonType>(typeCount);
|
||||
this.groupedDungeons = new ArrayList<ArrayList<DungeonGenerator>>(typeCount);
|
||||
this.groupedDungeons = new ArrayList<ArrayList<DungeonData>>(typeCount);
|
||||
|
||||
this.groupedDungeons.add(allDungeons); //Make sure the list of all dungeons is placed at index 0
|
||||
this.nameToTypeMapping.put(DungeonType.WILDCARD_TYPE.Name, DungeonType.WILDCARD_TYPE);
|
||||
@@ -52,7 +51,7 @@ public class DungeonPack
|
||||
{
|
||||
String standardName = typeName.toUpperCase();
|
||||
this.nameToTypeMapping.put(standardName, new DungeonType(this, standardName, index));
|
||||
this.groupedDungeons.add(new ArrayList<DungeonGenerator>());
|
||||
this.groupedDungeons.add(new ArrayList<DungeonData>());
|
||||
index++;
|
||||
}
|
||||
|
||||
@@ -108,14 +107,14 @@ public class DungeonPack
|
||||
return (this.getType(typeName) != null);
|
||||
}
|
||||
|
||||
public void addDungeon(DungeonGenerator generator)
|
||||
public void addDungeon(DungeonData dungeon)
|
||||
{
|
||||
//Make sure this dungeon really belongs in this pack
|
||||
DungeonType type = generator.getDungeonType();
|
||||
DungeonType type = dungeon.dungeonType();
|
||||
if (type.Owner == this)
|
||||
{
|
||||
allDungeons.add(generator);
|
||||
groupedDungeons.get(type.ID).add(generator);
|
||||
allDungeons.add(dungeon);
|
||||
groupedDungeons.get(type.ID).add(dungeon);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -123,7 +122,7 @@ public class DungeonPack
|
||||
}
|
||||
}
|
||||
|
||||
public DungeonGenerator getNextDungeon(NewLinkData inbound, Random random)
|
||||
public DungeonData getNextDungeon(NewDimData dimension, Random random)
|
||||
{
|
||||
if (allDungeons.isEmpty())
|
||||
{
|
||||
@@ -136,20 +135,19 @@ public class DungeonPack
|
||||
//for dungeon packs that can extend arbitrarily deep. We should probably set a reasonable limit anyway.
|
||||
|
||||
int maxSearchLength = config.allowDuplicatesInChain() ? maxRuleLength : MAX_HISTORY_LENGTH;
|
||||
ArrayList<DungeonGenerator> history = DungeonHelper.getDungeonChainHistory(
|
||||
dimHelper.instance.getDimData(inbound.locDimID), this, maxSearchLength);
|
||||
ArrayList<DungeonData> history = DungeonHelper.getDungeonChainHistory(dimension.parent(), this, maxSearchLength);
|
||||
return getNextDungeon(history, random);
|
||||
}
|
||||
|
||||
private DungeonGenerator getNextDungeon(ArrayList<DungeonGenerator> history, Random random)
|
||||
private DungeonData getNextDungeon(ArrayList<DungeonData> history, Random random)
|
||||
{
|
||||
//Extract the dungeon types that have been used from history and convert them into an array of IDs
|
||||
int index;
|
||||
int[] typeHistory = new int[history.size()];
|
||||
HashSet<DungeonGenerator> excludedDungeons = null;
|
||||
HashSet<DungeonData> excludedDungeons = null;
|
||||
for (index = 0; index < typeHistory.length; index++)
|
||||
{
|
||||
typeHistory[index] = history.get(index).getDungeonType().ID;
|
||||
typeHistory[index] = history.get(index).dungeonType().ID;
|
||||
}
|
||||
|
||||
for (DungeonChainRule rule : rules)
|
||||
@@ -167,16 +165,16 @@ public class DungeonPack
|
||||
//Initialize the set of excluded dungeons if needed
|
||||
if (excludedDungeons == null && !config.allowDuplicatesInChain())
|
||||
{
|
||||
excludedDungeons = new HashSet<DungeonGenerator>(history);
|
||||
excludedDungeons = new HashSet<DungeonData>(history);
|
||||
}
|
||||
|
||||
//List which dungeons are allowed
|
||||
ArrayList<DungeonGenerator> candidates;
|
||||
ArrayList<DungeonGenerator> group = groupedDungeons.get(nextType.ID);
|
||||
ArrayList<DungeonData> candidates;
|
||||
ArrayList<DungeonData> group = groupedDungeons.get(nextType.ID);
|
||||
if (excludedDungeons != null && !excludedDungeons.isEmpty())
|
||||
{
|
||||
candidates = new ArrayList<DungeonGenerator>(group.size());
|
||||
for (DungeonGenerator dungeon : group)
|
||||
candidates = new ArrayList<DungeonData>(group.size());
|
||||
for (DungeonData dungeon : group)
|
||||
{
|
||||
if (!excludedDungeons.contains(dungeon))
|
||||
{
|
||||
@@ -204,7 +202,7 @@ public class DungeonPack
|
||||
return getRandomDungeon(random);
|
||||
}
|
||||
|
||||
public DungeonGenerator getRandomDungeon(Random random)
|
||||
public DungeonData getRandomDungeon(Random random)
|
||||
{
|
||||
if (!allDungeons.isEmpty())
|
||||
{
|
||||
@@ -217,7 +215,7 @@ public class DungeonPack
|
||||
}
|
||||
|
||||
private static DungeonType getRandomDungeonType(Random random, Collection<WeightedContainer<DungeonType>> types,
|
||||
ArrayList<ArrayList<DungeonGenerator>> groupedDungeons)
|
||||
ArrayList<ArrayList<DungeonData>> groupedDungeons)
|
||||
{
|
||||
//TODO: Make this faster? This algorithm runs in quadratic time in the worst case because of the random-selection
|
||||
//process and the removal search. Might be okay for normal use, though. ~SenseiKiwi
|
||||
@@ -248,18 +246,18 @@ public class DungeonPack
|
||||
return null;
|
||||
}
|
||||
|
||||
private static DungeonGenerator getRandomDungeon(Random random, Collection<DungeonGenerator> dungeons)
|
||||
private static DungeonData getRandomDungeon(Random random, Collection<DungeonData> dungeons)
|
||||
{
|
||||
//Use Minecraft's WeightedRandom to select our dungeon. =D
|
||||
ArrayList<WeightedContainer<DungeonGenerator>> weights =
|
||||
new ArrayList<WeightedContainer<DungeonGenerator>>(dungeons.size());
|
||||
for (DungeonGenerator dungeon : dungeons)
|
||||
ArrayList<WeightedContainer<DungeonData>> weights =
|
||||
new ArrayList<WeightedContainer<DungeonData>>(dungeons.size());
|
||||
for (DungeonData dungeon : dungeons)
|
||||
{
|
||||
weights.add(new WeightedContainer<DungeonGenerator>(dungeon, dungeon.weight));
|
||||
weights.add(new WeightedContainer<DungeonData>(dungeon, dungeon.weight()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
WeightedContainer<DungeonGenerator> resultContainer = (WeightedContainer<DungeonGenerator>) WeightedRandom.getRandomItem(random, weights);
|
||||
WeightedContainer<DungeonData> resultContainer = (WeightedContainer<DungeonData>) WeightedRandom.getRandomItem(random, weights);
|
||||
return (resultContainer != null) ? resultContainer.getData() : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,11 @@ import java.util.regex.Pattern;
|
||||
import net.minecraft.util.WeightedRandom;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.DungeonGenerator;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.DungeonSchematic;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPackConfig;
|
||||
@@ -62,8 +63,6 @@ public class DungeonHelper
|
||||
|
||||
public static final String SCHEMATIC_FILE_EXTENSION = ".schematic";
|
||||
|
||||
private static final String DEFAULT_UP_SCHEMATIC_PATH = "/schematics/core/simpleStairsUp.schematic";
|
||||
private static final String DEFAULT_DOWN_SCHEMATIC_PATH = "/schematics/core/simpleStairsDown.schematic";
|
||||
private static final String DEFAULT_ERROR_SCHEMATIC_PATH = "/schematics/core/somethingBroke.schematic";
|
||||
private static final String DUNGEON_CREATION_GUIDE_SOURCE_PATH = "/mods/DimDoors/text/How_to_add_dungeons.txt";
|
||||
private static final String RUINS_PACK_PATH = "/schematics/ruins";
|
||||
@@ -86,16 +85,14 @@ public class DungeonHelper
|
||||
public static final short MAX_DUNGEON_HEIGHT = MAX_DUNGEON_WIDTH;
|
||||
public static final short MAX_DUNGEON_LENGTH = MAX_DUNGEON_WIDTH;
|
||||
|
||||
private ArrayList<DungeonGenerator> untaggedDungeons = new ArrayList<DungeonGenerator>();
|
||||
private ArrayList<DungeonGenerator> registeredDungeons = new ArrayList<DungeonGenerator>();
|
||||
private ArrayList<DungeonData> untaggedDungeons = new ArrayList<DungeonData>();
|
||||
private ArrayList<DungeonData> registeredDungeons = new ArrayList<DungeonData>();
|
||||
|
||||
private DungeonPack RuinsPack;
|
||||
private HashMap<String, DungeonPack> dungeonPackMapping = new HashMap<String, DungeonPack>();
|
||||
private ArrayList<DungeonPack> dungeonPackList = new ArrayList<DungeonPack>();
|
||||
|
||||
private DungeonGenerator defaultUp;
|
||||
private DungeonGenerator defaultDown;
|
||||
private DungeonGenerator defaultError;
|
||||
private DungeonData defaultError;
|
||||
|
||||
private DungeonHelper()
|
||||
{
|
||||
@@ -227,47 +224,34 @@ public class DungeonHelper
|
||||
}
|
||||
}
|
||||
|
||||
public List<DungeonGenerator> getRegisteredDungeons()
|
||||
public List<DungeonData> getRegisteredDungeons()
|
||||
{
|
||||
return Collections.unmodifiableList(this.registeredDungeons);
|
||||
}
|
||||
|
||||
public List<DungeonGenerator> getUntaggedDungeons()
|
||||
public List<DungeonData> getUntaggedDungeons()
|
||||
{
|
||||
return Collections.unmodifiableList(this.untaggedDungeons);
|
||||
}
|
||||
|
||||
public DungeonGenerator getDefaultErrorDungeon()
|
||||
public DungeonData getDefaultErrorDungeon()
|
||||
{
|
||||
return defaultError;
|
||||
}
|
||||
|
||||
public DungeonGenerator getDefaultUpDungeon()
|
||||
{
|
||||
return defaultUp;
|
||||
}
|
||||
|
||||
public DungeonGenerator getDefaultDownDungeon()
|
||||
{
|
||||
return defaultDown;
|
||||
}
|
||||
|
||||
public DungeonPack getDungeonPack(String name)
|
||||
{
|
||||
//TODO: This function might be obsolete after the new save format is implemented.
|
||||
return dungeonPackMapping.get(name.toUpperCase());
|
||||
}
|
||||
|
||||
public DungeonPack getDimDungeonPack(int dimensionID)
|
||||
private DungeonPack getDimDungeonPack(NewDimData data)
|
||||
{
|
||||
//FIXME: This function is a workaround to our current dungeon data limitations. Modify later.
|
||||
//The upcoming save format change and code overhaul will make this obsolete.
|
||||
|
||||
DungeonPack pack;
|
||||
DungeonGenerator generator = dimHelper.dimList.get(dimensionID).dungeonGenerator;
|
||||
if (generator != null)
|
||||
DungeonData dungeon = data.dungeon();
|
||||
if (dungeon != null)
|
||||
{
|
||||
pack = generator.getDungeonType().Owner;
|
||||
pack = dungeon.dungeonType().Owner;
|
||||
|
||||
//Make sure the pack isn't null. This can happen for dungeons with the special UNKNOWN type.
|
||||
if (pack == null)
|
||||
@@ -277,7 +261,7 @@ public class DungeonHelper
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dimensionID == NETHER_DIMENSION_ID)
|
||||
if (data.id() == NETHER_DIMENSION_ID)
|
||||
{
|
||||
//TODO: Change this to the nether-side pack later ^_^
|
||||
pack = RuinsPack;
|
||||
@@ -290,11 +274,11 @@ public class DungeonHelper
|
||||
return pack;
|
||||
}
|
||||
|
||||
public NewLinkData createCustomDungeonDoor(World world, int x, int y, int z)
|
||||
public IDimLink createCustomDungeonDoor(World world, int x, int y, int z)
|
||||
{
|
||||
//Create a link above the specified position. Link to a new pocket dimension.
|
||||
NewLinkData link = new NewLinkData(world.provider.dimensionId, 0, x, y + 1, z, x, y + 1, z, true, 3);
|
||||
link = dimHelper.instance.createPocket(link, true, false);
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
IDimLink link = dimension.createLink(x, y + 1, z).setLinkType(IDimLink.TYPE_POCKET);
|
||||
|
||||
//Place a Warp Door linked to that pocket
|
||||
itemDimDoor.placeDoorBlock(world, x, y, z, 3, mod_pocketDim.ExitDoor);
|
||||
@@ -304,7 +288,6 @@ public class DungeonHelper
|
||||
|
||||
public boolean validateDungeonType(String type, DungeonPack pack)
|
||||
{
|
||||
//Check if the dungeon type is valid
|
||||
return pack.isKnownType(type);
|
||||
}
|
||||
|
||||
@@ -370,10 +353,10 @@ public class DungeonHelper
|
||||
int weight = (dungeonData.length == 4) ? Integer.parseInt(dungeonData[3]) : DEFAULT_DUNGEON_WEIGHT;
|
||||
|
||||
//Add this custom dungeon to the list corresponding to its type
|
||||
DungeonGenerator generator = new DungeonGenerator(weight, path, isOpen, dungeonType);
|
||||
DungeonData dungeon = new DungeonData(path, isInternal, dungeonType, isOpen, weight);
|
||||
|
||||
pack.addDungeon(generator);
|
||||
registeredDungeons.add(generator);
|
||||
pack.addDungeon(dungeon);
|
||||
registeredDungeons.add(dungeon);
|
||||
if (verbose)
|
||||
{
|
||||
System.out.println("Registered dungeon: " + name);
|
||||
@@ -385,7 +368,7 @@ public class DungeonHelper
|
||||
{
|
||||
System.out.println("The following dungeon name is invalid for its given pack. It will not be generated naturally: " + schematicPath);
|
||||
}
|
||||
untaggedDungeons.add(new DungeonGenerator(DEFAULT_DUNGEON_WEIGHT, path, true, DungeonType.UNKNOWN_TYPE));
|
||||
untaggedDungeons.add(new DungeonData(path, isInternal, DungeonType.UNKNOWN_TYPE, true, DEFAULT_DUNGEON_WEIGHT));
|
||||
System.out.println("Registered untagged dungeon: " + name);
|
||||
}
|
||||
}
|
||||
@@ -462,9 +445,7 @@ public class DungeonHelper
|
||||
{
|
||||
//Register the core schematics
|
||||
//These are used for debugging and in case of unusual errors while loading dungeons
|
||||
defaultUp = new DungeonGenerator(DEFAULT_DUNGEON_WEIGHT, DEFAULT_UP_SCHEMATIC_PATH, true, DungeonType.UNKNOWN_TYPE);
|
||||
defaultDown = new DungeonGenerator(DEFAULT_DUNGEON_WEIGHT, DEFAULT_DOWN_SCHEMATIC_PATH, true, DungeonType.UNKNOWN_TYPE);
|
||||
defaultError = new DungeonGenerator(DEFAULT_DUNGEON_WEIGHT, DEFAULT_ERROR_SCHEMATIC_PATH, true, DungeonType.UNKNOWN_TYPE);
|
||||
defaultError = new DungeonData(DEFAULT_ERROR_SCHEMATIC_PATH, true, DungeonType.UNKNOWN_TYPE, true, DEFAULT_DUNGEON_WEIGHT);
|
||||
|
||||
//Open the list of dungeons packaged with our mod and register their schematics
|
||||
registerBundledPack(BUNDLED_RUINS_LIST_PATH, RUINS_PACK_PATH, "Ruins", reader);
|
||||
@@ -530,9 +511,10 @@ public class DungeonHelper
|
||||
}
|
||||
}
|
||||
|
||||
public void generateDungeonLink(NewLinkData inbound, DungeonPack pack, Random random)
|
||||
public DungeonData selectDungeon(NewDimData dimension, Random random)
|
||||
{
|
||||
DungeonGenerator selection;
|
||||
DungeonPack pack = getDimDungeonPack(dimension);
|
||||
DungeonData selection;
|
||||
DungeonPackConfig config;
|
||||
DungeonPack selectedPack;
|
||||
|
||||
@@ -546,13 +528,13 @@ public class DungeonHelper
|
||||
{
|
||||
//Calculate the chance of switching to a different pack type
|
||||
int packSwitchChance;
|
||||
if (dimHelper.dimList.get(inbound.locDimID).depth == 0)
|
||||
if (dimension.depth() == 1)
|
||||
{
|
||||
packSwitchChance = START_PACK_SWITCH_CHANCE;
|
||||
}
|
||||
else
|
||||
{
|
||||
packSwitchChance = MIN_PACK_SWITCH_CHANCE + (getPackDepth(inbound, pack) - 1) * PACK_SWITCH_CHANCE_PER_LEVEL;
|
||||
packSwitchChance = MIN_PACK_SWITCH_CHANCE + dimension.parent().packDepth() * PACK_SWITCH_CHANCE_PER_LEVEL;
|
||||
}
|
||||
|
||||
//Decide randomly whether to switch packs or not
|
||||
@@ -564,7 +546,7 @@ public class DungeonHelper
|
||||
}
|
||||
|
||||
//Pick the next dungeon
|
||||
selection = selectedPack.getNextDungeon(inbound, random);
|
||||
selection = selectedPack.getNextDungeon(dimension, random);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -580,7 +562,7 @@ public class DungeonHelper
|
||||
selection = defaultError;
|
||||
}
|
||||
}
|
||||
dimHelper.instance.getDimData(inbound.destDimID).dungeonGenerator = selection;
|
||||
return selection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -621,16 +603,16 @@ public class DungeonHelper
|
||||
return sortedNames;
|
||||
}
|
||||
|
||||
private static ArrayList<String> parseDungeonNames(ArrayList<DungeonGenerator> dungeons)
|
||||
private static ArrayList<String> parseDungeonNames(ArrayList<DungeonData> dungeons)
|
||||
{
|
||||
String name;
|
||||
File schematic;
|
||||
ArrayList<String> names = new ArrayList<String>(dungeons.size());
|
||||
|
||||
for (DungeonGenerator dungeon : dungeons)
|
||||
for (DungeonData dungeon : dungeons)
|
||||
{
|
||||
//Retrieve the file name and strip off the file extension
|
||||
schematic = new File(dungeon.schematicPath);
|
||||
schematic = new File(dungeon.schematicPath());
|
||||
name = schematic.getName();
|
||||
name = name.substring(0, name.length() - SCHEMATIC_FILE_EXTENSION.length());
|
||||
names.add(name);
|
||||
@@ -638,102 +620,48 @@ public class DungeonHelper
|
||||
return names;
|
||||
}
|
||||
|
||||
public static ArrayList<DungeonGenerator> getDungeonChainHistory(DimData dimData, DungeonPack pack, int maxSize)
|
||||
public static ArrayList<DungeonData> getDungeonChainHistory(NewDimData dimension, DungeonPack pack, int maxSize)
|
||||
{
|
||||
//TODO: I've improved this code for the time being. However, searching across links is a flawed approach. A player could
|
||||
//manipulate the output of this function by setting up links to mislead our algorithm or by removing links.
|
||||
//Dimensions MUST have built-in records of their parent dimensions in the future. ~SenseiKiwi
|
||||
|
||||
ArrayList<DungeonGenerator> history = new ArrayList<DungeonGenerator>();
|
||||
DimData tailDim = dimData;
|
||||
boolean found = true;
|
||||
|
||||
if (dimData.dungeonGenerator == null || dimData.dungeonGenerator.getDungeonType().Owner != pack || maxSize < 1)
|
||||
if (dimension == null)
|
||||
{
|
||||
//The initial dimension is already outside our pack. Return an empty list.
|
||||
return history;
|
||||
throw new IllegalArgumentException("dimension cannot be null.");
|
||||
}
|
||||
history.add(dimData.dungeonGenerator);
|
||||
|
||||
for (int count = 1; count < maxSize && found; count++)
|
||||
int count = 0;
|
||||
NewDimData tail = dimension;
|
||||
DungeonData dungeon = tail.dungeon();
|
||||
ArrayList<DungeonData> history = new ArrayList<DungeonData>();
|
||||
|
||||
while (count < maxSize && dungeon != null && dungeon.dungeonType().Owner == pack)
|
||||
{
|
||||
found = false;
|
||||
for (NewLinkData link : tailDim.getLinksInDim())
|
||||
{
|
||||
DimData neighbor = dimHelper.instance.getDimData(link.destDimID);
|
||||
if (neighbor.depth == tailDim.depth - 1 && neighbor.dungeonGenerator != null &&
|
||||
neighbor.dungeonGenerator.getDungeonType().Owner == pack)
|
||||
{
|
||||
tailDim = neighbor;
|
||||
history.add(tailDim.dungeonGenerator);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
history.add(dungeon);
|
||||
tail = tail.parent();
|
||||
dungeon = tail.dungeon();
|
||||
count++;
|
||||
}
|
||||
return history;
|
||||
}
|
||||
|
||||
private static int getPackDepth(NewLinkData inbound, DungeonPack pack)
|
||||
public static ArrayList<DungeonData> getFlatDungeonTree(NewDimData dimension, int maxSize)
|
||||
{
|
||||
//TODO: I've improved this code for the time being. However, searching across links is a flawed approach. A player could
|
||||
//manipulate the output of this function by setting up links to mislead our algorithm or by removing links.
|
||||
//Dimensions MUST have built-in records of their parent dimensions in the future. ~SenseiKiwi
|
||||
//Dimensions should also just keep track of pack depth internally.
|
||||
NewDimData root = dimension;
|
||||
ArrayList<DungeonData> dungeons = new ArrayList<DungeonData>();
|
||||
Queue<NewDimData> pendingDimensions = new LinkedList<NewDimData>();
|
||||
|
||||
int packDepth = 1;
|
||||
DimData tailDim = dimHelper.dimList.get(inbound.destDimID);
|
||||
boolean found;
|
||||
|
||||
do
|
||||
{
|
||||
found = false;
|
||||
for (NewLinkData link : tailDim.getLinksInDim())
|
||||
{
|
||||
DimData neighbor = dimHelper.instance.getDimData(link.destDimID);
|
||||
if (neighbor.depth == tailDim.depth - 1 && neighbor.dungeonGenerator != null &&
|
||||
neighbor.dungeonGenerator.getDungeonType().Owner == pack)
|
||||
{
|
||||
tailDim = neighbor;
|
||||
found = true;
|
||||
packDepth++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (found);
|
||||
|
||||
return packDepth;
|
||||
}
|
||||
|
||||
public static ArrayList<DungeonGenerator> getFlatDungeonTree(DimData dimData, int maxSize)
|
||||
{
|
||||
//TODO: I've improved this code for the time being. However, searching across links is a flawed approach. A player could
|
||||
//manipulate the output of this function by setting up links to mislead our algorithm or by removing links.
|
||||
//Dimensions MUST have built-in records of their parent dimensions in the future. ~SenseiKiwi
|
||||
|
||||
dimHelper helper = dimHelper.instance;
|
||||
ArrayList<DungeonGenerator> dungeons = new ArrayList<DungeonGenerator>();
|
||||
DimData root = helper.getDimData(helper.getLinkDataFromCoords(dimData.exitDimLink.destXCoord, dimData.exitDimLink.destYCoord, dimData.exitDimLink.destZCoord, dimData.exitDimLink.destDimID).destDimID);
|
||||
HashSet<DimData> checked = new HashSet<DimData>();
|
||||
Queue<DimData> pendingDimensions = new LinkedList<DimData>();
|
||||
|
||||
if (root.dungeonGenerator == null)
|
||||
if (root.dungeon() == null)
|
||||
{
|
||||
return dungeons;
|
||||
}
|
||||
pendingDimensions.add(root);
|
||||
checked.add(root);
|
||||
|
||||
while (dungeons.size() < maxSize && !pendingDimensions.isEmpty())
|
||||
{
|
||||
DimData current = pendingDimensions.remove();
|
||||
for (NewLinkData link : current.getLinksInDim())
|
||||
NewDimData current = pendingDimensions.remove();
|
||||
for (NewDimData child : current.children())
|
||||
{
|
||||
DimData child = helper.getDimData(link.destDimID);
|
||||
if (child.depth == current.depth + 1 && child.dungeonGenerator != null && checked.add(child))
|
||||
if (child.dungeon() != null)
|
||||
{
|
||||
dungeons.add(child.dungeonGenerator);
|
||||
dungeons.add(child.dungeon());
|
||||
pendingDimensions.add(child);
|
||||
}
|
||||
if (dungeons.size() == maxSize)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,41 +1,20 @@
|
||||
package StevenDimDoors.mod_pocketDim.helpers;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
|
||||
public class yCoordHelper
|
||||
{
|
||||
private static final int MAXIMUM_UNCOVERED_Y = 245;
|
||||
|
||||
public static int getFirstUncovered(NewLinkData pointerLink)
|
||||
{
|
||||
return yCoordHelper.getFirstUncovered(
|
||||
pointerLink.destDimID,
|
||||
pointerLink.destXCoord,
|
||||
pointerLink.destYCoord,
|
||||
pointerLink.destZCoord);
|
||||
}
|
||||
|
||||
public static int getFirstUncovered(int worldID, int x, int yStart, int z)
|
||||
{ return getFirstUncovered(worldID, x, yStart, z, false); }
|
||||
|
||||
public static int getFirstUncovered(int worldID, int x, int yStart, int z, boolean fromTop)
|
||||
{
|
||||
if (dimHelper.getWorld(worldID) == null ||
|
||||
dimHelper.getWorld(worldID).provider == null)
|
||||
{
|
||||
dimHelper.initDimension(worldID);
|
||||
}
|
||||
|
||||
return yCoordHelper.getFirstUncovered(dimHelper.getWorld(worldID), x, yStart, z, fromTop);
|
||||
}
|
||||
private yCoordHelper() { }
|
||||
|
||||
public static int getFirstUncovered(World world, int x, int yStart, int z)
|
||||
{ return getFirstUncovered(world, x, yStart, z, false); }
|
||||
{
|
||||
return getFirstUncovered(world, x, yStart, z, false);
|
||||
}
|
||||
|
||||
public static int getFirstUncovered(World world, int x, int yStart, int z, boolean fromTop)
|
||||
{
|
||||
@@ -46,18 +25,20 @@ public class yCoordHelper
|
||||
int height = MAXIMUM_UNCOVERED_Y; //world.getHeight();
|
||||
int y;
|
||||
|
||||
if(!fromTop)
|
||||
if (!fromTop)
|
||||
{
|
||||
boolean covered = true;
|
||||
for (y = yStart; y < height && covered; y++)
|
||||
{
|
||||
covered = IsCoveredBlock(chunk, localX, y - 1, localZ) || IsCoveredBlock(chunk, localX, y, localZ);
|
||||
covered = isCoveredBlock(chunk, localX, y - 1, localZ) || isCoveredBlock(chunk, localX, y, localZ);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean covered = false;
|
||||
for (y = MAXIMUM_UNCOVERED_Y; y > 1 && !covered; y--)
|
||||
{
|
||||
covered = IsCoveredBlock(chunk, localX, y - 1, localZ);
|
||||
covered = isCoveredBlock(chunk, localX, y - 1, localZ);
|
||||
}
|
||||
if (!covered) y = 63;
|
||||
y++;
|
||||
@@ -66,7 +47,7 @@ public class yCoordHelper
|
||||
return y;
|
||||
}
|
||||
|
||||
public static boolean IsCoveredBlock(Chunk chunk, int localX, int y, int localZ)
|
||||
public static boolean isCoveredBlock(Chunk chunk, int localX, int y, int localZ)
|
||||
{
|
||||
int blockID;
|
||||
Block block;
|
||||
@@ -86,4 +67,25 @@ public class yCoordHelper
|
||||
material = block.blockMaterial;
|
||||
return (material.isLiquid() || !material.isReplaceable());
|
||||
}
|
||||
|
||||
public static int adjustDestinationY(int y, int worldHeight, int entranceY, int dungeonHeight)
|
||||
{
|
||||
//The goal here is to guarantee that the dungeon fits within the vertical bounds
|
||||
//of the world while shifting it as little as possible.
|
||||
int destY = y;
|
||||
|
||||
//Is the top of the dungeon going to be at Y < worldHeight?
|
||||
int pocketTop = (dungeonHeight - 1) + destY - entranceY;
|
||||
if (pocketTop >= worldHeight)
|
||||
{
|
||||
destY = (worldHeight - 1) - (dungeonHeight - 1) + entranceY;
|
||||
}
|
||||
|
||||
//Is the bottom of the dungeon at Y >= 0?
|
||||
if (destY < entranceY)
|
||||
{
|
||||
destY = entranceY;
|
||||
}
|
||||
return destY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -188,16 +188,16 @@ public class ItemRiftBlade extends ItemSword
|
||||
if(this.getMaxItemUseDuration(par1ItemStack)-par4>12&&!par2World.isRemote&&itemDimDoor.canPlace(par2World, x, y, z, rotation))
|
||||
{
|
||||
|
||||
if(dimHelper.instance.getDimData(par2World.provider.dimensionId)!=null)
|
||||
if(PocketManager.instance.getDimData(par2World.provider.dimensionId)!=null)
|
||||
{
|
||||
if(dimHelper.instance.getDimData(par2World.provider.dimensionId).depth==0)
|
||||
if(PocketManager.instance.getDimData(par2World.provider.dimensionId).depth==0)
|
||||
{
|
||||
dimHelper.instance.createPocket(link,true, false);
|
||||
PocketManager.instance.createPocket(link,true, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dimHelper.instance.createPocket(link,true, false);
|
||||
PocketManager.instance.createPocket(link,true, false);
|
||||
}
|
||||
par3EntityPlayer.worldObj.playSoundAtEntity(par3EntityPlayer,"mods.DimDoors.sfx.riftDoor", (float) .6, 1);
|
||||
itemDimDoor.placeDoorBlock(par2World, x, y-1, z, rotation, mod_pocketDim.transientDoor);
|
||||
@@ -212,7 +212,7 @@ public class ItemRiftBlade extends ItemSword
|
||||
{
|
||||
if(par2World.getBlockId(hit.blockX, hit.blockY, hit.blockZ)==properties.RiftBlockID)
|
||||
{
|
||||
NewLinkData link = dimHelper.instance.getLinkDataFromCoords(hit.blockX, hit.blockY, hit.blockZ, par2World);
|
||||
NewLinkData link = PocketManager.instance.getLinkDataFromCoords(hit.blockX, hit.blockY, hit.blockZ, par2World);
|
||||
if(link!=null)
|
||||
{
|
||||
|
||||
@@ -229,7 +229,7 @@ public class ItemRiftBlade extends ItemSword
|
||||
{
|
||||
int var12 = MathHelper.floor_double((double)((par3EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
|
||||
if (!itemDimDoor.canPlace(par2World, par4, par5, par6, var12)||!itemDimDoor.canPlace(par2World, par4, par5-1, par6, var12)||dimHelper.instance.getLinkDataFromCoords(par4, par5, par6, par2World)==null)
|
||||
if (!itemDimDoor.canPlace(par2World, par4, par5, par6, var12)||!itemDimDoor.canPlace(par2World, par4, par5-1, par6, var12)||PocketManager.instance.getLinkDataFromCoords(par4, par5, par6, par2World)==null)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
@@ -342,7 +342,7 @@ public class ItemRiftBlade extends ItemSword
|
||||
{
|
||||
int var12 = MathHelper.floor_double((double)((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
|
||||
if (!itemDimDoor.canPlace(par3World, par4, par5, par6, var12)||dimHelper.instance.getLinkDataFromCoords(par4, par5+1, par6, par3World)==null)
|
||||
if (!itemDimDoor.canPlace(par3World, par4, par5, par6, var12)||PocketManager.instance.getLinkDataFromCoords(par4, par5+1, par6, par3World)==null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.List;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -83,11 +83,11 @@ public class ItemStabilizedRiftSignature extends itemLinkSignature
|
||||
}
|
||||
if(hasEnder&&!par3World.isRemote)
|
||||
{
|
||||
if(dimHelper.instance.getLinkDataFromCoords(linkCoords[0], linkCoords[1], linkCoords[2], par3World)==null)
|
||||
if(PocketManager.instance.getLinkDataFromCoords(linkCoords[0], linkCoords[1], linkCoords[2], par3World)==null)
|
||||
{
|
||||
dimHelper.instance.createLink(linkCoords[3], par3World.provider.dimensionId, linkCoords[0], linkCoords[1], linkCoords[2],par4, par5+offset, par6);
|
||||
PocketManager.instance.createLink(linkCoords[3], par3World.provider.dimensionId, linkCoords[0], linkCoords[1], linkCoords[2],par4, par5+offset, par6);
|
||||
}
|
||||
dimHelper.instance.createLink(par3World.provider.dimensionId, linkCoords[3], par4, par5+offset, par6, linkCoords[0], linkCoords[1], linkCoords[2]);
|
||||
PocketManager.instance.createLink(par3World.provider.dimensionId, linkCoords[3], par4, par5+offset, par6, linkCoords[0], linkCoords[1], linkCoords[2]);
|
||||
par2EntityPlayer.worldObj.playSoundAtEntity(par2EntityPlayer,"mods.DimDoors.sfx.riftEnd", (float) .6, 1);
|
||||
|
||||
par2EntityPlayer.sendChatToPlayer("Rift Created");
|
||||
@@ -105,7 +105,7 @@ public class ItemStabilizedRiftSignature extends itemLinkSignature
|
||||
offset = 1;
|
||||
}
|
||||
//otherwise, it creates the first half of the link. Next click will complete it.
|
||||
key= dimHelper.instance.createUniqueInterDimLinkKey();
|
||||
key= PocketManager.instance.createUniqueInterDimLinkKey();
|
||||
this.writeToNBT(par1ItemStack, par4, par5+offset, par6,par3World.provider.dimensionId);
|
||||
par2EntityPlayer.worldObj.playSoundAtEntity(par2EntityPlayer,"mods.DimDoors.sfx.riftStart", (float) .6, 1);
|
||||
|
||||
@@ -126,7 +126,7 @@ public class ItemStabilizedRiftSignature extends itemLinkSignature
|
||||
if(par1ItemStack.stackTagCompound.getBoolean("isCreated"))
|
||||
{
|
||||
Integer[] coords = this.readFromNBT(par1ItemStack);
|
||||
par3List.add(String.valueOf("Leads to dim "+coords[3] +" with depth "+dimHelper.instance.getDimDepth(dimHelper.instance.getDimDepth(coords[3]))));
|
||||
par3List.add(String.valueOf("Leads to dim "+coords[3] +" with depth "+PocketManager.instance.getDimDepth(PocketManager.instance.getDimDepth(coords[3]))));
|
||||
par3List.add("at x="+coords[0]+" y="+coords[1]+" z="+coords[2]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import StevenDimDoors.mod_pocketDim.SchematicLoader;
|
||||
import StevenDimDoors.mod_pocketDim.Spells;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.CommonTickHandler;
|
||||
import StevenDimDoors.mod_pocketDimClient.ClientTickHandler;
|
||||
|
||||
@@ -55,13 +55,13 @@ public class ItemStableFabric extends Item
|
||||
|
||||
Block block = Block.blocksList[par3World.getBlockId(par4, par5, par6)];
|
||||
|
||||
if(dimHelper.dimList.containsKey(par3World.provider.dimensionId))
|
||||
if(PocketManager.dimList.containsKey(par3World.provider.dimensionId))
|
||||
{
|
||||
if(dimHelper.instance.getDimData(par3World.provider.dimensionId).isPocket)
|
||||
if(PocketManager.instance.getDimData(par3World.provider.dimensionId).isPocket)
|
||||
{
|
||||
if(dimHelper.instance.getDimData(par3World.provider.dimensionId).dungeonGenerator!=null)
|
||||
if(PocketManager.instance.getDimData(par3World.provider.dimensionId).dungeonGenerator!=null)
|
||||
{
|
||||
System.out.println("Dungeon name "+dimHelper.instance.getDimData(par3World.provider.dimensionId).dungeonGenerator.schematicPath);
|
||||
System.out.println("Dungeon name "+PocketManager.instance.getDimData(par3World.provider.dimensionId).dungeonGenerator.schematicPath);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class ItemStableFabric extends Item
|
||||
{
|
||||
//if(par2World.getBlockId(hit.blockX, hit.blockY, hit.blockZ)==properties.RiftBlockID)
|
||||
{
|
||||
NewLinkData link = dimHelper.instance.getLinkDataFromCoords(hit.blockX, hit.blockY, hit.blockZ, par2World);
|
||||
NewLinkData link = PocketManager.instance.getLinkDataFromCoords(hit.blockX, hit.blockY, hit.blockZ, par2World);
|
||||
if(link!=null)
|
||||
{
|
||||
Block var11;
|
||||
|
||||
@@ -16,7 +16,7 @@ import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class itemDimDoor extends ItemDoor
|
||||
{
|
||||
@@ -138,7 +138,7 @@ public class itemDimDoor extends ItemDoor
|
||||
{
|
||||
if(par2World.getBlockId(hit.blockX, hit.blockY, hit.blockZ) == properties.RiftBlockID)
|
||||
{
|
||||
NewLinkData link = dimHelper.instance.getLinkDataFromCoords(hit.blockX, hit.blockY, hit.blockZ, par2World);
|
||||
NewLinkData link = PocketManager.instance.getLinkDataFromCoords(hit.blockX, hit.blockY, hit.blockZ, par2World);
|
||||
if(link!=null)
|
||||
{
|
||||
Block var11;
|
||||
@@ -169,7 +169,7 @@ public class itemDimDoor extends ItemDoor
|
||||
int var12 = MathHelper.floor_double((double)((par3EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
|
||||
if (!canPlace(par2World, par4, par5, par6, var12) || !canPlace(par2World, par4, par5-1, par6, var12) ||
|
||||
dimHelper.instance.getLinkDataFromCoords(par4, par5, par6, par2World) == null)
|
||||
PocketManager.instance.getLinkDataFromCoords(par4, par5, par6, par2World) == null)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ package StevenDimDoors.mod_pocketDim.items;
|
||||
import java.util.List;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.ILinkData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -69,7 +69,7 @@ public class itemLinkSignature extends Item
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
int key;
|
||||
NewLinkData linkData;
|
||||
ILinkData linkData;
|
||||
int thisWorldID=par3World.provider.dimensionId;
|
||||
|
||||
|
||||
@@ -118,13 +118,13 @@ public class itemLinkSignature extends Item
|
||||
|
||||
for(int count = 0;count<3;count++)
|
||||
{
|
||||
if(dimHelper.instance.getLinkDataFromCoords(par4, par5+count, par6,par3World)!=null)
|
||||
if(PocketManager.instance.getLinkDataFromCoords(par4, par5+count, par6,par3World)!=null)
|
||||
{
|
||||
int id= (par3World.getBlockId(par4, par5+count, par6));
|
||||
|
||||
if(id == properties.DimensionalDoorID||id==properties.WarpDoorID||id== properties.UnstableDoorID)
|
||||
{
|
||||
orientation = dimHelper.instance.getLinkDataFromCoords(par4, par5+count, par6,par3World).linkOrientation;
|
||||
orientation = PocketManager.instance.getLinkDataFromCoords(par4, par5+count, par6,par3World).linkOrientation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,8 +139,8 @@ public class itemLinkSignature extends Item
|
||||
|
||||
|
||||
|
||||
dimHelper.instance.createLink(par3World.provider.dimensionId, linkCoords[3], par4, par5+offset, par6, linkCoords[0], linkCoords[1], linkCoords[2],orientation);
|
||||
dimHelper.instance.createLink(linkCoords[3], par3World.provider.dimensionId, linkCoords[0], linkCoords[1], linkCoords[2],par4, par5+offset, par6,linkCoords[4]);
|
||||
PocketManager.instance.createLink(par3World.provider.dimensionId, linkCoords[3], par4, par5+offset, par6, linkCoords[0], linkCoords[1], linkCoords[2],orientation);
|
||||
PocketManager.instance.createLink(linkCoords[3], par3World.provider.dimensionId, linkCoords[0], linkCoords[1], linkCoords[2],par4, par5+offset, par6,linkCoords[4]);
|
||||
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ public class itemLinkSignature extends Item
|
||||
|
||||
|
||||
//otherwise, it creates the first half of the link. Next click will complete it.
|
||||
key= dimHelper.instance.createUniqueInterDimLinkKey();
|
||||
key= PocketManager.instance.createUniqueInterDimLinkKey();
|
||||
this.writeToNBT(par1ItemStack, par4, par5+offset, par6,par3World.provider.dimensionId,orientation);
|
||||
par2EntityPlayer.sendChatToPlayer("Rift Signature Stored");
|
||||
par2EntityPlayer.worldObj.playSoundAtEntity(par2EntityPlayer,"mods.DimDoors.sfx.riftStart", (float) .6, 1);
|
||||
@@ -183,7 +183,7 @@ public class itemLinkSignature extends Item
|
||||
{
|
||||
Integer[] coords = this.readFromNBT(par1ItemStack);
|
||||
|
||||
par3List.add(String.valueOf("Leads to dim "+coords[3] +" with depth "+(dimHelper.instance.getDimDepth(coords[3]))));
|
||||
par3List.add(String.valueOf("Leads to dim "+coords[3] +" with depth "+(PocketManager.instance.getDimDepth(coords[3]))));
|
||||
par3List.add("at x="+coords[0]+" y="+coords[1]+" z="+coords[2]);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package StevenDimDoors.mod_pocketDim.items;
|
||||
import java.util.List;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
@@ -83,7 +83,7 @@ public class itemRiftRemover extends Item
|
||||
if(hit!=null)
|
||||
{
|
||||
//System.out.println(hit.hitVec);
|
||||
if(dimHelper.instance.removeRift(par2World, hit.blockX, hit.blockY, hit.blockZ, 1, par3EntityPlayer, par1ItemStack))
|
||||
if(PocketManager.instance.removeRift(par2World, hit.blockX, hit.blockY, hit.blockZ, 1, par3EntityPlayer, par1ItemStack))
|
||||
{
|
||||
par3EntityPlayer.worldObj.playSoundAtEntity(par3EntityPlayer,"mods.DimDoors.sfx.riftClose", (float) .8, 1);
|
||||
|
||||
|
||||
@@ -33,9 +33,8 @@ import StevenDimDoors.mod_pocketDim.commands.CommandPrintDimensionData;
|
||||
import StevenDimDoors.mod_pocketDim.commands.CommandPruneDimensions;
|
||||
import StevenDimDoors.mod_pocketDim.commands.CommandResetDungeons;
|
||||
import StevenDimDoors.mod_pocketDim.commands.CommandTeleportPlayer;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemBlockDimWall;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemChaosDoor;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemRiftBlade;
|
||||
@@ -46,11 +45,13 @@ import StevenDimDoors.mod_pocketDim.items.itemExitDoor;
|
||||
import StevenDimDoors.mod_pocketDim.items.itemLinkSignature;
|
||||
import StevenDimDoors.mod_pocketDim.items.itemRiftRemover;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.CommonTickHandler;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.LimboDecay;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.MobMonolith;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.MonolithSpawner;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.RiftRegenerator;
|
||||
import StevenDimDoors.mod_pocketDim.world.BiomeGenLimbo;
|
||||
import StevenDimDoors.mod_pocketDim.world.BiomeGenPocket;
|
||||
import StevenDimDoors.mod_pocketDim.world.GatewayGenerator;
|
||||
import StevenDimDoors.mod_pocketDim.world.LimboProvider;
|
||||
import StevenDimDoors.mod_pocketDim.world.PocketProvider;
|
||||
import StevenDimDoors.mod_pocketDimClient.ClientPacketHandler;
|
||||
@@ -99,8 +100,6 @@ public class mod_pocketDim
|
||||
@Instance("PocketDimensions")
|
||||
public static mod_pocketDim instance = new mod_pocketDim();
|
||||
|
||||
public static pocketTeleporter teleporter;
|
||||
|
||||
public static Block transientDoor;
|
||||
public static Block ExitDoor;
|
||||
public static Block chaosDoor;
|
||||
@@ -127,12 +126,11 @@ public class mod_pocketDim
|
||||
|
||||
public static HashMap<String,ArrayList<EntityItem>> limboSpawnInventory = new HashMap<String,ArrayList<EntityItem>>();
|
||||
|
||||
public static boolean hasInitDims = false;
|
||||
public static boolean isPlayerWearingGoogles = false;
|
||||
|
||||
public static DDProperties properties;
|
||||
public static MonolithSpawner spawner; //Added this field temporarily. Will be refactored out later.
|
||||
public static RiftGenerator riftGen;
|
||||
public static GatewayGenerator riftGen;
|
||||
|
||||
public static long genTime;
|
||||
public static int teleTimer = 0;
|
||||
@@ -165,10 +163,8 @@ public class mod_pocketDim
|
||||
|
||||
//These fields MUST be initialized after properties are loaded to prevent
|
||||
//instances from holding onto null references to the properties.
|
||||
|
||||
teleporter = new pocketTeleporter();
|
||||
tracker = new PlayerRespawnTracker();
|
||||
riftGen = new RiftGenerator();
|
||||
riftGen = new GatewayGenerator();
|
||||
}
|
||||
|
||||
@Init
|
||||
@@ -396,12 +392,7 @@ public class mod_pocketDim
|
||||
{
|
||||
try
|
||||
{
|
||||
dimHelper.instance.save();
|
||||
dimHelper.instance.unregsisterDims();
|
||||
dimHelper.dimList.clear();
|
||||
dimHelper.blocksToDecay.clear();
|
||||
dimHelper.instance.interDimLinkList.clear();
|
||||
mod_pocketDim.hasInitDims=false;
|
||||
PocketManager.unload();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
@@ -409,7 +400,6 @@ public class mod_pocketDim
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ServerStarting
|
||||
public void serverStarting(FMLServerStartingEvent event)
|
||||
{
|
||||
@@ -423,13 +413,6 @@ public class mod_pocketDim
|
||||
CommandPruneDimensions.instance().register(event);
|
||||
CommandCreatePocket.instance().register(event);
|
||||
CommandTeleportPlayer.instance().register(event);
|
||||
dimHelper.instance.load();
|
||||
|
||||
if(!dimHelper.dimList.containsKey(properties.LimboDimensionID))
|
||||
{
|
||||
dimHelper.dimList.put(properties.LimboDimensionID, new DimData( properties.LimboDimensionID, false, 0, new NewLinkData()));
|
||||
}
|
||||
PocketManager.load();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,226 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityMinecart;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.Teleporter;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
public class pocketTeleporter
|
||||
{
|
||||
int x,y,z;
|
||||
|
||||
NewLinkData sendingLink;
|
||||
|
||||
|
||||
public pocketTeleporter()
|
||||
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new portal near an entity.
|
||||
*/
|
||||
|
||||
public void placeInPortal(Entity par1Entity, WorldServer world, NewLinkData link)
|
||||
{
|
||||
|
||||
|
||||
this.x=link.destXCoord;
|
||||
this.y=link.destYCoord;
|
||||
this.z=link.destZCoord;
|
||||
|
||||
this.sendingLink=link;
|
||||
|
||||
int id;
|
||||
|
||||
//TODO Temporary workaround for mismatched door/rift metadata cases. Gives priority to the door.
|
||||
id=dimHelper.instance.getDestOrientation(sendingLink);
|
||||
int receivingDoorMeta=world.getBlockMetadata(link.destXCoord, link.destYCoord-1, link.destZCoord);
|
||||
int recevingDoorID=world.getBlockId(link.destXCoord, link.destYCoord, link.destZCoord);
|
||||
if(receivingDoorMeta!=id)
|
||||
{
|
||||
if(recevingDoorID==mod_pocketDim.dimDoor.blockID||recevingDoorID==mod_pocketDim.ExitDoor.blockID)
|
||||
{
|
||||
dimHelper.instance.getLinkDataFromCoords(link.destXCoord, link.destYCoord, link.destZCoord, world).linkOrientation=receivingDoorMeta;
|
||||
id=receivingDoorMeta;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(par1Entity instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) par1Entity;
|
||||
|
||||
|
||||
|
||||
|
||||
//System.out.println("Teleporting with link oreintation "+id);
|
||||
|
||||
|
||||
player.rotationYaw=(id*90)+90;
|
||||
if(id==2||id==6)
|
||||
{
|
||||
player.setPositionAndUpdate( x+1.5, y-1, z+.5 );
|
||||
|
||||
|
||||
}
|
||||
else if(id==3||id==7)
|
||||
{
|
||||
|
||||
player.setPositionAndUpdate( x+.5, y-1, z+1.5 );
|
||||
|
||||
|
||||
}
|
||||
else if(id==0||id==4)
|
||||
{
|
||||
|
||||
player.setPositionAndUpdate(x-.5, y-1, z+.5);
|
||||
|
||||
}
|
||||
else if(id==1||id==5)
|
||||
{
|
||||
player.setPositionAndUpdate(x+.5, y-1, z-.5);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setPositionAndUpdate(x, y-1, z);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
else if(par1Entity instanceof EntityMinecart)
|
||||
{
|
||||
par1Entity.motionX=0;
|
||||
par1Entity.motionZ=0;
|
||||
par1Entity.motionY=0;
|
||||
|
||||
|
||||
|
||||
par1Entity.rotationYaw=(id*90)+90;
|
||||
|
||||
if(id==2||id==6)
|
||||
{
|
||||
|
||||
|
||||
this.setEntityPosition(par1Entity, x+1.5, y, z+.5 );
|
||||
par1Entity.motionX =.39;
|
||||
par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false);
|
||||
|
||||
}
|
||||
else if(id==3||id==7)
|
||||
{
|
||||
|
||||
|
||||
this.setEntityPosition(par1Entity, x+.5, y, z+1.5 );
|
||||
par1Entity.motionZ =.39;
|
||||
par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false);
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if(id==0||id==4)
|
||||
{
|
||||
|
||||
|
||||
this.setEntityPosition(par1Entity,x-.5, y, z+.5);
|
||||
par1Entity.motionX =-.39;
|
||||
par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false);
|
||||
|
||||
|
||||
}
|
||||
else if(id==1||id==5)
|
||||
{
|
||||
|
||||
this.setEntityPosition(par1Entity,x+.5, y, z-.5);
|
||||
par1Entity.motionZ =-.39;
|
||||
par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setEntityPosition(par1Entity,x, y, z);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
else if(par1Entity instanceof Entity)
|
||||
{
|
||||
|
||||
//System.out.println("Teleporting with link oreintation "+id);
|
||||
|
||||
|
||||
par1Entity.rotationYaw=(id*90)+90;
|
||||
|
||||
// EntityMinecart.class.cast(par1Entity).isinreverse=false;
|
||||
if(id==2||id==6)
|
||||
{
|
||||
this.setEntityPosition(par1Entity, x+1.5, y, z+.5 );
|
||||
|
||||
|
||||
}
|
||||
else if(id==3||id==7)
|
||||
{
|
||||
|
||||
this.setEntityPosition(par1Entity, x+.5, y, z+1.5 );
|
||||
|
||||
|
||||
}
|
||||
else if(id==0||id==4)
|
||||
{
|
||||
|
||||
this.setEntityPosition(par1Entity,x-.5, y, z+.5);
|
||||
|
||||
}
|
||||
else if(id==1||id==5)
|
||||
{
|
||||
this.setEntityPosition(par1Entity,x+.5, y, z-.5);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setEntityPosition(par1Entity,x, y, z);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setEntityPosition(Entity entity, double x, double y, double z)
|
||||
{
|
||||
entity.lastTickPosX = entity.prevPosX = entity.posX = x;
|
||||
entity.lastTickPosY = entity.prevPosY = entity.posY = y + (double)entity.yOffset;
|
||||
entity.lastTickPosZ = entity.prevPosZ = entity.posZ = z;
|
||||
entity.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
package StevenDimDoors.mod_pocketDim.ticking;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -6,9 +6,8 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.world.ChunkCoordIntPair;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.IRegularTickReceiver;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.IRegularTickSender;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
|
||||
/**
|
||||
* Provides methods for applying Limbo decay. Limbo decay refers to the effect that most blocks placed in Limbo
|
||||
@@ -81,7 +80,7 @@ public class LimboDecay implements IRegularTickReceiver {
|
||||
int x, y, z;
|
||||
int sectionY;
|
||||
int limboHeight;
|
||||
World limbo = dimHelper.getWorld(properties.LimboDimensionID);
|
||||
World limbo = DimensionManager.getWorld(properties.LimboDimensionID);
|
||||
|
||||
if (limbo != null)
|
||||
{
|
||||
@@ -8,8 +8,8 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
import StevenDimDoors.mod_pocketDim.util.ChunkLocation;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.world.LimboProvider;
|
||||
import StevenDimDoors.mod_pocketDim.world.PocketProvider;
|
||||
|
||||
@@ -173,7 +173,7 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
|
||||
NewLinkData link = new NewLinkData(this.worldObj.provider.dimensionId, properties.LimboDimensionID, (int)this.posX, (int)this.posY, (int)this.posZ, (int)this.posX+rand.nextInt(500)-250, (int)this.posY+500, (int)this.posZ+rand.nextInt(500)-250, false,0);
|
||||
|
||||
dimHelper.instance.traverseDimDoor(worldObj, link, entityPlayer);
|
||||
PocketManager.instance.traverseDimDoor(worldObj, link, entityPlayer);
|
||||
this.aggro=0;
|
||||
|
||||
entityPlayer.worldObj.playSoundAtEntity(entityPlayer,"mods.DimDoors.sfx.crack",13, 1);
|
||||
|
||||
@@ -7,9 +7,10 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
import StevenDimDoors.mod_pocketDim.util.ChunkLocation;
|
||||
|
||||
@@ -69,23 +70,24 @@ public class MonolithSpawner implements IRegularTickReceiver {
|
||||
|
||||
private void placeMonolithsInPocket(int dimensionID, int chunkX, int chunkZ)
|
||||
{
|
||||
World pocket = dimHelper.getWorld(dimensionID);
|
||||
DimData dimData = dimHelper.instance.getDimData(dimensionID);
|
||||
int sanity = 0;
|
||||
int blockID = 0;
|
||||
boolean didSpawn = false;
|
||||
NewDimData dimension = PocketManager.getDimensionData(dimensionID);
|
||||
World pocket = DimensionManager.getWorld(dimensionID);
|
||||
|
||||
if (pocket == null ||
|
||||
dimData == null ||
|
||||
dimData.dungeonGenerator == null ||
|
||||
dimData.dungeonGenerator.isOpen)
|
||||
dimension == null ||
|
||||
dimension.dungeon() == null ||
|
||||
dimension.dungeon().isOpen())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int sanity = 0;
|
||||
int blockID = 0;
|
||||
boolean didSpawn = false;
|
||||
|
||||
//The following initialization code is based on code from ChunkProviderGenerate.
|
||||
//It makes our generation depend on the world seed.
|
||||
Random random = new Random(pocket.getSeed());
|
||||
Random random = new Random(pocket.getSeed() ^ 0xA210FE65F20017D6L);
|
||||
long factorA = random.nextLong() / 2L * 2L + 1L;
|
||||
long factorB = random.nextLong() / 2L * 2L + 1L;
|
||||
random.setSeed(chunkX * factorA + chunkZ * factorB ^ pocket.getSeed());
|
||||
@@ -139,7 +141,7 @@ public class MonolithSpawner implements IRegularTickReceiver {
|
||||
|
||||
private void placeMonolithsInLimbo(int dimensionID, int chunkX, int chunkZ)
|
||||
{
|
||||
World limbo = dimHelper.getWorld(dimensionID);
|
||||
World limbo = DimensionManager.getWorld(dimensionID);
|
||||
|
||||
if (limbo == null)
|
||||
{
|
||||
@@ -148,7 +150,7 @@ public class MonolithSpawner implements IRegularTickReceiver {
|
||||
|
||||
//The following initialization code is based on code from ChunkProviderGenerate.
|
||||
//It makes our generation depend on the world seed.
|
||||
Random random = new Random(limbo.getSeed());
|
||||
Random random = new Random(limbo.getSeed() ^ 0xB5130C4ACC71A822L);
|
||||
long factorA = random.nextLong() / 2L * 2L + 1L;
|
||||
long factorB = random.nextLong() / 2L * 2L + 1L;
|
||||
random.setSeed(chunkX * factorA + chunkZ * factorB ^ limbo.getSeed());
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
package StevenDimDoors.mod_pocketDim.ticking;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.TileEntityRift;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class RiftRegenerator implements IRegularTickReceiver {
|
||||
|
||||
private static final int RIFT_REGENERATION_INTERVAL = 100; //Regenerate random rifts every 100 ticks
|
||||
private static final int RIFT_REGENERATION_INTERVAL = 200; //Regenerate random rifts every 200 ticks
|
||||
private static final int RIFTS_REGENERATED_PER_DIMENSION = 5;
|
||||
|
||||
private DDProperties properties;
|
||||
|
||||
@@ -24,49 +28,33 @@ public class RiftRegenerator implements IRegularTickReceiver {
|
||||
@Override
|
||||
public void notifyTick()
|
||||
{
|
||||
regenerate();
|
||||
regenerateRiftsInAllWorlds();
|
||||
}
|
||||
|
||||
private void regenerate()
|
||||
public static void regenerateRiftsInAllWorlds()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Regenerate rifts that have been replaced (not permanently removed) by players
|
||||
//Regenerate rifts that have been replaced (not permanently removed) by players
|
||||
DDProperties properties = DDProperties.instance();
|
||||
|
||||
int i = 0;
|
||||
|
||||
while (i < 15 && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
|
||||
for (NewDimData dimension : PocketManager.getDimensions())
|
||||
{
|
||||
if (dimension.linkCount() > 0)
|
||||
{
|
||||
i++;
|
||||
NewLinkData link;
|
||||
World world = DimensionManager.getWorld(dimension.id());
|
||||
|
||||
//actually gets the random rift based on the size of the list
|
||||
link = (NewLinkData) dimHelper.instance.getRandomLinkData(true);
|
||||
|
||||
if (link != null)
|
||||
{
|
||||
World world = dimHelper.getWorld(link.locDimID);
|
||||
|
||||
if (world != null && !mod_pocketDim.blockRift.isBlockImmune(world, link.locXCoord, link.locYCoord, link.locZCoord))
|
||||
{
|
||||
if (dimHelper.instance.getLinkDataFromCoords(link.locXCoord, link.locYCoord, link.locZCoord, link.locDimID) != null)
|
||||
{
|
||||
world.setBlock(link.locXCoord, link.locYCoord, link.locZCoord, properties.RiftBlockID);
|
||||
TileEntityRift rift = (TileEntityRift) world.getBlockTileEntity(link.locXCoord, link.locYCoord, link.locZCoord);
|
||||
if (rift == null)
|
||||
{
|
||||
dimHelper.getWorld(link.locDimID).setBlockTileEntity(link.locXCoord, link.locYCoord, link.locZCoord, new TileEntityRift());
|
||||
}
|
||||
rift.hasGrownRifts = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (world != null)
|
||||
{
|
||||
for (int count = 0; count < RIFTS_REGENERATED_PER_DIMENSION; count++)
|
||||
{
|
||||
IDimLink link = dimension.getRandomLink();
|
||||
Point4D source = link.source();
|
||||
if (!mod_pocketDim.blockRift.isBlockImmune(world, source.getX(), source.getY(), source.getZ()))
|
||||
{
|
||||
world.setBlock(source.getX(), source.getY(), source.getZ(), properties.RiftBlockID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("An exception occurred in RiftRegenerator.regenerate():");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package StevenDimDoors.mod_pocketDim.util;
|
||||
|
||||
|
||||
public final class Point4D
|
||||
public final class Point4D implements Comparable<Point4D>
|
||||
{
|
||||
private final int x;
|
||||
private final int y;
|
||||
@@ -135,6 +135,21 @@ public final class Point4D
|
||||
return (x == other.x && y == other.y && z == other.z && dimension == other.dimension);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Point4D other)
|
||||
{
|
||||
int diff = x - other.x;
|
||||
if (diff != 0)
|
||||
return diff;
|
||||
diff = y - other.y;
|
||||
if (diff != 0)
|
||||
return diff;
|
||||
diff = z - other.z;
|
||||
if (diff != 0)
|
||||
return diff;
|
||||
return dimension - other.dimension;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
package StevenDimDoors.mod_pocketDim.world;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -7,14 +7,15 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.items.itemDimDoor;
|
||||
import StevenDimDoors.mod_pocketDim.world.LimboProvider;
|
||||
import StevenDimDoors.mod_pocketDim.world.PocketProvider;
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
|
||||
public class RiftGenerator implements IWorldGenerator
|
||||
public class GatewayGenerator implements IWorldGenerator
|
||||
{
|
||||
public static final int MAX_GATEWAY_GENERATION_CHANCE = 10000;
|
||||
public static final int MAX_CLUSTER_GENERATION_CHANCE = 10000;
|
||||
@@ -30,7 +31,7 @@ public class RiftGenerator implements IWorldGenerator
|
||||
private static final int NETHER_DIMENSION_ID = -1;
|
||||
private static DDProperties properties = null;
|
||||
|
||||
public RiftGenerator()
|
||||
public GatewayGenerator()
|
||||
{
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
@@ -47,7 +48,7 @@ public class RiftGenerator implements IWorldGenerator
|
||||
return;
|
||||
}
|
||||
//This check prevents a crash related to superflat worlds not loading World 0
|
||||
if (dimHelper.getWorld(OVERWORLD_DIMENSION_ID) == null)
|
||||
if (DimensionManager.getWorld(OVERWORLD_DIMENSION_ID) == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -56,7 +57,8 @@ public class RiftGenerator implements IWorldGenerator
|
||||
int attempts;
|
||||
int correction;
|
||||
boolean valid;
|
||||
NewLinkData link;
|
||||
IDimLink link;
|
||||
NewDimData dimension;
|
||||
|
||||
//Check if we're generating things in the Nether
|
||||
if (world.provider.dimensionId == NETHER_DIMENSION_ID)
|
||||
@@ -76,6 +78,7 @@ public class RiftGenerator implements IWorldGenerator
|
||||
if (random.nextInt(MAX_CLUSTER_GENERATION_CHANCE) < properties.ClusterGenerationChance)
|
||||
{
|
||||
link = null;
|
||||
dimension = null;
|
||||
do
|
||||
{
|
||||
//Pick a random point on the surface of the chunk
|
||||
@@ -90,16 +93,15 @@ public class RiftGenerator implements IWorldGenerator
|
||||
world.getBlockId(x, y - 1, z) != Block.bedrock.blockID &&
|
||||
world.getBlockId(x, y - 2, z) != Block.bedrock.blockID)
|
||||
{
|
||||
//Create a link. If this is the first time, create a dungeon pocket and create a two-way link.
|
||||
//Otherwise, create a one-way link and connect to the destination of the first link.
|
||||
//Create a link. If this is not the first time, create a child link and connect it to the first link.
|
||||
if (link == null)
|
||||
{
|
||||
link = new NewLinkData(world.provider.dimensionId, 0, x, y + 1, z, x, y + 1, z, true, 0);
|
||||
link = dimHelper.instance.createPocket(link, true, true);
|
||||
dimension = PocketManager.getDimensionData(world);
|
||||
link = dimension.createLink(x, y + 1, z).setLinkType(IDimLink.TYPE_POCKET);
|
||||
}
|
||||
else
|
||||
{
|
||||
link = dimHelper.instance.createLink(link.locDimID, link.destDimID, x, y + 1, z, link.destXCoord, link.destYCoord, link.destZCoord);
|
||||
dimension.createChildLink(x, y + 1, z, link);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,13 +130,12 @@ public class RiftGenerator implements IWorldGenerator
|
||||
//Build the gateway if we found a valid location
|
||||
if (valid)
|
||||
{
|
||||
//Create a two-way link between the upper block of the gateway and a pocket dimension
|
||||
//That pocket dimension is where we'll start a dungeon!
|
||||
link = new NewLinkData(world.provider.dimensionId, 0, x, y + 1, z, x, y + 1, z, true, 0);
|
||||
link = dimHelper.instance.createPocket(link, true, true);
|
||||
//Create a partial link to a dungeon.
|
||||
dimension = PocketManager.getDimensionData(world);
|
||||
link = dimension.createLink(x, y + 1, z).setLinkType(IDimLink.TYPE_DUNGEON);
|
||||
|
||||
//If the current dimension isn't Limbo, build a Rift Gateway out of Stone Bricks
|
||||
if (world.provider.dimensionId != properties.LimboDimensionID)
|
||||
if (dimension.id() != properties.LimboDimensionID)
|
||||
{
|
||||
createStoneGateway(world, x, y, z, random);
|
||||
}
|
||||
422
StevenDimDoors/mod_pocketDim/world/PocketBuilder.java
Normal file
422
StevenDimDoors/mod_pocketDim/world/PocketBuilder.java
Normal file
@@ -0,0 +1,422 @@
|
||||
package StevenDimDoors.mod_pocketDim.world;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.DungeonSchematic;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPackConfig;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public class PocketBuilder
|
||||
{
|
||||
public static final int MIN_POCKET_SIZE = 5;
|
||||
public static final int MAX_POCKET_SIZE = 51;
|
||||
public static final int DEFAULT_POCKET_SIZE = 39;
|
||||
|
||||
public static final int MIN_POCKET_WALL_THICKNESS = 1;
|
||||
public static final int MAX_POCKET_WALL_THICKNESS = 10;
|
||||
public static final int DEFAULT_POCKET_WALL_THICKNESS = 5;
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
private PocketBuilder() { }
|
||||
|
||||
public static boolean initializeDestination(IDimLink link, DDProperties properties)
|
||||
{
|
||||
if (link.hasDestination())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//Check the destination type and respond accordingly
|
||||
switch (link.linkType())
|
||||
{
|
||||
case IDimLink.TYPE_DUNGEON:
|
||||
return generateNewDungeonPocket(link, properties);
|
||||
case IDimLink.TYPE_POCKET:
|
||||
return generateNewPocket(link, properties);
|
||||
default:
|
||||
throw new IllegalArgumentException("link has an unrecognized link type.");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean generateNewDungeonPocket(IDimLink link, DDProperties properties)
|
||||
{
|
||||
if (link == null)
|
||||
{
|
||||
throw new IllegalArgumentException("link cannot be null.");
|
||||
}
|
||||
if (properties == null)
|
||||
{
|
||||
throw new IllegalArgumentException("properties cannot be null.");
|
||||
}
|
||||
if (link.hasDestination())
|
||||
{
|
||||
throw new IllegalArgumentException("link cannot have a destination assigned already.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
//Register a new dimension
|
||||
NewDimData parent = PocketManager.getDimensionData(link.source().getDimension());
|
||||
NewDimData dimension = PocketManager.registerPocket(parent, false);
|
||||
|
||||
//Load a world
|
||||
World world = DimensionManager.getWorld(dimension.id());
|
||||
|
||||
if (world == null)
|
||||
{
|
||||
DimensionManager.initDimension(dimension.id());
|
||||
world = DimensionManager.getWorld(dimension.id());
|
||||
}
|
||||
if (world != null && world.provider == null)
|
||||
{
|
||||
DimensionManager.initDimension(dimension.id());
|
||||
}
|
||||
if (world == null || world.provider == null)
|
||||
{
|
||||
System.err.println("Could not initialize dimension for a dungeon!");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* This code is currently wrong. It's missing the following things:
|
||||
* 1. Calculate the destination point for real. That includes adding door noise if needed.
|
||||
* 2. Receive the DungeonData from selectDungeon()
|
||||
* 3. The function signature for DungeonSchematic.copyToWorld() has to be rewritten.
|
||||
*/
|
||||
|
||||
//Choose a dungeon to generate
|
||||
DungeonSchematic schematic = selectDungeon(dimension, random, properties);
|
||||
|
||||
if (schematic == null)
|
||||
{
|
||||
System.err.println("Could not select a dungeon for generation!");
|
||||
return false;
|
||||
}
|
||||
|
||||
//Calculate the destination point
|
||||
Point4D source = link.source();
|
||||
int destinationY = yCoordHelper.adjustDestinationY(destination, world.getHeight(), schematic.getEntranceDoorLocation().getY(), schematic.getHeight());
|
||||
int orientation = getDestinationOrientation(source);
|
||||
destination.setY(destinationY);
|
||||
|
||||
//Generate the dungeon
|
||||
DungeonPackConfig packConfig = dungeon.dungeonType().Owner != null ? dungeon.dungeonType().Owner.getConfig() : null;
|
||||
|
||||
schematic.copyToWorld(world, link, packConfig.doDistortDoorCoordinates());
|
||||
|
||||
//Finish up destination initialization
|
||||
dimension.initializePocket(destination.getX(), destination.getY(), destination.getZ(), orientation, link);
|
||||
dimension.setFilled(true);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static DungeonSchematic selectDungeon(NewDimData dimension, Random random, DDProperties properties)
|
||||
{
|
||||
//We assume the dimension doesn't have a dungeon assigned
|
||||
if (dimension.dungeon() != null)
|
||||
{
|
||||
throw new IllegalArgumentException("dimension cannot have a dungeon assigned already.");
|
||||
}
|
||||
|
||||
DungeonData dungeon = null;
|
||||
DungeonSchematic schematic = null;
|
||||
|
||||
dungeon = DungeonHelper.instance().selectDungeon(dimension, random);
|
||||
|
||||
if (dungeon != null)
|
||||
{
|
||||
schematic = loadAndValidateDungeon(dungeon, properties);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.err.println("Could not select a dungeon at all!");
|
||||
}
|
||||
|
||||
if (schematic == null)
|
||||
{
|
||||
//TODO: In the future, remove this dungeon from the generation lists altogether.
|
||||
//That will have to wait until our code is updated to support that more easily.
|
||||
|
||||
try
|
||||
{
|
||||
System.err.println("Loading the default error dungeon instead...");
|
||||
dungeon = DungeonHelper.instance().getDefaultErrorDungeon();
|
||||
schematic = loadAndValidateDungeon(dungeon, properties);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return schematic;
|
||||
}
|
||||
|
||||
private static DungeonSchematic loadAndValidateDungeon(DungeonData dungeon, DDProperties properties)
|
||||
{
|
||||
try
|
||||
{
|
||||
DungeonSchematic schematic = dungeon.loadSchematic();
|
||||
|
||||
//Validate the dungeon's dimensions
|
||||
if (hasValidDimensions(schematic))
|
||||
{
|
||||
schematic.applyImportFilters(properties);
|
||||
|
||||
//Check that the dungeon has an entrance or we'll have a crash
|
||||
if (schematic.getEntranceDoorLocation() == null)
|
||||
{
|
||||
System.err.println("The following schematic file does not have an entrance: " + dungeon.schematicPath());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.err.println("The following schematic file has dimensions that exceed the maximum permitted dimensions for dungeons: " + dungeon.schematicPath());
|
||||
return null;
|
||||
}
|
||||
return schematic;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("An error occurred while loading the following schematic: " + dungeon.schematicPath());
|
||||
System.err.println(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasValidDimensions(DungeonSchematic schematic)
|
||||
{
|
||||
return (schematic.getWidth() <= DungeonHelper.MAX_DUNGEON_WIDTH &&
|
||||
schematic.getHeight() <= DungeonHelper.MAX_DUNGEON_HEIGHT &&
|
||||
schematic.getLength() <= DungeonHelper.MAX_DUNGEON_LENGTH);
|
||||
}
|
||||
|
||||
public static boolean generateNewPocket(IDimLink link, DDProperties properties)
|
||||
{
|
||||
return generateNewPocket(link, DEFAULT_POCKET_SIZE, DEFAULT_POCKET_WALL_THICKNESS, properties);
|
||||
}
|
||||
|
||||
private static int getDestinationOrientation(Point4D source)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean generateNewPocket(IDimLink link, int size, int wallThickness, DDProperties properties)
|
||||
{
|
||||
if (link == null)
|
||||
{
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (properties == null)
|
||||
{
|
||||
throw new IllegalArgumentException("properties cannot be null.");
|
||||
}
|
||||
if (link.hasDestination())
|
||||
{
|
||||
throw new IllegalArgumentException("link cannot have a destination assigned already.");
|
||||
}
|
||||
|
||||
if (size < MIN_POCKET_SIZE || size > MAX_POCKET_SIZE)
|
||||
{
|
||||
throw new IllegalArgumentException("size must be between " + MIN_POCKET_SIZE + " and " + MAX_POCKET_SIZE + ", inclusive.");
|
||||
}
|
||||
if (wallThickness < MIN_POCKET_WALL_THICKNESS || wallThickness > MAX_POCKET_WALL_THICKNESS)
|
||||
{
|
||||
throw new IllegalArgumentException("wallThickness must be between " + MIN_POCKET_WALL_THICKNESS + " and " + MAX_POCKET_WALL_THICKNESS + ", inclusive.");
|
||||
}
|
||||
if (size % 2 == 0)
|
||||
{
|
||||
throw new IllegalArgumentException("size must be an odd number.");
|
||||
}
|
||||
if (size < 2 * wallThickness + 3)
|
||||
{
|
||||
throw new IllegalArgumentException("size must be large enough to fit the specified wall thickness and some air space.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
//Register a new dimension
|
||||
NewDimData parent = PocketManager.getDimensionData(link.source().getDimension());
|
||||
NewDimData dimension = PocketManager.registerPocket(parent, false);
|
||||
|
||||
//Load a world
|
||||
World world = DimensionManager.getWorld(dimension.id());
|
||||
|
||||
if (world == null)
|
||||
{
|
||||
DimensionManager.initDimension(dimension.id());
|
||||
world = DimensionManager.getWorld(dimension.id());
|
||||
}
|
||||
if (world != null && world.provider == null)
|
||||
{
|
||||
DimensionManager.initDimension(dimension.id());
|
||||
}
|
||||
if (world == null || world.provider == null)
|
||||
{
|
||||
System.err.println("Could not initialize dimension for a pocket!");
|
||||
return false;
|
||||
}
|
||||
|
||||
//Calculate the destination point
|
||||
Point4D source = link.source();
|
||||
int destinationY = yCoordHelper.adjustDestinationY(source.getY(), world.getHeight(), wallThickness + 1, size);
|
||||
int orientation = getDestinationOrientation(source);
|
||||
|
||||
//Build the actual pocket area
|
||||
buildPocket(world, source.getX(), destinationY, source.getZ(), orientation, size, wallThickness, properties);
|
||||
|
||||
//Finish up destination initialization
|
||||
dimension.initializePocket(source.getX(), destinationY, source.getZ(), orientation, link);
|
||||
dimension.setFilled(true);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildPocket(World world, int x, int y, int z, int orientation, int size, int wallThickness, DDProperties properties)
|
||||
{
|
||||
if (properties == null)
|
||||
{
|
||||
throw new IllegalArgumentException("properties cannot be null.");
|
||||
}
|
||||
if (size < MIN_POCKET_SIZE || size > MAX_POCKET_SIZE)
|
||||
{
|
||||
throw new IllegalArgumentException("size must be between " + MIN_POCKET_SIZE + " and " + MAX_POCKET_SIZE + ", inclusive.");
|
||||
}
|
||||
if (wallThickness < MIN_POCKET_WALL_THICKNESS || wallThickness > MAX_POCKET_WALL_THICKNESS)
|
||||
{
|
||||
throw new IllegalArgumentException("wallThickness must be between " + MIN_POCKET_WALL_THICKNESS + " and " + MAX_POCKET_WALL_THICKNESS + ", inclusive.");
|
||||
}
|
||||
if (size % 2 == 0)
|
||||
{
|
||||
throw new IllegalArgumentException("size must be an odd number.");
|
||||
}
|
||||
if (size < 2 * wallThickness + 3)
|
||||
{
|
||||
throw new IllegalArgumentException("size must be large enough to fit the specified wall thickness and some air space.");
|
||||
}
|
||||
|
||||
Point3D center = new Point3D(x - wallThickness + 1 + (size / 2), y - wallThickness - 1 + (size / 2), z);
|
||||
Point3D door = new Point3D(x, y, z);
|
||||
BlockRotator.transformPoint(center, door, orientation - BlockRotator.EAST_DOOR_METADATA, door);
|
||||
|
||||
//Build the outer layer of Eternal Fabric
|
||||
buildBox(world, center.getX(), center.getY(), center.getZ(), (size / 2), properties.PermaFabricBlockID, false, 0);
|
||||
|
||||
//Build the (wallThickness - 1) layers of Fabric of Reality
|
||||
for (int layer = 1; layer < wallThickness; layer++)
|
||||
{
|
||||
buildBox(world, center.getX(), center.getY(), center.getZ(), (size / 2) - layer, properties.FabricBlockID,
|
||||
layer < (wallThickness - 1) && properties.TNFREAKINGT_Enabled, properties.NonTntWeight);
|
||||
}
|
||||
|
||||
//Build the door
|
||||
int metadata = BlockRotator.transformMetadata(BlockRotator.EAST_DOOR_METADATA, orientation - BlockRotator.EAST_DOOR_METADATA, properties.DimensionalDoorID);
|
||||
setBlockDirectly(world, x, y, z, properties.DimensionalDoorID, metadata);
|
||||
setBlockDirectly(world, x, y - 1, z, properties.DimensionalDoorID, metadata);
|
||||
}
|
||||
|
||||
private static void buildBox(World world, int centerX, int centerY, int centerZ, int radius, int blockID, boolean placeTnt, int nonTntWeight)
|
||||
{
|
||||
int x, y, z;
|
||||
|
||||
final int startX = centerX - radius;
|
||||
final int startY = centerY - radius;
|
||||
final int startZ = centerZ - radius;
|
||||
|
||||
final int endX = centerX + radius;
|
||||
final int endY = centerY + radius;
|
||||
final int endZ = centerZ + radius;
|
||||
|
||||
//Build faces of the box
|
||||
for (x = startX; x <= endX; x++)
|
||||
{
|
||||
for (z = startZ; z <= endZ; z++)
|
||||
{
|
||||
setBlockDirectlySpecial(world, x, startY, z, blockID, 0, placeTnt, nonTntWeight);
|
||||
setBlockDirectlySpecial(world, x, endY, z, blockID, 0, placeTnt, nonTntWeight);
|
||||
}
|
||||
|
||||
for (y = startY; y <= endY; y++)
|
||||
{
|
||||
setBlockDirectlySpecial(world, x, y, startZ, blockID, 0, placeTnt, nonTntWeight);
|
||||
setBlockDirectlySpecial(world, x, y, endZ, blockID, 0, placeTnt, nonTntWeight);
|
||||
}
|
||||
}
|
||||
|
||||
for (y = startY; y <= endY; y++)
|
||||
{
|
||||
for (z = startZ; z <= endZ; z++)
|
||||
{
|
||||
setBlockDirectlySpecial(world, startX, y, z, blockID, 0, placeTnt, nonTntWeight);
|
||||
setBlockDirectlySpecial(world, endX, y, z, blockID, 0, placeTnt, nonTntWeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setBlockDirectlySpecial(World world, int x, int y, int z, int blockID, int metadata, boolean placeTnt, int nonTntWeight)
|
||||
{
|
||||
if (placeTnt && random.nextInt(nonTntWeight + 1) == 0)
|
||||
{
|
||||
setBlockDirectly(world, x, y, z, Block.tnt.blockID, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
setBlockDirectly(world, x, y, z, blockID, metadata);
|
||||
}
|
||||
}
|
||||
|
||||
private static void setBlockDirectly(World world, int x, int y, int z, int blockID, int metadata)
|
||||
{
|
||||
if (blockID != 0 && Block.blocksList[blockID] == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int cX = x >> 4;
|
||||
int cZ = z >> 4;
|
||||
int cY = y >> 4;
|
||||
Chunk chunk;
|
||||
|
||||
int localX = (x % 16) < 0 ? (x % 16) + 16 : (x % 16);
|
||||
int localZ = (z % 16) < 0 ? (z % 16) + 16 : (z % 16);
|
||||
ExtendedBlockStorage extBlockStorage;
|
||||
|
||||
chunk = world.getChunkFromChunkCoords(cX, cZ);
|
||||
extBlockStorage = chunk.getBlockStorageArray()[cY];
|
||||
if (extBlockStorage == null)
|
||||
{
|
||||
extBlockStorage = new ExtendedBlockStorage(cY << 4, !world.provider.hasNoSky);
|
||||
chunk.getBlockStorageArray()[cY] = extBlockStorage;
|
||||
}
|
||||
extBlockStorage.setExtBlockID(localX, y & 15, localZ, blockID);
|
||||
extBlockStorage.setExtBlockMetadata(localX, y & 15, localZ, metadata);
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,8 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.ChunkProviderGenerate;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.MonolithSpawner;
|
||||
|
||||
public class PocketGenerator extends ChunkProviderGenerate implements IChunkProvider
|
||||
@@ -69,16 +69,10 @@ public class PocketGenerator extends ChunkProviderGenerate implements IChunkProv
|
||||
@Override
|
||||
public List getPossibleCreatures(EnumCreatureType var1, int var2, int var3, int var4)
|
||||
{
|
||||
DimData data = dimHelper.instance.getDimData(this.worldObj.provider.dimensionId);
|
||||
if (data != null)
|
||||
NewDimData dimension = PocketManager.getDimensionData(this.worldObj);
|
||||
if (dimension != null && dimension.dungeon() != null && !dimension.dungeon().isOpen())
|
||||
{
|
||||
if (data.dungeonGenerator != null)
|
||||
{
|
||||
if (data.isDimRandomRift && data.isPocket && !data.dungeonGenerator.isOpen)
|
||||
{
|
||||
return this.worldObj.getBiomeGenForCoords(var2, var3).getSpawnableList(var1);
|
||||
}
|
||||
}
|
||||
return this.worldObj.getBiomeGenForCoords(var2, var3).getSpawnableList(var1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -6,10 +6,11 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.WorldProvider;
|
||||
import net.minecraft.world.biome.WorldChunkManagerHell;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.CloudRenderBlank;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.MonolithSpawner;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -113,12 +114,12 @@ public class PocketProvider extends WorldProvider
|
||||
}
|
||||
else
|
||||
{
|
||||
respawnDim = dimHelper.instance.getDimData(this.dimensionId).exitDimLink.destDimID;
|
||||
respawnDim = PocketManager.getDimensionData(this.dimensionId).root().id();
|
||||
}
|
||||
|
||||
if (dimHelper.getWorld(respawnDim) == null)
|
||||
if (DimensionManager.getWorld(respawnDim) == null)
|
||||
{
|
||||
dimHelper.initDimension(respawnDim);
|
||||
DimensionManager.initDimension(respawnDim);
|
||||
}
|
||||
return respawnDim;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package StevenDimDoors.mod_pocketDimClient;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
@@ -98,7 +98,7 @@ public class ClosingRiftFX extends EntityFX
|
||||
float var16 = .8F;
|
||||
try
|
||||
{
|
||||
if(dimHelper.instance.getDimData(this.worldObj.provider.dimensionId).isPocket)
|
||||
if(PocketManager.instance.getDimData(this.worldObj.provider.dimensionId).isPocket)
|
||||
{
|
||||
var16=.4F;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package StevenDimDoors.mod_pocketDimClient;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.particle.EntityFireworkSparkFX;
|
||||
@@ -55,7 +55,7 @@ public class GoggleRiftFX extends EntityFireworkSparkFX
|
||||
float var16 = .0F;
|
||||
try
|
||||
{
|
||||
if(dimHelper.instance.getDimData(this.worldObj.provider.dimensionId).isPocket)
|
||||
if(PocketManager.instance.getDimData(this.worldObj.provider.dimensionId).isPocket)
|
||||
{
|
||||
var16=.7F;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package StevenDimDoors.mod_pocketDimClient;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.particle.EntityFireworkSparkFX;
|
||||
@@ -112,7 +112,7 @@ public class RiftFX extends EntityFX
|
||||
|
||||
try
|
||||
{
|
||||
if(dimHelper.instance.getDimData(this.worldObj.provider.dimensionId).isPocket)
|
||||
if(PocketManager.instance.getDimData(this.worldObj.provider.dimensionId).isPocket)
|
||||
{
|
||||
f14=.7F;
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user