diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/CommonProxy.java b/src/main/java/StevenDimDoors/mod_pocketDim/CommonProxy.java index ada7b95b..952b7965 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/CommonProxy.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/CommonProxy.java @@ -1,11 +1,14 @@ package StevenDimDoors.mod_pocketDim; import java.io.File; 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.player.EntityPlayer; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import cpw.mods.fml.common.FMLCommonHandler; 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); + } + } + + } \ No newline at end of file diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/CraftingManager.java b/src/main/java/StevenDimDoors/mod_pocketDim/CraftingManager.java index 063fa44a..07b14bb8 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/CraftingManager.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/CraftingManager.java @@ -1,6 +1,7 @@ package StevenDimDoors.mod_pocketDim; import StevenDimDoors.mod_pocketDim.config.DDProperties; +import StevenDimDoors.mod_pocketDim.core.DDLock; import StevenDimDoors.mod_pocketDim.core.DimLink; import StevenDimDoors.mod_pocketDim.items.ItemDDKey; 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()); player.inventory.addItemStackToInventory(topKey); } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java b/src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java index 9f7fd0c5..be2125e5 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java @@ -59,6 +59,9 @@ public class EventHookContainer @ForgeSubscribe 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 + ":crack.ogg"); event.manager.addSound(mod_pocketDim.modid + ":tearing.ogg"); diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/PacketConstants.java b/src/main/java/StevenDimDoors/mod_pocketDim/PacketConstants.java index cc172083..ec8e45cf 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/PacketConstants.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/PacketConstants.java @@ -12,5 +12,6 @@ public class PacketConstants public static final byte CREATE_LINK_PACKET_ID = 4; public static final byte DELETE_LINK_PACKET_ID = 5; public static final byte CLIENT_LOGIN_DIM_REGISTER = 6; + public static final byte UPDATE_LINK_PACKET_ID = 7; } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/ServerPacketHandler.java b/src/main/java/StevenDimDoors/mod_pocketDim/ServerPacketHandler.java index ed756a70..7ad11f93 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/ServerPacketHandler.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/ServerPacketHandler.java @@ -38,6 +38,13 @@ public class ServerPacketHandler implements IPacketHandler public void onDeleted(ClientDimData 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); } + + @Override + public void update(ClientLinkData message) + { + sendLinkPacket(PacketConstants.UPDATE_LINK_PACKET_ID, message); + } } public static Packet250CustomPayload createLinkPacket(ClientLinkData data) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java index 131cc3c3..9b1d8781 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java @@ -181,14 +181,7 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn //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) - { - 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; - } + mod_pocketDim.proxy.updateDoorTE(this, world, x, y, z); return this; } @@ -353,7 +346,7 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn 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); 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; } - - 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); - 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) { 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) { - 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; } - if(player == null) - { - return false; - } - DimLink link = getLink(world, x, y, z); - for(ItemStack item : player.inventory.mainInventory) { if(item != null) { if(item.getItem() instanceof ItemDDKey) { - if(((ItemDDKey) item.getItem()).canKeyOpen(link, item)) + if(link.open(item)) { return true; } } } } + player.playSound(mod_pocketDim.modid + ":doorLocked", 1F, 1F); return false; } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/TransTrapdoor.java b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/TransTrapdoor.java index 30d74ef1..f4d8746d 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/TransTrapdoor.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/TransTrapdoor.java @@ -8,6 +8,8 @@ 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.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; 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.NewDimData; import StevenDimDoors.mod_pocketDim.core.PocketManager; +import StevenDimDoors.mod_pocketDim.items.ItemDDKey; import StevenDimDoors.mod_pocketDim.tileentities.TileEntityTransTrapdoor; 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); } + 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 public void enterDimDoor(World world, int x, int y, int z, Entity entity) { diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/WarpDoor.java b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/WarpDoor.java index 6f7d881b..58cfd05e 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/WarpDoor.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/WarpDoor.java @@ -9,7 +9,6 @@ import StevenDimDoors.mod_pocketDim.core.LinkTypes; import StevenDimDoors.mod_pocketDim.core.NewDimData; import StevenDimDoors.mod_pocketDim.core.PocketManager; -@SuppressWarnings("deprecation") public class WarpDoor extends BaseDimDoor { public WarpDoor(int blockID, Material material, DDProperties properties) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/commands/CommandResetDungeons.java b/src/main/java/StevenDimDoors/mod_pocketDim/commands/CommandResetDungeons.java index 0e1d5e28..81765371 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/commands/CommandResetDungeons.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/commands/CommandResetDungeons.java @@ -62,11 +62,11 @@ public class CommandResetDungeons extends DDCommandBase { 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) { - data.createLink(link.source(), LinkTypes.DUNGEON, link.orientation(), false); + data.createLink(link.source(), LinkTypes.DUNGEON, link.orientation(), null); } } } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/core/DDLock.java b/src/main/java/StevenDimDoors/mod_pocketDim/core/DDLock.java new file mode 100644 index 00000000..3b00196b --- /dev/null +++ b/src/main/java/StevenDimDoors/mod_pocketDim/core/DDLock.java @@ -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); + + + } + +} diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java b/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java index b85f31c9..c34814b5 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java @@ -485,7 +485,7 @@ public class DDTeleporter { 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 { diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/core/DimLink.java b/src/main/java/StevenDimDoors/mod_pocketDim/core/DimLink.java index ccbd2b3d..e4c9c940 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/core/DimLink.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/core/DimLink.java @@ -2,20 +2,20 @@ package StevenDimDoors.mod_pocketDim.core; import java.util.LinkedList; 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.watcher.ClientLinkData; public abstract class DimLink { protected Point4D point; protected int orientation; - protected boolean isLocked; + private DDLock lock; protected DimLink parent; protected LinkTail tail; protected List 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()) @@ -23,26 +23,25 @@ public abstract class DimLink // 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.lock = lock; this.parent = parent; this.point = point; this.tail = parent.tail; this.orientation = orientation; - this.isLocked = locked; this.children = new LinkedList(); 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) { throw new IllegalArgumentException("The specified link type is invalid."); } - + this.lock = lock; this.parent = null; this.point = point; this.orientation = orientation; - this.isLocked = locked; this.tail = new LinkTail(linkType, null); this.children = new LinkedList(); } @@ -115,18 +114,63 @@ public abstract class DimLink return tail.getLinkType(); } - public boolean isLocked() - { - return isLocked; - } - public void setLocked(boolean bol) - { - isLocked = bol; - } - public String toString() { 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; + } + } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/core/NewDimData.java b/src/main/java/StevenDimDoors/mod_pocketDim/core/NewDimData.java index 03b89b0d..eef34325 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/core/NewDimData.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/core/NewDimData.java @@ -24,14 +24,14 @@ public abstract class NewDimData implements IPackable { 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) @@ -99,7 +99,6 @@ public abstract class NewDimData implements IPackable this.orientation=orientation; } } - protected static Random random = new Random(); protected int id; @@ -279,10 +278,10 @@ public abstract class NewDimData implements IPackable 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. InnerDimLink link = linkMapping.get(source); @@ -308,10 +307,10 @@ public abstract class NewDimData implements IPackable 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 //its destination data instead of creating a new instance. @@ -584,6 +583,11 @@ public abstract class NewDimData implements IPackable return modified; } + public void flagModified() + { + modified = true; + } + public void clearModified() { this.modified = false; @@ -651,7 +655,7 @@ public abstract class NewDimData implements IPackable children.add(childLink.source().toPoint3D()); } 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()); if(Tails.contains(tempTail)) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/core/PocketManager.java b/src/main/java/StevenDimDoors/mod_pocketDim/core/PocketManager.java index d2ee19f8..10d9c612 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/core/PocketManager.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/core/PocketManager.java @@ -7,32 +7,25 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; 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.WorldServer; import net.minecraftforge.common.DimensionManager; -import StevenDimDoors.mod_pocketDim.Point3D; import StevenDimDoors.mod_pocketDim.mod_pocketDim; import StevenDimDoors.mod_pocketDim.config.DDProperties; 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.ClientLinkData; import StevenDimDoors.mod_pocketDim.watcher.IUpdateSource; import StevenDimDoors.mod_pocketDim.watcher.IUpdateWatcher; 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. @@ -40,7 +33,7 @@ import StevenDimDoors.mod_pocketDim.watcher.UpdateWatcherProxy; * well as loading old dimensions on startup */ public class PocketManager -{ +{ private static class InnerDimData extends NewDimData { // This class allows us to instantiate NewDimData indirectly without exposing @@ -69,7 +62,7 @@ public class PocketManager { Point4D source = link.point; 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 @@ -78,7 +71,17 @@ public class PocketManager Point4D source = link.point; NewDimData dimension = getDimensionData(source.getDimension()); 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 @@ -94,6 +97,12 @@ public class PocketManager { deletePocket(getDimensionData(data.ID), false); } + + @Override + public void update(ClientDimData message) + { + // TODO Auto-generated method stub + } } private static class DimRegistrationCallback implements IDimRegistrationCallback @@ -633,4 +642,9 @@ public class PocketManager { return dimWatcher; } + + public static UpdateWatcherProxy getLinkWatcher() + { + return linkWatcher; + } } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/helpers/Compactor.java b/src/main/java/StevenDimDoors/mod_pocketDim/helpers/Compactor.java index 1f3d0c99..4fdaa9e2 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/helpers/Compactor.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/helpers/Compactor.java @@ -80,7 +80,7 @@ public class Compactor { ClientLinkData link = ClientLinkData.read(input); 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); } } } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/items/ItemDDKey.java b/src/main/java/StevenDimDoors/mod_pocketDim/items/ItemDDKey.java index 7a74d6a0..bfb2de85 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/items/ItemDDKey.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/items/ItemDDKey.java @@ -17,8 +17,10 @@ import net.minecraft.util.StatCollector; import net.minecraft.world.World; import StevenDimDoors.mod_pocketDim.mod_pocketDim; import StevenDimDoors.mod_pocketDim.blocks.IDimDoor; +import StevenDimDoors.mod_pocketDim.core.DDLock; import StevenDimDoors.mod_pocketDim.core.DimLink; import StevenDimDoors.mod_pocketDim.core.PocketManager; +import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData; 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) { - boolean check = (this.isBound(par1ItemStack) ? par3List.add("Bound") : par3List.add("Unbound")); - return; + if(DDLock.hasCreatedLock(par1ItemStack)) + { + par3List.add("Bound"); + } + else + { + par3List.add("Unbound"); + } } @@ -47,7 +55,7 @@ public class ItemDDKey extends Item @SideOnly(Side.CLIENT) 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, @@ -70,162 +78,40 @@ public class ItemDDKey extends Item { 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; - } - - public boolean setBoundDoor(ItemStack itemStack, DimLink link) - { - //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())) + //what to do if the door has a lock already + if(link.hasLock()) { - return false; - } - - //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 private PackedLinkData createLinkDataFromJson(JsonReader reader) throws IOException { - boolean locked = false; + DDLock lock = null; Point4D source; Point3D parent; @@ -235,13 +236,11 @@ public class DimDataProcessor extends BaseConfigurationProcessor if(reader.peek()== JsonToken.NAME) { - reader.nextName(); - locked = reader.nextBoolean(); - + lock = this.createLockFromJson(reader); } 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 { @@ -307,4 +306,21 @@ public class DimDataProcessor extends BaseConfigurationProcessor 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); + } + } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/saving/OldSaveImporter.java b/src/main/java/StevenDimDoors/mod_pocketDim/saving/OldSaveImporter.java index 6ddcb9f9..13ae45a4 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/saving/OldSaveImporter.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/saving/OldSaveImporter.java @@ -80,7 +80,7 @@ public class OldSaveImporter PackedLinkTail tail = new PackedLinkTail(destintion, link.linkOrientation); List children = new ArrayList(); - 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); allPackedLinks.add(newPackedLink); diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/saving/PackedDimData.java b/src/main/java/StevenDimDoors/mod_pocketDim/saving/PackedDimData.java index fb058d3d..60a033d0 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/saving/PackedDimData.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/saving/PackedDimData.java @@ -49,4 +49,6 @@ public class PackedDimData { return "ID= "+this.ID; } + + } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/saving/PackedLinkData.java b/src/main/java/StevenDimDoors/mod_pocketDim/saving/PackedLinkData.java index 0cd62d66..d08ca0f9 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/saving/PackedLinkData.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/saving/PackedLinkData.java @@ -3,6 +3,7 @@ package StevenDimDoors.mod_pocketDim.saving; import java.util.List; import StevenDimDoors.mod_pocketDim.Point3D; +import StevenDimDoors.mod_pocketDim.core.DDLock; import StevenDimDoors.mod_pocketDim.util.Point4D; public class PackedLinkData @@ -12,15 +13,15 @@ public class PackedLinkData public final PackedLinkTail tail; public final int orientation; public final List children; - public final boolean locked; + public final DDLock lock; - public PackedLinkData(Point4D source, Point3D parent, PackedLinkTail tail, int orientation, List children, boolean locked) + public PackedLinkData(Point4D source, Point3D parent, PackedLinkTail tail, int orientation, List children, DDLock lock) { this.source=source; this.parent=parent; this.tail=tail; this.orientation=orientation; this.children=children; - this.locked = locked; + this.lock = lock; } } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityDimDoor.java b/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityDimDoor.java index 638c1a86..e566f63b 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityDimDoor.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityDimDoor.java @@ -19,6 +19,7 @@ public class TileEntityDimDoor extends DDTileEntityBase public boolean openOrClosed; public int orientation; public boolean hasExit; + public byte lockStatus; public boolean isDungeonChainLink; public boolean hasGennedPair=false; diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/watcher/ClientLinkData.java b/src/main/java/StevenDimDoors/mod_pocketDim/watcher/ClientLinkData.java index daa7aa92..34b7274e 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/watcher/ClientLinkData.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/watcher/ClientLinkData.java @@ -3,43 +3,53 @@ package StevenDimDoors.mod_pocketDim.watcher; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; - +import StevenDimDoors.mod_pocketDim.core.DDLock; import StevenDimDoors.mod_pocketDim.core.DimLink; import StevenDimDoors.mod_pocketDim.util.Point4D; public class ClientLinkData { - public Point4D point; - public int orientation; - public boolean isLocked; - - public ClientLinkData(DimLink link) - { - this.point= link.source(); - this.orientation=link.orientation(); - this.isLocked = link.isLocked(); - } - - public ClientLinkData(Point4D point, int orientation, boolean isLocked) - { - this.point = point; - this.orientation=orientation; - this.isLocked = isLocked; - } - - public void write(DataOutputStream output) throws IOException - { - Point4D.write(point, output); - output.writeInt(orientation); - output.writeBoolean(isLocked); - } - - public static ClientLinkData read(DataInputStream input) throws IOException - { - Point4D point = Point4D.read(input); - int orientation = input.readInt(); - boolean isLocked = input.readBoolean(); - return new ClientLinkData(point, orientation, isLocked); - } - + public Point4D point; + public DDLock lock; + + public ClientLinkData(DimLink link) + { + this.point = link.source(); + if (link.hasLock()) + { + lock = link.getLock(); + } + } + + public ClientLinkData(Point4D point, DDLock lock) + { + this.point = point; + this.lock = lock; + + } + + public void write(DataOutputStream output) throws IOException + { + Point4D.write(point, output); + + boolean hasLock = this.lock != null; + output.writeBoolean(hasLock); + + if (hasLock) + { + output.writeBoolean(lock.isLocked()); + output.writeInt(lock.getLockKey()); + } + } + + 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); + } } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/watcher/IUpdateWatcher.java b/src/main/java/StevenDimDoors/mod_pocketDim/watcher/IUpdateWatcher.java index eb8f9206..5e3cd047 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/watcher/IUpdateWatcher.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/watcher/IUpdateWatcher.java @@ -3,5 +3,6 @@ package StevenDimDoors.mod_pocketDim.watcher; public interface IUpdateWatcher { public void onCreated(T message); + public void update(T message); public void onDeleted(T message); } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/watcher/UpdateWatcherProxy.java b/src/main/java/StevenDimDoors/mod_pocketDim/watcher/UpdateWatcherProxy.java index e105476b..99811694 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/watcher/UpdateWatcherProxy.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/watcher/UpdateWatcherProxy.java @@ -39,4 +39,13 @@ public class UpdateWatcherProxy implements IUpdateWatcher { return watchers.remove(receiver); } + + @Override + public void update(T message) + { + for (IUpdateWatcher receiver : watchers) + { + receiver.update(message); + } + } } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/world/PocketBuilder.java b/src/main/java/StevenDimDoors/mod_pocketDim/world/PocketBuilder.java index 4d2d3a1f..7b9ed43a 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/world/PocketBuilder.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/world/PocketBuilder.java @@ -40,87 +40,6 @@ public class 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) { //Calculate the destination point diff --git a/src/main/java/StevenDimDoors/mod_pocketDimClient/ClientPacketHandler.java b/src/main/java/StevenDimDoors/mod_pocketDimClient/ClientPacketHandler.java index b9057f40..eda68a48 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDimClient/ClientPacketHandler.java +++ b/src/main/java/StevenDimDoors/mod_pocketDimClient/ClientPacketHandler.java @@ -68,6 +68,9 @@ public class ClientPacketHandler implements IPacketHandler, IUpdateSource case PacketConstants.DELETE_LINK_PACKET_ID: linkWatcher.onDeleted( ClientLinkData.read(input) ); break; + case PacketConstants.UPDATE_LINK_PACKET_ID: + linkWatcher.update( ClientLinkData.read(input) ); + break; } } catch (Exception e) diff --git a/src/main/java/StevenDimDoors/mod_pocketDimClient/ClientProxy.java b/src/main/java/StevenDimDoors/mod_pocketDimClient/ClientProxy.java index 26340c81..59bb2a87 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDimClient/ClientProxy.java +++ b/src/main/java/StevenDimDoors/mod_pocketDimClient/ClientProxy.java @@ -1,8 +1,14 @@ package StevenDimDoors.mod_pocketDimClient; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; 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.tileentities.TileEntityDimDoor; 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.RenderingRegistry; @@ -24,9 +30,18 @@ public class ClientProxy extends CommonProxy } @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 diff --git a/src/main/java/StevenDimDoors/mod_pocketDimClient/RenderDimDoor.java b/src/main/java/StevenDimDoors/mod_pocketDimClient/RenderDimDoor.java index 4e821638..195a7dac 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDimClient/RenderDimDoor.java +++ b/src/main/java/StevenDimDoors/mod_pocketDimClient/RenderDimDoor.java @@ -315,15 +315,13 @@ public class RenderDimDoor extends TileEntitySpecialRenderer if(i==1) { bindTexture(KeyholeLight); - GL11.glColor4d(1, 1, 1, .6); + GL11.glColor4d(1, 1, 1, .7); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_DST_COLOR); } - else + else { bindTexture(keyPath); - GL11.glColor4d(.0, .7, .1, 1); - glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA); } @@ -365,12 +363,17 @@ public class RenderDimDoor extends TileEntitySpecialRenderer if (tile.openOrClosed) { + 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); + } } + } } diff --git a/src/main/java/StevenDimDoors/mod_pocketDimClient/TESyncHandler.java b/src/main/java/StevenDimDoors/mod_pocketDimClient/TESyncHandler.java new file mode 100644 index 00000000..5e7f4651 --- /dev/null +++ b/src/main/java/StevenDimDoors/mod_pocketDimClient/TESyncHandler.java @@ -0,0 +1,25 @@ +package StevenDimDoors.mod_pocketDimClient; + +public class TESyncHandler +{ + public void onServerChanges() + { + + } + + public void onClientChanges() + { + + } + + public void onClientData() + { + + } + + public void onServerData() + { + + } + +} diff --git a/src/main/resources/assets/dimdoors/sound/doorLocked.mp3 b/src/main/resources/assets/dimdoors/sound/doorLocked.mp3 new file mode 100644 index 00000000..79bbc6aa Binary files /dev/null and b/src/main/resources/assets/dimdoors/sound/doorLocked.mp3 differ diff --git a/src/main/resources/assets/dimdoors/sound/doorLocked.ogg b/src/main/resources/assets/dimdoors/sound/doorLocked.ogg new file mode 100644 index 00000000..19c104c8 Binary files /dev/null and b/src/main/resources/assets/dimdoors/sound/doorLocked.ogg differ diff --git a/src/main/resources/assets/dimdoors/sound/keyLock.mp3 b/src/main/resources/assets/dimdoors/sound/keyLock.mp3 new file mode 100644 index 00000000..ae52ae92 Binary files /dev/null and b/src/main/resources/assets/dimdoors/sound/keyLock.mp3 differ diff --git a/src/main/resources/assets/dimdoors/sound/keyLock.ogg b/src/main/resources/assets/dimdoors/sound/keyLock.ogg new file mode 100644 index 00000000..c63ede2c Binary files /dev/null and b/src/main/resources/assets/dimdoors/sound/keyLock.ogg differ diff --git a/src/main/resources/assets/dimdoors/sound/keyUnlock.mp3 b/src/main/resources/assets/dimdoors/sound/keyUnlock.mp3 new file mode 100644 index 00000000..78451467 Binary files /dev/null and b/src/main/resources/assets/dimdoors/sound/keyUnlock.mp3 differ diff --git a/src/main/resources/assets/dimdoors/sound/keyUnlock.ogg b/src/main/resources/assets/dimdoors/sound/keyUnlock.ogg new file mode 100644 index 00000000..910bee5e Binary files /dev/null and b/src/main/resources/assets/dimdoors/sound/keyUnlock.ogg differ diff --git a/src/main/resources/assets/dimdoors/sound/monkLarge.ogg b/src/main/resources/assets/dimdoors/sound/monkLarge.ogg deleted file mode 100644 index 73e69b47..00000000 Binary files a/src/main/resources/assets/dimdoors/sound/monkLarge.ogg and /dev/null differ diff --git a/src/main/resources/assets/dimdoors/textures/items/itemDDKey.png b/src/main/resources/assets/dimdoors/textures/items/itemDDKey.png new file mode 100644 index 00000000..e2f0a749 Binary files /dev/null and b/src/main/resources/assets/dimdoors/textures/items/itemDDKey.png differ diff --git a/src/main/resources/assets/dimdoors/textures/other/keyhole.png b/src/main/resources/assets/dimdoors/textures/other/keyhole.png index 262a8e5e..7bb3ea32 100644 Binary files a/src/main/resources/assets/dimdoors/textures/other/keyhole.png and b/src/main/resources/assets/dimdoors/textures/other/keyhole.png differ