Fixed Bugs in Golden Dimensional Doors #167

Merged
SenseiKiwi merged 4 commits from master into master 2014-07-02 18:21:38 +00:00
3 changed files with 34 additions and 6 deletions
Showing only changes of commit b2e086e7c1 - Show all commits

View File

@@ -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;
@@ -33,11 +35,20 @@ public class EventHookContainer
private static final int MAX_FOOD_LEVEL = 20; 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)
@@ -134,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);
@@ -156,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);
@@ -171,6 +182,17 @@ 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)
{ {

View File

@@ -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();
} }

View 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;
@@ -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");