Fixed Bugs in Golden Dimensional Doors #167
@@ -15,7 +15,7 @@ apply plugin: 'forge'
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
version = "2.2.3-" + System.getenv("BUILD_NUMBER")
|
version = "2.2.4-" + System.getenv("BUILD_NUMBER")
|
||||||
group= "com.stevenrs11.dimdoors" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
group= "com.stevenrs11.dimdoors" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
archivesBaseName = "DimensionalDoors"
|
archivesBaseName = "DimensionalDoors"
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||||||
import net.minecraft.item.ItemDoor;
|
import net.minecraft.item.ItemDoor;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.WorldProvider;
|
||||||
import net.minecraftforge.client.event.sound.PlayBackgroundMusicEvent;
|
import net.minecraftforge.client.event.sound.PlayBackgroundMusicEvent;
|
||||||
import net.minecraftforge.client.event.sound.SoundLoadEvent;
|
import net.minecraftforge.client.event.sound.SoundLoadEvent;
|
||||||
import net.minecraftforge.event.EventPriority;
|
import net.minecraftforge.event.EventPriority;
|
||||||
@@ -18,6 +19,7 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
|
|||||||
import net.minecraftforge.event.terraingen.InitMapGenEvent;
|
import net.minecraftforge.event.terraingen.InitMapGenEvent;
|
||||||
import net.minecraftforge.event.world.WorldEvent;
|
import net.minecraftforge.event.world.WorldEvent;
|
||||||
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
||||||
|
import StevenDimDoors.mod_pocketDim.config.DDWorldProperties;
|
||||||
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
|
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
|
||||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
|
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
|
||||||
@@ -30,12 +32,23 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||||||
|
|
||||||
public class EventHookContainer
|
public class EventHookContainer
|
||||||
{
|
{
|
||||||
|
private static final int MAX_FOOD_LEVEL = 20;
|
||||||
|
|
||||||
private final DDProperties properties;
|
private final DDProperties properties;
|
||||||
|
private DDWorldProperties worldProperties;
|
||||||
|
|
||||||
public EventHookContainer(DDProperties properties)
|
public EventHookContainer(DDProperties properties)
|
||||||
{
|
{
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setWorldProperties(DDWorldProperties worldProperties)
|
||||||
|
{
|
||||||
|
// SenseiKiwi:
|
||||||
|
// Why have a setter rather than accessing mod_pocketDim.worldProperties?
|
||||||
|
// I want to make this dependency explicit in our code.
|
||||||
|
this.worldProperties = worldProperties;
|
||||||
|
}
|
||||||
|
|
||||||
@ForgeSubscribe(priority = EventPriority.LOW)
|
@ForgeSubscribe(priority = EventPriority.LOW)
|
||||||
public void onInitMapGen(InitMapGenEvent event)
|
public void onInitMapGen(InitMapGenEvent event)
|
||||||
@@ -132,7 +145,7 @@ public class EventHookContainer
|
|||||||
Entity entity = event.entity;
|
Entity entity = event.entity;
|
||||||
|
|
||||||
if (properties.LimboEnabled && properties.LimboReturnsInventoryEnabled &&
|
if (properties.LimboEnabled && properties.LimboReturnsInventoryEnabled &&
|
||||||
entity instanceof EntityPlayer && entity.worldObj.provider instanceof PocketProvider)
|
entity instanceof EntityPlayer && isValidSourceForLimbo(entity.worldObj.provider))
|
||||||
{
|
{
|
||||||
EntityPlayer player = (EntityPlayer) entity;
|
EntityPlayer player = (EntityPlayer) entity;
|
||||||
mod_pocketDim.deathTracker.addUsername(player.username);
|
mod_pocketDim.deathTracker.addUsername(player.username);
|
||||||
@@ -154,7 +167,7 @@ public class EventHookContainer
|
|||||||
|
|
||||||
Entity entity = event.entity;
|
Entity entity = event.entity;
|
||||||
|
|
||||||
if (entity instanceof EntityPlayer && entity.worldObj.provider instanceof PocketProvider)
|
if (entity instanceof EntityPlayer && isValidSourceForLimbo(entity.worldObj.provider))
|
||||||
{
|
{
|
||||||
EntityPlayer player = (EntityPlayer) entity;
|
EntityPlayer player = (EntityPlayer) entity;
|
||||||
mod_pocketDim.deathTracker.addUsername(player.username);
|
mod_pocketDim.deathTracker.addUsername(player.username);
|
||||||
@@ -169,12 +182,24 @@ public class EventHookContainer
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isValidSourceForLimbo(WorldProvider provider)
|
||||||
|
{
|
||||||
|
// Returns whether a given world is a valid place for sending a player
|
||||||
|
// to Limbo. We can send someone to Limbo from a certain dimension if
|
||||||
|
// Universal Limbo is enabled and the source dimension is not Limbo, or
|
||||||
|
// if the source dimension is a pocket dimension.
|
||||||
|
|
||||||
|
return (worldProperties.UniversalLimboEnabled && provider.dimensionId != properties.LimboDimensionID) ||
|
||||||
|
(provider instanceof PocketProvider);
|
||||||
|
}
|
||||||
|
|
||||||
private void revivePlayerInLimbo(EntityPlayer player)
|
private void revivePlayerInLimbo(EntityPlayer player)
|
||||||
{
|
{
|
||||||
player.extinguish();
|
player.extinguish();
|
||||||
player.clearActivePotions();
|
player.clearActivePotions();
|
||||||
player.setHealth(player.getMaxHealth());
|
player.setHealth(player.getMaxHealth());
|
||||||
|
player.getFoodStats().addStats(MAX_FOOD_LEVEL, 0);
|
||||||
Point4D destination = LimboProvider.getLimboSkySpawn(player, properties);
|
Point4D destination = LimboProvider.getLimboSkySpawn(player, properties);
|
||||||
DDTeleporter.teleportEntity(player, destination, false);
|
DDTeleporter.teleportEntity(player, destination, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,5 +4,6 @@ import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
|||||||
|
|
||||||
public interface IChunkLoader
|
public interface IChunkLoader
|
||||||
{
|
{
|
||||||
public void forceChunkLoading(Ticket ticket,int x, int z);
|
public boolean isInitialized();
|
||||||
|
public void initialize(Ticket ticket);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ public class DDWorldProperties
|
|||||||
/**
|
/**
|
||||||
* World Generation Settings
|
* World Generation Settings
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public final DimensionFilter RiftClusterDimensions;
|
public final DimensionFilter RiftClusterDimensions;
|
||||||
public final DimensionFilter RiftGatewayDimensions;
|
public final DimensionFilter RiftGatewayDimensions;
|
||||||
|
|
||||||
@@ -17,7 +16,7 @@ public class DDWorldProperties
|
|||||||
* General Flags
|
* General Flags
|
||||||
*/
|
*/
|
||||||
public final boolean LimboEscapeEnabled;
|
public final boolean LimboEscapeEnabled;
|
||||||
|
public final boolean UniversalLimboEnabled;
|
||||||
|
|
||||||
//Names of categories
|
//Names of categories
|
||||||
private static final String CATEGORY_WORLD_GENERATION = "world generation";
|
private static final String CATEGORY_WORLD_GENERATION = "world generation";
|
||||||
@@ -44,6 +43,12 @@ public class DDWorldProperties
|
|||||||
"generates near the bottom of the dimension. If disabled, players could still leave through " +
|
"generates near the bottom of the dimension. If disabled, players could still leave through " +
|
||||||
"dungeons in Limbo or by dying (if Hardcore Limbo is disabled). The default value is true.").getBoolean(true);
|
"dungeons in Limbo or by dying (if Hardcore Limbo is disabled). The default value is true.").getBoolean(true);
|
||||||
|
|
||||||
|
UniversalLimboEnabled = config.get(Configuration.CATEGORY_GENERAL, "Enable Universal Limbo", false,
|
||||||
|
"Sets whether players are teleported to Limbo when they die in any dimension (except Limbo). " +
|
||||||
|
"Normally, players only go to Limbo if they die in a pocket dimension. This setting will not " +
|
||||||
|
"affect deaths in Limbo, which can be set with the Hardcore Limbo option. " +
|
||||||
|
"The default value is false.").getBoolean(false);
|
||||||
|
|
||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,54 +1,98 @@
|
|||||||
package StevenDimDoors.mod_pocketDim.helpers;
|
package StevenDimDoors.mod_pocketDim.helpers;
|
||||||
|
|
||||||
import StevenDimDoors.mod_pocketDim.IChunkLoader;
|
|
||||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
|
||||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
|
||||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.world.ChunkCoordIntPair;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import net.minecraftforge.common.ForgeChunkManager;
|
import net.minecraftforge.common.ForgeChunkManager;
|
||||||
import net.minecraftforge.common.ForgeChunkManager.LoadingCallback;
|
import net.minecraftforge.common.ForgeChunkManager.LoadingCallback;
|
||||||
import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
||||||
|
import net.minecraftforge.common.ForgeChunkManager.Type;
|
||||||
|
import StevenDimDoors.experimental.BoundingBox;
|
||||||
|
import StevenDimDoors.mod_pocketDim.IChunkLoader;
|
||||||
|
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||||
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
|
import StevenDimDoors.mod_pocketDim.world.PocketBuilder;
|
||||||
|
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||||
|
|
||||||
public class ChunkLoaderHelper implements LoadingCallback
|
public class ChunkLoaderHelper implements LoadingCallback
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ticketsLoaded(List<Ticket> tickets, World world)
|
public void ticketsLoaded(List<Ticket> tickets, World world)
|
||||||
{
|
{
|
||||||
for (Ticket ticket : tickets)
|
for (Ticket ticket : tickets)
|
||||||
{
|
{
|
||||||
int goldDimDoorX = ticket.getModData().getInteger("goldDimDoorX");
|
boolean loaded = false;
|
||||||
int goldDimDoorY = ticket.getModData().getInteger("goldDimDoorY");
|
int x = ticket.getModData().getInteger("goldDimDoorX");
|
||||||
int goldDimDoorZ = ticket.getModData().getInteger("goldDimDoorZ");
|
int y = ticket.getModData().getInteger("goldDimDoorY");
|
||||||
if(world.getBlockId(goldDimDoorX, goldDimDoorY, goldDimDoorZ) != mod_pocketDim.properties.GoldenDimensionalDoorID)
|
int z = ticket.getModData().getInteger("goldDimDoorZ");
|
||||||
|
|
||||||
|
if (world.getBlockId(x, y, z) == mod_pocketDim.properties.GoldenDimensionalDoorID)
|
||||||
|
{
|
||||||
|
IChunkLoader loader = (IChunkLoader) world.getBlockTileEntity(x, y, z);
|
||||||
|
if (!loader.isInitialized())
|
||||||
|
{
|
||||||
|
loader.initialize(ticket);
|
||||||
|
loaded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!loaded)
|
||||||
{
|
{
|
||||||
ForgeChunkManager.releaseTicket(ticket);
|
ForgeChunkManager.releaseTicket(ticket);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Ticket createTicket(int x, int y, int z, World world)
|
||||||
|
{
|
||||||
|
NBTTagCompound data;
|
||||||
|
Ticket ticket = ForgeChunkManager.requestTicket(mod_pocketDim.instance, world, Type.NORMAL);
|
||||||
|
if (ticket != null)
|
||||||
|
{
|
||||||
|
data = ticket.getModData();
|
||||||
|
data.setInteger("goldDimDoorX", x);
|
||||||
|
data.setInteger("goldDimDoorY", y);
|
||||||
|
data.setInteger("goldDimDoorZ", z);
|
||||||
|
}
|
||||||
|
return ticket;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void forcePocketChunks(NewDimData pocket, Ticket ticket)
|
||||||
|
{
|
||||||
|
BoundingBox bounds = PocketBuilder.calculateDefaultBounds(pocket);
|
||||||
|
Point3D minCorner = bounds.minCorner();
|
||||||
|
Point3D maxCorner = bounds.maxCorner();
|
||||||
|
int minX = minCorner.getX() >> 4;
|
||||||
|
int minZ = minCorner.getZ() >> 4;
|
||||||
|
int maxX = maxCorner.getX() >> 4;
|
||||||
|
int maxZ = maxCorner.getZ() >> 4;
|
||||||
|
int chunkX;
|
||||||
|
int chunkZ;
|
||||||
|
|
||||||
|
for (chunkX = minX; chunkX <= maxX; chunkX++)
|
||||||
|
{
|
||||||
|
for (chunkZ = minZ; chunkZ <= maxZ; chunkZ++)
|
||||||
{
|
{
|
||||||
IChunkLoader tile = (IChunkLoader) world.getBlockTileEntity(goldDimDoorX, goldDimDoorY, goldDimDoorZ);
|
ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(chunkX, chunkZ));
|
||||||
tile.forceChunkLoading(ticket,goldDimDoorX,goldDimDoorZ);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadChunkForcedWorlds(FMLServerStartingEvent event)
|
public static void loadChunkForcedWorlds(FMLServerStartingEvent event)
|
||||||
{
|
{
|
||||||
for(NewDimData data : PocketManager.getDimensions())
|
for (NewDimData data : PocketManager.getDimensions())
|
||||||
{
|
{
|
||||||
if(data.isPocketDimension())
|
if(data.isPocketDimension())
|
||||||
{
|
{
|
||||||
String chunkDir = DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoors/pocketDimID" + data.id();
|
String chunkDir = DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoors/pocketDimID" + data.id();
|
||||||
|
|
||||||
File file = new File(chunkDir);
|
File file = new File(chunkDir);
|
||||||
|
|
||||||
if(file.exists())
|
if(file.exists())
|
||||||
{
|
{
|
||||||
if(ForgeChunkManager.savedWorldHasForcedChunkTickets(file))
|
if(ForgeChunkManager.savedWorldHasForcedChunkTickets(file))
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
|
|||||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoorGold;
|
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoorGold;
|
||||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityRift;
|
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityRift;
|
||||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityTransTrapdoor;
|
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityTransTrapdoor;
|
||||||
import StevenDimDoors.mod_pocketDim.util.DDLogger;
|
|
||||||
import StevenDimDoors.mod_pocketDim.world.BiomeGenLimbo;
|
import StevenDimDoors.mod_pocketDim.world.BiomeGenLimbo;
|
||||||
import StevenDimDoors.mod_pocketDim.world.BiomeGenPocket;
|
import StevenDimDoors.mod_pocketDim.world.BiomeGenPocket;
|
||||||
import StevenDimDoors.mod_pocketDim.world.DDBiomeGenBase;
|
import StevenDimDoors.mod_pocketDim.world.DDBiomeGenBase;
|
||||||
@@ -99,7 +98,7 @@ serverPacketHandlerSpec =
|
|||||||
@SidedPacketHandler(channels = {PacketConstants.CHANNEL_NAME}, packetHandler = ServerPacketHandler.class))
|
@SidedPacketHandler(channels = {PacketConstants.CHANNEL_NAME}, packetHandler = ServerPacketHandler.class))
|
||||||
public class mod_pocketDim
|
public class mod_pocketDim
|
||||||
{
|
{
|
||||||
public static final String version = "1.6.4-R2.2.3";
|
public static final String version = "1.6.4-R2.2.4";
|
||||||
public static final String modid = "dimdoors";
|
public static final String modid = "dimdoors";
|
||||||
|
|
||||||
//TODO need a place to stick all these constants
|
//TODO need a place to stick all these constants
|
||||||
@@ -148,6 +147,7 @@ public class mod_pocketDim
|
|||||||
public static FastRiftRegenerator fastRiftRegenerator;
|
public static FastRiftRegenerator fastRiftRegenerator;
|
||||||
public static GatewayGenerator gatewayGenerator;
|
public static GatewayGenerator gatewayGenerator;
|
||||||
public static DeathTracker deathTracker;
|
public static DeathTracker deathTracker;
|
||||||
|
private static EventHookContainer hooks;
|
||||||
|
|
||||||
//TODO this is a temporary workaround for saving data
|
//TODO this is a temporary workaround for saving data
|
||||||
private String currrentSaveRootDirectory;
|
private String currrentSaveRootDirectory;
|
||||||
@@ -177,7 +177,7 @@ public class mod_pocketDim
|
|||||||
properties = DDProperties.initialize(new File(path));
|
properties = DDProperties.initialize(new File(path));
|
||||||
|
|
||||||
//Now do other stuff
|
//Now do other stuff
|
||||||
EventHookContainer hooks = new EventHookContainer(properties);
|
hooks = new EventHookContainer(properties);
|
||||||
MinecraftForge.EVENT_BUS.register(hooks);
|
MinecraftForge.EVENT_BUS.register(hooks);
|
||||||
MinecraftForge.TERRAIN_GEN_BUS.register(hooks);
|
MinecraftForge.TERRAIN_GEN_BUS.register(hooks);
|
||||||
}
|
}
|
||||||
@@ -336,6 +336,7 @@ public class mod_pocketDim
|
|||||||
|
|
||||||
// Load the config file that's specific to this world
|
// Load the config file that's specific to this world
|
||||||
worldProperties = new DDWorldProperties(new File(currrentSaveRootDirectory + "/DimensionalDoors/DimDoorsWorld.cfg"));
|
worldProperties = new DDWorldProperties(new File(currrentSaveRootDirectory + "/DimensionalDoors/DimDoorsWorld.cfg"));
|
||||||
|
hooks.setWorldProperties(worldProperties);
|
||||||
|
|
||||||
// Initialize a new DeathTracker
|
// Initialize a new DeathTracker
|
||||||
deathTracker = new DeathTracker(currrentSaveRootDirectory + "/DimensionalDoors/data/deaths.txt");
|
deathTracker = new DeathTracker(currrentSaveRootDirectory + "/DimensionalDoors/data/deaths.txt");
|
||||||
|
|||||||
@@ -1,85 +1,93 @@
|
|||||||
package StevenDimDoors.mod_pocketDim.tileentities;
|
package StevenDimDoors.mod_pocketDim.tileentities;
|
||||||
|
|
||||||
import net.minecraft.world.ChunkCoordIntPair;
|
|
||||||
import net.minecraftforge.common.ForgeChunkManager;
|
import net.minecraftforge.common.ForgeChunkManager;
|
||||||
import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
||||||
import net.minecraftforge.common.ForgeChunkManager.Type;
|
|
||||||
import StevenDimDoors.mod_pocketDim.IChunkLoader;
|
import StevenDimDoors.mod_pocketDim.IChunkLoader;
|
||||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
import StevenDimDoors.mod_pocketDim.helpers.ChunkLoaderHelper;
|
||||||
import StevenDimDoors.mod_pocketDim.world.PocketBuilder;
|
import StevenDimDoors.mod_pocketDim.world.PocketBuilder;
|
||||||
|
|
||||||
public class TileEntityDimDoorGold extends TileEntityDimDoor implements IChunkLoader
|
public class TileEntityDimDoorGold extends TileEntityDimDoor implements IChunkLoader
|
||||||
{
|
{
|
||||||
private Ticket chunkTicket;
|
private Ticket chunkTicket;
|
||||||
|
private boolean initialized = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canUpdate()
|
public boolean canUpdate()
|
||||||
{
|
{
|
||||||
return true;
|
return !initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInitialized()
|
||||||
|
{
|
||||||
|
return initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity()
|
public void updateEntity()
|
||||||
{ // every tick?
|
{
|
||||||
if (PocketManager.getDimensionData(this.worldObj) != null &&
|
if (!initialized)
|
||||||
PocketManager.getDimensionData(this.worldObj).isPocketDimension() &&
|
{
|
||||||
!this.worldObj.isRemote)
|
initialize(null);
|
||||||
{
|
}
|
||||||
if(PocketManager.getLink(this.xCoord,this.yCoord,this.zCoord,this.worldObj)==null)
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(Ticket ticket)
|
||||||
|
{
|
||||||
|
initialized = true;
|
||||||
|
chunkTicket = ticket;
|
||||||
|
|
||||||
|
// Only do anything if this function is running on the server side
|
||||||
|
// NOTE: We don't have to check whether this block is the upper door
|
||||||
|
// block or the lower one because only one of them should have a
|
||||||
|
// link associated with it.
|
||||||
|
if (!worldObj.isRemote)
|
||||||
|
{
|
||||||
|
NewDimData dimension = PocketManager.getDimensionData(worldObj);
|
||||||
|
|
||||||
|
// Check whether a ticket has already been assigned to this door
|
||||||
|
if (chunkTicket == null)
|
||||||
{
|
{
|
||||||
return;
|
// No ticket yet.
|
||||||
}
|
// Check if this area should be loaded and request a new ticket.
|
||||||
if (this.chunkTicket == null)
|
if (isValidChunkLoaderSetup(dimension))
|
||||||
{
|
|
||||||
chunkTicket = ForgeChunkManager.requestTicket(mod_pocketDim.instance, worldObj, Type.NORMAL);
|
|
||||||
if(chunkTicket == null)
|
|
||||||
{
|
{
|
||||||
return;
|
chunkTicket = ChunkLoaderHelper.createTicket(xCoord, yCoord, zCoord, worldObj);
|
||||||
}
|
}
|
||||||
chunkTicket.getModData().setInteger("goldDimDoorX", xCoord);
|
}
|
||||||
chunkTicket.getModData().setInteger("goldDimDoorY", yCoord);
|
else
|
||||||
chunkTicket.getModData().setInteger("goldDimDoorZ", zCoord);
|
{
|
||||||
forceChunkLoading(chunkTicket,this.xCoord,this.zCoord);
|
// A ticket has already been provided.
|
||||||
|
// Check if this area should be loaded. If not, release the ticket.
|
||||||
|
if (!isValidChunkLoaderSetup(dimension))
|
||||||
|
{
|
||||||
|
ForgeChunkManager.releaseTicket(chunkTicket);
|
||||||
|
chunkTicket = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If chunkTicket isn't null at this point, then this is a valid door setup.
|
||||||
|
// The last step is to request force loading of the pocket's chunks.
|
||||||
|
if (chunkTicket != null)
|
||||||
|
{
|
||||||
|
ChunkLoaderHelper.forcePocketChunks(dimension, chunkTicket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private boolean isValidChunkLoaderSetup(NewDimData dimension)
|
||||||
public void forceChunkLoading(Ticket chunkTicket,int x,int z)
|
|
||||||
{
|
{
|
||||||
Point4D origin = PocketManager.getDimensionData(this.worldObj).origin();
|
// Check the various conditions that make this a valid door setup.
|
||||||
int orientation = PocketManager.getDimensionData(this.worldObj).orientation();
|
// 1. The door must be inside the pocket's XZ boundaries,
|
||||||
|
// to prevent loading of chunks with a distant door
|
||||||
|
// 2. The dimension must be a pocket dimension
|
||||||
|
// 3. The door must be linked so that it's clear that it's not a normal door
|
||||||
|
|
||||||
int xOffset=0;
|
return (dimension.isPocketDimension() && dimension.getLink(xCoord, yCoord, zCoord) != null &&
|
||||||
int zOffset=0;
|
PocketBuilder.calculateDefaultBounds(dimension).contains(xCoord, yCoord, zCoord));
|
||||||
|
|
||||||
switch(orientation)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
xOffset = PocketBuilder.DEFAULT_POCKET_SIZE/2;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
zOffset = PocketBuilder.DEFAULT_POCKET_SIZE/2;
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
xOffset = -PocketBuilder.DEFAULT_POCKET_SIZE/2;
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
zOffset = -PocketBuilder.DEFAULT_POCKET_SIZE/2;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
for(int chunkX = -2; chunkX<3;chunkX++)
|
|
||||||
{
|
|
||||||
for(int chunkZ = -2; chunkZ<3;chunkZ++)
|
|
||||||
{
|
|
||||||
ForgeChunkManager.forceChunk(chunkTicket, new ChunkCoordIntPair((origin.getX()+xOffset >> 4)+chunkX, (origin.getZ()+zOffset >> 4)+chunkZ));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import net.minecraft.world.World;
|
|||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import StevenDimDoors.experimental.MazeBuilder;
|
import StevenDimDoors.experimental.BoundingBox;
|
||||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||||
import StevenDimDoors.mod_pocketDim.blocks.IDimDoor;
|
import StevenDimDoors.mod_pocketDim.blocks.IDimDoor;
|
||||||
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
||||||
@@ -21,13 +21,13 @@ import StevenDimDoors.mod_pocketDim.dungeon.DungeonSchematic;
|
|||||||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPackConfig;
|
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPackConfig;
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||||
|
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
|
||||||
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
||||||
import StevenDimDoors.mod_pocketDim.util.Pair;
|
import StevenDimDoors.mod_pocketDim.util.Pair;
|
||||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||||
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
|
|
||||||
|
|
||||||
public class PocketBuilder
|
public class PocketBuilder
|
||||||
{
|
{
|
||||||
public static final int MIN_POCKET_SIZE = 5;
|
public static final int MIN_POCKET_SIZE = 5;
|
||||||
public static final int MAX_POCKET_SIZE = 51;
|
public static final int MAX_POCKET_SIZE = 51;
|
||||||
public static final int DEFAULT_POCKET_SIZE = 39;
|
public static final int DEFAULT_POCKET_SIZE = 39;
|
||||||
@@ -559,4 +559,39 @@ public class PocketBuilder
|
|||||||
extBlockStorage.setExtBlockMetadata(localX, y & 15, localZ, metadata);
|
extBlockStorage.setExtBlockMetadata(localX, y & 15, localZ, metadata);
|
||||||
chunk.setChunkModified();
|
chunk.setChunkModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static BoundingBox calculateDefaultBounds(NewDimData pocket)
|
||||||
|
{
|
||||||
|
// Calculate the XZ bounds of this pocket assuming that it has the default size
|
||||||
|
// The Y bounds will be set to encompass the height of a chunk.
|
||||||
|
|
||||||
|
int minX = 0;
|
||||||
|
int minZ = 0;
|
||||||
|
Point4D origin = pocket.origin();
|
||||||
|
int orientation = pocket.orientation();
|
||||||
|
if (orientation < 0 || orientation > 3)
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("pocket has an invalid orientation value.");
|
||||||
|
}
|
||||||
|
switch (orientation)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
minX = origin.getX() - DEFAULT_POCKET_WALL_THICKNESS + 1;
|
||||||
|
minZ = origin.getZ() - DEFAULT_POCKET_SIZE / 2;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
minX = origin.getX() - DEFAULT_POCKET_SIZE / 2;
|
||||||
|
minZ = origin.getZ() - DEFAULT_POCKET_WALL_THICKNESS + 1;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
minX = origin.getX() + DEFAULT_POCKET_WALL_THICKNESS - DEFAULT_POCKET_SIZE;
|
||||||
|
minZ = origin.getZ() - DEFAULT_POCKET_SIZE / 2;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
minX = origin.getX() - DEFAULT_POCKET_SIZE / 2;
|
||||||
|
minZ = origin.getZ() + DEFAULT_POCKET_WALL_THICKNESS - DEFAULT_POCKET_SIZE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return new BoundingBox(minX, 0, minZ, DEFAULT_POCKET_SIZE, 255, DEFAULT_POCKET_SIZE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"modid": "dimdoors",
|
"modid": "dimdoors",
|
||||||
"name": "Dimensional Doors",
|
"name": "Dimensional Doors",
|
||||||
"description": "Bend and twist reality itself, creating pocket dimensions, rifts, and much more",
|
"description": "Bend and twist reality itself, creating pocket dimensions, rifts, and much more",
|
||||||
"version": "1.6.4-R2.2.3",
|
"version": "1.6.4-R2.2.4",
|
||||||
"credits": "Created by StevenRS11, Coded by StevenRS11 and SenseiKiwi, Logo and Testing by Jaitsu",
|
"credits": "Created by StevenRS11, Coded by StevenRS11 and SenseiKiwi, Logo and Testing by Jaitsu",
|
||||||
"logoFile": "/dimdoors_logo.png",
|
"logoFile": "/dimdoors_logo.png",
|
||||||
"mcversion": "",
|
"mcversion": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user