Fixed Unstable Doors

Added code so that the links for Unstable Doors are handled properly by
DDTeleporter. Hurray! Also cleaned up some unused imports in the
BiomeGen classes and removed the RANDOM_DUNGEON link type - it was meant
for the dd-rift command but there is no need for it anymore.
This commit is contained in:
SenseiKiwi 2013-09-05 18:13:05 -04:00
parent 1dfa5817bf
commit 3ce380ad5e
4 changed files with 52 additions and 9 deletions

View file

@ -1,5 +1,6 @@
package StevenDimDoors.mod_pocketDim.core;
import java.util.ArrayList;
import java.util.Random;
import net.minecraft.entity.Entity;
@ -344,8 +345,20 @@ public class DDTeleporter
return;
}
entity = teleportEntity(entity, link.destination());
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
if (link.linkType() == LinkTypes.RANDOM)
{
Point4D randomDestination = getRandomDestination();
if (randomDestination != null)
{
entity = teleportEntity(entity, randomDestination);
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
}
}
else
{
entity = teleportEntity(entity, link.destination());
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
}
}
private static boolean initializeDestination(DimLink link, DDProperties properties)
@ -366,9 +379,45 @@ public class DDTeleporter
case LinkTypes.POCKET:
return PocketBuilder.generateNewPocket(link, properties);
case LinkTypes.NORMAL:
case LinkTypes.RANDOM:
return true;
default:
throw new IllegalArgumentException("link has an unrecognized link type.");
}
}
private static Point4D getRandomDestination()
{
// Our aim is to return a point near a random link's source
// so that a link of type RANDOM can teleport a player there.
// Restrictions:
// 1. Ignore links with their source inside a pocket dimension.
// 2. Ignore links with link type RANDOM.
ArrayList<Point4D> matches = new ArrayList<Point4D>();
for (NewDimData dimension : PocketManager.getDimensions())
{
if (!dimension.isPocketDimension())
{
for (DimLink link : dimension.getAllLinks())
{
if (link.linkType() != LinkTypes.RANDOM)
{
matches.add(link.source());
}
}
}
}
// Pick a random point, if any is available
if (!matches.isEmpty())
{
return matches.get( random.nextInt(matches.size()) );
}
else
{
return null;
}
}
}

View file

@ -5,7 +5,7 @@ public class LinkTypes
private LinkTypes() { }
public static final int ENUM_MIN = 0;
public static final int ENUM_MAX = 7;
public static final int ENUM_MAX = 6;
public static final int CLIENT_SIDE = -1337;
@ -17,5 +17,4 @@ public class LinkTypes
public static final int DUNGEON_EXIT = 4;
public static final int SAFE_EXIT = 5;
public static final int UNSAFE_EXIT = 6;
public static final int RANDOM_DUNGEON = 7;
}

View file

@ -1,9 +1,6 @@
package StevenDimDoors.mod_pocketDim.world;
import StevenDimDoors.mod_pocketDim.ticking.MobMonolith;
import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.SpawnListEntry;
public class BiomeGenLimbo extends BiomeGenBase
{

View file

@ -1,8 +1,6 @@
package StevenDimDoors.mod_pocketDim.world;
import StevenDimDoors.mod_pocketDim.ticking.MobMonolith;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.SpawnListEntry;
public class BiomeGenPocket extends BiomeGenBase
{