Rewrite Continued #84
@@ -1,5 +1,6 @@
|
|||||||
package StevenDimDoors.mod_pocketDim.core;
|
package StevenDimDoors.mod_pocketDim.core;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
@@ -344,8 +345,20 @@ public class DDTeleporter
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity = teleportEntity(entity, link.destination());
|
if (link.linkType() == LinkTypes.RANDOM)
|
||||||
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
|
{
|
||||||
|
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)
|
private static boolean initializeDestination(DimLink link, DDProperties properties)
|
||||||
@@ -366,9 +379,45 @@ public class DDTeleporter
|
|||||||
case LinkTypes.POCKET:
|
case LinkTypes.POCKET:
|
||||||
return PocketBuilder.generateNewPocket(link, properties);
|
return PocketBuilder.generateNewPocket(link, properties);
|
||||||
case LinkTypes.NORMAL:
|
case LinkTypes.NORMAL:
|
||||||
|
case LinkTypes.RANDOM:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("link has an unrecognized link type.");
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ public class LinkTypes
|
|||||||
private LinkTypes() { }
|
private LinkTypes() { }
|
||||||
|
|
||||||
public static final int ENUM_MIN = 0;
|
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;
|
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 DUNGEON_EXIT = 4;
|
||||||
public static final int SAFE_EXIT = 5;
|
public static final int SAFE_EXIT = 5;
|
||||||
public static final int UNSAFE_EXIT = 6;
|
public static final int UNSAFE_EXIT = 6;
|
||||||
public static final int RANDOM_DUNGEON = 7;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package StevenDimDoors.mod_pocketDim.world;
|
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.BiomeGenBase;
|
||||||
import net.minecraft.world.biome.SpawnListEntry;
|
|
||||||
|
|
||||||
public class BiomeGenLimbo extends BiomeGenBase
|
public class BiomeGenLimbo extends BiomeGenBase
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package StevenDimDoors.mod_pocketDim.world;
|
package StevenDimDoors.mod_pocketDim.world;
|
||||||
|
|
||||||
import StevenDimDoors.mod_pocketDim.ticking.MobMonolith;
|
|
||||||
import net.minecraft.world.biome.BiomeGenBase;
|
import net.minecraft.world.biome.BiomeGenBase;
|
||||||
import net.minecraft.world.biome.SpawnListEntry;
|
|
||||||
|
|
||||||
public class BiomeGenPocket extends BiomeGenBase
|
public class BiomeGenPocket extends BiomeGenBase
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user