finished networking changes for locks
This commit is contained in:
parent
ef860e295e
commit
3fcc55b5e1
39 changed files with 566 additions and 350 deletions
|
@ -1,11 +1,14 @@
|
||||||
package StevenDimDoors.mod_pocketDim;
|
package StevenDimDoors.mod_pocketDim;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import StevenDimDoors.mod_pocketDim.blocks.BaseDimDoor;
|
||||||
|
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.nbt.CompressedStreamTools;
|
import net.minecraft.nbt.CompressedStreamTools;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
import cpw.mods.fml.common.network.IGuiHandler;
|
import cpw.mods.fml.common.network.IGuiHandler;
|
||||||
|
@ -130,6 +133,20 @@ public class CommonProxy implements IGuiHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public void updateDoorTE(BaseDimDoor door, World world, int x, int y, int z)
|
||||||
|
{
|
||||||
|
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||||
|
if (tile instanceof TileEntityDimDoor)
|
||||||
|
{
|
||||||
|
int metadata = world.getBlockMetadata(x, y, z);
|
||||||
|
TileEntityDimDoor dimTile = (TileEntityDimDoor) tile;
|
||||||
|
dimTile.openOrClosed = door.isDoorOnRift(world, x, y, z)&&door.isUpperDoorBlock(metadata);
|
||||||
|
dimTile.orientation = door.getFullMetadata(world, x, y, z) & 7;
|
||||||
|
dimTile.lockStatus = door.getLockStatus(world, x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package StevenDimDoors.mod_pocketDim;
|
package StevenDimDoors.mod_pocketDim;
|
||||||
|
|
||||||
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.DDLock;
|
||||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||||
import StevenDimDoors.mod_pocketDim.items.ItemDDKey;
|
import StevenDimDoors.mod_pocketDim.items.ItemDDKey;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -129,7 +130,7 @@ public class CraftingManager implements ICraftingHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
keyItem.addDoorToKey(topKey, bottomKey);
|
DDLock.addKeys(bottomKey, DDLock.getKeys(topKey));
|
||||||
item.setTagCompound(bottomKey.getTagCompound());
|
item.setTagCompound(bottomKey.getTagCompound());
|
||||||
player.inventory.addItemStackToInventory(topKey);
|
player.inventory.addItemStackToInventory(topKey);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,9 @@ public class EventHookContainer
|
||||||
@ForgeSubscribe
|
@ForgeSubscribe
|
||||||
public void onSoundLoad(SoundLoadEvent event)
|
public void onSoundLoad(SoundLoadEvent event)
|
||||||
{
|
{
|
||||||
|
event.manager.addSound(mod_pocketDim.modid + ":doorLocked.ogg");
|
||||||
|
event.manager.addSound(mod_pocketDim.modid + ":keyLock.ogg");
|
||||||
|
event.manager.addSound(mod_pocketDim.modid + ":keyUnlock.ogg");
|
||||||
event.manager.addSound(mod_pocketDim.modid + ":monk.ogg");
|
event.manager.addSound(mod_pocketDim.modid + ":monk.ogg");
|
||||||
event.manager.addSound(mod_pocketDim.modid + ":crack.ogg");
|
event.manager.addSound(mod_pocketDim.modid + ":crack.ogg");
|
||||||
event.manager.addSound(mod_pocketDim.modid + ":tearing.ogg");
|
event.manager.addSound(mod_pocketDim.modid + ":tearing.ogg");
|
||||||
|
|
|
@ -12,5 +12,6 @@ public class PacketConstants
|
||||||
public static final byte CREATE_LINK_PACKET_ID = 4;
|
public static final byte CREATE_LINK_PACKET_ID = 4;
|
||||||
public static final byte DELETE_LINK_PACKET_ID = 5;
|
public static final byte DELETE_LINK_PACKET_ID = 5;
|
||||||
public static final byte CLIENT_LOGIN_DIM_REGISTER = 6;
|
public static final byte CLIENT_LOGIN_DIM_REGISTER = 6;
|
||||||
|
public static final byte UPDATE_LINK_PACKET_ID = 7;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,13 @@ public class ServerPacketHandler implements IPacketHandler
|
||||||
public void onDeleted(ClientDimData message)
|
public void onDeleted(ClientDimData message)
|
||||||
{
|
{
|
||||||
sendDimPacket(PacketConstants.DELETE_DIM_PACKET_ID, message);
|
sendDimPacket(PacketConstants.DELETE_DIM_PACKET_ID, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(ClientDimData message)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +61,12 @@ public class ServerPacketHandler implements IPacketHandler
|
||||||
{
|
{
|
||||||
sendLinkPacket(PacketConstants.DELETE_LINK_PACKET_ID, message);
|
sendLinkPacket(PacketConstants.DELETE_LINK_PACKET_ID, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(ClientLinkData message)
|
||||||
|
{
|
||||||
|
sendLinkPacket(PacketConstants.UPDATE_LINK_PACKET_ID, message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet250CustomPayload createLinkPacket(ClientLinkData data)
|
public static Packet250CustomPayload createLinkPacket(ClientLinkData data)
|
||||||
|
|
|
@ -181,14 +181,7 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
|
||||||
//but this works fine and is more versatile I think.
|
//but this works fine and is more versatile I think.
|
||||||
public BaseDimDoor updateAttachedTile(World world, int x, int y, int z)
|
public BaseDimDoor updateAttachedTile(World world, int x, int y, int z)
|
||||||
{
|
{
|
||||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
mod_pocketDim.proxy.updateDoorTE(this, world, x, y, z);
|
||||||
if (tile instanceof TileEntityDimDoor)
|
|
||||||
{
|
|
||||||
int metadata = world.getBlockMetadata(x, y, z);
|
|
||||||
TileEntityDimDoor dimTile = (TileEntityDimDoor) tile;
|
|
||||||
dimTile.openOrClosed = this.isDoorOnRift(world, x, y, z)&&this.isUpperDoorBlock(metadata);
|
|
||||||
dimTile.orientation = this.getFullMetadata(world, x, y, z) & 7;
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,7 +346,7 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
|
||||||
this.dropBlockAsItem(world, x, y, z, metadata, 0);
|
this.dropBlockAsItem(world, x, y, z, metadata, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(!this.hasLock(world, x, y, z))
|
else if(this.getLockStatus(world, x, y, z)<=1)
|
||||||
{
|
{
|
||||||
boolean powered = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z);
|
boolean powered = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z);
|
||||||
if ((powered || neighborID > 0 && Block.blocksList[neighborID].canProvidePower()) && neighborID != this.blockID)
|
if ((powered || neighborID > 0 && Block.blocksList[neighborID].canProvidePower()) && neighborID != this.blockID)
|
||||||
|
@ -457,17 +450,32 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
|
||||||
return (metadata & 4) != 0;
|
return (metadata & 4) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public boolean hasLock(World world, int x, int y, int z)
|
* 0 if link is no lock;
|
||||||
|
* 1 if there is a lock;
|
||||||
|
* 2 if the lock is locked.
|
||||||
|
* @param world
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
* @param z
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public byte getLockStatus(World world, int x, int y, int z)
|
||||||
{
|
{
|
||||||
|
byte status = 0;
|
||||||
DimLink link = getLink(world, x, y, z);
|
DimLink link = getLink(world, x, y, z);
|
||||||
if(link!=null&&link.isLocked())
|
if(link!=null&&link.hasLock())
|
||||||
{
|
{
|
||||||
return true;
|
status++;
|
||||||
|
if(link.isLocked())
|
||||||
|
{
|
||||||
|
status++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean checkCanOpen(World world, int x, int y, int z)
|
public boolean checkCanOpen(World world, int x, int y, int z)
|
||||||
{
|
{
|
||||||
return this.checkCanOpen(world, x, y, z, null);
|
return this.checkCanOpen(world, x, y, z, null);
|
||||||
|
@ -475,30 +483,30 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
|
||||||
|
|
||||||
public boolean checkCanOpen(World world, int x, int y, int z, EntityPlayer player)
|
public boolean checkCanOpen(World world, int x, int y, int z, EntityPlayer player)
|
||||||
{
|
{
|
||||||
if(!hasLock(world, x, y, z))
|
DimLink link = getLink(world, x, y, z);
|
||||||
|
if(link==null||player==null)
|
||||||
|
{
|
||||||
|
return link==null;
|
||||||
|
}
|
||||||
|
if(!link.isLocked())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
DimLink link = getLink(world, x, y, z);
|
|
||||||
|
|
||||||
for(ItemStack item : player.inventory.mainInventory)
|
for(ItemStack item : player.inventory.mainInventory)
|
||||||
{
|
{
|
||||||
if(item != null)
|
if(item != null)
|
||||||
{
|
{
|
||||||
if(item.getItem() instanceof ItemDDKey)
|
if(item.getItem() instanceof ItemDDKey)
|
||||||
{
|
{
|
||||||
if(((ItemDDKey) item.getItem()).canKeyOpen(link, item))
|
if(link.open(item))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
player.playSound(mod_pocketDim.modid + ":doorLocked", 1F, 1F);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@ import net.minecraft.block.ITileEntityProvider;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.client.renderer.texture.IconRegister;
|
import net.minecraft.client.renderer.texture.IconRegister;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||||
|
@ -16,6 +18,7 @@ import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
|
import StevenDimDoors.mod_pocketDim.items.ItemDDKey;
|
||||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityTransTrapdoor;
|
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityTransTrapdoor;
|
||||||
|
|
||||||
public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntityProvider
|
public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntityProvider
|
||||||
|
@ -40,6 +43,55 @@ public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntit
|
||||||
enterDimDoor(world, x, y, z, entity);
|
enterDimDoor(world, x, y, z, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean checkCanOpen(World world, int x, int y, int z)
|
||||||
|
{
|
||||||
|
return this.checkCanOpen(world, x, y, z, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkCanOpen(World world, int x, int y, int z, EntityPlayer player)
|
||||||
|
{
|
||||||
|
DimLink link = PocketManager.getLink( x, y,z, world);
|
||||||
|
if(link==null||player==null)
|
||||||
|
{
|
||||||
|
return link==null;
|
||||||
|
}
|
||||||
|
if(!link.isLocked())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(ItemStack item : player.inventory.mainInventory)
|
||||||
|
{
|
||||||
|
if(item != null)
|
||||||
|
{
|
||||||
|
if(item.getItem() instanceof ItemDDKey)
|
||||||
|
{
|
||||||
|
if(link.open(item))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||||
|
{
|
||||||
|
if(this.checkCanOpen(par1World, par3, par3, par4, par5EntityPlayer))
|
||||||
|
{
|
||||||
|
return super.onBlockActivated(par1World, par2, par3, par4, par5EntityPlayer, par6, par7, par8, par9);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPoweredBlockChange(World par1World, int par2, int par3, int par4, boolean par5)
|
||||||
|
{
|
||||||
|
if(this.checkCanOpen(par1World, par2, par3, par4))
|
||||||
|
{
|
||||||
|
super.onPoweredBlockChange(par1World, par2, par3, par4, par5);
|
||||||
|
}
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void enterDimDoor(World world, int x, int y, int z, Entity entity)
|
public void enterDimDoor(World world, int x, int y, int z, Entity entity)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,6 @@ import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class WarpDoor extends BaseDimDoor
|
public class WarpDoor extends BaseDimDoor
|
||||||
{
|
{
|
||||||
public WarpDoor(int blockID, Material material, DDProperties properties)
|
public WarpDoor(int blockID, Material material, DDProperties properties)
|
||||||
|
|
|
@ -62,11 +62,11 @@ public class CommandResetDungeons extends DDCommandBase
|
||||||
{
|
{
|
||||||
if(link.linkType()==LinkTypes.REVERSE)
|
if(link.linkType()==LinkTypes.REVERSE)
|
||||||
{
|
{
|
||||||
data.createLink(link.source(), LinkTypes.DUNGEON_EXIT, link.orientation(), false);
|
data.createLink(link.source(), LinkTypes.DUNGEON_EXIT, link.orientation(), null);
|
||||||
}
|
}
|
||||||
if(link.linkType()==LinkTypes.DUNGEON)
|
if(link.linkType()==LinkTypes.DUNGEON)
|
||||||
{
|
{
|
||||||
data.createLink(link.source(), LinkTypes.DUNGEON, link.orientation(), false);
|
data.createLink(link.source(), LinkTypes.DUNGEON, link.orientation(), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
169
src/main/java/StevenDimDoors/mod_pocketDim/core/DDLock.java
Normal file
169
src/main/java/StevenDimDoors/mod_pocketDim/core/DDLock.java
Normal file
|
@ -0,0 +1,169 @@
|
||||||
|
package StevenDimDoors.mod_pocketDim.core;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import StevenDimDoors.mod_pocketDim.items.ItemDDKey;
|
||||||
|
import StevenDimDoors.mod_pocketDim.saving.IPackable;
|
||||||
|
import StevenDimDoors.mod_pocketDim.saving.PackedDimData;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagIntArray;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
|
||||||
|
public class DDLock
|
||||||
|
{
|
||||||
|
private boolean isLocked;
|
||||||
|
private final int lockKey;
|
||||||
|
|
||||||
|
|
||||||
|
public DDLock(boolean isLocked, int lockKey)
|
||||||
|
{
|
||||||
|
this.isLocked = isLocked;
|
||||||
|
this.lockKey = lockKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLockKey()
|
||||||
|
{
|
||||||
|
return this.lockKey;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* See if the lock is currently locked. False if there is no lock.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isLocked()
|
||||||
|
{
|
||||||
|
return this.isLocked;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the state of the lock. Returns false if there is no lock to set,
|
||||||
|
* otherwise returns true
|
||||||
|
* @param flag
|
||||||
|
*/
|
||||||
|
public void lock(boolean flag)
|
||||||
|
{
|
||||||
|
this.isLocked = flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* see if we could unlock this door if it where locked.
|
||||||
|
* @param link
|
||||||
|
* @param itemStack
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean canOpen(ItemStack itemStack)
|
||||||
|
{
|
||||||
|
for(int key :getKeys(itemStack))
|
||||||
|
{
|
||||||
|
if(this.lockKey == key)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to open this lock
|
||||||
|
* @param item
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean open(ItemStack itemStack)
|
||||||
|
{
|
||||||
|
return (!this.isLocked)||this.canOpen(itemStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the key/s to the given key/s
|
||||||
|
* @return
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets all the keys stored on a single key item
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static int[] getKeys(ItemStack itemStack)
|
||||||
|
{
|
||||||
|
if (!itemStack.hasTagCompound())
|
||||||
|
{
|
||||||
|
initNBTTags(itemStack);
|
||||||
|
}
|
||||||
|
return itemStack.getTagCompound().getIntArray("DDKeys");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* adds the key/s to the given key
|
||||||
|
* @return
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static void addKeys(ItemStack itemStack, int[] keysToAdd)
|
||||||
|
{
|
||||||
|
int[] oldKeys = DDLock.getKeys(itemStack);
|
||||||
|
int[] newKeys = new int[keysToAdd.length+oldKeys.length];
|
||||||
|
System.arraycopy(oldKeys, 0, newKeys, 0, oldKeys.length);
|
||||||
|
System.arraycopy(keysToAdd, 0, newKeys, oldKeys.length, keysToAdd.length);
|
||||||
|
setKeys(itemStack,newKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the key/s to the given key/s
|
||||||
|
* @return
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static void setKeys(ItemStack itemStack, int[] keys)
|
||||||
|
{
|
||||||
|
if (!itemStack.hasTagCompound())
|
||||||
|
{
|
||||||
|
initNBTTags(itemStack);
|
||||||
|
}
|
||||||
|
NBTTagCompound tag = itemStack.getTagCompound();
|
||||||
|
tag.setIntArray("DDKeys", keys);
|
||||||
|
itemStack.setTagCompound(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gives the key a new NBTTag
|
||||||
|
* @param itemStack
|
||||||
|
*/
|
||||||
|
public static void initNBTTags(ItemStack itemStack)
|
||||||
|
{
|
||||||
|
itemStack.setTagCompound(new NBTTagCompound());
|
||||||
|
NBTTagCompound tag = itemStack.getTagCompound();
|
||||||
|
tag.setIntArray("DDKeys", new int[0]);
|
||||||
|
tag.setBoolean("HasCreatedLock", false);
|
||||||
|
itemStack.setTagCompound(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasCreatedLock(ItemStack key)
|
||||||
|
{
|
||||||
|
if(isKey(key))
|
||||||
|
{
|
||||||
|
if(key.hasTagCompound())
|
||||||
|
{
|
||||||
|
return key.getTagCompound().getBoolean("HasCreatedLock");
|
||||||
|
}
|
||||||
|
initNBTTags(key);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isKey(ItemStack key)
|
||||||
|
{
|
||||||
|
return key.getItem() instanceof ItemDDKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static DDLock createLock(ItemStack itemStack, int lockKey2)
|
||||||
|
{
|
||||||
|
itemStack.getTagCompound().setBoolean("HasCreatedLock", true);
|
||||||
|
DDLock.setKeys(itemStack, new int[]{lockKey2});
|
||||||
|
return new DDLock(true, lockKey2);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -485,7 +485,7 @@ public class DDTeleporter
|
||||||
{
|
{
|
||||||
if(PocketManager.isBlackListed(link.destination().getDimension()))
|
if(PocketManager.isBlackListed(link.destination().getDimension()))
|
||||||
{
|
{
|
||||||
link=PocketManager.getDimensionData(link.source().getDimension()).createLink(link.point,LinkTypes.SAFE_EXIT,link.orientation, false);
|
link=PocketManager.getDimensionData(link.source().getDimension()).createLink(link.point,LinkTypes.SAFE_EXIT,link.orientation, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,20 +2,20 @@ package StevenDimDoors.mod_pocketDim.core;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import StevenDimDoors.mod_pocketDim.items.ItemDDKey;
|
||||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||||
import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
|
|
||||||
|
|
||||||
public abstract class DimLink
|
public abstract class DimLink
|
||||||
{
|
{
|
||||||
protected Point4D point;
|
protected Point4D point;
|
||||||
protected int orientation;
|
protected int orientation;
|
||||||
protected boolean isLocked;
|
private DDLock lock;
|
||||||
protected DimLink parent;
|
protected DimLink parent;
|
||||||
protected LinkTail tail;
|
protected LinkTail tail;
|
||||||
protected List<DimLink> children;
|
protected List<DimLink> children;
|
||||||
|
|
||||||
protected DimLink(Point4D point, int orientation, boolean locked, DimLink parent)
|
protected DimLink(Point4D point, int orientation, DDLock lock, DimLink parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (parent.point.getDimension() != point.getDimension())
|
if (parent.point.getDimension() != point.getDimension())
|
||||||
|
@ -23,26 +23,25 @@ public abstract class DimLink
|
||||||
// Ban having children in other dimensions to avoid serialization issues with cross-dimensional tails
|
// 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.");
|
throw new IllegalArgumentException("source and parent.source must have the same dimension.");
|
||||||
}
|
}
|
||||||
|
this.lock = lock;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.point = point;
|
this.point = point;
|
||||||
this.tail = parent.tail;
|
this.tail = parent.tail;
|
||||||
this.orientation = orientation;
|
this.orientation = orientation;
|
||||||
this.isLocked = locked;
|
|
||||||
this.children = new LinkedList<DimLink>();
|
this.children = new LinkedList<DimLink>();
|
||||||
parent.children.add(this);
|
parent.children.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DimLink(Point4D point, int orientation, boolean locked, int linkType)
|
protected DimLink(Point4D point, int orientation, DDLock lock, int linkType)
|
||||||
{
|
{
|
||||||
if ((linkType < LinkTypes.ENUM_MIN || linkType > LinkTypes.ENUM_MAX) && linkType != LinkTypes.CLIENT_SIDE)
|
if ((linkType < LinkTypes.ENUM_MIN || linkType > LinkTypes.ENUM_MAX) && linkType != LinkTypes.CLIENT_SIDE)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("The specified link type is invalid.");
|
throw new IllegalArgumentException("The specified link type is invalid.");
|
||||||
}
|
}
|
||||||
|
this.lock = lock;
|
||||||
this.parent = null;
|
this.parent = null;
|
||||||
this.point = point;
|
this.point = point;
|
||||||
this.orientation = orientation;
|
this.orientation = orientation;
|
||||||
this.isLocked = locked;
|
|
||||||
this.tail = new LinkTail(linkType, null);
|
this.tail = new LinkTail(linkType, null);
|
||||||
this.children = new LinkedList<DimLink>();
|
this.children = new LinkedList<DimLink>();
|
||||||
}
|
}
|
||||||
|
@ -115,18 +114,63 @@ public abstract class DimLink
|
||||||
return tail.getLinkType();
|
return tail.getLinkType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLocked()
|
|
||||||
{
|
|
||||||
return isLocked;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLocked(boolean bol)
|
|
||||||
{
|
|
||||||
isLocked = bol;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return point + " -> " + (hasDestination() ? destination() : "");
|
return point + " -> " + (hasDestination() ? destination() : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to open this lock. Returns true if the lock is open or if the key can open it
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean open(ItemStack item)
|
||||||
|
{
|
||||||
|
return lock.open(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test if there is a lock, regardless if it is locked or not.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean hasLock()
|
||||||
|
{
|
||||||
|
return this.lock!=null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLocked()
|
||||||
|
{
|
||||||
|
return this.hasLock()&&this.lock.isLocked();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DDLock getLock()
|
||||||
|
{
|
||||||
|
PocketManager.getDimensionData(this.source().getDimension()).flagModified();
|
||||||
|
return this.lock;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* only use this on the client to update errything
|
||||||
|
* @param lock
|
||||||
|
*/
|
||||||
|
public void setLock(DDLock lock)
|
||||||
|
{
|
||||||
|
this.lock = lock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create a lock from a key. Returns false if this door already has a lock, or if they has already locked a door
|
||||||
|
* @param itemStack
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean createLock(ItemStack itemStack, int lockKey)
|
||||||
|
{
|
||||||
|
if(this.hasLock()||DDLock.hasCreatedLock(itemStack))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.lock = DDLock.createLock(itemStack, lockKey);
|
||||||
|
PocketManager.getDimensionData(this.source().getDimension()).flagModified();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,14 @@ public abstract class NewDimData implements IPackable<PackedDimData>
|
||||||
{
|
{
|
||||||
private static class InnerDimLink extends DimLink
|
private static class InnerDimLink extends DimLink
|
||||||
{
|
{
|
||||||
public InnerDimLink(Point4D source, DimLink parent, int orientation, boolean isLocked)
|
public InnerDimLink(Point4D source, DimLink parent, int orientation, DDLock lock)
|
||||||
{
|
{
|
||||||
super(source, orientation, isLocked, parent);
|
super(source, orientation, lock, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InnerDimLink(Point4D source, int linkType, int orientation, boolean isLocked)
|
public InnerDimLink(Point4D source, int linkType, int orientation, DDLock lock)
|
||||||
{
|
{
|
||||||
super(source, orientation, isLocked, linkType);
|
super(source, orientation, lock, linkType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDestination(int x, int y, int z, NewDimData dimension)
|
public void setDestination(int x, int y, int z, NewDimData dimension)
|
||||||
|
@ -99,7 +99,6 @@ public abstract class NewDimData implements IPackable<PackedDimData>
|
||||||
this.orientation=orientation;
|
this.orientation=orientation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Random random = new Random();
|
protected static Random random = new Random();
|
||||||
|
|
||||||
protected int id;
|
protected int id;
|
||||||
|
@ -279,10 +278,10 @@ public abstract class NewDimData implements IPackable<PackedDimData>
|
||||||
|
|
||||||
public DimLink createLink(int x, int y, int z, int linkType, int orientation)
|
public DimLink createLink(int x, int y, int z, int linkType, int orientation)
|
||||||
{
|
{
|
||||||
return createLink(new Point4D(x, y, z, id), linkType, orientation, false);
|
return createLink(new Point4D(x, y, z, id), linkType, orientation, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DimLink createLink(Point4D source, int linkType, int orientation, boolean locked)
|
public DimLink createLink(Point4D source, int linkType, int orientation, DDLock locked)
|
||||||
{
|
{
|
||||||
//Return an existing link if there is one to avoid creating multiple links starting at the same point.
|
//Return an existing link if there is one to avoid creating multiple links starting at the same point.
|
||||||
InnerDimLink link = linkMapping.get(source);
|
InnerDimLink link = linkMapping.get(source);
|
||||||
|
@ -308,10 +307,10 @@ public abstract class NewDimData implements IPackable<PackedDimData>
|
||||||
|
|
||||||
public DimLink createChildLink(int x, int y, int z, DimLink parent)
|
public DimLink createChildLink(int x, int y, int z, DimLink parent)
|
||||||
{
|
{
|
||||||
return createChildLink(new Point4D(x, y, z, id), (InnerDimLink) parent, false);
|
return createChildLink(new Point4D(x, y, z, id), (InnerDimLink) parent, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DimLink createChildLink(Point4D source, DimLink parent, boolean locked)
|
public DimLink createChildLink(Point4D source, DimLink parent, DDLock locked)
|
||||||
{
|
{
|
||||||
//To avoid having multiple links at a single point, if we find an existing link then we overwrite
|
//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.
|
//its destination data instead of creating a new instance.
|
||||||
|
@ -584,6 +583,11 @@ public abstract class NewDimData implements IPackable<PackedDimData>
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void flagModified()
|
||||||
|
{
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
public void clearModified()
|
public void clearModified()
|
||||||
{
|
{
|
||||||
this.modified = false;
|
this.modified = false;
|
||||||
|
@ -651,7 +655,7 @@ public abstract class NewDimData implements IPackable<PackedDimData>
|
||||||
children.add(childLink.source().toPoint3D());
|
children.add(childLink.source().toPoint3D());
|
||||||
}
|
}
|
||||||
PackedLinkTail tail = new PackedLinkTail(link.tail.getDestination(),link.tail.getLinkType());
|
PackedLinkTail tail = new PackedLinkTail(link.tail.getDestination(),link.tail.getLinkType());
|
||||||
Links.add(new PackedLinkData(link.point,parentPoint,tail,link.orientation,children,link.isLocked()));
|
Links.add(new PackedLinkData(link.point,parentPoint,tail,link.orientation,children,link.getLock()));
|
||||||
|
|
||||||
PackedLinkTail tempTail = new PackedLinkTail(link.tail.getDestination(),link.tail.getLinkType());
|
PackedLinkTail tempTail = new PackedLinkTail(link.tail.getDestination(),link.tail.getLinkType());
|
||||||
if(Tails.contains(tempTail))
|
if(Tails.contains(tempTail))
|
||||||
|
|
|
@ -7,32 +7,25 @@ import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
|
||||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||||
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.Compactor;
|
import StevenDimDoors.mod_pocketDim.helpers.Compactor;
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.DeleteFolder;
|
import StevenDimDoors.mod_pocketDim.helpers.DeleteFolder;
|
||||||
import StevenDimDoors.mod_pocketDim.saving.DDSaveHandler;
|
import StevenDimDoors.mod_pocketDim.saving.DDSaveHandler;
|
||||||
import StevenDimDoors.mod_pocketDim.saving.IPackable;
|
|
||||||
import StevenDimDoors.mod_pocketDim.saving.OldSaveImporter;
|
import StevenDimDoors.mod_pocketDim.saving.OldSaveImporter;
|
||||||
import StevenDimDoors.mod_pocketDim.saving.PackedDimData;
|
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.util.Point4D;
|
||||||
import StevenDimDoors.mod_pocketDim.watcher.ClientDimData;
|
import StevenDimDoors.mod_pocketDim.watcher.ClientDimData;
|
||||||
import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
|
import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
|
||||||
import StevenDimDoors.mod_pocketDim.watcher.IUpdateSource;
|
import StevenDimDoors.mod_pocketDim.watcher.IUpdateSource;
|
||||||
import StevenDimDoors.mod_pocketDim.watcher.IUpdateWatcher;
|
import StevenDimDoors.mod_pocketDim.watcher.IUpdateWatcher;
|
||||||
import StevenDimDoors.mod_pocketDim.watcher.UpdateWatcherProxy;
|
import StevenDimDoors.mod_pocketDim.watcher.UpdateWatcherProxy;
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class regulates all the operations involving the storage and manipulation of dimensions.
|
* This class regulates all the operations involving the storage and manipulation of dimensions.
|
||||||
|
@ -40,7 +33,7 @@ import StevenDimDoors.mod_pocketDim.watcher.UpdateWatcherProxy;
|
||||||
* well as loading old dimensions on startup
|
* well as loading old dimensions on startup
|
||||||
*/
|
*/
|
||||||
public class PocketManager
|
public class PocketManager
|
||||||
{
|
{
|
||||||
private static class InnerDimData extends NewDimData
|
private static class InnerDimData extends NewDimData
|
||||||
{
|
{
|
||||||
// This class allows us to instantiate NewDimData indirectly without exposing
|
// This class allows us to instantiate NewDimData indirectly without exposing
|
||||||
|
@ -69,7 +62,7 @@ public class PocketManager
|
||||||
{
|
{
|
||||||
Point4D source = link.point;
|
Point4D source = link.point;
|
||||||
NewDimData dimension = getDimensionData(source.getDimension());
|
NewDimData dimension = getDimensionData(source.getDimension());
|
||||||
dimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.CLIENT_SIDE,link.orientation);
|
dimension.createLink(source, LinkTypes.CLIENT_SIDE, 0, link.lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -78,7 +71,17 @@ public class PocketManager
|
||||||
Point4D source = link.point;
|
Point4D source = link.point;
|
||||||
NewDimData dimension = getDimensionData(source.getDimension());
|
NewDimData dimension = getDimensionData(source.getDimension());
|
||||||
dimension.deleteLink(source.getX(), source.getY(), source.getZ());
|
dimension.deleteLink(source.getX(), source.getY(), source.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(ClientLinkData link)
|
||||||
|
{
|
||||||
|
Point4D source = link.point;
|
||||||
|
NewDimData dimension = getDimensionData(source.getDimension());
|
||||||
|
DimLink dLink = dimension.getLink(source);
|
||||||
|
dLink.setLock(link.lock);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ClientDimWatcher implements IUpdateWatcher<ClientDimData>
|
private static class ClientDimWatcher implements IUpdateWatcher<ClientDimData>
|
||||||
|
@ -94,6 +97,12 @@ public class PocketManager
|
||||||
{
|
{
|
||||||
deletePocket(getDimensionData(data.ID), false);
|
deletePocket(getDimensionData(data.ID), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(ClientDimData message)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class DimRegistrationCallback implements IDimRegistrationCallback
|
private static class DimRegistrationCallback implements IDimRegistrationCallback
|
||||||
|
@ -633,4 +642,9 @@ public class PocketManager
|
||||||
{
|
{
|
||||||
return dimWatcher;
|
return dimWatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static UpdateWatcherProxy<ClientLinkData> getLinkWatcher()
|
||||||
|
{
|
||||||
|
return linkWatcher;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class Compactor
|
||||||
{
|
{
|
||||||
ClientLinkData link = ClientLinkData.read(input);
|
ClientLinkData link = ClientLinkData.read(input);
|
||||||
Point4D source = link.point;
|
Point4D source = link.point;
|
||||||
dimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.CLIENT_SIDE,link.orientation);
|
dimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.CLIENT_SIDE,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,10 @@ import net.minecraft.util.StatCollector;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||||
import StevenDimDoors.mod_pocketDim.blocks.IDimDoor;
|
import StevenDimDoors.mod_pocketDim.blocks.IDimDoor;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.DDLock;
|
||||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
|
import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
|
||||||
|
|
||||||
public class ItemDDKey extends Item
|
public class ItemDDKey extends Item
|
||||||
{
|
{
|
||||||
|
@ -32,8 +34,14 @@ public class ItemDDKey extends Item
|
||||||
|
|
||||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||||
{
|
{
|
||||||
boolean check = (this.isBound(par1ItemStack) ? par3List.add("Bound") : par3List.add("Unbound"));
|
if(DDLock.hasCreatedLock(par1ItemStack))
|
||||||
return;
|
{
|
||||||
|
par3List.add("Bound");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
par3List.add("Unbound");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,7 +55,7 @@ public class ItemDDKey extends Item
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public boolean hasEffect(ItemStack par1ItemStack)
|
public boolean hasEffect(ItemStack par1ItemStack)
|
||||||
{
|
{
|
||||||
return !this.isBound(par1ItemStack);
|
return !DDLock.hasCreatedLock(par1ItemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onItemUseFirst(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float playerX, float playerY,
|
public boolean onItemUseFirst(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float playerX, float playerY,
|
||||||
|
@ -70,162 +78,40 @@ public class ItemDDKey extends Item
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//make sure we are not trying to mess with a door thats already locked by someone else
|
|
||||||
if(!this.canKeyOpen(link, itemStack)&&link.isLocked())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//see if we can bind this key to this door and lock it
|
|
||||||
if(setBoundDoor(itemStack, link))
|
|
||||||
{
|
|
||||||
link.setLocked(true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//lastly, just see if we can toggle the door's lock state if its locked.
|
|
||||||
if(this.canKeyOpen(link, itemStack))
|
|
||||||
{
|
|
||||||
link.setLocked(!link.isLocked());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//what to do if the door has a lock already
|
||||||
public boolean setBoundDoor(ItemStack itemStack, DimLink link)
|
if(link.hasLock())
|
||||||
{
|
|
||||||
//dont bind to a door if we already are bound, or if we dont have permission to lock that door
|
|
||||||
if(this.isBound(itemStack)|| (!this.canKeyOpen(link, itemStack)&&link.isLocked()))
|
|
||||||
{
|
{
|
||||||
return false;
|
if(link.getLock().canOpen(itemStack))
|
||||||
}
|
|
||||||
|
|
||||||
//dont bind if the door has a lock already on it, but we can still open it. That would waste the key.
|
|
||||||
if(link.isLocked())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//init tags
|
|
||||||
if(!itemStack.hasTagCompound())
|
|
||||||
{
|
|
||||||
this.initNBTTags(itemStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
//consume this keys ability to create a lock
|
|
||||||
itemStack.getTagCompound().setBoolean("HasLockedDoor", true);
|
|
||||||
|
|
||||||
//create the tag that binds this door to this key
|
|
||||||
NBTTagCompound tag = new NBTTagCompound();
|
|
||||||
|
|
||||||
int x = link.source().getX();
|
|
||||||
int y = link.source().getY();
|
|
||||||
int z = link.source().getZ();
|
|
||||||
|
|
||||||
tag.setInteger("x", x);
|
|
||||||
tag.setInteger("y", y);
|
|
||||||
tag.setInteger("z", z);
|
|
||||||
tag.setInteger("dim", link.source().getDimension());
|
|
||||||
|
|
||||||
//add this door's tag to this keys keyring
|
|
||||||
NBTTagList keyRing = itemStack.getTagCompound().getTagList("DDKeys");
|
|
||||||
keyRing.appendTag(tag);
|
|
||||||
itemStack.getTagCompound().setTag("DDKeys", keyRing);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* copies all the tags from the first key onto the second key
|
|
||||||
* @param givingKey
|
|
||||||
* @param receivingKey
|
|
||||||
*/
|
|
||||||
public void addDoorToKey(ItemStack givingKey, ItemStack receivingKey)
|
|
||||||
{
|
|
||||||
//cant copy tags from a key with no tags
|
|
||||||
if(!givingKey.hasTagCompound())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//initialize the receiving key
|
|
||||||
if(!receivingKey.hasTagCompound())
|
|
||||||
{
|
|
||||||
this.initNBTTags(receivingKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
//get the tags
|
|
||||||
NBTTagCompound recevingTags = receivingKey.getTagCompound();
|
|
||||||
NBTTagCompound sendingTags = (NBTTagCompound) givingKey.getTagCompound().copy();
|
|
||||||
|
|
||||||
//copy over the actual tags
|
|
||||||
for(int i = 0; i<sendingTags.getTagList("DDKeys").tagCount();i++)
|
|
||||||
{
|
|
||||||
recevingTags.getTagList("DDKeys").appendTag(sendingTags.getTagList("DDKeys").tagAt(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* see if we could unlock this door if it where locked.
|
|
||||||
* @param link
|
|
||||||
* @param itemStack
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean canKeyOpen(DimLink link, ItemStack itemStack)
|
|
||||||
{
|
|
||||||
//make sure we have a tag
|
|
||||||
if (itemStack.hasTagCompound())
|
|
||||||
{
|
|
||||||
NBTTagList tags = itemStack.getTagCompound().getTagList("DDKeys");
|
|
||||||
|
|
||||||
for(int i = 0; i < tags.tagCount(); i++)
|
|
||||||
{
|
{
|
||||||
NBTTagCompound tag = (NBTTagCompound) tags.tagAt(i);
|
if(link.isLocked())
|
||||||
Integer x = tag.getInteger("x");
|
|
||||||
Integer y = tag.getInteger("y");
|
|
||||||
Integer z = tag.getInteger("z");
|
|
||||||
Integer dimID = tag.getInteger("dim");
|
|
||||||
if (x != null && y != null && z != null && dimID != null)
|
|
||||||
{
|
{
|
||||||
if (x == link.source().getX() &&
|
world.playSoundAtEntity(player, mod_pocketDim.modid + ":keyUnlock", 1F, 1F);
|
||||||
y == link.source().getY() &&
|
|
||||||
z == link.source().getZ() &&
|
|
||||||
dimID == link.source().getDimension())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
world.playSoundAtEntity(player, mod_pocketDim.modid + ":keyLock", 1F, 1F);
|
||||||
|
}
|
||||||
|
link.getLock().lock(!link.isLocked());
|
||||||
|
PocketManager.getLinkWatcher().update(new ClientLinkData(link.source(),link.getLock()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!DDLock.hasCreatedLock(itemStack))
|
||||||
|
{
|
||||||
|
world.playSoundAtEntity(player, mod_pocketDim.modid + ":keyLock", 1F, 1F);
|
||||||
|
link.createLock(itemStack, world.rand.nextInt(Integer.MAX_VALUE));
|
||||||
|
PocketManager.getLinkWatcher().update(new ClientLinkData(link.source(),link.getLock()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getItemStackDisplayName(ItemStack par1ItemStack)
|
public String getItemStackDisplayName(ItemStack par1ItemStack)
|
||||||
{
|
{
|
||||||
return StatCollector.translateToLocal(this.getUnlocalizedName(par1ItemStack) + ".name");
|
return StatCollector.translateToLocal(this.getUnlocalizedName(par1ItemStack) + ".name");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBound(ItemStack item)
|
|
||||||
{
|
|
||||||
if(item.hasTagCompound())
|
|
||||||
{
|
|
||||||
if(item.getTagCompound().getBoolean("HasLockedDoor"))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public void initNBTTags(ItemStack itemStack)
|
|
||||||
{
|
|
||||||
itemStack.setTagCompound(new NBTTagCompound());
|
|
||||||
NBTTagCompound tag = itemStack.getTagCompound();
|
|
||||||
tag.setTag("DDKeys", new NBTTagList());
|
|
||||||
itemStack.setTagCompound(tag);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,7 +197,7 @@ public class DDSaveHandler
|
||||||
linkType = LinkTypes.NORMAL;
|
linkType = LinkTypes.NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DimLink link = data.createLink(packedLink.source, linkType, packedLink.orientation, packedLink.locked);
|
DimLink link = data.createLink(packedLink.source, linkType, packedLink.orientation, packedLink.lock);
|
||||||
Point4D destination = packedLink.tail.destination;
|
Point4D destination = packedLink.tail.destination;
|
||||||
if(destination!=null)
|
if(destination!=null)
|
||||||
{
|
{
|
||||||
|
@ -216,7 +216,7 @@ public class DDSaveHandler
|
||||||
NewDimData data = PocketManager.getDimensionData(packedLink.source.getDimension());
|
NewDimData data = PocketManager.getDimensionData(packedLink.source.getDimension());
|
||||||
if(data.getLink(packedLink.parent)!=null)
|
if(data.getLink(packedLink.parent)!=null)
|
||||||
{
|
{
|
||||||
data.createChildLink(packedLink.source, data.getLink(packedLink.parent), packedLink.locked);
|
data.createChildLink(packedLink.source, data.getLink(packedLink.parent), packedLink.lock);
|
||||||
}
|
}
|
||||||
unpackedLinks.add(packedLink);
|
unpackedLinks.add(packedLink);
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ public class DDSaveHandler
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static PackedDimData readDimension(File dataFile, DimDataProcessor reader)
|
private static PackedDimData readDimension(File dataFile, DimDataProcessor reader)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,6 +13,7 @@ import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonToken;
|
import com.google.gson.stream.JsonToken;
|
||||||
|
|
||||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.DDLock;
|
||||||
import StevenDimDoors.mod_pocketDim.util.BaseConfigurationProcessor;
|
import StevenDimDoors.mod_pocketDim.util.BaseConfigurationProcessor;
|
||||||
import StevenDimDoors.mod_pocketDim.util.ConfigurationProcessingException;
|
import StevenDimDoors.mod_pocketDim.util.ConfigurationProcessingException;
|
||||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||||
|
@ -202,7 +203,7 @@ public class DimDataProcessor extends BaseConfigurationProcessor<PackedDimData>
|
||||||
|
|
||||||
private PackedLinkData createLinkDataFromJson(JsonReader reader) throws IOException
|
private PackedLinkData createLinkDataFromJson(JsonReader reader) throws IOException
|
||||||
{
|
{
|
||||||
boolean locked = false;
|
DDLock lock = null;
|
||||||
|
|
||||||
Point4D source;
|
Point4D source;
|
||||||
Point3D parent;
|
Point3D parent;
|
||||||
|
@ -235,13 +236,11 @@ public class DimDataProcessor extends BaseConfigurationProcessor<PackedDimData>
|
||||||
|
|
||||||
if(reader.peek()== JsonToken.NAME)
|
if(reader.peek()== JsonToken.NAME)
|
||||||
{
|
{
|
||||||
reader.nextName();
|
lock = this.createLockFromJson(reader);
|
||||||
locked = reader.nextBoolean();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
reader.endObject();
|
reader.endObject();
|
||||||
|
|
||||||
return new PackedLinkData(source, parent, tail, orientation, children, locked);
|
return new PackedLinkData(source, parent, tail, orientation, children, lock);
|
||||||
}
|
}
|
||||||
private PackedDungeonData createDungeonDataFromJson(JsonReader reader) throws IOException
|
private PackedDungeonData createDungeonDataFromJson(JsonReader reader) throws IOException
|
||||||
{
|
{
|
||||||
|
@ -307,4 +306,21 @@ public class DimDataProcessor extends BaseConfigurationProcessor<PackedDimData>
|
||||||
|
|
||||||
return new PackedLinkTail(destination, linkType);
|
return new PackedLinkTail(destination, linkType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DDLock createLockFromJson(JsonReader reader) throws IOException
|
||||||
|
{
|
||||||
|
reader.nextName();
|
||||||
|
|
||||||
|
reader.beginObject();
|
||||||
|
reader.nextName();
|
||||||
|
|
||||||
|
boolean locked = reader.nextBoolean();
|
||||||
|
reader.nextName();
|
||||||
|
|
||||||
|
int key = reader.nextInt();
|
||||||
|
reader.endObject();
|
||||||
|
|
||||||
|
return new DDLock(locked, key);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class OldSaveImporter
|
||||||
PackedLinkTail tail = new PackedLinkTail(destintion, link.linkOrientation);
|
PackedLinkTail tail = new PackedLinkTail(destintion, link.linkOrientation);
|
||||||
List<Point3D> children = new ArrayList<Point3D>();
|
List<Point3D> children = new ArrayList<Point3D>();
|
||||||
|
|
||||||
PackedLinkData newPackedLink = new PackedLinkData(source, new Point3D(-1,-1,-1), tail, link.linkOrientation,children, false);
|
PackedLinkData newPackedLink = new PackedLinkData(source, new Point3D(-1,-1,-1), tail, link.linkOrientation,children, null);
|
||||||
|
|
||||||
newPackedLinkData.add(newPackedLink);
|
newPackedLinkData.add(newPackedLink);
|
||||||
allPackedLinks.add(newPackedLink);
|
allPackedLinks.add(newPackedLink);
|
||||||
|
|
|
@ -49,4 +49,6 @@ public class PackedDimData
|
||||||
{
|
{
|
||||||
return "ID= "+this.ID;
|
return "ID= "+this.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package StevenDimDoors.mod_pocketDim.saving;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.DDLock;
|
||||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||||
|
|
||||||
public class PackedLinkData
|
public class PackedLinkData
|
||||||
|
@ -12,15 +13,15 @@ public class PackedLinkData
|
||||||
public final PackedLinkTail tail;
|
public final PackedLinkTail tail;
|
||||||
public final int orientation;
|
public final int orientation;
|
||||||
public final List<Point3D> children;
|
public final List<Point3D> children;
|
||||||
public final boolean locked;
|
public final DDLock lock;
|
||||||
|
|
||||||
public PackedLinkData(Point4D source, Point3D parent, PackedLinkTail tail, int orientation, List<Point3D> children, boolean locked)
|
public PackedLinkData(Point4D source, Point3D parent, PackedLinkTail tail, int orientation, List<Point3D> children, DDLock lock)
|
||||||
{
|
{
|
||||||
this.source=source;
|
this.source=source;
|
||||||
this.parent=parent;
|
this.parent=parent;
|
||||||
this.tail=tail;
|
this.tail=tail;
|
||||||
this.orientation=orientation;
|
this.orientation=orientation;
|
||||||
this.children=children;
|
this.children=children;
|
||||||
this.locked = locked;
|
this.lock = lock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ public class TileEntityDimDoor extends DDTileEntityBase
|
||||||
public boolean openOrClosed;
|
public boolean openOrClosed;
|
||||||
public int orientation;
|
public int orientation;
|
||||||
public boolean hasExit;
|
public boolean hasExit;
|
||||||
|
public byte lockStatus;
|
||||||
public boolean isDungeonChainLink;
|
public boolean isDungeonChainLink;
|
||||||
public boolean hasGennedPair=false;
|
public boolean hasGennedPair=false;
|
||||||
|
|
||||||
|
|
|
@ -3,43 +3,53 @@ package StevenDimDoors.mod_pocketDim.watcher;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.DDLock;
|
||||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||||
|
|
||||||
public class ClientLinkData
|
public class ClientLinkData
|
||||||
{
|
{
|
||||||
public Point4D point;
|
public Point4D point;
|
||||||
public int orientation;
|
public DDLock lock;
|
||||||
public boolean isLocked;
|
|
||||||
|
public ClientLinkData(DimLink link)
|
||||||
public ClientLinkData(DimLink link)
|
{
|
||||||
{
|
this.point = link.source();
|
||||||
this.point= link.source();
|
if (link.hasLock())
|
||||||
this.orientation=link.orientation();
|
{
|
||||||
this.isLocked = link.isLocked();
|
lock = link.getLock();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public ClientLinkData(Point4D point, int orientation, boolean isLocked)
|
|
||||||
{
|
public ClientLinkData(Point4D point, DDLock lock)
|
||||||
this.point = point;
|
{
|
||||||
this.orientation=orientation;
|
this.point = point;
|
||||||
this.isLocked = isLocked;
|
this.lock = lock;
|
||||||
}
|
|
||||||
|
}
|
||||||
public void write(DataOutputStream output) throws IOException
|
|
||||||
{
|
public void write(DataOutputStream output) throws IOException
|
||||||
Point4D.write(point, output);
|
{
|
||||||
output.writeInt(orientation);
|
Point4D.write(point, output);
|
||||||
output.writeBoolean(isLocked);
|
|
||||||
}
|
boolean hasLock = this.lock != null;
|
||||||
|
output.writeBoolean(hasLock);
|
||||||
public static ClientLinkData read(DataInputStream input) throws IOException
|
|
||||||
{
|
if (hasLock)
|
||||||
Point4D point = Point4D.read(input);
|
{
|
||||||
int orientation = input.readInt();
|
output.writeBoolean(lock.isLocked());
|
||||||
boolean isLocked = input.readBoolean();
|
output.writeInt(lock.getLockKey());
|
||||||
return new ClientLinkData(point, orientation, isLocked);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ClientLinkData read(DataInputStream input) throws IOException
|
||||||
|
{
|
||||||
|
Point4D point = Point4D.read(input);
|
||||||
|
DDLock lock = null;
|
||||||
|
if (input.readBoolean())
|
||||||
|
{
|
||||||
|
lock = new DDLock(input.readBoolean(), input.readInt());
|
||||||
|
}
|
||||||
|
return new ClientLinkData(point, lock);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,6 @@ package StevenDimDoors.mod_pocketDim.watcher;
|
||||||
public interface IUpdateWatcher<T>
|
public interface IUpdateWatcher<T>
|
||||||
{
|
{
|
||||||
public void onCreated(T message);
|
public void onCreated(T message);
|
||||||
|
public void update(T message);
|
||||||
public void onDeleted(T message);
|
public void onDeleted(T message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,4 +39,13 @@ public class UpdateWatcherProxy<T> implements IUpdateWatcher<T>
|
||||||
{
|
{
|
||||||
return watchers.remove(receiver);
|
return watchers.remove(receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(T message)
|
||||||
|
{
|
||||||
|
for (IUpdateWatcher<T> receiver : watchers)
|
||||||
|
{
|
||||||
|
receiver.update(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,87 +40,6 @@ public class PocketBuilder
|
||||||
|
|
||||||
private PocketBuilder() { }
|
private PocketBuilder() { }
|
||||||
|
|
||||||
/**
|
|
||||||
* Method that takes an arbitrary link into a dungeon pocket and tries to regenerate it. First uses the origin to find that link,
|
|
||||||
* then uses that link to find the link that originally created the dungeon. If it cant find any of these, it
|
|
||||||
* instead makes the link that lead to this point into an exit door style link, sending the player to the overworld.
|
|
||||||
* @param dimension The dungeon to be regenerated
|
|
||||||
* @param linkIn The link leading somewhere into the dungeon.
|
|
||||||
* @param properties
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static boolean regenerateDungeonPocket(NewDimData dimension, DimLink linkIn, DDProperties properties)
|
|
||||||
{
|
|
||||||
if (linkIn == null)
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("link cannot be null.");
|
|
||||||
}
|
|
||||||
if (properties == null)
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("properties cannot be null.");
|
|
||||||
}
|
|
||||||
//The link that is at the origin of the dungeon
|
|
||||||
DimLink originLink = dimension.getLink(dimension.origin());
|
|
||||||
Point4D oldLinkPos = linkIn.source();
|
|
||||||
if(originLink==null)
|
|
||||||
{
|
|
||||||
int orientation = linkIn.orientation();
|
|
||||||
originLink=dimension.createLink(oldLinkPos, LinkTypes.SAFE_EXIT, (orientation+2)%4, false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
//The link that originally created the dungeon on the way in
|
|
||||||
DimLink incomingLink = PocketManager.getLink(originLink.destination());
|
|
||||||
if(incomingLink==null||incomingLink.linkType()!=LinkTypes.DUNGEON||!(originLink.linkType()==LinkTypes.REVERSE))
|
|
||||||
{
|
|
||||||
int orientation = linkIn.orientation();
|
|
||||||
dimension.deleteLink(originLink);
|
|
||||||
dimension.createLink(oldLinkPos, LinkTypes.SAFE_EXIT, (orientation+2)%4, false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
NewDimData parent = PocketManager.getDimensionData(incomingLink.source().getDimension());
|
|
||||||
|
|
||||||
if (!dimension.isDungeon())
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("destination must be dungeon");
|
|
||||||
}
|
|
||||||
if (dimension.isFilled())
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("destination must be empty");
|
|
||||||
}
|
|
||||||
if (!dimension.isInitialized())
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("destination must already exist");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//Load a world
|
|
||||||
World world = PocketManager.loadDimension(dimension.id());
|
|
||||||
|
|
||||||
if (world == null || world.provider == null)
|
|
||||||
{
|
|
||||||
System.err.println("Could not initialize dimension for a dungeon!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DungeonSchematic schematic = loadAndValidateDungeon(dimension.dungeon(), properties);
|
|
||||||
if (schematic == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Point3D destination = new Point3D(incomingLink.destination());
|
|
||||||
schematic.copyToWorld(world, destination, originLink.orientation(), incomingLink, random, properties, false);
|
|
||||||
dimension.setFilled(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean buildDungeonPocket(DungeonData dungeon, NewDimData dimension, DimLink link, DungeonSchematic schematic, World world, DDProperties properties)
|
private static boolean buildDungeonPocket(DungeonData dungeon, NewDimData dimension, DimLink link, DungeonSchematic schematic, World world, DDProperties properties)
|
||||||
{
|
{
|
||||||
//Calculate the destination point
|
//Calculate the destination point
|
||||||
|
|
|
@ -68,6 +68,9 @@ public class ClientPacketHandler implements IPacketHandler, IUpdateSource
|
||||||
case PacketConstants.DELETE_LINK_PACKET_ID:
|
case PacketConstants.DELETE_LINK_PACKET_ID:
|
||||||
linkWatcher.onDeleted( ClientLinkData.read(input) );
|
linkWatcher.onDeleted( ClientLinkData.read(input) );
|
||||||
break;
|
break;
|
||||||
|
case PacketConstants.UPDATE_LINK_PACKET_ID:
|
||||||
|
linkWatcher.update( ClientLinkData.read(input) );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
package StevenDimDoors.mod_pocketDimClient;
|
package StevenDimDoors.mod_pocketDimClient;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import StevenDimDoors.mod_pocketDim.CommonProxy;
|
import StevenDimDoors.mod_pocketDim.CommonProxy;
|
||||||
|
import StevenDimDoors.mod_pocketDim.blocks.BaseDimDoor;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
import StevenDimDoors.mod_pocketDim.ticking.MobMonolith;
|
import StevenDimDoors.mod_pocketDim.ticking.MobMonolith;
|
||||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
|
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
|
||||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityTransTrapdoor;
|
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityTransTrapdoor;
|
||||||
|
import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
|
||||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||||
|
|
||||||
|
@ -24,9 +30,18 @@ public class ClientProxy extends CommonProxy
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadTextures()
|
public void updateDoorTE(BaseDimDoor door, World world, int x, int y, int z)
|
||||||
{
|
{
|
||||||
|
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||||
|
if (tile instanceof TileEntityDimDoor)
|
||||||
|
{
|
||||||
|
DimLink link = PocketManager.getLink(x, y, z, world);
|
||||||
|
int metadata = world.getBlockMetadata(x, y, z);
|
||||||
|
TileEntityDimDoor dimTile = (TileEntityDimDoor) tile;
|
||||||
|
dimTile.openOrClosed = door.isDoorOnRift(world, x, y, z)&&door.isUpperDoorBlock(metadata);
|
||||||
|
dimTile.orientation = door.getFullMetadata(world, x, y, z) & 7;
|
||||||
|
dimTile.lockStatus = door.getLockStatus(world, x, y, z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -315,15 +315,13 @@ public class RenderDimDoor extends TileEntitySpecialRenderer
|
||||||
if(i==1)
|
if(i==1)
|
||||||
{
|
{
|
||||||
bindTexture(KeyholeLight);
|
bindTexture(KeyholeLight);
|
||||||
GL11.glColor4d(1, 1, 1, .6);
|
GL11.glColor4d(1, 1, 1, .7);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_DST_COLOR);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_DST_COLOR);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bindTexture(keyPath);
|
bindTexture(keyPath);
|
||||||
GL11.glColor4d(.0, .7, .1, 1);
|
|
||||||
|
|
||||||
glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);
|
glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -365,12 +363,17 @@ public class RenderDimDoor extends TileEntitySpecialRenderer
|
||||||
|
|
||||||
if (tile.openOrClosed)
|
if (tile.openOrClosed)
|
||||||
{
|
{
|
||||||
|
|
||||||
renderDimDoorTileEntity((TileEntityDimDoor) par1TileEntity, par2, par4, par6);
|
renderDimDoorTileEntity((TileEntityDimDoor) par1TileEntity, par2, par4, par6);
|
||||||
for(int i = 0; i<2; i++ )
|
if(tile.lockStatus>=1)
|
||||||
{
|
{
|
||||||
this.renderKeyHole(tile, par2, par4, par6, i);
|
for(int i = 0; i<1+tile.lockStatus; i++ )
|
||||||
|
{
|
||||||
|
this.renderKeyHole(tile, par2, par4, par6, i);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package StevenDimDoors.mod_pocketDimClient;
|
||||||
|
|
||||||
|
public class TESyncHandler
|
||||||
|
{
|
||||||
|
public void onServerChanges()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClientChanges()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClientData()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onServerData()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
BIN
src/main/resources/assets/dimdoors/sound/doorLocked.mp3
Normal file
BIN
src/main/resources/assets/dimdoors/sound/doorLocked.mp3
Normal file
Binary file not shown.
BIN
src/main/resources/assets/dimdoors/sound/doorLocked.ogg
Normal file
BIN
src/main/resources/assets/dimdoors/sound/doorLocked.ogg
Normal file
Binary file not shown.
BIN
src/main/resources/assets/dimdoors/sound/keyLock.mp3
Normal file
BIN
src/main/resources/assets/dimdoors/sound/keyLock.mp3
Normal file
Binary file not shown.
BIN
src/main/resources/assets/dimdoors/sound/keyLock.ogg
Normal file
BIN
src/main/resources/assets/dimdoors/sound/keyLock.ogg
Normal file
Binary file not shown.
BIN
src/main/resources/assets/dimdoors/sound/keyUnlock.mp3
Normal file
BIN
src/main/resources/assets/dimdoors/sound/keyUnlock.mp3
Normal file
Binary file not shown.
BIN
src/main/resources/assets/dimdoors/sound/keyUnlock.ogg
Normal file
BIN
src/main/resources/assets/dimdoors/sound/keyUnlock.ogg
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/main/resources/assets/dimdoors/textures/items/itemDDKey.png
Normal file
BIN
src/main/resources/assets/dimdoors/textures/items/itemDDKey.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Loading…
Add table
Reference in a new issue