THE UPDATE
Merging months of dev work into master. The update is playable, but untested.
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
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 BlankTeleporter extends Teleporter
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import StevenDimDoors.mod_pocketDimClient.ClientTickHandler;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
@@ -47,7 +44,6 @@ public class CommonProxy implements IGuiHandler
|
||||
public void writeNBTToFile(World world)
|
||||
{
|
||||
boolean flag = true;
|
||||
boolean secondTry = false;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -58,7 +54,6 @@ public class CommonProxy implements IGuiHandler
|
||||
if (!flag)
|
||||
{
|
||||
dirFolder.replace("saves/", FMLCommonHandler.instance().getMinecraftServerInstance().getFolderName());
|
||||
secondTry = true;
|
||||
}
|
||||
|
||||
File file = new File(dirFolder, "GGMData.dat");
|
||||
@@ -91,7 +86,6 @@ public class CommonProxy implements IGuiHandler
|
||||
public void readNBTFromFile(World world)
|
||||
{
|
||||
boolean flag = true;
|
||||
boolean secondTry = false;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -102,7 +96,6 @@ public class CommonProxy implements IGuiHandler
|
||||
if (!flag)
|
||||
{
|
||||
dirFolder.replace("saves/", FMLCommonHandler.instance().getMinecraftServerInstance().getFolderName());
|
||||
secondTry = true;
|
||||
}
|
||||
|
||||
File file = new File(dirFolder, "GGMData.dat");
|
||||
@@ -117,12 +110,9 @@ public class CommonProxy implements IGuiHandler
|
||||
fileoutputstream.close();
|
||||
}
|
||||
|
||||
FileInputStream fileinputstream = new FileInputStream(file);
|
||||
/*FileInputStream fileinputstream = new FileInputStream(file);
|
||||
NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(fileinputstream);
|
||||
|
||||
|
||||
|
||||
fileinputstream.close();
|
||||
fileinputstream.close();*/
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
||||
@@ -1,81 +1,60 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.NetLoginHandler;
|
||||
import net.minecraft.network.packet.NetHandler;
|
||||
import net.minecraft.network.packet.Packet1Login;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import cpw.mods.fml.common.network.IConnectionHandler;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
|
||||
public class ConnectionHandler implements IConnectionHandler
|
||||
public class ConnectionHandler implements IConnectionHandler
|
||||
{
|
||||
private static boolean connected = false;
|
||||
private static DDProperties properties = null;
|
||||
|
||||
//sends a packet to clients containing all the information about the dims and links. Lots of packets, actually.
|
||||
@Override
|
||||
public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager)
|
||||
public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager)
|
||||
{
|
||||
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));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionOpened(NetHandler netClientHandler, String server,int port, INetworkManager manager)
|
||||
{
|
||||
connected = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionOpened(NetHandler netClientHandler,MinecraftServer server, INetworkManager manager)
|
||||
{
|
||||
public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager) { }
|
||||
|
||||
}
|
||||
@Override
|
||||
public void connectionOpened(NetHandler netClientHandler,MinecraftServer server, INetworkManager manager) { }
|
||||
|
||||
@Override
|
||||
public void connectionClosed(INetworkManager manager)
|
||||
public void connectionClosed(INetworkManager manager) { }
|
||||
|
||||
@Override
|
||||
public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login) { }
|
||||
|
||||
@Override
|
||||
public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager)
|
||||
{
|
||||
if (connected)
|
||||
//Send information about all the registered dimensions and links to the client
|
||||
try
|
||||
{
|
||||
System.out.println("Clearing dim cache");
|
||||
dimHelper.instance.save();
|
||||
dimHelper.instance.unregsisterDims();
|
||||
dimHelper.dimList.clear();
|
||||
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
DataOutputStream writer = new DataOutputStream(buffer);
|
||||
writer.writeByte(PacketConstants.CLIENT_JOIN_PACKET_ID);
|
||||
PocketManager.writePacket(writer);
|
||||
writer.close();
|
||||
packet.channel = PacketConstants.CHANNEL_NAME;
|
||||
packet.data = buffer.toByteArray();
|
||||
packet.length = packet.data.length;
|
||||
manager.addToSendQueue(packet);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
//This shouldn't happen...
|
||||
e.printStackTrace();
|
||||
}
|
||||
connected = false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager,
|
||||
Packet1Login login)
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playerLoggedIn(Player player, NetHandler netHandler,
|
||||
INetworkManager manager)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class DDLoot {
|
||||
|
||||
addContent(properties.DimensionalDoorLootEnabled, items, mod_pocketDim.itemDimDoor.itemID, UNCOMMON_LOOT_WEIGHT);
|
||||
addContent(properties.WarpDoorLootEnabled, items, mod_pocketDim.itemExitDoor.itemID, UNCOMMON_LOOT_WEIGHT);
|
||||
addContent(properties.TransTrapdoorLootEnabled, items, mod_pocketDim.dimHatch.blockID, UNCOMMON_LOOT_WEIGHT);
|
||||
addContent(properties.TransTrapdoorLootEnabled, items, mod_pocketDim.transTrapdoor.blockID, UNCOMMON_LOOT_WEIGHT);
|
||||
addContent(properties.RiftSignatureLootEnabled, items, mod_pocketDim.itemLinkSignature.itemID, UNCOMMON_LOOT_WEIGHT);
|
||||
addContent(properties.StableFabricLootEnabled, items, mod_pocketDim.itemStableFabric.itemID, UNCOMMON_LOOT_WEIGHT);
|
||||
addContent(properties.RiftRemoverLootEnabled, items, mod_pocketDim.itemRiftRemover.itemID, UNCOMMON_LOOT_WEIGHT);
|
||||
@@ -78,9 +78,6 @@ public class DDLoot {
|
||||
//because the items in that category have strange weights that are incompatible with all other
|
||||
//chest categories.
|
||||
|
||||
//This function has a flaw. It treats items with the same item ID but different damage values as
|
||||
//the same item. For instance, it cannot distinguish between different types of wood. That shouldn't
|
||||
//matter for most chest loot, though. This could be fixed if we cared enough.
|
||||
Random random = new Random();
|
||||
HashMap<Integer, WeightedRandomChestContent> container = new HashMap<Integer, WeightedRandomChestContent>();
|
||||
|
||||
@@ -89,7 +86,9 @@ public class DDLoot {
|
||||
WeightedRandomChestContent[] items = ChestGenHooks.getItems(category, random);
|
||||
for (WeightedRandomChestContent item : items)
|
||||
{
|
||||
int id = item.theItemId.itemID;
|
||||
ItemStack stack = item.theItemId;
|
||||
int id = stack.itemID;
|
||||
int subtype = stack.getItem().getHasSubtypes() ? stack.getItemDamage() : 0;
|
||||
|
||||
//Correct the weights of Vanilla dungeon chests (DUNGEON_CHEST)
|
||||
//Comparing by String references is valid here since they should match!
|
||||
@@ -100,20 +99,25 @@ public class DDLoot {
|
||||
item.itemWeight /= DUNGEON_CHEST_WEIGHT_INFLATION;
|
||||
if (item.itemWeight == 0)
|
||||
item.itemWeight = 1;
|
||||
}
|
||||
if (!container.containsKey(id))
|
||||
}
|
||||
|
||||
//Generate an identifier for this item using its item ID and damage value,
|
||||
//if it has subtypes. This solves the issue of matching items that have
|
||||
//the same item ID but different subtypes (e.g. wood planks, dyes).
|
||||
int key = ((subtype & 0xFFFF) << 16) + ((id & 0xFFFF) << 16);
|
||||
WeightedRandomChestContent other = container.get(key);
|
||||
if (other == null)
|
||||
{
|
||||
//This item has not been seen before. Simply add it to the container.
|
||||
container.put(id, item);
|
||||
container.put(key, item);
|
||||
}
|
||||
else
|
||||
{
|
||||
//This item conflicts with an existing entry. Replace that entry
|
||||
//if our current item has a lower weight.
|
||||
WeightedRandomChestContent other = container.get(id);
|
||||
if (item.itemWeight < other.itemWeight)
|
||||
{
|
||||
container.put(id, item);
|
||||
container.put(key, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,7 +131,7 @@ public class DDLoot {
|
||||
{
|
||||
if (item.theItemId.itemID == enchantedBookID)
|
||||
{
|
||||
item.itemWeight = 3;
|
||||
item.itemWeight = 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
@@ -12,7 +13,9 @@ public class DDProperties
|
||||
*/
|
||||
|
||||
public final int UnstableDoorID;
|
||||
public final int DimensionalDoorID;
|
||||
public final int DimensionalDoorID;
|
||||
public final int GoldDoorID;
|
||||
public final int GoldDimDoorID;
|
||||
public final int WarpDoorID;
|
||||
public final int TransTrapdoorID;
|
||||
public final int TransientDoorID;
|
||||
@@ -31,7 +34,9 @@ public class DDProperties
|
||||
*/
|
||||
|
||||
public final int RiftBladeItemID;
|
||||
public final int RiftSignatureItemID;
|
||||
public final int RiftSignatureItemID;
|
||||
public final int GoldDimDoorItemID;
|
||||
public final int GoldDoorItemID;
|
||||
public final int RiftRemoverItemID;
|
||||
public final int StableFabricItemID;
|
||||
public final int StabilizedRiftSignatureItemID;
|
||||
@@ -55,7 +60,7 @@ public class DDProperties
|
||||
* Crafting Flags
|
||||
*/
|
||||
|
||||
public final boolean CraftingDimensionaDoorAllowed;
|
||||
public final boolean CraftingDimensionalDoorAllowed;
|
||||
public final boolean CraftingWarpDoorAllowed;
|
||||
public final boolean CraftingRiftSignatureAllowed;
|
||||
public final boolean CraftingRiftRemoverAllowed;
|
||||
@@ -64,6 +69,8 @@ public class DDProperties
|
||||
public final boolean CraftingTransTrapdoorAllowed;
|
||||
public final boolean CraftingStabilizedRiftSignatureAllowed;
|
||||
public final boolean CraftingStableFabricAllowed;
|
||||
public final boolean CraftingGoldDimDoorAllowed;
|
||||
public final boolean CraftingGoldDoorAllowed;
|
||||
|
||||
/**
|
||||
* Loot Flags
|
||||
@@ -93,14 +100,12 @@ public class DDProperties
|
||||
public final boolean LimboReturnsInventoryEnabled;
|
||||
public final boolean DoorRenderingEnabled;
|
||||
public final boolean TNFREAKINGT_Enabled;
|
||||
public final boolean RiftBladeRiftCreationEnabled;
|
||||
|
||||
/**
|
||||
* Other
|
||||
*/
|
||||
|
||||
public final int NonTntWeight;
|
||||
public final int RiftSpreadModifier;
|
||||
public final int ClusterGenerationChance;
|
||||
public final int GatewayGenerationChance;
|
||||
public final int MonolithSpawningChance;
|
||||
@@ -128,7 +133,7 @@ public class DDProperties
|
||||
Configuration config = new Configuration(configFile);
|
||||
config.load();
|
||||
|
||||
CraftingDimensionaDoorAllowed = config.get(CATEGORY_CRAFTING, "Allow Crafting Dimensional Door", true).getBoolean(true);
|
||||
CraftingDimensionalDoorAllowed = config.get(CATEGORY_CRAFTING, "Allow Crafting Dimensional Door", true).getBoolean(true);
|
||||
CraftingWarpDoorAllowed = config.get(CATEGORY_CRAFTING, "Allow Crafting Warp Door", true).getBoolean(true);
|
||||
CraftingUnstableDoorAllowed = config.get(CATEGORY_CRAFTING, "Allow Crafting Unstable Door", true).getBoolean(true);
|
||||
CraftingTransTrapdoorAllowed = config.get(CATEGORY_CRAFTING, "Allow Crafting Transdimensional Trapdoor", true).getBoolean(true);
|
||||
@@ -137,6 +142,8 @@ public class DDProperties
|
||||
CraftingStabilizedRiftSignatureAllowed = config.get(CATEGORY_CRAFTING, "Allow Crafting Stabilized Rift Signature", true).getBoolean(true);
|
||||
CraftingRiftBladeAllowed = config.get(CATEGORY_CRAFTING, "Allow Crafting Rift Blade", true).getBoolean(true);
|
||||
CraftingStableFabricAllowed = config.get(CATEGORY_CRAFTING, "Allow Crafting Stable Fabric", true).getBoolean(true);
|
||||
CraftingGoldDimDoorAllowed = config.get(CATEGORY_CRAFTING, "Allow Crafting Golden Dimensional Door", true).getBoolean(true);
|
||||
CraftingGoldDoorAllowed = config.get(CATEGORY_CRAFTING, "Allow Golden Door", true).getBoolean(true);
|
||||
|
||||
DimensionalDoorLootEnabled = config.get(CATEGORY_LOOT, "Enable Dimensional Door Loot", true).getBoolean(true);
|
||||
WarpDoorLootEnabled = config.get(CATEGORY_LOOT, "Enable Warp Door Loot", false).getBoolean(false);
|
||||
@@ -165,9 +172,6 @@ public class DDProperties
|
||||
LimboReturnRange = config.get(Configuration.CATEGORY_GENERAL, "Limbo Return Range", 500,
|
||||
"Sets the farthest distance that Limbo can send you upon returning to the Overworld").getInt();
|
||||
DoorRenderingEnabled = config.get(Configuration.CATEGORY_GENERAL, "Enable Door Rendering", true).getBoolean(true);
|
||||
RiftBladeRiftCreationEnabled = config.get(Configuration.CATEGORY_GENERAL, "Enable Rift Creation with Rift Blade", true,
|
||||
"Sets whether Rift Blades can create new rifts. If set to false, " +
|
||||
"they will only be able to create transient doors on existing rifts.").getBoolean(true);
|
||||
|
||||
TNFREAKINGT_Enabled = config.get(Configuration.CATEGORY_GENERAL, "EXPLOSIONS!!???!!!?!?!!", false).getBoolean(false);
|
||||
NonTntWeight = config.get(Configuration.CATEGORY_GENERAL, "HOWMUCHTNT", 25,
|
||||
@@ -184,7 +188,9 @@ public class DDProperties
|
||||
RiftBlockID = config.getBlock("Rift Block ID", 1977).getInt();
|
||||
UnstableDoorID = config.getBlock("Unstable Door Block ID", 1978).getInt();
|
||||
TransientDoorID = config.getBlock("Transient Door Block ID", 1979).getInt();
|
||||
|
||||
GoldDoorID = config.getBlock("Gold Door Block ID", 1980).getInt();
|
||||
GoldDimDoorID = config.getBlock("Gold Dim Door Block ID", 1981).getInt();
|
||||
|
||||
WarpDoorItemID = config.getItem("Warp Door Item ID", 5670).getInt();
|
||||
RiftRemoverItemID = config.getItem("Rift Remover Item ID", 5671).getInt();
|
||||
StableFabricItemID = config.getItem("Stable Fabric Item ID", 5672).getInt();
|
||||
@@ -193,7 +199,9 @@ public class DDProperties
|
||||
RiftSignatureItemID = config.getItem("Rift Signature Item ID", 5675).getInt();
|
||||
RiftBladeItemID = config.getItem("Rift Blade Item ID", 5676).getInt();
|
||||
StabilizedRiftSignatureItemID = config.getItem("Stabilized Rift Signature Item ID", 5677).getInt();
|
||||
|
||||
GoldDoorItemID = config.getItem("Gold Door Item ID", 5678).getInt();
|
||||
GoldDimDoorItemID = config.getItem("Gold Dim Door Item ID", 5679).getInt();
|
||||
|
||||
LimboBlockID = config.getTerrainBlock("World Generation Block IDs - must be less than 256", "Limbo Block ID", 217,
|
||||
"Blocks used for the terrain in Limbo").getInt();
|
||||
PermaFabricBlockID = config.getTerrainBlock("World Generation Block IDs - must be less than 256",
|
||||
@@ -211,16 +219,12 @@ 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,
|
||||
"Sets the number of times a rift can spread. 0 prevents rifts from spreading at all. " +
|
||||
"A value greater than 5 is not recommended as the growth is exponential.").getInt();
|
||||
|
||||
LimboBiomeID = config.get(CATEGORY_BIOME, "Limbo Biome ID", 251).getInt();
|
||||
PocketBiomeID = config.get(CATEGORY_BIOME, "Pocket Biome ID", 250).getInt();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
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
|
||||
*/
|
||||
/**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;
|
||||
@@ -13,245 +13,245 @@ import net.minecraft.world.World;
|
||||
|
||||
public class DimData implements Serializable
|
||||
{
|
||||
public int dimID;
|
||||
public int depth;
|
||||
public int dimOrientation;
|
||||
public int dimID;
|
||||
public int depth;
|
||||
public int dimOrientation;
|
||||
|
||||
public World world;
|
||||
public World world;
|
||||
|
||||
public LinkData exitDimLink;
|
||||
public LinkData 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, LinkData>>> linksInThisDim = new HashMap();
|
||||
HashMap<Integer, LinkData> dimX;
|
||||
HashMap<Integer, HashMap<Integer, LinkData>> dimY ;
|
||||
public boolean isPocket;
|
||||
public boolean hasBeenFilled=false;
|
||||
public boolean hasDoor=false;
|
||||
public boolean isDimRandomRift=false;
|
||||
public Object dungeonGenerator = null;
|
||||
//public boolean isPrivatePocket = false;
|
||||
public HashMap<Integer, HashMap<Integer, HashMap<Integer, LinkData>>> linksInThisDim = new HashMap();
|
||||
HashMap<Integer, LinkData> dimX;
|
||||
HashMap<Integer, HashMap<Integer, LinkData>> dimY ;
|
||||
|
||||
static final long serialVersionUID = 454342L;
|
||||
static final long serialVersionUID = 454342L;
|
||||
|
||||
public DimData(int dimID, boolean isPocket, int depth, LinkData exitLinkData)
|
||||
{
|
||||
this.dimID=dimID;
|
||||
this.depth=depth;
|
||||
this.isPocket=isPocket;
|
||||
public DimData(int dimID, boolean isPocket, int depth, LinkData exitLinkData)
|
||||
{
|
||||
this.dimID=dimID;
|
||||
this.depth=depth;
|
||||
this.isPocket=isPocket;
|
||||
|
||||
this.exitDimLink= exitLinkData;
|
||||
}
|
||||
this.exitDimLink= exitLinkData;
|
||||
}
|
||||
|
||||
public DimData(int dimID, boolean isPocket, int depth, int exitLinkDimID, int exitX, int exitY, int exitZ)
|
||||
{
|
||||
this(dimID, isPocket, depth, new LinkData(exitLinkDimID, exitX, exitY, exitZ));
|
||||
}
|
||||
public DimData(int dimID, boolean isPocket, int depth, int exitLinkDimID, int exitX, int exitY, int exitZ)
|
||||
{
|
||||
this(dimID, isPocket, depth, new LinkData(exitLinkDimID, exitX, exitY, exitZ));
|
||||
}
|
||||
|
||||
public LinkData findNearestRift(World world, int range, int x, int y, int z)
|
||||
{
|
||||
LinkData nearest=null;
|
||||
float distance=range+1;
|
||||
int i=-range;
|
||||
int j=-range;
|
||||
int k=-range;
|
||||
DDProperties properties = DDProperties.instance();
|
||||
public LinkData findNearestRift(World world, int range, int x, int y, int z)
|
||||
{
|
||||
LinkData 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);
|
||||
}
|
||||
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++;
|
||||
}
|
||||
k++;
|
||||
}
|
||||
k=-range;
|
||||
j++;
|
||||
|
||||
}
|
||||
j=-range;
|
||||
i++;
|
||||
}
|
||||
j=-range;
|
||||
i++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return nearest;
|
||||
return nearest;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList findRiftsInRange(World world, int range, int x, int y, int z)
|
||||
{
|
||||
LinkData nearest=null;
|
||||
ArrayList rifts = new ArrayList();
|
||||
int i=-range;
|
||||
int j=-range;
|
||||
int k=-range;
|
||||
DDProperties properties = DDProperties.instance();
|
||||
public ArrayList findRiftsInRange(World world, int range, int x, int y, int z)
|
||||
{
|
||||
LinkData 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);
|
||||
}
|
||||
}
|
||||
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++;
|
||||
}
|
||||
k++;
|
||||
}
|
||||
k=-range;
|
||||
j++;
|
||||
|
||||
}
|
||||
j=-range;
|
||||
i++;
|
||||
}
|
||||
j=-range;
|
||||
i++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return rifts;
|
||||
return rifts;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public LinkData addLinkToDim(LinkData link)
|
||||
{
|
||||
if(this.linksInThisDim.containsKey(link.locZCoord))
|
||||
{
|
||||
this.dimY=this.linksInThisDim.get(link.locZCoord);
|
||||
public LinkData addLinkToDim(LinkData 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, LinkData>();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dimX=new HashMap<Integer, LinkData>();
|
||||
this.dimY=new HashMap<Integer, HashMap<Integer, LinkData>>();
|
||||
}
|
||||
if(this.dimY.containsKey(link.locYCoord))
|
||||
{
|
||||
this.dimX=this.dimY.get(link.locYCoord);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dimX=new HashMap<Integer, LinkData>();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dimX=new HashMap<Integer, LinkData>();
|
||||
this.dimY=new HashMap<Integer, HashMap<Integer, LinkData>>();
|
||||
}
|
||||
|
||||
this.dimX.put(link.locXCoord, link);
|
||||
this.dimY.put(link.locYCoord, dimX);
|
||||
this.linksInThisDim.put(link.locZCoord, dimY);
|
||||
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;
|
||||
//System.out.println("added link to dim "+this.dimID);
|
||||
return link;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public LinkData addLinkToDim( int destinationDimID, int locationXCoord, int locationYCoord, int locationZCoord, int destinationXCoord, int destinationYCoord, int destinationZCoord, int linkOrientation)
|
||||
{
|
||||
LinkData linkData= new LinkData(this.dimID, destinationDimID, locationXCoord, locationYCoord, locationZCoord, destinationXCoord, destinationYCoord,destinationZCoord,this.isPocket,linkOrientation);
|
||||
public LinkData addLinkToDim( int destinationDimID, int locationXCoord, int locationYCoord, int locationZCoord, int destinationXCoord, int destinationYCoord, int destinationZCoord, int linkOrientation)
|
||||
{
|
||||
LinkData linkData= new LinkData(this.dimID, destinationDimID, locationXCoord, locationYCoord, locationZCoord, destinationXCoord, destinationYCoord,destinationZCoord,this.isPocket,linkOrientation);
|
||||
|
||||
return this.addLinkToDim(linkData);
|
||||
}
|
||||
return this.addLinkToDim(linkData);
|
||||
}
|
||||
|
||||
public boolean isLimbo()
|
||||
{
|
||||
return (this.dimID == DDProperties.instance().LimboDimensionID);
|
||||
}
|
||||
public boolean isLimbo()
|
||||
{
|
||||
return (this.dimID == DDProperties.instance().LimboDimensionID);
|
||||
}
|
||||
|
||||
public void removeLinkAtCoords(LinkData link)
|
||||
{
|
||||
this.removeLinkAtCoords(link.locDimID, link.locXCoord, link.locYCoord, link.locZCoord);
|
||||
}
|
||||
public void removeLinkAtCoords(LinkData 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);
|
||||
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, LinkData>();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dimX=new HashMap<Integer, LinkData>();
|
||||
this.dimY=new HashMap<Integer, HashMap<Integer, LinkData>>();
|
||||
}
|
||||
if(this.dimY.containsKey(locationYCoord))
|
||||
{
|
||||
this.dimX=this.dimY.get(locationYCoord);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dimX=new HashMap<Integer, LinkData>();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dimX=new HashMap<Integer, LinkData>();
|
||||
this.dimY=new HashMap<Integer, HashMap<Integer, LinkData>>();
|
||||
}
|
||||
|
||||
this.dimX.remove(locationXCoord);
|
||||
this.dimY.put(locationYCoord, dimX);
|
||||
this.linksInThisDim.put(locationZCoord, dimY);
|
||||
}
|
||||
this.dimX.remove(locationXCoord);
|
||||
this.dimY.put(locationYCoord, dimX);
|
||||
this.linksInThisDim.put(locationZCoord, dimY);
|
||||
}
|
||||
|
||||
public LinkData findLinkAtCoords(int locationXCoord, int locationYCoord, int locationZCoord)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(this.linksInThisDim.containsKey(locationZCoord))
|
||||
{
|
||||
this.dimY=this.linksInThisDim.get(locationZCoord);
|
||||
public LinkData 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.dimY.containsKey(locationYCoord))
|
||||
{
|
||||
this.dimX=this.dimY.get(locationYCoord);
|
||||
|
||||
if(this.dimX.containsKey(locationXCoord))
|
||||
{
|
||||
return this.dimX.get(locationXCoord);
|
||||
}
|
||||
if(this.dimX.containsKey(locationXCoord))
|
||||
{
|
||||
return this.dimX.get(locationXCoord);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception E)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception E)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<LinkData> 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<LinkData> links = new ArrayList<LinkData>();
|
||||
if (this.linksInThisDim == null)
|
||||
{
|
||||
return links;
|
||||
}
|
||||
for (HashMap<Integer, HashMap<Integer, LinkData>> first : this.linksInThisDim.values())
|
||||
{
|
||||
for (HashMap<Integer, LinkData> second : first.values())
|
||||
{
|
||||
for (LinkData linkData : second.values())
|
||||
{
|
||||
links.add(linkData);
|
||||
}
|
||||
}
|
||||
}
|
||||
return links;
|
||||
}
|
||||
public ArrayList<LinkData> 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<LinkData> links = new ArrayList<LinkData>();
|
||||
if (this.linksInThisDim == null)
|
||||
{
|
||||
return links;
|
||||
}
|
||||
for (HashMap<Integer, HashMap<Integer, LinkData>> first : this.linksInThisDim.values())
|
||||
{
|
||||
for (HashMap<Integer, LinkData> second : first.values())
|
||||
{
|
||||
for (LinkData linkData : second.values())
|
||||
{
|
||||
links.add(linkData);
|
||||
}
|
||||
}
|
||||
}
|
||||
return links;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
|
||||
public class DimUpdatePacket
|
||||
{
|
||||
|
||||
public DimUpdatePacket(int dim)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -11,74 +11,74 @@ 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 LinkData 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...
|
||||
}
|
||||
//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 LinkData 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));
|
||||
}
|
||||
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,23 +1,37 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
import paulscode.sound.SoundSystem;
|
||||
import net.minecraft.client.audio.SoundPool;
|
||||
import net.minecraft.client.audio.SoundPoolEntry;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.sound.PlayBackgroundMusicEvent;
|
||||
import net.minecraftforge.client.event.sound.PlaySoundEffectEvent;
|
||||
import net.minecraftforge.client.event.sound.SoundLoadEvent;
|
||||
import net.minecraftforge.event.EventPriority;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.RiftRegenerator;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import StevenDimDoors.mod_pocketDim.world.LimboProvider;
|
||||
import StevenDimDoors.mod_pocketDim.world.PocketProvider;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class EventHookContainer
|
||||
{
|
||||
private static DDProperties properties = null;
|
||||
private final DDProperties properties;
|
||||
|
||||
public EventHookContainer()
|
||||
public EventHookContainer(DDProperties properties)
|
||||
{
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -32,43 +46,35 @@ public class EventHookContainer
|
||||
event.manager.soundPoolSounds.addSound("mods/DimDoors/sfx/riftEnd.ogg", (mod_pocketDim.class.getResource("/mods/DimDoors/sfx/riftEnd.ogg")));
|
||||
event.manager.soundPoolSounds.addSound("mods/DimDoors/sfx/riftClose.ogg", (mod_pocketDim.class.getResource("/mods/DimDoors/sfx/riftClose.ogg")));
|
||||
event.manager.soundPoolSounds.addSound("mods/DimDoors/sfx/riftDoor.ogg", (mod_pocketDim.class.getResource("/mods/DimDoors/sfx/riftDoor.ogg")));
|
||||
}
|
||||
event.manager.soundPoolMusic.addSound("mods/DimDoors/sfx/creepy.ogg", (mod_pocketDim.class.getResource("/mods/DimDoors/sfx/creepy.ogg")));
|
||||
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
@ForgeSubscribe
|
||||
public void onSoundEffectResult(PlayBackgroundMusicEvent event)
|
||||
{
|
||||
if (FMLClientHandler.instance().getClient().thePlayer.worldObj.provider.dimensionId==mod_pocketDim.properties.LimboDimensionID);
|
||||
{
|
||||
this.playMusicForDim(FMLClientHandler.instance().getClient().thePlayer.worldObj);
|
||||
}
|
||||
}
|
||||
@ForgeSubscribe
|
||||
public void onWorldLoad(WorldEvent.Load event)
|
||||
{
|
||||
if (!mod_pocketDim.hasInitDims && event.world.provider.dimensionId == 0 && !event.world.isRemote)
|
||||
// We need to initialize PocketManager here because onServerAboutToStart fires before we can
|
||||
// use DimensionManager and onServerStarting fires after the game tries to generate terrain.
|
||||
// If a gateway tries to generate before PocketManager has initialized, we get a crash.
|
||||
if (!PocketManager.isLoaded())
|
||||
{
|
||||
System.out.println("Registering Pocket Dims");
|
||||
mod_pocketDim.hasInitDims = true;
|
||||
dimHelper.instance.unregsisterDims();
|
||||
dimHelper.dimList.clear();
|
||||
dimHelper.instance.interDimLinkList.clear();
|
||||
dimHelper.instance.initPockets();
|
||||
PocketManager.load();
|
||||
}
|
||||
|
||||
//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 (LinkData 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (PocketManager.isLoaded())
|
||||
{
|
||||
RiftRegenerator.regenerateRiftsInAllWorlds();
|
||||
}
|
||||
|
||||
this.playMusicForDim(event.world);
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
@@ -76,21 +82,51 @@ public class EventHookContainer
|
||||
{
|
||||
event.setCanceled(event.entity.worldObj.provider.dimensionId == properties.LimboDimensionID);
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onPlayerDrops(PlayerDropsEvent event)
|
||||
@ForgeSubscribe(priority=EventPriority.HIGHEST)
|
||||
public boolean LivingDeathEvent(LivingDeathEvent event)
|
||||
{
|
||||
//TODO: I have some doubts. Is this triggered even if you die outside Limbo? And do you still drop items that others could pick up? We don't cancel the event. ~SenseiKiwi
|
||||
mod_pocketDim.limboSpawnInventory.put(event.entityPlayer.username, event.drops);
|
||||
Entity entity = event.entity;
|
||||
|
||||
if (entity instanceof EntityPlayer && properties.LimboEnabled &&
|
||||
entity.worldObj.provider instanceof PocketProvider)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
if (!properties.LimboReturnsInventoryEnabled)
|
||||
{
|
||||
player.inventory.clearInventory(-1, -1);
|
||||
}
|
||||
ChunkCoordinates coords = LimboProvider.getLimboSkySpawn(player.worldObj.rand);
|
||||
Point4D destination = new Point4D((int) (coords.posX+entity.posX), coords.posY, (int) (coords.posZ+entity.posZ ), mod_pocketDim.properties.LimboDimensionID);
|
||||
DDTeleporter.teleportEntity(player, destination, false);
|
||||
player.setEntityHealth(player.getMaxHealth());
|
||||
event.setCanceled(true);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onWorldsave(WorldEvent.Save event)
|
||||
public void onWorldSave(WorldEvent.Save event)
|
||||
{
|
||||
|
||||
if (mod_pocketDim.hasInitDims && event.world.provider.dimensionId == 0)
|
||||
if (event.world.provider.dimensionId == 0)
|
||||
{
|
||||
dimHelper.instance.save();
|
||||
PocketManager.save();
|
||||
}
|
||||
}
|
||||
|
||||
public void playMusicForDim(World world)
|
||||
{
|
||||
if(world.isRemote&&world.provider instanceof LimboProvider)
|
||||
{
|
||||
SoundSystem sndSystem = FMLClientHandler.instance().getClient().sndManager.sndSystem;
|
||||
sndSystem.stop("BgMusic");
|
||||
SoundPoolEntry soundPoolEntry = FMLClientHandler.instance().getClient().sndManager.soundPoolMusic.getRandomSoundFromSoundPool("mods.DimDoors.sfx.creepy");
|
||||
sndSystem.backgroundMusic("LimboMusic", soundPoolEntry.soundUrl, soundPoolEntry.soundName, false);
|
||||
sndSystem.play("LimboMusic");
|
||||
}
|
||||
else if(world.isRemote && !(world.provider instanceof LimboProvider))
|
||||
{
|
||||
FMLClientHandler.instance().getClient().sndManager.sndSystem.stop("LimboMusic");
|
||||
}
|
||||
}
|
||||
}
|
||||
8
StevenDimDoors/mod_pocketDim/IChunkLoader.java
Normal file
8
StevenDimDoors/mod_pocketDim/IChunkLoader.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
||||
|
||||
public interface IChunkLoader
|
||||
{
|
||||
public void forceChunkLoading(Ticket ticket,int x, int z);
|
||||
}
|
||||
@@ -4,65 +4,65 @@ import java.io.Serializable;
|
||||
|
||||
public class LinkData implements Serializable
|
||||
{
|
||||
|
||||
public int locXCoord;
|
||||
public int locYCoord;
|
||||
public int locZCoord;
|
||||
|
||||
public int destXCoord;
|
||||
public int destYCoord;
|
||||
public int destZCoord;
|
||||
public int numberofChildren;
|
||||
public boolean isLocPocket;
|
||||
public int linkOrientation;
|
||||
|
||||
public int locXCoord;
|
||||
public int locYCoord;
|
||||
public int locZCoord;
|
||||
|
||||
public int destXCoord;
|
||||
public int destYCoord;
|
||||
public int destZCoord;
|
||||
public int numberofChildren;
|
||||
public boolean isLocPocket;
|
||||
public int linkOrientation;
|
||||
|
||||
public int destDimID;
|
||||
public int locDimID;
|
||||
|
||||
public boolean exists=false;
|
||||
public boolean hasGennedDoor=false;
|
||||
|
||||
static final long serialVersionUID = 45544342L;
|
||||
|
||||
|
||||
public LinkData()
|
||||
{
|
||||
this.exists=false;
|
||||
}
|
||||
|
||||
public LinkData(int exitLinkDimID, int exitX, int exitY, int exitZ)
|
||||
{
|
||||
this.destDimID=exitLinkDimID;
|
||||
this.destXCoord=exitX;
|
||||
this.destYCoord=exitY;
|
||||
this.destZCoord=exitZ;
|
||||
}
|
||||
public int destDimID;
|
||||
public int locDimID;
|
||||
|
||||
public boolean exists=false;
|
||||
public boolean hasGennedDoor=false;
|
||||
|
||||
static final long serialVersionUID = 45544342L;
|
||||
|
||||
|
||||
public LinkData()
|
||||
{
|
||||
this.exists=false;
|
||||
}
|
||||
|
||||
public LinkData(int exitLinkDimID, int exitX, int exitY, int exitZ)
|
||||
{
|
||||
this.destDimID=exitLinkDimID;
|
||||
this.destXCoord=exitX;
|
||||
this.destYCoord=exitY;
|
||||
this.destZCoord=exitZ;
|
||||
}
|
||||
|
||||
public LinkData(int locationDimID, int destinationDimID, int locationXCoord, int locationYCoord, int locationZCoord, int destinationXCoord, int destinationYCoord, int destinationZCoord, boolean isPocket,int orientation)
|
||||
{
|
||||
this.exists = true;
|
||||
this.locXCoord=locationXCoord;
|
||||
this.locYCoord=locationYCoord;
|
||||
this.locZCoord=locationZCoord;
|
||||
|
||||
this.destXCoord=destinationXCoord;
|
||||
this.destYCoord=destinationYCoord;
|
||||
this.destZCoord=destinationZCoord;
|
||||
|
||||
this.destDimID=destinationDimID;
|
||||
this.locDimID=locationDimID;
|
||||
this.isLocPocket=isPocket;
|
||||
this.linkOrientation=orientation;
|
||||
}
|
||||
|
||||
public String printLinkData()
|
||||
{
|
||||
//TODO: Rewrite this to make it prettier. @_@ I'm afraid of changing it to ToString() on the off
|
||||
//chance it'll cause explosions and sadness. Damn serialization! ~SenseiKiwi
|
||||
|
||||
String linkInfo;
|
||||
linkInfo = String.valueOf(this.locDimID) + "locDimID "+String.valueOf(this.locXCoord)+":locXCoord "+String.valueOf(this.locYCoord)+":locYCoord "+String.valueOf(this.locZCoord)+":locZCoord ";
|
||||
linkInfo.concat("\n"+ String.valueOf(this.destDimID)+"DestDimID "+String.valueOf(this.destXCoord)+":destXCoord "+String.valueOf(this.destYCoord)+":destYCoord "+String.valueOf(this.destZCoord)+":destZCoord ");
|
||||
return linkInfo;
|
||||
}
|
||||
public LinkData(int locationDimID, int destinationDimID, int locationXCoord, int locationYCoord, int locationZCoord, int destinationXCoord, int destinationYCoord, int destinationZCoord, boolean isPocket,int orientation)
|
||||
{
|
||||
this.exists = true;
|
||||
this.locXCoord=locationXCoord;
|
||||
this.locYCoord=locationYCoord;
|
||||
this.locZCoord=locationZCoord;
|
||||
|
||||
this.destXCoord=destinationXCoord;
|
||||
this.destYCoord=destinationYCoord;
|
||||
this.destZCoord=destinationZCoord;
|
||||
|
||||
this.destDimID=destinationDimID;
|
||||
this.locDimID=locationDimID;
|
||||
this.isLocPocket=isPocket;
|
||||
this.linkOrientation=orientation;
|
||||
}
|
||||
|
||||
public String printLinkData()
|
||||
{
|
||||
//TODO: Rewrite this to make it prettier. @_@ I'm afraid of changing it to ToString() on the off
|
||||
//chance it'll cause explosions and sadness. Damn serialization! ~SenseiKiwi
|
||||
|
||||
String linkInfo;
|
||||
linkInfo = String.valueOf(this.locDimID) + "locDimID "+String.valueOf(this.locXCoord)+":locXCoord "+String.valueOf(this.locYCoord)+":locYCoord "+String.valueOf(this.locZCoord)+":locZCoord ";
|
||||
linkInfo.concat("\n"+ String.valueOf(this.destDimID)+"DestDimID "+String.valueOf(this.destXCoord)+":destXCoord "+String.valueOf(this.destYCoord)+":destYCoord "+String.valueOf(this.destZCoord)+":destZCoord ");
|
||||
return linkInfo;
|
||||
}
|
||||
}
|
||||
14
StevenDimDoors/mod_pocketDim/PacketConstants.java
Normal file
14
StevenDimDoors/mod_pocketDim/PacketConstants.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
public class PacketConstants
|
||||
{
|
||||
private PacketConstants() { }
|
||||
|
||||
public static final String CHANNEL_NAME = "DimDoorsPackets";
|
||||
|
||||
public static final byte CLIENT_JOIN_PACKET_ID = 1;
|
||||
public static final byte CREATE_DIM_PACKET_ID = 2;
|
||||
public static final byte DELETE_DIM_PACKET_ID = 3;
|
||||
public static final byte CREATE_LINK_PACKET_ID = 4;
|
||||
public static final byte DELETE_LINK_PACKET_ID = 5;
|
||||
}
|
||||
@@ -1,423 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
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.helpers.dimHelper;
|
||||
|
||||
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;
|
||||
|
||||
@Override
|
||||
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player)
|
||||
{
|
||||
|
||||
if (packet.channel.equals("DimDoorPackets"))
|
||||
{
|
||||
handleRandom(packet,player);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void handleRandom(Packet250CustomPayload packet, Player player)
|
||||
{
|
||||
ByteArrayDataInput data = ByteStreams.newDataInput(packet.data);
|
||||
|
||||
int id=data.readByte();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(id==regsiterDimPacketID)
|
||||
{
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
LinkData linkToAdd = new LinkData(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);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
System.out.println("Tried to update client link data & failed!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(id==removeLinkPacketID)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
int dimId = data.readInt();
|
||||
try
|
||||
{
|
||||
DimData dimDataToRemoveFrom= dimHelper.instance.getDimData(dimId);
|
||||
|
||||
LinkData linkToAdd = new LinkData(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)
|
||||
{
|
||||
//e.printStackTrace();
|
||||
System.out.println("Tried to update client link data & failed!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(id==this.linkKeyPacketID)
|
||||
{
|
||||
LinkData link = new LinkData(data.readInt(), data.readInt(), data.readInt(), data.readInt());
|
||||
dimHelper.instance.interDimLinkList.put(data.readInt(), link);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void onClientJoinPacket(INetworkManager manager, HashMap<Integer, DimData> dimList)
|
||||
{
|
||||
|
||||
Collection<Integer> dimIDs= dimList.keySet();
|
||||
Collection<DimData> dimDataSet= dimList.values();
|
||||
Collection<Packet250CustomPayload> packetsToSend = new HashSet();
|
||||
|
||||
|
||||
|
||||
for(DimData data : dimDataSet)
|
||||
{
|
||||
|
||||
manager.addToSendQueue(PacketHandler.onDimCreatedPacket(data));
|
||||
|
||||
Collection <HashMap<Integer, HashMap<Integer, LinkData>>> linkList = data.linksInThisDim.values();
|
||||
|
||||
for(HashMap map : linkList )
|
||||
{
|
||||
|
||||
Collection <HashMap<Integer, LinkData>> linkList2 = map.values();
|
||||
|
||||
for(HashMap map2 : linkList2)
|
||||
{
|
||||
Collection <LinkData> linkList3 = map2.values();
|
||||
|
||||
for(LinkData link : linkList3)
|
||||
{
|
||||
|
||||
packetsToSend.add(( PacketHandler.onLinkCreatedPacket(link)));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
for (Packet250CustomPayload packet : packetsToSend)
|
||||
{
|
||||
manager.addToSendQueue(packet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static Packet250CustomPayload onLinkCreatedPacket(LinkData link)
|
||||
{
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream dataOut = new DataOutputStream(bos);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
dataOut.writeByte(PacketHandler.registerLinkPacketID);
|
||||
dataOut.writeInt(link.locDimID);
|
||||
dataOut.writeInt(link.destDimID);
|
||||
dataOut.writeInt(link.locXCoord);
|
||||
dataOut.writeInt(link.locYCoord);
|
||||
dataOut.writeInt(link.locZCoord);
|
||||
dataOut.writeInt(link.destXCoord);
|
||||
dataOut.writeInt(link.destYCoord);
|
||||
dataOut.writeInt(link.destZCoord);
|
||||
dataOut.writeBoolean(link.isLocPocket);
|
||||
|
||||
dataOut.writeInt(link.linkOrientation);
|
||||
dataOut.writeBoolean(link.hasGennedDoor);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Packet250CustomPayload packet= new Packet250CustomPayload();
|
||||
packet.channel="DimDoorPackets";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();;
|
||||
PacketDispatcher.sendPacketToAllPlayers(packet);
|
||||
return packet;
|
||||
}
|
||||
|
||||
|
||||
public static Packet250CustomPayload linkKeyPacket(LinkData link, int key)
|
||||
{
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream dataOut = new DataOutputStream(bos);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
dataOut.writeByte(PacketHandler.linkKeyPacketID);
|
||||
|
||||
dataOut.writeInt(link.destDimID);
|
||||
dataOut.writeInt(link.destXCoord);
|
||||
dataOut.writeInt(link.destYCoord);
|
||||
dataOut.writeInt(link.destZCoord);
|
||||
dataOut.writeInt(key);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Packet250CustomPayload packet= new Packet250CustomPayload();
|
||||
packet.channel="DimDoorPackets";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();;
|
||||
PacketDispatcher.sendPacketToAllPlayers(packet);
|
||||
return packet;
|
||||
}
|
||||
|
||||
|
||||
public static void onLinkRemovedPacket(LinkData link)
|
||||
{
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream dataOut = new DataOutputStream(bos);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
dataOut.writeByte(PacketHandler.removeLinkPacketID);
|
||||
dataOut.writeInt(link.locDimID);
|
||||
dataOut.writeInt(link.destDimID);
|
||||
dataOut.writeInt(link.locXCoord);
|
||||
dataOut.writeInt(link.locYCoord);
|
||||
dataOut.writeInt(link.locZCoord);
|
||||
dataOut.writeInt(link.destXCoord);
|
||||
dataOut.writeInt(link.destYCoord);
|
||||
dataOut.writeInt(link.destZCoord);
|
||||
dataOut.writeBoolean(link.isLocPocket);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Packet250CustomPayload packet= new Packet250CustomPayload();
|
||||
packet.channel="DimDoorPackets";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();;
|
||||
PacketDispatcher.sendPacketToAllPlayers(packet);
|
||||
}
|
||||
|
||||
|
||||
public static Packet250CustomPayload onDimCreatedPacket(DimData data)
|
||||
{
|
||||
|
||||
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream dataOut = new DataOutputStream(bos);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
dataOut.writeByte(PacketHandler.regsiterDimPacketID);
|
||||
dataOut.writeInt(data.dimID);
|
||||
dataOut.writeBoolean(data.isPocket);
|
||||
|
||||
dataOut.writeInt(data.depth);
|
||||
dataOut.writeInt(data.exitDimLink.destDimID);
|
||||
dataOut.writeInt(data.exitDimLink.destXCoord);
|
||||
dataOut.writeInt(data.exitDimLink.destYCoord);
|
||||
dataOut.writeInt(data.exitDimLink.destZCoord);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Packet250CustomPayload packet= new Packet250CustomPayload();
|
||||
packet.channel="DimDoorPackets";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
|
||||
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)
|
||||
{
|
||||
try
|
||||
{
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream dataOut = new ObjectOutputStream(bos);
|
||||
dataOut.writeObject(dim);
|
||||
|
||||
Packet250CustomPayload packet= new Packet250CustomPayload();
|
||||
packet.channel="DimDoorPackets";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();;
|
||||
PacketDispatcher.sendPacketToAllPlayers(packet);
|
||||
}
|
||||
catch (IOException e)
|
||||
|
||||
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
|
||||
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import cpw.mods.fml.common.IPlayerTracker;
|
||||
|
||||
|
||||
public class PlayerRespawnTracker implements IPlayerTracker
|
||||
{
|
||||
public PlayerRespawnTracker()
|
||||
{
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
}
|
||||
|
||||
private static DDProperties properties = null;
|
||||
|
||||
@Override
|
||||
public void onPlayerLogin(EntityPlayer player) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerLogout(EntityPlayer player) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerChangedDimension(EntityPlayer player) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerRespawn(EntityPlayer player)
|
||||
{
|
||||
if(player.worldObj.provider.dimensionId==properties.LimboDimensionID)
|
||||
{
|
||||
|
||||
if(!player.worldObj.isRemote && properties.LimboReturnsInventoryEnabled)
|
||||
{
|
||||
|
||||
if(player.username!=null)
|
||||
{
|
||||
|
||||
if(!mod_pocketDim.limboSpawnInventory.isEmpty()&&mod_pocketDim.limboSpawnInventory.containsKey(player.username))
|
||||
{
|
||||
for(EntityItem drop : mod_pocketDim.limboSpawnInventory.get(player.username))
|
||||
{
|
||||
if(drop.getEntityItem().getItem() instanceof ItemArmor)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
player.inventory.addItemStackToInventory(drop.getEntityItem());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,8 +2,12 @@ package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public class Point3D implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -9044026830605287190L;
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
@@ -14,6 +18,13 @@ public class Point3D implements Serializable {
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public Point3D(Point4D point)
|
||||
{
|
||||
this.x = point.getX();
|
||||
this.y = point.getY();
|
||||
this.z = point.getZ();
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
@@ -49,7 +60,10 @@ public class Point3D implements Serializable {
|
||||
{
|
||||
return new Point3D(x, y, z);
|
||||
}
|
||||
|
||||
public int[] toIntArray()
|
||||
{
|
||||
return new int[]{x,y,z};
|
||||
}
|
||||
public boolean equals(Point3D other)
|
||||
{
|
||||
if (other == null)
|
||||
|
||||
@@ -1,204 +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.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(LinkData 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;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,101 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.ClientDimData;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.IUpdateWatcher;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
|
||||
public class ServerPacketHandler implements IPacketHandler
|
||||
{
|
||||
@Override
|
||||
public void onPacketData(INetworkManager manager,
|
||||
Packet250CustomPayload packet, Player player)
|
||||
public ServerPacketHandler()
|
||||
{
|
||||
PocketManager.registerDimWatcher(new DimWatcher());
|
||||
PocketManager.registerLinkWatcher(new LinkWatcher());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { }
|
||||
|
||||
private static class DimWatcher implements IUpdateWatcher<ClientDimData>
|
||||
{
|
||||
@Override
|
||||
public void onCreated(ClientDimData message)
|
||||
{
|
||||
sendDimPacket(PacketConstants.CREATE_DIM_PACKET_ID, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleted(ClientDimData message)
|
||||
{
|
||||
sendDimPacket(PacketConstants.DELETE_DIM_PACKET_ID, message);
|
||||
}
|
||||
}
|
||||
|
||||
private static class LinkWatcher implements IUpdateWatcher<Point4D>
|
||||
{
|
||||
@Override
|
||||
public void onCreated(Point4D message)
|
||||
{
|
||||
sendLinkPacket(PacketConstants.CREATE_LINK_PACKET_ID, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleted(Point4D message)
|
||||
{
|
||||
sendLinkPacket(PacketConstants.DELETE_LINK_PACKET_ID, message);
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendDimPacket(byte id, ClientDimData data)
|
||||
{
|
||||
try
|
||||
{
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
DataOutputStream writer = new DataOutputStream(buffer);
|
||||
writer.writeByte(id);
|
||||
data.write(writer);
|
||||
writer.close();
|
||||
packet.channel = PacketConstants.CHANNEL_NAME;
|
||||
packet.data = buffer.toByteArray();
|
||||
packet.length = packet.data.length;
|
||||
PacketDispatcher.sendPacketToAllPlayers(packet);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
//This shouldn't happen...
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendLinkPacket(byte id, Point4D data)
|
||||
{
|
||||
try
|
||||
{
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
DataOutputStream writer = new DataOutputStream(buffer);
|
||||
writer.writeByte(id);
|
||||
Point4D.write(data, writer);
|
||||
writer.close();
|
||||
packet.channel = PacketConstants.CHANNEL_NAME;
|
||||
packet.data = buffer.toByteArray();
|
||||
packet.length = packet.data.length;
|
||||
PacketDispatcher.sendPacketToAllPlayers(packet);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
//This shouldn't happen...
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TileEntityDimRail extends TileEntity
|
||||
|
||||
{
|
||||
|
||||
public int orientation;
|
||||
public boolean hasExit;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updateEntity()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
int i = nbt.getInteger(("Size"));
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
this.orientation = nbt.getInteger("orientation");
|
||||
|
||||
this.hasExit = nbt.getBoolean("hasExit");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
int i = 0;
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
|
||||
nbt.setBoolean("hasExit", this.hasExit);
|
||||
|
||||
nbt.setInteger("orientation", this.orientation);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,369 +0,0 @@
|
||||
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.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;
|
||||
|
||||
public class TileEntityRift extends TileEntity
|
||||
|
||||
{
|
||||
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 LinkData 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;
|
||||
}
|
||||
|
||||
//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;
|
||||
this.calculateNextRenderQuad(age, rand);
|
||||
}
|
||||
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)
|
||||
{
|
||||
if(this.worldObj.getEntityByID(this.spawnedEndermenID) instanceof EntityEnderman)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
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(!this.worldObj.isRemote&&distance>1)
|
||||
{
|
||||
try
|
||||
{
|
||||
grow(distance);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void grow(int distance)
|
||||
{
|
||||
if(this.worldObj.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int growCount=0;
|
||||
if(rand.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))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if (growCount<100)
|
||||
{
|
||||
|
||||
LinkData link = dimHelper.instance.getLinkDataFromCoords(this.xCoord, this.yCoord, this.zCoord, worldObj);
|
||||
if(link!=null)
|
||||
{
|
||||
if(!this.hasGrownRifts&&rand.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
{
|
||||
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))
|
||||
{
|
||||
if(this.renderingCenters.get(iteration-1)[3]==0)
|
||||
{
|
||||
coords[0]=noise/2+this.renderingCenters.get(iteration-1)[0];
|
||||
coords[1]=noise/2+this.renderingCenters.get(iteration-1)[1];
|
||||
coords[2]= this.renderingCenters.get(iteration-1)[2]+fl;
|
||||
coords[3] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
coords[0]=this.renderingCenters.get(iteration-1)[0]+fl;
|
||||
coords[1]=noise/2+this.renderingCenters.get(iteration-1)[1];
|
||||
coords[2]=noise/2+this.renderingCenters.get(iteration-1)[2];
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.blocks.ExitDoor;
|
||||
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 cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class TransientDoor extends ExitDoor
|
||||
{
|
||||
|
||||
protected TransientDoor(int par1, Material material)
|
||||
{
|
||||
super(par1, Material.grass);
|
||||
// this.blockIndexInTexture = 18;
|
||||
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
}
|
||||
|
||||
private static DDProperties properties = null;
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
return this.blockIcon;
|
||||
|
||||
|
||||
}
|
||||
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 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)
|
||||
{
|
||||
|
||||
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);
|
||||
|
||||
if(!par1World.isRemote&&(num)==var12||!par1World.isRemote&&!(par5Entity instanceof EntityPlayer))
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
LinkData 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
429
StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java
Normal file
429
StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java
Normal file
@@ -0,0 +1,429 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemDoor;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
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.DDTeleporter;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEntityProvider
|
||||
{
|
||||
protected final DDProperties properties;
|
||||
private Icon blockIconBottom;
|
||||
|
||||
public BaseDimDoor(int blockID, Material material, DDProperties properties)
|
||||
{
|
||||
super(blockID, material);
|
||||
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
this.enterDimDoor(world, x, y, z, entity);
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
|
||||
boolean shouldOpen=true;
|
||||
|
||||
//System.out.println(String.valueOf(par1World.getBlockMetadata(par2, par3, par4)));
|
||||
if(player.inventory.getCurrentItem()!=null)
|
||||
{
|
||||
if(player.inventory.getCurrentItem().getItem() == mod_pocketDim.itemRiftBlade)
|
||||
{
|
||||
shouldOpen = false;
|
||||
if (!world.isRemote && world.getBlockId(x, y-1, z) == this.blockID)
|
||||
{
|
||||
int var12 = (int) (MathHelper.floor_double((double)((player.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
|
||||
|
||||
if (world.getBlockMetadata(x, y-1, z) == var12)
|
||||
{
|
||||
var12 = BlockRotator.transformMetadata(var12, 1, this.blockID);
|
||||
}
|
||||
world.setBlockMetadataWithNotify(x, y-1, z, var12, 2);
|
||||
}
|
||||
if (!world.isRemote && world.getBlockId(x, y+1, z) == this.blockID)
|
||||
{
|
||||
int var12 = (int) (MathHelper.floor_double((double)((player.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
|
||||
if(world.getBlockMetadata(x, y, z)==var12)
|
||||
{
|
||||
var12 = BlockRotator.transformMetadata(var12, 1, this.blockID);
|
||||
}
|
||||
world.setBlockMetadataWithNotify(x, y, z, var12, 2);
|
||||
}
|
||||
world.playAuxSFXAtEntity(player, 1001, x, y, z, 0);
|
||||
|
||||
if (!shouldOpen && !world.isRemote)
|
||||
{
|
||||
player.inventory.getCurrentItem().damageItem(5, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(shouldOpen)
|
||||
{
|
||||
int var10 = this.getFullMetadata(world, x, y, z);
|
||||
int var11 = var10 & 7;
|
||||
var11 ^= 4;
|
||||
|
||||
if ((var10 & 8) == 0)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, var11,2);
|
||||
world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y - 1, z, var11,2);
|
||||
world.markBlockRangeForRenderUpdate(x, y - 1, z, x, y, z);
|
||||
}
|
||||
|
||||
world.playAuxSFXAtEntity(player, 1003, x, y, z, 0);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
|
||||
this.placeLink(world, x, y, z);
|
||||
world.setBlockTileEntity(x, y, z, this.createNewTileEntity(world));
|
||||
this.updateAttachedTile(world, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
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 blockIconBottom;
|
||||
}
|
||||
}
|
||||
|
||||
//Called to update the render information on the tile entity. Could probably implement a data watcher,
|
||||
//but this works fine and is more versatile I think.
|
||||
public BaseDimDoor updateAttachedTile(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
if (tile instanceof TileEntityDimDoor)
|
||||
{
|
||||
TileEntityDimDoor dimTile = (TileEntityDimDoor) tile;
|
||||
dimTile.openOrClosed = PocketManager.getLink(x, y, z, world.provider.dimensionId) != null;
|
||||
dimTile.orientation = this.getFullMetadata(world, x, y, z) & 7;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
TileEntityDimDoor tile = (TileEntityDimDoor) par1World.getBlockTileEntity(par2, par3, par4);
|
||||
tile.openOrClosed = this.isDoorOpen( par1World, par2, par3, par4);
|
||||
tile.orientation = this.getFullMetadata(par1World, par2, par3, par4) & 7;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
this.setDoorRotation(this.getFullMetadata(par1IBlockAccess, par2, par3, par4));
|
||||
}
|
||||
|
||||
|
||||
public void setDoorRotation(int par1)
|
||||
{
|
||||
float var2 = 0.1875F;
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F);
|
||||
int var3 = par1 & 3;
|
||||
boolean var4 = (par1 & 4) != 0;
|
||||
boolean var5 = (par1 & 16) != 0;
|
||||
|
||||
if (var3 == 0)
|
||||
{
|
||||
if (var4)
|
||||
{
|
||||
if (!var5)
|
||||
{
|
||||
this.setBlockBounds(0.001F, 0.0F, 0.0F, 1.0F, 1.0F, var2);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.001F, 0.0F, 1.0F - var2, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, var2, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else if (var3 == 1)
|
||||
{
|
||||
if (var4)
|
||||
{
|
||||
if (!var5)
|
||||
{
|
||||
this.setBlockBounds(1.0F - var2, 0.0F, 0.001F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.001F, var2, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, var2);
|
||||
}
|
||||
}
|
||||
else if (var3 == 2)
|
||||
{
|
||||
if (var4)
|
||||
{
|
||||
if (!var5)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 1.0F - var2, .99F, 1.0F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, .99F, 1.0F, var2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(1.0F - var2, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else if (var3 == 3)
|
||||
{
|
||||
if (var4)
|
||||
{
|
||||
if (!var5)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, var2, 1.0F, 0.99F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(1.0F - var2, 0.0F, 0.0F, 1.0F, 1.0F, 0.99F);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 1.0F - var2, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
@Override
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if ((var6 & 8) == 0)
|
||||
{
|
||||
boolean var7 = false;
|
||||
|
||||
if (par1World.getBlockId(par2, par3 + 1, par4) != this.blockID)
|
||||
{
|
||||
par1World.setBlock(par2, par3, par4, 0);
|
||||
var7 = true;
|
||||
}
|
||||
|
||||
/**
|
||||
if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4))
|
||||
{
|
||||
par1World.setBlockWithNotify(par2, par3, par4, 0);
|
||||
var7 = true;
|
||||
|
||||
if (par1World.getBlockId(par2, par3 + 1, par4) == this.blockID)
|
||||
{
|
||||
par1World.setBlockWithNotify(par2, par3 + 1, par4, 0);
|
||||
}
|
||||
}
|
||||
**/
|
||||
|
||||
if (var7)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, properties.DimensionalDoorID, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean var8 = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4) || par1World.isBlockIndirectlyGettingPowered(par2, par3 + 1, par4);
|
||||
|
||||
if ((var8 || par5 > 0 && Block.blocksList[par5].canProvidePower()) && par5 != this.blockID)
|
||||
{
|
||||
this.onPoweredBlockChange(par1World, par2, par3, par4, var8);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (par1World.getBlockId(par2, par3 - 1, par4) != this.blockID)
|
||||
{
|
||||
par1World.setBlock(par2, par3, par4, 0);
|
||||
}
|
||||
|
||||
if (par5 > 0 && par5 != this.blockID)
|
||||
{
|
||||
this.onNeighborBlockChange(par1World, par2, par3 - 1, par4, par5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
|
||||
*/
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return this.getDrops();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return (par1 & 8) != 0 ? 0 : (getDrops());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is attempted to be harvested
|
||||
*/
|
||||
@Override
|
||||
public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer)
|
||||
{
|
||||
if (par6EntityPlayer.capabilities.isCreativeMode && (par5 & 8) != 0 && par1World.getBlockId(par2, par3 - 1, par4) == this.blockID)
|
||||
{
|
||||
par1World.setBlock(par2, par3 - 1, par4, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
return new TileEntityDimDoor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterDimDoor(World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
// FX entities dont exist on the server
|
||||
if (world.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that this is the top block of the door
|
||||
if (world.getBlockId(x, y - 1, z) == this.blockID)
|
||||
{
|
||||
int metadata = world.getBlockMetadata(x, y - 1, z);
|
||||
boolean canUse = isDoorOpen(metadata);
|
||||
if (canUse && entity instanceof EntityPlayer)
|
||||
{
|
||||
// Dont check for non-player entites
|
||||
canUse = isEntityFacingDoor(metadata, (EntityLiving) entity);
|
||||
}
|
||||
if (canUse)
|
||||
{
|
||||
// Teleport the entity through the link, if it exists
|
||||
DimLink link = PocketManager.getLink(x, y, z, world.provider.dimensionId);
|
||||
if (link != null)
|
||||
{
|
||||
DDTeleporter.traverseDimDoor(world, link, entity, this);
|
||||
}
|
||||
// Close the door only after the entity goes through
|
||||
// so players don't have it slam in their faces.
|
||||
this.onPoweredBlockChange(world, x, y, z, false);
|
||||
}
|
||||
}
|
||||
else if (world.getBlockId(x, y + 1, z) == this.blockID)
|
||||
{
|
||||
enterDimDoor(world, x, y + 1, z, entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDrops()
|
||||
{
|
||||
return this.blockID;
|
||||
}
|
||||
|
||||
protected static boolean isDoorOpen(int metadata)
|
||||
{
|
||||
return (metadata & 4) != 0;
|
||||
}
|
||||
|
||||
protected static boolean isEntityFacingDoor(int metadata, EntityLiving entity)
|
||||
{
|
||||
// Although any entity has the proper fields for this check,
|
||||
// we should only apply it to living entities since things
|
||||
// like Minecarts might come in backwards.
|
||||
int direction = (int) (MathHelper.floor_double((double) ((entity.rotationYaw + 90) * 4.0F / 360.0F) + 0.5D) & 3);
|
||||
return ((metadata & 3) == direction);
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,6 @@ package StevenDimDoors.mod_pocketDim.blocks;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -20,6 +15,9 @@ import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockDimWall extends Block
|
||||
{
|
||||
@@ -69,14 +67,7 @@ public class BlockDimWall extends Block
|
||||
@Override
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
if (par2 == 1)
|
||||
{
|
||||
return blockIcon[par2];
|
||||
}
|
||||
else
|
||||
{
|
||||
return blockIcon[0];
|
||||
}
|
||||
return (par2 != 1) ? blockIcon[0] : blockIcon[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,8 +110,13 @@ public class BlockDimWall extends Block
|
||||
|
||||
if (playerEquip instanceof ItemBlock)
|
||||
{
|
||||
Block block = Block.blocksList[playerEquip.itemID];
|
||||
if (!Block.isNormalCube(playerEquip.itemID) || block instanceof BlockContainer || block.blockID == this.blockID)
|
||||
// SenseiKiwi: Using getBlockID() rather than the raw itemID is critical.
|
||||
// Some mods may override that function and use item IDs outside the range
|
||||
// of the block list.
|
||||
|
||||
int blockID = ((ItemBlock) playerEquip).getBlockID();
|
||||
Block block = Block.blocksList[blockID];
|
||||
if (!Block.isNormalCube(blockID) || block instanceof BlockContainer || blockID == this.blockID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -8,18 +8,18 @@ import net.minecraft.client.renderer.texture.IconRegister;
|
||||
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 net.minecraft.world.WorldServer;
|
||||
import StevenDimDoors.mod_pocketDim.BlankTeleporter;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public class BlockDimWallPerm extends Block
|
||||
{
|
||||
private static final Random random = new Random();
|
||||
private static DDProperties properties = null;
|
||||
|
||||
public BlockDimWallPerm(int i, int j, Material par2Material)
|
||||
@@ -45,97 +45,51 @@ 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 world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if(!par1World.isRemote&&par1World.provider.dimensionId==properties.LimboDimensionID)
|
||||
if (!world.isRemote && world.provider.dimensionId == properties.LimboDimensionID)
|
||||
{
|
||||
Random rand = new Random();
|
||||
|
||||
LinkData link=dimHelper.instance.getRandomLinkData(false);
|
||||
if(link==null)
|
||||
World overworld = DimensionManager.getWorld(0);
|
||||
if (overworld != null && entity instanceof EntityPlayerMP)
|
||||
{
|
||||
link =new LinkData(0,0,0,0);
|
||||
}
|
||||
link.destDimID = 0;
|
||||
link.locDimID = par1World.provider.dimensionId;
|
||||
|
||||
|
||||
if(dimHelper.getWorld(0)==null)
|
||||
{
|
||||
dimHelper.initDimension(0);
|
||||
}
|
||||
|
||||
|
||||
if(dimHelper.getWorld(0)!=null&&par5Entity 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 rangeLimit = properties.LimboReturnRange / 2;
|
||||
int destinationX = x + MathHelper.getRandomIntegerInRange(random, -rangeLimit, rangeLimit);
|
||||
int destinationZ = z + MathHelper.getRandomIntegerInRange(random, -rangeLimit, rangeLimit);
|
||||
|
||||
//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);
|
||||
z = z + (z >> 4);
|
||||
destinationX = destinationX + (destinationX >> 4);
|
||||
destinationZ = destinationZ + (destinationZ >> 4);
|
||||
|
||||
int y = yCoordHelper.getFirstUncovered(0, x, 63, z, true);
|
||||
int destinationY = yCoordHelper.getFirstUncovered(overworld, destinationX, 63, destinationZ, true);
|
||||
|
||||
EntityPlayer.class.cast(par5Entity).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));
|
||||
|
||||
|
||||
EntityPlayer.class.cast(par5Entity).setPositionAndUpdate( x, y, z );
|
||||
//FIXME: Shouldn't we make the player's destination safe BEFORE teleporting him?!
|
||||
//player.setPositionAndUpdate( x, y, z );
|
||||
Point4D destination = new Point4D(destinationX, destinationY, destinationZ, 0);
|
||||
DDTeleporter.teleportEntity(player, destination, false);
|
||||
|
||||
//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(destinationX, destinationY, destinationZ);
|
||||
overworld.setBlockToAir(destinationX, destinationY + 1, destinationZ);
|
||||
|
||||
int i=x;
|
||||
int j=y;
|
||||
int k=z;
|
||||
|
||||
|
||||
for(int xc=-3;xc<4;xc++)
|
||||
for (int xc = -3; xc < 4; xc++)
|
||||
{
|
||||
for(int zc=-3;zc<4;zc++)
|
||||
for (int zc = -3; zc < 4; zc++)
|
||||
{
|
||||
for(int yc=0;yc<200;yc++)
|
||||
if (Math.abs(xc) + Math.abs(zc) < random.nextInt(3) + 2 ||
|
||||
Math.abs(xc) + Math.abs(zc) < random.nextInt(3) + 3)
|
||||
{
|
||||
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);
|
||||
}
|
||||
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(destinationX + xc, destinationY - 1, destinationZ + zc, properties.LimboBlockID);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
{
|
||||
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( destinationX, destinationY, destinationZ );
|
||||
player.fallDistance = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
49
StevenDimDoors/mod_pocketDim/blocks/BlockDoorGold.java
Normal file
49
StevenDimDoors/mod_pocketDim/blocks/BlockDoorGold.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class BlockDoorGold extends BlockDoor
|
||||
{
|
||||
|
||||
private Icon blockIconBottom;
|
||||
private DDProperties properties;
|
||||
|
||||
public BlockDoorGold(int par1, Material par2Material,DDProperties properties)
|
||||
{
|
||||
super(par1, par2Material);
|
||||
this.properties=properties;
|
||||
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
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 blockIconBottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
50
StevenDimDoors/mod_pocketDim/blocks/BlockGoldDimDoor.java
Normal file
50
StevenDimDoors/mod_pocketDim/blocks/BlockGoldDimDoor.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
|
||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoorGold;
|
||||
|
||||
public class BlockGoldDimDoor extends BaseDimDoor implements IDimDoor
|
||||
{
|
||||
|
||||
public BlockGoldDimDoor(int blockID, Material material,
|
||||
DDProperties properties) {
|
||||
super(blockID, material, properties);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeLink(World world, int x, int y, int z)
|
||||
{
|
||||
if (!world.isRemote && world.getBlockId(x, y - 1, z) == this.blockID)
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = dimension.getLink(x, y, z);
|
||||
if (link == null)
|
||||
{
|
||||
dimension.createLink(x, y, z, LinkTypes.POCKET,world.getBlockMetadata(x, y - 1, z));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public int getDrops()
|
||||
{
|
||||
return this.properties.GoldDoorItemID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
return new TileEntityDimDoorGold();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
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_pocketDim.tileentities.TileEntityRift;
|
||||
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)
|
||||
{
|
||||
@@ -53,6 +53,9 @@ public class BlockRift extends BlockContainer
|
||||
this.blocksImmuneToRift.add(properties.UnstableDoorID);
|
||||
this.blocksImmuneToRift.add(properties.RiftBlockID);
|
||||
this.blocksImmuneToRift.add(properties.TransientDoorID);
|
||||
this.blocksImmuneToRift.add(properties.GoldDimDoorID);
|
||||
this.blocksImmuneToRift.add(properties.GoldDoorID);
|
||||
|
||||
this.blocksImmuneToRift.add(Block.blockIron.blockID);
|
||||
this.blocksImmuneToRift.add(Block.blockDiamond.blockID);
|
||||
this.blocksImmuneToRift.add(Block.blockEmerald.blockID);
|
||||
@@ -154,7 +157,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 +338,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)
|
||||
|
||||
@@ -1,146 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
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 cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ChaosDoor extends dimDoor
|
||||
{
|
||||
private Icon blockIconBottom;
|
||||
private static DDProperties properties = null;
|
||||
|
||||
public ChaosDoor(int par1, Material material)
|
||||
{
|
||||
super(par1, Material.iron);
|
||||
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)
|
||||
{
|
||||
LinkData link = new LinkData(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);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//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++;
|
||||
|
||||
LinkData link = (LinkData) dimHelper.instance.getRandomLinkData(false);
|
||||
|
||||
if(link!=null)
|
||||
{
|
||||
|
||||
if(!link.isLocPocket&&link.linkOrientation!=-10&&link.destDimID!=properties.LimboDimensionID)
|
||||
{
|
||||
foundRandomDest=true;
|
||||
|
||||
dimHelper.instance.traverseDimDoor(par1World, new LinkData(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
39
StevenDimDoors/mod_pocketDim/blocks/DimensionalDoor.java
Normal file
39
StevenDimDoors/mod_pocketDim/blocks/DimensionalDoor.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class DimensionalDoor extends BaseDimDoor
|
||||
{
|
||||
|
||||
public DimensionalDoor(int blockID, Material material, DDProperties properties)
|
||||
{
|
||||
super(blockID, material, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeLink(World world, int x, int y, int z)
|
||||
{
|
||||
if (!world.isRemote && world.getBlockId(x, y - 1, z) == this.blockID)
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = dimension.getLink(x, y, z);
|
||||
if (link == null)
|
||||
{
|
||||
dimension.createLink(x, y, z, LinkTypes.POCKET,world.getBlockMetadata(x, y - 1, z));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public int getDrops()
|
||||
{
|
||||
return Item.doorIron.itemID;
|
||||
}
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
super(par1, Material.wood);
|
||||
|
||||
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
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");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
|
||||
|
||||
if(!par1World.isRemote&&par1World.getBlockId(par2, par3-1, par4)==this.blockID)
|
||||
{
|
||||
|
||||
|
||||
int locDimID=par1World.provider.dimensionId;
|
||||
|
||||
if(dimHelper.instance.dimList.containsKey(locDimID)&&dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World)==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));
|
||||
|
||||
|
||||
}
|
||||
**/
|
||||
|
||||
}
|
||||
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));
|
||||
|
||||
}
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
13
StevenDimDoors/mod_pocketDim/blocks/IDimDoor.java
Normal file
13
StevenDimDoors/mod_pocketDim/blocks/IDimDoor.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IDimDoor
|
||||
{
|
||||
public void enterDimDoor(World world, int x, int y, int z, Entity entity);
|
||||
|
||||
public void placeLink(World world, int x, int y, int z);
|
||||
|
||||
public int getDrops();
|
||||
}
|
||||
121
StevenDimDoors/mod_pocketDim/blocks/TransTrapdoor.java
Normal file
121
StevenDimDoors/mod_pocketDim/blocks/TransTrapdoor.java
Normal file
@@ -0,0 +1,121 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockTrapDoor;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemDoor;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
|
||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityTransTrapdoor;
|
||||
|
||||
public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntityProvider
|
||||
{
|
||||
|
||||
public TransTrapdoor(int blockID, Material material)
|
||||
{
|
||||
super(blockID, material);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2());
|
||||
}
|
||||
|
||||
//Teleports the player to the exit link of that dimension, assuming it is a pocket
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
enterDimDoor(world, x, y, z, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterDimDoor(World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if (!world.isRemote && isTrapdoorOpen(world.getBlockMetadata(x, y, z)))
|
||||
{
|
||||
this.onPoweredBlockChange(world, x, y, z, false);
|
||||
|
||||
DimLink link = PocketManager.getLink(x, y, z, world);
|
||||
if (link != null)
|
||||
{
|
||||
DDTeleporter.traverseDimDoor(world, link, entity,this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z)
|
||||
{
|
||||
this.placeLink(world, x, y, z);
|
||||
world.setBlockTileEntity(x, y, z, this.createNewTileEntity(world));
|
||||
this.updateAttachedTile(world, x, y, z);
|
||||
}
|
||||
|
||||
public void updateTick(World world, int x, int y, int z, Random random)
|
||||
{
|
||||
TileEntityTransTrapdoor tile = (TileEntityTransTrapdoor) world.getBlockTileEntity(x, y, z);
|
||||
tile.hasRift = PocketManager.getLink(x, y, z, world) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
return new TileEntityTransTrapdoor();
|
||||
}
|
||||
|
||||
public void updateAttachedTile(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
if (tile instanceof TileEntityTransTrapdoor)
|
||||
{
|
||||
TileEntityTransTrapdoor trapdoorTile = (TileEntityTransTrapdoor) tile;
|
||||
trapdoorTile.hasRift = (PocketManager.getLink(x, y, z, world) != null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeLink(World world, int x, int y, int z)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = dimension.getLink(x, y, z);
|
||||
if (link == null && dimension.isPocketDimension())
|
||||
{
|
||||
dimension.createLink(x, y, z, LinkTypes.UNSAFE_EXIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int idDropped(int metadata, Random random, int fortuneLevel)
|
||||
{
|
||||
return getDrops();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDrops()
|
||||
{
|
||||
return Block.trapdoor.blockID;
|
||||
}
|
||||
|
||||
public static boolean isTrapdoorSetLow(int metadata)
|
||||
{
|
||||
return (metadata & 8) == 0;
|
||||
}
|
||||
}
|
||||
103
StevenDimDoors/mod_pocketDim/blocks/TransientDoor.java
Normal file
103
StevenDimDoors/mod_pocketDim/blocks/TransientDoor.java
Normal file
@@ -0,0 +1,103 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.item.ItemDoor;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
|
||||
|
||||
public class TransientDoor extends BaseDimDoor
|
||||
{
|
||||
public TransientDoor(int blockID, Material material, DDProperties properties)
|
||||
{
|
||||
super(blockID, material, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterDimDoor(World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
// We need to ignore particle entities
|
||||
if (world.isRemote || entity instanceof EntityFX)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that this is the top block of the door
|
||||
if (world.getBlockId(x, y - 1, z) == this.blockID)
|
||||
{
|
||||
boolean canUse = true;
|
||||
int metadata = world.getBlockMetadata(x, y - 1, z);
|
||||
if (canUse && entity instanceof EntityLiving)
|
||||
{
|
||||
// Don't check for non-living entities since it might not work right
|
||||
canUse = BaseDimDoor.isEntityFacingDoor(metadata, (EntityLiving) entity);
|
||||
}
|
||||
if (canUse)
|
||||
{
|
||||
// Teleport the entity through the link, if it exists
|
||||
DimLink link = PocketManager.getLink(x, y, z, world.provider.dimensionId);
|
||||
if (link != null)
|
||||
{
|
||||
DDTeleporter.traverseDimDoor(world, link, entity, this);
|
||||
// Turn the door into a rift AFTER teleporting the player.
|
||||
// The door's orientation may be necessary for the teleport.
|
||||
world.setBlock(x, y, z, properties.RiftBlockID);
|
||||
world.setBlockToAir(x, y - 1, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (world.getBlockId(x, y + 1, z) == this.blockID)
|
||||
{
|
||||
enterDimDoor(world, x, y + 1, z, entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeLink(World world, int x, int y, int z)
|
||||
{
|
||||
if (!world.isRemote && world.getBlockId(x, y - 1, z) == this.blockID)
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = dimension.getLink(x, y, z);
|
||||
if (link == null && dimension.isPocketDimension())
|
||||
{
|
||||
dimension.createLink(x, y, z, LinkTypes.SAFE_EXIT,world.getBlockMetadata(x, y - 1, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDrops()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
}
|
||||
32
StevenDimDoors/mod_pocketDim/blocks/UnstableDoor.java
Normal file
32
StevenDimDoors/mod_pocketDim/blocks/UnstableDoor.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class UnstableDoor extends BaseDimDoor
|
||||
{
|
||||
public UnstableDoor(int blockID, Material material, DDProperties properties)
|
||||
{
|
||||
super(blockID, material, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeLink(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, LinkTypes.RANDOM,world.getBlockMetadata(x, y - 1, z));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int getDrops()
|
||||
{
|
||||
return Item.doorIron.itemID;
|
||||
}
|
||||
}
|
||||
38
StevenDimDoors/mod_pocketDim/blocks/WarpDoor.java
Normal file
38
StevenDimDoors/mod_pocketDim/blocks/WarpDoor.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class WarpDoor extends BaseDimDoor
|
||||
{
|
||||
public WarpDoor(int blockID, Material material, DDProperties properties)
|
||||
{
|
||||
super(blockID, material, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeLink(World world, int x, int y, int z)
|
||||
{
|
||||
if (!world.isRemote && world.getBlockId(x, y - 1, z) == this.blockID)
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = dimension.getLink(x, y, z);
|
||||
if (link == null && dimension.isPocketDimension())
|
||||
{
|
||||
dimension.createLink(x, y, z, LinkTypes.SAFE_EXIT,world.getBlockMetadata(x, y - 1, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDrops()
|
||||
{
|
||||
return Item.doorWood.itemID;
|
||||
}
|
||||
}
|
||||
@@ -1,674 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.TileEntityDimDoor;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
||||
|
||||
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.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
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 cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class dimDoor extends BlockContainer
|
||||
{
|
||||
private static Icon blockIconBottom;
|
||||
public dimDoor(int par1, Material material)
|
||||
{
|
||||
super(par1, Material.iron);
|
||||
// this.blockIndexInTexture = 18;
|
||||
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
}
|
||||
|
||||
private static DDProperties properties = null;
|
||||
|
||||
|
||||
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");
|
||||
|
||||
}
|
||||
|
||||
|
||||
//spawns the rift attatched to the block. Doesnt work in creative mode for some reason
|
||||
//TODO make work in creative
|
||||
public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if(!par1World.isRemote)
|
||||
{
|
||||
if(dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World)!=null)
|
||||
{
|
||||
LinkData link= dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World);
|
||||
par1World.setBlock(par2, par3, par4, properties.RiftBlockID);
|
||||
|
||||
}
|
||||
if(dimHelper.instance.getLinkDataFromCoords(par2, par3-1, par4, par1World)!=null)
|
||||
{
|
||||
LinkData link= dimHelper.instance.getLinkDataFromCoords(par2, par3-1, par4, par1World);
|
||||
par1World.setBlock(par2, par3-1, par4, properties.RiftBlockID);
|
||||
|
||||
}
|
||||
if(dimHelper.instance.getLinkDataFromCoords(par2, par3+1, par4, par1World)!=null)
|
||||
{
|
||||
LinkData link= dimHelper.instance.getLinkDataFromCoords(par2, par3+1, par4, par1World);
|
||||
par1World.setBlock(par2, par3+1, par4, properties.RiftBlockID);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//finds the rift data and teleports the player to it.
|
||||
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
{
|
||||
|
||||
if(!par1World.isRemote)
|
||||
{
|
||||
int var12 = (int) (MathHelper.floor_double((double)((par5Entity.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
|
||||
|
||||
int num=0;
|
||||
LinkData linkData=null;
|
||||
|
||||
if(par1World.getBlockId(par2, par3-1, par4)==this.blockID)
|
||||
{
|
||||
num=par1World.getBlockMetadata(par2, par3-1, par4);
|
||||
linkData= dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World);
|
||||
}
|
||||
|
||||
if(par1World.getBlockId(par2, par3+1, par4)==this.blockID)
|
||||
{
|
||||
num=par1World.getBlockMetadata(par2, par3, par4);
|
||||
linkData= dimHelper.instance.getLinkDataFromCoords(par2, par3+1, par4, par1World);
|
||||
}
|
||||
|
||||
if(!(par5Entity instanceof EntityPlayer)&&num>3)
|
||||
{
|
||||
this.onPoweredBlockChange(par1World, par2, par3, par4, false);
|
||||
dimHelper.instance.traverseDimDoor(par1World, linkData, par5Entity);
|
||||
}
|
||||
|
||||
else if(!par1World.isRemote&&(num==5||num==4||num==6||num==7)&&(num-4)==var12)
|
||||
{
|
||||
|
||||
//int destinationID= dimHelper.instance.getDestIDFromCoords(par2, par3, par4, par1World);
|
||||
|
||||
|
||||
this.onPoweredBlockChange(par1World, par2, par3, par4, false);
|
||||
|
||||
dimHelper.instance.traverseDimDoor(par1World, linkData, par5Entity);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
|
||||
boolean shouldOpen=true;
|
||||
|
||||
//System.out.println(String.valueOf(par1World.getBlockMetadata(par2, par3, par4)));
|
||||
if(par5EntityPlayer.inventory.getCurrentItem()!=null)
|
||||
{
|
||||
if(par5EntityPlayer.inventory.getCurrentItem().getItem() == mod_pocketDim.itemRiftBlade)
|
||||
{
|
||||
shouldOpen=false;
|
||||
if(!par1World.isRemote&&par1World.getBlockId(par2, par3-1, par4)==this.blockID)
|
||||
{
|
||||
int var12 = (int) (MathHelper.floor_double((double)((par5EntityPlayer.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
|
||||
|
||||
if(par1World.getBlockMetadata(par2, par3-1, par4)==var12)
|
||||
{
|
||||
var12 = BlockRotator.transformMetadata(var12, 2, Block.doorWood.blockID);
|
||||
}
|
||||
par1World.setBlockMetadataWithNotify(par2, par3-1, par4, var12,2);
|
||||
|
||||
if( dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World)!=null)
|
||||
{
|
||||
dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World).linkOrientation= par1World.getBlockMetadata(par2, par3-1, par4);
|
||||
|
||||
}
|
||||
}
|
||||
if(!par1World.isRemote&&par1World.getBlockId(par2, par3+1, par4)==this.blockID)
|
||||
{
|
||||
int var12 = (int) (MathHelper.floor_double((double)((par5EntityPlayer.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
|
||||
if(par1World.getBlockMetadata(par2, par3, par4)==var12)
|
||||
{
|
||||
var12 = BlockRotator.transformMetadata(var12, 2, Block.doorWood.blockID);
|
||||
}
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var12,2);
|
||||
|
||||
if( dimHelper.instance.getLinkDataFromCoords(par2, par3+1, par4, par1World)!=null)
|
||||
{
|
||||
dimHelper.instance.getLinkDataFromCoords(par2, par3+1, par4, par1World).linkOrientation= par1World.getBlockMetadata(par2, par3, par4);
|
||||
}
|
||||
|
||||
}
|
||||
par1World.playAuxSFXAtEntity(par5EntityPlayer, 1001, par2, par3, par4, 0);
|
||||
|
||||
if(!shouldOpen&&!par1World.isRemote)
|
||||
{
|
||||
|
||||
par5EntityPlayer.inventory.getCurrentItem().damageItem(5, par5EntityPlayer);
|
||||
|
||||
// par5EntityPlayer.sendChatToPlayer("You wedge the stick into a cranny in the door attempt to rotate the it");
|
||||
// par5EntityPlayer.sendChatToPlayer("The door rotates, but the stick breaks in half and is lost");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(shouldOpen)
|
||||
{
|
||||
|
||||
int var10 = this.getFullMetadata(par1World, par2, par3, par4);
|
||||
int var11 = var10 & 7;
|
||||
var11 ^= 4;
|
||||
|
||||
if ((var10 & 8) == 0)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var11,2);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3 - 1, par4, var11,2);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3 - 1, par4, par2, par3, par4);
|
||||
}
|
||||
|
||||
par1World.playAuxSFXAtEntity(par5EntityPlayer, 1003, par2, par3, par4, 0);
|
||||
if(dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World)!=null)
|
||||
{
|
||||
// System.out.println("Link orient is- " +dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World).linkOrientation);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A function to open a door.
|
||||
*/
|
||||
public void onPoweredBlockChange(World par1World, int par2, int par3, int par4, boolean par5)
|
||||
{
|
||||
int var6 = this.getFullMetadata(par1World, par2, par3, par4);
|
||||
boolean var7 = (var6 & 4) != 0;
|
||||
|
||||
if (var7 != par5)
|
||||
{
|
||||
int var8 = var6 & 7;
|
||||
var8 ^= 4;
|
||||
|
||||
if ((var6 & 8) == 0)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var8,2);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3 - 1, par4, var8,2);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3 - 1, par4, par2, par3, par4);
|
||||
}
|
||||
|
||||
par1World.playAuxSFXAtEntity((EntityPlayer)null, 1003, par2, par3, par4, 0);
|
||||
}
|
||||
}
|
||||
//TODO simplify this
|
||||
@Override
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if(!par1World.isRemote&&par1World.getBlockId(par2, par3-1, par4)==this.blockID)
|
||||
{
|
||||
|
||||
|
||||
if(dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World)==null)
|
||||
{
|
||||
|
||||
|
||||
|
||||
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,true, false);
|
||||
// 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);
|
||||
dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World).hasGennedDoor=false;
|
||||
|
||||
}
|
||||
}
|
||||
par1World.setBlockTileEntity(par2, par3, par4, this.createNewTileEntity(par1World));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
//Called to update the render information on the tile entity. Could probably implement a data watcher, but this works fine and is more versatile I think.
|
||||
public dimDoor updateAttatchedTile(IBlockAccess par1World, int par2, int par3, int par4)
|
||||
{
|
||||
TileEntity tile = (TileEntity) par1World.getBlockTileEntity(par2, par3, par4);
|
||||
if(tile instanceof TileEntityDimDoor )
|
||||
{
|
||||
TileEntityDimDoor dimTile=(TileEntityDimDoor)tile;
|
||||
|
||||
if(par1World.getBlockId( par2, par3+1, par4 )==par1World.getBlockId( par2, par3, par4 ))
|
||||
{
|
||||
//dimTile.openOrClosed=false;
|
||||
}
|
||||
if(dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, (World)par1World)==null)
|
||||
{
|
||||
dimTile.openOrClosed=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
dimTile.openOrClosed=true;
|
||||
}
|
||||
|
||||
int metaData = this.getFullMetadata(par1World, par2, par3, par4)%8;
|
||||
dimTile.orientation=metaData;
|
||||
}
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
|
||||
TileEntityDimDoor tile = (TileEntityDimDoor) par1World.getBlockTileEntity(par2, par3, par4);
|
||||
tile.openOrClosed=this.isDoorOpen( par1World, par2, par3, par4);
|
||||
int metaData = this.getFullMetadata(par1World, par2, par3, par4);
|
||||
tile.orientation=metaData%8 ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean getBlocksMovement(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = this.getFullMetadata(par1IBlockAccess, par2, par3, par4);
|
||||
return (var5 & 4) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType()
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
/**
|
||||
* Returns the bounding box of the wired rectangular prism to render.
|
||||
*/
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
this.setBlockBoundsBasedOnState(par1World, par2, par3, par4);
|
||||
return super.getSelectedBoundingBoxFromPool(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
|
||||
* cleared to be reused)
|
||||
*/
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
this.setBlockBoundsBasedOnState(par1World, par2, par3, par4);
|
||||
return super.getCollisionBoundingBoxFromPool(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the blocks bounds based on its current state. Args: world, x, y, z
|
||||
*/
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
this.setDoorRotation(this.getFullMetadata(par1IBlockAccess, par2, par3, par4));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 0, 1, 2 or 3 depending on where the hinge is.
|
||||
*/
|
||||
public int getDoorOrientation(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
return this.getFullMetadata(par1IBlockAccess, par2, par3, par4) & 3;
|
||||
}
|
||||
|
||||
public boolean isDoorOpen(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
return (this.getFullMetadata(par1IBlockAccess, par2, par3, par4) & 4) != 0;
|
||||
}
|
||||
|
||||
private void setDoorRotation(int par1)
|
||||
{
|
||||
float var2 = 0.1875F;
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F);
|
||||
int var3 = par1 & 3;
|
||||
boolean var4 = (par1 & 4) != 0;
|
||||
boolean var5 = (par1 & 16) != 0;
|
||||
|
||||
if (var3 == 0)
|
||||
{
|
||||
if (var4)
|
||||
{
|
||||
if (!var5)
|
||||
{
|
||||
this.setBlockBounds(0.001F, 0.0F, 0.0F, 1.0F, 1.0F, var2);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.001F, 0.0F, 1.0F - var2, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, var2, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else if (var3 == 1)
|
||||
{
|
||||
if (var4)
|
||||
{
|
||||
if (!var5)
|
||||
{
|
||||
this.setBlockBounds(1.0F - var2, 0.0F, 0.001F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.001F, var2, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, var2);
|
||||
}
|
||||
}
|
||||
else if (var3 == 2)
|
||||
{
|
||||
if (var4)
|
||||
{
|
||||
if (!var5)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 1.0F - var2, .99F, 1.0F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, .99F, 1.0F, var2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(1.0F - var2, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else if (var3 == 3)
|
||||
{
|
||||
if (var4)
|
||||
{
|
||||
if (!var5)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, var2, 1.0F, 0.99F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(1.0F - var2, 0.0F, 0.0F, 1.0F, 1.0F, 0.99F);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 1.0F - var2, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is clicked by a player. Args: x, y, z, entityPlayer
|
||||
*/
|
||||
public void onBlockClicked(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
|
||||
{
|
||||
// System.out.println(this.getFullMetadata(par1World, par2, par3, par4)%4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* A function to open a door.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if ((var6 & 8) == 0)
|
||||
{
|
||||
boolean var7 = false;
|
||||
|
||||
if (par1World.getBlockId(par2, par3 + 1, par4) != this.blockID)
|
||||
{
|
||||
par1World.setBlock(par2, par3, par4, 0);
|
||||
var7 = true;
|
||||
}
|
||||
|
||||
/**
|
||||
if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4))
|
||||
{
|
||||
par1World.setBlockWithNotify(par2, par3, par4, 0);
|
||||
var7 = true;
|
||||
|
||||
if (par1World.getBlockId(par2, par3 + 1, par4) == this.blockID)
|
||||
{
|
||||
par1World.setBlockWithNotify(par2, par3 + 1, par4, 0);
|
||||
}
|
||||
}
|
||||
**/
|
||||
|
||||
if (var7)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, properties.DimensionalDoorID, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean var8 = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4) || par1World.isBlockIndirectlyGettingPowered(par2, par3 + 1, par4);
|
||||
|
||||
if ((var8 || par5 > 0 && Block.blocksList[par5].canProvidePower()) && par5 != this.blockID)
|
||||
{
|
||||
this.onPoweredBlockChange(par1World, par2, par3, par4, var8);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (par1World.getBlockId(par2, par3 - 1, par4) != this.blockID)
|
||||
{
|
||||
par1World.setBlock(par2, par3, par4, 0);
|
||||
}
|
||||
|
||||
if (par5 > 0 && par5 != this.blockID)
|
||||
{
|
||||
this.onNeighborBlockChange(par1World, par2, par3 - 1, par4, par5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Ray traces through the blocks collision from start vector to end vector returning a ray trace hit. Args: world,
|
||||
* x, y, z, startVec, endVec
|
||||
*/
|
||||
public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3)
|
||||
{
|
||||
this.setBlockBoundsBasedOnState(par1World, par2, par3, par4);
|
||||
return super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
|
||||
*/
|
||||
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return par3 >= 255 ? false : par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && super.canPlaceBlockAt(par1World, par2, par3, par4) && super.canPlaceBlockAt(par1World, par2, par3 + 1, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mobility information of the block, 0 = free, 1 = can't push but can move over, 2 = total immobility
|
||||
* and stop pistons
|
||||
*/
|
||||
public int getMobilityFlag()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full metadata value created by combining the metadata of both blocks the door takes up.
|
||||
*/
|
||||
public int getFullMetadata(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
|
||||
boolean var6 = (var5 & 8) != 0;
|
||||
int var7;
|
||||
int var8;
|
||||
|
||||
if (var6)
|
||||
{
|
||||
var7 = par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4);
|
||||
var8 = var5;
|
||||
}
|
||||
else
|
||||
{
|
||||
var7 = var5;
|
||||
var8 = par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4);
|
||||
}
|
||||
|
||||
boolean var9 = (var8 & 1) != 0;
|
||||
return var7 & 7 | (var6 ? 8 : 0) | (var9 ? 16 : 0);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
/**
|
||||
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
|
||||
*/
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return Item.doorIron.itemID;
|
||||
}
|
||||
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return (par1 & 8) != 0 ? 0 : (Item.doorIron.itemID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is attempted to be harvested
|
||||
*/
|
||||
public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer)
|
||||
{
|
||||
if (par6EntityPlayer.capabilities.isCreativeMode && (par5 & 8) != 0 && par1World.getBlockId(par2, par3 - 1, par4) == this.blockID)
|
||||
{
|
||||
par1World.setBlock(par2, par3 - 1, par4, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public TileEntity createNewTileEntity(World par1World)
|
||||
{
|
||||
|
||||
TileEntity tile= new TileEntityDimDoor();
|
||||
|
||||
return tile;
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
{
|
||||
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);
|
||||
|
||||
LinkData exitLink=dimData.exitDimLink;
|
||||
exitLink.locDimID=par1World.provider.dimensionId;
|
||||
|
||||
|
||||
dimHelper.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,56 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
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 linkDimDoor extends dimDoor
|
||||
{
|
||||
private Icon blockIconBottom;
|
||||
public linkDimDoor(int par1, Material material) {
|
||||
|
||||
super(par1, material);
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
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");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
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.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class linkExitDoor extends ExitDoor
|
||||
{
|
||||
private Icon blockIconBottom;
|
||||
public linkExitDoor(int par1,Material par2Material)
|
||||
{
|
||||
|
||||
super(par1, Material.wood);
|
||||
//this.blockIndexInTexture = 20;
|
||||
|
||||
|
||||
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,16 @@
|
||||
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.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
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
|
||||
{
|
||||
@@ -30,6 +32,7 @@ public class CommandCreateDungeonRift extends DDCommandBase
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
NewDimData dimension;
|
||||
DungeonHelper dungeonHelper = DungeonHelper.instance();
|
||||
|
||||
if (sender.worldObj.isRemote)
|
||||
@@ -56,17 +59,21 @@ public class CommandCreateDungeonRift extends DDCommandBase
|
||||
}
|
||||
else
|
||||
{
|
||||
DungeonGenerator result;
|
||||
DimLink link;
|
||||
DungeonData result;
|
||||
int x = MathHelper.floor_double(sender.posX);
|
||||
int y = MathHelper.floor_double(sender.posY);
|
||||
int z = MathHelper.floor_double (sender.posZ);
|
||||
LinkData link = new LinkData(sender.worldObj.provider.dimensionId, 0, x, y + 1, z, x, y + 1, z, true, 3);
|
||||
|
||||
int orientation = MathHelper.floor_double((double) ((sender.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
|
||||
if (command[0].equals("random"))
|
||||
{
|
||||
dimHelper.instance.createLink(link);
|
||||
link = dimHelper.instance.createPocket(link, true, true);
|
||||
sender.sendChatToPlayer("Created a rift to a random dungeon (Dimension ID = " + link.destDimID + ").");
|
||||
|
||||
dimension = PocketManager.getDimensionData(sender.worldObj);
|
||||
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON);
|
||||
sender.worldObj.setBlock(x, y + 1, z,mod_pocketDim.blockRift.blockID,0,3);
|
||||
|
||||
sender.sendChatToPlayer("Created a rift to a random dungeon.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -79,9 +86,12 @@ 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 + ").");
|
||||
//TODO currently crashes, need to create the dimension first
|
||||
dimension = PocketManager.getDimensionData(sender.worldObj);
|
||||
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON);
|
||||
PocketManager.getDimensionData(link.destination().getDimension()).initializeDungeon(x, y + 1, z, orientation,link, result);
|
||||
sender.worldObj.setBlock(x, y + 1, z,mod_pocketDim.blockRift.blockID,0,3);
|
||||
sender.sendChatToPlayer("Created a rift to \"" + result.schematicName() + "\" dungeon (Dimension ID = " + link.destination().getDimension() + ").");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -93,20 +103,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 +125,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.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||
|
||||
public class CommandCreatePocket extends DDCommandBase
|
||||
@@ -35,14 +34,14 @@ public class CommandCreatePocket extends DDCommandBase
|
||||
}
|
||||
|
||||
//Place a door leading to a pocket dimension where the player is standing.
|
||||
//The pocket dimension will be serve as a room for the player to build a dungeon.
|
||||
//The pocket dimension will serve as a room for the player to build a dungeon.
|
||||
int x = (int) sender.posX;
|
||||
int y = (int) sender.posY;
|
||||
int z = (int) sender.posZ;
|
||||
LinkData 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,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.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class CommandDeleteAllLinks extends DDCommandBase
|
||||
{
|
||||
@@ -32,53 +33,34 @@ public class CommandDeleteAllLinks extends DDCommandBase
|
||||
int targetDim;
|
||||
boolean shouldGo= true;
|
||||
|
||||
if(command.length==0)
|
||||
{
|
||||
targetDim= sender.worldObj.provider.dimensionId;
|
||||
}
|
||||
else if(command.length==1)
|
||||
if(command.length==1)
|
||||
{
|
||||
targetDim = parseInt(sender, command[0]);
|
||||
if(!dimHelper.dimList.containsKey(targetDim))
|
||||
{
|
||||
sender.sendChatToPlayer("Error- dim "+targetDim+" not registered");
|
||||
shouldGo=false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
targetDim=0;
|
||||
shouldGo=false;
|
||||
sender.sendChatToPlayer("Error-Invalid argument, delete_all_links <targetDimID> or blank for current dim");
|
||||
sender.sendChatToPlayer("Error-Invalid argument, delete_all_links <targetDimID>");
|
||||
}
|
||||
|
||||
if(shouldGo)
|
||||
{
|
||||
if(dimHelper.dimList.containsKey(targetDim))
|
||||
{
|
||||
DimData dim = dimHelper.instance.getDimData(targetDim);
|
||||
ArrayList<LinkData> linksInDim = dim.getLinksInDim();
|
||||
|
||||
NewDimData dim = PocketManager.getDimensionData(targetDim);
|
||||
ArrayList<DimLink> linksInDim = dim.getAllLinks();
|
||||
|
||||
for (LinkData link : linksInDim)
|
||||
for (DimLink link : linksInDim)
|
||||
{
|
||||
World targetWorld = dimHelper.getWorld(targetDim);
|
||||
World targetWorld = PocketManager.loadDimension(targetDim);
|
||||
targetWorld.setBlock(link.source().getX(), link.source().getY(), link.source().getZ(), 0);
|
||||
dim.deleteLink(link);
|
||||
//TODO Probably should check what the block is, but thats annoying so Ill do it later.
|
||||
|
||||
if(targetWorld==null)
|
||||
{
|
||||
dimHelper.initDimension(targetDim);
|
||||
}
|
||||
else if(targetWorld.provider==null)
|
||||
{
|
||||
dimHelper.initDimension(targetDim);
|
||||
}
|
||||
targetWorld = dimHelper.getWorld(targetDim);
|
||||
dim.removeLinkAtCoords(link);
|
||||
targetWorld.setBlock(link.locXCoord, link.locYCoord, link.locZCoord, 0);
|
||||
linksRemoved++;
|
||||
}
|
||||
//dim.linksInThisDim.clear();
|
||||
sender.sendChatToPlayer("Removed " + linksRemoved + " links.");
|
||||
}
|
||||
|
||||
}
|
||||
return DDCommandResult.SUCCESS; //TEMPORARY HACK
|
||||
}
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
|
||||
public class CommandDeleteDimensionData extends DDCommandBase
|
||||
{
|
||||
private static CommandDeleteDimensionData instance = null;
|
||||
|
||||
private CommandDeleteDimensionData()
|
||||
{
|
||||
super("dd-deletedimension", "???");
|
||||
}
|
||||
|
||||
public static CommandDeleteDimensionData instance()
|
||||
{
|
||||
if (instance == null)
|
||||
instance = new CommandDeleteDimensionData();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
int linksRemoved=0;
|
||||
int targetDim;
|
||||
boolean shouldGo= true;
|
||||
|
||||
if (command.length==0)
|
||||
{
|
||||
targetDim= sender.worldObj.provider.dimensionId;
|
||||
}
|
||||
else if (command.length==1)
|
||||
{
|
||||
targetDim = parseInt(sender, command[0]);
|
||||
if(!dimHelper.dimList.containsKey(targetDim))
|
||||
{
|
||||
sender.sendChatToPlayer("Error- dim "+targetDim+" not registered");
|
||||
shouldGo=false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
targetDim=0;
|
||||
shouldGo=false;
|
||||
sender.sendChatToPlayer("Error-Invalid argument, delete_dim_data <targetDimID> or blank for current dim");
|
||||
}
|
||||
|
||||
if(shouldGo)
|
||||
{
|
||||
if(dimHelper.dimList.containsKey(targetDim))
|
||||
{
|
||||
try
|
||||
{
|
||||
for(DimData dimData :dimHelper.dimList.values())
|
||||
{
|
||||
Collection<LinkData> links= new ArrayList<LinkData>();
|
||||
links.addAll( dimData.getLinksInDim());
|
||||
|
||||
for(LinkData link : links)
|
||||
{
|
||||
if(link.destDimID==targetDim)
|
||||
{
|
||||
dimHelper.instance.getDimData(link.locDimID).removeLinkAtCoords(link);
|
||||
linksRemoved++;
|
||||
}
|
||||
if(dimData.dimID==targetDim)
|
||||
{
|
||||
linksRemoved++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
dimHelper.dimList.remove(targetDim);
|
||||
sender.sendChatToPlayer("Removed dimension " + targetDim + " from DimDoors and deleted " + linksRemoved + " links");
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendChatToPlayer("Error- dimension "+targetDim+" not registered with dimDoors");
|
||||
}
|
||||
}
|
||||
return DDCommandResult.SUCCESS; //TEMPORARY HACK
|
||||
}
|
||||
}
|
||||
@@ -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.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class CommandDeleteRifts extends DDCommandBase
|
||||
{
|
||||
@@ -33,56 +33,36 @@ public class CommandDeleteRifts extends DDCommandBase
|
||||
int targetDim;
|
||||
boolean shouldGo= true;
|
||||
|
||||
if(command.length==0)
|
||||
{
|
||||
targetDim= sender.worldObj.provider.dimensionId;
|
||||
}
|
||||
else if(command.length==1)
|
||||
if(command.length==1)
|
||||
{
|
||||
targetDim = parseInt(sender, command[0]);
|
||||
if(!dimHelper.dimList.containsKey(targetDim))
|
||||
{
|
||||
sender.sendChatToPlayer("Error- dim "+targetDim+" not registered");
|
||||
shouldGo=false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
targetDim=0;
|
||||
shouldGo=false;
|
||||
sender.sendChatToPlayer("Error-Invalid argument, delete_links <targetDimID> or blank for current dim");
|
||||
sender.sendChatToPlayer("Error-Invalid argument, delete_all_links <targetDimID>");
|
||||
}
|
||||
|
||||
if(shouldGo)
|
||||
{
|
||||
if(dimHelper.dimList.containsKey(targetDim))
|
||||
{
|
||||
DimData dim = dimHelper.instance.getDimData(targetDim);
|
||||
ArrayList<LinkData> linksInDim = dim.getLinksInDim();
|
||||
|
||||
NewDimData dim = PocketManager.getDimensionData(targetDim);
|
||||
ArrayList<DimLink> linksInDim = dim.getAllLinks();
|
||||
|
||||
for(LinkData link : linksInDim)
|
||||
for (DimLink link : linksInDim)
|
||||
{
|
||||
World targetWorld = dimHelper.getWorld(targetDim);
|
||||
|
||||
if(targetWorld==null)
|
||||
World targetWorld = PocketManager.loadDimension(targetDim);
|
||||
|
||||
if(sender.worldObj.getBlockId(link.source().getX(), link.source().getY(), link.source().getZ())==mod_pocketDim.blockRift.blockID)
|
||||
{
|
||||
dimHelper.initDimension(targetDim);
|
||||
}
|
||||
else if(targetWorld.provider==null)
|
||||
{
|
||||
dimHelper.initDimension(targetDim);
|
||||
}
|
||||
targetWorld = dimHelper.getWorld(targetDim);
|
||||
|
||||
if (targetWorld.getBlockId(link.locXCoord, link.locYCoord, link.locZCoord) == mod_pocketDim.blockRift.blockID)
|
||||
{
|
||||
dim.removeLinkAtCoords(link);
|
||||
targetWorld.setBlock(link.locXCoord, link.locYCoord, link.locZCoord, 0);
|
||||
targetWorld.setBlock(link.source().getX(), link.source().getY(), link.source().getZ(), 0);
|
||||
linksRemoved++;
|
||||
dim.deleteLink(link);
|
||||
}
|
||||
}
|
||||
sender.sendChatToPlayer("Removed "+linksRemoved+" rifts.");
|
||||
}
|
||||
sender.sendChatToPlayer("Removed " + linksRemoved + " rifts.");
|
||||
|
||||
}
|
||||
return DDCommandResult.SUCCESS; //TEMPORARY HACK
|
||||
}
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
|
||||
public class CommandPrintDimensionData extends DDCommandBase
|
||||
{
|
||||
private static CommandPrintDimensionData instance = null;
|
||||
|
||||
private CommandPrintDimensionData()
|
||||
{
|
||||
super("dd-dimensiondata", "[dimension number]");
|
||||
}
|
||||
|
||||
public static CommandPrintDimensionData instance()
|
||||
{
|
||||
if (instance == null)
|
||||
instance = new CommandPrintDimensionData();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
int targetDim;
|
||||
DimData dimData;
|
||||
|
||||
if (command.length == 0)
|
||||
{
|
||||
targetDim = sender.worldObj.provider.dimensionId;
|
||||
}
|
||||
else if (command.length == 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
targetDim = Integer.parseInt(command[0]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return DDCommandResult.INVALID_DIMENSION_ID;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return DDCommandResult.TOO_MANY_ARGUMENTS;
|
||||
}
|
||||
|
||||
dimData = dimHelper.instance.getDimData(targetDim);
|
||||
if (dimData == null)
|
||||
{
|
||||
return DDCommandResult.UNREGISTERED_DIMENSION;
|
||||
}
|
||||
|
||||
ArrayList<LinkData> links = dimData.getLinksInDim();
|
||||
|
||||
sender.sendChatToPlayer("Dimension ID = " + dimData.dimID);
|
||||
sender.sendChatToPlayer("Dimension Depth = " + dimData.depth);
|
||||
for (LinkData link : links)
|
||||
{
|
||||
sender.sendChatToPlayer(link.printLinkData());
|
||||
}
|
||||
return DDCommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
|
||||
public class CommandPruneDimensions extends DDCommandBase
|
||||
{
|
||||
private static CommandPruneDimensions instance = null;
|
||||
|
||||
private CommandPruneDimensions()
|
||||
{
|
||||
super("dd-prune", "['delete']");
|
||||
}
|
||||
|
||||
public static CommandPruneDimensions instance()
|
||||
{
|
||||
if (instance == null)
|
||||
instance = new CommandPruneDimensions();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
if (command.length > 1)
|
||||
{
|
||||
return DDCommandResult.TOO_MANY_ARGUMENTS;
|
||||
}
|
||||
if (command.length == 1 && !command[0].equalsIgnoreCase("delete"))
|
||||
{
|
||||
return DDCommandResult.INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
for (DimData data : allDims)
|
||||
{
|
||||
for (LinkData link : data.getLinksInDim())
|
||||
{
|
||||
linkedDimensions.add(link.destDimID);
|
||||
}
|
||||
}
|
||||
for (LinkData link : dimHelper.instance.interDimLinkList.values())
|
||||
{
|
||||
linkedDimensions.add(link.destDimID);
|
||||
}
|
||||
for (DimData data : allDims)
|
||||
{
|
||||
if (!linkedDimensions.contains(data.dimID))
|
||||
{
|
||||
if (dimHelper.instance.pruneDimension(data, deleteFolders))
|
||||
{
|
||||
removedCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
dimHelper.instance.save();
|
||||
sender.sendChatToPlayer("Removed " + removedCount + " unreachable pocket dims.");
|
||||
return DDCommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
package StevenDimDoors.mod_pocketDim.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class CommandResetDungeons extends DDCommandBase
|
||||
{
|
||||
@@ -24,6 +29,10 @@ public class CommandResetDungeons extends DDCommandBase
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
if(sender.worldObj.isRemote)
|
||||
{
|
||||
return DDCommandResult.SUCCESS;
|
||||
}
|
||||
if (command.length > 0)
|
||||
{
|
||||
return DDCommandResult.TOO_FEW_ARGUMENTS;
|
||||
@@ -31,19 +40,49 @@ public class CommandResetDungeons extends DDCommandBase
|
||||
|
||||
int dungeonCount = 0;
|
||||
int resetCount = 0;
|
||||
|
||||
for (DimData data : dimHelper.dimList.values())
|
||||
ArrayList<Integer> dimsToDelete = new ArrayList<Integer>();
|
||||
ArrayList<Integer> dimsToFix = new ArrayList<Integer>();
|
||||
|
||||
for (NewDimData data : PocketManager.getDimensions())
|
||||
{
|
||||
if (data.isDimRandomRift)
|
||||
|
||||
if(DimensionManager.getWorld(data.id())==null&&data.isDungeon())
|
||||
{
|
||||
resetCount++;
|
||||
dungeonCount++;
|
||||
if (dimHelper.instance.resetPocket(data))
|
||||
dimsToDelete.add(data.id());
|
||||
}
|
||||
else if(data.isDungeon())
|
||||
{
|
||||
dimsToFix.add(data.id());
|
||||
dungeonCount++;
|
||||
for(DimLink link : data.links())
|
||||
{
|
||||
resetCount++;
|
||||
if(link.linkType()==LinkTypes.REVERSE)
|
||||
{
|
||||
data.createLink(link.source(), LinkTypes.DUNGEON_EXIT, link.orientation());
|
||||
}
|
||||
if(link.linkType()==LinkTypes.DUNGEON)
|
||||
{
|
||||
data.createLink(link.source(), LinkTypes.DUNGEON, link.orientation());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(Integer dimID:dimsToDelete)
|
||||
{
|
||||
PocketManager.deletePocket(PocketManager.getDimensionData(dimID), true);
|
||||
}
|
||||
/**
|
||||
* temporary workaround
|
||||
*/
|
||||
for(Integer dimID: dimsToFix)
|
||||
{
|
||||
PocketManager.getDimensionData(dimID).setParentToRoot();
|
||||
}
|
||||
//TODO- for some reason the parent field of loaded dimenions get reset to null if I call .setParentToRoot() before I delete the pockets.
|
||||
//TODO implement blackList
|
||||
//Notify the user of the results
|
||||
sender.sendChatToPlayer("Reset complete. " + resetCount + " out of " + dungeonCount + " dungeons were reset.");
|
||||
return DDCommandResult.SUCCESS;
|
||||
|
||||
@@ -6,13 +6,16 @@ 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.DDTeleporter;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
|
||||
public class CommandTeleportPlayer extends DDCommandBase
|
||||
@@ -39,7 +42,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(DimensionManager.getStaticDimensionIDs()); //Gets list of all registered dimensions, regardless if loaded or not
|
||||
EntityPlayer targetPlayer = sender;
|
||||
int dimDestinationID = sender.worldObj.provider.dimensionId;
|
||||
|
||||
@@ -66,13 +69,10 @@ public class CommandTeleportPlayer extends DDCommandBase
|
||||
{
|
||||
return DDCommandResult.INVALID_DIMENSION_ID;
|
||||
}
|
||||
if(dimHelper.getWorld(dimDestinationID)==null)
|
||||
{
|
||||
dimHelper.initDimension(dimDestinationID);
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().transferPlayerToDimension((EntityPlayerMP) targetPlayer, dimDestinationID, new BlankTeleporter(dimHelper.getWorld(dimDestinationID)));
|
||||
targetPlayer.setPositionAndUpdate(Integer.parseInt(command[2]),Integer.parseInt(command[3]),Integer.parseInt(command[4]));
|
||||
|
||||
PocketManager.loadDimension(dimDestinationID);
|
||||
Point4D destination = new Point4D(Integer.parseInt(command[2]),Integer.parseInt(command[3]),Integer.parseInt(command[4]),dimDestinationID);
|
||||
DDTeleporter.teleportEntity(targetPlayer, destination, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
702
StevenDimDoors/mod_pocketDim/core/DDTeleporter.java
Normal file
702
StevenDimDoors/mod_pocketDim/core/DDTeleporter.java
Normal file
@@ -0,0 +1,702 @@
|
||||
package StevenDimDoors.mod_pocketDim.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
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.item.ItemDoor;
|
||||
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.Point3D;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.BlockRift;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.IDimDoor;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import StevenDimDoors.mod_pocketDim.world.PocketBuilder;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class DDTeleporter
|
||||
{
|
||||
private static final Random random = new Random();
|
||||
private static final int END_DIMENSION_ID = 1;
|
||||
private static final int MAX_ROOT_SHIFT_CHANCE = 100;
|
||||
private static final int START_ROOT_SHIFT_CHANCE = 0;
|
||||
private static final int ROOT_SHIFT_CHANCE_PER_LEVEL = 5;
|
||||
|
||||
public static int cooldown = 0;
|
||||
|
||||
private DDTeleporter() { }
|
||||
|
||||
/**Checks if the destination supplied is valid, ie, filled by any non-replaceable block.
|
||||
*
|
||||
* @param entity
|
||||
* @param world
|
||||
* @param destination
|
||||
* @param properties
|
||||
* @return
|
||||
*/
|
||||
public static boolean CheckDestination(Entity entity, WorldServer world, Point4D destination,DDProperties properties)
|
||||
{
|
||||
int x = destination.getX();
|
||||
int y = destination.getY();
|
||||
int z = destination.getZ();
|
||||
int blockIDTop;
|
||||
int blockIDBottom;
|
||||
|
||||
Point3D point;
|
||||
|
||||
int orientation;
|
||||
|
||||
orientation = getDestinationOrientation(destination, properties);
|
||||
entity.rotationYaw = (orientation * 90) + 90;
|
||||
switch (orientation)
|
||||
{
|
||||
case 0:
|
||||
point= new Point3D(MathHelper.floor_double(x - 0.5), y - 1, MathHelper.floor_double(z + 0.5));
|
||||
break;
|
||||
case 1:
|
||||
point= new Point3D(MathHelper.floor_double(x + 0.5), y - 1, MathHelper.floor_double(z - 0.5));
|
||||
break;
|
||||
case 2:
|
||||
point = new Point3D(MathHelper.floor_double(x + 1.5), y - 1, MathHelper.floor_double(z + 0.5));
|
||||
break;
|
||||
case 3:
|
||||
point = new Point3D(MathHelper.floor_double(x + 0.5), y - 1, MathHelper.floor_double(z + 1.5));
|
||||
break;
|
||||
default:
|
||||
point = new Point3D(x, y - 1, z);
|
||||
break;
|
||||
}
|
||||
blockIDBottom = world.getBlockId(point.getX(), point.getY(), point.getZ());
|
||||
blockIDTop = world.getBlockId(point.getX(), point.getY()+1, point.getZ());
|
||||
|
||||
if(!(Block.blocksList[blockIDBottom]==null))
|
||||
{
|
||||
if(!Block.blocksList[blockIDBottom].isBlockReplaceable(world, point.getX(), point.getY(), point.getZ()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(!(Block.blocksList[blockIDTop]==null))
|
||||
{
|
||||
if(!Block.blocksList[blockIDTop].isBlockReplaceable(world, point.getX(), point.getY()+1, point.getZ()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
private static void placeInPortal(Entity entity, WorldServer world, Point4D destination, DDProperties properties, boolean checkOrientation)
|
||||
{
|
||||
int x = destination.getX();
|
||||
int y = destination.getY();
|
||||
int z = destination.getZ();
|
||||
|
||||
int orientation;
|
||||
if (checkOrientation)
|
||||
{
|
||||
orientation = getDestinationOrientation(destination, properties);
|
||||
entity.rotationYaw = (orientation * 90) + 90;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Teleport the entity to the precise destination point
|
||||
orientation = -1;
|
||||
}
|
||||
|
||||
if(!CheckDestination(entity, world, destination, properties))
|
||||
{
|
||||
if(entity instanceof EntityPlayerMP)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
player.rotationYaw=(orientation * 90)+90;
|
||||
switch (orientation)
|
||||
{
|
||||
case 0:
|
||||
player.setPositionAndUpdate(x + 0.5, y - 1, z + 0.5);
|
||||
break;
|
||||
case 1:
|
||||
player.setPositionAndUpdate(x + 0.5, y - 1, z + 0.5);
|
||||
break;
|
||||
case 2:
|
||||
player.setPositionAndUpdate(x + 0.5, y - 1, z + 0.5);
|
||||
break;
|
||||
case 3:
|
||||
player.setPositionAndUpdate(x + 0.5, y - 1, z + .5);
|
||||
break;
|
||||
default:
|
||||
player.setPositionAndUpdate(x, y - 1, z);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (entity instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
switch (orientation)
|
||||
{
|
||||
case 0:
|
||||
player.setPositionAndUpdate(x - 0.5, y - 1, z + 0.5);
|
||||
break;
|
||||
case 1:
|
||||
player.setPositionAndUpdate(x + 0.5, y - 1, z - 0.5);
|
||||
break;
|
||||
case 2:
|
||||
player.setPositionAndUpdate(x + 1.5, y - 1, z + 0.5);
|
||||
break;
|
||||
case 3:
|
||||
player.setPositionAndUpdate(x + 0.5, y - 1, z + 1.5);
|
||||
break;
|
||||
default:
|
||||
player.setPositionAndUpdate(x + 0.5, y - 1, z + 0.5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (entity instanceof EntityMinecart)
|
||||
{
|
||||
entity.motionX = 0;
|
||||
entity.motionZ = 0;
|
||||
entity.motionY = 0;
|
||||
switch (orientation)
|
||||
{
|
||||
case 0:
|
||||
DDTeleporter.setEntityPosition(entity, x - 0.5, y, z + 0.5);
|
||||
entity.motionX = -0.39;
|
||||
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
||||
break;
|
||||
case 1:
|
||||
DDTeleporter.setEntityPosition(entity, x + 0.5, y, z - 0.5);
|
||||
entity.motionZ = -0.39;
|
||||
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
||||
break;
|
||||
case 2:
|
||||
DDTeleporter.setEntityPosition(entity, x + 1.5, y, z + 0.5);
|
||||
entity.motionX = 0.39;
|
||||
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
||||
break;
|
||||
case 3:
|
||||
DDTeleporter.setEntityPosition(entity, x + 0.5, y, z + 1.5 );
|
||||
entity.motionZ = 0.39;
|
||||
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
||||
break;
|
||||
default:
|
||||
DDTeleporter.setEntityPosition(entity, x + 0.5, y, z + 0.5);
|
||||
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (orientation)
|
||||
{
|
||||
case 0:
|
||||
setEntityPosition(entity, x - 0.5, y, z + 0.5);
|
||||
break;
|
||||
case 1:
|
||||
setEntityPosition(entity, x + 0.5, y, z - 0.5);
|
||||
break;
|
||||
case 2:
|
||||
setEntityPosition(entity, x + 1.5, y, z + 0.5);
|
||||
break;
|
||||
case 3:
|
||||
setEntityPosition(entity, x + 0.5, y, z + 1.5);
|
||||
break;
|
||||
default:
|
||||
setEntityPosition(entity, x + 0.5, y, z + 0.5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
private static int getDestinationOrientation(Point4D door, DDProperties properties)
|
||||
{
|
||||
World world = DimensionManager.getWorld(door.getDimension());
|
||||
if (world == null)
|
||||
{
|
||||
throw new IllegalStateException("The destination world should be loaded!");
|
||||
}
|
||||
|
||||
//Check if the block below that point is actually a door
|
||||
int blockID = world.getBlockId(door.getX(), door.getY() - 1, door.getZ());
|
||||
if (blockID != properties.DimensionalDoorID && blockID != properties.WarpDoorID &&
|
||||
blockID != properties.TransientDoorID && blockID != properties.UnstableDoorID
|
||||
&& blockID != properties.GoldDimDoorID)
|
||||
{
|
||||
//Return the pocket's orientation instead
|
||||
return PocketManager.getDimensionData(door.getDimension()).orientation();
|
||||
}
|
||||
|
||||
//Return the orientation portion of its metadata
|
||||
return world.getBlockMetadata(door.getX(), door.getY() - 1, door.getZ()) & 3;
|
||||
}
|
||||
|
||||
public static Entity teleportEntity(Entity entity, Point4D destination, boolean checkOrientation)
|
||||
{
|
||||
if (entity == null)
|
||||
{
|
||||
throw new IllegalArgumentException("entity cannot be null.");
|
||||
}
|
||||
if (destination == null)
|
||||
{
|
||||
throw new IllegalArgumentException("destination cannot be null.");
|
||||
}
|
||||
|
||||
//This beautiful teleport method is based off of xCompWiz's teleport function.
|
||||
|
||||
WorldServer oldWorld = (WorldServer) entity.worldObj;
|
||||
WorldServer newWorld;
|
||||
EntityPlayerMP player = (entity instanceof EntityPlayerMP) ? (EntityPlayerMP) entity : null;
|
||||
DDProperties properties = DDProperties.instance();
|
||||
|
||||
// Is something riding? Handle it first.
|
||||
if (entity.riddenByEntity != null)
|
||||
{
|
||||
return teleportEntity(entity.riddenByEntity, destination, checkOrientation);
|
||||
}
|
||||
|
||||
// Are we riding something? Dismount and tell the mount to go first.
|
||||
Entity cart = entity.ridingEntity;
|
||||
if (cart != null)
|
||||
{
|
||||
entity.mountEntity(null);
|
||||
cart = teleportEntity(cart, destination, checkOrientation);
|
||||
// We keep track of both so we can remount them on the other side.
|
||||
}
|
||||
|
||||
// Determine if our destination is in another realm.
|
||||
boolean difDest = entity.dimension != destination.getDimension();
|
||||
if (difDest)
|
||||
{
|
||||
// Destination isn't loaded? Then we need to load it.
|
||||
newWorld = PocketManager.loadDimension(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, destination, properties, checkOrientation);
|
||||
|
||||
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 = 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(newWorld);
|
||||
|
||||
// Synchronize with the server so the client knows what time it is and what it's holding.
|
||||
player.mcServer.getConfigurationManager().updateTimeAndWeatherForPlayer(player, 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)
|
||||
{
|
||||
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, destination, properties, checkOrientation);
|
||||
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.
|
||||
* @param world - world the player is currently in
|
||||
* @param link - the link the player is using to teleport; sends the player to its destination
|
||||
* @param player - the instance of the player to be teleported
|
||||
*/
|
||||
public static void traverseDimDoor(World world, DimLink link, Entity entity, Block door)
|
||||
{
|
||||
if (world == null)
|
||||
{
|
||||
throw new IllegalArgumentException("world cannot be null.");
|
||||
}
|
||||
if (link == null)
|
||||
{
|
||||
throw new IllegalArgumentException("link cannot be null.");
|
||||
}
|
||||
if (entity == null)
|
||||
{
|
||||
throw new IllegalArgumentException("entity cannot be null.");
|
||||
}
|
||||
if (world.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (cooldown == 0 || entity instanceof EntityPlayer)
|
||||
{
|
||||
cooldown = 2 + random.nextInt(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!initializeDestination(link, DDProperties.instance(),door))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (link.linkType() == LinkTypes.RANDOM)
|
||||
{
|
||||
Point4D randomDestination = getRandomDestination();
|
||||
if (randomDestination != null)
|
||||
{
|
||||
entity = teleportEntity(entity, randomDestination, true);
|
||||
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buildExitDoor(door, link, DDProperties.instance());
|
||||
entity = teleportEntity(entity, link.destination(), link.linkType() != LinkTypes.UNSAFE_EXIT);
|
||||
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean initializeDestination(DimLink link, DDProperties properties, Block door)
|
||||
{
|
||||
if (link.hasDestination())
|
||||
{
|
||||
if(PocketManager.isBlackListed(link.destination().getDimension()))
|
||||
{
|
||||
link=PocketManager.getDimensionData(link.source().getDimension()).createLink(link.source,LinkTypes.SAFE_EXIT,link.orientation);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check the destination type and respond accordingly
|
||||
switch (link.linkType())
|
||||
{
|
||||
case LinkTypes.DUNGEON:
|
||||
return PocketBuilder.generateNewDungeonPocket(link, properties);
|
||||
case LinkTypes.POCKET:
|
||||
return PocketBuilder.generateNewPocket(link, properties,door);
|
||||
case LinkTypes.SAFE_EXIT:
|
||||
return generateSafeExit(link, properties);
|
||||
case LinkTypes.DUNGEON_EXIT:
|
||||
return generateDungeonExit(link, properties);
|
||||
case LinkTypes.UNSAFE_EXIT:
|
||||
return generateUnsafeExit(link);
|
||||
case LinkTypes.NORMAL:
|
||||
case LinkTypes.REVERSE:
|
||||
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 random link's source point
|
||||
// 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.
|
||||
|
||||
// Iterate over the root dimensions. Pocket dimensions cannot be roots.
|
||||
// Don't just pick a random root and a random link within that root
|
||||
// because we want to have unbiased selection among all links.
|
||||
ArrayList<Point4D> matches = new ArrayList<Point4D>();
|
||||
for (NewDimData dimension : PocketManager.getRootDimensions())
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean generateUnsafeExit(DimLink link)
|
||||
{
|
||||
// An unsafe exit teleports the user to the first available air space
|
||||
// in the pocket's root dimension. X and Z are kept roughly the same
|
||||
// as the source location, but Y is set by searching down. We don't
|
||||
// place a platform at the destination. We also don't place a reverse
|
||||
// link at the destination, so it's a one-way trip. Good luck!
|
||||
|
||||
// To avoid loops, don't generate a destination if the player is
|
||||
// already in a non-pocket dimension.
|
||||
|
||||
NewDimData current = PocketManager.getDimensionData(link.source.getDimension());
|
||||
if (current.isPocketDimension())
|
||||
{
|
||||
Point4D source = link.source();
|
||||
World world = PocketManager.loadDimension(current.root().id());
|
||||
if (world == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Point3D destination = yCoordHelper.findDropPoint(world, source.getX(), source.getY() + 1, source.getZ());
|
||||
if (destination != null)
|
||||
{
|
||||
current.root().setDestination(link, destination.getX(), destination.getY(), destination.getZ());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void buildExitDoor(Block door,DimLink link, DDProperties prop)
|
||||
{
|
||||
World startWorld = PocketManager.loadDimension(link.source().getDimension());
|
||||
World destWorld = PocketManager.loadDimension(link.destination().getDimension());
|
||||
TileEntity doorTE = startWorld.getBlockTileEntity(link.source().getX(), link.source().getY(), link.source.getZ());
|
||||
if(doorTE instanceof TileEntityDimDoor)
|
||||
{
|
||||
if((TileEntityDimDoor.class.cast(doorTE).hasGennedPair))
|
||||
{
|
||||
return;
|
||||
}
|
||||
TileEntityDimDoor.class.cast(doorTE).hasGennedPair=true;
|
||||
Block blockToReplace = Block.blocksList[destWorld.getBlockId(link.destination().getX(), link.destination().getY(), link.destination().getZ())];
|
||||
|
||||
if(!destWorld.isAirBlock(link.destination().getX(), link.destination().getY(), link.destination().getZ()))
|
||||
{
|
||||
if(!blockToReplace.isBlockReplaceable(destWorld, link.destination().getX(), link.destination().getY(), link.destination().getZ()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BaseItemDoor.placeDoorBlock(destWorld, link.destination().getX(), link.destination().getY()-1, link.destination().getZ(),link.getDestinationOrientation(), door);
|
||||
TileEntity doorDestTE = startWorld.getBlockTileEntity(link.destination().getX(), link.destination().getY(), link.destination().getZ());
|
||||
|
||||
if(doorDestTE instanceof TileEntityDimDoor)
|
||||
{
|
||||
TileEntityDimDoor.class.cast(doorDestTE).hasGennedPair=true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
private static boolean generateSafeExit(DimLink link, DDProperties properties)
|
||||
{
|
||||
NewDimData current = PocketManager.getDimensionData(link.source.getDimension());
|
||||
return generateSafeExit(current.root(), link, properties);
|
||||
}
|
||||
|
||||
private static boolean generateDungeonExit(DimLink link, DDProperties properties)
|
||||
{
|
||||
// A dungeon exit acts the same as a safe exit, but has the chance of
|
||||
// taking the user to any non-pocket dimension, excluding Limbo and The End.
|
||||
|
||||
NewDimData current = PocketManager.getDimensionData(link.source.getDimension());
|
||||
ArrayList<NewDimData> roots = PocketManager.getRootDimensions();
|
||||
int shiftChance = START_ROOT_SHIFT_CHANCE + ROOT_SHIFT_CHANCE_PER_LEVEL * (current.packDepth() - 1);
|
||||
|
||||
if (random.nextInt(MAX_ROOT_SHIFT_CHANCE) < shiftChance)
|
||||
{
|
||||
for (int attempts = 0; attempts < 10; attempts++)
|
||||
{
|
||||
NewDimData selection = roots.get( random.nextInt(roots.size()) );
|
||||
if (selection.id() != END_DIMENSION_ID &&
|
||||
selection.id() != properties.LimboDimensionID &&
|
||||
selection != current.root())
|
||||
{
|
||||
return generateSafeExit(selection, link, properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Yes, this could lead you back into Limbo. That's intentional.
|
||||
return generateSafeExit(current.root(), link, properties);
|
||||
}
|
||||
|
||||
private static boolean generateSafeExit(NewDimData destinationDim, DimLink link, DDProperties properties)
|
||||
{
|
||||
// A safe exit attempts to place a Warp Door in a dimension with
|
||||
// some precautions to protect the player. The X and Z coordinates
|
||||
// are fixed to match the source (mostly - may be shifted a little),
|
||||
// but the Y coordinate is chosen by searching for the nearest
|
||||
// a safe location to place the door.
|
||||
|
||||
Point4D source = link.source();
|
||||
World world = PocketManager.loadDimension(destinationDim.id());
|
||||
if (world == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int startY = source.getY() - 2;
|
||||
Point3D destination;
|
||||
Point3D locationUp = yCoordHelper.findSafeCubeUp(world, source.getX(), startY, source.getZ());
|
||||
Point3D locationDown = yCoordHelper.findSafeCubeDown(world, source.getX(), startY, source.getZ());
|
||||
|
||||
if (locationUp == null)
|
||||
{
|
||||
destination = locationDown;
|
||||
}
|
||||
else if (locationDown == null)
|
||||
{
|
||||
destination = locationUp;
|
||||
}
|
||||
else if (locationUp.getY() - startY <= startY - locationDown.getY())
|
||||
{
|
||||
destination = locationUp;
|
||||
}
|
||||
else
|
||||
{
|
||||
destination = locationDown;
|
||||
}
|
||||
if (destination != null)
|
||||
{
|
||||
// Set up a 3x3 platform at the destination
|
||||
int x = destination.getX();
|
||||
int y = destination.getY();
|
||||
int z = destination.getZ();
|
||||
for (int dx = -1; dx <= 1; dx++)
|
||||
{
|
||||
for (int dz = -1; dz <= 1; dz++)
|
||||
{
|
||||
world.setBlock(x + dx, y, z + dz, properties.FabricBlockID);
|
||||
}
|
||||
}
|
||||
|
||||
// Create a reverse link for returning
|
||||
int orientation = getDestinationOrientation(source, properties);
|
||||
NewDimData sourceDim = PocketManager.getDimensionData(link.source().getDimension());
|
||||
DimLink reverse = destinationDim.createLink(x, y + 2, z, LinkTypes.REVERSE,orientation);
|
||||
sourceDim.setDestination(reverse, source.getX(), source.getY(), source.getZ());
|
||||
|
||||
// Set up the warp door at the destination
|
||||
orientation = BlockRotator.transformMetadata(orientation, 2, properties.WarpDoorID);
|
||||
ItemDimensionalDoor.placeDoorBlock(world, x, y + 1, z, orientation, mod_pocketDim.warpDoor);
|
||||
|
||||
// Complete the link to the destination
|
||||
// This comes last so the destination isn't set unless everything else works first
|
||||
destinationDim.setDestination(link, x, y + 2, z);
|
||||
}
|
||||
|
||||
return (destination != null);
|
||||
}
|
||||
}
|
||||
91
StevenDimDoors/mod_pocketDim/core/DimLink.java
Normal file
91
StevenDimDoors/mod_pocketDim/core/DimLink.java
Normal file
@@ -0,0 +1,91 @@
|
||||
package StevenDimDoors.mod_pocketDim.core;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public abstract class DimLink
|
||||
{
|
||||
protected Point4D source;
|
||||
protected DimLink parent;
|
||||
protected LinkTail tail;
|
||||
protected int orientation;
|
||||
protected List<DimLink> children;
|
||||
|
||||
protected DimLink(Point4D source, DimLink parent, int orientation)
|
||||
{
|
||||
|
||||
if (parent.source.getDimension() != source.getDimension())
|
||||
{
|
||||
// Ban having children in other dimensions to avoid serialization issues with cross-dimensional tails
|
||||
throw new IllegalArgumentException("source and parent.source must have the same dimension.");
|
||||
}
|
||||
this.orientation=orientation;
|
||||
this.parent = parent;
|
||||
this.source = source;
|
||||
this.tail = parent.tail;
|
||||
this.children = new LinkedList<DimLink>();
|
||||
parent.children.add(this);
|
||||
}
|
||||
|
||||
protected DimLink(Point4D source, int linkType, int orientation)
|
||||
{
|
||||
if ((linkType < LinkTypes.ENUM_MIN || linkType > LinkTypes.ENUM_MAX) && linkType != LinkTypes.CLIENT_SIDE)
|
||||
{
|
||||
throw new IllegalArgumentException("The specified link type is invalid.");
|
||||
}
|
||||
this.orientation = orientation;
|
||||
this.parent = null;
|
||||
this.source = source;
|
||||
this.tail = new LinkTail(linkType, null);
|
||||
this.children = new LinkedList<DimLink>();
|
||||
}
|
||||
|
||||
public Point4D source()
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
public Point4D destination()
|
||||
{
|
||||
return tail.getDestination();
|
||||
}
|
||||
public int getDestinationOrientation()
|
||||
{
|
||||
return PocketManager.getLink(source.getX(), source.getY(), source.getZ(), source.getDimension()).orientation();
|
||||
}
|
||||
public boolean hasDestination()
|
||||
{
|
||||
return (tail.getDestination() != null);
|
||||
}
|
||||
|
||||
public Iterable<DimLink> children()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
|
||||
public int childCount()
|
||||
{
|
||||
return children.size();
|
||||
}
|
||||
|
||||
public DimLink parent()
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
public int linkType()
|
||||
{
|
||||
return tail.getLinkType();
|
||||
}
|
||||
public int orientation()
|
||||
{
|
||||
return orientation;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return source + " -> " + (hasDestination() ? destination() : "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package StevenDimDoors.mod_pocketDim.core;
|
||||
|
||||
public interface IDimRegistrationCallback
|
||||
{
|
||||
public NewDimData registerDimension(int dimensionID, int rootID);
|
||||
}
|
||||
32
StevenDimDoors/mod_pocketDim/core/LinkTail.java
Normal file
32
StevenDimDoors/mod_pocketDim/core/LinkTail.java
Normal file
@@ -0,0 +1,32 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
21
StevenDimDoors/mod_pocketDim/core/LinkTypes.java
Normal file
21
StevenDimDoors/mod_pocketDim/core/LinkTypes.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package StevenDimDoors.mod_pocketDim.core;
|
||||
|
||||
public class LinkTypes
|
||||
{
|
||||
private LinkTypes() { }
|
||||
|
||||
public static final int ENUM_MIN = 0;
|
||||
public static final int ENUM_MAX = 7;
|
||||
|
||||
public static final int CLIENT_SIDE = -1337;
|
||||
|
||||
// WARNING: Don't modify these values carelessly or you'll risk breaking links in existing worlds!
|
||||
public static final int NORMAL = 0;
|
||||
public static final int POCKET = 1;
|
||||
public static final int DUNGEON = 2;
|
||||
public static final int RANDOM = 3;
|
||||
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 REVERSE = 7;
|
||||
}
|
||||
551
StevenDimDoors/mod_pocketDim/core/NewDimData.java
Normal file
551
StevenDimDoors/mod_pocketDim/core/NewDimData.java
Normal file
@@ -0,0 +1,551 @@
|
||||
package StevenDimDoors.mod_pocketDim.core;
|
||||
|
||||
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.Point3D;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.IUpdateWatcher;
|
||||
|
||||
public abstract class NewDimData
|
||||
{
|
||||
private static class InnerDimLink extends DimLink
|
||||
{
|
||||
public InnerDimLink(Point4D source, DimLink parent,int orientation)
|
||||
{
|
||||
super(source, parent,orientation);
|
||||
}
|
||||
|
||||
public InnerDimLink(Point4D source, int linkType, int orientation)
|
||||
{
|
||||
super(source, linkType,orientation);
|
||||
}
|
||||
|
||||
public void setDestination(int x, int y, int z, NewDimData dimension)
|
||||
{
|
||||
tail.setDestination(new Point4D(x, y, z, dimension.id()));
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
//Release children
|
||||
for (DimLink child : children)
|
||||
{
|
||||
((InnerDimLink) child).parent = null;
|
||||
}
|
||||
children.clear();
|
||||
|
||||
//Release parent
|
||||
if (parent != null)
|
||||
{
|
||||
parent.children.remove(this);
|
||||
}
|
||||
|
||||
parent = null;
|
||||
source = null;
|
||||
tail = new LinkTail(0, null);
|
||||
}
|
||||
|
||||
public boolean overwrite(InnerDimLink nextParent,int orientation)
|
||||
{
|
||||
if (nextParent == null)
|
||||
{
|
||||
throw new IllegalArgumentException("nextParent cannot be null.");
|
||||
}
|
||||
if (this == nextParent)
|
||||
{
|
||||
//Ignore this request silently
|
||||
return false;
|
||||
}
|
||||
if (nextParent.source.getDimension() != source.getDimension())
|
||||
{
|
||||
// Ban having children in other dimensions to avoid serialization issues with cross-dimensional tails
|
||||
throw new IllegalArgumentException("source and parent.source must have the same dimension.");
|
||||
}
|
||||
|
||||
//Release children
|
||||
for (DimLink child : children)
|
||||
{
|
||||
((InnerDimLink) child).parent = null;
|
||||
}
|
||||
children.clear();
|
||||
|
||||
//Release parent
|
||||
if (parent != null)
|
||||
{
|
||||
parent.children.remove(this);
|
||||
}
|
||||
|
||||
//Attach to new parent
|
||||
parent = nextParent;
|
||||
tail = nextParent.tail;
|
||||
nextParent.children.add(this);
|
||||
this.orientation=orientation;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void overwrite(int linkType, int orientation)
|
||||
{
|
||||
//Release children
|
||||
for (DimLink child : children)
|
||||
{
|
||||
((InnerDimLink) child).parent = null;
|
||||
}
|
||||
children.clear();
|
||||
|
||||
//Release parent
|
||||
if (parent != null)
|
||||
{
|
||||
parent.children.remove(this);
|
||||
}
|
||||
|
||||
//Attach to new parent
|
||||
parent = null;
|
||||
tail = new LinkTail(linkType, null);
|
||||
//Set new orientation
|
||||
this.orientation=orientation;
|
||||
}
|
||||
}
|
||||
|
||||
protected static Random random = new Random();
|
||||
|
||||
protected int id;
|
||||
protected Map<Point4D, InnerDimLink> linkMapping;
|
||||
protected List<InnerDimLink> linkList;
|
||||
protected boolean isDungeon;
|
||||
protected boolean isFilled;
|
||||
protected int depth;
|
||||
protected int packDepth;
|
||||
protected NewDimData parent;
|
||||
protected NewDimData root;
|
||||
protected List<NewDimData> children;
|
||||
protected Point4D origin;
|
||||
protected int orientation;
|
||||
protected DungeonData dungeon;
|
||||
protected IUpdateWatcher<Point4D> linkWatcher;
|
||||
|
||||
protected NewDimData(int id, NewDimData parent, boolean isPocket, boolean isDungeon,
|
||||
IUpdateWatcher<Point4D> linkWatcher)
|
||||
{
|
||||
// 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, InnerDimLink>(); //Should be stored in oct tree -- temporary solution
|
||||
this.linkList = new ArrayList<InnerDimLink>(); //Should be stored in oct tree -- temporary solution
|
||||
this.children = new ArrayList<NewDimData>();
|
||||
this.parent = parent;
|
||||
this.packDepth = 0;
|
||||
this.isDungeon = isDungeon;
|
||||
this.isFilled = false;
|
||||
this.orientation = 0;
|
||||
this.origin = null;
|
||||
this.dungeon = null;
|
||||
this.linkWatcher = linkWatcher;
|
||||
|
||||
//Register with parent
|
||||
if (parent != null)
|
||||
{
|
||||
//We don't need to raise an update event for adding a child because the child's creation will be signaled.
|
||||
this.root = parent.root;
|
||||
this.depth = parent.depth + 1;
|
||||
parent.children.add(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.root = this;
|
||||
this.depth = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected NewDimData(int id, NewDimData root)
|
||||
{
|
||||
// This constructor is meant for client-side code only
|
||||
if (root == null)
|
||||
{
|
||||
throw new IllegalArgumentException("root cannot be null.");
|
||||
}
|
||||
|
||||
this.id = id;
|
||||
this.linkMapping = new TreeMap<Point4D, InnerDimLink>(); //Should be stored in oct tree -- temporary solution
|
||||
this.linkList = new ArrayList<InnerDimLink>(); //Should be stored in oct tree -- temporary solution
|
||||
this.children = new ArrayList<NewDimData>();
|
||||
this.parent = null;
|
||||
this.packDepth = 0;
|
||||
this.isDungeon = false;
|
||||
this.isFilled = false;
|
||||
this.orientation = 0;
|
||||
this.origin = null;
|
||||
this.dungeon = null;
|
||||
this.linkWatcher = null;
|
||||
this.depth = 0;
|
||||
this.root = root;
|
||||
}
|
||||
|
||||
public DimLink findNearestRift(World world, int range, int x, int y, int z)
|
||||
{
|
||||
//TODO: Rewrite this later to use an octtree
|
||||
|
||||
//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.
|
||||
|
||||
DimLink nearest = null;
|
||||
DimLink 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 DimLink createLink(int x, int y, int z, int linkType)
|
||||
{
|
||||
return createLink(new Point4D(x, y, z, id), linkType,0);
|
||||
}
|
||||
public DimLink createLink(int x, int y, int z, int linkType,int orientation)
|
||||
{
|
||||
return createLink(new Point4D(x, y, z, id), linkType,orientation);
|
||||
}
|
||||
|
||||
public DimLink createLink(Point4D source, int linkType,int orientation)
|
||||
{
|
||||
//Return an existing link if there is one to avoid creating multiple links starting at the same point.
|
||||
InnerDimLink link = linkMapping.get(source);
|
||||
if (link == null)
|
||||
{
|
||||
link = new InnerDimLink(source, linkType,orientation);
|
||||
linkMapping.put(source, link);
|
||||
linkList.add(link);
|
||||
}
|
||||
else
|
||||
{
|
||||
link.overwrite(linkType,orientation);
|
||||
}
|
||||
//Link created!
|
||||
if(linkType!=LinkTypes.CLIENT_SIDE)
|
||||
{
|
||||
linkWatcher.onCreated(link.source);
|
||||
}
|
||||
return link;
|
||||
}
|
||||
|
||||
public DimLink createChildLink(int x, int y, int z, DimLink parent)
|
||||
{
|
||||
if (parent == null)
|
||||
{
|
||||
throw new IllegalArgumentException("parent cannot be null.");
|
||||
}
|
||||
|
||||
return createChildLink(new Point4D(x, y, z, id), (InnerDimLink) parent);
|
||||
}
|
||||
|
||||
private DimLink createChildLink(Point4D source, InnerDimLink 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.
|
||||
|
||||
InnerDimLink link = linkMapping.get(source);
|
||||
if (link == null)
|
||||
{
|
||||
link = new InnerDimLink(source, parent, parent.orientation);
|
||||
linkMapping.put(source, link);
|
||||
linkList.add(link);
|
||||
|
||||
//Link created!
|
||||
linkWatcher.onCreated(link.source);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (link.overwrite(parent, parent.orientation))
|
||||
{
|
||||
//Link created!
|
||||
linkWatcher.onCreated(link.source);
|
||||
}
|
||||
}
|
||||
return link;
|
||||
}
|
||||
|
||||
public boolean deleteLink(DimLink link)
|
||||
{
|
||||
if (link.source().getDimension() != id)
|
||||
{
|
||||
throw new IllegalArgumentException("Attempted to delete a link from another dimension.");
|
||||
}
|
||||
InnerDimLink target = linkMapping.remove(link.source());
|
||||
if (target != null)
|
||||
{
|
||||
linkList.remove(target);
|
||||
//Raise deletion event
|
||||
linkWatcher.onDeleted(target.source);
|
||||
target.clear();
|
||||
}
|
||||
return (target != null);
|
||||
}
|
||||
|
||||
public boolean deleteLink(int x, int y, int z)
|
||||
{
|
||||
Point4D location = new Point4D(x, y, z, id);
|
||||
InnerDimLink target = linkMapping.remove(location);
|
||||
if (target != null)
|
||||
{
|
||||
linkList.remove(target);
|
||||
//Raise deletion event
|
||||
linkWatcher.onDeleted(target.source);
|
||||
target.clear();
|
||||
}
|
||||
return (target != null);
|
||||
}
|
||||
|
||||
public DimLink getLink(int x, int y, int z)
|
||||
{
|
||||
Point4D location = new Point4D(x, y, z, id);
|
||||
return linkMapping.get(location);
|
||||
}
|
||||
|
||||
public DimLink getLink(Point3D location)
|
||||
{
|
||||
return linkMapping.get(new Point4D(location.getX(),location.getY(),location.getZ(),this.id));
|
||||
}
|
||||
|
||||
public DimLink getLink(Point4D location)
|
||||
{
|
||||
if (location.getDimension() != id)
|
||||
return null;
|
||||
|
||||
return linkMapping.get(location);
|
||||
}
|
||||
|
||||
public ArrayList<DimLink> getAllLinks()
|
||||
{
|
||||
ArrayList<DimLink> results = new ArrayList<DimLink>(linkMapping.size());
|
||||
results.addAll(linkMapping.values());
|
||||
return results;
|
||||
}
|
||||
|
||||
public boolean isPocketDimension()
|
||||
{
|
||||
return (root != this);
|
||||
}
|
||||
|
||||
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 linkList.size();
|
||||
}
|
||||
|
||||
public Iterable<NewDimData> children()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
|
||||
public Iterable<? extends DimLink> links()
|
||||
{
|
||||
return linkList;
|
||||
}
|
||||
|
||||
public void initializeDungeon(int originX, int originY, int originZ, int orientation, DimLink incoming, 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.");
|
||||
}
|
||||
if (orientation < 0 || orientation > 3)
|
||||
{
|
||||
throw new IllegalArgumentException("orientation must be between 0 and 3, inclusive.");
|
||||
}
|
||||
setDestination(incoming, originX, originY, originZ);
|
||||
this.origin = incoming.destination();
|
||||
this.orientation = orientation;
|
||||
this.dungeon = dungeon;
|
||||
this.packDepth = calculatePackDepth(parent, dungeon);
|
||||
}
|
||||
|
||||
/**
|
||||
* effectivly moves the dungeon to the 'top' of a chain as far as dungeon generation is concerend.
|
||||
*/
|
||||
public void setParentToRoot()
|
||||
{
|
||||
this.depth=1;
|
||||
this.parent=this.root;
|
||||
this.root.children.add(this);
|
||||
}
|
||||
|
||||
public static int calculatePackDepth(NewDimData parent, DungeonData current)
|
||||
{
|
||||
DungeonData predecessor = parent.dungeon();
|
||||
if (current == null)
|
||||
{
|
||||
throw new IllegalArgumentException("current cannot be null.");
|
||||
}
|
||||
if (predecessor == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
DungeonPack predOwner = predecessor.dungeonType().Owner;
|
||||
DungeonPack currentOwner = current.dungeonType().Owner;
|
||||
if (currentOwner == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (predOwner == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (predOwner == currentOwner)
|
||||
{
|
||||
return parent.packDepth + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void initializePocket(int originX, int originY, int originZ, int orientation, DimLink incoming)
|
||||
{
|
||||
if (!isPocketDimension())
|
||||
{
|
||||
throw new IllegalStateException("Cannot invoke initializePocket() on a non-pocket dimension.");
|
||||
}
|
||||
if (isInitialized())
|
||||
{
|
||||
throw new IllegalStateException("The dimension has already been initialized.");
|
||||
}
|
||||
|
||||
setDestination(incoming, originX, originY, originZ);
|
||||
this.origin = incoming.destination();
|
||||
this.orientation = orientation;
|
||||
}
|
||||
|
||||
public void setDestination(DimLink incoming, int x, int y, int z)
|
||||
{
|
||||
InnerDimLink link = (InnerDimLink) incoming;
|
||||
link.setDestination(x, y, z, this);
|
||||
}
|
||||
|
||||
public DimLink 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
671
StevenDimDoors/mod_pocketDim/core/PocketManager.java
Normal file
671
StevenDimDoors/mod_pocketDim/core/PocketManager.java
Normal file
@@ -0,0 +1,671 @@
|
||||
package StevenDimDoors.mod_pocketDim.core;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.Compactor;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.DeleteFolder;
|
||||
import StevenDimDoors.mod_pocketDim.saving.DDSaveHandler;
|
||||
import StevenDimDoors.mod_pocketDim.saving.IPackable;
|
||||
import StevenDimDoors.mod_pocketDim.saving.OldSaveImporter;
|
||||
import StevenDimDoors.mod_pocketDim.saving.PackedDimData;
|
||||
import StevenDimDoors.mod_pocketDim.saving.PackedDungeonData;
|
||||
import StevenDimDoors.mod_pocketDim.saving.PackedLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.saving.PackedLinkTail;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.ClientDimData;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.IUpdateSource;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.IUpdateWatcher;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.UpdateWatcherProxy;
|
||||
|
||||
/**
|
||||
* 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 implements IPackable<PackedDimData>
|
||||
{
|
||||
// This 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 going through PocketManager. In turn, that enforces
|
||||
// that any link destinations must be real dimensions controlled by PocketManager.
|
||||
|
||||
public InnerDimData(int id, InnerDimData parent, boolean isPocket, boolean isDungeon,
|
||||
IUpdateWatcher<Point4D> linkWatcher)
|
||||
{
|
||||
super(id, parent, isPocket, isDungeon, linkWatcher);
|
||||
}
|
||||
|
||||
public InnerDimData(int id, InnerDimData root)
|
||||
{
|
||||
// This constructor is meant for client-side code only
|
||||
super(id, root);
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
// If this dimension has a parent, remove it from its parent's list of children
|
||||
if (parent != null)
|
||||
{
|
||||
parent.children.remove(this);
|
||||
}
|
||||
// Remove this dimension as the parent of its children
|
||||
for (NewDimData child : children)
|
||||
{
|
||||
child.parent = null;
|
||||
}
|
||||
// Clear all fields
|
||||
id = Integer.MIN_VALUE;
|
||||
linkMapping.clear();
|
||||
linkMapping = null;
|
||||
linkList.clear();
|
||||
linkList = null;
|
||||
children.clear();
|
||||
children = null;
|
||||
isDungeon = false;
|
||||
isFilled = false;
|
||||
depth = Integer.MIN_VALUE;
|
||||
packDepth = Integer.MIN_VALUE;
|
||||
origin = null;
|
||||
orientation = Integer.MIN_VALUE;
|
||||
dungeon = null;
|
||||
linkWatcher = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name()
|
||||
{
|
||||
return String.valueOf(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackedDimData pack()
|
||||
{
|
||||
ArrayList<Integer> ChildIDs = new ArrayList<Integer>();
|
||||
ArrayList<PackedLinkData> Links = new ArrayList<PackedLinkData>();
|
||||
ArrayList<PackedLinkTail> Tails = new ArrayList<PackedLinkTail>();
|
||||
PackedDungeonData packedDungeon=null;
|
||||
|
||||
if(this.dungeon!=null)
|
||||
{
|
||||
packedDungeon= new PackedDungeonData(dungeon.weight(), dungeon.isOpen(), dungeon.isInternal(),
|
||||
dungeon.schematicPath(), dungeon.schematicName(), dungeon.dungeonType().Name,
|
||||
dungeon.dungeonType().Owner.getName());
|
||||
}
|
||||
//Make a list of children
|
||||
for(NewDimData data : this.children)
|
||||
{
|
||||
ChildIDs.add(data.id);
|
||||
}
|
||||
for(DimLink link:this.links())
|
||||
{
|
||||
ArrayList<Point3D> children = new ArrayList<Point3D>();
|
||||
Point3D parentPoint = new Point3D(-1,-1,-1);
|
||||
if(link.parent!=null)
|
||||
{
|
||||
parentPoint=link.parent.source.toPoint3D();
|
||||
}
|
||||
|
||||
for(DimLink childLink : link.children)
|
||||
{
|
||||
children.add(childLink.source().toPoint3D());
|
||||
}
|
||||
PackedLinkTail tail = new PackedLinkTail(link.tail.getDestination(),link.tail.getLinkType());
|
||||
Links.add(new PackedLinkData(link.source,parentPoint,tail,link.orientation,children));
|
||||
|
||||
PackedLinkTail tempTail = new PackedLinkTail(link.tail.getDestination(),link.tail.getLinkType());
|
||||
if(Tails.contains(tempTail))
|
||||
{
|
||||
Tails.add(tempTail);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
int parentID=this.id;
|
||||
Point3D originPoint=new Point3D(0,0,0);
|
||||
if(this.parent!=null)
|
||||
{
|
||||
parentID = this.parent.id;
|
||||
}
|
||||
if(this.origin!=null)
|
||||
{
|
||||
originPoint=this.origin.toPoint3D();
|
||||
}
|
||||
return new PackedDimData(this.id, depth, this.packDepth, parentID, this.root().id(), orientation,
|
||||
isDungeon, isFilled,packedDungeon, originPoint, ChildIDs, Links, Tails);
|
||||
// FIXME: IMPLEMENTATION PLZTHX
|
||||
//I tried
|
||||
}
|
||||
}
|
||||
|
||||
private static class ClientLinkWatcher implements IUpdateWatcher<Point4D>
|
||||
{
|
||||
@Override
|
||||
public void onCreated(Point4D source)
|
||||
{
|
||||
NewDimData dimension = getDimensionData(source.getDimension());
|
||||
dimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.CLIENT_SIDE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleted(Point4D source)
|
||||
{
|
||||
NewDimData dimension = getDimensionData(source.getDimension());
|
||||
dimension.deleteLink(source.getX(), source.getY(), source.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ClientDimWatcher implements IUpdateWatcher<ClientDimData>
|
||||
{
|
||||
@Override
|
||||
public void onCreated(ClientDimData data)
|
||||
{
|
||||
registerClientDimension(data.ID, data.RootID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleted(ClientDimData data)
|
||||
{
|
||||
deletePocket(getDimensionData(data.ID), false);
|
||||
}
|
||||
}
|
||||
|
||||
private static class DimRegistrationCallback implements IDimRegistrationCallback
|
||||
{
|
||||
// We use this class to provide Compactor with the ability to send us dim data without
|
||||
// having to instantiate a bunch of data containers and without exposing an "unsafe"
|
||||
// creation method for anyone to call. Integrity protection for the win! It's like
|
||||
// exposing a private constructor ONLY to a very specific trusted class.
|
||||
|
||||
@Override
|
||||
public NewDimData registerDimension(int dimensionID, int rootID)
|
||||
{
|
||||
return registerClientDimension(dimensionID, rootID);
|
||||
}
|
||||
}
|
||||
|
||||
private static int OVERWORLD_DIMENSION_ID = 0;
|
||||
|
||||
private static volatile boolean isLoading = false;
|
||||
private static volatile boolean isLoaded = false;
|
||||
private static volatile boolean isSaving = false;
|
||||
private static final UpdateWatcherProxy<Point4D> linkWatcher = new UpdateWatcherProxy<Point4D>();
|
||||
private static final UpdateWatcherProxy<ClientDimData> dimWatcher = new UpdateWatcherProxy<ClientDimData>();
|
||||
private static ArrayList<NewDimData> rootDimensions = null;
|
||||
|
||||
//HashMap that maps all the dimension IDs registered with DimDoors to their DD data.
|
||||
private static HashMap<Integer, InnerDimData> dimensionData = null;
|
||||
//ArrayList that stores the dimension IDs of any dimension that has been deleted.
|
||||
private static ArrayList<Integer> dimensionIDBlackList = null;
|
||||
|
||||
public static boolean isLoaded()
|
||||
{
|
||||
return isLoaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 load()
|
||||
{
|
||||
if (isLoaded)
|
||||
{
|
||||
throw new IllegalStateException("Pocket dimensions have already been loaded!");
|
||||
}
|
||||
if (isLoading)
|
||||
{
|
||||
return;
|
||||
}
|
||||
isLoading = true;
|
||||
|
||||
dimensionData = new HashMap<Integer, InnerDimData>();
|
||||
rootDimensions = new ArrayList<NewDimData>();
|
||||
dimensionIDBlackList = new ArrayList<Integer>();
|
||||
|
||||
if(FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
{
|
||||
//Shouldnt try to load everything if we are a client
|
||||
//This was preventing onPacket from loading properly
|
||||
isLoading=false;
|
||||
return;
|
||||
}
|
||||
//Register Limbo
|
||||
DDProperties properties = DDProperties.instance();
|
||||
registerDimension(properties.LimboDimensionID, null, false, false);
|
||||
|
||||
loadInternal();
|
||||
|
||||
//Register pocket dimensions
|
||||
registerPockets(properties);
|
||||
|
||||
isLoaded = true;
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public static boolean registerPackedDimData(PackedDimData packedData)
|
||||
{
|
||||
InnerDimData dimData;
|
||||
|
||||
if(packedData.ID==packedData.ParentID)
|
||||
{
|
||||
dimData = new InnerDimData(packedData.ID, null, false, false, linkWatcher);
|
||||
dimData.root=dimData;
|
||||
dimData.parent=dimData;
|
||||
dimData.isFilled=packedData.IsFilled;
|
||||
|
||||
PocketManager.rootDimensions.add(dimData);
|
||||
}
|
||||
else
|
||||
{
|
||||
InnerDimData test = PocketManager.dimensionData.get(packedData.ParentID);
|
||||
dimData = new InnerDimData(packedData.ID, test,true, packedData.IsDungeon, linkWatcher);
|
||||
dimData.isFilled=packedData.IsFilled;
|
||||
|
||||
dimData.root=PocketManager.getDimensionData(packedData.RootID);
|
||||
|
||||
if(packedData.DungeonData!=null)
|
||||
{
|
||||
dimData.dungeon=DDSaveHandler.unpackDungeonData(packedData.DungeonData);
|
||||
}
|
||||
|
||||
}
|
||||
PocketManager.dimensionData.put(dimData.id, dimData);
|
||||
dimWatcher.onCreated(new ClientDimData(dimData));
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
public static boolean deletePocket(NewDimData target, boolean deleteFolder)
|
||||
{
|
||||
// We can't delete the dimension if it's currently loaded or if it's not actually a pocket.
|
||||
// We cast to InnerDimData so that if anyone tries to be a smartass and create their
|
||||
// own version of NewDimData, this will throw an exception.
|
||||
InnerDimData dimension = (InnerDimData) target;
|
||||
if (dimension.isPocketDimension() && DimensionManager.getWorld(dimension.id()) == null)
|
||||
{
|
||||
if (deleteFolder)
|
||||
{
|
||||
deleteDimensionFolder(target);
|
||||
}
|
||||
dimensionIDBlackList.add(dimension.id);
|
||||
deleteDimensionData(dimension.id);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private static boolean deleteDimensionFolder(NewDimData target)
|
||||
{
|
||||
InnerDimData dimension = (InnerDimData) target;
|
||||
if (dimension.isPocketDimension() && DimensionManager.getWorld(dimension.id()) == null)
|
||||
{
|
||||
File saveDirectory = new File(DimensionManager.getCurrentSaveRootDirectory() + "/DimensionalDoors/pocketDimID" + dimension.id());
|
||||
DeleteFolder.deleteFolder(saveDirectory);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private static boolean deleteDimensionData(int dimensionID)
|
||||
{
|
||||
if(dimensionData.containsKey(dimensionID)&& DimensionManager.getWorld(dimensionID) == null)
|
||||
{
|
||||
NewDimData target = PocketManager.getDimensionData(dimensionID);
|
||||
InnerDimData dimension = (InnerDimData) target;
|
||||
|
||||
dimensionData.remove(dimensionID);
|
||||
// Raise the dim deleted event
|
||||
dimWatcher.onDeleted(new ClientDimData(dimension));
|
||||
dimension.clear();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void registerPockets(DDProperties properties)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void unregisterPockets()
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* loads the dim data from the saved hashMap. Also handles compatibility with old saves, see OldSaveHandler
|
||||
*/
|
||||
private static void loadInternal()
|
||||
{
|
||||
System.out.println(!FMLCommonHandler.instance().getSide().isClient());
|
||||
|
||||
File saveDir = DimensionManager.getCurrentSaveRootDirectory();
|
||||
if (saveDir != null)
|
||||
{
|
||||
// Load and register blacklisted dimension IDs
|
||||
File oldSaveData = new File(saveDir+"/DimensionalDoorsData");
|
||||
if(oldSaveData.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.println("Importing old DD save data...");
|
||||
OldSaveImporter.importOldSave(oldSaveData);
|
||||
oldSaveData.delete();
|
||||
|
||||
System.out.println("Import Succesful!");
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//TODO handle fail cases
|
||||
System.out.println("Import failed!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Load save data
|
||||
System.out.println("Loading Dimensional Doors save data...");
|
||||
if (DDSaveHandler.loadAll())
|
||||
{
|
||||
System.out.println("Loaded successfully!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void save()
|
||||
{
|
||||
if (!isLoaded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
World world = DimensionManager.getWorld(OVERWORLD_DIMENSION_ID);
|
||||
if (world == null || world.isRemote || DimensionManager.getCurrentSaveRootDirectory() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//Check this last to make sure we set the flag shortly after.
|
||||
if (isSaving)
|
||||
{
|
||||
return;
|
||||
}
|
||||
isSaving = true;
|
||||
|
||||
try
|
||||
{
|
||||
System.out.println("Writing Dimensional Doors save data...");
|
||||
if ( DDSaveHandler.saveAll(dimensionData.values()) )
|
||||
{
|
||||
System.out.println("Saved successfully!");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Wrap the exception in a RuntimeException so functions that call
|
||||
// PocketManager.save() don't need to catch it. We want MC to
|
||||
// crash if something really bad happens rather than ignoring it!
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
isSaving = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static WorldServer loadDimension(int id)
|
||||
{
|
||||
WorldServer world = DimensionManager.getWorld(id);
|
||||
if (world == null)
|
||||
{
|
||||
DimensionManager.initDimension(id);
|
||||
world = DimensionManager.getWorld(id);
|
||||
}
|
||||
else if (world.provider == null)
|
||||
{
|
||||
DimensionManager.initDimension(id);
|
||||
world = DimensionManager.getWorld(id);
|
||||
}
|
||||
return world;
|
||||
}
|
||||
|
||||
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, (InnerDimData) parent, true, isDungeon);
|
||||
}
|
||||
|
||||
private static NewDimData registerDimension(int dimensionID, InnerDimData 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.");
|
||||
}
|
||||
//TODO blacklist stuff probably should happen here
|
||||
InnerDimData dimension = new InnerDimData(dimensionID, parent, isPocket, isDungeon, linkWatcher);
|
||||
dimensionData.put(dimensionID, dimension);
|
||||
if (!dimension.isPocketDimension())
|
||||
{
|
||||
rootDimensions.add(dimension);
|
||||
}
|
||||
dimWatcher.onCreated(new ClientDimData(dimension));
|
||||
|
||||
return dimension;
|
||||
}
|
||||
|
||||
private static NewDimData registerClientDimension(int dimensionID, int rootID)
|
||||
{
|
||||
// No need to raise events heres since this code should only run on the client side
|
||||
// getDimensionData() always handles root dimensions properly, even if the weren't defined before
|
||||
|
||||
// SenseiKiwi: I'm a little worried about how getDimensionData will raise
|
||||
// an event when it creates any root dimensions... Needs checking later.
|
||||
|
||||
InnerDimData root = (InnerDimData) getDimensionData(rootID);
|
||||
InnerDimData dimension;
|
||||
|
||||
if (rootID != dimensionID)
|
||||
{
|
||||
dimension = dimensionData.get(dimensionID);
|
||||
if (dimension == null)
|
||||
{
|
||||
dimension = new InnerDimData(dimensionID, root);
|
||||
dimensionData.put(dimension.id(), dimension);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dimension = root;
|
||||
}
|
||||
if(dimension.isPocketDimension())
|
||||
{
|
||||
//Im registering pocket dims here. I *think* we can assume that if its a pocket and we are
|
||||
//registering its dim data, we also need to register it with forge.
|
||||
DimensionManager.registerDimension(dimensionID, mod_pocketDim.properties.PocketProviderID);
|
||||
}
|
||||
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 Iterable<? extends NewDimData> getDimensions()
|
||||
{
|
||||
return dimensionData.values();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static ArrayList<NewDimData> getRootDimensions()
|
||||
{
|
||||
return (ArrayList<NewDimData>) rootDimensions.clone();
|
||||
}
|
||||
|
||||
public static void unload()
|
||||
{
|
||||
if (!isLoaded)
|
||||
{
|
||||
throw new IllegalStateException("Pocket dimensions have already been unloaded!");
|
||||
}
|
||||
|
||||
save();
|
||||
unregisterPockets();
|
||||
dimensionData = null;
|
||||
rootDimensions = null;
|
||||
isLoaded = false;
|
||||
}
|
||||
|
||||
public static DimLink getLink(int x, int y, int z, World world)
|
||||
{
|
||||
return getLink(x, y, z, world.provider.dimensionId);
|
||||
}
|
||||
|
||||
public static DimLink getLink(Point4D point)
|
||||
{
|
||||
return getLink(point.getX(), point.getY(), point.getZ(), point.getDimension());
|
||||
}
|
||||
|
||||
public static DimLink 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;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isBlackListed(int dimensionID)
|
||||
{
|
||||
return PocketManager.dimensionIDBlackList.contains(dimensionID);
|
||||
}
|
||||
public static void registerDimWatcher(IUpdateWatcher<ClientDimData> watcher)
|
||||
{
|
||||
dimWatcher.registerReceiver(watcher);
|
||||
}
|
||||
|
||||
public static boolean unregisterDimWatcher(IUpdateWatcher<ClientDimData> watcher)
|
||||
{
|
||||
return dimWatcher.unregisterReceiver(watcher);
|
||||
}
|
||||
|
||||
public static void registerLinkWatcher(IUpdateWatcher<Point4D> watcher)
|
||||
{
|
||||
linkWatcher.registerReceiver(watcher);
|
||||
}
|
||||
|
||||
public static boolean unregisterLinkWatcher(IUpdateWatcher<Point4D> watcher)
|
||||
{
|
||||
return linkWatcher.unregisterReceiver(watcher);
|
||||
}
|
||||
|
||||
public static void getWatchers(IUpdateSource updateSource)
|
||||
{
|
||||
updateSource.registerWatchers(new ClientDimWatcher(), new ClientLinkWatcher());
|
||||
}
|
||||
|
||||
public static void writePacket(DataOutputStream output) throws IOException
|
||||
{
|
||||
// Write a very compact description of our dimensions and links to be sent to a client
|
||||
Compactor.write(dimensionData.values(), output);
|
||||
}
|
||||
|
||||
public static boolean isRegisteredInternally(int dimensionID)
|
||||
{
|
||||
return dimensionData.containsKey(dimensionID);
|
||||
}
|
||||
|
||||
public static void readPacket(DataInputStream input) throws IOException
|
||||
{
|
||||
if (isLoaded)
|
||||
{
|
||||
throw new IllegalStateException("Pocket dimensions have already been loaded!");
|
||||
}
|
||||
if (isLoading)
|
||||
{
|
||||
throw new IllegalStateException("Pocket dimensions are already loading!");
|
||||
}
|
||||
// Load compacted client-side dimension data
|
||||
Compactor.readDimensions(input, new DimRegistrationCallback());
|
||||
|
||||
// Register pocket dimensions
|
||||
DDProperties properties = DDProperties.instance();
|
||||
registerPockets(properties);
|
||||
|
||||
isLoaded = true;
|
||||
isLoading = false;
|
||||
}
|
||||
}
|
||||
78
StevenDimDoors/mod_pocketDim/dungeon/DungeonData.java
Normal file
78
StevenDimDoors/mod_pocketDim/dungeon/DungeonData.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package StevenDimDoors.mod_pocketDim.dungeon;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonType;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.InvalidSchematicException;
|
||||
|
||||
public class DungeonData
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
public int weight()
|
||||
{
|
||||
return weight;
|
||||
}
|
||||
|
||||
public boolean isOpen()
|
||||
{
|
||||
return isOpen;
|
||||
}
|
||||
|
||||
public boolean isInternal()
|
||||
{
|
||||
return isInternal;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,19 +14,21 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.CompoundFilter;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.InvalidSchematicException;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.ReplacementFilter;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.Schematic;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.MobMonolith;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.MonolithSpawner;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public class DungeonSchematic extends Schematic {
|
||||
|
||||
@@ -167,15 +169,14 @@ public class DungeonSchematic extends Schematic {
|
||||
return new DungeonSchematic(Schematic.copyFromWorld(world, x, y, z, width, height, length, doCompactBounds));
|
||||
}
|
||||
|
||||
public void copyToWorld(World world, Point3D pocketCenter, int dungeonOrientation, int originDimID, int destDimID, boolean doDistortCoordinates)
|
||||
public void copyToWorld(World world, Point3D pocketCenter, int targetOrientation, DimLink entryLink, Random random)
|
||||
{
|
||||
//TODO: This function is an improvised solution so we can get the release moving. In the future,
|
||||
//we should generalize block tranformations and implement support for them at the level of Schematic,
|
||||
//we should generalize block transformations and implement support for them at the level of Schematic,
|
||||
//then just use that support from DungeonSchematic instead of making this local fix.
|
||||
//It might be easiest to support transformations using a WorldOperation
|
||||
|
||||
final int turnAngle = dungeonOrientation - orientation;
|
||||
|
||||
final int turnAngle = targetOrientation - this.orientation;
|
||||
|
||||
int index;
|
||||
int count;
|
||||
@@ -222,18 +223,11 @@ public class DungeonSchematic extends Schematic {
|
||||
world.setBlockTileEntity(pocketPoint.getX(), pocketPoint.getY(), pocketPoint.getZ(), TileEntity.createAndLoadEntity(tileTag));
|
||||
}
|
||||
|
||||
setUpDungeon(world, pocketCenter, turnAngle, originDimID, destDimID, doDistortCoordinates);
|
||||
setUpDungeon(PocketManager.getDimensionData(world), world, pocketCenter, turnAngle, entryLink, random);
|
||||
}
|
||||
|
||||
private void setUpDungeon(World world, Point3D pocketCenter, int turnAngle, int originDimID, int destDimID, boolean doDistortCoordinates)
|
||||
private void setUpDungeon(NewDimData dimension, World world, Point3D pocketCenter, int turnAngle, DimLink entryLink, Random random)
|
||||
{
|
||||
//The following Random initialization code is based on code from ChunkProviderGenerate.
|
||||
//It makes our generation depend on the world seed.
|
||||
Random random = new Random(world.getSeed());
|
||||
long factorA = random.nextLong() / 2L * 2L + 1L;
|
||||
long factorB = random.nextLong() / 2L * 2L + 1L;
|
||||
random.setSeed(pocketCenter.getX() * factorB + pocketCenter.getZ() * factorA ^ world.getSeed());
|
||||
|
||||
//Transform dungeon corners
|
||||
Point3D minCorner = new Point3D(0, 0, 0);
|
||||
Point3D maxCorner = new Point3D(width - 1, height - 1, length - 1);
|
||||
@@ -244,24 +238,25 @@ public class DungeonSchematic extends Schematic {
|
||||
filler.apply(world, minCorner, maxCorner);
|
||||
|
||||
//Set up entrance door rift
|
||||
setUpEntranceDoorLink(world, entranceDoorLocation, turnAngle, pocketCenter);
|
||||
createEntranceReverseLink(dimension, pocketCenter, entryLink, world);
|
||||
|
||||
//Set up link data for dimensional doors
|
||||
for (Point3D location : dimensionalDoorLocations)
|
||||
{
|
||||
setUpDimensionalDoorLink(world, location, entranceDoorLocation, turnAngle, pocketCenter, originDimID, destDimID, doDistortCoordinates, random);
|
||||
createDimensionalDoorLink(dimension, location, entranceDoorLocation, turnAngle, pocketCenter,world);
|
||||
}
|
||||
|
||||
//Set up link data for exit door
|
||||
for (Point3D location : exitDoorLocations)
|
||||
{
|
||||
setUpExitDoorLink(world, location, entranceDoorLocation, turnAngle, pocketCenter, originDimID, destDimID, random);
|
||||
createExitDoorLink(world, dimension, location, entranceDoorLocation, turnAngle, pocketCenter);
|
||||
}
|
||||
|
||||
//Remove end portal frames and spawn Monoliths
|
||||
//Remove end portal frames and spawn Monoliths, if allowed
|
||||
boolean canSpawn = MonolithSpawner.isMobSpawningAllowed();
|
||||
for (Point3D location : monolithSpawnLocations)
|
||||
{
|
||||
spawnMonolith(world, location, entranceDoorLocation, turnAngle, pocketCenter);
|
||||
spawnMonolith(world, location, entranceDoorLocation, turnAngle, pocketCenter, canSpawn);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,133 +285,46 @@ public class DungeonSchematic extends Schematic {
|
||||
}
|
||||
}
|
||||
|
||||
private static void setUpEntranceDoorLink(World world, Point3D entrance, int rotation, Point3D pocketCenter)
|
||||
private static void createEntranceReverseLink(NewDimData dimension, Point3D pocketCenter, DimLink entryLink,World world)
|
||||
{
|
||||
//Set the orientation of the rift exit
|
||||
Point3D entranceRiftLocation = entrance.clone();
|
||||
BlockRotator.transformPoint(entranceRiftLocation, entrance, rotation, pocketCenter);
|
||||
LinkData sideLink = dimHelper.instance.getLinkDataFromCoords(
|
||||
entranceRiftLocation.getX(),
|
||||
entranceRiftLocation.getY(),
|
||||
entranceRiftLocation.getZ(),
|
||||
world);
|
||||
sideLink.linkOrientation = world.getBlockMetadata(
|
||||
entranceRiftLocation.getX(),
|
||||
entranceRiftLocation.getY() - 1,
|
||||
entranceRiftLocation.getZ());
|
||||
int orientation = world.getBlockMetadata(pocketCenter.getX(), pocketCenter.getY()-1, pocketCenter.getZ());
|
||||
DimLink reverseLink = dimension.createLink(pocketCenter.getX(), pocketCenter.getY(), pocketCenter.getZ(), LinkTypes.REVERSE,orientation);
|
||||
Point4D destination = entryLink.source();
|
||||
NewDimData prevDim = PocketManager.getDimensionData(destination.getDimension());
|
||||
prevDim.setDestination(reverseLink, destination.getX(), destination.getY(), destination.getZ());
|
||||
}
|
||||
|
||||
private static void setUpExitDoorLink(World world, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter, int originDimID, int destDimID, Random random)
|
||||
private static void createExitDoorLink(World world, NewDimData dimension, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter)
|
||||
{
|
||||
try
|
||||
{
|
||||
//TODO: Hax, remove this later
|
||||
DDProperties properties = DDProperties.instance();
|
||||
|
||||
//Transform doorLocation to the pocket coordinate system.
|
||||
Point3D location = point.clone();
|
||||
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);
|
||||
int blockDirection = world.getBlockMetadata(location.getX(), location.getY() - 1, location.getZ());
|
||||
Point3D linkDestination = location.clone();
|
||||
|
||||
LinkData randomLink = dimHelper.instance.getRandomLinkData(false);
|
||||
LinkData sideLink = new LinkData(destDimID,
|
||||
dimHelper.instance.getDimData(originDimID).exitDimLink.destDimID,
|
||||
location.getX(),
|
||||
location.getY(),
|
||||
location.getZ(),
|
||||
linkDestination.getX(),
|
||||
linkDestination.getY() + 1,
|
||||
linkDestination.getZ(),
|
||||
true, blockDirection);
|
||||
|
||||
if (sideLink.destDimID == properties.LimboDimensionID)
|
||||
{
|
||||
sideLink.destDimID = 0;
|
||||
}
|
||||
else if ((random.nextBoolean() && randomLink != null))
|
||||
{
|
||||
sideLink.destDimID = randomLink.locDimID;
|
||||
}
|
||||
sideLink.destYCoord = yCoordHelper.getFirstUncovered(sideLink.destDimID, linkDestination.getX(), linkDestination.getY(), linkDestination.getZ())-1;
|
||||
|
||||
if (sideLink.destYCoord < 5)
|
||||
{
|
||||
sideLink.destYCoord = 70;
|
||||
}
|
||||
sideLink.linkOrientation = world.getBlockMetadata(linkDestination.getX(), linkDestination.getY() - 1, linkDestination.getZ());
|
||||
|
||||
dimHelper.instance.createLink(sideLink);
|
||||
/**dimHelper.instance.createLink(sideLink.destDimID ,
|
||||
sideLink.locDimID,
|
||||
sideLink.destXCoord,
|
||||
sideLink.destYCoord,
|
||||
sideLink.destZCoord,
|
||||
sideLink.locXCoord,
|
||||
sideLink.locYCoord,
|
||||
sideLink.locZCoord,
|
||||
BlockRotator.transformMetadata(sideLink.linkOrientation, 2, Block.doorWood.blockID));
|
||||
**/
|
||||
|
||||
if (world.getBlockId(linkDestination.getX(), linkDestination.getY() - 3, linkDestination.getZ()) == properties.FabricBlockID)
|
||||
{
|
||||
setBlockDirectly(world, linkDestination.getX(), linkDestination.getY() - 2, linkDestination.getZ(), Block.stoneBrick.blockID, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
setBlockDirectly(world,linkDestination.getX(), linkDestination.getY() - 2, linkDestination.getZ(),
|
||||
world.getBlockId(linkDestination.getX(), linkDestination.getY() - 3, linkDestination.getZ()),
|
||||
world.getBlockMetadata(linkDestination.getX(), linkDestination.getY() - 3, linkDestination.getZ()));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
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 forwardNoise;
|
||||
int sidewaysNoise;
|
||||
|
||||
if (applyNoise)
|
||||
{
|
||||
forwardNoise = MathHelper.getRandomIntegerInRange(random, -50 * depth, 150 * depth);
|
||||
sidewaysNoise = MathHelper.getRandomIntegerInRange(random, -10 * depth, 10 * depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
forwardNoise = 0;
|
||||
sidewaysNoise = 0;
|
||||
}
|
||||
|
||||
//Transform doorLocation to the pocket coordinate system
|
||||
//Transform the door's location to the pocket coordinate system
|
||||
Point3D location = point.clone();
|
||||
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);
|
||||
int blockDirection = world.getBlockMetadata(location.getX(), location.getY() - 1, location.getZ());
|
||||
|
||||
//Rotate the link destination noise to point in the same direction as the door exit
|
||||
//and add it to the door's location. Use EAST as the reference orientation since linkDestination
|
||||
//is constructed as if pointing East.
|
||||
Point3D linkDestination = new Point3D(forwardNoise, 0, sidewaysNoise);
|
||||
Point3D zeroPoint = new Point3D(0, 0, 0);
|
||||
BlockRotator.transformPoint(linkDestination, zeroPoint, blockDirection - BlockRotator.EAST_DOOR_METADATA, location);
|
||||
|
||||
//Create the link between our current door and its intended exit in destination pocket
|
||||
LinkData sideLink = new LinkData(destDimID, 0,
|
||||
location.getX(),
|
||||
location.getY(),
|
||||
location.getZ(),
|
||||
linkDestination.getX(),
|
||||
linkDestination.getY() + 1,
|
||||
linkDestination.getZ(),
|
||||
true, blockDirection);
|
||||
dimHelper.instance.createPocket(sideLink, true, true);
|
||||
int orientation = world.getBlockMetadata(location.getX(), location.getY()-1, location.getZ());
|
||||
dimension.createLink(location.getX(), location.getY(), location.getZ(), LinkTypes.DUNGEON_EXIT,orientation);
|
||||
//Replace the sandstone block under the exit door with the same block as the one underneath it
|
||||
int x = location.getX();
|
||||
int y = location.getY() - 3;
|
||||
int z = location.getZ();
|
||||
if (y >= 0)
|
||||
{
|
||||
int blockID = world.getBlockId(x, y, z);
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
setBlockDirectly(world, x, y + 1, z, blockID, metadata);
|
||||
}
|
||||
}
|
||||
|
||||
private static void spawnMonolith(World world, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter)
|
||||
private static void createDimensionalDoorLink(NewDimData dimension, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter,World world)
|
||||
{
|
||||
//Transform the door's location to the pocket coordinate system
|
||||
Point3D location = point.clone();
|
||||
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);
|
||||
int orientation = world.getBlockMetadata(location.getX(), location.getY()-1, location.getZ());
|
||||
|
||||
dimension.createLink(location.getX(), location.getY(), location.getZ(), LinkTypes.DUNGEON,orientation);
|
||||
}
|
||||
|
||||
private static void spawnMonolith(World world, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter, boolean canSpawn)
|
||||
{
|
||||
//Transform the frame block's location to the pocket coordinate system
|
||||
Point3D location = point.clone();
|
||||
@@ -424,8 +332,11 @@ public class DungeonSchematic extends Schematic {
|
||||
//Remove frame block
|
||||
setBlockDirectly(world, location.getX(), location.getY(), location.getZ(), 0, 0);
|
||||
//Spawn Monolith
|
||||
Entity mob = new MobMonolith(world);
|
||||
mob.setLocationAndAngles(location.getX(), location.getY(), location.getZ(), 1, 1);
|
||||
world.spawnEntityInWorld(mob);
|
||||
if (canSpawn)
|
||||
{
|
||||
Entity mob = new MobMonolith(world);
|
||||
mob.setLocationAndAngles(location.getX(), location.getY(), location.getZ(), 1, 1);
|
||||
world.spawnEntityInWorld(mob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.LinkData;
|
||||
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(LinkData inbound, Random random)
|
||||
public DungeonData getNextDungeon(NewDimData dimension, Random random)
|
||||
{
|
||||
if (allDungeons.isEmpty())
|
||||
{
|
||||
@@ -136,27 +135,26 @@ 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)
|
||||
{
|
||||
if (rule.evaluate(typeHistory))
|
||||
{
|
||||
//Pick a random dungeon type to be generated next based on the rule's products
|
||||
//Pick a random dungeon type to be generated next based on the rule's products
|
||||
ArrayList<WeightedContainer<DungeonType>> products = rule.products();
|
||||
DungeonType nextType;
|
||||
do
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
32
StevenDimDoors/mod_pocketDim/helpers/ChunkLoaderHelper.java
Normal file
32
StevenDimDoors/mod_pocketDim/helpers/ChunkLoaderHelper.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package StevenDimDoors.mod_pocketDim.helpers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeChunkManager;
|
||||
import net.minecraftforge.common.ForgeChunkManager.LoadingCallback;
|
||||
import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
||||
import StevenDimDoors.mod_pocketDim.IChunkLoader;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoorGold;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
|
||||
public class ChunkLoaderHelper implements LoadingCallback
|
||||
{
|
||||
|
||||
@Override
|
||||
public void ticketsLoaded(List<Ticket> tickets, World world)
|
||||
{
|
||||
for (Ticket ticket : tickets)
|
||||
{
|
||||
int goldDimDoorX = ticket.getModData().getInteger("goldDimDoorX");
|
||||
int goldDimDoorY = ticket.getModData().getInteger("goldDimDoorY");
|
||||
int goldDimDoorZ = ticket.getModData().getInteger("goldDimDoorZ");
|
||||
IChunkLoader tile = (IChunkLoader) world.getBlockTileEntity(goldDimDoorX, goldDimDoorY, goldDimDoorZ);
|
||||
tile.forceChunkLoading(ticket,goldDimDoorX,goldDimDoorZ);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
83
StevenDimDoors/mod_pocketDim/helpers/Compactor.java
Normal file
83
StevenDimDoors/mod_pocketDim/helpers/Compactor.java
Normal file
@@ -0,0 +1,83 @@
|
||||
package StevenDimDoors.mod_pocketDim.helpers;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimRegistrationCallback;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public class Compactor
|
||||
{
|
||||
|
||||
private static class DimComparator implements Comparator<NewDimData>
|
||||
{
|
||||
@Override
|
||||
public int compare(NewDimData a, NewDimData b)
|
||||
{
|
||||
return a.id() - b.id();
|
||||
}
|
||||
}
|
||||
|
||||
public static void write(Collection<? extends NewDimData> values, DataOutputStream output) throws IOException
|
||||
{
|
||||
// SenseiKiwi: Just encode the data straight up for now. I'll implement fancier compression later.
|
||||
output.writeInt(values.size());
|
||||
for (NewDimData dimension : values)
|
||||
{
|
||||
output.writeInt(dimension.id());
|
||||
output.writeInt(dimension.root().id());
|
||||
output.writeInt(dimension.linkCount());
|
||||
for (DimLink link : dimension.links())
|
||||
{
|
||||
Point4D.write(link.source(), output);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Note to self: the root ID can be "compressed" by grouping
|
||||
// dimensions by their root ID and then only sending it once
|
||||
|
||||
/*
|
||||
// To compress the dimension IDs, we'll sort them by ID
|
||||
// and write the _difference_ between their ID numbers.
|
||||
NewDimData[] dimensions = new NewDimData[values.size()];
|
||||
dimensions = values.toArray(dimensions);
|
||||
Arrays.sort(dimensions, new DimComparator());
|
||||
*/
|
||||
}
|
||||
|
||||
public static void readDimensions(DataInputStream input, IDimRegistrationCallback callback) throws IOException
|
||||
{
|
||||
// Read in the dimensions one by one. Make sure we register root dimensions before
|
||||
// attempting to register the dimensions under them.
|
||||
|
||||
HashSet<Integer> rootIDs = new HashSet<Integer>();
|
||||
|
||||
int dimCount = input.readInt();
|
||||
for (int k = 0; k < dimCount; k++)
|
||||
{
|
||||
int id = input.readInt();
|
||||
int rootID = input.readInt();
|
||||
|
||||
if (rootIDs.add(rootID))
|
||||
{
|
||||
callback.registerDimension(rootID, rootID);
|
||||
}
|
||||
// Don't check if (id != rootID) - we want to retrieve the reference anyway
|
||||
NewDimData dimension = callback.registerDimension(id, rootID);
|
||||
int linkCount = input.readInt();
|
||||
for (int h = 0; h < linkCount; h++)
|
||||
{
|
||||
Point4D source = Point4D.read(input);
|
||||
dimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.CLIENT_SIDE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,40 +20,24 @@ 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.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
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;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPackConfigReader;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonType;
|
||||
import StevenDimDoors.mod_pocketDim.items.itemDimDoor;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
|
||||
import StevenDimDoors.mod_pocketDim.util.ConfigurationProcessingException;
|
||||
import StevenDimDoors.mod_pocketDim.util.FileFilters;
|
||||
import StevenDimDoors.mod_pocketDim.util.WeightedContainer;
|
||||
|
||||
public class DungeonHelper
|
||||
{
|
||||
//TODO: File-handling functionality should be spun off to a helper class later
|
||||
private static class DirectoryFilter implements FileFilter
|
||||
{
|
||||
@Override
|
||||
public boolean accept(File file)
|
||||
{
|
||||
return file.isDirectory();
|
||||
}
|
||||
}
|
||||
|
||||
private static class SchematicFileFilter implements FileFilter
|
||||
{
|
||||
@Override
|
||||
public boolean accept(File file)
|
||||
{
|
||||
return file.isFile() && file.getName().endsWith(SCHEMATIC_FILE_EXTENSION);
|
||||
}
|
||||
}
|
||||
|
||||
private static DungeonHelper instance = null;
|
||||
private static DDProperties properties = null;
|
||||
|
||||
@@ -62,8 +46,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 +68,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 +207,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 +244,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,21 +257,20 @@ public class DungeonHelper
|
||||
return pack;
|
||||
}
|
||||
|
||||
public LinkData createCustomDungeonDoor(World world, int x, int y, int z)
|
||||
public DimLink createCustomDungeonDoor(World world, int x, int y, int z)
|
||||
{
|
||||
//Create a link above the specified position. Link to a new pocket dimension.
|
||||
LinkData link = new LinkData(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);
|
||||
DimLink link = dimension.createLink(x, y + 1, z, LinkTypes.POCKET,3);
|
||||
|
||||
//Place a Warp Door linked to that pocket
|
||||
itemDimDoor.placeDoorBlock(world, x, y, z, 3, mod_pocketDim.ExitDoor);
|
||||
ItemDimensionalDoor.placeDoorBlock(world, x, y, z, 3, mod_pocketDim.warpDoor);
|
||||
|
||||
return link;
|
||||
}
|
||||
|
||||
public boolean validateDungeonType(String type, DungeonPack pack)
|
||||
{
|
||||
//Check if the dungeon type is valid
|
||||
return pack.isKnownType(type);
|
||||
}
|
||||
|
||||
@@ -370,10 +336,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 +351,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);
|
||||
}
|
||||
}
|
||||
@@ -403,7 +369,7 @@ public class DungeonHelper
|
||||
File[] packFiles;
|
||||
ArrayList<String> packFilePaths;
|
||||
File directory = new File(path);
|
||||
SchematicFileFilter schematicFileFilter = new SchematicFileFilter();
|
||||
FileFilter schematicFileFilter = new FileFilters.FileExtensionFilter(SCHEMATIC_FILE_EXTENSION);
|
||||
|
||||
//Check that the Ruins pack has been loaded
|
||||
if (RuinsPack == null)
|
||||
@@ -427,7 +393,7 @@ public class DungeonHelper
|
||||
schematics = null; //Release memory
|
||||
|
||||
//Load the custom dungeon packs
|
||||
packDirectories = directory.listFiles(new DirectoryFilter());
|
||||
packDirectories = directory.listFiles(new FileFilters.DirectoryFilter());
|
||||
if (packDirectories != null)
|
||||
{
|
||||
//Loop through each directory, which is assumed to be a dungeon pack
|
||||
@@ -462,9 +428,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 +494,10 @@ public class DungeonHelper
|
||||
}
|
||||
}
|
||||
|
||||
public void generateDungeonLink(LinkData 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 +511,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 +529,7 @@ public class DungeonHelper
|
||||
}
|
||||
|
||||
//Pick the next dungeon
|
||||
selection = selectedPack.getNextDungeon(inbound, random);
|
||||
selection = selectedPack.getNextDungeon(dimension, random);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -580,7 +545,7 @@ public class DungeonHelper
|
||||
selection = defaultError;
|
||||
}
|
||||
}
|
||||
dimHelper.instance.getDimData(inbound.destDimID).dungeonGenerator = selection;
|
||||
return selection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -621,16 +586,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 +603,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 (LinkData 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(LinkData 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 (LinkData 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 (LinkData 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,23 @@
|
||||
package StevenDimDoors.mod_pocketDim.helpers;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||
|
||||
public class yCoordHelper
|
||||
{
|
||||
private static final int MAXIMUM_UNCOVERED_Y = 245;
|
||||
|
||||
public static int getFirstUncovered(LinkData 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)
|
||||
{
|
||||
@@ -43,21 +25,23 @@ public class yCoordHelper
|
||||
|
||||
int localX = x < 0 ? (x % 16) + 16 : (x % 16);
|
||||
int localZ = z < 0 ? (z % 16) + 16 : (z % 16);
|
||||
int height = MAXIMUM_UNCOVERED_Y; //world.getHeight();
|
||||
int height = MAXIMUM_UNCOVERED_Y;
|
||||
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 +50,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 +70,228 @@ public class yCoordHelper
|
||||
material = block.blockMaterial;
|
||||
return (material.isLiquid() || !material.isReplaceable());
|
||||
}
|
||||
|
||||
public static Point3D findSafeCubeUp(World world, int x, int startY, int z)
|
||||
{
|
||||
// Search for a 3x3x3 cube of air with blocks underneath
|
||||
// We can also match against a 3x2x3 box with
|
||||
// We shift the search area into the bounds of a chunk for the sake of simplicity,
|
||||
// so that we don't need to worry about working across chunks.
|
||||
|
||||
int localX = x < 0 ? (x % 16) + 16 : (x % 16);
|
||||
int localZ = z < 0 ? (z % 16) + 16 : (z % 16);
|
||||
int cornerX = x - localX;
|
||||
int cornerZ = z - localZ;
|
||||
localX = MathHelper.clamp_int(localX, 1, 14);
|
||||
localZ = MathHelper.clamp_int(localZ, 1, 14);
|
||||
|
||||
Chunk chunk = initializeChunkArea(world, x >> 4, z >> 4);
|
||||
|
||||
int height = world.getActualHeight();
|
||||
int y, dx, dz, blockID;
|
||||
boolean isSafe;
|
||||
Block block;
|
||||
|
||||
// Initialize layers to a huge negative number so that we won't
|
||||
// consider an area as usable unless it gets reset to 0 first
|
||||
// when we find a foundation upon which to build.
|
||||
int layers = -1000000;
|
||||
|
||||
// Check if a 3x3 layer of blocks is empty
|
||||
// If we find a layer that contains replaceable blocks, it can
|
||||
// serve as the base where we'll place the player and door.
|
||||
for (y = Math.max(startY - 1, 0); y < height; y++)
|
||||
{
|
||||
isSafe = true;
|
||||
for (dx = -1; dx <= 1 && isSafe; dx++)
|
||||
{
|
||||
for (dz = -1; dz <= 1 && isSafe; dz++)
|
||||
{
|
||||
blockID = chunk.getBlockID(localX + dx, y, localZ + dz);
|
||||
if (blockID != 0)
|
||||
{
|
||||
block = Block.blocksList[blockID];
|
||||
if (!block.blockMaterial.isReplaceable())
|
||||
{
|
||||
isSafe = false;
|
||||
}
|
||||
layers = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isSafe)
|
||||
{
|
||||
layers++;
|
||||
if (layers == 3)
|
||||
{
|
||||
return new Point3D(localX + cornerX, y - 2, localZ + cornerZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Point3D findSafeCubeDown(World world, int x, int startY, int z)
|
||||
{
|
||||
// Search for a 3x3x3 cube of air with blocks underneath
|
||||
// We can also match against a 3x2x3 box with
|
||||
// We shift the search area into the bounds of a chunk for the sake of simplicity,
|
||||
// so that we don't need to worry about working across chunks.
|
||||
|
||||
int localX = x < 0 ? (x % 16) + 16 : (x % 16);
|
||||
int localZ = z < 0 ? (z % 16) + 16 : (z % 16);
|
||||
int cornerX = x - localX;
|
||||
int cornerZ = z - localZ;
|
||||
localX = MathHelper.clamp_int(localX, 1, 14);
|
||||
localZ = MathHelper.clamp_int(localZ, 1, 14);
|
||||
|
||||
Chunk chunk = initializeChunkArea(world, x >> 4, z >> 4);
|
||||
|
||||
int height = world.getActualHeight();
|
||||
int y, dx, dz, blockID;
|
||||
boolean isSafe;
|
||||
boolean hasBlocks;
|
||||
Block block;
|
||||
int layers = 0;
|
||||
|
||||
// Check if a 3x3 layer of blocks is empty
|
||||
// If we find a layer that contains replaceable blocks, it can
|
||||
// serve as the base where we'll place the player and door.
|
||||
for (y = Math.min(startY + 2, height - 1); y >= 0; y--)
|
||||
{
|
||||
isSafe = true;
|
||||
hasBlocks = false;
|
||||
for (dx = -1; dx <= 1 && isSafe; dx++)
|
||||
{
|
||||
for (dz = -1; dz <= 1 && isSafe; dz++)
|
||||
{
|
||||
blockID = chunk.getBlockID(localX + dx, y, localZ + dz);
|
||||
if (blockID != 0)
|
||||
{
|
||||
block = Block.blocksList[blockID];
|
||||
if (!block.blockMaterial.isReplaceable())
|
||||
{
|
||||
if (layers >= 3)
|
||||
{
|
||||
return new Point3D(localX + cornerX, y + 1, localZ + cornerZ);
|
||||
}
|
||||
isSafe = false;
|
||||
}
|
||||
hasBlocks = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isSafe)
|
||||
{
|
||||
layers++;
|
||||
if (hasBlocks)
|
||||
{
|
||||
if (layers >= 3)
|
||||
{
|
||||
return new Point3D(localX + cornerX, y, localZ + cornerZ);
|
||||
}
|
||||
layers = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Chunk initializeChunkArea(World world, int chunkX, int chunkZ)
|
||||
{
|
||||
// We initialize a 3x3 area of chunks instead of just initializing
|
||||
// the target chunk because things generated in adjacent chunks
|
||||
// (e.g. trees) might intrude into the target chunk.
|
||||
|
||||
IChunkProvider provider = world.getChunkProvider();
|
||||
Chunk target = provider.loadChunk(chunkX, chunkZ);
|
||||
for (int dx = -1; dx <= 1; dx++)
|
||||
{
|
||||
for (int dz = -1; dz <= 1; dz++)
|
||||
{
|
||||
if (!provider.chunkExists(chunkX + dx, chunkZ + dz))
|
||||
{
|
||||
provider.loadChunk(chunkX, chunkZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
public static Point3D findDropPoint(World world, int x, int startY, int z)
|
||||
{
|
||||
// Find a simple 2-block-high air gap
|
||||
// Search across a 3x3 column
|
||||
final int GAP_HEIGHT = 2;
|
||||
|
||||
int localX = x < 0 ? (x % 16) + 16 : (x % 16);
|
||||
int localZ = z < 0 ? (z % 16) + 16 : (z % 16);
|
||||
int cornerX = x - localX;
|
||||
int cornerZ = z - localZ;
|
||||
localX = MathHelper.clamp_int(localX, 1, 14);
|
||||
localZ = MathHelper.clamp_int(localZ, 1, 14);
|
||||
|
||||
Chunk chunk = initializeChunkArea(world, x >> 4, z >> 4);
|
||||
|
||||
int y, dx, dz, index;
|
||||
int height = world.getActualHeight();
|
||||
int[] gaps = new int[9];
|
||||
|
||||
// Check 3x3 layers of blocks for air spaces
|
||||
for (y = Math.min(startY, height - 1); y > 0; y--)
|
||||
{
|
||||
for (dx = -1, index = 0; dx <= 1; dx++)
|
||||
{
|
||||
for (dz = -1; dz <= 1; dz++, index++)
|
||||
{
|
||||
if (chunk.getBlockID(localX + dx, y, localZ + dz) != 0)
|
||||
{
|
||||
gaps[index] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
gaps[index]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check if an acceptable gap exists in the center of the search column
|
||||
if (gaps[index / 2] == GAP_HEIGHT)
|
||||
{
|
||||
return new Point3D(localX + cornerX, y + GAP_HEIGHT - 1, localZ + cornerZ);
|
||||
}
|
||||
// Check the other positions in the column
|
||||
for (dx = -1, index = 0; dx <= 1; dx++)
|
||||
{
|
||||
for (dz = -1; dz <= 1; dz++, index++)
|
||||
{
|
||||
if (gaps[index] == GAP_HEIGHT)
|
||||
{
|
||||
return new Point3D(localX + cornerX + dx, y + GAP_HEIGHT - 1, localZ + cornerZ + dz);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
118
StevenDimDoors/mod_pocketDim/items/BaseItemDoor.java
Normal file
118
StevenDimDoors/mod_pocketDim/items/BaseItemDoor.java
Normal file
@@ -0,0 +1,118 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemDoor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public abstract class BaseItemDoor extends ItemDoor
|
||||
{
|
||||
private static DDProperties properties = null;
|
||||
|
||||
public BaseItemDoor(int itemID, Material material)
|
||||
{
|
||||
super(itemID, material);
|
||||
this.setMaxStackSize(64);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
@Override
|
||||
public abstract void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4);
|
||||
|
||||
@Override
|
||||
public abstract boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ);
|
||||
|
||||
public static boolean tryItemUse(Block doorBlock, ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, boolean requireLink, boolean reduceStack)
|
||||
{
|
||||
// Only place doors on top of blocks - check if we're targeting the top side
|
||||
if (side == 1 && !world.isRemote)
|
||||
{
|
||||
int blockID = world.getBlockId(x, y, z);
|
||||
if (blockID != 0)
|
||||
{
|
||||
if (!Block.blocksList[blockID].isBlockReplaceable(world, x, y, z))
|
||||
{
|
||||
y++;
|
||||
}
|
||||
}
|
||||
|
||||
if (canPlace(world, x, y, z) && canPlace(world, x, y + 1, z) &&
|
||||
player.canPlayerEdit(x, y, z, side, stack) && player.canPlayerEdit(x, y + 1, z, side, stack) &&
|
||||
(!requireLink || PocketManager.getLink(x, y + 1, z, world) != null)&&stack.stackSize>0)
|
||||
{
|
||||
int orientation = MathHelper.floor_double((double) ((player.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
placeDoorBlock(world, x, y, z, orientation, doorBlock);
|
||||
|
||||
if (!player.capabilities.isCreativeMode && reduceStack)
|
||||
{
|
||||
stack.stackSize--;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player);
|
||||
|
||||
public boolean tryPlacingDoor(Block doorBlock, World world, EntityPlayer player, ItemStack item)
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(player.worldObj, player, true);
|
||||
if (hit != null)
|
||||
{
|
||||
if (world.getBlockId(hit.blockX, hit.blockY, hit.blockZ) == properties.RiftBlockID)
|
||||
{
|
||||
DimLink link = PocketManager.getLink(hit.blockX, hit.blockY, hit.blockZ, world.provider.dimensionId);
|
||||
if (link != null)
|
||||
{
|
||||
int x = hit.blockX;
|
||||
int y = hit.blockY;
|
||||
int z = hit.blockZ;
|
||||
|
||||
if (player.canPlayerEdit(x, y, z, hit.sideHit, item) && player.canPlayerEdit(x, y - 1, z, hit.sideHit, item))
|
||||
{
|
||||
if (canPlace(world, x, y, z) && canPlace(world, x, y - 1, z))
|
||||
{
|
||||
int orientation = MathHelper.floor_double(((player.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
placeDoorBlock(world, x, y - 1, z, orientation, doorBlock);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean canPlace(World world, int x, int y, int z)
|
||||
{
|
||||
int id = world.getBlockId(x, y, z);
|
||||
|
||||
return (id == properties.RiftBlockID || id == 0 || Block.blocksList[id].blockMaterial.isReplaceable());
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
public class ItemChaosDoor extends itemDimDoor
|
||||
{
|
||||
public ItemChaosDoor(int par1, Material par2Material)
|
||||
{
|
||||
super(par1, par2Material);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Caution: Leads to random destination");
|
||||
}
|
||||
|
||||
}
|
||||
48
StevenDimDoors/mod_pocketDim/items/ItemDimensionalDoor.java
Normal file
48
StevenDimDoors/mod_pocketDim/items/ItemDimensionalDoor.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
public class ItemDimensionalDoor extends BaseItemDoor
|
||||
{
|
||||
public ItemDimensionalDoor(int itemID, Material material)
|
||||
{
|
||||
super(itemID, material);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Place on the block under a rift");
|
||||
par3List.add("to activate that rift or place");
|
||||
par3List.add("anywhere else to create a");
|
||||
par3List.add("pocket dimension.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (tryPlacingDoor(mod_pocketDim.dimensionalDoor, world, player, stack) &&
|
||||
!player.capabilities.isCreativeMode)
|
||||
{
|
||||
stack.stackSize--;
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y,
|
||||
int z, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
return tryItemUse(mod_pocketDim.dimensionalDoor, stack, player, world, x, y, z, par7, false, true);
|
||||
}
|
||||
}
|
||||
53
StevenDimDoors/mod_pocketDim/items/ItemGoldDimDoor.java
Normal file
53
StevenDimDoors/mod_pocketDim/items/ItemGoldDimDoor.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
public class ItemGoldDimDoor extends BaseItemDoor
|
||||
{
|
||||
|
||||
public ItemGoldDimDoor(int itemID, Material material) {
|
||||
super(itemID, material);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Similar to a Iron Dim Door");
|
||||
par3List.add("But if present in a pocket dim");
|
||||
par3List.add("it will keep it loaded.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y,
|
||||
int z, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
return tryItemUse(mod_pocketDim.goldDimDoor, stack, player, world, x, y, z, par7, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (tryPlacingDoor(mod_pocketDim.goldDimDoor, world, player, stack) &&
|
||||
!player.capabilities.isCreativeMode)
|
||||
{
|
||||
stack.stackSize--;
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
64
StevenDimDoors/mod_pocketDim/items/ItemGoldDoor.java
Normal file
64
StevenDimDoors/mod_pocketDim/items/ItemGoldDoor.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemDoor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemGoldDoor extends ItemDoor
|
||||
{
|
||||
|
||||
public ItemGoldDoor(int par1, Material par2Material)
|
||||
{
|
||||
super(par1, par2Material);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
|
||||
}
|
||||
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
if (par7 != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
++par5;
|
||||
Block block = mod_pocketDim.goldDoor;
|
||||
|
||||
|
||||
|
||||
if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack))
|
||||
{
|
||||
if (!block.canPlaceBlockAt(par3World, par4, par5, par6))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i1 = MathHelper.floor_double((double)((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
placeDoorBlock(par3World, par4, par5, par6, i1, block);
|
||||
--par1ItemStack.stackSize;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -5,14 +5,11 @@ import java.util.List;
|
||||
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.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.EnumToolMaterial;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
@@ -21,38 +18,34 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemRiftBlade extends ItemSword
|
||||
{
|
||||
public ItemRiftBlade(int par1)
|
||||
private final DDProperties properties;
|
||||
|
||||
public ItemRiftBlade(int itemID, EnumToolMaterial material, DDProperties properties)
|
||||
{
|
||||
super(par1, EnumToolMaterial.GOLD);
|
||||
super(itemID, material);
|
||||
|
||||
// this.setTextureFile("/PocketBlockTextures.png");
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
this.setMaxStackSize(1);
|
||||
|
||||
// this.itemIcon=5;
|
||||
this.setMaxDamage(500);
|
||||
this.hasSubtypes=false;
|
||||
//TODO move to proxy
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
this.hasSubtypes = false;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
private static DDProperties properties = null;
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean isFull3D()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
|
||||
{
|
||||
if (par2Block.blockID == Block.web.blockID)
|
||||
@@ -66,25 +59,27 @@ public class ItemRiftBlade extends ItemSword
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getDamageVsEntity(Entity par1Entity)
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean hasEffect(ItemStack par1ItemStack)
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
|
||||
{
|
||||
par1ItemStack.damageItem(1, par3EntityLiving);
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getDamageVsEntity(Entity par1Entity)
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3)
|
||||
{
|
||||
float var4 = 1.0F;
|
||||
@@ -109,22 +104,19 @@ public class ItemRiftBlade extends ItemSword
|
||||
return par1World.rayTraceBlocks_do_do(var13, var23, true, false);
|
||||
}
|
||||
|
||||
protected boolean teleportToEntity(ItemStack item, Entity par1Entity, EntityPlayer holder)
|
||||
private boolean teleportToEntity(ItemStack item, Entity par1Entity, EntityPlayer holder)
|
||||
{
|
||||
Vec3 var2 = holder.worldObj.getWorldVec3Pool().getVecFromPool(holder.posX - par1Entity.posX, holder.boundingBox.minY + (double)(holder.height / 2.0F) - par1Entity.posY + (double)par1Entity.getEyeHeight(), holder.posZ - par1Entity.posZ);
|
||||
|
||||
|
||||
double cooef =( var2.lengthVector()-2.5)/var2.lengthVector();
|
||||
var2.xCoord*=cooef;
|
||||
var2.yCoord*=cooef;
|
||||
var2.zCoord*=cooef;
|
||||
double var5 = holder.posX - var2.xCoord;
|
||||
double var9 = holder.posZ - var2.zCoord;
|
||||
double var7 =holder.worldObj.getHeightValue(MathHelper.floor_double(var5), MathHelper.floor_double(var9));
|
||||
if((Math.abs((holder.posY - var2.yCoord)-var7)>2))
|
||||
{
|
||||
|
||||
var7 = MathHelper.floor_double(holder.posY - var2.yCoord) ;
|
||||
|
||||
|
||||
double var7 = MathHelper.floor_double(holder.posY - var2.yCoord) ;
|
||||
|
||||
int var14 = MathHelper.floor_double(var5);
|
||||
int var15 = MathHelper.floor_double(var7);
|
||||
@@ -134,264 +126,98 @@ public class ItemRiftBlade extends ItemSword
|
||||
var15++;
|
||||
}
|
||||
var7=var15;
|
||||
}
|
||||
|
||||
|
||||
|
||||
holder.setPositionAndUpdate(var5, var7, var9);
|
||||
holder.playSound("mob.endermen.portal", 1.0F, 1.0F);
|
||||
holder.worldObj.playSoundEffect(holder.posX, holder.posY, holder.posZ, "mob.endermen.portal", 1.0F, 1.0F);
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
public ItemStack onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* How long it takes to use or consume an item
|
||||
*/
|
||||
public int getMaxItemUseDuration(ItemStack par1ItemStack)
|
||||
{
|
||||
return 72000;
|
||||
}
|
||||
|
||||
public EnumAction getItemUseAction(ItemStack par1ItemStack)
|
||||
{
|
||||
return properties.RiftBladeRiftCreationEnabled ? EnumAction.bow : EnumAction.block;
|
||||
}
|
||||
|
||||
public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4)
|
||||
{
|
||||
//Condition for disabling rift creation
|
||||
if (!properties.RiftBladeRiftCreationEnabled)
|
||||
return;
|
||||
|
||||
Vec3 var2 = par3EntityPlayer.getLook(1.0F);
|
||||
|
||||
double cooef = -2;
|
||||
var2.xCoord*=cooef;
|
||||
var2.yCoord*=cooef;
|
||||
var2.zCoord*=cooef;
|
||||
double var5 = par3EntityPlayer.posX - var2.xCoord;
|
||||
double var9 = par3EntityPlayer.posZ - var2.zCoord;
|
||||
double var7 = par3EntityPlayer.posY - var2.yCoord+2;
|
||||
|
||||
int x = MathHelper.floor_double(var5);
|
||||
int y = MathHelper.floor_double(var7);
|
||||
int z = MathHelper.floor_double(var9);
|
||||
|
||||
int rotation = (int) (MathHelper.floor_double((double)((par3EntityPlayer.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
|
||||
LinkData link = new LinkData(par2World.provider.dimensionId, 0, x, y, z, x, y, z, true,rotation);
|
||||
|
||||
if(this.getMaxItemUseDuration(par1ItemStack)-par4>12&&!par2World.isRemote&&itemDimDoor.canPlace(par2World, x, y, z, rotation))
|
||||
if (!world.isRemote)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<EntityLiving> list = (List<EntityLiving>) world.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(player.posX-8,player.posY-8, player.posZ-8, player.posX+8,player.posY+8, player.posZ+8));
|
||||
list.remove(player);
|
||||
|
||||
if(dimHelper.instance.getDimData(par2World.provider.dimensionId)!=null)
|
||||
for (EntityLiving ent : list)
|
||||
{
|
||||
if(dimHelper.instance.getDimData(par2World.provider.dimensionId).depth==0)
|
||||
Vec3 var3 = player.getLook(1.0F).normalize();
|
||||
Vec3 var4 = player.worldObj.getWorldVec3Pool().getVecFromPool(ent.posX - player.posX, ent.boundingBox.minY + (double)((ent.height) / 2.0F) - ( player.posY + (double) player.getEyeHeight()), ent.posZ - player.posZ);
|
||||
double var5 = var4.lengthVector();
|
||||
var4 = var4.normalize();
|
||||
double var7 = var3.dotProduct(var4);
|
||||
if( (var7+.1) > 1.0D - 0.025D / var5 ? player.canEntityBeSeen(ent) : false)
|
||||
{
|
||||
dimHelper.instance.createPocket(link,true, false);
|
||||
teleportToEntity(stack, ent, player);
|
||||
stack.damageItem(3, player);
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dimHelper.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);
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
Boolean didFindThing=false;
|
||||
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(par3EntityPlayer.worldObj, par3EntityPlayer, false );
|
||||
if(hit!=null&&!par2World.isRemote)
|
||||
{
|
||||
if(par2World.getBlockId(hit.blockX, hit.blockY, hit.blockZ)==properties.RiftBlockID)
|
||||
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, false);
|
||||
if (hit != null)
|
||||
{
|
||||
LinkData link = dimHelper.instance.getLinkDataFromCoords(hit.blockX, hit.blockY, hit.blockZ, par2World);
|
||||
if(link!=null)
|
||||
int x = hit.blockX;
|
||||
int y = hit.blockY;
|
||||
int z = hit.blockZ;
|
||||
if (world.getBlockId(x, y, z) == properties.RiftBlockID)
|
||||
{
|
||||
|
||||
Block var11 = mod_pocketDim.transientDoor;
|
||||
int par4 = hit.blockX;
|
||||
int par5 = hit.blockY;
|
||||
int par6 = hit.blockZ;
|
||||
int par7 = 0 ;
|
||||
|
||||
|
||||
|
||||
|
||||
if (par3EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par3EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)&&!par2World.isRemote)
|
||||
if (PocketManager.getLink(x, y, z, world) != null)
|
||||
{
|
||||
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)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
else
|
||||
if (player.canPlayerEdit(x, y, z, hit.sideHit, stack) &&
|
||||
player.canPlayerEdit(x, y + 1, z, hit.sideHit, stack))
|
||||
{
|
||||
int orientation = MathHelper.floor_double((double)((player.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
|
||||
itemDimDoor.placeDoorBlock(par2World, par4, par5-1, par6, var12, var11);
|
||||
par3EntityPlayer.worldObj.playSoundAtEntity(par3EntityPlayer,"mods.DimDoors.sfx.riftDoor", (float) .6, 1);
|
||||
|
||||
didFindThing=true;
|
||||
|
||||
|
||||
par1ItemStack.damageItem(10, par3EntityPlayer);
|
||||
|
||||
if (BaseItemDoor.canPlace(world, x, y, z) &&
|
||||
BaseItemDoor.canPlace(world, x, y - 1, z))
|
||||
{
|
||||
ItemDimensionalDoor.placeDoorBlock(world, x, y - 1, z, orientation, mod_pocketDim.transientDoor);
|
||||
player.worldObj.playSoundAtEntity(player,"mods.DimDoors.sfx.riftDoor", 0.6f, 1);
|
||||
stack.damageItem(3, player);
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(par2World.getBlockId(hit.blockX, hit.blockY, hit.blockZ) == properties.TransientDoorID)
|
||||
{
|
||||
didFindThing=true;
|
||||
}
|
||||
|
||||
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(!par3EntityPlayer.worldObj.isRemote)
|
||||
{
|
||||
List<EntityLiving> list = par3EntityPlayer.worldObj.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox( par3EntityPlayer.posX-8,par3EntityPlayer.posY-8, par3EntityPlayer.posZ-8, par3EntityPlayer.posX+8,par3EntityPlayer.posY+8, par3EntityPlayer.posZ+8));
|
||||
list.remove(par3EntityPlayer);
|
||||
|
||||
|
||||
for(EntityLiving ent : list)
|
||||
{
|
||||
|
||||
Vec3 var3 = par3EntityPlayer.getLook(1.0F).normalize();
|
||||
Vec3 var4 = par3EntityPlayer.worldObj.getWorldVec3Pool().getVecFromPool(ent.posX - par3EntityPlayer.posX, ent.boundingBox.minY + (double)((ent.height) / 2.0F) - ( par3EntityPlayer.posY + (double) par3EntityPlayer.getEyeHeight()), ent.posZ - par3EntityPlayer.posZ);
|
||||
double var5 = var4.lengthVector();
|
||||
var4 = var4.normalize();
|
||||
double var7 = var3.dotProduct(var4);
|
||||
if( (var7+.1) > 1.0D - 0.025D / var5 ? par3EntityPlayer.canEntityBeSeen(ent) : false)
|
||||
{
|
||||
System.out.println(list.size());
|
||||
ItemRiftBlade.class.cast(par1ItemStack.getItem()).teleportToEntity(par1ItemStack,ent, par3EntityPlayer);
|
||||
didFindThing=true;
|
||||
break;
|
||||
|
||||
//ItemRiftBlade.class.cast(item.getItem()).teleportTo(event.entityPlayer, ent.posX, ent.posY, ent.posZ);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// if(dimHelper.instance.getDimData(par2World.provider.dimensionId)!=null&&!par2World.isRemote&&!didFindThing)
|
||||
{
|
||||
|
||||
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return par1ItemStack;
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
|
||||
|
||||
}
|
||||
public int getItemEnchantability()
|
||||
{
|
||||
return EnumToolMaterial.GOLD.getEnchantability();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name for this tool's material.
|
||||
*/
|
||||
public String getToolMaterialName()
|
||||
{
|
||||
return EnumToolMaterial.GOLD.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this item is repairable in an anvil.
|
||||
*/
|
||||
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
|
||||
{
|
||||
return mod_pocketDim.itemStableFabric.itemID == par2ItemStack.itemID ? true : super.getIsRepairable(par1ItemStack, par2ItemStack);
|
||||
}
|
||||
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
/**
|
||||
* Return whether this item is repairable in an anvil.
|
||||
*/
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
|
||||
{
|
||||
if (par7 != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
++par5;
|
||||
Block var11;
|
||||
|
||||
|
||||
|
||||
var11 = mod_pocketDim.transientDoor;
|
||||
if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)&&!par3World.isRemote)
|
||||
{
|
||||
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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
itemDimDoor.placeDoorBlock(par3World, par4, par5, par6, var12, var11);
|
||||
par2EntityPlayer.worldObj.playSoundAtEntity(par2EntityPlayer,"mods.DimDoors.sfx.rift", (float) .6, 1);
|
||||
|
||||
|
||||
par1ItemStack.damageItem(10, par2EntityPlayer);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//Don't include a call to super.getIsRepairable()!
|
||||
//That would cause this sword to accept gold as a repair material (since we set material = Gold).
|
||||
return mod_pocketDim.itemStableFabric.itemID == par2ItemStack.itemID ? true : false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
/**
|
||||
* allows items to add custom lines of information to the mouseover description
|
||||
*/
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Opens a temporary doors,");
|
||||
par3List.add ("special teleport attack,");
|
||||
par3List.add ("and rotates existing doors");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
if(!par2World.isRemote)
|
||||
{
|
||||
/**
|
||||
//creates the first half of the link on item creation
|
||||
int key= dimHelper.instance.createUniqueInterDimLinkKey();
|
||||
LinkData linkData= new LinkData(par2World.provider.dimensionId,MathHelper.floor_double(par3EntityPlayer.posX),MathHelper.floor_double(par3EntityPlayer.posY),MathHelper.floor_double(par3EntityPlayer.posZ));
|
||||
System.out.println(key);
|
||||
|
||||
dimHelper.instance.interDimLinkList.put(key, linkData);
|
||||
par1ItemStack.setItemDamage(key);
|
||||
**/
|
||||
}
|
||||
par3List.add("Creates temporary doors");
|
||||
par3List.add("on rifts, rotates doors,");
|
||||
par3List.add("and has a teleport attack.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.EnumArmorMaterial;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
|
||||
public class ItemRiftGoggles extends ItemArmor
|
||||
{
|
||||
private Material doorMaterial;
|
||||
|
||||
public ItemRiftGoggles(int par1, int par2, int par3)
|
||||
{
|
||||
|
||||
245
StevenDimDoors/mod_pocketDim/items/ItemRiftSignature.java
Normal file
245
StevenDimDoors/mod_pocketDim/items/ItemRiftSignature.java
Normal file
@@ -0,0 +1,245 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.BaseDimDoor;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemRiftSignature extends Item
|
||||
{
|
||||
public ItemRiftSignature(int itemID)
|
||||
{
|
||||
super(itemID);
|
||||
this.setMaxStackSize(1);
|
||||
this.setMaxDamage(0);
|
||||
this.hasSubtypes = true;
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack stack)
|
||||
{
|
||||
//Make the item glow if it has one endpoint stored
|
||||
return (stack.getItemDamage() != 0);
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
//TODO- recognize doors and intelligently place rifts on them.
|
||||
// We must use onItemUseFirst() instead of onItemUse() because Minecraft checks
|
||||
// whether the user is in creative mode after calling onItemUse() and undoes any
|
||||
// damage we might set to indicate the rift sig has been activated. Otherwise,
|
||||
// we would need to rely on checking NBT tags for hasEffect() and that function
|
||||
// gets called constantly. Avoiding NBT lookups reduces our performance impact.
|
||||
|
||||
// Return false on the client side to pass this request to the server
|
||||
if (world.isRemote)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
y += 2; //Increase y by 2 to place the rift at head level
|
||||
if (!player.canPlayerEdit(x, y, z, side, stack))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
int adjustedY = adjustYForSpecialBlocks(world,x,y,z);
|
||||
Point4DOrientation source = getSource(stack);
|
||||
int orientation = MathHelper.floor_double((double) ((player.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
if (source != null)
|
||||
{
|
||||
//The link was used before and already has an endpoint stored. Create links connecting the two endpoints.
|
||||
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
|
||||
NewDimData destinationDimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.NORMAL,source.getOrientation());
|
||||
DimLink reverse = destinationDimension.createLink(x, adjustedY, z, LinkTypes.NORMAL,orientation);
|
||||
destinationDimension.setDestination(link, x, adjustedY, z);
|
||||
sourceDimension.setDestination(reverse, source.getX(), source.getY(), source.getZ());
|
||||
|
||||
//Try placing a rift at the destination point
|
||||
if (!mod_pocketDim.blockRift.isBlockImmune(world, x, adjustedY, z))
|
||||
{
|
||||
world.setBlock(x, adjustedY, z, mod_pocketDim.blockRift.blockID);
|
||||
}
|
||||
|
||||
//Try placing a rift at the source point, but check if its world is loaded first
|
||||
World sourceWorld = DimensionManager.getWorld(sourceDimension.id());
|
||||
if (sourceWorld != null &&
|
||||
!mod_pocketDim.blockRift.isBlockImmune(sourceWorld, source.getX(), source.getY(), source.getZ()))
|
||||
{
|
||||
sourceWorld.setBlock(source.getX(), source.getY(), source.getZ(), mod_pocketDim.blockRift.blockID);
|
||||
}
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
stack.stackSize--;
|
||||
}
|
||||
clearSource(stack);
|
||||
player.sendChatToPlayer("Rift Created");
|
||||
world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftEnd", 0.6f, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
//The link signature has not been used. Store its current target as the first location.
|
||||
setSource(stack, x, adjustedY, z,orientation, PocketManager.getDimensionData(world));
|
||||
player.sendChatToPlayer("Location Stored in Rift Signature");
|
||||
world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftStart", 0.6f, 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* allows items to add custom lines of information to the mouseover description
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
Point4DOrientation source = getSource(par1ItemStack);
|
||||
if (source != null)
|
||||
{
|
||||
par3List.add("Leads to (" + source.getX() + ", " + source.getY() + ", " + source.getZ() + ") at dimension #" + source.getDimension());
|
||||
}
|
||||
else
|
||||
{
|
||||
par3List.add("First click stores a location;");
|
||||
par3List.add("second click creates a pair of");
|
||||
par3List.add("rifts linking the two locations.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the rift placement account for replaceable blocks and doors.
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @return the adjusted y coord
|
||||
*/
|
||||
public static int adjustYForSpecialBlocks(World world, int x, int y, int z)
|
||||
{
|
||||
y=y-2;//get the block the player actually clicked on
|
||||
Block block = Block.blocksList[world.getBlockId(x, y, z)];
|
||||
if(block.isBlockReplaceable(world, x, y, z))
|
||||
{
|
||||
return y+1;//move block placement down (-2+1) one so its directly over things like snow
|
||||
}
|
||||
if(block instanceof BaseDimDoor)
|
||||
{
|
||||
if(world.getBlockId(x, y-1, z)==block.blockID&&world.getBlockMetadata(x, y, z)==8)
|
||||
{
|
||||
return y;//move rift placement down two so its in the right place on the door.
|
||||
}
|
||||
return y+1;
|
||||
}
|
||||
return y+2;
|
||||
}
|
||||
public static void setSource(ItemStack itemStack, int x, int y, int z, int orientation, NewDimData dimension)
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
|
||||
tag.setInteger("linkX", x);
|
||||
tag.setInteger("linkY", y);
|
||||
tag.setInteger("linkZ", z);
|
||||
tag.setInteger("orientation", orientation);
|
||||
tag.setInteger("linkDimID", dimension.id());
|
||||
|
||||
itemStack.setTagCompound(tag);
|
||||
itemStack.setItemDamage(1);
|
||||
}
|
||||
|
||||
public static void clearSource(ItemStack itemStack)
|
||||
{
|
||||
//Don't just set the tag to null since there may be other data there (e.g. for renamed items)
|
||||
NBTTagCompound tag = itemStack.getTagCompound();
|
||||
tag.removeTag("linkX");
|
||||
tag.removeTag("linkY");
|
||||
tag.removeTag("linkZ");
|
||||
tag.removeTag("orientation");
|
||||
tag.removeTag("linkDimID");
|
||||
itemStack.setItemDamage(0);
|
||||
}
|
||||
|
||||
public static Point4DOrientation getSource(ItemStack itemStack)
|
||||
{
|
||||
if (itemStack.getItemDamage() != 0)
|
||||
{
|
||||
if (itemStack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = itemStack.getTagCompound();
|
||||
|
||||
Integer x = tag.getInteger("linkX");
|
||||
Integer y = tag.getInteger("linkY");
|
||||
Integer z = tag.getInteger("linkZ");
|
||||
Integer orientation = tag.getInteger("orientation");
|
||||
Integer dimID = tag.getInteger("linkDimID");
|
||||
|
||||
if (x != null && y != null && z != null && dimID != null)
|
||||
{
|
||||
return new Point4DOrientation(x, y, z,orientation, dimID);
|
||||
}
|
||||
}
|
||||
itemStack.setItemDamage(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static class Point4DOrientation
|
||||
{
|
||||
private Point4D point;
|
||||
private int orientation;
|
||||
Point4DOrientation(int x, int y, int z, int orientation, int dimID)
|
||||
{
|
||||
this.point= new Point4D(x,y,z,dimID);
|
||||
this.orientation=orientation;
|
||||
}
|
||||
|
||||
int getX()
|
||||
{
|
||||
return point.getX();
|
||||
}
|
||||
|
||||
int getY()
|
||||
{
|
||||
return point.getY();
|
||||
}
|
||||
|
||||
int getZ()
|
||||
{
|
||||
return point.getZ();
|
||||
}
|
||||
|
||||
int getDimension()
|
||||
{
|
||||
return point.getDimension();
|
||||
}
|
||||
int getOrientation()
|
||||
{
|
||||
return orientation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,201 +2,121 @@ package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
|
||||
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.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemStabilizedRiftSignature extends itemLinkSignature
|
||||
public class ItemStabilizedRiftSignature extends ItemRiftSignature
|
||||
{
|
||||
private static DDProperties properties = null;
|
||||
|
||||
public ItemStabilizedRiftSignature(int par)
|
||||
{
|
||||
super(par);
|
||||
this.setMaxStackSize(1);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
this.setMaxDamage(0);
|
||||
this.hasSubtypes=true;
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack par1ItemStack)
|
||||
{
|
||||
// adds effect if item has a link stored
|
||||
if(par1ItemStack.hasTagCompound())
|
||||
{
|
||||
if(par1ItemStack.stackTagCompound.getBoolean("isCreated"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
|
||||
}
|
||||
public ItemStabilizedRiftSignature(int itemID)
|
||||
{
|
||||
super(itemID);
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
LinkData linkData;
|
||||
int thisWorldID=par3World.provider.dimensionId;
|
||||
Integer[] linkCoords =this.readFromNBT(par1ItemStack);
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
|
||||
}
|
||||
|
||||
int offset = 2;
|
||||
if(par1ItemStack.getTagCompound()!=null)
|
||||
{
|
||||
if(par1ItemStack.getTagCompound().getBoolean("isCreated"))
|
||||
{
|
||||
boolean hasEnder = false;
|
||||
// checks to see if the item has a link stored, if so, it creates it
|
||||
if(par2EntityPlayer.inventory.hasItem(Item.enderPearl.itemID)||par2EntityPlayer.inventory.hasItem(properties.StableFabricItemID))
|
||||
{
|
||||
if(!par2EntityPlayer.inventory.consumeInventoryItem(properties.StableFabricItemID))
|
||||
{
|
||||
par2EntityPlayer.inventory.consumeInventoryItem(Item.enderPearl.itemID);
|
||||
}
|
||||
hasEnder=true;
|
||||
}
|
||||
if(par3World.getBlockId(par4, par5, par6)==Block.snow.blockID)
|
||||
{
|
||||
offset = 1;
|
||||
}
|
||||
if(hasEnder&&!par3World.isRemote)
|
||||
{
|
||||
if(dimHelper.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);
|
||||
}
|
||||
dimHelper.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);
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
// Return false on the client side to pass this request to the server
|
||||
if (world.isRemote)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
par2EntityPlayer.sendChatToPlayer("Rift Created");
|
||||
}
|
||||
else if(!par3World.isRemote)
|
||||
{
|
||||
par2EntityPlayer.sendChatToPlayer("No Ender Pearls!");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!par3World.isRemote)
|
||||
{
|
||||
if(par3World.getBlockId(par4, par5, par6)==Block.snow.blockID)
|
||||
{
|
||||
offset = 1;
|
||||
}
|
||||
//otherwise, it creates the first half of the link. Next click will complete it.
|
||||
key= dimHelper.instance.createUniqueInterDimLinkKey();
|
||||
this.writeToNBT(par1ItemStack, par4, par5+offset, par6,par3World.provider.dimensionId);
|
||||
par2EntityPlayer.worldObj.playSoundAtEntity(par2EntityPlayer,"mods.DimDoors.sfx.riftStart", (float) .6, 1);
|
||||
// We don't check for replaceable blocks. The user can deal with that. <_<
|
||||
y += 2; //Increase y by 2 to place the rift at head level
|
||||
if (!player.canPlayerEdit(x, y, z, side, stack))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
Point4DOrientation source = getSource(stack);
|
||||
int adjustedY = adjustYForSpecialBlocks(world,x,y,z);
|
||||
|
||||
// Check if the Stabilized Rift Signature has been initialized
|
||||
int orientation = MathHelper.floor_double((double) ((player.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
if (source != null)
|
||||
{
|
||||
// Yes, it's initialized. Check if the player is in creative
|
||||
// or if the player can pay an Ender Pearl to create a rift.
|
||||
if (!player.capabilities.isCreativeMode && !player.inventory.hasItem(Item.enderPearl.itemID))
|
||||
{
|
||||
player.sendChatToPlayer("You don't have any Ender Pearls!");
|
||||
return true;
|
||||
}
|
||||
|
||||
par2EntityPlayer.sendChatToPlayer("Rift Signature Stored");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
//The link was used before and already has an endpoint stored. Create links connecting the two endpoints.
|
||||
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
|
||||
NewDimData destinationDimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.NORMAL,source.getOrientation());
|
||||
DimLink reverse = destinationDimension.createLink(x, adjustedY, z, LinkTypes.NORMAL,orientation);
|
||||
destinationDimension.setDestination(link, x, adjustedY, z);
|
||||
sourceDimension.setDestination(reverse, source.getX(), source.getY(), source.getZ());
|
||||
|
||||
/**
|
||||
* allows items to add custom lines of information to the mouseover description
|
||||
*/
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
if(par1ItemStack.hasTagCompound())
|
||||
{
|
||||
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("at x="+coords[0]+" y="+coords[1]+" z="+coords[2]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
par3List.add("First click stores location,");
|
||||
par3List.add ("second click creates two rifts,");
|
||||
par3List.add("that link the first location");
|
||||
par3List.add("with the second location");
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(ItemStack itemStack,int x, int y, int z, int dimID)
|
||||
{
|
||||
NBTTagCompound tag;
|
||||
//Try placing a rift at the destination point
|
||||
if (!mod_pocketDim.blockRift.isBlockImmune(world, x, adjustedY, z))
|
||||
{
|
||||
world.setBlock(x, adjustedY, z, mod_pocketDim.blockRift.blockID);
|
||||
}
|
||||
|
||||
if(itemStack.hasTagCompound())
|
||||
{
|
||||
tag = itemStack.getTagCompound();
|
||||
}
|
||||
else
|
||||
{
|
||||
tag= new NBTTagCompound();
|
||||
}
|
||||
tag.setInteger("linkX", x);
|
||||
tag.setInteger("linkY", y);
|
||||
tag.setInteger("linkZ", z);
|
||||
tag.setInteger("linkDimID", dimID);
|
||||
tag.setBoolean("isCreated", true);
|
||||
itemStack.setTagCompound(tag);
|
||||
}
|
||||
//Try placing a rift at the source point, but check if its world is loaded first
|
||||
World sourceWorld = DimensionManager.getWorld(sourceDimension.id());
|
||||
if (sourceWorld != null &&
|
||||
!mod_pocketDim.blockRift.isBlockImmune(sourceWorld, source.getX(), source.getY(), source.getZ()))
|
||||
{
|
||||
sourceWorld.setBlock(source.getX(), source.getY(), source.getZ(), mod_pocketDim.blockRift.blockID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the stack fields from a NBT object.
|
||||
*/
|
||||
public Integer[] readFromNBT(ItemStack itemStack)
|
||||
{
|
||||
NBTTagCompound tag;
|
||||
Integer[] linkCoords = new Integer[5];
|
||||
if(itemStack.hasTagCompound())
|
||||
{
|
||||
tag = itemStack.getTagCompound();
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
player.inventory.consumeInventoryItem(Item.enderPearl.itemID);
|
||||
}
|
||||
player.sendChatToPlayer("Rift Created");
|
||||
world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftEnd", 0.6f, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
//The link signature has not been used. Store its current target as the first location.
|
||||
setSource(stack, x, adjustedY, z, orientation, PocketManager.getDimensionData(world));
|
||||
player.sendChatToPlayer("Location Stored in Rift Signature");
|
||||
world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftStart", 0.6f, 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!tag.getBoolean("isCreated"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
linkCoords[0]=tag.getInteger("linkX");
|
||||
linkCoords[1]=tag.getInteger("linkY");
|
||||
linkCoords[2]=tag.getInteger("linkZ");
|
||||
linkCoords[3]=tag.getInteger("linkDimID");
|
||||
}
|
||||
return linkCoords;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
if(!par2World.isRemote)
|
||||
{
|
||||
/**
|
||||
//creates the first half of the link on item creation
|
||||
int key= dimHelper.instance.createUniqueInterDimLinkKey();
|
||||
LinkData linkData= new LinkData(par2World.provider.dimensionId,MathHelper.floor_double(par3EntityPlayer.posX),MathHelper.floor_double(par3EntityPlayer.posY),MathHelper.floor_double(par3EntityPlayer.posZ));
|
||||
System.out.println(key);
|
||||
|
||||
dimHelper.instance.interDimLinkList.put(key, linkData);
|
||||
par1ItemStack.setItemDamage(key);
|
||||
**/
|
||||
}
|
||||
}
|
||||
/**
|
||||
* allows items to add custom lines of information to the mouseover description
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
Point4DOrientation source = getSource(par1ItemStack);
|
||||
if (source != null)
|
||||
{
|
||||
par3List.add("Leads to (" + source.getX() + ", " + source.getY() + ", " + source.getZ() + ") at dimension #" + source.getDimension());
|
||||
}
|
||||
else
|
||||
{
|
||||
par3List.add("First click stores a location,");
|
||||
par3List.add("second click creates two rifts");
|
||||
par3List.add("that link the locations together.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,184 +1,19 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.SchematicLoader;
|
||||
import StevenDimDoors.mod_pocketDim.Spells;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.CommonTickHandler;
|
||||
import StevenDimDoors.mod_pocketDimClient.ClientTickHandler;
|
||||
|
||||
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.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.RotationHelper;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
public class ItemStableFabric extends Item
|
||||
{
|
||||
private Material doorMaterial;
|
||||
|
||||
public ItemStableFabric(int par1, int par2)
|
||||
public ItemStableFabric(int itemID, int par2)
|
||||
{
|
||||
super(par1);
|
||||
// this.setitemIcon(Item.doorWood.getIconFromDamage(0));
|
||||
super(itemID);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
|
||||
|
||||
}
|
||||
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
|
||||
if(!par3World.isRemote)
|
||||
{
|
||||
System.out.println("Block metadata is "+par3World.getBlockMetadata(par4, par5, par6));
|
||||
System.out.println(par3World.getBiomeGenForCoords(par4, par6).biomeName);
|
||||
|
||||
|
||||
this.onItemRightClick(par1ItemStack, par3World, par2EntityPlayer);
|
||||
|
||||
Block block = Block.blocksList[par3World.getBlockId(par4, par5, par6)];
|
||||
|
||||
if(dimHelper.dimList.containsKey(par3World.provider.dimensionId))
|
||||
{
|
||||
if(dimHelper.instance.getDimData(par3World.provider.dimensionId).isPocket)
|
||||
{
|
||||
if(dimHelper.instance.getDimData(par3World.provider.dimensionId).dungeonGenerator!=null)
|
||||
{
|
||||
System.out.println("Dungeon name "+dimHelper.instance.getDimData(par3World.provider.dimensionId).dungeonGenerator.schematicPath);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
//System.out.println("Block texture data is "+Block.blocksList[par3World.getBlockId(par4, par5, par6)].getBlockTexture(par3World,par4, par5, par6,par7).getIconName());
|
||||
//System.out.println("Block name is is "+Block.blocksList[par3World.getBlockId(par4, par5, par6)].getUnlocalizedName2());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3)
|
||||
{
|
||||
float var4 = 1.0F;
|
||||
float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
|
||||
float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
|
||||
double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * (double)var4;
|
||||
double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * (double)var4 + 1.62D - (double)par2EntityPlayer.yOffset;
|
||||
double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * (double)var4;
|
||||
Vec3 var13 = par1World.getWorldVec3Pool().getVecFromPool(var7, var9, var11);
|
||||
float var14 = MathHelper.cos(-var6 * 0.017453292F - (float)Math.PI);
|
||||
float var15 = MathHelper.sin(-var6 * 0.017453292F - (float)Math.PI);
|
||||
float var16 = -MathHelper.cos(-var5 * 0.017453292F);
|
||||
float var17 = MathHelper.sin(-var5 * 0.017453292F);
|
||||
float var18 = var15 * var16;
|
||||
float var20 = var14 * var16;
|
||||
double var21 = 5.0D;
|
||||
if (par2EntityPlayer instanceof EntityPlayerMP)
|
||||
{
|
||||
var21 = 4;
|
||||
}
|
||||
Vec3 var23 = var13.addVector((double)var18 * var21, (double)var17 * var21, (double)var20 * var21);
|
||||
return par1World.rayTraceBlocks_do_do(var13, var23, true, false);
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
if (this.isSteven(par3EntityPlayer))
|
||||
{
|
||||
new Spells(par3EntityPlayer, par1ItemStack.stackSize).cast();
|
||||
//mod_pocketDim.proxy.startCasting(par3EntityPlayer, par1ItemStack.stackSize);
|
||||
}
|
||||
|
||||
Boolean didFindThing=false;
|
||||
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(par3EntityPlayer.worldObj, par3EntityPlayer, false );
|
||||
if(hit!=null&&!par2World.isRemote)
|
||||
{
|
||||
//if(par2World.getBlockId(hit.blockX, hit.blockY, hit.blockZ)==properties.RiftBlockID)
|
||||
{
|
||||
LinkData link = dimHelper.instance.getLinkDataFromCoords(hit.blockX, hit.blockY, hit.blockZ, par2World);
|
||||
if(link!=null)
|
||||
{
|
||||
Block var11;
|
||||
if(par1ItemStack.getItem() instanceof itemExitDoor )
|
||||
{
|
||||
var11 = mod_pocketDim.ExitDoor;
|
||||
}
|
||||
|
||||
else if(par1ItemStack.getItem() instanceof ItemChaosDoor )
|
||||
{
|
||||
var11 = mod_pocketDim.chaosDoor;
|
||||
}
|
||||
else
|
||||
{
|
||||
var11 = mod_pocketDim.dimDoor;
|
||||
}
|
||||
|
||||
int par4 = hit.blockX;
|
||||
int par5 = hit.blockY-1;
|
||||
int par6 = hit.blockZ;
|
||||
int par7 = 0 ;
|
||||
|
||||
|
||||
|
||||
|
||||
if (par3EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par3EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)&&!par2World.isRemote)
|
||||
{
|
||||
int var12 = MathHelper.floor_double((double)((par3EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
String cardinal= "default";
|
||||
|
||||
switch(link.linkOrientation)
|
||||
{
|
||||
case 0:
|
||||
cardinal = "East";
|
||||
break;
|
||||
case 1:
|
||||
cardinal = "South";
|
||||
break;
|
||||
case 2:
|
||||
cardinal = "West";
|
||||
break;
|
||||
case 3:
|
||||
cardinal = "North";
|
||||
break;
|
||||
}
|
||||
System.out.println("Link orientation is " + link.linkOrientation + " - " + cardinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
|
||||
public boolean isSteven(EntityPlayer player)
|
||||
{
|
||||
return (player.username.equalsIgnoreCase("stevenrs11"));
|
||||
}
|
||||
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
45
StevenDimDoors/mod_pocketDim/items/ItemUnstableDoor.java
Normal file
45
StevenDimDoors/mod_pocketDim/items/ItemUnstableDoor.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
public class ItemUnstableDoor extends BaseItemDoor
|
||||
{
|
||||
public ItemUnstableDoor(int itemID, Material material)
|
||||
{
|
||||
super(itemID, material);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Caution: Leads to random destination");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (tryPlacingDoor(mod_pocketDim.unstableDoor, world, player, stack) &&
|
||||
!player.capabilities.isCreativeMode)
|
||||
{
|
||||
stack.stackSize--;
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y,
|
||||
int z, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
return tryItemUse(mod_pocketDim.unstableDoor, stack, player, world, x, y, z, par7, false, true);
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
48
StevenDimDoors/mod_pocketDim/items/ItemWarpDoor.java
Normal file
48
StevenDimDoors/mod_pocketDim/items/ItemWarpDoor.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
public class ItemWarpDoor extends BaseItemDoor
|
||||
{
|
||||
public ItemWarpDoor(int itemID, Material material)
|
||||
{
|
||||
super(itemID, material);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Place on the block under");
|
||||
par3List.add("a rift to create a portal,");
|
||||
par3List.add("or place anywhere in a");
|
||||
par3List.add("pocket dimension to exit.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (tryPlacingDoor(mod_pocketDim.warpDoor, world, player, stack) &&
|
||||
!player.capabilities.isCreativeMode)
|
||||
{
|
||||
stack.stackSize--;
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y,
|
||||
int z, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
return tryItemUse(mod_pocketDim.warpDoor, stack, player, world, x, y, z, par7, false, true);
|
||||
}
|
||||
}
|
||||
@@ -1,208 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemDoor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
|
||||
public class itemDimDoor extends ItemDoor
|
||||
{
|
||||
private static DDProperties properties = null;
|
||||
|
||||
public itemDimDoor(int par1, Material par2Material)
|
||||
{
|
||||
super(par1, par2Material);
|
||||
this.setMaxStackSize(64);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Place on the block under a rift");
|
||||
par3List.add("to activate that rift or place");
|
||||
par3List.add("anywhere else to create a");
|
||||
par3List.add("pocket dimension.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
if (par7 != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
++par5;
|
||||
Block var11;
|
||||
|
||||
|
||||
if(par1ItemStack.getItem() instanceof itemExitDoor )
|
||||
{
|
||||
var11 = mod_pocketDim.ExitDoor;
|
||||
}
|
||||
|
||||
else if(par1ItemStack.getItem() instanceof ItemChaosDoor )
|
||||
{
|
||||
var11 = mod_pocketDim.chaosDoor;
|
||||
}
|
||||
else
|
||||
{
|
||||
var11 = mod_pocketDim.dimDoor;
|
||||
}
|
||||
|
||||
if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)&&!par3World.isRemote)
|
||||
{
|
||||
int var12 = MathHelper.floor_double((double)((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
|
||||
if (!canPlace(par3World, par4, par5, par6, var12) || !canPlace(par3World, par4, par5+1, par6, var12))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int offset = 0;
|
||||
int idBlock = par3World.getBlockId(par4, par5-1, par6);
|
||||
|
||||
if(Block.blocksList.length>idBlock&&idBlock!=0)
|
||||
{
|
||||
if(Block.blocksList[idBlock].isBlockReplaceable(par3World, par4, par5-1, par6))
|
||||
{
|
||||
offset = 1;
|
||||
}
|
||||
}
|
||||
|
||||
placeDoorBlock(par3World, par4, par5-offset, par6, var12, var11);
|
||||
|
||||
--par1ItemStack.stackSize;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3)
|
||||
{
|
||||
float var4 = 1.0F;
|
||||
float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
|
||||
float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
|
||||
double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * (double)var4;
|
||||
double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * (double)var4 + 1.62D - (double)par2EntityPlayer.yOffset;
|
||||
double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * (double)var4;
|
||||
Vec3 var13 = par1World.getWorldVec3Pool().getVecFromPool(var7, var9, var11);
|
||||
float var14 = MathHelper.cos(-var6 * 0.017453292F - (float)Math.PI);
|
||||
float var15 = MathHelper.sin(-var6 * 0.017453292F - (float)Math.PI);
|
||||
float var16 = -MathHelper.cos(-var5 * 0.017453292F);
|
||||
float var17 = MathHelper.sin(-var5 * 0.017453292F);
|
||||
float var18 = var15 * var16;
|
||||
float var20 = var14 * var16;
|
||||
double var21 = 5.0D;
|
||||
if (par2EntityPlayer instanceof EntityPlayerMP)
|
||||
{
|
||||
var21 = 4;
|
||||
}
|
||||
Vec3 var23 = var13.addVector((double)var18 * var21, (double)var17 * var21, (double)var20 * var21);
|
||||
return par1World.rayTraceBlocks_do_do(var13, var23, true, false);
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(par3EntityPlayer.worldObj, par3EntityPlayer, false );
|
||||
if(hit!=null&&!par2World.isRemote)
|
||||
{
|
||||
if(par2World.getBlockId(hit.blockX, hit.blockY, hit.blockZ) == properties.RiftBlockID)
|
||||
{
|
||||
LinkData link = dimHelper.instance.getLinkDataFromCoords(hit.blockX, hit.blockY, hit.blockZ, par2World);
|
||||
if(link!=null)
|
||||
{
|
||||
Block var11;
|
||||
if(par1ItemStack.getItem() instanceof itemExitDoor )
|
||||
{
|
||||
var11 = mod_pocketDim.ExitDoor;
|
||||
}
|
||||
|
||||
else if(par1ItemStack.getItem() instanceof ItemChaosDoor )
|
||||
{
|
||||
var11 = mod_pocketDim.chaosDoor;
|
||||
}
|
||||
else
|
||||
{
|
||||
var11 = mod_pocketDim.dimDoor;
|
||||
}
|
||||
|
||||
int par4 = hit.blockX;
|
||||
int par5 = hit.blockY;
|
||||
int par6 = hit.blockZ;
|
||||
int par7 = 0 ;
|
||||
|
||||
|
||||
|
||||
|
||||
if (par3EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par3EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)&&!par2World.isRemote)
|
||||
{
|
||||
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)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
else
|
||||
{
|
||||
placeDoorBlock(par2World, par4, par5-1, par6, var12, var11);
|
||||
|
||||
--par1ItemStack.stackSize;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
|
||||
}
|
||||
|
||||
public static boolean canPlace(World world,int i, int j, int k, int p)
|
||||
{
|
||||
int id = world.getBlockId(i, j, k);
|
||||
|
||||
boolean flag = true;
|
||||
if (id==properties.FabricBlockID || id==properties.RiftBlockID || id==properties.PermaFabricBlockID || id == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (id != 0 && !Block.blocksList[id].blockMaterial.isReplaceable())
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
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.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemDoor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class itemExitDoor extends itemDimDoor
|
||||
{
|
||||
private Material doorMaterial;
|
||||
|
||||
public itemExitDoor(int par1, Material par2Material)
|
||||
{
|
||||
super(par1, par2Material);
|
||||
this.doorMaterial = par2Material;
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
|
||||
|
||||
par3List.add("Place on the block under a rift");
|
||||
par3List.add ("in any dimension,");
|
||||
par3List.add("or place anywhere in pocket dim");
|
||||
par3List.add("to approach surface");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,274 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
|
||||
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.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class itemLinkSignature extends Item
|
||||
{
|
||||
|
||||
public itemLinkSignature(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.setMaxStackSize(1);
|
||||
// this.setTextureFile("/PocketBlockTextures.png");
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
|
||||
// this.itemIcon=5;
|
||||
this.setMaxDamage(0);
|
||||
this.hasSubtypes=true;
|
||||
//TODO move to proxy
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
}
|
||||
|
||||
private static DDProperties properties = null;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack par1ItemStack)
|
||||
{
|
||||
// adds effect if item has a link stored
|
||||
|
||||
|
||||
if(par1ItemStack.hasTagCompound())
|
||||
{
|
||||
if(par1ItemStack.stackTagCompound.getBoolean("isCreated"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
LinkData linkData;
|
||||
int thisWorldID=par3World.provider.dimensionId;
|
||||
|
||||
|
||||
|
||||
|
||||
if(!par3World.isRemote)
|
||||
{
|
||||
|
||||
//par1ItemStack= par2EntityPlayer.getCurrentEquippedItem();
|
||||
Integer[] linkCoords =this.readFromNBT(par1ItemStack);
|
||||
|
||||
|
||||
|
||||
//System.out.println(key);
|
||||
int offset = 2;
|
||||
int idBlock = par3World.getBlockId(par4, par5, par6);
|
||||
|
||||
if(Block.blocksList.length>idBlock&&idBlock!=0)
|
||||
{
|
||||
if(Block.blocksList[idBlock].isBlockReplaceable(par3World, par4, par5, par6))
|
||||
{
|
||||
offset = 1;
|
||||
}
|
||||
}
|
||||
if(par3World.getBlockId(par4, par5, par6) == properties.DimensionalDoorID && par3World.getBlockId(par4, par5 + 1, par6) == properties.DimensionalDoorID)
|
||||
{
|
||||
offset = 1;
|
||||
}
|
||||
else
|
||||
if(par3World.getBlockId(par4, par5, par6)==properties.WarpDoorID&&par3World.getBlockId(par4, par5+1, par6)==properties.WarpDoorID)
|
||||
{
|
||||
offset = 1;
|
||||
}
|
||||
else
|
||||
if (par3World.getBlockId(par4, par5, par6)==properties.DimensionalDoorID&&par3World.getBlockId(par4, par5-1, par6)==properties.DimensionalDoorID)
|
||||
{
|
||||
offset = 0;
|
||||
}
|
||||
else
|
||||
if (par3World.getBlockId(par4, par5, par6) == properties.WarpDoorID && par3World.getBlockId(par4, par5-1, par6)==properties.WarpDoorID)
|
||||
{
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
int orientation = MathHelper.floor_double((double)((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
|
||||
for(int count = 0;count<3;count++)
|
||||
{
|
||||
if(dimHelper.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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(par1ItemStack.getTagCompound()!=null)
|
||||
{
|
||||
if(par1ItemStack.getTagCompound().getBoolean("isCreated"))
|
||||
{
|
||||
// checks to see if the item has a link stored, if so, it creates it
|
||||
|
||||
|
||||
|
||||
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]);
|
||||
|
||||
|
||||
|
||||
--par1ItemStack.stackSize;
|
||||
par2EntityPlayer.sendChatToPlayer("Rift Created");
|
||||
par1ItemStack.stackTagCompound=null;
|
||||
par2EntityPlayer.worldObj.playSoundAtEntity(par2EntityPlayer,"mods.DimDoors.sfx.riftEnd", (float) .6, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
//otherwise, it creates the first half of the link. Next click will complete it.
|
||||
key= dimHelper.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);
|
||||
}
|
||||
//dimHelper.instance.save();
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
/**
|
||||
* allows items to add custom lines of information to the mouseover description
|
||||
*/
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
|
||||
if(par1ItemStack.hasTagCompound())
|
||||
{
|
||||
if(par1ItemStack.stackTagCompound.getBoolean("isCreated"))
|
||||
{
|
||||
Integer[] coords = this.readFromNBT(par1ItemStack);
|
||||
|
||||
par3List.add(String.valueOf("Leads to dim "+coords[3] +" with depth "+(dimHelper.instance.getDimDepth(coords[3]))));
|
||||
par3List.add("at x="+coords[0]+" y="+coords[1]+" z="+coords[2]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
par3List.add("First click stores location,");
|
||||
par3List.add ("second click creates two rifts,");
|
||||
par3List.add("that link the first location");
|
||||
par3List.add("with the second location");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(ItemStack itemStack,int x, int y, int z, int dimID,int orientation)
|
||||
{
|
||||
NBTTagCompound tag;
|
||||
|
||||
if(itemStack.hasTagCompound())
|
||||
{
|
||||
tag = itemStack.getTagCompound();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
tag= new NBTTagCompound();
|
||||
}
|
||||
|
||||
tag.setInteger("linkX", x);
|
||||
tag.setInteger("linkY", y);
|
||||
tag.setInteger("linkZ", z);
|
||||
tag.setInteger("linkDimID", dimID);
|
||||
tag.setBoolean("isCreated", true);
|
||||
tag.setInteger("orientation", orientation);
|
||||
|
||||
itemStack.setTagCompound(tag);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the stack fields from a NBT object.
|
||||
*/
|
||||
public Integer[] readFromNBT(ItemStack itemStack)
|
||||
{
|
||||
|
||||
NBTTagCompound tag;
|
||||
Integer[] linkCoords = new Integer[5];
|
||||
if(itemStack.hasTagCompound())
|
||||
{
|
||||
tag = itemStack.getTagCompound();
|
||||
|
||||
if(!tag.getBoolean("isCreated"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
linkCoords[0]=tag.getInteger("linkX");
|
||||
linkCoords[1]=tag.getInteger("linkY");
|
||||
linkCoords[2]=tag.getInteger("linkZ");
|
||||
linkCoords[3]=tag.getInteger("linkDimID");
|
||||
linkCoords[4]=tag.getInteger("orientation");
|
||||
|
||||
|
||||
|
||||
}
|
||||
return linkCoords;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
if(!par2World.isRemote)
|
||||
{
|
||||
/**
|
||||
//creates the first half of the link on item creation
|
||||
int key= dimHelper.instance.createUniqueInterDimLinkKey();
|
||||
LinkData linkData= new LinkData(par2World.provider.dimensionId,MathHelper.floor_double(par3EntityPlayer.posX),MathHelper.floor_double(par3EntityPlayer.posY),MathHelper.floor_double(par3EntityPlayer.posZ));
|
||||
System.out.println(key);
|
||||
|
||||
dimHelper.instance.interDimLinkList.put(key, linkData);
|
||||
par1ItemStack.setItemDamage(key);
|
||||
**/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,135 +2,135 @@ package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityRift;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class itemRiftRemover extends Item
|
||||
{
|
||||
private Material doorMaterial;
|
||||
public itemRiftRemover(int itemID, Material par2Material)
|
||||
{
|
||||
super(itemID);
|
||||
this.setMaxStackSize(1);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
this.setMaxDamage(4);
|
||||
}
|
||||
|
||||
public itemRiftRemover(int par1, Material par2Material)
|
||||
{
|
||||
super(par1);
|
||||
this.setMaxStackSize(1);
|
||||
// this.setTextureFile("/PocketBlockTextures.png");
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
|
||||
}
|
||||
|
||||
// this.itemIcon=6;
|
||||
this.setMaxDamage(5);
|
||||
this.hasSubtypes=true;
|
||||
//TODO move to proxy
|
||||
}
|
||||
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
// We invoke PlayerControllerMP.onPlayerRightClick() from here so that Minecraft
|
||||
// will invoke onItemUseFirst() on the client side. We'll tell it to pass the
|
||||
// request to the server, which will make sure that rift-related changes are
|
||||
// reflected on the server.
|
||||
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack par1ItemStack)
|
||||
{
|
||||
// adds effect if item has a link stored
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static MovingObjectPosition getBlockTarget(World par1World, EntityPlayer par2EntityPlayer, boolean par3)
|
||||
{
|
||||
float var4 = 1.0F;
|
||||
float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
|
||||
float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
|
||||
double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * (double)var4;
|
||||
double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * (double)var4 + 1.62D - (double)par2EntityPlayer.yOffset;
|
||||
double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * (double)var4;
|
||||
Vec3 var13 = par1World.getWorldVec3Pool().getVecFromPool(var7, var9, var11);
|
||||
float var14 = MathHelper.cos(-var6 * 0.017453292F - (float)Math.PI);
|
||||
float var15 = MathHelper.sin(-var6 * 0.017453292F - (float)Math.PI);
|
||||
float var16 = -MathHelper.cos(-var5 * 0.017453292F);
|
||||
float var17 = MathHelper.sin(-var5 * 0.017453292F);
|
||||
float var18 = var15 * var16;
|
||||
float var20 = var14 * var16;
|
||||
double var21 = 5.0D;
|
||||
if (par2EntityPlayer instanceof EntityPlayerMP)
|
||||
{
|
||||
var21 = 6;
|
||||
}
|
||||
Vec3 var23 = var13.addVector((double)var18 * var21, (double)var17 * var21, (double)var20 * var21);
|
||||
return par1World.rayTraceBlocks_do_do(var13, var23, true, false);
|
||||
}
|
||||
if (!world.isRemote)
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
{
|
||||
MovingObjectPosition hit = this.getBlockTarget(par3EntityPlayer.worldObj, par3EntityPlayer, false );
|
||||
if(hit!=null)
|
||||
{
|
||||
//System.out.println(hit.hitVec);
|
||||
if(dimHelper.instance.removeRift(par2World, hit.blockX, hit.blockY, hit.blockZ, 1, par3EntityPlayer, par1ItemStack))
|
||||
{
|
||||
par3EntityPlayer.worldObj.playSoundAtEntity(par3EntityPlayer,"mods.DimDoors.sfx.riftClose", (float) .8, 1);
|
||||
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, true);
|
||||
if (hit != null)
|
||||
{
|
||||
int hx = hit.blockX;
|
||||
int hy = hit.blockY;
|
||||
int hz = hit.blockZ;
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = dimension.getLink(hx, hy, hz);
|
||||
if (world.getBlockId(hx, hy, hz) == mod_pocketDim.blockRift.blockID && link != null &&
|
||||
player.canPlayerEdit(hx, hy, hz, hit.sideHit, stack))
|
||||
{
|
||||
// Invoke onPlayerRightClick()
|
||||
FMLClientHandler.instance().getClient().playerController.onPlayerRightClick(
|
||||
player, world, stack, hx, hy, hz, hit.sideHit, hit.hitVec);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// dimHelper.removeRift( par3World, par4, par5, par6, range, par2EntityPlayer, par1ItemStack);
|
||||
|
||||
|
||||
}
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
|
||||
/**
|
||||
* allows items to add custom lines of information to the mouseover description
|
||||
*/
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
|
||||
|
||||
par3List.add("Use near exposed rift");
|
||||
par3List.add ("to remove it and");
|
||||
par3List.add("any nearby rifts");
|
||||
|
||||
// We want to use onItemUseFirst() here so that this code will run on the server side,
|
||||
// so we don't need the client to send link-related updates to the server. Still,
|
||||
// check whether we have a rift in sight before passing the request over.
|
||||
|
||||
// On integrated servers, the link won't be removed immediately because of the rift
|
||||
// removal animation. That means we'll have a chance to check for the link before
|
||||
// it's deleted. Otherwise the Rift Remover's durability wouldn't drop.
|
||||
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, true);
|
||||
if (hit != null)
|
||||
{
|
||||
x = hit.blockX;
|
||||
y = hit.blockY;
|
||||
z = hit.blockZ;
|
||||
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = dimension.getLink(x, y, z);
|
||||
if (world.getBlockId(x, y, z) == mod_pocketDim.blockRift.blockID && link != null &&
|
||||
player.canPlayerEdit(x, y, z, side, stack))
|
||||
{
|
||||
// Tell the rift's tile entity to do its removal animation
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
if (tileEntity != null && tileEntity instanceof TileEntityRift)
|
||||
{
|
||||
((TileEntityRift) tileEntity).shouldClose = true;
|
||||
tileEntity.onInventoryChanged();
|
||||
}
|
||||
else if (!world.isRemote)
|
||||
{
|
||||
// Only set the block to air on the server side so that we don't
|
||||
// tell the server to remove the rift block before it can use the
|
||||
// Rift Remover. Otherwise, it won't know to reduce durability.
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
if (world.isRemote)
|
||||
{
|
||||
// Tell the server about this
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
stack.damageItem(1, player);
|
||||
}
|
||||
player.worldObj.playSoundAtEntity(player, "mods.DimDoors.sfx.riftClose", 0.8f, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
if(!par2World.isRemote)
|
||||
{
|
||||
/**
|
||||
//creates the first half of the link on item creation
|
||||
int key= dimHelper.instance.createUniqueInterDimLinkKey();
|
||||
LinkData linkData= new LinkData(par2World.provider.dimensionId,MathHelper.floor_double(par3EntityPlayer.posX),MathHelper.floor_double(par3EntityPlayer.posY),MathHelper.floor_double(par3EntityPlayer.posZ));
|
||||
System.out.println(key);
|
||||
|
||||
dimHelper.instance.interDimLinkList.put(key, linkData);
|
||||
par1ItemStack.setItemDamage(key);
|
||||
**/
|
||||
}
|
||||
}
|
||||
/**
|
||||
* allows items to add custom lines of information to the mouseover description
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Use near exposed rift");
|
||||
par3List.add("to remove it and");
|
||||
par3List.add("any nearby rifts.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,55 +1,62 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityEggInfo;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.EnumToolMaterial;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.ForgeChunkManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.BlockDimWall;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.BlockDimWallPerm;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.BlockDoorGold;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.BlockGoldDimDoor;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.BlockLimbo;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.BlockRift;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.ChaosDoor;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.ExitDoor;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.dimDoor;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.dimHatch;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.DimensionalDoor;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.TransTrapdoor;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.TransientDoor;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.UnstableDoor;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.WarpDoor;
|
||||
import StevenDimDoors.mod_pocketDim.commands.CommandCreateDungeonRift;
|
||||
import StevenDimDoors.mod_pocketDim.commands.CommandCreatePocket;
|
||||
import StevenDimDoors.mod_pocketDim.commands.CommandDeleteAllLinks;
|
||||
import StevenDimDoors.mod_pocketDim.commands.CommandDeleteDimensionData;
|
||||
import StevenDimDoors.mod_pocketDim.commands.CommandDeleteRifts;
|
||||
import StevenDimDoors.mod_pocketDim.commands.CommandExportDungeon;
|
||||
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.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.ChunkLoaderHelper;
|
||||
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.ItemDimensionalDoor;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemGoldDimDoor;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemGoldDoor;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemRiftBlade;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemRiftSignature;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemStabilizedRiftSignature;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemStableFabric;
|
||||
import StevenDimDoors.mod_pocketDim.items.itemDimDoor;
|
||||
import StevenDimDoors.mod_pocketDim.items.itemExitDoor;
|
||||
import StevenDimDoors.mod_pocketDim.items.itemLinkSignature;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemUnstableDoor;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemWarpDoor;
|
||||
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.tileentities.TileEntityDimDoor;
|
||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoorGold;
|
||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityRift;
|
||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityTransTrapdoor;
|
||||
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;
|
||||
@@ -78,13 +85,11 @@ import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
@Mod(modid = mod_pocketDim.modid, name = "Dimensional Doors", version = mod_pocketDim.version)
|
||||
|
||||
|
||||
@NetworkMod(clientSideRequired = true, serverSideRequired = false,
|
||||
@NetworkMod(clientSideRequired = true, serverSideRequired = false, connectionHandler=ConnectionHandler.class,
|
||||
clientPacketHandlerSpec =
|
||||
@SidedPacketHandler(channels = {"pocketDim" }, packetHandler = ClientPacketHandler.class),
|
||||
@SidedPacketHandler(channels = {PacketConstants.CHANNEL_NAME}, packetHandler = ClientPacketHandler.class),
|
||||
serverPacketHandlerSpec =
|
||||
@SidedPacketHandler(channels = {"pocketDim" }, packetHandler = ServerPacketHandler.class),
|
||||
channels={"DimDoorPackets"}, packetHandler = PacketHandler.class, connectionHandler=ConnectionHandler.class)
|
||||
@SidedPacketHandler(channels = {PacketConstants.CHANNEL_NAME}, packetHandler = ServerPacketHandler.class))
|
||||
|
||||
public class mod_pocketDim
|
||||
{
|
||||
@@ -98,18 +103,20 @@ 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;
|
||||
public static Block warpDoor;
|
||||
public static Block goldDoor;
|
||||
public static Block goldDimDoor;
|
||||
public static Block unstableDoor;
|
||||
public static Block blockLimbo;
|
||||
public static Block dimDoor;
|
||||
public static DimensionalDoor dimensionalDoor;
|
||||
public static Block blockDimWall;
|
||||
public static Block dimHatch;
|
||||
public static TransTrapdoor transTrapdoor;
|
||||
public static Block blockDimWallPerm;
|
||||
public static BlockRift blockRift;
|
||||
|
||||
public static Item itemGoldDimDoor;
|
||||
public static Item itemGoldDoor;
|
||||
public static Item itemRiftBlade;
|
||||
public static Item itemDimDoor;
|
||||
public static Item itemExitDoor;
|
||||
@@ -121,20 +128,12 @@ public class mod_pocketDim
|
||||
|
||||
public static BiomeGenBase limboBiome;
|
||||
public static BiomeGenBase pocketBiome;
|
||||
|
||||
public static PlayerRespawnTracker tracker;
|
||||
|
||||
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 long genTime;
|
||||
public static int teleTimer = 0;
|
||||
public static GatewayGenerator riftGen;
|
||||
|
||||
public static CreativeTabs dimDoorsCreativeTab = new CreativeTabs("dimDoorsCreativeTab")
|
||||
{
|
||||
@@ -154,24 +153,20 @@ public class mod_pocketDim
|
||||
|
||||
|
||||
@PreInit
|
||||
public void PreInit(FMLPreInitializationEvent event)
|
||||
public void onPreInitialization(FMLPreInitializationEvent event)
|
||||
{
|
||||
this.instance = this;
|
||||
//This should be the FIRST thing that gets done.
|
||||
properties = DDProperties.initialize(event.getSuggestedConfigurationFile());
|
||||
|
||||
//Now do other stuff
|
||||
MinecraftForge.EVENT_BUS.register(new EventHookContainer());
|
||||
MinecraftForge.EVENT_BUS.register(new EventHookContainer(properties));
|
||||
|
||||
//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(properties);
|
||||
}
|
||||
|
||||
@Init
|
||||
public void Init(FMLInitializationEvent event)
|
||||
public void onInitialization(FMLInitializationEvent event)
|
||||
{
|
||||
CommonTickHandler commonTickHandler = new CommonTickHandler();
|
||||
TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT);
|
||||
@@ -180,28 +175,31 @@ public class mod_pocketDim
|
||||
//MonolithSpawner should be initialized before any provider instances are created
|
||||
//Register the other regular tick receivers as well
|
||||
spawner = new MonolithSpawner(commonTickHandler, properties);
|
||||
new RiftRegenerator(commonTickHandler, properties); //No need to store the reference
|
||||
new RiftRegenerator(commonTickHandler); //No need to store the reference
|
||||
LimboDecay decay = new LimboDecay(commonTickHandler, properties);
|
||||
|
||||
transientDoor = (new TransientDoor(properties.TransientDoorID, Material.iron)).setHardness(1.0F) .setUnlocalizedName("transientDoor");
|
||||
transientDoor = new TransientDoor(properties.TransientDoorID, Material.iron, properties).setHardness(1.0F) .setUnlocalizedName("transientDoor");
|
||||
goldDimDoor = new BlockGoldDimDoor(properties.GoldDimDoorID, Material.iron, properties).setHardness(1.0F) .setUnlocalizedName("dimDoorGold");
|
||||
|
||||
blockDimWall = (new BlockDimWall(properties.FabricBlockID, 0, Material.iron)).setLightValue(1.0F).setHardness(0.1F).setUnlocalizedName("blockDimWall");
|
||||
goldDoor = new BlockDoorGold(properties.GoldDoorID, Material.iron, properties).setHardness(0.1F).setUnlocalizedName("doorGold");
|
||||
blockDimWall = new BlockDimWall(properties.FabricBlockID, 0, Material.iron).setLightValue(1.0F).setHardness(0.1F).setUnlocalizedName("blockDimWall");
|
||||
blockDimWallPerm = (new BlockDimWallPerm(properties.PermaFabricBlockID, 0, Material.iron)).setLightValue(1.0F).setBlockUnbreakable().setResistance(6000000.0F).setUnlocalizedName("blockDimWallPerm");
|
||||
ExitDoor = (new ExitDoor(properties.WarpDoorID, Material.wood)).setHardness(1.0F) .setUnlocalizedName("dimDoorWarp");
|
||||
warpDoor = new WarpDoor(properties.WarpDoorID, Material.wood, properties).setHardness(1.0F) .setUnlocalizedName("dimDoorWarp");
|
||||
blockRift = (BlockRift) (new BlockRift(properties.RiftBlockID, 0, Material.air, properties).setHardness(1.0F) .setUnlocalizedName("rift"));
|
||||
blockLimbo = (new BlockLimbo(properties.LimboBlockID, 15, Material.iron, properties.LimboDimensionID, decay).setHardness(.2F).setUnlocalizedName("BlockLimbo").setLightValue(.0F));
|
||||
chaosDoor = (new ChaosDoor(properties.UnstableDoorID, Material.iron).setHardness(.2F).setUnlocalizedName("chaosDoor").setLightValue(.0F) );
|
||||
dimDoor = (new dimDoor(properties.DimensionalDoorID, Material.iron)).setHardness(1.0F).setResistance(2000.0F) .setUnlocalizedName("dimDoor");
|
||||
dimHatch = (new dimHatch(properties.TransTrapdoorID, 84, Material.iron)).setHardness(1.0F) .setUnlocalizedName("dimHatch");
|
||||
// dimRail = (new DimRail(dimRailID, 88, false)).setHardness(.5F) .setUnlocalizedName("dimRail");
|
||||
|
||||
itemDimDoor = (new itemDimDoor(properties.DimensionalDoorItemID, Material.iron)).setUnlocalizedName("itemDimDoor");
|
||||
itemExitDoor = (new itemExitDoor(properties.WarpDoorItemID, Material.wood)).setUnlocalizedName("itemDimDoorWarp");
|
||||
itemLinkSignature = (new itemLinkSignature(properties.RiftSignatureItemID)).setUnlocalizedName("itemLinkSignature");
|
||||
blockLimbo = new BlockLimbo(properties.LimboBlockID, 15, Material.iron, properties.LimboDimensionID, decay).setHardness(.2F).setUnlocalizedName("BlockLimbo").setLightValue(.0F);
|
||||
unstableDoor = (new UnstableDoor(properties.UnstableDoorID, Material.iron, properties).setHardness(.2F).setUnlocalizedName("chaosDoor").setLightValue(.0F) );
|
||||
dimensionalDoor = (DimensionalDoor) (new DimensionalDoor(properties.DimensionalDoorID, Material.iron, properties).setHardness(1.0F).setResistance(2000.0F) .setUnlocalizedName("dimDoor"));
|
||||
transTrapdoor = (TransTrapdoor) (new TransTrapdoor(properties.TransTrapdoorID, Material.wood).setHardness(1.0F) .setUnlocalizedName("dimHatch"));
|
||||
|
||||
itemGoldDimDoor = (new ItemGoldDimDoor(properties.GoldDimDoorItemID, Material.iron)).setUnlocalizedName("itemGoldDimDoor");
|
||||
itemGoldDoor = (new ItemGoldDoor(properties.GoldDoorID, Material.wood)).setUnlocalizedName("itemGoldDoor");
|
||||
itemDimDoor = (new ItemDimensionalDoor(properties.DimensionalDoorItemID, Material.iron)).setUnlocalizedName("itemDimDoor");
|
||||
itemExitDoor = (new ItemWarpDoor(properties.WarpDoorItemID, Material.wood)).setUnlocalizedName("itemDimDoorWarp");
|
||||
itemLinkSignature = (new ItemRiftSignature(properties.RiftSignatureItemID)).setUnlocalizedName("itemLinkSignature");
|
||||
itemRiftRemover = (new itemRiftRemover(properties.RiftRemoverItemID, Material.wood)).setUnlocalizedName("itemRiftRemover");
|
||||
itemStableFabric = (new ItemStableFabric(properties.StableFabricItemID, 0)).setUnlocalizedName("itemStableFabric");
|
||||
itemChaosDoor = (new ItemChaosDoor(properties.UnstableDoorItemID, Material.iron)).setUnlocalizedName("itemChaosDoor");
|
||||
itemRiftBlade = (new ItemRiftBlade(properties.RiftBladeItemID)).setUnlocalizedName("ItemRiftBlade");
|
||||
itemChaosDoor = (new ItemUnstableDoor(properties.UnstableDoorItemID, Material.iron)).setUnlocalizedName("itemChaosDoor");
|
||||
itemRiftBlade = (new ItemRiftBlade(properties.RiftBladeItemID, EnumToolMaterial.GOLD, properties)).setUnlocalizedName("ItemRiftBlade");
|
||||
itemStabilizedLinkSignature = (new ItemStabilizedRiftSignature(properties.StabilizedRiftSignatureItemID)).setUnlocalizedName("itemStabilizedRiftSig");
|
||||
|
||||
mod_pocketDim.limboBiome= (new BiomeGenLimbo(properties.LimboBiomeID));
|
||||
@@ -209,35 +207,39 @@ public class mod_pocketDim
|
||||
|
||||
GameRegistry.registerWorldGenerator(mod_pocketDim.riftGen);
|
||||
|
||||
GameRegistry.registerBlock(chaosDoor, "Unstable Door");
|
||||
GameRegistry.registerBlock(ExitDoor, "Warp Door");
|
||||
GameRegistry.registerBlock(goldDoor, "Golden Door");
|
||||
GameRegistry.registerBlock(goldDimDoor, "Golden Dimensional Door");
|
||||
GameRegistry.registerBlock(unstableDoor, "Unstable Door");
|
||||
GameRegistry.registerBlock(warpDoor, "Warp Door");
|
||||
GameRegistry.registerBlock(blockRift, "Rift");
|
||||
GameRegistry.registerBlock(blockLimbo, "Unraveled Fabric");
|
||||
GameRegistry.registerBlock(dimDoor, "Dimensional Door");
|
||||
GameRegistry.registerBlock(dimHatch,"Transdimensional Trapdoor");
|
||||
GameRegistry.registerBlock(dimensionalDoor, "Dimensional Door");
|
||||
GameRegistry.registerBlock(transTrapdoor,"Transdimensional Trapdoor");
|
||||
GameRegistry.registerBlock(blockDimWallPerm, "Fabric of RealityPerm");
|
||||
GameRegistry.registerBlock(transientDoor, "transientDoor");
|
||||
|
||||
GameRegistry.registerBlock(blockDimWall, ItemBlockDimWall.class, "Fabric of Reality");
|
||||
|
||||
GameRegistry.registerPlayerTracker(tracker);
|
||||
|
||||
DimensionManager.registerProviderType(properties.PocketProviderID, PocketProvider.class, false);
|
||||
DimensionManager.registerProviderType(properties.LimboProviderID, LimboProvider.class, false);
|
||||
DimensionManager.registerDimension(properties.LimboDimensionID, properties.LimboProviderID);
|
||||
|
||||
LanguageRegistry.addName(goldDoor, "Golden Door");
|
||||
LanguageRegistry.addName(goldDimDoor, "Golden Dimensional Door");
|
||||
LanguageRegistry.addName(transientDoor , "transientDoor");
|
||||
LanguageRegistry.addName(blockRift , "Rift");
|
||||
LanguageRegistry.addName(blockLimbo , "Unraveled Fabric");
|
||||
LanguageRegistry.addName(ExitDoor , "Warp Door");
|
||||
LanguageRegistry.addName(chaosDoor , "Unstable Door");
|
||||
LanguageRegistry.addName(warpDoor , "Warp Door");
|
||||
LanguageRegistry.addName(unstableDoor , "Unstable Door");
|
||||
LanguageRegistry.addName(blockDimWall , "Fabric of Reality");
|
||||
LanguageRegistry.addName(blockDimWallPerm , "Eternal Fabric");
|
||||
LanguageRegistry.addName(dimDoor, "Dimensional Door");
|
||||
LanguageRegistry.addName(dimHatch, "Transdimensional Trapdoor");
|
||||
LanguageRegistry.addName(dimensionalDoor, "Dimensional Door");
|
||||
LanguageRegistry.addName(transTrapdoor, "Transdimensional Trapdoor");
|
||||
|
||||
LanguageRegistry.addName(itemExitDoor, "Warp Door");
|
||||
LanguageRegistry.addName(itemLinkSignature , "Rift Signature");
|
||||
LanguageRegistry.addName(itemGoldDoor, "Golden Door");
|
||||
LanguageRegistry.addName(itemGoldDimDoor , "Golden Dimensional Door");
|
||||
LanguageRegistry.addName(itemStabilizedLinkSignature, "Stabilized Rift Signature");
|
||||
LanguageRegistry.addName(itemRiftRemover , "Rift Remover");
|
||||
LanguageRegistry.addName(itemStableFabric , "Stable Fabric");
|
||||
@@ -254,10 +256,10 @@ public class mod_pocketDim
|
||||
|
||||
LanguageRegistry.instance().addStringLocalization("itemGroup.dimDoorsCustomTab", "en_US", "Dimensional Doors Items");
|
||||
|
||||
//GameRegistry.registerTileEntity(TileEntityDimDoor.class, "TileEntityDimRail");
|
||||
|
||||
GameRegistry.registerTileEntity(TileEntityDimDoor.class, "TileEntityDimDoor");
|
||||
GameRegistry.registerTileEntity(TileEntityRift.class, "TileEntityRift");
|
||||
GameRegistry.registerTileEntity(TileEntityTransTrapdoor.class, "TileEntityDimHatch");
|
||||
GameRegistry.registerTileEntity(TileEntityDimDoorGold.class, "TileEntityDimDoorGold");
|
||||
|
||||
EntityRegistry.registerModEntity(MobMonolith.class, "Monolith", properties.MonolithEntityID, this, 70, 1, true);
|
||||
EntityList.IDtoClassMapping.put(properties.MonolithEntityID, MobMonolith.class);
|
||||
@@ -267,7 +269,7 @@ public class mod_pocketDim
|
||||
//GameRegistry.addBiome(this.limboBiome);
|
||||
//GameRegistry.addBiome(this.pocketBiome);
|
||||
|
||||
if (properties.CraftingDimensionaDoorAllowed)
|
||||
if (properties.CraftingDimensionalDoorAllowed)
|
||||
{
|
||||
GameRegistry.addRecipe(new ItemStack(itemDimDoor, 1), new Object[]
|
||||
{
|
||||
@@ -279,22 +281,6 @@ public class mod_pocketDim
|
||||
" ", "yxy", " ", 'x', mod_pocketDim.itemStableFabric, 'y', Item.doorIron
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
if(this.enableDimRail)
|
||||
{
|
||||
GameRegistry.addRecipe(new ItemStack(dimRail, 1), new Object[]
|
||||
{
|
||||
" ", "yxy", " ", 'x', this.itemDimDoor, 'y', Block.rail
|
||||
});
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(dimRail, 1), new Object[]
|
||||
{
|
||||
" ", "yxy", " ", 'x', this.itemExitDoor, 'y', Block.rail
|
||||
});
|
||||
}
|
||||
**/
|
||||
|
||||
if(properties.CraftingUnstableDoorAllowed)
|
||||
{
|
||||
GameRegistry.addRecipe(new ItemStack(itemChaosDoor, 1), new Object[]
|
||||
@@ -316,12 +302,12 @@ public class mod_pocketDim
|
||||
}
|
||||
if(properties.CraftingTransTrapdoorAllowed)
|
||||
{
|
||||
GameRegistry.addRecipe(new ItemStack(dimHatch, 1), new Object[]
|
||||
GameRegistry.addRecipe(new ItemStack(transTrapdoor, 1), new Object[]
|
||||
{
|
||||
" y ", " x ", " y ", 'x', Item.enderPearl, 'y', Block.trapdoor
|
||||
});
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(dimHatch, 1), new Object[]
|
||||
GameRegistry.addRecipe(new ItemStack(transTrapdoor, 1), new Object[]
|
||||
{
|
||||
" y ", " x ", " y ", 'x', mod_pocketDim.itemStableFabric, 'y', Block.trapdoor
|
||||
});
|
||||
@@ -375,7 +361,25 @@ public class mod_pocketDim
|
||||
" y ", "yxy", " y ", 'x', mod_pocketDim.itemLinkSignature, 'y', mod_pocketDim.itemStableFabric
|
||||
});
|
||||
}
|
||||
|
||||
if (properties.CraftingGoldDimDoorAllowed)
|
||||
{
|
||||
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemGoldDimDoor,1), new Object[]
|
||||
{
|
||||
" x ", " y ", " x ", 'x', mod_pocketDim.itemGoldDoor, 'y', Item.eyeOfEnder
|
||||
});
|
||||
}
|
||||
if (properties.CraftingGoldDoorAllowed)
|
||||
{
|
||||
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemGoldDoor,1), new Object[]
|
||||
{
|
||||
"yy ", "yy ", "yy ", 'y', Item.ingotGold
|
||||
});
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(mod_pocketDim.itemGoldDoor,1), new Object[]
|
||||
{
|
||||
" yy", " yy", " yy", 'y', Item.ingotGold
|
||||
});
|
||||
}
|
||||
DungeonHelper.initialize();
|
||||
|
||||
proxy.loadTextures();
|
||||
@@ -384,51 +388,41 @@ public class mod_pocketDim
|
||||
|
||||
|
||||
@PostInit
|
||||
public void PostInit(FMLPostInitializationEvent event)
|
||||
public void onPostInitialization(FMLPostInitializationEvent event)
|
||||
{
|
||||
ForgeChunkManager.setForcedChunkLoadingCallback(instance, new ChunkLoaderHelper());
|
||||
//Register loot chests
|
||||
DDLoot.registerInfo();
|
||||
}
|
||||
|
||||
@ServerStopping
|
||||
public void serverStopping(FMLServerStoppingEvent event)
|
||||
public void onServerStopping(FMLServerStoppingEvent event)
|
||||
{
|
||||
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)
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ServerStarting
|
||||
public void serverStarting(FMLServerStartingEvent event)
|
||||
public void onServerStarting(FMLServerStartingEvent event)
|
||||
{
|
||||
|
||||
//TODO- load dims with forced chunks on server startup here
|
||||
|
||||
CommandResetDungeons.instance().register(event);
|
||||
CommandCreateDungeonRift.instance().register(event);
|
||||
CommandDeleteAllLinks.instance().register(event);
|
||||
CommandDeleteDimensionData.instance().register(event);
|
||||
//CommandDeleteDimensionData.instance().register(event);
|
||||
CommandDeleteRifts.instance().register(event);
|
||||
CommandExportDungeon.instance().register(event);
|
||||
CommandPrintDimensionData.instance().register(event);
|
||||
CommandPruneDimensions.instance().register(event);
|
||||
//CommandPrintDimensionData.instance().register(event);
|
||||
//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 LinkData()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,225 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
|
||||
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;
|
||||
|
||||
LinkData sendingLink;
|
||||
|
||||
|
||||
public pocketTeleporter()
|
||||
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new portal near an entity.
|
||||
*/
|
||||
|
||||
public void placeInPortal(Entity par1Entity, WorldServer world, LinkData 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
269
StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java
Normal file
269
StevenDimDoors/mod_pocketDim/saving/DDSaveHandler.java
Normal file
@@ -0,0 +1,269 @@
|
||||
package StevenDimDoors.mod_pocketDim.saving;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonType;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||
import StevenDimDoors.mod_pocketDim.util.FileFilters;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
|
||||
public class DDSaveHandler
|
||||
{
|
||||
public static boolean loadAll()
|
||||
{
|
||||
// SenseiKiwi: Loading up our save data is not as simple as just reading files.
|
||||
// To properly restore dimensions, we need to make sure we always load
|
||||
// a dimension's parent and root before trying to load it. We'll use
|
||||
// topological sorting to determine the order in which to recreate the
|
||||
// dimension objects such that we respect those dependencies.
|
||||
// Links must be loaded after instantiating all the dimensions and must
|
||||
// be checked against our dimension blacklist.
|
||||
|
||||
// Don't surround this code with try-catch. Our mod should crash if an error
|
||||
// occurs at this level, since it could lead to some nasty problems.
|
||||
|
||||
String basePath = DimensionManager.getCurrentSaveRootDirectory() + "/DimensionalDoors/data/";
|
||||
File dataDirectory = new File(basePath);
|
||||
|
||||
// Check if the folder exists. If it doesn't, just return.
|
||||
if (!dataDirectory.exists())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Load the dimension blacklist
|
||||
// --insert code here--
|
||||
|
||||
// List any dimension data files and read each dimension
|
||||
DimDataProcessor reader = new DimDataProcessor();
|
||||
List<PackedDimData> packedDims = new ArrayList<PackedDimData>();
|
||||
FileFilter dataFileFilter = new FileFilters.RegexFileFilter("dim_-?\\d+\\.txt");
|
||||
|
||||
File[] dataFiles = dataDirectory.listFiles(dataFileFilter);
|
||||
for (File dataFile : dataFiles)
|
||||
{
|
||||
PackedDimData packedDim = readDimension(dataFile, reader);
|
||||
packedDims.add(packedDim);
|
||||
}
|
||||
|
||||
List<PackedLinkData> linksToUnpack = new ArrayList<PackedLinkData>();
|
||||
//get the grand list of all links to unpack
|
||||
for(PackedDimData packedDim : packedDims)
|
||||
{
|
||||
linksToUnpack.addAll(packedDim.Links);
|
||||
}
|
||||
|
||||
|
||||
return unpackDimData(packedDims)&&unpackLinkData(linksToUnpack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a list of packedDimData and rebuilds the DimData for it
|
||||
* @param packedDims
|
||||
* @return
|
||||
*/
|
||||
public static boolean unpackDimData(List<PackedDimData> packedDims)
|
||||
{
|
||||
List<PackedDimData> unpackedDims = new ArrayList<PackedDimData>();
|
||||
|
||||
|
||||
//Load roots
|
||||
for(PackedDimData packedDim : packedDims)
|
||||
{
|
||||
if(packedDim.ParentID==packedDim.ID)
|
||||
{
|
||||
PocketManager.registerPackedDimData(packedDim);
|
||||
unpackedDims.add(packedDim);
|
||||
}
|
||||
}
|
||||
packedDims.removeAll(unpackedDims);
|
||||
unpackedDims.clear();
|
||||
|
||||
//Load the pockets
|
||||
while(!packedDims.isEmpty())
|
||||
{
|
||||
for(PackedDimData packedDim : packedDims)
|
||||
{
|
||||
if(PocketManager.isRegisteredInternally(packedDim.ParentID))
|
||||
{
|
||||
PocketManager.registerPackedDimData(packedDim);
|
||||
unpackedDims.add(packedDim);
|
||||
}
|
||||
else
|
||||
{
|
||||
//break here gracefully
|
||||
}
|
||||
}
|
||||
packedDims.removeAll(unpackedDims);
|
||||
unpackedDims.clear();
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean unpackLinkData(List<PackedLinkData> linksToUnpack)
|
||||
{
|
||||
Point3D fakePoint = new Point3D(-1,-1,-1);
|
||||
List<PackedLinkData> unpackedLinks = new ArrayList<PackedLinkData>();
|
||||
/**
|
||||
* sort through the list, unpacking links that do not have parents.
|
||||
*/
|
||||
//TODO- what we have a loop of links?
|
||||
for(PackedLinkData packedLink : linksToUnpack)
|
||||
{
|
||||
if(packedLink.parent.equals(fakePoint))
|
||||
{
|
||||
NewDimData data = PocketManager.getDimensionData(packedLink.source.getDimension());
|
||||
DimLink link = data.createLink(packedLink.source, packedLink.tail.linkType, packedLink.orientation);
|
||||
Point4D destination = packedLink.tail.destination;
|
||||
if(destination!=null)
|
||||
{
|
||||
PocketManager.getDimensionData(destination.getDimension()).setDestination(link, destination.getX(),destination.getY(),destination.getZ());
|
||||
}
|
||||
unpackedLinks.add(packedLink);
|
||||
}
|
||||
}
|
||||
linksToUnpack.removeAll(unpackedLinks);
|
||||
|
||||
//unpack remaining children
|
||||
while(!linksToUnpack.isEmpty())
|
||||
{
|
||||
for(PackedLinkData packedLink : linksToUnpack)
|
||||
{
|
||||
NewDimData data = PocketManager.getDimensionData(packedLink.source.getDimension());
|
||||
if(data.getLink(packedLink.parent)!=null)
|
||||
{
|
||||
data.createChildLink(packedLink.source.getX(), packedLink.source.getY(), packedLink.source.getZ(), data.getLink(packedLink.parent));
|
||||
}
|
||||
unpackedLinks.add(packedLink);
|
||||
}
|
||||
linksToUnpack.removeAll(unpackedLinks);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private static PackedDimData readDimension(File dataFile, DimDataProcessor reader)
|
||||
{
|
||||
try
|
||||
{
|
||||
return reader.readFromFile(dataFile);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("Could not read dimension data from: " + dataFile.getAbsolutePath());
|
||||
System.err.println("The following error occurred:");
|
||||
printException(e, false);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean saveAll(Iterable<? extends IPackable<PackedDimData>> dimensions) throws IOException
|
||||
{
|
||||
// Create the data directory for our dimensions
|
||||
// Don't catch exceptions here. If we can't create this folder,
|
||||
// the mod should crash to let the user know early on.
|
||||
|
||||
String basePath = DimensionManager.getCurrentSaveRootDirectory() + "/DimensionalDoors/data/";
|
||||
File basePathFile = new File(basePath);
|
||||
Files.createParentDirs(basePathFile);
|
||||
basePathFile.mkdir();
|
||||
|
||||
FileFilter dataFileFilter = new FileFilters.RegexFileFilter("dim_-?\\d+\\.txt");
|
||||
|
||||
//TODO Deal with temp files correctly
|
||||
File[] dataFiles = basePathFile.listFiles(dataFileFilter);
|
||||
for (File dataFile : dataFiles)
|
||||
{
|
||||
dataFile.delete();
|
||||
}
|
||||
|
||||
|
||||
basePathFile = null;
|
||||
basePath += "dim_";
|
||||
|
||||
boolean succeeded = true;
|
||||
DimDataProcessor writer = new DimDataProcessor();
|
||||
for (IPackable<PackedDimData> dimension : dimensions)
|
||||
{
|
||||
succeeded &= writeDimension(dimension, writer, basePath);
|
||||
}
|
||||
return succeeded;
|
||||
}
|
||||
|
||||
private static boolean writeDimension(IPackable<PackedDimData> dimension, DimDataProcessor writer, String basePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
File tempFile = new File(basePath + (dimension.name() + ".tmp"));
|
||||
File saveFile = new File(basePath + (dimension.name() + ".txt"));
|
||||
writer.writeToFile(tempFile, dimension.pack());
|
||||
saveFile.delete();
|
||||
tempFile.renameTo(saveFile);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("Could not save data for dimension #" + dimension.name() + ". The following error occurred:");
|
||||
printException(e, true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void printException(Exception e, boolean verbose)
|
||||
{
|
||||
if (e.getCause() == null)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
else
|
||||
{
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println(e.getMessage());
|
||||
System.err.println("Caused by an underlying error:");
|
||||
if (verbose)
|
||||
{
|
||||
e.getCause().printStackTrace();
|
||||
}
|
||||
else
|
||||
{
|
||||
System.err.println(e.getCause().getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO - make this more robust
|
||||
public static DungeonData unpackDungeonData(PackedDungeonData packedDungeon)
|
||||
{
|
||||
DungeonPack pack;
|
||||
DungeonType type;
|
||||
|
||||
for(DungeonData data : DungeonHelper.instance().getRegisteredDungeons())
|
||||
{
|
||||
if(data.schematicName().equals(packedDungeon.SchematicName))
|
||||
{
|
||||
//return data;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
307
StevenDimDoors/mod_pocketDim/saving/DimDataProcessor.java
Normal file
307
StevenDimDoors/mod_pocketDim/saving/DimDataProcessor.java
Normal file
@@ -0,0 +1,307 @@
|
||||
package StevenDimDoors.mod_pocketDim.saving;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import scala.Char;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||
import StevenDimDoors.mod_pocketDim.util.BaseConfigurationProcessor;
|
||||
import StevenDimDoors.mod_pocketDim.util.ConfigurationProcessingException;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public class DimDataProcessor extends BaseConfigurationProcessor<PackedDimData>
|
||||
{
|
||||
@Override
|
||||
public PackedDimData readFromStream(InputStream inputStream)
|
||||
throws ConfigurationProcessingException
|
||||
{
|
||||
try
|
||||
{
|
||||
JsonReader reader = new JsonReader(new InputStreamReader(inputStream, "UTF-8"));
|
||||
PackedDimData data = this.createDImDataFromJson(reader);
|
||||
return data;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
throw new ConfigurationProcessingException("Could not read packedDimData");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(OutputStream outputStream, PackedDimData data)
|
||||
throws ConfigurationProcessingException
|
||||
{
|
||||
/** Print out dimData using the GSON built in serializer. I dont feel bad doing this because
|
||||
* 1- We can read it
|
||||
* 2- We are manually reading the data in.
|
||||
* 3- The error messages tell us exactly where its failing, so its easy to fix
|
||||
*/
|
||||
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
Gson gson = gsonBuilder.setPrettyPrinting().create();
|
||||
|
||||
try
|
||||
{
|
||||
outputStream.write(gson.toJson(data).getBytes("UTF-8"));
|
||||
outputStream.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// not sure if this is kosher, we need it to explode, but not by throwing the IO exception.
|
||||
throw new ConfigurationProcessingException("Incorrectly formatted save data");
|
||||
}
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
/**
|
||||
* Nightmare method that takes a JsonReader pointed at a serialized instance of PackedDimData
|
||||
* @param reader
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public PackedDimData createDImDataFromJson(JsonReader reader) throws IOException
|
||||
{
|
||||
int ID;
|
||||
boolean IsDungeon;
|
||||
boolean IsFilled;
|
||||
int Depth;
|
||||
int PackDepth;
|
||||
int ParentID;
|
||||
int RootID;
|
||||
PackedDungeonData Dungeon = null;
|
||||
Point3D Origin;
|
||||
int Orientation;
|
||||
List<Integer> ChildIDs;
|
||||
List<PackedLinkData> Links;
|
||||
List<PackedLinkTail> Tails = new ArrayList<PackedLinkTail>();
|
||||
|
||||
reader.beginObject();
|
||||
|
||||
reader.nextName();
|
||||
if(reader.nextLong()!=PackedDimData.SAVE_DATA_VERSION_ID)
|
||||
{
|
||||
throw new IOException("Save data version mismatch");
|
||||
}
|
||||
|
||||
reader.nextName();
|
||||
ID = reader.nextInt();
|
||||
|
||||
reader.nextName();
|
||||
IsDungeon = reader.nextBoolean();
|
||||
|
||||
reader.nextName();
|
||||
IsFilled = reader.nextBoolean();
|
||||
|
||||
reader.nextName();
|
||||
Depth = reader.nextInt();
|
||||
|
||||
reader.nextName();
|
||||
PackDepth = reader.nextInt();
|
||||
|
||||
reader.nextName();
|
||||
ParentID=reader.nextInt();
|
||||
|
||||
reader.nextName();
|
||||
RootID= reader.nextInt();
|
||||
|
||||
if(reader.nextName().equals("DungeonData"))
|
||||
{
|
||||
Dungeon = createDungeonDataFromJson(reader);
|
||||
reader.nextName();
|
||||
}
|
||||
|
||||
Origin = createPointFromJson(reader);
|
||||
|
||||
reader.nextName();
|
||||
Orientation = reader.nextInt();
|
||||
|
||||
reader.nextName();
|
||||
ChildIDs = this.createIntListFromJson(reader);
|
||||
|
||||
reader.nextName();
|
||||
Links = this.createLinksListFromJson(reader);
|
||||
|
||||
return new PackedDimData(ID, Depth, PackDepth, ParentID, RootID, Orientation, IsDungeon, IsFilled, Dungeon, Origin, ChildIDs, Links, Tails);
|
||||
}
|
||||
|
||||
private Point3D createPointFromJson(JsonReader reader) throws IOException
|
||||
{
|
||||
reader.beginObject();
|
||||
|
||||
reader.nextName();
|
||||
int x = reader.nextInt();
|
||||
|
||||
reader.nextName();
|
||||
int y = reader.nextInt();
|
||||
|
||||
reader.nextName();
|
||||
int z = reader.nextInt();
|
||||
|
||||
reader.endObject();
|
||||
|
||||
return new Point3D(x,y,z);
|
||||
}
|
||||
|
||||
private Point4D createPoint4DFromJson(JsonReader reader) throws IOException
|
||||
{
|
||||
reader.beginObject();
|
||||
|
||||
reader.nextName();
|
||||
int x = reader.nextInt();
|
||||
|
||||
reader.nextName();
|
||||
int y = reader.nextInt();
|
||||
|
||||
reader.nextName();
|
||||
int z = reader.nextInt();
|
||||
|
||||
reader.nextName();
|
||||
int dimension = reader.nextInt();
|
||||
|
||||
reader.endObject();
|
||||
|
||||
return new Point4D(x,y,z,dimension);
|
||||
}
|
||||
|
||||
private List<Integer> createIntListFromJson(JsonReader reader) throws IOException
|
||||
{
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
reader.beginArray();
|
||||
|
||||
while(reader.peek()!= JsonToken.END_ARRAY)
|
||||
{
|
||||
list.add(reader.nextInt());
|
||||
|
||||
}
|
||||
reader.endArray();
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<PackedLinkData> createLinksListFromJson(JsonReader reader) throws IOException
|
||||
{
|
||||
List<PackedLinkData> list = new ArrayList<PackedLinkData>();
|
||||
|
||||
reader.beginArray();
|
||||
|
||||
while(reader.peek()!= JsonToken.END_ARRAY)
|
||||
{
|
||||
list.add(createLinkDataFromJson(reader));
|
||||
}
|
||||
reader.endArray();
|
||||
return list;
|
||||
}
|
||||
|
||||
private PackedLinkData createLinkDataFromJson(JsonReader reader) throws IOException
|
||||
{
|
||||
Point4D source;
|
||||
Point3D parent;
|
||||
PackedLinkTail tail;
|
||||
int orientation;
|
||||
List<Point3D> children = new ArrayList<Point3D>();
|
||||
|
||||
reader.beginObject();
|
||||
|
||||
reader.nextName();
|
||||
source = this.createPoint4DFromJson(reader);
|
||||
|
||||
reader.nextName();
|
||||
parent = this.createPointFromJson(reader);
|
||||
|
||||
reader.nextName();
|
||||
tail = this.createLinkTailFromJson(reader);
|
||||
|
||||
reader.nextName();
|
||||
orientation = reader.nextInt();
|
||||
|
||||
reader.nextName();
|
||||
reader.beginArray();
|
||||
|
||||
while(reader.peek() != JsonToken.END_ARRAY)
|
||||
{
|
||||
children.add(this.createPointFromJson(reader));
|
||||
}
|
||||
reader.endArray();
|
||||
reader.endObject();
|
||||
|
||||
return new PackedLinkData(source, parent, tail, orientation, children);
|
||||
}
|
||||
private PackedDungeonData createDungeonDataFromJson(JsonReader reader) throws IOException
|
||||
{
|
||||
int Weight;
|
||||
boolean IsOpen;
|
||||
boolean IsInternal;
|
||||
String SchematicPath;
|
||||
String SchematicName;
|
||||
String DungeonTypeName;
|
||||
String DungeonPackName;
|
||||
|
||||
reader.beginObject();
|
||||
JsonToken test = reader.peek();
|
||||
|
||||
if(reader.peek() == JsonToken.END_OBJECT)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
reader.nextName();
|
||||
Weight=reader.nextInt();
|
||||
|
||||
reader.nextName();
|
||||
IsOpen=reader.nextBoolean();
|
||||
|
||||
reader.nextName();
|
||||
IsInternal=reader.nextBoolean();
|
||||
|
||||
reader.nextName();
|
||||
SchematicPath=reader.nextString();
|
||||
|
||||
reader.nextName();
|
||||
SchematicName=reader.nextString();
|
||||
|
||||
reader.nextName();
|
||||
DungeonTypeName=reader.nextString();
|
||||
|
||||
reader.nextName();
|
||||
DungeonPackName=reader.nextString();
|
||||
|
||||
reader.endObject();
|
||||
return new PackedDungeonData(Weight, IsOpen, IsInternal, SchematicPath, SchematicName, DungeonTypeName, DungeonPackName);
|
||||
}
|
||||
private PackedLinkTail createLinkTailFromJson(JsonReader reader) throws IOException
|
||||
{
|
||||
Point4D destination=null;
|
||||
int linkType;
|
||||
reader.beginObject();
|
||||
reader.nextName();
|
||||
|
||||
JsonToken test =reader.peek();
|
||||
if(reader.peek()==JsonToken.BEGIN_OBJECT)
|
||||
{
|
||||
destination = this.createPoint4DFromJson(reader);
|
||||
reader.nextName();
|
||||
}
|
||||
|
||||
linkType = reader.nextInt();
|
||||
reader.endObject();
|
||||
|
||||
return new PackedLinkTail(destination, linkType);
|
||||
}
|
||||
}
|
||||
7
StevenDimDoors/mod_pocketDim/saving/IPackable.java
Normal file
7
StevenDimDoors/mod_pocketDim/saving/IPackable.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package StevenDimDoors.mod_pocketDim.saving;
|
||||
|
||||
public interface IPackable<T>
|
||||
{
|
||||
public String name();
|
||||
public T pack();
|
||||
}
|
||||
73
StevenDimDoors/mod_pocketDim/saving/OldSaveImporter.java
Normal file
73
StevenDimDoors/mod_pocketDim/saving/OldSaveImporter.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package StevenDimDoors.mod_pocketDim.saving;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.ObjectSaveInputStream;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public class OldSaveImporter
|
||||
{
|
||||
public static void importOldSave(File file) throws IOException, ClassNotFoundException
|
||||
{
|
||||
FileInputStream saveFile = new FileInputStream(file);
|
||||
ObjectSaveInputStream save = new ObjectSaveInputStream(saveFile);
|
||||
HashMap comboSave =((HashMap) save.readObject());
|
||||
save.close();
|
||||
|
||||
List<PackedLinkData> allPackedLinks = new ArrayList<PackedLinkData>();
|
||||
List<PackedDimData> newPackedDimData = new ArrayList<PackedDimData>();
|
||||
|
||||
HashMap<Integer, DimData> dimMap;
|
||||
|
||||
try
|
||||
{
|
||||
dimMap = (HashMap<Integer, DimData>) comboSave.get("dimList");
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
System.out.println("Could not import old save data");
|
||||
return;
|
||||
}
|
||||
|
||||
for(DimData data : dimMap.values())
|
||||
{
|
||||
List<PackedLinkData> newPackedLinkData = new ArrayList<PackedLinkData>();
|
||||
List<Integer> childDims = new ArrayList<Integer>();
|
||||
|
||||
for(LinkData link : data.getLinksInDim())
|
||||
{
|
||||
Point4D source = new Point4D(link.locXCoord,link.locYCoord,link.locZCoord,link.locDimID);
|
||||
Point4D destintion = new Point4D(link.destXCoord,link.destYCoord,link.destZCoord,link.destDimID);
|
||||
PackedLinkTail tail = new PackedLinkTail(destintion, link.linkOrientation);
|
||||
List<Point3D> children = new ArrayList<Point3D>();
|
||||
|
||||
PackedLinkData newPackedLink = new PackedLinkData(source, new Point3D(-1,-1,-1), tail, link.linkOrientation,children);
|
||||
|
||||
newPackedLinkData.add(newPackedLink);
|
||||
allPackedLinks.add(newPackedLink);
|
||||
|
||||
}
|
||||
|
||||
PackedDimData dim = new PackedDimData(data.dimID, data.depth, data.depth, data.exitDimLink.locDimID, data.exitDimLink.locDimID, 0, data.dungeonGenerator!=null, data.hasBeenFilled, null, new Point3D(0,64,0), childDims, newPackedLinkData, null);
|
||||
newPackedDimData.add(dim);
|
||||
|
||||
DDSaveHandler.unpackDimData(newPackedDimData);
|
||||
DDSaveHandler.unpackLinkData(allPackedLinks);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
46
StevenDimDoors/mod_pocketDim/saving/PackedDimData.java
Normal file
46
StevenDimDoors/mod_pocketDim/saving/PackedDimData.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package StevenDimDoors.mod_pocketDim.saving;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||
|
||||
public class PackedDimData
|
||||
{
|
||||
// These fields will be public since this is a simple data container
|
||||
public final static long SAVE_DATA_VERSION_ID = 982405775L;
|
||||
public final long SAVE_DATA_VERSION_ID_INSTANCE = SAVE_DATA_VERSION_ID;
|
||||
public final int ID;
|
||||
public final boolean IsDungeon;
|
||||
public final boolean IsFilled;
|
||||
public final int Depth;
|
||||
public final int PackDepth;
|
||||
public final int ParentID;
|
||||
public final int RootID;
|
||||
public final PackedDungeonData DungeonData;
|
||||
public final Point3D Origin;
|
||||
public final int Orientation;
|
||||
public final List<Integer> ChildIDs;
|
||||
public final List<PackedLinkData> Links;
|
||||
public final List<PackedLinkTail> Tails;
|
||||
|
||||
// FIXME Missing dungeon data, not sure how to include it
|
||||
|
||||
public PackedDimData(int id, int depth, int packDepth, int parentID, int rootID, int orientation,
|
||||
boolean isDungeon, boolean isFilled,PackedDungeonData dungeonData, Point3D origin, List<Integer> childIDs, List<PackedLinkData> links,
|
||||
List<PackedLinkTail> tails)
|
||||
{
|
||||
ID = id;
|
||||
Depth = depth;
|
||||
PackDepth = packDepth;
|
||||
ParentID = parentID;
|
||||
RootID = rootID;
|
||||
Orientation = orientation;
|
||||
IsDungeon = isDungeon;
|
||||
IsFilled = isFilled;
|
||||
DungeonData = dungeonData;
|
||||
Origin = origin;
|
||||
ChildIDs = childIDs;
|
||||
Links = links;
|
||||
Tails = tails;
|
||||
}
|
||||
}
|
||||
29
StevenDimDoors/mod_pocketDim/saving/PackedDungeonData.java
Normal file
29
StevenDimDoors/mod_pocketDim/saving/PackedDungeonData.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package StevenDimDoors.mod_pocketDim.saving;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonType;
|
||||
|
||||
public class PackedDungeonData
|
||||
{
|
||||
|
||||
public final int Weight;
|
||||
public final boolean IsOpen;
|
||||
public final boolean IsInternal;
|
||||
public final String SchematicPath;
|
||||
public final String SchematicName;
|
||||
public final String DungeonTypeName;
|
||||
public final String DungeonPackName;
|
||||
|
||||
public PackedDungeonData(int weight, boolean isOpen, boolean isInternal, String schematicPath, String schematicName, String dungeonTypeName, String dungeonPackName)
|
||||
{
|
||||
this.Weight= weight;
|
||||
this.IsOpen=isOpen;
|
||||
this.IsInternal=isInternal;
|
||||
this.SchematicName=schematicName;
|
||||
this.SchematicPath=schematicPath;
|
||||
this.DungeonTypeName=dungeonTypeName;
|
||||
this.DungeonPackName=dungeonPackName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
25
StevenDimDoors/mod_pocketDim/saving/PackedLinkData.java
Normal file
25
StevenDimDoors/mod_pocketDim/saving/PackedLinkData.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package StevenDimDoors.mod_pocketDim.saving;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public class PackedLinkData
|
||||
{
|
||||
public final Point4D source;
|
||||
public final Point3D parent;
|
||||
public final PackedLinkTail tail;
|
||||
public final int orientation;
|
||||
public final List<Point3D> children;
|
||||
|
||||
public PackedLinkData(Point4D source, Point3D parent, PackedLinkTail tail, int orientation, List<Point3D> children)
|
||||
{
|
||||
this.source=source;
|
||||
this.parent=parent;
|
||||
this.tail=tail;
|
||||
this.orientation=orientation;
|
||||
this.children=children;
|
||||
}
|
||||
}
|
||||
16
StevenDimDoors/mod_pocketDim/saving/PackedLinkTail.java
Normal file
16
StevenDimDoors/mod_pocketDim/saving/PackedLinkTail.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package StevenDimDoors.mod_pocketDim.saving;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public class PackedLinkTail
|
||||
{
|
||||
public final Point4D destination;
|
||||
public final int linkType;
|
||||
|
||||
public PackedLinkTail(Point4D destination, int linkType)
|
||||
{
|
||||
this.destination=destination;
|
||||
this.linkType=linkType;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import net.minecraft.block.BlockRedstoneRepeater;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.dimDoor;
|
||||
|
||||
public class BlockRotator
|
||||
{
|
||||
@@ -64,8 +63,8 @@ public class BlockRotator
|
||||
hasOrientations[Block.railActivator.blockID] = true;
|
||||
hasOrientations[Block.rail.blockID] = true;
|
||||
|
||||
hasOrientations[mod_pocketDim.dimDoor.blockID] = true;
|
||||
hasOrientations[mod_pocketDim.ExitDoor.blockID] = true;
|
||||
hasOrientations[mod_pocketDim.dimensionalDoor.blockID] = true;
|
||||
hasOrientations[mod_pocketDim.warpDoor.blockID] = true;
|
||||
|
||||
}
|
||||
|
||||
@@ -379,7 +378,7 @@ public class BlockRotator
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(Block.blocksList[blockID] instanceof BlockRedstoneRepeater || Block.blocksList[blockID] instanceof BlockDoor || Block.blocksList[blockID] instanceof dimDoor || blockID== Block.tripWireSource.blockID || Block.blocksList[blockID] instanceof BlockComparator)
|
||||
else if (Block.blocksList[blockID] instanceof BlockRedstoneRepeater || Block.blocksList[blockID] instanceof BlockDoor || blockID== Block.tripWireSource.blockID || Block.blocksList[blockID] instanceof BlockComparator)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ package StevenDimDoors.mod_pocketDim.ticking;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
|
||||
@@ -43,9 +43,9 @@ public class CommonTickHandler implements ITickHandler, IRegularTickSender
|
||||
|
||||
//TODO: Stuck this in here because it's already rather hackish.
|
||||
//We should standardize this as an IRegularTickReceiver in the future. ~SenseiKiwi
|
||||
if (mod_pocketDim.teleTimer > 0)
|
||||
if (DDTeleporter.cooldown > 0)
|
||||
{
|
||||
mod_pocketDim.teleTimer--;
|
||||
DDTeleporter.cooldown--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -25,16 +24,27 @@ public class LimboDecay implements IRegularTickReceiver {
|
||||
//Provides a reversed list of the block IDs that blocks cycle through during decay.
|
||||
private final int[] decaySequence;
|
||||
|
||||
private Random random;
|
||||
private DDProperties properties = null;
|
||||
private final Random random;
|
||||
private final DDProperties properties;
|
||||
private final int[] blocksImmuneToDecay;
|
||||
|
||||
public LimboDecay(IRegularTickSender tickSender, DDProperties properties)
|
||||
{
|
||||
decaySequence = new int[] {
|
||||
properties.LimboBlockID,
|
||||
Block.gravel.blockID,
|
||||
Block.cobblestone.blockID,
|
||||
Block.stone.blockID
|
||||
properties.LimboBlockID,
|
||||
Block.gravel.blockID,
|
||||
Block.cobblestone.blockID,
|
||||
Block.stone.blockID
|
||||
};
|
||||
|
||||
blocksImmuneToDecay = new int[] {
|
||||
properties.LimboBlockID,
|
||||
properties.PermaFabricBlockID,
|
||||
properties.TransientDoorID,
|
||||
properties.DimensionalDoorID,
|
||||
properties.WarpDoorID,
|
||||
properties.RiftBlockID,
|
||||
properties.UnstableDoorID
|
||||
};
|
||||
|
||||
this.properties = properties;
|
||||
@@ -81,7 +91,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)
|
||||
{
|
||||
@@ -152,12 +162,22 @@ public class LimboDecay implements IRegularTickReceiver {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a block can decay. We will not decay air, Unraveled Fabric, Eternal Fabric, or containers.
|
||||
* Checks if a block can decay. We will not decay air, certain DD blocks, or containers.
|
||||
*/
|
||||
private boolean canDecayBlock(int blockID)
|
||||
{
|
||||
if (blockID == 0 || blockID == properties.LimboBlockID || blockID == properties.PermaFabricBlockID)
|
||||
if (blockID == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int k = 0; k < blocksImmuneToDecay.length; k++)
|
||||
{
|
||||
if (blockID == blocksImmuneToDecay[k])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Block block = Block.blocksList[blockID];
|
||||
return (block == null || !(block instanceof BlockContainer));
|
||||
@@ -1,26 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.ticking;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
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.helpers.yCoordHelper;
|
||||
import StevenDimDoors.mod_pocketDim.util.ChunkLocation;
|
||||
|
||||
public class LimboGatewayGenerator implements IRegularTickReceiver
|
||||
{
|
||||
|
||||
@Override
|
||||
public void notifyTick()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,12 +9,14 @@ import net.minecraft.entity.monster.IMob;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import StevenDimDoors.mod_pocketDim.world.LimboProvider;
|
||||
import StevenDimDoors.mod_pocketDim.world.PocketProvider;
|
||||
|
||||
@@ -24,7 +26,7 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
float soundTime = 0;
|
||||
int aggro = 0;
|
||||
byte textureState = 0;
|
||||
|
||||
|
||||
float scaleFactor = 0;
|
||||
int aggroMax;
|
||||
int destX=0;
|
||||
@@ -86,16 +88,14 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
@Override
|
||||
public void onEntityUpdate()
|
||||
{
|
||||
if(!(this.worldObj.provider instanceof LimboProvider ||this.worldObj.provider instanceof PocketProvider))
|
||||
if (!(this.worldObj.provider instanceof LimboProvider || this.worldObj.provider instanceof PocketProvider))
|
||||
{
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
|
||||
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
|
||||
|
||||
this.texture="/mods/DimDoors/textures/mobs/Monolith"+b0+".png";
|
||||
|
||||
|
||||
super.onEntityUpdate();
|
||||
|
||||
if (this.isEntityAlive() && this.isEntityInsideOpaqueBlock())
|
||||
@@ -103,12 +103,9 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
EntityPlayer entityPlayer = this.worldObj.getClosestPlayerToEntity(this, 30);
|
||||
|
||||
if(entityPlayer != null)
|
||||
if (entityPlayer != null)
|
||||
{
|
||||
if(this.soundTime<=0)
|
||||
{
|
||||
@@ -116,83 +113,54 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
this.soundTime=100;
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.faceEntity(entityPlayer, 1, 1);
|
||||
|
||||
if(shouldAttackPlayer(entityPlayer))
|
||||
if (shouldAttackPlayer(entityPlayer))
|
||||
{
|
||||
{
|
||||
|
||||
}
|
||||
if(aggro<470)
|
||||
if (aggro<470)
|
||||
{
|
||||
if(rand.nextInt(11)>this.textureState||this.aggro>=300||rand.nextInt(13)>this.textureState&&this.aggroMax>this.aggro)
|
||||
if (rand.nextInt(11)>this.textureState||this.aggro>=300||rand.nextInt(13)>this.textureState&&this.aggroMax>this.aggro)
|
||||
{
|
||||
aggro++;
|
||||
}
|
||||
|
||||
|
||||
if(this.worldObj.provider instanceof PocketProvider||this.worldObj.getClosestPlayerToEntity(this, 5)!=null)
|
||||
if (this.worldObj.provider instanceof PocketProvider||this.worldObj.getClosestPlayerToEntity(this, 5)!=null)
|
||||
{
|
||||
|
||||
aggro++;
|
||||
aggro++;
|
||||
|
||||
if(rand.nextBoolean())
|
||||
if (rand.nextBoolean())
|
||||
{
|
||||
aggro++;
|
||||
}
|
||||
|
||||
}
|
||||
if(aggro>430&&this.soundTime<100)
|
||||
if (aggro>430&&this.soundTime<100)
|
||||
{
|
||||
//this.worldObj.playSoundAtEntity(entityPlayer,"mods.DimDoors.sfx.tearing",2, 1);
|
||||
this.worldObj.playSoundEffect(entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ,"mods.DimDoors.sfx.tearing",2F, 1F);
|
||||
|
||||
this.soundTime=100;
|
||||
|
||||
}
|
||||
if(aggro>445&&this.soundTime<200)
|
||||
if (aggro>445&&this.soundTime<200)
|
||||
{
|
||||
//this.worldObj.playSoundAtEntity(entityPlayer,"mods.DimDoors.sfx.tearing",5, 1);
|
||||
this.worldObj.playSoundEffect(entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ,"mods.DimDoors.sfx.tearing",5F, 1F);
|
||||
|
||||
this.soundTime=200;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if(!this.worldObj.isRemote&&!entityPlayer.capabilities.isCreativeMode)
|
||||
else if (!this.worldObj.isRemote && !entityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
LinkData link = new LinkData(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);
|
||||
this.aggro=0;
|
||||
|
||||
entityPlayer.worldObj.playSoundAtEntity(entityPlayer,"mods.DimDoors.sfx.crack",13, 1);
|
||||
ChunkCoordinates coords = LimboProvider.getLimboSkySpawn(entityPlayer.worldObj.rand);
|
||||
Point4D destination = new Point4D((int) (coords.posX+entityPlayer.posX), coords.posY, (int) (coords.posZ+entityPlayer.posZ ), mod_pocketDim.properties.LimboDimensionID);
|
||||
DDTeleporter.teleportEntity(entityPlayer, destination, false);
|
||||
|
||||
|
||||
|
||||
|
||||
this.aggro = 0;
|
||||
entityPlayer.worldObj.playSoundAtEntity(entityPlayer,"mods.DimDoors.sfx.crack",13, 1);
|
||||
}
|
||||
if(!(this.worldObj.provider instanceof LimboProvider || this.worldObj.getClosestPlayerToEntity(this, 5)!=null)||this.aggro>300)
|
||||
if (!(this.worldObj.provider instanceof LimboProvider || this.worldObj.getClosestPlayerToEntity(this, 5) != null) || this.aggro > 300)
|
||||
{
|
||||
|
||||
for (int i = 0; i < -1+this.textureState/2; ++i)
|
||||
{
|
||||
entityPlayer.worldObj.spawnParticle("portal", entityPlayer.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, entityPlayer.posY + this.rand.nextDouble() * (double)entityPlayer.height - 0.75D, entityPlayer.posZ + (this.rand.nextDouble() - 0.5D) * (double)entityPlayer.width, (this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(), (this.rand.nextDouble() - 0.5D) * 2.0D);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -205,12 +173,9 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if(aggro>0)
|
||||
{
|
||||
aggro--;
|
||||
@@ -221,44 +186,23 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
}
|
||||
}
|
||||
}
|
||||
if(soundTime>=0)
|
||||
if (soundTime>=0)
|
||||
{
|
||||
soundTime--;
|
||||
}
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.textureState= (byte) (this.aggro/25);
|
||||
if(!this.worldObj.isRemote)
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
|
||||
this.dataWatcher.updateObject(16, Byte.valueOf(this.textureState));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private boolean shouldAttackPlayer(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return par1EntityPlayer.canEntityBeSeen(this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private boolean isCourseTraversable(double par1, double par3, double par5, double par7)
|
||||
{
|
||||
double d4 = (par1 - this.posX) / par7;
|
||||
@@ -275,9 +219,9 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
|
||||
{
|
||||
if(!(par1DamageSource==DamageSource.inWall))
|
||||
@@ -286,6 +230,7 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void faceEntity(Entity par1Entity, float par2, float par3)
|
||||
{
|
||||
double d0 = par1Entity.posX - this.posX;
|
||||
@@ -311,7 +256,6 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
this.rotationYaw = f2;
|
||||
this.rotationYawHead=f2;
|
||||
this.renderYawOffset=this.rotationYaw;
|
||||
|
||||
}
|
||||
|
||||
private float updateRotation(float par1, float par2, float par3)
|
||||
@@ -336,8 +280,6 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeEntityToNBT(par1NBTTagCompound);
|
||||
@@ -346,9 +288,8 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
par1NBTTagCompound.setInteger("aggroMax", this.aggroMax);
|
||||
par1NBTTagCompound.setByte("textureState", this.textureState);
|
||||
par1NBTTagCompound.setFloat("scaleFactor", this.scaleFactor);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
@@ -358,31 +299,27 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
this.aggroMax = par1NBTTagCompound.getInteger("aggroMax");
|
||||
this.textureState = par1NBTTagCompound.getByte("textureState");
|
||||
this.scaleFactor = par1NBTTagCompound.getFloat("scaleFactor");
|
||||
|
||||
}
|
||||
public boolean getCanSpawnHere()
|
||||
{
|
||||
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this,AxisAlignedBB.getBoundingBox( this.posX-15, posY-4, this.posZ-15, this.posX+15, this.posY+15, this.posZ+15));
|
||||
|
||||
if(this.worldObj.provider.dimensionId==DDProperties.instance().LimboDimensionID)
|
||||
{
|
||||
if(list.size()>0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
else if(this.worldObj.provider instanceof PocketProvider)
|
||||
{
|
||||
if(list.size()>5||this.worldObj.canBlockSeeTheSky((int)this.posX, (int)this.posY, (int)this.posZ))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return this.worldObj.checkNoEntityCollision(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox);
|
||||
}
|
||||
|
||||
public boolean getCanSpawnHere()
|
||||
{
|
||||
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, AxisAlignedBB.getBoundingBox( this.posX-15, posY-4, this.posZ-15, this.posX+15, this.posY+15, this.posZ+15));
|
||||
|
||||
if(this.worldObj.provider.dimensionId==DDProperties.instance().LimboDimensionID)
|
||||
{
|
||||
if(list.size()>0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if(this.worldObj.provider instanceof PocketProvider)
|
||||
{
|
||||
if(list.size()>5||this.worldObj.canBlockSeeTheSky((int)this.posX, (int)this.posY, (int)this.posZ))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return this.worldObj.checkNoEntityCollision(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
NewDimData dimension = PocketManager.getDimensionData(dimensionID);
|
||||
World pocket = DimensionManager.getWorld(dimensionID);
|
||||
|
||||
if (pocket == null ||
|
||||
dimension == null ||
|
||||
dimension.dungeon() == null ||
|
||||
dimension.dungeon().isOpen())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int sanity = 0;
|
||||
int blockID = 0;
|
||||
boolean didSpawn = false;
|
||||
|
||||
if (pocket == null ||
|
||||
dimData == null ||
|
||||
dimData.dungeonGenerator == null ||
|
||||
dimData.dungeonGenerator.isOpen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//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());
|
||||
@@ -192,7 +194,7 @@ public class MonolithSpawner implements IRegularTickReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isMobSpawningAllowed()
|
||||
public static boolean isMobSpawningAllowed()
|
||||
{
|
||||
//This function is used to retrieve the value of doMobSpawning. The code is the same
|
||||
//as the code used by Minecraft. Jaitsu requested this to make testing easier. ~SenseiKiwi
|
||||
|
||||
@@ -1,75 +1,54 @@
|
||||
package StevenDimDoors.mod_pocketDim.ticking;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.TileEntityRift;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public class RiftRegenerator implements IRegularTickReceiver {
|
||||
|
||||
private static final int RIFT_REGENERATION_INTERVAL = 100; //Regenerate random rifts every 100 ticks
|
||||
|
||||
private DDProperties properties;
|
||||
private static final int RIFT_REGENERATION_INTERVAL = 200; //Regenerate random rifts every 200 ticks
|
||||
private static final int RIFTS_REGENERATED_PER_DIMENSION = 5;
|
||||
|
||||
public RiftRegenerator(IRegularTickSender sender, DDProperties properties)
|
||||
public RiftRegenerator(IRegularTickSender sender)
|
||||
{
|
||||
sender.registerForTicking(this, RIFT_REGENERATION_INTERVAL, false);
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@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
|
||||
|
||||
int i = 0;
|
||||
|
||||
while (i < 15 && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
|
||||
//Regenerate rifts that have been replaced (not permanently removed) by players
|
||||
DDProperties properties = DDProperties.instance();
|
||||
|
||||
for (NewDimData dimension : PocketManager.getDimensions())
|
||||
{
|
||||
if (dimension.linkCount() > 0)
|
||||
{
|
||||
i++;
|
||||
LinkData link;
|
||||
|
||||
//actually gets the random rift based on the size of the list
|
||||
link = (LinkData) 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());
|
||||
}
|
||||
if (rift != null)
|
||||
{
|
||||
rift.hasGrownRifts = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
World world = DimensionManager.getWorld(dimension.id());
|
||||
|
||||
if (world != null)
|
||||
{
|
||||
for (int count = 0; count < RIFTS_REGENERATED_PER_DIMENSION; count++)
|
||||
{
|
||||
DimLink link = dimension.getRandomLink();
|
||||
Point4D source = link.source();
|
||||
if (!mod_pocketDim.blockRift.isBlockImmune(world, source.getX(), source.getY(), source.getZ())&& world.getChunkProvider().chunkExists(source.getX() >> 4, source.getZ() >> 4))
|
||||
{
|
||||
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,10 @@
|
||||
package StevenDimDoors.mod_pocketDim;
|
||||
package StevenDimDoors.mod_pocketDim.tileentities;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileEntityDimDoor extends TileEntity
|
||||
|
||||
@@ -10,6 +13,8 @@ public class TileEntityDimDoor extends TileEntity
|
||||
public int orientation;
|
||||
public boolean hasExit;
|
||||
public boolean isDungeonChainLink;
|
||||
public boolean hasGennedPair=false;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -41,6 +46,8 @@ public class TileEntityDimDoor extends TileEntity
|
||||
|
||||
this.isDungeonChainLink = nbt.getBoolean("isDungeonChainLink");
|
||||
|
||||
this.hasGennedPair = nbt.getBoolean("hasGennedPair");
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -65,6 +72,7 @@ public class TileEntityDimDoor extends TileEntity
|
||||
|
||||
nbt.setBoolean("isDungeonChainLink", isDungeonChainLink);
|
||||
|
||||
|
||||
nbt.setBoolean("hasGennedPair", hasGennedPair);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package StevenDimDoors.mod_pocketDim.tileentities;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.IChunkLoader;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.world.PocketBuilder;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.ChunkCoordIntPair;
|
||||
import net.minecraftforge.common.ForgeChunkManager;
|
||||
import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
||||
import net.minecraftforge.common.ForgeChunkManager.Type;
|
||||
|
||||
public class TileEntityDimDoorGold extends TileEntityDimDoor implements IChunkLoader
|
||||
{
|
||||
|
||||
private Ticket chunkTicket;
|
||||
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void updateEntity()
|
||||
{
|
||||
if(PocketManager.getDimensionData(this.worldObj)!=null&&PocketManager.getDimensionData(this.worldObj).isPocketDimension()&&!this.worldObj.isRemote)
|
||||
{
|
||||
if(this.chunkTicket==null)
|
||||
{
|
||||
chunkTicket = ForgeChunkManager.requestTicket(mod_pocketDim.instance, worldObj, Type.NORMAL);
|
||||
}
|
||||
|
||||
chunkTicket.getModData().setInteger("goldDimDoorX", xCoord);
|
||||
chunkTicket.getModData().setInteger("goldDimDoorY", yCoord);
|
||||
chunkTicket.getModData().setInteger("goldDimDoorZ", zCoord);
|
||||
ForgeChunkManager.forceChunk(chunkTicket, new ChunkCoordIntPair(xCoord >> 4, zCoord >> 4));
|
||||
forceChunkLoading(chunkTicket,this.xCoord,this.zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
public void forceChunkLoading(Ticket chunkTicket,int x,int z)
|
||||
{
|
||||
if(PocketManager.getDimensionData(chunkTicket.world)==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(!PocketManager.getDimensionData(chunkTicket.world).isPocketDimension())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(int chunks = (PocketBuilder.DEFAULT_POCKET_SIZE/16)+1;chunks>0;chunks--)
|
||||
{
|
||||
ForgeChunkManager.forceChunk(chunkTicket, new ChunkCoordIntPair((xCoord >> 4)+chunks, (zCoord >> 4)+chunks));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
ForgeChunkManager.releaseTicket(chunkTicket);
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
int i = nbt.getInteger(("Size"));
|
||||
|
||||
try
|
||||
{
|
||||
this.openOrClosed = nbt.getBoolean("openOrClosed");
|
||||
|
||||
this.orientation = nbt.getInteger("orientation");
|
||||
|
||||
this.hasExit = nbt.getBoolean("hasExit");
|
||||
|
||||
this.isDungeonChainLink = nbt.getBoolean("isDungeonChainLink");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
int i = 0;
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setBoolean("openOrClosed", this.openOrClosed);
|
||||
|
||||
nbt.setBoolean("hasExit", this.hasExit);
|
||||
|
||||
nbt.setInteger("orientation", this.orientation);
|
||||
|
||||
nbt.setBoolean("isDungeonChainLink", isDungeonChainLink);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
362
StevenDimDoors/mod_pocketDim/tileentities/TileEntityRift.java
Normal file
362
StevenDimDoors/mod_pocketDim/tileentities/TileEntityRift.java
Normal file
@@ -0,0 +1,362 @@
|
||||
package StevenDimDoors.mod_pocketDim.tileentities;
|
||||
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.DataWatcher;
|
||||
import net.minecraft.entity.Entity;
|
||||
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.Packet132TileEntityData;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
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 isNearRift=false;
|
||||
private int count=200;
|
||||
private int count2 = 0;
|
||||
public int age = 0;
|
||||
|
||||
public HashMap<Integer, double[]> renderingCenters = new HashMap<Integer, double[]>();
|
||||
public DimLink nearestRiftData;
|
||||
public int spawnedEndermenID=0;
|
||||
DataWatcher watcher = new DataWatcher();
|
||||
|
||||
public void updateEntity()
|
||||
{
|
||||
//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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
this.calculateNextRenderQuad(age, rand);
|
||||
}
|
||||
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 (!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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void spawnEndermen()
|
||||
{
|
||||
if (worldObj.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NewDimData dimension = PocketManager.getDimensionData(worldObj);
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
//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));
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
rift.shouldClose = true;
|
||||
rift.onInventoryChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
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 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;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.xOffset=0;
|
||||
this.yOffset=0;
|
||||
this.xOffset=0;
|
||||
}
|
||||
this.onInventoryChanged();
|
||||
}
|
||||
|
||||
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-(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)
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(worldObj);
|
||||
DimLink link = dimension.getLink(xCoord, yCoord, zCoord);
|
||||
if (link != null)
|
||||
{
|
||||
if (!this.hasGrownRifts && random.nextInt(3) == 0)
|
||||
{
|
||||
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())
|
||||
{
|
||||
coords[0] = fl*1.5;
|
||||
coords[1] = rand.nextGaussian()/5;
|
||||
coords[2] = 0;
|
||||
coords[3] = 1;
|
||||
}
|
||||
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))
|
||||
{
|
||||
if(this.renderingCenters.get(iteration-1)[3]==0)
|
||||
{
|
||||
coords[0]=noise/2+this.renderingCenters.get(iteration-1)[0];
|
||||
coords[1]=noise/2+this.renderingCenters.get(iteration-1)[1];
|
||||
coords[2]= this.renderingCenters.get(iteration-1)[2]+fl;
|
||||
coords[3] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
coords[0]=this.renderingCenters.get(iteration-1)[0]+fl;
|
||||
coords[1]=noise/2+this.renderingCenters.get(iteration-1)[1];
|
||||
coords[2]=noise/2+this.renderingCenters.get(iteration-1)[2];
|
||||
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);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user