Rewrite #79

Merged
StevenRS11 merged 14 commits from rewrite into DevBranch 2013-09-02 02:17:17 +00:00
67 changed files with 1921 additions and 3539 deletions

View File

@@ -1,11 +1,7 @@
package StevenDimDoors.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.Teleporter;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
public class BlankTeleporter extends Teleporter

View File

@@ -1,10 +1,7 @@
package StevenDimDoors.mod_pocketDim;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import StevenDimDoors.mod_pocketDimClient.ClientTickHandler;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.CompressedStreamTools;
@@ -47,7 +44,6 @@ public class CommonProxy implements IGuiHandler
public void writeNBTToFile(World world)
{
boolean flag = true;
boolean secondTry = false;
try
{
@@ -58,7 +54,6 @@ public class CommonProxy implements IGuiHandler
if (!flag)
{
dirFolder.replace("saves/", FMLCommonHandler.instance().getMinecraftServerInstance().getFolderName());
secondTry = true;
}
File file = new File(dirFolder, "GGMData.dat");
@@ -91,7 +86,6 @@ public class CommonProxy implements IGuiHandler
public void readNBTFromFile(World world)
{
boolean flag = true;
boolean secondTry = false;
try
{
@@ -102,7 +96,6 @@ public class CommonProxy implements IGuiHandler
if (!flag)
{
dirFolder.replace("saves/", FMLCommonHandler.instance().getMinecraftServerInstance().getFolderName());
secondTry = true;
}
File file = new File(dirFolder, "GGMData.dat");
@@ -117,12 +110,9 @@ public class CommonProxy implements IGuiHandler
fileoutputstream.close();
}
FileInputStream fileinputstream = new FileInputStream(file);
/*FileInputStream fileinputstream = new FileInputStream(file);
NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(fileinputstream);
fileinputstream.close();
fileinputstream.close();*/
}
catch (Exception exception)
{

View File

@@ -1,62 +1,62 @@
package StevenDimDoors.mod_pocketDim;
import java.util.ArrayList;
import java.util.Collection;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.NetLoginHandler;
import net.minecraft.network.packet.NetHandler;
import net.minecraft.network.packet.Packet1Login;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.server.MinecraftServer;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.watcher.IOpaqueMessage;
import cpw.mods.fml.common.network.IConnectionHandler;
import cpw.mods.fml.common.network.Player;
public class ConnectionHandler implements IConnectionHandler
public class ConnectionHandler implements IConnectionHandler
{
private static boolean connected = false;
private static DDProperties properties = null;
//sends a packet to clients containing all the information about the dims and links. Lots of packets, actually.
@Override
public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager)
{
if (properties == null)
properties = DDProperties.instance();
PacketHandler.onClientJoinPacket(manager, PocketManager.dimList);
PacketHandler.onDimCreatedPacket(new NewDimData(properties.LimboDimensionID, false, 0, 0, 0, 0, 0));
return null;
}
@Override
public void connectionOpened(NetHandler netClientHandler, String server,int port, INetworkManager manager)
{
connected = true;
}
public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager) { }
@Override
public void connectionOpened(NetHandler netClientHandler,MinecraftServer server, INetworkManager manager) { }
@Override
public void connectionClosed(INetworkManager manager)
{
if (connected)
{
System.out.println("Clearing dim cache");
PocketManager.instance.save();
PocketManager.instance.unregsisterDims();
PocketManager.dimList.clear();
}
connected = false;
}
public void connectionClosed(INetworkManager manager) { }
@Override
public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login) { }
@Override
public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager) { }
public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager)
{
//Send information about all the registered dimensions and links to the client
try
{
IOpaqueMessage message = PocketManager.getState();
Packet250CustomPayload packet = new Packet250CustomPayload();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream writer = new DataOutputStream(buffer);
writer.writeByte(PacketConstants.CLIENT_JOIN_PACKET_ID);
message.writeToStream(writer);
writer.close();
packet.channel = PacketConstants.CHANNEL_NAME;
packet.data = buffer.toByteArray();
packet.length = packet.data.length;
manager.addToSendQueue(packet);
}
catch (IOException e)
{
//This shouldn't happen...
e.printStackTrace();
}
}
}

View File

@@ -56,7 +56,7 @@ public class DDProperties
* Crafting Flags
*/
public final boolean CraftingDimensionaDoorAllowed;
public final boolean CraftingDimensionalDoorAllowed;
public final boolean CraftingWarpDoorAllowed;
public final boolean CraftingRiftSignatureAllowed;
public final boolean CraftingRiftRemoverAllowed;
@@ -129,7 +129,7 @@ public class DDProperties
Configuration config = new Configuration(configFile);
config.load();
CraftingDimensionaDoorAllowed = config.get(CATEGORY_CRAFTING, "Allow Crafting Dimensional Door", true).getBoolean(true);
CraftingDimensionalDoorAllowed = config.get(CATEGORY_CRAFTING, "Allow Crafting Dimensional Door", true).getBoolean(true);
CraftingWarpDoorAllowed = config.get(CATEGORY_CRAFTING, "Allow Crafting Warp Door", true).getBoolean(true);
CraftingUnstableDoorAllowed = config.get(CATEGORY_CRAFTING, "Allow Crafting Unstable Door", true).getBoolean(true);
CraftingTransTrapdoorAllowed = config.get(CATEGORY_CRAFTING, "Allow Crafting Transdimensional Trapdoor", true).getBoolean(true);

View File

@@ -1,7 +1,7 @@
package StevenDimDoors.mod_pocketDim;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import java.util.Random;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.item.EntityMinecart;
@@ -19,36 +19,27 @@ import net.minecraftforge.common.DimensionManager;
import StevenDimDoors.mod_pocketDim.core.IDimLink;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.util.Point4D;
import StevenDimDoors.mod_pocketDim.world.PocketBuilder;
import cpw.mods.fml.common.registry.GameRegistry;
public class DDTeleporter
{
private static final Random random = new Random();
public static int cooldown = 0;
private DDTeleporter() { }
/**
* Create a new portal near an entity.
*/
public static void placeInPortal(Entity par1Entity, WorldServer world, IDimLink link)
private static void placeInPortal(Entity entity, WorldServer world, Point4D destination, DDProperties properties)
{
Point4D destination = link.destination();
int x = destination.getX();
int y = destination.getY();
int z = destination.getZ();
//TODO Temporary workaround for mismatched door/rift metadata cases. Gives priority to the door.
int orientation = PocketManager.getDestinationOrientation(link);
int receivingDoorMeta = world.getBlockMetadata(x, y - 1, z);
int receivingDoorID = world.getBlockId(x, y, z);
if (receivingDoorMeta != orientation)
{
if (receivingDoorID == mod_pocketDim.dimDoor.blockID || receivingDoorID == mod_pocketDim.ExitDoor.blockID)
{
orientation = receivingDoorMeta;
}
}
int orientation = getDestinationOrientation(destination, properties);
if (par1Entity instanceof EntityPlayer)
if (entity instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) par1Entity;
EntityPlayer player = (EntityPlayer) entity;
player.rotationYaw=(orientation*90)+90;
if(orientation==2||orientation==6)
{
@@ -71,65 +62,65 @@ public class DDTeleporter
player.setPositionAndUpdate(x, y-1, z);
}
}
else if (par1Entity instanceof EntityMinecart)
else if (entity instanceof EntityMinecart)
{
par1Entity.motionX=0;
par1Entity.motionZ=0;
par1Entity.motionY=0;
par1Entity.rotationYaw=(orientation*90)+90;
entity.motionX=0;
entity.motionZ=0;
entity.motionY=0;
entity.rotationYaw=(orientation*90)+90;
if(orientation==2||orientation==6)
{
DDTeleporter.setEntityPosition(par1Entity, x+1.5, y, z+.5 );
par1Entity.motionX =.39;
par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false);
DDTeleporter.setEntityPosition(entity, x+1.5, y, z+.5 );
entity.motionX =.39;
entity.worldObj.updateEntityWithOptionalForce(entity, false);
}
else if(orientation==3||orientation==7)
{
DDTeleporter.setEntityPosition(par1Entity, x+.5, y, z+1.5 );
par1Entity.motionZ =.39;
par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false);
DDTeleporter.setEntityPosition(entity, x+.5, y, z+1.5 );
entity.motionZ =.39;
entity.worldObj.updateEntityWithOptionalForce(entity, false);
}
else if(orientation==0||orientation==4)
{
DDTeleporter.setEntityPosition(par1Entity,x-.5, y, z+.5);
par1Entity.motionX =-.39;
par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false);
DDTeleporter.setEntityPosition(entity,x-.5, y, z+.5);
entity.motionX =-.39;
entity.worldObj.updateEntityWithOptionalForce(entity, false);
}
else if(orientation==1||orientation==5)
{
DDTeleporter.setEntityPosition(par1Entity,x+.5, y, z-.5);
par1Entity.motionZ =-.39;
par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false);
DDTeleporter.setEntityPosition(entity,x+.5, y, z-.5);
entity.motionZ =-.39;
entity.worldObj.updateEntityWithOptionalForce(entity, false);
}
else
{
DDTeleporter.setEntityPosition(par1Entity,x, y, z);
DDTeleporter.setEntityPosition(entity,x, y, z);
}
}
else if (par1Entity instanceof Entity)
else if (entity instanceof Entity)
{
par1Entity.rotationYaw=(orientation*90)+90;
entity.rotationYaw=(orientation*90)+90;
if(orientation==2||orientation==6)
{
DDTeleporter.setEntityPosition(par1Entity, x+1.5, y, z+.5 );
DDTeleporter.setEntityPosition(entity, x+1.5, y, z+.5 );
}
else if(orientation==3||orientation==7)
{
DDTeleporter.setEntityPosition(par1Entity, x+.5, y, z+1.5 );
DDTeleporter.setEntityPosition(entity, x+.5, y, z+1.5 );
}
else if(orientation==0||orientation==4)
{
DDTeleporter.setEntityPosition(par1Entity,x-.5, y, z+.5);
DDTeleporter.setEntityPosition(entity,x-.5, y, z+.5);
}
else if(orientation==1||orientation==5)
{
DDTeleporter.setEntityPosition(par1Entity,x+.5, y, z-.5);
DDTeleporter.setEntityPosition(entity,x+.5, y, z-.5);
}
else
{
DDTeleporter.setEntityPosition(par1Entity,x, y, z);
DDTeleporter.setEntityPosition(entity,x, y, z);
}
}
}
@@ -142,18 +133,49 @@ public class DDTeleporter
entity.setPosition(x, y, z);
}
public static Entity teleportEntity(World world, Entity entity, IDimLink link)
private static int getDestinationOrientation(Point4D door, DDProperties properties)
{
World world = DimensionManager.getWorld(door.getDimension());
if (world == null)
{
throw new IllegalStateException("The destination world should be loaded!");
}
//Check if the block at that point is actually a door
int blockID = world.getBlockId(door.getX(), door.getY(), door.getZ());
if (blockID != properties.DimensionalDoorID && blockID != properties.WarpDoorID &&
blockID != properties.TransientDoorID && blockID != properties.UnstableDoorID)
{
//Return the pocket's orientation instead
return PocketManager.getDimensionData(door.getDimension()).orientation();
}
//Return the orientation portion of its metadata
return world.getBlockMetadata(door.getX(), door.getY(), door.getZ()) & 3;
}
public static Entity teleportEntity(Entity entity, Point4D destination)
{
if (entity == null)
{
throw new IllegalArgumentException("entity cannot be null.");
}
if (destination == null)
{
throw new IllegalArgumentException("destination cannot be null.");
}
//This beautiful teleport method is based off of xCompWiz's teleport function.
WorldServer oldWorld = (WorldServer)world;
WorldServer oldWorld = (WorldServer) entity.worldObj;
WorldServer newWorld;
EntityPlayerMP player = (entity instanceof EntityPlayerMP) ? (EntityPlayerMP)entity : null;
EntityPlayerMP player = (entity instanceof EntityPlayerMP) ? (EntityPlayerMP) entity : null;
DDProperties properties = DDProperties.instance();
// Is something riding? Handle it first.
if(entity.riddenByEntity != null)
if (entity.riddenByEntity != null)
{
return teleportEntity(oldWorld, entity.riddenByEntity, link);
return teleportEntity(entity.riddenByEntity, destination);
}
// Are we riding something? Dismount and tell the mount to go first.
@@ -161,22 +183,21 @@ public class DDTeleporter
if (cart != null)
{
entity.mountEntity(null);
cart = teleportEntity(oldWorld, cart, link);
cart = teleportEntity(cart, destination);
// We keep track of both so we can remount them on the other side.
}
// Destination doesn't exist? We need to make it.
if (DimensionManager.getWorld(link.destination().getDimension()) == null)
{
//FIXME: I think this is where I need to add initialization code for pockets!!! REALLY IMPORTANT!!!
DimensionManager.initDimension(link.destination().getDimension());
}
// Determine if our destination's in another realm.
boolean difDest = link.source().getDimension() != link.destination().getDimension();
// Determine if our destination is in another realm.
boolean difDest = entity.dimension == destination.getDimension();
if (difDest)
{
newWorld = DimensionManager.getWorld(link.destination().getDimension());
// Destination isn't loaded? Then we need to load it.
newWorld = DimensionManager.getWorld(destination.getDimension());
if (newWorld == null)
{
DimensionManager.initDimension(destination.getDimension());
}
newWorld = DimensionManager.getWorld(destination.getDimension());
}
else
{
@@ -185,7 +206,7 @@ public class DDTeleporter
// GreyMaria: What is this even accomplishing? We're doing the exact same thing at the end of this all.
// TODO Check to see if this is actually vital.
DDTeleporter.placeInPortal(entity, newWorld, link);
DDTeleporter.placeInPortal(entity, newWorld, destination, properties);
if (difDest) // Are we moving our target to a new dimension?
{
@@ -194,7 +215,7 @@ public class DDTeleporter
// We need to do all this special stuff to move a player between dimensions.
// Set the new dimension and inform the client that it's moving to a new world.
player.dimension = link.destination().getDimension();
player.dimension = destination.getDimension();
player.playerNetServerHandler.sendPacketToPlayer(new Packet9Respawn(player.dimension, (byte)player.worldObj.difficultySetting, newWorld.getWorldInfo().getTerrainType(), newWorld.getHeight(), player.theItemInWorldManager.getGameType()));
// GreyMaria: Used the safe player entity remover before.
@@ -203,7 +224,7 @@ public class DDTeleporter
// for a pocket dimension, causing all sleeping players
// to remain asleep instead of progressing to day.
oldWorld.removePlayerEntityDangerously(player);
player.isDead=false;
player.isDead = false;
// Creates sanity by ensuring that we're only known to exist where we're supposed to be known to exist.
oldWorld.getPlayerManager().removePlayer(player);
@@ -243,7 +264,8 @@ public class DDTeleporter
entity = EntityList.createEntityFromNBT(entityNBT, newWorld);
if (entity == null)
{ // TODO FIXME IMPLEMENT NULL CHECKS THAT ACTUALLY DO SOMETHING.
{
// TODO FIXME IMPLEMENT NULL CHECKS THAT ACTUALLY DO SOMETHING.
/*
* shit ourselves in an organized fashion, preferably
* in a neat pile instead of all over our users' games
@@ -270,107 +292,84 @@ public class DDTeleporter
}
// Did we teleport a player? Load the chunk for them.
if(player != null)
if (player != null)
{
WorldServer.class.cast(newWorld).getChunkProvider().loadChunk(MathHelper.floor_double(entity.posX) >> 4, MathHelper.floor_double(entity.posZ) >> 4);
newWorld.getChunkProvider().loadChunk(MathHelper.floor_double(entity.posX) >> 4, MathHelper.floor_double(entity.posZ) >> 4);
// Tell Forge we're moving its players so everyone else knows.
// Let's try doing this down here in case this is what's killing NEI.
GameRegistry.onPlayerChangedDimension((EntityPlayer)entity);
}
DDTeleporter.placeInPortal(entity, newWorld, link);
DDTeleporter.placeInPortal(entity, newWorld, destination, properties);
return entity;
}
/**
* Primary function used to teleport the player using doors. Performs numerous null checks, and also generates the destination door/pocket if it has not done so already.
* Also ensures correct orientation relative to the door using DDTeleporter.
* @param world- world the player is currently in
* @param linkData- the link the player is using to teleport, sends the player to its dest information.
* @param player- the instance of the player to be teleported
* @param orientation- the orientation of the door used to teleport, determines player orientation and door placement on arrival
* @Return
* Also ensures correct orientation relative to the door.
* @param world - world the player is currently in
* @param link - the link the player is using to teleport; sends the player to its destination
* @param player - the instance of the player to be teleported
*/
public static void traverseDimDoor(World world, IDimLink linkData, Entity entity)
public static void traverseDimDoor(World world, IDimLink link, Entity entity)
{
DDProperties properties = DDProperties.instance();
if (world == null)
{
throw new IllegalArgumentException("world cannot be null.");
}
if (link == null)
{
throw new IllegalArgumentException("link cannot be null.");
}
if (entity == null)
{
throw new IllegalArgumentException("entity cannot be null.");
}
if (world.isRemote)
{
return;
}
if (linkData != null)
if (cooldown == 0 || entity instanceof EntityPlayer)
{
int destinationID = link.destination().getDimension();
if(PocketManager.dimList.containsKey(destinationID) && PocketManager.dimList.containsKey(world.provider.dimensionId))
{
this.generatePocket(linkData);
if(mod_pocketDim.teleTimer==0||entity instanceof EntityPlayer)
{
mod_pocketDim.teleTimer=2+rand.nextInt(2);
}
else
{
return;
}
if(!world.isRemote)
{
entity = this.teleportEntity(world, entity, linkData);
}
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
int playerXCoord=MathHelper.floor_double(entity.posX);
int playerYCoord=MathHelper.floor_double(entity.posY);
int playerZCoord=MathHelper.floor_double(entity.posZ);
if(!entity.worldObj.isBlockOpaqueCube(playerXCoord, playerYCoord-1,playerZCoord )&&PocketManager.instance.getDimData(linkData.locDimID).isDimRandomRift&&!linkData.hasGennedDoor)
{
for(int count=0;count<20;count++)
{
if(!entity.worldObj.isAirBlock(playerXCoord, playerYCoord-2-count,playerZCoord))
{
if(Block.blocksList[entity.worldObj.getBlockId(playerXCoord, playerYCoord-2-count,playerZCoord)].blockMaterial.isLiquid())
{
entity.worldObj.setBlock(playerXCoord, playerYCoord-1, playerZCoord, properties.FabricBlockID);
break;
}
}
if(entity.worldObj.isBlockOpaqueCube(playerXCoord, playerYCoord-1-count,playerZCoord))
{
break;
}
if(count==19)
{
entity.worldObj.setBlock(playerXCoord, playerYCoord-1, playerZCoord, properties.FabricBlockID);
}
}
}
this.generateDoor(world,linkData);
if(!entity.worldObj.isAirBlock(playerXCoord,playerYCoord+1,playerZCoord))
{
if(Block.blocksList[entity.worldObj.getBlockId(playerXCoord,playerYCoord+1,playerZCoord)].isOpaqueCube() &&
!mod_pocketDim.blockRift.isBlockImmune(entity.worldObj, playerXCoord+1,playerYCoord,playerZCoord))
{
entity.worldObj.setBlock(playerXCoord,playerYCoord+1,playerZCoord,0);
}
}
if (!entity.worldObj.isAirBlock(playerXCoord,playerYCoord,playerZCoord))
{
if(Block.blocksList[entity.worldObj.getBlockId(playerXCoord,playerYCoord,playerZCoord)].isOpaqueCube() &&
!mod_pocketDim.blockRift.isBlockImmune(entity.worldObj, playerXCoord,playerYCoord,playerZCoord))
{
entity.worldObj.setBlock(playerXCoord,playerYCoord,playerZCoord,0);
}
}
}
cooldown = 2 + random.nextInt(2);
}
else
{
return;
}
if (!initializeDestination(link, DDProperties.instance()))
{
return;
}
entity = teleportEntity(entity, link.destination());
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
}
private static boolean initializeDestination(IDimLink link, DDProperties properties)
{
//FIXME: Change this later to support rooms that have been wiped and must be regenerated.
if (link.hasDestination())
{
return true;
}
//Check the destination type and respond accordingly
//FIXME: Add missing link types.
//FIXME: Add code for restoring the destination-side door.
switch (link.linkType())
{
case IDimLink.TYPE_DUNGEON:
return PocketBuilder.generateNewDungeonPocket(link, properties);
case IDimLink.TYPE_POCKET:
return PocketBuilder.generateNewPocket(link, properties);
case IDimLink.TYPE_NORMAL:
return true;
default:
throw new IllegalArgumentException("link has an unrecognized link type.");
}
return;
}
}

View File

@@ -12,12 +12,11 @@ import cpw.mods.fml.relauncher.SideOnly;
public class EventHookContainer
{
private static DDProperties properties = null;
private final DDProperties properties;
public EventHookContainer()
public EventHookContainer(DDProperties properties)
{
if (properties == null)
properties = DDProperties.instance();
this.properties = properties;
}
@SideOnly(Side.CLIENT)
@@ -56,7 +55,7 @@ public class EventHookContainer
@ForgeSubscribe
public void onWorldsave(WorldEvent.Save event)
{
if (PocketManager.isInitialized() && event.world.provider.dimensionId == 0)
if (event.world.provider.dimensionId == 0)
{
PocketManager.save();
}

View File

@@ -0,0 +1,15 @@
package StevenDimDoors.mod_pocketDim;
public class PacketConstants
{
private PacketConstants() { }
public static final byte CLIENT_JOIN_PACKET_ID = 1;
public static final byte CREATE_DIM_PACKET_ID = 2;
public static final byte UPDATE_DIM_PACKET_ID = 3;
public static final byte DELETE_DIM_PACKET_ID = 4;
public static final byte CREATE_LINK_PACKET_ID = 5;
public static final byte UPDATE_LINK_PACKET_ID = 6;
public static final byte DELETE_LINK_PACKET_ID = 7;
public static final String CHANNEL_NAME = "DimDoorsPackets";
}

View File

@@ -1,306 +0,0 @@
package StevenDimDoors.mod_pocketDim;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
public class PacketHandler implements IPacketHandler
{
public static byte DIM_UPDATE_PACKET_ID = 1;
public static byte REGISTER_DIM_PACKET_ID = 3;
public static byte REGISTER_LINK_PACKET_ID = 4;
public static byte REMOVE_LINK_PACKET_ID = 5;
public static byte DIM_PACKET_ID = 6;
public static byte LINK_KEY_PACKET_ID = 7;
@Override
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player)
{
if (packet.channel.equals("DimDoorPackets"))
{
processPacket(packet, player);
}
}
private void processPacket(Packet250CustomPayload packet, Player player)
{
ByteArrayDataInput data = ByteStreams.newDataInput(packet.data);
int id = data.readByte();
if (id == REGISTER_DIM_PACKET_ID)
{
int dimId = data.readInt();
try
{
NewDimData dimDataToAdd = new NewDimData(dimId, data.readBoolean(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt());
if(!PocketManager.dimList.containsKey(dimId))
{
PocketManager.dimList.put(dimId, dimDataToAdd);
}
if (dimDataToAdd.isPocket)
{
DDProperties properties = DDProperties.instance();
PocketManager.registerDimension(dimId, properties.PocketProviderID);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
else if (id == REGISTER_LINK_PACKET_ID)
{
int dimId = data.readInt();
try
{
NewDimData dimDataToAddLink= PocketManager.instance.getDimData(dimId);
ILinkData linkToAdd = new ILinkData(dimId, data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readBoolean(),data.readInt());
linkToAdd.hasGennedDoor=data.readBoolean();
PocketManager.instance.createLink(linkToAdd);
}
catch (Exception e)
{
System.err.println("Tried to update client link data and failed!");
e.printStackTrace();
}
}
else if (id == REMOVE_LINK_PACKET_ID)
{
int dimId = data.readInt();
try
{
NewDimData dimDataToRemoveFrom= PocketManager.instance.getDimData(dimId);
ILinkData linkToAdd = new ILinkData(dimId, data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readBoolean(),data.readInt());
dimDataToRemoveFrom.removeLinkAtCoords(linkToAdd.locDimID, linkToAdd.locXCoord,linkToAdd.locYCoord, linkToAdd.locZCoord);
}
catch (Exception e)
{
System.out.println("Tried to update client link data & failed!");
e.printStackTrace();
}
}
else if (id == LINK_KEY_PACKET_ID)
{
ILinkData link = new ILinkData(data.readInt(), data.readInt(), data.readInt(), data.readInt());
dimHelper.PocketManager.interDimLinkList.put(data.readInt(), link);
}
}
private static void processRegisterDimPacket()
{
}
private static void processUpdateDimPacket()
{
}
private static void processRegisterLinkPacket()
{
}
private static void processRemoveLinkPacket()
{
}
public static void onClientJoinPacket(INetworkManager manager, HashMap<Integer, NewDimData> dimList)
{
Collection<Integer> dimIDs= dimList.keySet();
Collection<NewDimData> dimDataSet= dimList.values();
Collection<Packet250CustomPayload> packetsToSend = new HashSet();
for(NewDimData data : dimDataSet)
{
manager.addToSendQueue(PacketHandler.onDimCreatedPacket(data));
Collection <HashMap<Integer, HashMap<Integer, ILinkData>>> linkList = data.linksInThisDim.values();
for(HashMap map : linkList )
{
Collection <HashMap<Integer, ILinkData>> linkList2 = map.values();
for(HashMap map2 : linkList2)
{
Collection <ILinkData> linkList3 = map2.values();
for(ILinkData link : linkList3)
{
packetsToSend.add(( PacketHandler.onLinkCreatedPacket(link)));
}
}
}
}
for (Packet250CustomPayload packet : packetsToSend)
{
manager.addToSendQueue(packet);
}
}
public static void sendLinkCreatedPacket(ILinkData link)
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dataOut = new DataOutputStream(bos);
try
{
dataOut.writeByte(PacketHandler.registerLinkPacketID);
dataOut.writeInt(link.locDimID);
dataOut.writeInt(link.destDimID);
dataOut.writeInt(link.locXCoord);
dataOut.writeInt(link.locYCoord);
dataOut.writeInt(link.locZCoord);
dataOut.writeInt(link.destXCoord);
dataOut.writeInt(link.destYCoord);
dataOut.writeInt(link.destZCoord);
dataOut.writeBoolean(link.isLocPocket);
dataOut.writeInt(link.linkOrientation);
dataOut.writeBoolean(link.hasGennedDoor);
}
catch (IOException e)
{
e.printStackTrace();
}
Packet250CustomPayload packet= new Packet250CustomPayload();
packet.channel = "DimDoorPackets";
packet.data = bos.toByteArray();
packet.length = bos.size();;
PacketDispatcher.sendPacketToAllPlayers(packet);
return packet;
}
public static void sendlinkKeyPacket(ILinkData link, int key)
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dataOut = new DataOutputStream(bos);
try
{
dataOut.writeByte(PacketHandler.linkKeyPacketID);
dataOut.writeInt(link.destDimID);
dataOut.writeInt(link.destXCoord);
dataOut.writeInt(link.destYCoord);
dataOut.writeInt(link.destZCoord);
dataOut.writeInt(key);
}
catch (IOException e)
{
e.printStackTrace();
}
Packet250CustomPayload packet = new Packet250CustomPayload();
packet.channel="DimDoorPackets";
packet.data = bos.toByteArray();
packet.length = bos.size();;
PacketDispatcher.sendPacketToAllPlayers(packet);
}
public static void sendLinkRemovedPacket(ILinkData link)
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dataOut = new DataOutputStream(bos);
try
{
dataOut.writeByte(PacketHandler.removeLinkPacketID);
dataOut.writeInt(link.locDimID);
dataOut.writeInt(link.destDimID);
dataOut.writeInt(link.locXCoord);
dataOut.writeInt(link.locYCoord);
dataOut.writeInt(link.locZCoord);
dataOut.writeInt(link.destXCoord);
dataOut.writeInt(link.destYCoord);
dataOut.writeInt(link.destZCoord);
dataOut.writeBoolean(link.isLocPocket);
}
catch (IOException e)
{
e.printStackTrace();
}
Packet250CustomPayload packet= new Packet250CustomPayload();
packet.channel="DimDoorPackets";
packet.data = bos.toByteArray();
packet.length = bos.size();;
PacketDispatcher.sendPacketToAllPlayers(packet);
}
public static void sendDimCreatedPacket(NewDimData data)
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dataOut = new DataOutputStream(bos);
try
{
dataOut.writeByte(PacketHandler.regsiterDimPacketID);
dataOut.writeInt(data.dimID);
dataOut.writeBoolean(data.isPocket);
dataOut.writeInt(data.depth);
dataOut.writeInt(data.exitDimLink.destDimID);
dataOut.writeInt(data.exitDimLink.destXCoord);
dataOut.writeInt(data.exitDimLink.destYCoord);
dataOut.writeInt(data.exitDimLink.destZCoord);
}
catch (IOException e)
{
e.printStackTrace();
}
Packet250CustomPayload packet= new Packet250CustomPayload();
packet.channel="DimDoorPackets";
packet.data = bos.toByteArray();
packet.length = bos.size();
PacketDispatcher.sendPacketToAllPlayers(packet);
return packet;
}
public static void sendDimObject(NewDimData dim)
{
try
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream dataOut = new ObjectOutputStream(bos);
dataOut.writeObject(dim);
Packet250CustomPayload packet= new Packet250CustomPayload();
packet.channel="DimDoorPackets";
packet.data = bos.toByteArray();
packet.length = bos.size();;
PacketDispatcher.sendPacketToAllPlayers(packet);
}
catch (IOException e)
{
e.printStackTrace();
}
}
}

View File

@@ -12,13 +12,12 @@ import cpw.mods.fml.common.IPlayerTracker;
public class PlayerRespawnTracker implements IPlayerTracker
{
public PlayerRespawnTracker()
{
if (properties == null)
properties = DDProperties.instance();
}
private final DDProperties properties;
private static DDProperties properties = null;
public PlayerRespawnTracker(DDProperties properties)
{
this.properties = properties;
}
@Override
public void onPlayerLogin(EntityPlayer player) {

View File

@@ -4,6 +4,8 @@ import java.io.Serializable;
public class Point3D implements Serializable {
private static final long serialVersionUID = -9044026830605287190L;
private int x;
private int y;
private int z;

View File

@@ -1,15 +1,93 @@
package StevenDimDoors.mod_pocketDim;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.watcher.IOpaqueMessage;
import StevenDimDoors.mod_pocketDim.watcher.IUpdateWatcher;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
public class ServerPacketHandler implements IPacketHandler
{
@Override
public void onPacketData(INetworkManager manager,
Packet250CustomPayload packet, Player player)
public ServerPacketHandler()
{
PocketManager.registerDimWatcher(new DimWatcher());
PocketManager.registerLinkWatcher(new LinkWatcher());
}
@Override
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player)
{
}
private class DimWatcher implements IUpdateWatcher
{
@Override
public void onCreated(IOpaqueMessage message)
{
sendMessageToAllPlayers(PacketConstants.CREATE_DIM_PACKET_ID, message);
}
@Override
public void onUpdated(IOpaqueMessage message)
{
sendMessageToAllPlayers(PacketConstants.UPDATE_DIM_PACKET_ID, message);
}
@Override
public void onDeleted(IOpaqueMessage message)
{
sendMessageToAllPlayers(PacketConstants.DELETE_DIM_PACKET_ID, message);
}
}
private class LinkWatcher implements IUpdateWatcher
{
@Override
public void onCreated(IOpaqueMessage message)
{
sendMessageToAllPlayers(PacketConstants.CREATE_LINK_PACKET_ID, message);
}
@Override
public void onUpdated(IOpaqueMessage message)
{
sendMessageToAllPlayers(PacketConstants.UPDATE_LINK_PACKET_ID, message);
}
@Override
public void onDeleted(IOpaqueMessage message)
{
sendMessageToAllPlayers(PacketConstants.DELETE_LINK_PACKET_ID, message);
}
}
private static void sendMessageToAllPlayers(byte id, IOpaqueMessage message)
{
try
{
Packet250CustomPayload packet = new Packet250CustomPayload();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream writer = new DataOutputStream(buffer);
writer.writeByte(id);
message.writeToStream(writer);
writer.close();
packet.channel = PacketConstants.CHANNEL_NAME;
packet.data = buffer.toByteArray();
packet.length = packet.data.length;
PacketDispatcher.sendPacketToAllPlayers(packet);
}
catch (IOException e)
{
//This shouldn't happen...
e.printStackTrace();
}
}
}

View File

@@ -1,68 +0,0 @@
package StevenDimDoors.mod_pocketDim;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
public class TileEntityDimRail extends TileEntity
{
public int orientation;
public boolean hasExit;
public boolean canUpdate()
{
return false;
}
public void updateEntity()
{
}
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
int i = nbt.getInteger(("Size"));
try
{
this.orientation = nbt.getInteger("orientation");
this.hasExit = nbt.getBoolean("hasExit");
}
catch (Exception e)
{
}
}
@Override
public void writeToNBT(NBTTagCompound nbt)
{
int i = 0;
super.writeToNBT(nbt);
nbt.setBoolean("hasExit", this.hasExit);
nbt.setInteger("orientation", this.orientation);
}
}

View File

@@ -8,16 +8,18 @@ import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.DDTeleporter;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.IDimLink;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
import StevenDimDoors.mod_pocketDim.util.Point4D;
public class BlockDimWallPerm extends Block
{
private static final Random random = new Random();
private static DDProperties properties = null;
public BlockDimWallPerm(int i, int j, Material par2Material)
@@ -43,83 +45,50 @@ public class BlockDimWallPerm extends Block
/**
* Only matters if the player is in limbo, acts to teleport the player from limbo back to dim 0
*/
public void onEntityWalking(World par1World, int par2, int par3, int par4, Entity entity)
public void onEntityWalking(World world, int x, int y, int z, Entity entity)
{
if (!par1World.isRemote && par1World.provider.dimensionId == properties.LimboDimensionID)
if (!world.isRemote && world.provider.dimensionId == properties.LimboDimensionID)
{
Random rand = new Random();
IDimLink link = PocketManager.getRandomLinkData(false);
if (link == null)
{
link =new NewLinkData(0,0,0,0);
}
link.destDimID = 0;
link.locDimID = par1World.provider.dimensionId;
World overworld = DimensionManager.getWorld(0);
if (overworld == null)
{
DimensionManager.initDimension(0);
overworld = DimensionManager.getWorld(0);
}
if (overworld != null && entity instanceof EntityPlayerMP)
{
EntityPlayer player = (EntityPlayer) entity;
player.fallDistance = 0;
int x = (link.destXCoord + rand.nextInt(properties.LimboReturnRange) - properties.LimboReturnRange/2);
int z = (link.destZCoord + rand.nextInt(properties.LimboReturnRange) - properties.LimboReturnRange/2);
int rangeLimit = properties.LimboReturnRange / 2;
int destinationX = x + MathHelper.getRandomIntegerInRange(random, -rangeLimit, rangeLimit);
int destinationZ = z + MathHelper.getRandomIntegerInRange(random, -rangeLimit, rangeLimit);
//make sure I am in the middle of a chunk, and not on a boundary, so it doesn't load the chunk next to me
x = x + (x >> 4);
z = z + (z >> 4);
destinationX = destinationX + (destinationX >> 4);
destinationZ = destinationZ + (destinationZ >> 4);
int y = yCoordHelper.getFirstUncovered(0, x, 63, z, true);
int destinationY = yCoordHelper.getFirstUncovered(overworld, destinationX, 63, destinationZ, true);
player.setPositionAndUpdate( x, y, z );
//this complicated chunk teleports the player back to the overworld at some random location. Looks funky becaue it has to load the chunk
link.destXCoord = x;
link.destYCoord = y;
link.destZCoord = z;
PocketManager.teleportEntity(par1World, player, link);
//FIXME: Shouldn't we make the player's destination safe BEFORE teleporting him?!
//player.setPositionAndUpdate( x, y, z );
Point4D destination = new Point4D(destinationX, destinationY, destinationZ, 0);
DDTeleporter.teleportEntity(player, destination);
player.setPositionAndUpdate( x, y, z );
//player.setPositionAndUpdate( x, y, z );
// Make absolutely sure the player doesn't spawn inside blocks, though to be honest this shouldn't ever have to be a problem...
overworld.setBlockToAir(x, y, z);
overworld.setBlockToAir(x, y + 1, z);
overworld.setBlockToAir(destinationX, destinationY, destinationZ);
overworld.setBlockToAir(destinationX, destinationY + 1, destinationZ);
int i=x;
int j=y;
int k=z;
for(int xc=-3;xc<4;xc++)
for (int xc = -3; xc < 4; xc++)
{
for(int zc=-3;zc<4;zc++)
for (int zc = -3; zc < 4; zc++)
{
for(int yc=0;yc<200;yc++)
if (Math.abs(xc) + Math.abs(zc) < random.nextInt(3) + 2 ||
Math.abs(xc) + Math.abs(zc) < random.nextInt(3) + 3)
{
if (yc==0)
{
if(Math.abs(xc)+Math.abs(zc)<rand.nextInt(3)+2)
{
overworld.setBlock(i+xc, j-1+yc, k+zc, properties.LimboBlockID);
}
else if(Math.abs(xc)+Math.abs(zc)<rand.nextInt(3)+3)
{
overworld.setBlock(i+xc, j-1+yc, k+zc, properties.LimboBlockID,2,0);
}
}
overworld.setBlock(destinationX + xc, destinationY - 1, destinationZ + zc, properties.LimboBlockID);
}
}
}
//FIXME: Why do we do this repeatedly? We also set the fall distance at the start...
player.setPositionAndUpdate( x, y, z );
player.setPositionAndUpdate( destinationX, destinationY, destinationZ );
player.fallDistance = 0;
}
}

View File

@@ -16,9 +16,9 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.Point3D;
import StevenDimDoors.mod_pocketDim.TileEntityRift;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityRift;
import StevenDimDoors.mod_pocketDimClient.ClosingRiftFX;
import StevenDimDoors.mod_pocketDimClient.GoggleRiftFX;
import StevenDimDoors.mod_pocketDimClient.RiftFX;

View File

@@ -18,21 +18,22 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.TileEntityDimDoor;
import StevenDimDoors.mod_pocketDim.DDTeleporter;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.IDimLink;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class dimDoor extends BlockContainer
public class DimensionalDoor extends BlockContainer
{
private static DDProperties properties = null;
protected static DDProperties properties = null;
private Icon blockIconBottom;
public dimDoor(int par1, Material material)
public DimensionalDoor(int par1, Material material)
{
super(par1, material);
@@ -61,7 +62,7 @@ public class dimDoor extends BlockContainer
IDimLink link = PocketManager.getLink(x, y, z, world.provider.dimensionId);
if (link != null)
{
PocketManager.traverseDimDoor(world, link, entity);
DDTeleporter.traverseDimDoor(world, link, entity);
}
}
}
@@ -171,7 +172,7 @@ public class dimDoor extends BlockContainer
IDimLink link = dimension.getLink(x, y, z);
if (link == null)
{
dimension.createLink(x, y, z).setLinkType(IDimLink.TYPE_POCKET);
dimension.createLink(x, y, z, IDimLink.TYPE_POCKET);
}
}
world.setBlockTileEntity(x, y, z, this.createNewTileEntity(world));
@@ -196,10 +197,10 @@ public class dimDoor extends BlockContainer
//Called to update the render information on the tile entity. Could probably implement a data watcher,
//but this works fine and is more versatile I think.
public dimDoor updateAttachedTile(World world, int x, int y, int z)
public DimensionalDoor updateAttachedTile(World world, int x, int y, int z)
{
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof TileEntityDimDoor )
if (tile instanceof TileEntityDimDoor)
{
TileEntityDimDoor dimTile = (TileEntityDimDoor) tile;
dimTile.openOrClosed = PocketManager.getLink(x, y, z, world.provider.dimensionId) != null;

View File

@@ -1,4 +1,4 @@
package StevenDimDoors.mod_pocketDim;
package StevenDimDoors.mod_pocketDim.blocks;
import java.util.Random;
@@ -10,43 +10,34 @@ import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.blocks.ExitDoor;
import StevenDimDoors.mod_pocketDim.DDTeleporter;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.IDimLink;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TransientDoor extends ExitDoor
public class TransientDoor extends WarpDoor
{
protected TransientDoor(int par1, Material material)
public TransientDoor(int blockID, Material material)
{
super(par1, Material.grass);
// this.blockIndexInTexture = 18;
if (properties == null)
properties = DDProperties.instance();
super(blockID, material);
}
private static DDProperties properties = null;
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_top");
}
@SideOnly(Side.CLIENT)
/**
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
*/
@SideOnly(Side.CLIENT)
public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
return this.blockIcon;
}
public boolean isCollidable()
{
return false;
@@ -78,10 +69,11 @@ public class TransientDoor extends ExitDoor
IDimLink link = PocketManager.getLink(x, y, z, world.provider.dimensionId);
if (link != null)
{
//Turn the transient door into a rift before teleporting the entity
DDTeleporter.traverseDimDoor(world, link, entity);
//Turn the transient door into a rift AFTER teleporting the entity.
//The door's orientation may be needed for generating a room at the link's destination.
world.setBlock(x, y, z, properties.RiftBlockID);
world.setBlockToAir(x, y - 1, z);
PocketManager.traverseDimDoor(world, link, entity);
}
}
}

View File

@@ -1,12 +1,8 @@
package StevenDimDoors.mod_pocketDim.blocks;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.DDProperties;
@@ -17,12 +13,12 @@ import StevenDimDoors.mod_pocketDim.core.PocketManager;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ChaosDoor extends dimDoor
public class UnstableDoor extends DimensionalDoor
{
private Icon blockIconBottom;
private static DDProperties properties = null;
public ChaosDoor(int par1, Material material)
public UnstableDoor(int par1, Material material)
{
super(par1, material);
if (properties == null)
@@ -33,7 +29,6 @@ public class ChaosDoor extends dimDoor
{
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_top");
this.blockIconBottom = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_bottom");
}
@SideOnly(Side.CLIENT)
@@ -59,7 +54,7 @@ public class ChaosDoor extends dimDoor
if (!world.isRemote && world.getBlockId(x, y - 1, z) == this.blockID)
{
NewDimData dimension = PocketManager.getDimensionData(world);
dimension.createLink(x, y, z).setLinkType(IDimLink.TYPE_RANDOM);
dimension.createLink(x, y, z, IDimLink.TYPE_RANDOM);
}
}
}

View File

@@ -15,11 +15,11 @@ import StevenDimDoors.mod_pocketDim.core.PocketManager;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ExitDoor extends dimDoor
public class WarpDoor extends DimensionalDoor
{
private Icon blockIconBottom;
public ExitDoor(int blockID, Material material)
public WarpDoor(int blockID, Material material)
{
super(blockID, material);
}
@@ -41,7 +41,7 @@ public class ExitDoor extends dimDoor
IDimLink link = dimension.getLink(x, y, z);
if (link == null)
{
dimension.createLink(x, y, z).setLinkType(IDimLink.TYPE_SAFE_EXIT);
dimension.createLink(x, y, z, IDimLink.TYPE_SAFE_EXIT);
}
}
world.setBlockTileEntity(x, y, z, this.createNewTileEntity(world));

View File

@@ -1,56 +0,0 @@
package StevenDimDoors.mod_pocketDim.blocks;
import java.util.Random;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class linkDimDoor extends dimDoor
{
private Icon blockIconBottom;
public linkDimDoor(int par1, Material material) {
super(par1, material);
// TODO Auto-generated constructor stub
}
@SideOnly(Side.CLIENT)
/**
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
*/
public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
if(par1IBlockAccess.getBlockId(par2, par3-1, par4)==this.blockID)
{
return this.blockIcon;
}
else
{
return this.blockIconBottom;
}
}
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_top");
this.blockIconBottom = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_bottom");
}
}

View File

@@ -1,57 +0,0 @@
package StevenDimDoors.mod_pocketDim.blocks;
import java.util.Random;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class linkExitDoor extends ExitDoor
{
private Icon blockIconBottom;
public linkExitDoor(int par1,Material par2Material)
{
super(par1, Material.wood);
//this.blockIndexInTexture = 20;
// TODO Auto-generated constructor stub
}
@SideOnly(Side.CLIENT)
/**
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
*/
public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
if(par1IBlockAccess.getBlockId(par2, par3-1, par4)==this.blockID)
{
return this.blockIcon;
}
else
{
return this.blockIconBottom;
}
}
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_top");
this.blockIconBottom = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_bottom");
}
}

View File

@@ -34,7 +34,7 @@ public class CommandCreatePocket extends DDCommandBase
}
//Place a door leading to a pocket dimension where the player is standing.
//The pocket dimension will be serve as a room for the player to build a dungeon.
//The pocket dimension will serve as a room for the player to build a dungeon.
int x = (int) sender.posX;
int y = (int) sender.posY;
int z = (int) sender.posZ;

View File

@@ -1,10 +1,8 @@
package StevenDimDoors.mod_pocketDim.core;
import java.io.Serializable;
import StevenDimDoors.mod_pocketDim.util.Point4D;
public interface IDimLink extends Serializable
public interface IDimLink
{
public final int TYPE_ENUM_MIN = 0;
public final int TYPE_ENUM_MAX = 8;
@@ -26,6 +24,4 @@ public interface IDimLink extends Serializable
public int childCount();
public IDimLink parent();
public int linkType();
public IDimLink setDestination(int x, int y, int z, NewDimData dimension);
public IDimLink setLinkType(int linkType);
}

View File

@@ -1,5 +1,4 @@
package StevenDimDoors.mod_pocketDim.core;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -9,15 +8,17 @@ import java.util.TreeMap;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack;
import StevenDimDoors.mod_pocketDim.util.Point4D;
import StevenDimDoors.mod_pocketDim.watcher.IOpaqueMessage;
import StevenDimDoors.mod_pocketDim.watcher.IUpdateWatcher;
public abstract class NewDimData implements Serializable
public abstract class NewDimData
{
private static class DimLink implements IDimLink
{
//DimLink is an inner class here to make it immutable to code outside NewDimData
private static final long serialVersionUID = 1462177151401498444L;
private static final int EXPECTED_CHILDREN = 2;
private Point4D source;
@@ -34,11 +35,16 @@ public abstract class NewDimData implements Serializable
parent.children.add(this);
}
public DimLink(Point4D source)
public DimLink(Point4D source, int linkType)
{
if (linkType < IDimLink.TYPE_ENUM_MIN || linkType > IDimLink.TYPE_ENUM_MAX)
{
throw new IllegalArgumentException("The specified link type is invalid.");
}
this.parent = null;
this.source = source;
this.tail = new LinkTail(0, null);
this.tail = new LinkTail(linkType, null);
this.children = new ArrayList<IDimLink>(EXPECTED_CHILDREN);
}
@@ -60,28 +66,9 @@ public abstract class NewDimData implements Serializable
return (tail.getDestination() != null);
}
@Override
public IDimLink setDestination(int x, int y, int z, NewDimData dimension)
public void setDestination(int x, int y, int z, NewDimData dimension)
{
if (dimension == null)
{
throw new IllegalArgumentException("dimension cannot be null.");
}
tail.setDestination(new Point4D(x, y, z, dimension.id()));
return this;
}
@Override
public IDimLink setLinkType(int linkType)
{
if (linkType < IDimLink.TYPE_ENUM_MIN || linkType > IDimLink.TYPE_ENUM_MAX)
{
throw new IllegalArgumentException("The specified link type is invalid.");
}
tail.setLinkType(linkType);
return this;
}
@Override
@@ -130,6 +117,11 @@ public abstract class NewDimData implements Serializable
public void overwrite(DimLink nextParent)
{
if (nextParent == null)
{
throw new IllegalArgumentException("nextParent cannot be null.");
}
if (this == nextParent)
{
//Ignore this request silently
@@ -151,15 +143,28 @@ public abstract class NewDimData implements Serializable
//Attach to new parent
parent = nextParent;
tail = nextParent.tail;
nextParent.children.add(this);
}
public void overwrite(int linkType)
{
//Release children
for (IDimLink child : children)
{
((DimLink) child).parent = null;
}
children.clear();
//Release parent
if (parent != null)
{
tail = parent.tail;
parent.children.add(this);
}
else
{
tail = new LinkTail(0, null);
parent.children.remove(this);
}
//Attach to new parent
parent = null;
tail = new LinkTail(linkType, null);
}
@Override
@@ -167,9 +172,18 @@ public abstract class NewDimData implements Serializable
{
return source + " -> " + (hasDestination() ? destination() : "");
}
public IOpaqueMessage toMessage()
{
return null;
}
public IOpaqueMessage toKey()
{
return null;
}
}
private static final long serialVersionUID = 89361974746997260L;
private static Random random = new Random();
private final int id;
@@ -185,8 +199,11 @@ public abstract class NewDimData implements Serializable
private Point4D origin;
private int orientation;
private DungeonData dungeon;
private final IUpdateWatcher dimWatcher;
private final IUpdateWatcher linkWatcher;
protected NewDimData(int id, NewDimData parent, boolean isPocket, boolean isDungeon)
protected NewDimData(int id, NewDimData parent, boolean isPocket, boolean isDungeon,
IUpdateWatcher dimWatcher, IUpdateWatcher linkWatcher)
{
//The isPocket flag is redundant. It's meant as an integrity safeguard.
if (isPocket == (parent != null))
@@ -203,27 +220,36 @@ public abstract class NewDimData implements Serializable
this.linkList = new ArrayList<DimLink>(); //Should be stored in oct tree -- temporary solution
this.children = new ArrayList<NewDimData>();
this.parent = parent;
this.root = (parent != null ? parent.root : this);
this.depth = (parent != null ? parent.depth + 1 : 0);
this.packDepth = 0;
this.isDungeon = isDungeon;
this.isFilled = false;
this.orientation = 0;
this.origin = null;
this.dungeon = null;
this.dimWatcher = dimWatcher;
this.linkWatcher = linkWatcher;
//Register with parent
addChildDimension(this);
if (parent != null)
{
//We don't need to raise an update event for adding a child because the child's creation will be signaled.
this.root = parent.root;
this.depth = parent.depth + 1;
parent.children.add(this);
}
else
{
this.root = this;
this.depth = 0;
}
}
private void addChildDimension(NewDimData child)
{
children.add(child);
}
protected abstract IOpaqueMessage toMessage();
protected abstract IOpaqueMessage toKey();
public IDimLink findNearestRift(World world, int range, int x, int y, int z)
{
//TODO: Rewrite this later to use an octtree, remove World parameter
//TODO: Rewrite this later to use an octtree
//Sanity check...
if (world.provider.dimensionId != id)
@@ -270,25 +296,27 @@ public abstract class NewDimData implements Serializable
return Math.abs(i) + Math.abs(j) + Math.abs(k);
}
public IDimLink createLink(int x, int y, int z)
public IDimLink createLink(int x, int y, int z, int linkType)
{
return createLink(new Point4D(x, y, z, id));
return createLink(new Point4D(x, y, z, id), linkType);
}
private IDimLink createLink(Point4D source)
private IDimLink createLink(Point4D source, int linkType)
{
//Return an existing link if there is one to avoid creating multiple links starting at the same point.
DimLink link = linkMapping.get(source);
if (link == null)
{
link = new DimLink(source);
link = new DimLink(source, linkType);
linkMapping.put(source, link);
linkList.add(link);
}
else
{
link.overwrite(null);
link.overwrite(linkType);
}
//Link created!
linkWatcher.onCreated(link.toMessage());
return link;
}
@@ -318,7 +346,8 @@ public abstract class NewDimData implements Serializable
{
link.overwrite(parent);
}
//Link created!
linkWatcher.onCreated(link.toMessage());
return link;
}
@@ -332,6 +361,8 @@ public abstract class NewDimData implements Serializable
if (target != null)
{
linkList.remove(target);
//Raise deletion event
linkWatcher.onDeleted(target.toKey());
target.clear();
}
return (target != null);
@@ -344,6 +375,8 @@ public abstract class NewDimData implements Serializable
if (target != null)
{
linkList.remove(target);
//Raise deletion event
linkWatcher.onDeleted(target.toKey());
target.clear();
}
return (target != null);
@@ -388,6 +421,8 @@ public abstract class NewDimData implements Serializable
public void setFilled(boolean isFilled)
{
this.isFilled = isFilled;
//Raise the dim update event
dimWatcher.onUpdated(this.toMessage());
}
public int id()
@@ -445,7 +480,7 @@ public abstract class NewDimData implements Serializable
return children;
}
public void initializeDungeon(int originX, int originY, int originZ, int orientation, IDimLink link, DungeonData dungeon)
public void initializeDungeon(int originX, int originY, int originZ, int orientation, IDimLink incoming, DungeonData dungeon)
{
if (!isDungeon)
{
@@ -456,13 +491,48 @@ public abstract class NewDimData implements Serializable
throw new IllegalStateException("The dimension has already been initialized.");
}
link.setDestination(originX, originY, originZ, this);
this.origin = link.destination();
setDestination(incoming, originX, originY, originZ);
this.origin = incoming.destination();
this.orientation = orientation;
this.dungeon = dungeon;
this.packDepth = calculatePackDepth(parent, dungeon);
//Raise the dim update event
dimWatcher.onUpdated(this.toMessage());
}
public void initializePocket(int originX, int originY, int originZ, int orientation, IDimLink link)
private static int calculatePackDepth(NewDimData parent, DungeonData current)
{
DungeonData predecessor = parent.dungeon();
if (current == null)
{
throw new IllegalArgumentException("current cannot be null.");
}
if (predecessor == null)
{
return 1;
}
DungeonPack predOwner = predecessor.dungeonType().Owner;
DungeonPack currentOwner = current.dungeonType().Owner;
if (currentOwner == null)
{
return 1;
}
if (predOwner == null)
{
return 1;
}
if (predOwner == currentOwner)
{
return parent.packDepth + 1;
}
else
{
return 1;
}
}
public void initializePocket(int originX, int originY, int originZ, int orientation, IDimLink incoming)
{
if (!isPocketDimension())
{
@@ -473,9 +543,19 @@ public abstract class NewDimData implements Serializable
throw new IllegalStateException("The dimension has already been initialized.");
}
link.setDestination(originX, originY, originZ, this);
this.origin = link.destination();
setDestination(incoming, originX, originY, originZ);
this.origin = incoming.destination();
this.orientation = orientation;
//Raise the dim update event
dimWatcher.onUpdated(this.toMessage());
}
public void setDestination(IDimLink incoming, int x, int y, int z)
{
DimLink link = (DimLink) incoming;
link.setDestination(x, y, z, this);
//Raise update event
linkWatcher.onUpdated(link.toMessage());
}
public IDimLink getRandomLink()

View File

@@ -1,40 +1,24 @@
package StevenDimDoors.mod_pocketDim.core;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet41EntityEffect;
import net.minecraft.network.packet.Packet43Experience;
import net.minecraft.network.packet.Packet9Respawn;
import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.DDTeleporter;
import StevenDimDoors.mod_pocketDim.ObjectSaveInputStream;
import StevenDimDoors.mod_pocketDim.PacketHandler;
import StevenDimDoors.mod_pocketDim.TileEntityRift;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.helpers.DeleteFolder;
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityRift;
import StevenDimDoors.mod_pocketDim.util.Point4D;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import StevenDimDoors.mod_pocketDim.watcher.IOpaqueMessage;
import StevenDimDoors.mod_pocketDim.watcher.IUpdateWatcher;
import StevenDimDoors.mod_pocketDim.watcher.UpdateWatcherProxy;
/**
* This class regulates all the operations involving the storage and manipulation of dimensions. It handles saving dim data, teleporting the player, and
@@ -49,152 +33,119 @@ public class PocketManager
//of NewDimData without using PocketManager's functions. In turn, that enforces that any
//link destinations must be real dimensions controlled by PocketManager.
private static final long serialVersionUID = -3497038894870586232L;
public InnerDimData(int id, NewDimData parent, boolean isPocket, boolean isDungeon)
public InnerDimData(int id, NewDimData parent, boolean isPocket, boolean isDungeon,
IUpdateWatcher dimWatcher, IUpdateWatcher linkWatcher)
{
super(id, parent, isPocket, isDungeon);
super(id, parent, isPocket, isDungeon, dimWatcher, linkWatcher);
}
@Override
protected IOpaqueMessage toMessage()
{
// TODO Auto-generated method stub
return null;
}
@Override
protected IOpaqueMessage toKey()
{
// TODO Auto-generated method stub
return null;
}
}
private static int OVERWORLD_DIMENSION_ID = 0;
private static boolean isInitialized = false;
private static boolean isSaving = false;
private static Random random = new Random();
private static volatile boolean isLoading = false;
private static volatile boolean isLoaded = false;
private static volatile boolean isSaving = false;
private static UpdateWatcherProxy linkWatcher = null;
private static UpdateWatcherProxy dimWatcher = null;
//HashMap containing all the dims registered with DimDoors, sorted by dim ID. loaded on startup
//HashMap that maps all the dimension IDs registered with DimDoors to their DD data.
private static HashMap<Integer, NewDimData> dimensionData = new HashMap<Integer, NewDimData>();
//HashMap for temporary storage of Link Signature damage hash values. See itemLinkSignature for more details
private static HashMap<Integer, IDimLink> keyLinkMapping = new HashMap<Integer, IDimLink>();
public static boolean isInitialized()
public static boolean isLoaded()
{
return isInitialized;
}
public ILinkData createLink(ILinkData link)
{
DDProperties properties = DDProperties.instance();
if(!PocketManager.dimList.containsKey(link.locDimID))
{
NewDimData locationDimData= new NewDimData(link.locDimID, false, 0, link.locDimID,link.locXCoord,link.locYCoord,link.locZCoord);
PocketManager.dimList.put(link.locDimID, locationDimData);
link.isLocPocket=false;
}
if(!dimList.containsKey(link.destDimID))
{
PocketManager.dimList.put(link.destDimID, new NewDimData(link.destDimID, false, 0, link.locDimID,link.locXCoord,link.locYCoord,link.locZCoord));
}
NewDimData locationDimData= PocketManager.instance.getDimData(link.locDimID);
link.isLocPocket=locationDimData.isPocket;
locationDimData.addLinkToDim(link);
World world = PocketManager.getWorld(link.locDimID);
if (world != null)
{
if (!mod_pocketDim.blockRift.isBlockImmune(world, link.locXCoord, link.locYCoord, link.locZCoord))
{
world.setBlock(link.locXCoord, link.locYCoord, link.locZCoord, properties.RiftBlockID);
}
}
//Notifies other players that a link has been created.
//TODO: Couldn't we use the serverside/clientside annotations to achieve this instead? Seems safer. ~SenseiKiwi
if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER)
{
PacketHandler.onLinkCreatedPacket(link);
}
return link;
}
/**
* properly deletes a link at the given coordinates. used by the rift remover. Also notifies clients of change.
* @param locationDimID
* @param locationXCoord
* @param locationYCoord
* @param locationZCoord
*/
public void removeLink( int locationDimID, int locationXCoord, int locationYCoord, int locationZCoord)
{
if(!PocketManager.dimList.containsKey(locationDimID))
{
NewDimData locationDimData= new NewDimData(locationDimID, false, 0, locationDimID,locationXCoord,locationYCoord,locationZCoord);
PocketManager.dimList.put(locationDimID, locationDimData);
}
ILinkData link = this.getLinkDataFromCoords(locationXCoord, locationYCoord, locationZCoord, locationDimID);
PocketManager.instance.getDimData(locationDimID).removeLinkAtCoords(link);
//updates clients that a rift has been removed
if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER)
{
PacketHandler.onLinkRemovedPacket(link);
this.save();
}
}
/**
* generates a door based on what door was used to teleport. Only functions once per linking.
* @param world- door
* @param incLink
*/
public void generateDoor(World world, ILinkData incLink)
{
int locX = incLink.locXCoord;
int locY = incLink.locYCoord;
int locZ = incLink.locZCoord;
int destX = incLink.destXCoord;
int destY = incLink.destYCoord;
int destZ = incLink.destZCoord;
DDProperties properties = DDProperties.instance();
if(!incLink.hasGennedDoor)
{
int destinationID = incLink.destDimID;
int id =world.getBlockId(locX, locY, locZ);
if(id==properties.WarpDoorID||id==properties.DimensionalDoorID||id==properties.TransientDoorID)
{
int doorTypeToPlace=id;
if(DimensionManager.getWorld(destinationID)==null)
{
DimensionManager.initDimension(destinationID);
}
ILinkData destLink = this.getLinkDataFromCoords(destX, destY, destZ, destinationID);
int destOrientation = 0;
if(destLink!=null)
{
destOrientation = destLink.linkOrientation;
destLink.hasGennedDoor=true;
}
int blockToReplace= DimensionManager.getWorld(destinationID).getBlockId(destX, destY, destZ);
if(blockToReplace!=properties.DimensionalDoorID&&blockToReplace!=properties.WarpDoorID&&blockToReplace != properties.TransientDoorID)
{
DimensionManager.getWorld(destinationID).setBlock(destX, destY-1, destZ, doorTypeToPlace,destOrientation,2);
DimensionManager.getWorld(destinationID).setBlock(destX, destY, destZ, doorTypeToPlace,8,2);
}
incLink.hasGennedDoor=true;
}
}
return isLoaded;
}
/**
* simple method called on startup to register all dims saved in the dim list. Only tries to register pocket dims, though. Also calls load()
* @return
*/
public static void initPockets()
public static void load()
{
if (isInitialized)
if (isLoaded)
{
throw new IllegalStateException("Pocket dimensions have already been initialized!");
throw new IllegalStateException("Pocket dimensions have already been loaded!");
}
if (isLoading)
{
return;
}
DDProperties properties = DDProperties.instance();
isLoading = true;
isInitialized = true;
load();
//Set up watcher proxies
dimWatcher = new UpdateWatcherProxy();
linkWatcher = new UpdateWatcherProxy();
loadInternal();
//Register Limbo
DDProperties properties = DDProperties.instance();
registerDimension(properties.LimboDimensionID, null, false, false);
//Register pocket dimensions
registerPockets(properties);
isLoaded = true;
isLoading = false;
}
public boolean clearPocket(NewDimData dimension)
{
if (!dimension.isPocketDimension() || DimensionManager.getWorld(dimension.id()) != null)
{
return false;
}
File save = new File(DimensionManager.getCurrentSaveRootDirectory() + "/DimensionalDoors/pocketDimID" + dimension.id());
DeleteFolder.deleteFolder(save);
dimension.setFilled(false);
//FIXME: Reset door information?
return true;
}
public static boolean deletePocket(NewDimData dimension, boolean deleteFolder)
{
//FIXME: Shouldn't the links in and out of this dimension be altered somehow? Otherwise we have links pointing
//into a deleted dimension!
//Checks to see if the pocket is loaded or isn't actually a pocket.
if (dimension.isPocketDimension() && DimensionManager.getWorld(dimension.id()) == null)
{
dimensionData.remove(dimension.id());
DimensionManager.unregisterDimension(dimension.id());
if (deleteFolder)
{
File save = new File(DimensionManager.getCurrentSaveRootDirectory() + "/DimensionalDoors/pocketDimID" + dimension.id());
DeleteFolder.deleteFolder(save);
}
//Raise the dim deleted event
dimWatcher.onDeleted(dimension.toKey());
//dimension.implode()??? -- more like delete, but yeah
return true;
}
else
{
return false;
}
}
private static void registerPockets(DDProperties properties)
{
for (NewDimData dimension : dimensionData.values())
{
if (dimension.isPocketDimension())
@@ -212,45 +163,7 @@ public class PocketManager
}
}
public boolean resetPocket(NewDimData dimension)
{
if (!dimension.isPocketDimension() || DimensionManager.getWorld(dimension.id()) != null)
{
return false;
}
File save = new File(DimensionManager.getCurrentSaveRootDirectory() + "/DimensionalDoors/pocketDimID" + dimension.id());
DeleteFolder.deleteFolder(save);
dimension.setFilled(false);
//FIXME: Reset door information?
return true;
}
public static boolean pruneDimension(NewDimData dimension, boolean deleteFolder)
{
//FIXME: Shouldn't the links in and out of this dimension be altered somehow? Otherwise we have links pointing
//into a deleted dimension!
//Checks to see if the pocket is loaded or isn't actually a pocket.
if (dimension.isPocketDimension() && DimensionManager.getWorld(dimension.id()) == null)
{
dimensionData.remove(dimension.id());
//FIXME: I added the following line. Seems like a good idea. Is it?
DimensionManager.unregisterDimension(dimension.id());
if (deleteFolder)
{
File save = new File(DimensionManager.getCurrentSaveRootDirectory() + "/DimensionalDoors/pocketDimID" + dimension.id());
DeleteFolder.deleteFolder(save);
}
return true;
}
else
{
return false;
}
}
private static void unregisterDimensions()
private static void unregisterPockets()
{
for (NewDimData dimension : dimensionData.values())
{
@@ -270,254 +183,73 @@ public class PocketManager
}
/**
* Used to associate a damage value on a Rift Signature with a link pair. See LinkSignature for details.
* loads the dim data from the saved hashMap. Also handles compatibility with old saves, see OldSaveHandler
* @return
*/
public static int createUniqueLinkKey()
@SuppressWarnings("unchecked")
private static void loadInternal()
{
int linkKey;
do
// SenseiKiwi: This is a temporary function for testing purposes.
// We'll move on to using a text-based format in the future.
if (!DimensionManager.getWorld(OVERWORLD_DIMENSION_ID).isRemote &&
DimensionManager.getCurrentSaveRootDirectory() != null)
{
linkKey = random.nextInt(30000);
System.out.println("Loading Dimensional Doors save data...");
File saveFile = new File(DimensionManager.getCurrentSaveRootDirectory() + "/dimdoors.dat");
//Missing code for converting the binary data in the file into an IOpaqueMessage
IOpaqueMessage saveData;
setState(saveData);
System.out.println("Loaded successfully!");
}
while (keyLinkMapping.containsKey(linkKey));
return linkKey;
}
/**
* Method used to create and register a new pocket dimension. Creates a reverse link if necessary.
* Populates the destination as well.
*/
private NewDimData createDestinationPocket(IDimLink link)
{
//First check the destination type
if (link.linkType() != IDimLink.TYPE_DUNGEON && link.linkType() != IDimLink.TYPE_POCKET)
{
throw new IllegalArgumentException("The link must lead to a dimensional dungeon or a pocket dimension.");
}
DDProperties properties = DDProperties.instance();
//FIXME: This code had a check for whether dimension 0 was null. Why? Removed it for the time being. ~SenseiKiwi
if (PocketManager.getWorld(link.locDimID) == null)
{
PocketManager.initDimension(link.locDimID);
}
int dimensionID;
int depth = this.getDimDepth(link.locDimID);
dimensionID = getNextFreeDimId();
registerDimension(dimensionID, properties.PocketProviderID);
NewDimData locationDimData;
NewDimData destDimData;
if(PocketManager.dimList.containsKey(link.locDimID)&&!DimensionManager.getWorld(link.locDimID).isRemote) //checks to see if dim is already registered. If not, it creates a DimData entry for it later
{
//randomizes exit if deep enough
locationDimData= dimList.get(DimensionManager.getWorld(link.locDimID).provider.dimensionId);
if(depth>5)
{
if(depth>=12)
{
depth=11;
}
if(rand.nextInt(13-depth)==0)
{
ILinkData link1=getRandomLinkData(false);
}
}
if(locationDimData.isPocket) //determines the qualites of the pocket dim being created, based on parent dim.
{
if(isGoingDown)
{
destDimData= new NewDimData(dimensionID, true, locationDimData.depth+1, locationDimData.exitDimLink);
}
else
{
destDimData= new NewDimData(dimensionID, true, locationDimData.depth-1, locationDimData.exitDimLink);
}
}
else
{
destDimData= new NewDimData(dimensionID, true, 1, link.locDimID,link.locXCoord,link.locYCoord,link.locZCoord);
}
}
else
{
locationDimData= new NewDimData(link.locDimID, false, 0, link.locDimID,link.locXCoord,link.locYCoord,link.locZCoord);
destDimData= new NewDimData(dimensionID, true, 1, link.locDimID,link.locXCoord,link.locYCoord,link.locZCoord);
}
destDimData.isDimRandomRift=isRandomRift;
PocketManager.dimList.put(DimensionManager.getWorld(link.locDimID).provider.dimensionId, locationDimData);
PocketManager.dimList.put(dimensionID, destDimData);
if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER)//sends packet to clients notifying them that a new dim has been created.
{
PacketHandler.onDimCreatedPacket(destDimData);
}
link = this.createLink(DimensionManager.getWorld(link.locDimID).provider.dimensionId,dimensionID,link.locXCoord,link.locYCoord,link.locZCoord, link.destXCoord,constrainPocketY(link.destYCoord),link.destZCoord,link.linkOrientation); //creates and registers the two rifts that link the parent and pocket dim.
this.createLink(dimensionID,DimensionManager.getWorld(link.locDimID).provider.dimensionId, link.destXCoord,constrainPocketY(link.destYCoord),link.destZCoord, link.locXCoord,link.locYCoord,link.locZCoord, BlockRotator.transformMetadata(link.linkOrientation, 2, Block.doorWood.blockID));
return link;
}
/**
* Function that saves all dim data in a hashMap. Calling too often can cause Concurrent modification exceptions, so be careful.
* @return
*/
public static void save()
{
//TODO change from saving serialized objects to just saving data for compatabilies sake.
//TODO If saving is multithreaded as the concurrent modification exception implies, you should be synchronizing access. ~SenseiKiwi
// SenseiKiwi: This is a temporary function for testing purposes.
// We'll move on to using a text-based format in the future.
if (isSaving)
if (!isLoaded)
{
return;
}
World world = DimensionManager.getWorld(OVERWORLD_DIMENSION_ID);
if (world == null || world.isRemote)
if (world == null || world.isRemote || DimensionManager.getCurrentSaveRootDirectory() != null)
{
return;
}
if (DimensionManager.getCurrentSaveRootDirectory() != null)
//Check this last to make sure we set the flag shortly after.
if (isSaving)
{
isSaving = true;
HashMap comboSave = new HashMap();
comboSave.put("dimensionData", dimensionData);
comboSave.put("keyLinkMapping", keyLinkMapping);
FileOutputStream saveFile = null;
try
{
String saveFileName=DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoorsDataTEMP";
saveFile = new FileOutputStream(saveFileName);
ObjectOutputStream save = new ObjectOutputStream(saveFile);
save.writeObject(comboSave);
save.close();
saveFile.close();
if (new File(DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoorsDataOLD").exists())
{
new File(DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoorsDataOLD").delete();
}
new File(DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoorsData").renameTo(new File(DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoorsDataOLD"));
new File(saveFileName).renameTo( new File(DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoorsData"));
}
catch(Exception e)
{
e.printStackTrace();
System.err.println("Could not save data-- SEVERE");
}
isSaving = false;
return;
}
}
/**
* loads the dim data from the saved hashMap. Also handles compatibility with old saves, see OldSaveHandler
* @return
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void load()
{
//FIXME: There are a lot of things to fix here... First, we shouldn't be created so many File instances
//when we could just hold references and reuse them. Second, duplicate code is BAD. Loading stuff should
//be a function so that you can apply it to the save file first, then the "backup", instead of duplicating
//so much code. >_<
boolean firstRun = false;
System.out.println("Loading DimDoors data");
FileInputStream saveFile = null;
if (!DimensionManager.getWorld(OVERWORLD_DIMENSION_ID).isRemote && DimensionManager.getCurrentSaveRootDirectory()!=null)
isSaving = true;
try
{
try
{
File dataStore = new File( DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoorsData");
if (!dataStore.exists())
{
if (!new File( DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoorsDataOLD").exists())
{
firstRun=true;
}
}
saveFile = new FileInputStream(dataStore);
ObjectSaveInputStream save = new ObjectSaveInputStream(saveFile);
HashMap comboSave = ((HashMap) save.readObject());
try
{
keyLinkMapping = (HashMap<Integer, IDimLink>) comboSave.get("keyLinkMapping");
}
catch (Exception e)
{
System.out.println("Could not load Link Signature list. Link Sig items will lose their stored locations.");
}
try
{
dimensionData = (HashMap<Integer, NewDimData>) comboSave.get("dimensionData");
}
catch(Exception e)
{
System.out.println("Could not load pocket dimension list. Saves are probably lost, but repairable. Move the files from individual pocket dim files to active ones. See MC thread for details.");
}
save.close();
saveFile.close();
}
catch (Exception e)
{
try
{
if (!firstRun)
{
System.out.println("Save data damaged, trying backup...");
}
World world=FMLCommonHandler.instance().getMinecraftServerInstance().worldServers[0];
File dataStore =new File( world.getSaveHandler().getMapFileFromName("idcounts").getParentFile().getParent()+"/DimensionalDoorsDataOLD");
saveFile = new FileInputStream(dataStore);
ObjectSaveInputStream save = new ObjectSaveInputStream(saveFile);
HashMap comboSave =((HashMap)save.readObject());
try
{
keyLinkMapping = (HashMap<Integer, IDimLink>) comboSave.get("keyLinkMapping");
}
catch (Exception e2)
{
System.out.println("Could not load Link Signature list. Link Sig items will loose restored locations.");
}
try
{
dimensionData = (HashMap<Integer, NewDimData>) comboSave.get("dimensionData");
}
catch (Exception e2)
{
System.out.println("Could not load pocket dim list. Saves probably lost, but repairable. Move the files from indivual pocket dim files to active ones. See MC thread for details.");
}
save.close();
saveFile.close();
}
catch (Exception e2)
{
if (!firstRun)
{
System.err.println("Could not read data-- SEVERE");
e2.printStackTrace();
}
}
}
System.out.println("Writing Dimensional Doors save data...");
String tempPath = DimensionManager.getCurrentSaveRootDirectory() + "/dimdoors.tmp";
String savePath = DimensionManager.getCurrentSaveRootDirectory() + "/dimdoors.dat";
File tempFile = new File(tempPath);
File saveFile = new File(savePath);
DataOutputStream writer = new DataOutputStream(new FileOutputStream(tempFile));
getState().writeToStream(writer);
writer.close();
saveFile.delete();
tempFile.renameTo(saveFile);
System.out.println("Saved successfully!");
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
isSaving = false;
}
}
@@ -569,7 +301,7 @@ public class PocketManager
throw new IllegalArgumentException("Cannot register a dimension with ID = " + dimensionID + " because it has already been registered.");
}
NewDimData dimension = new InnerDimData(dimensionID, parent, isPocket, isDungeon);
NewDimData dimension = new InnerDimData(dimensionID, parent, isPocket, isDungeon, dimWatcher, linkWatcher);
dimensionData.put(dimensionID, dimension);
return dimension;
}
@@ -598,9 +330,8 @@ public class PocketManager
public static void unload()
{
save();
unregisterDimensions();
unregisterPockets();
dimensionData.clear();
keyLinkMapping.clear();
}
public static Iterable<NewDimData> getDimensions()
@@ -608,6 +339,11 @@ public class PocketManager
return dimensionData.values();
}
public static IDimLink getLink(int x, int y, int z, World world)
{
return getLink(x, y, z, world.provider.dimensionId);
}
public static IDimLink getLink(int x, int y, int z, int dimensionID)
{
NewDimData dimension = dimensionData.get(dimensionID);
@@ -620,4 +356,38 @@ public class PocketManager
return null;
}
}
public static void registerDimWatcher(IUpdateWatcher watcher)
{
dimWatcher.registerReceiver(watcher);
}
public static boolean unregisterDimWatcher(IUpdateWatcher watcher)
{
return dimWatcher.unregisterReceiver(watcher);
}
public static void registerLinkWatcher(IUpdateWatcher watcher)
{
linkWatcher.registerReceiver(watcher);
}
public static boolean unregisterLinkWatcher(IUpdateWatcher watcher)
{
return linkWatcher.unregisterReceiver(watcher);
}
public static IOpaqueMessage getState()
{
}
public static void setState(IOpaqueMessage state)
{
if (isLoaded)
{
throw new IllegalStateException("Pocket dimensions have already been loaded!");
}
}
}

View File

@@ -1,16 +1,13 @@
package StevenDimDoors.mod_pocketDim.dungeon;
import java.io.FileNotFoundException;
import java.io.Serializable;
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonType;
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
import StevenDimDoors.mod_pocketDim.schematic.InvalidSchematicException;
public class DungeonData implements Serializable
public class DungeonData
{
private static final long serialVersionUID = -5624866366474710161L;
private final int weight;
private final boolean isOpen;
private final boolean isInternal;

View File

@@ -14,19 +14,19 @@ import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.Point3D;
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
import StevenDimDoors.mod_pocketDim.core.IDimLink;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
import StevenDimDoors.mod_pocketDim.schematic.CompoundFilter;
import StevenDimDoors.mod_pocketDim.schematic.InvalidSchematicException;
import StevenDimDoors.mod_pocketDim.schematic.ReplacementFilter;
import StevenDimDoors.mod_pocketDim.schematic.Schematic;
import StevenDimDoors.mod_pocketDim.ticking.MobMonolith;
import StevenDimDoors.mod_pocketDim.util.Point4D;
public class DungeonSchematic extends Schematic {
@@ -167,16 +167,15 @@ public class DungeonSchematic extends Schematic {
return new DungeonSchematic(Schematic.copyFromWorld(world, x, y, z, width, height, length, doCompactBounds));
}
public void copyToWorld(World world, Point3D pocketCenter, int dungeonOrientation, int originDimID, int destDimID, boolean doDistortCoordinates)
public void copyToWorld(World world, Point3D pocketCenter, int dungeonOrientation, IDimLink entryLink, Random random)
{
//TODO: This function is an improvised solution so we can get the release moving. In the future,
//we should generalize block tranformations and implement support for them at the level of Schematic,
//we should generalize block transformations and implement support for them at the level of Schematic,
//then just use that support from DungeonSchematic instead of making this local fix.
//It might be easiest to support transformations using a WorldOperation
final int turnAngle = dungeonOrientation - orientation;
int index;
int count;
int blockID;
@@ -222,18 +221,11 @@ public class DungeonSchematic extends Schematic {
world.setBlockTileEntity(pocketPoint.getX(), pocketPoint.getY(), pocketPoint.getZ(), TileEntity.createAndLoadEntity(tileTag));
}
setUpDungeon(world, pocketCenter, turnAngle, originDimID, destDimID, doDistortCoordinates);
setUpDungeon(PocketManager.getDimensionData(world), world, pocketCenter, turnAngle, entryLink, random);
}
private void setUpDungeon(World world, Point3D pocketCenter, int turnAngle, int originDimID, int destDimID, boolean doDistortCoordinates)
private void setUpDungeon(NewDimData dimension, World world, Point3D pocketCenter, int turnAngle, IDimLink entryLink, Random random)
{
//The following Random initialization code is based on code from ChunkProviderGenerate.
//It makes our generation depend on the world seed.
Random random = new Random(world.getSeed());
long factorA = random.nextLong() / 2L * 2L + 1L;
long factorB = random.nextLong() / 2L * 2L + 1L;
random.setSeed(pocketCenter.getX() * factorB + pocketCenter.getZ() * factorA ^ world.getSeed());
//Transform dungeon corners
Point3D minCorner = new Point3D(0, 0, 0);
Point3D maxCorner = new Point3D(width - 1, height - 1, length - 1);
@@ -244,18 +236,18 @@ public class DungeonSchematic extends Schematic {
filler.apply(world, minCorner, maxCorner);
//Set up entrance door rift
setUpEntranceDoorLink(world, entranceDoorLocation, turnAngle, pocketCenter);
createEntranceReverseLink(dimension, pocketCenter, entryLink);
//Set up link data for dimensional doors
for (Point3D location : dimensionalDoorLocations)
{
setUpDimensionalDoorLink(world, location, entranceDoorLocation, turnAngle, pocketCenter, originDimID, destDimID, doDistortCoordinates, random);
createDimensionalDoorLink(dimension, location, entranceDoorLocation, turnAngle, pocketCenter);
}
//Set up link data for exit door
for (Point3D location : exitDoorLocations)
{
setUpExitDoorLink(world, location, entranceDoorLocation, turnAngle, pocketCenter, originDimID, destDimID, random);
createExitDoorLink(dimension, location, entranceDoorLocation, turnAngle, pocketCenter);
}
//Remove end portal frames and spawn Monoliths
@@ -290,130 +282,28 @@ public class DungeonSchematic extends Schematic {
}
}
private static void setUpEntranceDoorLink(World world, Point3D entrance, int rotation, Point3D pocketCenter)
private static void createEntranceReverseLink(NewDimData dimension, Point3D pocketCenter, IDimLink entryLink)
{
//Set the orientation of the rift exit
Point3D entranceRiftLocation = entrance.clone();
BlockRotator.transformPoint(entranceRiftLocation, entrance, rotation, pocketCenter);
NewLinkData sideLink = PocketManager.instance.getLinkDataFromCoords(
entranceRiftLocation.getX(),
entranceRiftLocation.getY(),
entranceRiftLocation.getZ(),
world);
sideLink.linkOrientation = world.getBlockMetadata(
entranceRiftLocation.getX(),
entranceRiftLocation.getY() - 1,
entranceRiftLocation.getZ());
IDimLink link = dimension.createLink(pocketCenter.getX(), pocketCenter.getY(), pocketCenter.getZ(), IDimLink.TYPE_NORMAL);
Point4D destination = link.source();
NewDimData prevDim = PocketManager.getDimensionData(destination.getDimension());
prevDim.setDestination(link, destination.getX(), destination.getY(), destination.getZ());
}
private static void setUpExitDoorLink(World world, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter, int originDimID, int destDimID, Random random)
private static void createExitDoorLink(NewDimData dimension, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter)
{
try
{
//TODO: Hax, remove this later
DDProperties properties = DDProperties.instance();
//Transform doorLocation to the pocket coordinate system.
Point3D location = point.clone();
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);
int blockDirection = world.getBlockMetadata(location.getX(), location.getY() - 1, location.getZ());
Point3D linkDestination = location.clone();
NewLinkData randomLink = PocketManager.instance.getRandomLinkData(false);
NewLinkData sideLink = new NewLinkData(destDimID,
PocketManager.instance.getDimData(originDimID).exitDimLink.destDimID,
location.getX(),
location.getY(),
location.getZ(),
linkDestination.getX(),
linkDestination.getY() + 1,
linkDestination.getZ(),
true, blockDirection);
if (sideLink.destDimID == properties.LimboDimensionID)
{
sideLink.destDimID = 0;
}
else if ((random.nextBoolean() && randomLink != null))
{
sideLink.destDimID = randomLink.locDimID;
}
sideLink.destYCoord = yCoordHelper.getFirstUncovered(sideLink.destDimID, linkDestination.getX(), linkDestination.getY(), linkDestination.getZ())-1;
if (sideLink.destYCoord < 5)
{
sideLink.destYCoord = 70;
}
sideLink.linkOrientation = world.getBlockMetadata(linkDestination.getX(), linkDestination.getY() - 1, linkDestination.getZ());
PocketManager.instance.createLink(sideLink);
/**dimHelper.instance.createLink(sideLink.destDimID ,
sideLink.locDimID,
sideLink.destXCoord,
sideLink.destYCoord,
sideLink.destZCoord,
sideLink.locXCoord,
sideLink.locYCoord,
sideLink.locZCoord,
BlockRotator.transformMetadata(sideLink.linkOrientation, 2, Block.doorWood.blockID));
**/
if (world.getBlockId(linkDestination.getX(), linkDestination.getY() - 3, linkDestination.getZ()) == properties.FabricBlockID)
{
setBlockDirectly(world, linkDestination.getX(), linkDestination.getY() - 2, linkDestination.getZ(), Block.stoneBrick.blockID, 0);
}
else
{
setBlockDirectly(world,linkDestination.getX(), linkDestination.getY() - 2, linkDestination.getZ(),
world.getBlockId(linkDestination.getX(), linkDestination.getY() - 3, linkDestination.getZ()),
world.getBlockMetadata(linkDestination.getX(), linkDestination.getY() - 3, linkDestination.getZ()));
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
private static void setUpDimensionalDoorLink(World world, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter, int originDimID, int destDimID, boolean applyNoise, Random random)
{
int depth = PocketManager.instance.getDimDepth(originDimID) + 1;
int forwardNoise;
int sidewaysNoise;
if (applyNoise)
{
forwardNoise = MathHelper.getRandomIntegerInRange(random, -50 * depth, 150 * depth);
sidewaysNoise = MathHelper.getRandomIntegerInRange(random, -10 * depth, 10 * depth);
}
else
{
forwardNoise = 0;
sidewaysNoise = 0;
}
//Transform doorLocation to the pocket coordinate system
//Transform the door's location to the pocket coordinate system
Point3D location = point.clone();
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);
int blockDirection = world.getBlockMetadata(location.getX(), location.getY() - 1, location.getZ());
dimension.createLink(location.getX(), location.getY(), location.getZ(), IDimLink.TYPE_DUNGEON_EXIT);
}
//Rotate the link destination noise to point in the same direction as the door exit
//and add it to the door's location. Use EAST as the reference orientation since linkDestination
//is constructed as if pointing East.
Point3D linkDestination = new Point3D(forwardNoise, 0, sidewaysNoise);
Point3D zeroPoint = new Point3D(0, 0, 0);
BlockRotator.transformPoint(linkDestination, zeroPoint, blockDirection - BlockRotator.EAST_DOOR_METADATA, location);
//Create the link between our current door and its intended exit in destination pocket
NewLinkData sideLink = new NewLinkData(destDimID, 0,
location.getX(),
location.getY(),
location.getZ(),
linkDestination.getX(),
linkDestination.getY() + 1,
linkDestination.getZ(),
true, blockDirection);
PocketManager.instance.createPocket(sideLink, true, true);
private static void createDimensionalDoorLink(NewDimData dimension, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter)
{
//Transform the door's location to the pocket coordinate system
Point3D location = point.clone();
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);
dimension.createLink(location.getX(), location.getY(), location.getZ(), IDimLink.TYPE_DUNGEON);
}
private static void spawnMonolith(World world, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter)

View File

@@ -30,7 +30,7 @@ import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack;
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPackConfig;
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPackConfigReader;
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonType;
import StevenDimDoors.mod_pocketDim.items.itemDimDoor;
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
import StevenDimDoors.mod_pocketDim.util.ConfigurationProcessingException;
import StevenDimDoors.mod_pocketDim.util.WeightedContainer;
@@ -278,10 +278,10 @@ public class DungeonHelper
{
//Create a link above the specified position. Link to a new pocket dimension.
NewDimData dimension = PocketManager.getDimensionData(world);
IDimLink link = dimension.createLink(x, y + 1, z).setLinkType(IDimLink.TYPE_POCKET);
IDimLink link = dimension.createLink(x, y + 1, z, IDimLink.TYPE_POCKET);
//Place a Warp Door linked to that pocket
itemDimDoor.placeDoorBlock(world, x, y, z, 3, mod_pocketDim.ExitDoor);
ItemDimensionalDoor.placeDoorBlock(world, x, y, z, 3, mod_pocketDim.warpDoor);
return link;
}

View File

@@ -22,7 +22,7 @@ public class yCoordHelper
int localX = x < 0 ? (x % 16) + 16 : (x % 16);
int localZ = z < 0 ? (z % 16) + 16 : (z % 16);
int height = MAXIMUM_UNCOVERED_Y; //world.getHeight();
int height = MAXIMUM_UNCOVERED_Y;
int y;
if (!fromTop)

View File

@@ -0,0 +1,146 @@
package StevenDimDoors.mod_pocketDim.items;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemDoor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.IDimLink;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
public abstract class BaseItemDoor extends ItemDoor
{
private static DDProperties properties = null;
public BaseItemDoor(int itemID, Material material)
{
super(itemID, material);
this.setMaxStackSize(64);
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
if (properties == null)
properties = DDProperties.instance();
}
public void registerIcons(IconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
}
@SuppressWarnings({ "rawtypes" })
@Override
public abstract void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4);
@Override
public abstract boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10);
public static boolean tryItemUse(Block doorBlock, ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, boolean requireLink, boolean reduceStack)
{
//FIXME: Without any sort of this documentation, this condition is like magic -_- ~SenseiKiwi
if (par7 == 1 && !world.isRemote)
{
int blockID = world.getBlockId(x, y, z);
if (blockID != 0)
{
if (!Block.blocksList[blockID].isBlockReplaceable(world, x, y, z))
{
y++;
}
}
if (canPlace(world, x, y, z) && canPlace(world, x, y + 1, z) &&
player.canPlayerEdit(x, y, z, par7, stack) && player.canPlayerEdit(x, y + 1, z, par7, stack) &&
(!requireLink || PocketManager.getLink(x, y + 1, z, world) != null))
{
int orientation = MathHelper.floor_double((double) ((player.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
placeDoorBlock(world, x, y, z, orientation, doorBlock);
if (!player.capabilities.isCreativeMode && reduceStack)
{
stack.stackSize--;
}
return true;
}
}
return false;
}
@Override
public final MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3)
{
float var4 = 1.0F;
float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * (double)var4;
double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * (double)var4 + 1.62D - (double)par2EntityPlayer.yOffset;
double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * (double)var4;
Vec3 var13 = par1World.getWorldVec3Pool().getVecFromPool(var7, var9, var11);
float var14 = MathHelper.cos(-var6 * 0.017453292F - (float)Math.PI);
float var15 = MathHelper.sin(-var6 * 0.017453292F - (float)Math.PI);
float var16 = -MathHelper.cos(-var5 * 0.017453292F);
float var17 = MathHelper.sin(-var5 * 0.017453292F);
float var18 = var15 * var16;
float var20 = var14 * var16;
double var21 = 5.0D;
if (par2EntityPlayer instanceof EntityPlayerMP)
{
var21 = 4;
}
Vec3 var23 = var13.addVector((double) var18 * var21, (double)var17 * var21, (double)var20 * var21);
return par1World.rayTraceBlocks_do_do(var13, var23, true, false);
}
@Override
public abstract ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player);
public boolean tryPlacingDoor(Block doorBlock, World world, EntityPlayer player, ItemStack item)
{
if (world.isRemote)
{
return false;
}
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(player.worldObj, player, false);
if (hit != null)
{
if (world.getBlockId(hit.blockX, hit.blockY, hit.blockZ) == properties.RiftBlockID)
{
IDimLink link = PocketManager.getLink(hit.blockX, hit.blockY, hit.blockZ, world.provider.dimensionId);
if (link != null)
{
int x = hit.blockX;
int y = hit.blockY;
int z = hit.blockZ;
int par7 = 0;
if (player.canPlayerEdit(x, y, z, par7, item) && player.canPlayerEdit(x, y - 1, z, par7, item))
{
if (canPlace(world, x, y, z) && canPlace(world, x, y - 1, z))
{
int orientation = MathHelper.floor_double(((player.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
placeDoorBlock(world, x, y - 1, z, orientation, doorBlock);
return true;
}
}
}
}
}
return false;
}
public static boolean canPlace(World world, int x, int y, int z)
{
int id = world.getBlockId(x, y, z);
return (id == properties.RiftBlockID || id == 0 || Block.blocksList[id].blockMaterial.isReplaceable());
}
}

View File

@@ -1,32 +0,0 @@
package StevenDimDoors.mod_pocketDim.items;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
public class ItemChaosDoor extends itemDimDoor
{
public ItemChaosDoor(int par1, Material par2Material)
{
super(par1, par2Material);
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
}
public void registerIcons(IconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("Caution: Leads to random destination");
}
}

View File

@@ -0,0 +1,48 @@
package StevenDimDoors.mod_pocketDim.items;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
public class ItemDimensionalDoor extends BaseItemDoor
{
public ItemDimensionalDoor(int itemID, Material material)
{
super(itemID, material);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("Place on the block under a rift");
par3List.add("to activate that rift or place");
par3List.add("anywhere else to create a");
par3List.add("pocket dimension.");
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
if (!world.isRemote)
{
if (tryPlacingDoor(mod_pocketDim.dimensionalDoor, world, player, stack) &&
!player.capabilities.isCreativeMode)
{
stack.stackSize--;
}
}
return stack;
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y,
int z, int par7, float par8, float par9, float par10)
{
return tryItemUse(mod_pocketDim.dimensionalDoor, stack, player, world, x, y, z, par7, false, true);
}
}

View File

@@ -5,14 +5,12 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.EnumAction;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.util.AxisAlignedBB;
@@ -22,37 +20,35 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
import StevenDimDoors.mod_pocketDim.core.IDimLink;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemRiftBlade extends ItemSword
{
public ItemRiftBlade(int par1)
private static DDProperties properties = null;
public ItemRiftBlade(int itemID, EnumToolMaterial material)
{
super(par1, EnumToolMaterial.GOLD);
super(itemID, material);
// this.setTextureFile("/PocketBlockTextures.png");
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
this.setMaxStackSize(1);
// this.itemIcon=5;
this.setMaxDamage(500);
this.hasSubtypes=false;
//TODO move to proxy
this.hasSubtypes = false;
if (properties == null)
properties = DDProperties.instance();
}
private static DDProperties properties = null;
@SideOnly(Side.CLIENT)
public boolean isFull3D()
{
return true;
}
@Override
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
{
if (par2Block.blockID == Block.web.blockID)
@@ -71,20 +67,22 @@ public class ItemRiftBlade extends ItemSword
public boolean hasEffect(ItemStack par1ItemStack)
{
return true;
}
@Override
public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
{
par1ItemStack.damageItem(1, par3EntityLiving);
return true;
}
@Override
public int getDamageVsEntity(Entity par1Entity)
{
return 7;
}
@Override
public MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3)
{
float var4 = 1.0F;
@@ -109,11 +107,10 @@ public class ItemRiftBlade extends ItemSword
return par1World.rayTraceBlocks_do_do(var13, var23, true, false);
}
protected boolean teleportToEntity(ItemStack item, Entity par1Entity, EntityPlayer holder)
private boolean teleportToEntity(ItemStack item, Entity par1Entity, EntityPlayer holder)
{
Vec3 var2 = holder.worldObj.getWorldVec3Pool().getVecFromPool(holder.posX - par1Entity.posX, holder.boundingBox.minY + (double)(holder.height / 2.0F) - par1Entity.posY + (double)par1Entity.getEyeHeight(), holder.posZ - par1Entity.posZ);
double cooef =( var2.lengthVector()-2.5)/var2.lengthVector();
var2.xCoord*=cooef;
var2.yCoord*=cooef;
@@ -123,7 +120,6 @@ public class ItemRiftBlade extends ItemSword
double var7 =holder.worldObj.getHeightValue(MathHelper.floor_double(var5), MathHelper.floor_double(var9));
if((Math.abs((holder.posY - var2.yCoord)-var7)>2))
{
var7 = MathHelper.floor_double(holder.posY - var2.yCoord) ;
int var14 = MathHelper.floor_double(var5);
@@ -136,262 +132,169 @@ public class ItemRiftBlade extends ItemSword
var7=var15;
}
holder.setPositionAndUpdate(var5, var7, var9);
holder.playSound("mob.endermen.portal", 1.0F, 1.0F);
holder.worldObj.playSoundEffect(holder.posX, holder.posY, holder.posZ, "mob.endermen.portal", 1.0F, 1.0F);
return true;
}
public ItemStack onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
return par1ItemStack;
}
/**
* How long it takes to use or consume an item
*/
public int getMaxItemUseDuration(ItemStack par1ItemStack)
@Override
public int getMaxItemUseDuration(ItemStack par1ItemStack)
{
return 72000;
}
public EnumAction getItemUseAction(ItemStack par1ItemStack)
@Override
public EnumAction getItemUseAction(ItemStack stack)
{
return properties.RiftBladeRiftCreationEnabled ? EnumAction.bow : EnumAction.block;
}
public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4)
@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int itemInUseCount)
{
//Condition for disabling rift creation
if (!properties.RiftBladeRiftCreationEnabled)
return;
Vec3 var2 = par3EntityPlayer.getLook(1.0F);
if (world.isRemote)
return;
Vec3 var2 = player.getLook(1.0F);
double cooef = -2;
var2.xCoord*=cooef;
var2.yCoord*=cooef;
var2.zCoord*=cooef;
double var5 = par3EntityPlayer.posX - var2.xCoord;
double var9 = par3EntityPlayer.posZ - var2.zCoord;
double var7 = par3EntityPlayer.posY - var2.yCoord+2;
var2.xCoord *= cooef;
var2.yCoord *= cooef;
var2.zCoord *= cooef;
double var5 = player.posX - var2.xCoord;
double var9 = player.posZ - var2.zCoord;
double var7 = player.posY - var2.yCoord + 2;
int x = MathHelper.floor_double(var5);
int y = MathHelper.floor_double(var7);
int z = MathHelper.floor_double(var9);
int rotation = (int) (MathHelper.floor_double((double)((par3EntityPlayer.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
NewLinkData link = new NewLinkData(par2World.provider.dimensionId, 0, x, y, z, x, y, z, true,rotation);
int orientation = (int) (MathHelper.floor_double((double) ((player.rotationYaw + 90) * 4.0F / 360.0F) + 0.5D) & 3);
if(this.getMaxItemUseDuration(par1ItemStack)-par4>12&&!par2World.isRemote&&itemDimDoor.canPlace(par2World, x, y, z, rotation))
//TODO: This looks weird. Shouldn't we aim to only create rifts on maxed-out usage time? i.e. "<= 0"
if (this.getMaxItemUseDuration(stack) - itemInUseCount > 12 &&
ItemDimensionalDoor.canPlace(world, x, y, z) && ItemDimensionalDoor.canPlace(world, x, y + 1, z))
{
if(PocketManager.instance.getDimData(par2World.provider.dimensionId)!=null)
NewDimData dimension = PocketManager.getDimensionData(world);
if (!dimension.isPocketDimension() && dimension.getLink(x, y + 1, z) == null)
{
if(PocketManager.instance.getDimData(par2World.provider.dimensionId).depth==0)
{
PocketManager.instance.createPocket(link,true, false);
}
dimension.createLink(x, y + 1, z, IDimLink.TYPE_POCKET);
player.worldObj.playSoundAtEntity(player,"mods.DimDoors.sfx.riftDoor", 0.6f, 1);
ItemDimensionalDoor.placeDoorBlock(world, x, y, z, orientation, mod_pocketDim.transientDoor);
}
else
{
PocketManager.instance.createPocket(link,true, false);
}
par3EntityPlayer.worldObj.playSoundAtEntity(par3EntityPlayer,"mods.DimDoors.sfx.riftDoor", (float) .6, 1);
itemDimDoor.placeDoorBlock(par2World, x, y-1, z, rotation, mod_pocketDim.transientDoor);
}
}
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
Boolean didFindThing=false;
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(par3EntityPlayer.worldObj, par3EntityPlayer, false );
if(hit!=null&&!par2World.isRemote)
if (!world.isRemote)
{
if(par2World.getBlockId(hit.blockX, hit.blockY, hit.blockZ)==properties.RiftBlockID)
@SuppressWarnings("unchecked")
List<EntityLiving> list = (List<EntityLiving>) world.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(player.posX-8,player.posY-8, player.posZ-8, player.posX+8,player.posY+8, player.posZ+8));
list.remove(player);
for (EntityLiving ent : list)
{
NewLinkData link = PocketManager.instance.getLinkDataFromCoords(hit.blockX, hit.blockY, hit.blockZ, par2World);
if(link!=null)
{
Block var11 = mod_pocketDim.transientDoor;
int par4 = hit.blockX;
int par5 = hit.blockY;
int par6 = hit.blockZ;
int par7 = 0 ;
if (par3EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par3EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)&&!par2World.isRemote)
{
int var12 = MathHelper.floor_double((double)((par3EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
if (!itemDimDoor.canPlace(par2World, par4, par5, par6, var12)||!itemDimDoor.canPlace(par2World, par4, par5-1, par6, var12)||PocketManager.instance.getLinkDataFromCoords(par4, par5, par6, par2World)==null)
{
return par1ItemStack;
}
else
{
itemDimDoor.placeDoorBlock(par2World, par4, par5-1, par6, var12, var11);
par3EntityPlayer.worldObj.playSoundAtEntity(par3EntityPlayer,"mods.DimDoors.sfx.riftDoor", (float) .6, 1);
didFindThing=true;
par1ItemStack.damageItem(10, par3EntityPlayer);
}
}
}
}
else if(par2World.getBlockId(hit.blockX, hit.blockY, hit.blockZ) == properties.TransientDoorID)
{
didFindThing=true;
}
}
if(!par3EntityPlayer.worldObj.isRemote)
{
List<EntityLiving> list = par3EntityPlayer.worldObj.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox( par3EntityPlayer.posX-8,par3EntityPlayer.posY-8, par3EntityPlayer.posZ-8, par3EntityPlayer.posX+8,par3EntityPlayer.posY+8, par3EntityPlayer.posZ+8));
list.remove(par3EntityPlayer);
for(EntityLiving ent : list)
{
Vec3 var3 = par3EntityPlayer.getLook(1.0F).normalize();
Vec3 var4 = par3EntityPlayer.worldObj.getWorldVec3Pool().getVecFromPool(ent.posX - par3EntityPlayer.posX, ent.boundingBox.minY + (double)((ent.height) / 2.0F) - ( par3EntityPlayer.posY + (double) par3EntityPlayer.getEyeHeight()), ent.posZ - par3EntityPlayer.posZ);
Vec3 var3 = player.getLook(1.0F).normalize();
Vec3 var4 = player.worldObj.getWorldVec3Pool().getVecFromPool(ent.posX - player.posX, ent.boundingBox.minY + (double)((ent.height) / 2.0F) - ( player.posY + (double) player.getEyeHeight()), ent.posZ - player.posZ);
double var5 = var4.lengthVector();
var4 = var4.normalize();
double var7 = var3.dotProduct(var4);
if( (var7+.1) > 1.0D - 0.025D / var5 ? par3EntityPlayer.canEntityBeSeen(ent) : false)
if( (var7+.1) > 1.0D - 0.025D / var5 ? player.canEntityBeSeen(ent) : false)
{
System.out.println(list.size());
ItemRiftBlade.class.cast(par1ItemStack.getItem()).teleportToEntity(par1ItemStack,ent, par3EntityPlayer);
didFindThing=true;
break;
//ItemRiftBlade.class.cast(item.getItem()).teleportTo(event.entityPlayer, ent.posX, ent.posY, ent.posZ);
((ItemRiftBlade) stack.getItem()).teleportToEntity(stack, ent, player);
return stack;
}
}
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, false);
if (hit != null)
{
if (world.getBlockId(hit.blockX, hit.blockY, hit.blockZ) == properties.RiftBlockID)
{
if (PocketManager.getLink(hit.blockX, hit.blockY, hit.blockZ, world) != null)
{
Block var11 = mod_pocketDim.transientDoor;
int par4 = hit.blockX;
int par5 = hit.blockY;
int par6 = hit.blockZ;
int par7 = 0;
}
// if(dimHelper.instance.getDimData(par2World.provider.dimensionId)!=null&&!par2World.isRemote&&!didFindThing)
{
if (player.canPlayerEdit(par4, par5, par6, par7, stack) && player.canPlayerEdit(par4, par5 + 1, par6, par7, stack)&&!world.isRemote)
{
int var12 = MathHelper.floor_double((double)((player.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
if (BaseItemDoor.canPlace(world, par4, par5, par6) &&
BaseItemDoor.canPlace(world, par4, par5 - 1, par6))
{
ItemDimensionalDoor.placeDoorBlock(world, par4, par5 - 1, par6, var12, var11);
player.worldObj.playSoundAtEntity(player,"mods.DimDoors.sfx.riftDoor", 0.6f, 1);
stack.damageItem(10, player);
}
}
}
return stack;
}
}
//FIXME: Should this be inside or after this IF?
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
}
return par1ItemStack;
return stack;
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
}
public int getItemEnchantability()
{
return EnumToolMaterial.GOLD.getEnchantability();
}
/**
* Return the name for this tool's material.
*/
public String getToolMaterialName()
{
return EnumToolMaterial.GOLD.toString();
}
/**
* Return whether this item is repairable in an anvil.
*/
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
{
return mod_pocketDim.itemStableFabric.itemID == par2ItemStack.itemID ? true : super.getIsRepairable(par1ItemStack, par2ItemStack);
}
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
/**
* Return whether this item is repairable in an anvil.
*/
@Override
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
{
if (par7 != 1)
//Don't include a call to super.getIsRepairable()!
//That would cause this sword to accept gold as a repair material (since we set material = Gold).
return mod_pocketDim.itemStableFabric.itemID == par2ItemStack.itemID ? true : false;
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y,
int z, int par7, float par8, float par9, float par10)
{
if (BaseItemDoor.tryItemUse(mod_pocketDim.transientDoor, stack, player, world, x, y, z, par7, true, false))
{
return false;
world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftDoor", 0.6f, 1);
return true;
}
else
{
++par5;
Block var11;
var11 = mod_pocketDim.transientDoor;
if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)&&!par3World.isRemote)
{
int var12 = MathHelper.floor_double((double)((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
if (!itemDimDoor.canPlace(par3World, par4, par5, par6, var12)||PocketManager.instance.getLinkDataFromCoords(par4, par5+1, par6, par3World)==null)
{
return false;
}
else
{
itemDimDoor.placeDoorBlock(par3World, par4, par5, par6, var12, var11);
par2EntityPlayer.worldObj.playSoundAtEntity(par2EntityPlayer,"mods.DimDoors.sfx.rift", (float) .6, 1);
par1ItemStack.damageItem(10, par2EntityPlayer);
return true;
}
}
else
{
return false;
}
return false;
}
}
@SideOnly(Side.CLIENT)
/**
* allows items to add custom lines of information to the mouseover description
*/
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
@SuppressWarnings({ "unchecked", "rawtypes" })
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("Opens a temporary doors,");
par3List.add ("special teleport attack,");
par3List.add ("and rotates existing doors");
}
@Override
public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if(!par2World.isRemote)
{
/**
//creates the first half of the link on item creation
int key= dimHelper.instance.createUniqueInterDimLinkKey();
LinkData linkData= new LinkData(par2World.provider.dimensionId,MathHelper.floor_double(par3EntityPlayer.posX),MathHelper.floor_double(par3EntityPlayer.posY),MathHelper.floor_double(par3EntityPlayer.posZ));
System.out.println(key);
dimHelper.instance.interDimLinkList.put(key, linkData);
par1ItemStack.setItemDamage(key);
**/
}
par3List.add("Opens a temporary door, has");
par3List.add("a special teleport attack,");
par3List.add("and rotates existing doors.");
}
}

View File

@@ -1,14 +1,11 @@
package StevenDimDoors.mod_pocketDim.items;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.ItemArmor;
public class ItemRiftGoggles extends ItemArmor
{
private Material doorMaterial;
public ItemRiftGoggles(int par1, int par2, int par3)
{

View File

@@ -0,0 +1,174 @@
package StevenDimDoors.mod_pocketDim.items;
import java.util.List;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.IDimLink;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.util.Point4D;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemRiftSignature extends Item
{
public ItemRiftSignature(int itemID)
{
super(itemID);
this.setMaxStackSize(1);
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
this.setMaxDamage(0);
this.hasSubtypes = true;
}
@SideOnly(Side.CLIENT)
@Override
public boolean hasEffect(ItemStack stack)
{
//Make the item glow if it has one endpoint stored
return (stack.getItemDamage() != 0);
}
public void registerIcons(IconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
{
tryItemUse(stack, player, world, x, y, z);
return true;
}
protected boolean tryItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z)
{
if (!world.isRemote)
{
//We don't check for replaceable blocks. The user can deal with that. <_<
y += 2; //Increase y by 2 to place the rift at head level
if (!player.canPlayerEdit(x, y, z, 0, stack))
{
return false;
}
Point4D source = getSource(stack);
if (source != null)
{
//The link was used before and already has an endpoint stored. Create links connecting the two endpoints.
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
NewDimData destinationDimension = PocketManager.getDimensionData(world);
IDimLink link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), IDimLink.TYPE_NORMAL);
IDimLink reverse = destinationDimension.createLink(x, y, z, IDimLink.TYPE_NORMAL);
destinationDimension.setDestination(link, x, y, z);
sourceDimension.setDestination(reverse, source.getX(), source.getY(), source.getZ());
//Try placing a rift at the destination point
if (!mod_pocketDim.blockRift.isBlockImmune(world, x, y, z))
{
world.setBlock(x, y, z, mod_pocketDim.blockRift.blockID);
}
//Try placing a rift at the source point, but check if its world is loaded first
World sourceWorld = DimensionManager.getWorld(sourceDimension.id());
if (sourceWorld != null &&
!mod_pocketDim.blockRift.isBlockImmune(sourceWorld, source.getX(), source.getY(), source.getZ()))
{
sourceWorld.setBlock(source.getX(), source.getY(), source.getY(), mod_pocketDim.blockRift.blockID);
}
if (!player.capabilities.isCreativeMode)
{
stack.stackSize--;
}
clearSource(stack);
player.sendChatToPlayer("Rift Created");
world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftEnd", 0.6f, 1);
}
else
{
//The link signature has not been used. Store its current target as the first location.
setSource(stack, x, y, z, PocketManager.getDimensionData(world));
player.sendChatToPlayer("Location Stored in Rift Signature");
world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftStart", 0.6f, 1);
}
return true;
}
return false;
}
/**
* allows items to add custom lines of information to the mouseover description
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
Point4D source = getSource(par1ItemStack);
if (source != null)
{
par3List.add("Leads to (" + source.getX() + ", " + source.getY() + ", " + source.getZ() + ") at dimension #" + source.getDimension());
}
else
{
par3List.add("First click stores a location;");
par3List.add("second click creates a pair of");
par3List.add("rifts linking the two locations.");
}
}
public static void setSource(ItemStack itemStack, int x, int y, int z, NewDimData dimension)
{
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("linkX", x);
tag.setInteger("linkY", y);
tag.setInteger("linkZ", z);
tag.setInteger("linkDimID", dimension.id());
itemStack.setTagCompound(tag);
itemStack.setItemDamage(1);
}
public static void clearSource(ItemStack itemStack)
{
//Don't just set the tag to null since there may be other data there (e.g. for renamed items)
NBTTagCompound tag = itemStack.getTagCompound();
tag.removeTag("linkX");
tag.removeTag("linkY");
tag.removeTag("linkZ");
tag.removeTag("linkDimID");
itemStack.setItemDamage(0);
}
public static Point4D getSource(ItemStack itemStack)
{
if (itemStack.getItemDamage() != 0)
{
if (itemStack.hasTagCompound())
{
NBTTagCompound tag = itemStack.getTagCompound();
Integer x = tag.getInteger("linkX");
Integer y = tag.getInteger("linkY");
Integer z = tag.getInteger("linkZ");
Integer dimID = tag.getInteger("linkDimID");
if (x != null && y != null && z != null && dimID != null)
{
return new Point4D(x, y, z, dimID);
}
}
itemStack.setItemDamage(0);
}
return null;
}
}

View File

@@ -2,51 +2,21 @@ package StevenDimDoors.mod_pocketDim.items;
import java.util.List;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.util.Point4D;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemStabilizedRiftSignature extends itemLinkSignature
public class ItemStabilizedRiftSignature extends ItemRiftSignature
{
private static DDProperties properties = null;
public ItemStabilizedRiftSignature(int par)
public ItemStabilizedRiftSignature(int itemID)
{
super(par);
this.setMaxStackSize(1);
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
this.setMaxDamage(0);
this.hasSubtypes=true;
if (properties == null)
properties = DDProperties.instance();
}
@SideOnly(Side.CLIENT)
@Override
public boolean hasEffect(ItemStack par1ItemStack)
{
// adds effect if item has a link stored
if(par1ItemStack.hasTagCompound())
{
if(par1ItemStack.stackTagCompound.getBoolean("isCreated"))
{
return true;
}
}
return false;
super(itemID);
}
public void registerIcons(IconRegister par1IconRegister)
@@ -55,148 +25,47 @@ public class ItemStabilizedRiftSignature extends itemLinkSignature
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
{
int key;
NewLinkData linkData;
int thisWorldID=par3World.provider.dimensionId;
Integer[] linkCoords =this.readFromNBT(par1ItemStack);
int offset = 2;
if(par1ItemStack.getTagCompound()!=null)
//Check if the Stabilized Rift Signature has been initialized
Point4D source = getSource(stack);
if (source != null)
{
if(par1ItemStack.getTagCompound().getBoolean("isCreated"))
//Yes, it's initialized. Check if the player can pay an Ender Pearl to create a rift.
if (player.inventory.hasItem(Item.enderPearl.itemID))
{
boolean hasEnder = false;
// checks to see if the item has a link stored, if so, it creates it
if(par2EntityPlayer.inventory.hasItem(Item.enderPearl.itemID)||par2EntityPlayer.inventory.hasItem(properties.StableFabricItemID))
{
if(!par2EntityPlayer.inventory.consumeInventoryItem(properties.StableFabricItemID))
{
par2EntityPlayer.inventory.consumeInventoryItem(Item.enderPearl.itemID);
}
hasEnder=true;
}
if(par3World.getBlockId(par4, par5, par6)==Block.snow.blockID)
{
offset = 1;
}
if(hasEnder&&!par3World.isRemote)
{
if(PocketManager.instance.getLinkDataFromCoords(linkCoords[0], linkCoords[1], linkCoords[2], par3World)==null)
{
PocketManager.instance.createLink(linkCoords[3], par3World.provider.dimensionId, linkCoords[0], linkCoords[1], linkCoords[2],par4, par5+offset, par6);
}
PocketManager.instance.createLink(par3World.provider.dimensionId, linkCoords[3], par4, par5+offset, par6, linkCoords[0], linkCoords[1], linkCoords[2]);
par2EntityPlayer.worldObj.playSoundAtEntity(par2EntityPlayer,"mods.DimDoors.sfx.riftEnd", (float) .6, 1);
par2EntityPlayer.sendChatToPlayer("Rift Created");
}
else if(!par3World.isRemote)
{
par2EntityPlayer.sendChatToPlayer("No Ender Pearls!");
}
if (tryItemUse(stack, player, world, x, y, z) && !player.capabilities.isCreativeMode)
{
player.inventory.consumeInventoryItem(Item.enderPearl.itemID);
}
}
}
else if(!par3World.isRemote)
{
if(par3World.getBlockId(par4, par5, par6)==Block.snow.blockID)
{
offset = 1;
}
//otherwise, it creates the first half of the link. Next click will complete it.
key= PocketManager.instance.createUniqueInterDimLinkKey();
this.writeToNBT(par1ItemStack, par4, par5+offset, par6,par3World.provider.dimensionId);
par2EntityPlayer.worldObj.playSoundAtEntity(par2EntityPlayer,"mods.DimDoors.sfx.riftStart", (float) .6, 1);
par2EntityPlayer.sendChatToPlayer("Rift Signature Stored");
}
else
{
//Initialization doesn't cost any materials
tryItemUse(stack, player, world, x, y, z);
}
return true;
}
@SideOnly(Side.CLIENT)
/**
* allows items to add custom lines of information to the mouseover description
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
if(par1ItemStack.hasTagCompound())
Point4D source = getSource(par1ItemStack);
if (source != null)
{
par3List.add("Leads to (" + source.getX() + ", " + source.getY() + ", " + source.getZ() + ") at dimension #" + source.getDimension());
}
else
{
if(par1ItemStack.stackTagCompound.getBoolean("isCreated"))
{
Integer[] coords = this.readFromNBT(par1ItemStack);
par3List.add(String.valueOf("Leads to dim "+coords[3] +" with depth "+PocketManager.instance.getDimDepth(PocketManager.instance.getDimDepth(coords[3]))));
par3List.add("at x="+coords[0]+" y="+coords[1]+" z="+coords[2]);
}
}
else
{
par3List.add("First click stores location,");
par3List.add ("second click creates two rifts,");
par3List.add("that link the first location");
par3List.add("with the second location");
}
}
public void writeToNBT(ItemStack itemStack,int x, int y, int z, int dimID)
{
NBTTagCompound tag;
if(itemStack.hasTagCompound())
{
tag = itemStack.getTagCompound();
}
else
{
tag= new NBTTagCompound();
}
tag.setInteger("linkX", x);
tag.setInteger("linkY", y);
tag.setInteger("linkZ", z);
tag.setInteger("linkDimID", dimID);
tag.setBoolean("isCreated", true);
itemStack.setTagCompound(tag);
}
/**
* Read the stack fields from a NBT object.
*/
public Integer[] readFromNBT(ItemStack itemStack)
{
NBTTagCompound tag;
Integer[] linkCoords = new Integer[5];
if(itemStack.hasTagCompound())
{
tag = itemStack.getTagCompound();
if(!tag.getBoolean("isCreated"))
{
return null;
}
linkCoords[0]=tag.getInteger("linkX");
linkCoords[1]=tag.getInteger("linkY");
linkCoords[2]=tag.getInteger("linkZ");
linkCoords[3]=tag.getInteger("linkDimID");
}
return linkCoords;
}
@Override
public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if(!par2World.isRemote)
{
/**
//creates the first half of the link on item creation
int key= dimHelper.instance.createUniqueInterDimLinkKey();
LinkData linkData= new LinkData(par2World.provider.dimensionId,MathHelper.floor_double(par3EntityPlayer.posX),MathHelper.floor_double(par3EntityPlayer.posY),MathHelper.floor_double(par3EntityPlayer.posZ));
System.out.println(key);
dimHelper.instance.interDimLinkList.put(key, linkData);
par1ItemStack.setItemDamage(key);
**/
par3List.add("First click stores a location,");
par3List.add("second click creates two rifts");
par3List.add("that link the locations together.");
}
}
}

View File

@@ -1,184 +1,19 @@
package StevenDimDoors.mod_pocketDim.items;
import java.util.List;
import StevenDimDoors.mod_pocketDim.SchematicLoader;
import StevenDimDoors.mod_pocketDim.Spells;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.ticking.CommonTickHandler;
import StevenDimDoors.mod_pocketDimClient.ClientTickHandler;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.RotationHelper;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
public class ItemStableFabric extends Item
{
private Material doorMaterial;
public ItemStableFabric(int par1, int par2)
public ItemStableFabric(int itemID, int par2)
{
super(par1);
// this.setitemIcon(Item.doorWood.getIconFromDamage(0));
super(itemID);
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
}
public void registerIcons(IconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
}
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
if(!par3World.isRemote)
{
System.out.println("Block metadata is "+par3World.getBlockMetadata(par4, par5, par6));
System.out.println(par3World.getBiomeGenForCoords(par4, par6).biomeName);
this.onItemRightClick(par1ItemStack, par3World, par2EntityPlayer);
Block block = Block.blocksList[par3World.getBlockId(par4, par5, par6)];
if(PocketManager.dimList.containsKey(par3World.provider.dimensionId))
{
if(PocketManager.instance.getDimData(par3World.provider.dimensionId).isPocket)
{
if(PocketManager.instance.getDimData(par3World.provider.dimensionId).dungeonGenerator!=null)
{
System.out.println("Dungeon name "+PocketManager.instance.getDimData(par3World.provider.dimensionId).dungeonGenerator.schematicPath);
}
}
}
}
//System.out.println("Block texture data is "+Block.blocksList[par3World.getBlockId(par4, par5, par6)].getBlockTexture(par3World,par4, par5, par6,par7).getIconName());
//System.out.println("Block name is is "+Block.blocksList[par3World.getBlockId(par4, par5, par6)].getUnlocalizedName2());
return true;
}
public MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3)
{
float var4 = 1.0F;
float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * (double)var4;
double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * (double)var4 + 1.62D - (double)par2EntityPlayer.yOffset;
double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * (double)var4;
Vec3 var13 = par1World.getWorldVec3Pool().getVecFromPool(var7, var9, var11);
float var14 = MathHelper.cos(-var6 * 0.017453292F - (float)Math.PI);
float var15 = MathHelper.sin(-var6 * 0.017453292F - (float)Math.PI);
float var16 = -MathHelper.cos(-var5 * 0.017453292F);
float var17 = MathHelper.sin(-var5 * 0.017453292F);
float var18 = var15 * var16;
float var20 = var14 * var16;
double var21 = 5.0D;
if (par2EntityPlayer instanceof EntityPlayerMP)
{
var21 = 4;
}
Vec3 var23 = var13.addVector((double)var18 * var21, (double)var17 * var21, (double)var20 * var21);
return par1World.rayTraceBlocks_do_do(var13, var23, true, false);
}
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if (this.isSteven(par3EntityPlayer))
{
new Spells(par3EntityPlayer, par1ItemStack.stackSize).cast();
//mod_pocketDim.proxy.startCasting(par3EntityPlayer, par1ItemStack.stackSize);
}
Boolean didFindThing=false;
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(par3EntityPlayer.worldObj, par3EntityPlayer, false );
if(hit!=null&&!par2World.isRemote)
{
//if(par2World.getBlockId(hit.blockX, hit.blockY, hit.blockZ)==properties.RiftBlockID)
{
NewLinkData link = PocketManager.instance.getLinkDataFromCoords(hit.blockX, hit.blockY, hit.blockZ, par2World);
if(link!=null)
{
Block var11;
if(par1ItemStack.getItem() instanceof itemExitDoor )
{
var11 = mod_pocketDim.ExitDoor;
}
else if(par1ItemStack.getItem() instanceof ItemChaosDoor )
{
var11 = mod_pocketDim.chaosDoor;
}
else
{
var11 = mod_pocketDim.dimDoor;
}
int par4 = hit.blockX;
int par5 = hit.blockY-1;
int par6 = hit.blockZ;
int par7 = 0 ;
if (par3EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par3EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)&&!par2World.isRemote)
{
int var12 = MathHelper.floor_double((double)((par3EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
String cardinal= "default";
switch(link.linkOrientation)
{
case 0:
cardinal = "East";
break;
case 1:
cardinal = "South";
break;
case 2:
cardinal = "West";
break;
case 3:
cardinal = "North";
break;
}
System.out.println("Link orientation is " + link.linkOrientation + " - " + cardinal);
}
}
}
}
return par1ItemStack;
}
public boolean isSteven(EntityPlayer player)
{
return (player.username.equalsIgnoreCase("stevenrs11"));
}
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
}
}

View File

@@ -0,0 +1,45 @@
package StevenDimDoors.mod_pocketDim.items;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
public class ItemUnstableDoor extends BaseItemDoor
{
public ItemUnstableDoor(int itemID, Material material)
{
super(itemID, material);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("Caution: Leads to random destination");
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
if (!world.isRemote)
{
if (tryPlacingDoor(mod_pocketDim.unstableDoor, world, player, stack) &&
!player.capabilities.isCreativeMode)
{
stack.stackSize--;
}
}
return stack;
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y,
int z, int par7, float par8, float par9, float par10)
{
return tryItemUse(mod_pocketDim.unstableDoor, stack, player, world, x, y, z, par7, false, true);
}
}

View File

@@ -1 +0,0 @@
package StevenDimDoors.mod_pocketDim.items;

View File

@@ -0,0 +1,48 @@
package StevenDimDoors.mod_pocketDim.items;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
public class ItemWarpDoor extends BaseItemDoor
{
public ItemWarpDoor(int itemID, Material material)
{
super(itemID, material);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("Place on the block under");
par3List.add("a rift to create a portal,");
par3List.add("or place anywhere in a");
par3List.add("pocket dimension to exit.");
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
if (!world.isRemote)
{
if (tryPlacingDoor(mod_pocketDim.warpDoor, world, player, stack) &&
!player.capabilities.isCreativeMode)
{
stack.stackSize--;
}
}
return stack;
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y,
int z, int par7, float par8, float par9, float par10)
{
return tryItemUse(mod_pocketDim.warpDoor, stack, player, world, x, y, z, par7, false, true);
}
}

View File

@@ -1,208 +0,0 @@
package StevenDimDoors.mod_pocketDim.items;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemDoor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
public class itemDimDoor extends ItemDoor
{
private static DDProperties properties = null;
public itemDimDoor(int par1, Material par2Material)
{
super(par1, par2Material);
this.setMaxStackSize(64);
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
if (properties == null)
properties = DDProperties.instance();
}
public void registerIcons(IconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("Place on the block under a rift");
par3List.add("to activate that rift or place");
par3List.add("anywhere else to create a");
par3List.add("pocket dimension.");
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
if (par7 != 1)
{
return false;
}
else
{
++par5;
Block var11;
if(par1ItemStack.getItem() instanceof itemExitDoor )
{
var11 = mod_pocketDim.ExitDoor;
}
else if(par1ItemStack.getItem() instanceof ItemChaosDoor )
{
var11 = mod_pocketDim.chaosDoor;
}
else
{
var11 = mod_pocketDim.dimDoor;
}
if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)&&!par3World.isRemote)
{
int var12 = MathHelper.floor_double((double)((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
if (!canPlace(par3World, par4, par5, par6, var12) || !canPlace(par3World, par4, par5+1, par6, var12))
{
return false;
}
else
{
int offset = 0;
int idBlock = par3World.getBlockId(par4, par5-1, par6);
if(Block.blocksList.length>idBlock&&idBlock!=0)
{
if(Block.blocksList[idBlock].isBlockReplaceable(par3World, par4, par5-1, par6))
{
offset = 1;
}
}
placeDoorBlock(par3World, par4, par5-offset, par6, var12, var11);
--par1ItemStack.stackSize;
return true;
}
}
else
{
return false;
}
}
}
public MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3)
{
float var4 = 1.0F;
float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * (double)var4;
double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * (double)var4 + 1.62D - (double)par2EntityPlayer.yOffset;
double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * (double)var4;
Vec3 var13 = par1World.getWorldVec3Pool().getVecFromPool(var7, var9, var11);
float var14 = MathHelper.cos(-var6 * 0.017453292F - (float)Math.PI);
float var15 = MathHelper.sin(-var6 * 0.017453292F - (float)Math.PI);
float var16 = -MathHelper.cos(-var5 * 0.017453292F);
float var17 = MathHelper.sin(-var5 * 0.017453292F);
float var18 = var15 * var16;
float var20 = var14 * var16;
double var21 = 5.0D;
if (par2EntityPlayer instanceof EntityPlayerMP)
{
var21 = 4;
}
Vec3 var23 = var13.addVector((double)var18 * var21, (double)var17 * var21, (double)var20 * var21);
return par1World.rayTraceBlocks_do_do(var13, var23, true, false);
}
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(par3EntityPlayer.worldObj, par3EntityPlayer, false );
if(hit!=null&&!par2World.isRemote)
{
if(par2World.getBlockId(hit.blockX, hit.blockY, hit.blockZ) == properties.RiftBlockID)
{
NewLinkData link = PocketManager.instance.getLinkDataFromCoords(hit.blockX, hit.blockY, hit.blockZ, par2World);
if(link!=null)
{
Block var11;
if(par1ItemStack.getItem() instanceof itemExitDoor )
{
var11 = mod_pocketDim.ExitDoor;
}
else if(par1ItemStack.getItem() instanceof ItemChaosDoor )
{
var11 = mod_pocketDim.chaosDoor;
}
else
{
var11 = mod_pocketDim.dimDoor;
}
int par4 = hit.blockX;
int par5 = hit.blockY;
int par6 = hit.blockZ;
int par7 = 0 ;
if (par3EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par3EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)&&!par2World.isRemote)
{
int var12 = MathHelper.floor_double((double)((par3EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
if (!canPlace(par2World, par4, par5, par6, var12) || !canPlace(par2World, par4, par5-1, par6, var12) ||
PocketManager.instance.getLinkDataFromCoords(par4, par5, par6, par2World) == null)
{
return par1ItemStack;
}
else
{
placeDoorBlock(par2World, par4, par5-1, par6, var12, var11);
--par1ItemStack.stackSize;
}
}
}
}
}
return par1ItemStack;
}
public static boolean canPlace(World world,int i, int j, int k, int p)
{
int id = world.getBlockId(i, j, k);
boolean flag = true;
if (id==properties.FabricBlockID || id==properties.RiftBlockID || id==properties.PermaFabricBlockID || id == 0)
{
return true;
}
if (id != 0 && !Block.blocksList[id].blockMaterial.isReplaceable())
{
flag = false;
}
return flag;
}
}

View File

@@ -1,51 +0,0 @@
package StevenDimDoors.mod_pocketDim.items;
import java.util.List;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemDoor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class itemExitDoor extends itemDimDoor
{
private Material doorMaterial;
public itemExitDoor(int par1, Material par2Material)
{
super(par1, par2Material);
this.doorMaterial = par2Material;
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
}
public void registerIcons(IconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
}
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("Place on the block under a rift");
par3List.add ("in any dimension,");
par3List.add("or place anywhere in pocket dim");
par3List.add("to approach surface");
}
}

View File

@@ -1,274 +0,0 @@
package StevenDimDoors.mod_pocketDim.items;
import java.util.List;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.ILinkData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class itemLinkSignature extends Item
{
public itemLinkSignature(int par1)
{
super(par1);
this.setMaxStackSize(1);
// this.setTextureFile("/PocketBlockTextures.png");
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
// this.itemIcon=5;
this.setMaxDamage(0);
this.hasSubtypes=true;
//TODO move to proxy
if (properties == null)
properties = DDProperties.instance();
}
private static DDProperties properties = null;
@SideOnly(Side.CLIENT)
@Override
public boolean hasEffect(ItemStack par1ItemStack)
{
// adds effect if item has a link stored
if(par1ItemStack.hasTagCompound())
{
if(par1ItemStack.stackTagCompound.getBoolean("isCreated"))
{
return true;
}
}
return false;
}
public void registerIcons(IconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
int key;
ILinkData linkData;
int thisWorldID=par3World.provider.dimensionId;
if(!par3World.isRemote)
{
//par1ItemStack= par2EntityPlayer.getCurrentEquippedItem();
Integer[] linkCoords =this.readFromNBT(par1ItemStack);
//System.out.println(key);
int offset = 2;
int idBlock = par3World.getBlockId(par4, par5, par6);
if(Block.blocksList.length>idBlock&&idBlock!=0)
{
if(Block.blocksList[idBlock].isBlockReplaceable(par3World, par4, par5, par6))
{
offset = 1;
}
}
if(par3World.getBlockId(par4, par5, par6) == properties.DimensionalDoorID && par3World.getBlockId(par4, par5 + 1, par6) == properties.DimensionalDoorID)
{
offset = 1;
}
else
if(par3World.getBlockId(par4, par5, par6)==properties.WarpDoorID&&par3World.getBlockId(par4, par5+1, par6)==properties.WarpDoorID)
{
offset = 1;
}
else
if (par3World.getBlockId(par4, par5, par6)==properties.DimensionalDoorID&&par3World.getBlockId(par4, par5-1, par6)==properties.DimensionalDoorID)
{
offset = 0;
}
else
if (par3World.getBlockId(par4, par5, par6) == properties.WarpDoorID && par3World.getBlockId(par4, par5-1, par6)==properties.WarpDoorID)
{
offset = 0;
}
int orientation = MathHelper.floor_double((double)((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
for(int count = 0;count<3;count++)
{
if(PocketManager.instance.getLinkDataFromCoords(par4, par5+count, par6,par3World)!=null)
{
int id= (par3World.getBlockId(par4, par5+count, par6));
if(id == properties.DimensionalDoorID||id==properties.WarpDoorID||id== properties.UnstableDoorID)
{
orientation = PocketManager.instance.getLinkDataFromCoords(par4, par5+count, par6,par3World).linkOrientation;
}
}
}
if(par1ItemStack.getTagCompound()!=null)
{
if(par1ItemStack.getTagCompound().getBoolean("isCreated"))
{
// checks to see if the item has a link stored, if so, it creates it
PocketManager.instance.createLink(par3World.provider.dimensionId, linkCoords[3], par4, par5+offset, par6, linkCoords[0], linkCoords[1], linkCoords[2],orientation);
PocketManager.instance.createLink(linkCoords[3], par3World.provider.dimensionId, linkCoords[0], linkCoords[1], linkCoords[2],par4, par5+offset, par6,linkCoords[4]);
--par1ItemStack.stackSize;
par2EntityPlayer.sendChatToPlayer("Rift Created");
par1ItemStack.stackTagCompound=null;
par2EntityPlayer.worldObj.playSoundAtEntity(par2EntityPlayer,"mods.DimDoors.sfx.riftEnd", (float) .6, 1);
}
}
else
{
//otherwise, it creates the first half of the link. Next click will complete it.
key= PocketManager.instance.createUniqueInterDimLinkKey();
this.writeToNBT(par1ItemStack, par4, par5+offset, par6,par3World.provider.dimensionId,orientation);
par2EntityPlayer.sendChatToPlayer("Rift Signature Stored");
par2EntityPlayer.worldObj.playSoundAtEntity(par2EntityPlayer,"mods.DimDoors.sfx.riftStart", (float) .6, 1);
}
//dimHelper.instance.save();
}
return true;
}
@SideOnly(Side.CLIENT)
/**
* allows items to add custom lines of information to the mouseover description
*/
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
if(par1ItemStack.hasTagCompound())
{
if(par1ItemStack.stackTagCompound.getBoolean("isCreated"))
{
Integer[] coords = this.readFromNBT(par1ItemStack);
par3List.add(String.valueOf("Leads to dim "+coords[3] +" with depth "+(PocketManager.instance.getDimDepth(coords[3]))));
par3List.add("at x="+coords[0]+" y="+coords[1]+" z="+coords[2]);
}
}
else
{
par3List.add("First click stores location,");
par3List.add ("second click creates two rifts,");
par3List.add("that link the first location");
par3List.add("with the second location");
}
}
public void writeToNBT(ItemStack itemStack,int x, int y, int z, int dimID,int orientation)
{
NBTTagCompound tag;
if(itemStack.hasTagCompound())
{
tag = itemStack.getTagCompound();
}
else
{
tag= new NBTTagCompound();
}
tag.setInteger("linkX", x);
tag.setInteger("linkY", y);
tag.setInteger("linkZ", z);
tag.setInteger("linkDimID", dimID);
tag.setBoolean("isCreated", true);
tag.setInteger("orientation", orientation);
itemStack.setTagCompound(tag);
}
/**
* Read the stack fields from a NBT object.
*/
public Integer[] readFromNBT(ItemStack itemStack)
{
NBTTagCompound tag;
Integer[] linkCoords = new Integer[5];
if(itemStack.hasTagCompound())
{
tag = itemStack.getTagCompound();
if(!tag.getBoolean("isCreated"))
{
return null;
}
linkCoords[0]=tag.getInteger("linkX");
linkCoords[1]=tag.getInteger("linkY");
linkCoords[2]=tag.getInteger("linkZ");
linkCoords[3]=tag.getInteger("linkDimID");
linkCoords[4]=tag.getInteger("orientation");
}
return linkCoords;
}
@Override
public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if(!par2World.isRemote)
{
/**
//creates the first half of the link on item creation
int key= dimHelper.instance.createUniqueInterDimLinkKey();
LinkData linkData= new LinkData(par2World.provider.dimensionId,MathHelper.floor_double(par3EntityPlayer.posX),MathHelper.floor_double(par3EntityPlayer.posY),MathHelper.floor_double(par3EntityPlayer.posZ));
System.out.println(key);
dimHelper.instance.interDimLinkList.put(key, linkData);
par1ItemStack.setItemDamage(key);
**/
}
}
}

View File

@@ -2,12 +2,8 @@ package StevenDimDoors.mod_pocketDim.items;
import java.util.List;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
@@ -16,40 +12,25 @@ import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class itemRiftRemover extends Item
{
private Material doorMaterial;
public itemRiftRemover(int par1, Material par2Material)
{
super(par1);
this.setMaxStackSize(1);
// this.setTextureFile("/PocketBlockTextures.png");
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
// this.itemIcon=6;
this.setMaxDamage(5);
this.hasSubtypes=true;
//TODO move to proxy
this.hasSubtypes = true;
}
public void registerIcons(IconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
}
@SideOnly(Side.CLIENT)
@Override
public boolean hasEffect(ItemStack par1ItemStack)
{
// adds effect if item has a link stored
return false;
}
public static MovingObjectPosition getBlockTarget(World par1World, EntityPlayer par2EntityPlayer, boolean par3)
@@ -78,59 +59,27 @@ public class itemRiftRemover extends Item
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
{
MovingObjectPosition hit = this.getBlockTarget(par3EntityPlayer.worldObj, par3EntityPlayer, false );
if(hit!=null)
{
//System.out.println(hit.hitVec);
if(PocketManager.instance.removeRift(par2World, hit.blockX, hit.blockY, hit.blockZ, 1, par3EntityPlayer, par1ItemStack))
{
par3EntityPlayer.worldObj.playSoundAtEntity(par3EntityPlayer,"mods.DimDoors.sfx.riftClose", (float) .8, 1);
}
}
// dimHelper.removeRift( par3World, par4, par5, par6, range, par2EntityPlayer, par1ItemStack);
}
MovingObjectPosition hit = getBlockTarget(par3EntityPlayer.worldObj, par3EntityPlayer, false);
if (hit != null)
{
if (PocketManager.removeRift(par2World, hit.blockX, hit.blockY, hit.blockZ, 1, par3EntityPlayer, par1ItemStack))
{
par3EntityPlayer.worldObj.playSoundAtEntity(par3EntityPlayer,"mods.DimDoors.sfx.riftClose", 0.8f, 1);
}
}
return par1ItemStack;
}
@SideOnly(Side.CLIENT)
/**
* allows items to add custom lines of information to the mouseover description
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("Use near exposed rift");
par3List.add ("to remove it and");
par3List.add("any nearby rifts");
}
@Override
public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if(!par2World.isRemote)
{
/**
//creates the first half of the link on item creation
int key= dimHelper.instance.createUniqueInterDimLinkKey();
LinkData linkData= new LinkData(par2World.provider.dimensionId,MathHelper.floor_double(par3EntityPlayer.posX),MathHelper.floor_double(par3EntityPlayer.posY),MathHelper.floor_double(par3EntityPlayer.posZ));
System.out.println(key);
dimHelper.instance.interDimLinkList.put(key, linkData);
par1ItemStack.setItemDamage(key);
**/
}
}
par3List.add("Use near exposed rift");
par3List.add("to remove it and");
par3List.add("any nearby rifts.");
}
}

View File

@@ -10,6 +10,7 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityEggInfo;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.biome.BiomeGenBase;
@@ -19,36 +20,29 @@ import StevenDimDoors.mod_pocketDim.blocks.BlockDimWall;
import StevenDimDoors.mod_pocketDim.blocks.BlockDimWallPerm;
import StevenDimDoors.mod_pocketDim.blocks.BlockLimbo;
import StevenDimDoors.mod_pocketDim.blocks.BlockRift;
import StevenDimDoors.mod_pocketDim.blocks.ChaosDoor;
import StevenDimDoors.mod_pocketDim.blocks.ExitDoor;
import StevenDimDoors.mod_pocketDim.blocks.dimDoor;
import StevenDimDoors.mod_pocketDim.blocks.DimensionalDoor;
import StevenDimDoors.mod_pocketDim.blocks.TransientDoor;
import StevenDimDoors.mod_pocketDim.blocks.UnstableDoor;
import StevenDimDoors.mod_pocketDim.blocks.WarpDoor;
import StevenDimDoors.mod_pocketDim.blocks.dimHatch;
import StevenDimDoors.mod_pocketDim.commands.CommandCreateDungeonRift;
import StevenDimDoors.mod_pocketDim.commands.CommandCreatePocket;
import StevenDimDoors.mod_pocketDim.commands.CommandDeleteAllLinks;
import StevenDimDoors.mod_pocketDim.commands.CommandDeleteDimensionData;
import StevenDimDoors.mod_pocketDim.commands.CommandDeleteRifts;
import StevenDimDoors.mod_pocketDim.commands.CommandExportDungeon;
import StevenDimDoors.mod_pocketDim.commands.CommandPrintDimensionData;
import StevenDimDoors.mod_pocketDim.commands.CommandPruneDimensions;
import StevenDimDoors.mod_pocketDim.commands.CommandResetDungeons;
import StevenDimDoors.mod_pocketDim.commands.CommandTeleportPlayer;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
import StevenDimDoors.mod_pocketDim.items.ItemBlockDimWall;
import StevenDimDoors.mod_pocketDim.items.ItemChaosDoor;
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
import StevenDimDoors.mod_pocketDim.items.ItemRiftBlade;
import StevenDimDoors.mod_pocketDim.items.ItemRiftSignature;
import StevenDimDoors.mod_pocketDim.items.ItemStabilizedRiftSignature;
import StevenDimDoors.mod_pocketDim.items.ItemStableFabric;
import StevenDimDoors.mod_pocketDim.items.itemDimDoor;
import StevenDimDoors.mod_pocketDim.items.itemExitDoor;
import StevenDimDoors.mod_pocketDim.items.itemLinkSignature;
import StevenDimDoors.mod_pocketDim.items.ItemUnstableDoor;
import StevenDimDoors.mod_pocketDim.items.ItemWarpDoor;
import StevenDimDoors.mod_pocketDim.items.itemRiftRemover;
import StevenDimDoors.mod_pocketDim.ticking.CommonTickHandler;
import StevenDimDoors.mod_pocketDim.ticking.LimboDecay;
import StevenDimDoors.mod_pocketDim.ticking.MobMonolith;
import StevenDimDoors.mod_pocketDim.ticking.MonolithSpawner;
import StevenDimDoors.mod_pocketDim.ticking.RiftRegenerator;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityRift;
import StevenDimDoors.mod_pocketDim.world.BiomeGenLimbo;
import StevenDimDoors.mod_pocketDim.world.BiomeGenPocket;
import StevenDimDoors.mod_pocketDim.world.GatewayGenerator;
@@ -80,13 +74,11 @@ import cpw.mods.fml.relauncher.Side;
@Mod(modid = mod_pocketDim.modid, name = "Dimensional Doors", version = mod_pocketDim.version)
@NetworkMod(clientSideRequired = true, serverSideRequired = false,
@NetworkMod(clientSideRequired = true, serverSideRequired = false, connectionHandler=ConnectionHandler.class,
clientPacketHandlerSpec =
@SidedPacketHandler(channels = {"pocketDim" }, packetHandler = ClientPacketHandler.class),
@SidedPacketHandler(channels = {PacketConstants.CHANNEL_NAME}, packetHandler = ClientPacketHandler.class),
serverPacketHandlerSpec =
@SidedPacketHandler(channels = {"pocketDim" }, packetHandler = ServerPacketHandler.class),
channels={"DimDoorPackets"}, packetHandler = PacketHandler.class, connectionHandler=ConnectionHandler.class)
@SidedPacketHandler(channels = {PacketConstants.CHANNEL_NAME}, packetHandler = ServerPacketHandler.class))
public class mod_pocketDim
{
@@ -101,10 +93,10 @@ public class mod_pocketDim
public static mod_pocketDim instance = new mod_pocketDim();
public static Block transientDoor;
public static Block ExitDoor;
public static Block chaosDoor;
public static Block warpDoor;
public static Block unstableDoor;
public static Block blockLimbo;
public static Block dimDoor;
public static DimensionalDoor dimensionalDoor;
public static Block blockDimWall;
public static Block dimHatch;
public static Block blockDimWallPerm;
@@ -132,9 +124,6 @@ public class mod_pocketDim
public static MonolithSpawner spawner; //Added this field temporarily. Will be refactored out later.
public static GatewayGenerator riftGen;
public static long genTime;
public static int teleTimer = 0;
public static CreativeTabs dimDoorsCreativeTab = new CreativeTabs("dimDoorsCreativeTab")
{
@Override
@@ -153,22 +142,20 @@ public class mod_pocketDim
@PreInit
public void PreInit(FMLPreInitializationEvent event)
public void onPreInitialization(FMLPreInitializationEvent event)
{
//This should be the FIRST thing that gets done.
properties = DDProperties.initialize(event.getSuggestedConfigurationFile());
//Now do other stuff
MinecraftForge.EVENT_BUS.register(new EventHookContainer());
MinecraftForge.EVENT_BUS.register(new EventHookContainer(properties));
//These fields MUST be initialized after properties are loaded to prevent
//instances from holding onto null references to the properties.
tracker = new PlayerRespawnTracker();
riftGen = new GatewayGenerator();
tracker = new PlayerRespawnTracker(properties);
riftGen = new GatewayGenerator(properties);
}
@Init
public void Init(FMLInitializationEvent event)
public void onInitialization(FMLInitializationEvent event)
{
CommonTickHandler commonTickHandler = new CommonTickHandler();
TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT);
@@ -184,21 +171,21 @@ public class mod_pocketDim
blockDimWall = (new BlockDimWall(properties.FabricBlockID, 0, Material.iron)).setLightValue(1.0F).setHardness(0.1F).setUnlocalizedName("blockDimWall");
blockDimWallPerm = (new BlockDimWallPerm(properties.PermaFabricBlockID, 0, Material.iron)).setLightValue(1.0F).setBlockUnbreakable().setResistance(6000000.0F).setUnlocalizedName("blockDimWallPerm");
ExitDoor = (new ExitDoor(properties.WarpDoorID, Material.wood)).setHardness(1.0F) .setUnlocalizedName("dimDoorWarp");
warpDoor = (new WarpDoor(properties.WarpDoorID, Material.wood)).setHardness(1.0F) .setUnlocalizedName("dimDoorWarp");
blockRift = (BlockRift) (new BlockRift(properties.RiftBlockID, 0, Material.air, properties).setHardness(1.0F) .setUnlocalizedName("rift"));
blockLimbo = (new BlockLimbo(properties.LimboBlockID, 15, Material.iron, properties.LimboDimensionID, decay).setHardness(.2F).setUnlocalizedName("BlockLimbo").setLightValue(.0F));
chaosDoor = (new ChaosDoor(properties.UnstableDoorID, Material.iron).setHardness(.2F).setUnlocalizedName("chaosDoor").setLightValue(.0F) );
dimDoor = (new dimDoor(properties.DimensionalDoorID, Material.iron)).setHardness(1.0F).setResistance(2000.0F) .setUnlocalizedName("dimDoor");
unstableDoor = (new UnstableDoor(properties.UnstableDoorID, Material.iron).setHardness(.2F).setUnlocalizedName("chaosDoor").setLightValue(.0F) );
dimensionalDoor = (DimensionalDoor) (new DimensionalDoor(properties.DimensionalDoorID, Material.iron)).setHardness(1.0F).setResistance(2000.0F) .setUnlocalizedName("dimDoor");
dimHatch = (new dimHatch(properties.TransTrapdoorID, 84, Material.iron)).setHardness(1.0F) .setUnlocalizedName("dimHatch");
// dimRail = (new DimRail(dimRailID, 88, false)).setHardness(.5F) .setUnlocalizedName("dimRail");
itemDimDoor = (new itemDimDoor(properties.DimensionalDoorItemID, Material.iron)).setUnlocalizedName("itemDimDoor");
itemExitDoor = (new itemExitDoor(properties.WarpDoorItemID, Material.wood)).setUnlocalizedName("itemDimDoorWarp");
itemLinkSignature = (new itemLinkSignature(properties.RiftSignatureItemID)).setUnlocalizedName("itemLinkSignature");
itemDimDoor = (new ItemDimensionalDoor(properties.DimensionalDoorItemID, Material.iron)).setUnlocalizedName("itemDimDoor");
itemExitDoor = (new ItemWarpDoor(properties.WarpDoorItemID, Material.wood)).setUnlocalizedName("itemDimDoorWarp");
itemLinkSignature = (new ItemRiftSignature(properties.RiftSignatureItemID)).setUnlocalizedName("itemLinkSignature");
itemRiftRemover = (new itemRiftRemover(properties.RiftRemoverItemID, Material.wood)).setUnlocalizedName("itemRiftRemover");
itemStableFabric = (new ItemStableFabric(properties.StableFabricItemID, 0)).setUnlocalizedName("itemStableFabric");
itemChaosDoor = (new ItemChaosDoor(properties.UnstableDoorItemID, Material.iron)).setUnlocalizedName("itemChaosDoor");
itemRiftBlade = (new ItemRiftBlade(properties.RiftBladeItemID)).setUnlocalizedName("ItemRiftBlade");
itemChaosDoor = (new ItemUnstableDoor(properties.UnstableDoorItemID, Material.iron)).setUnlocalizedName("itemChaosDoor");
itemRiftBlade = (new ItemRiftBlade(properties.RiftBladeItemID, EnumToolMaterial.GOLD)).setUnlocalizedName("ItemRiftBlade");
itemStabilizedLinkSignature = (new ItemStabilizedRiftSignature(properties.StabilizedRiftSignatureItemID)).setUnlocalizedName("itemStabilizedRiftSig");
mod_pocketDim.limboBiome= (new BiomeGenLimbo(properties.LimboBiomeID));
@@ -206,11 +193,11 @@ public class mod_pocketDim
GameRegistry.registerWorldGenerator(mod_pocketDim.riftGen);
GameRegistry.registerBlock(chaosDoor, "Unstable Door");
GameRegistry.registerBlock(ExitDoor, "Warp Door");
GameRegistry.registerBlock(unstableDoor, "Unstable Door");
GameRegistry.registerBlock(warpDoor, "Warp Door");
GameRegistry.registerBlock(blockRift, "Rift");
GameRegistry.registerBlock(blockLimbo, "Unraveled Fabric");
GameRegistry.registerBlock(dimDoor, "Dimensional Door");
GameRegistry.registerBlock(dimensionalDoor, "Dimensional Door");
GameRegistry.registerBlock(dimHatch,"Transdimensional Trapdoor");
GameRegistry.registerBlock(blockDimWallPerm, "Fabric of RealityPerm");
GameRegistry.registerBlock(transientDoor, "transientDoor");
@@ -226,11 +213,11 @@ public class mod_pocketDim
LanguageRegistry.addName(transientDoor , "transientDoor");
LanguageRegistry.addName(blockRift , "Rift");
LanguageRegistry.addName(blockLimbo , "Unraveled Fabric");
LanguageRegistry.addName(ExitDoor , "Warp Door");
LanguageRegistry.addName(chaosDoor , "Unstable Door");
LanguageRegistry.addName(warpDoor , "Warp Door");
LanguageRegistry.addName(unstableDoor , "Unstable Door");
LanguageRegistry.addName(blockDimWall , "Fabric of Reality");
LanguageRegistry.addName(blockDimWallPerm , "Eternal Fabric");
LanguageRegistry.addName(dimDoor, "Dimensional Door");
LanguageRegistry.addName(dimensionalDoor, "Dimensional Door");
LanguageRegistry.addName(dimHatch, "Transdimensional Trapdoor");
LanguageRegistry.addName(itemExitDoor, "Warp Door");
@@ -251,8 +238,6 @@ public class mod_pocketDim
LanguageRegistry.instance().addStringLocalization("itemGroup.dimDoorsCustomTab", "en_US", "Dimensional Doors Items");
//GameRegistry.registerTileEntity(TileEntityDimDoor.class, "TileEntityDimRail");
GameRegistry.registerTileEntity(TileEntityDimDoor.class, "TileEntityDimDoor");
GameRegistry.registerTileEntity(TileEntityRift.class, "TileEntityRift");
@@ -264,7 +249,7 @@ public class mod_pocketDim
//GameRegistry.addBiome(this.limboBiome);
//GameRegistry.addBiome(this.pocketBiome);
if (properties.CraftingDimensionaDoorAllowed)
if (properties.CraftingDimensionalDoorAllowed)
{
GameRegistry.addRecipe(new ItemStack(itemDimDoor, 1), new Object[]
{
@@ -276,22 +261,6 @@ public class mod_pocketDim
" ", "yxy", " ", 'x', mod_pocketDim.itemStableFabric, 'y', Item.doorIron
});
}
/**
if(this.enableDimRail)
{
GameRegistry.addRecipe(new ItemStack(dimRail, 1), new Object[]
{
" ", "yxy", " ", 'x', this.itemDimDoor, 'y', Block.rail
});
GameRegistry.addRecipe(new ItemStack(dimRail, 1), new Object[]
{
" ", "yxy", " ", 'x', this.itemExitDoor, 'y', Block.rail
});
}
**/
if(properties.CraftingUnstableDoorAllowed)
{
GameRegistry.addRecipe(new ItemStack(itemChaosDoor, 1), new Object[]
@@ -381,28 +350,29 @@ public class mod_pocketDim
@PostInit
public void PostInit(FMLPostInitializationEvent event)
public void onPostInitialization(FMLPostInitializationEvent event)
{
//Register loot chests
DDLoot.registerInfo();
}
@ServerStopping
public void serverStopping(FMLServerStoppingEvent event)
public void onServerStopping(FMLServerStoppingEvent event)
{
try
{
PocketManager.unload();
}
catch(Exception e)
catch (Exception e)
{
e.printStackTrace();
}
}
@ServerStarting
public void serverStarting(FMLServerStartingEvent event)
public void onServerStarting(FMLServerStartingEvent event)
{
/*
CommandResetDungeons.instance().register(event);
CommandCreateDungeonRift.instance().register(event);
CommandDeleteAllLinks.instance().register(event);
@@ -413,6 +383,7 @@ public class mod_pocketDim
CommandPruneDimensions.instance().register(event);
CommandCreatePocket.instance().register(event);
CommandTeleportPlayer.instance().register(event);
*/
PocketManager.load();
}
}

View File

@@ -7,7 +7,7 @@ import net.minecraft.block.BlockRedstoneRepeater;
import net.minecraft.block.BlockStairs;
import StevenDimDoors.mod_pocketDim.Point3D;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.blocks.dimDoor;
import StevenDimDoors.mod_pocketDim.blocks.DimensionalDoor;
public class BlockRotator
{
@@ -64,8 +64,8 @@ public class BlockRotator
hasOrientations[Block.railActivator.blockID] = true;
hasOrientations[Block.rail.blockID] = true;
hasOrientations[mod_pocketDim.dimDoor.blockID] = true;
hasOrientations[mod_pocketDim.ExitDoor.blockID] = true;
hasOrientations[mod_pocketDim.dimensionalDoor.blockID] = true;
hasOrientations[mod_pocketDim.warpDoor.blockID] = true;
}
@@ -379,7 +379,7 @@ public class BlockRotator
break;
}
}
else if(Block.blocksList[blockID] instanceof BlockRedstoneRepeater || Block.blocksList[blockID] instanceof BlockDoor || Block.blocksList[blockID] instanceof dimDoor || blockID== Block.tripWireSource.blockID || Block.blocksList[blockID] instanceof BlockComparator)
else if(Block.blocksList[blockID] instanceof BlockRedstoneRepeater || Block.blocksList[blockID] instanceof BlockDoor || Block.blocksList[blockID] instanceof DimensionalDoor || blockID== Block.tripWireSource.blockID || Block.blocksList[blockID] instanceof BlockComparator)
{
switch (metadata)
{

View File

@@ -3,7 +3,7 @@ package StevenDimDoors.mod_pocketDim.ticking;
import java.util.ArrayList;
import java.util.EnumSet;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.DDTeleporter;
import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;
@@ -43,9 +43,9 @@ public class CommonTickHandler implements ITickHandler, IRegularTickSender
//TODO: Stuck this in here because it's already rather hackish.
//We should standardize this as an IRegularTickReceiver in the future. ~SenseiKiwi
if (mod_pocketDim.teleTimer > 0)
if (DDTeleporter.cooldown > 0)
{
mod_pocketDim.teleTimer--;
DDTeleporter.cooldown--;
}
}

View File

@@ -1,26 +0,0 @@
package StevenDimDoors.mod_pocketDim.ticking;
import java.util.ArrayList;
import java.util.Random;
import net.minecraft.entity.Entity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.GameRules;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
import StevenDimDoors.mod_pocketDim.util.ChunkLocation;
public class LimboGatewayGenerator implements IRegularTickReceiver
{
@Override
public void notifyTick()
{
}
}

View File

@@ -13,8 +13,8 @@ import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.DDTeleporter;
import StevenDimDoors.mod_pocketDim.util.Point4D;
import StevenDimDoors.mod_pocketDim.world.LimboProvider;
import StevenDimDoors.mod_pocketDim.world.PocketProvider;
@@ -86,7 +86,7 @@ public class MobMonolith extends EntityFlying implements IMob
@Override
public void onEntityUpdate()
{
if(!(this.worldObj.provider instanceof LimboProvider ||this.worldObj.provider instanceof PocketProvider))
if (!(this.worldObj.provider instanceof LimboProvider || this.worldObj.provider instanceof PocketProvider))
{
this.setDead();
}
@@ -94,8 +94,6 @@ public class MobMonolith extends EntityFlying implements IMob
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
this.texture="/mods/DimDoors/textures/mobs/Monolith"+b0+".png";
super.onEntityUpdate();
if (this.isEntityAlive() && this.isEntityInsideOpaqueBlock())
@@ -103,12 +101,9 @@ public class MobMonolith extends EntityFlying implements IMob
this.setDead();
}
EntityPlayer entityPlayer = this.worldObj.getClosestPlayerToEntity(this, 30);
if(entityPlayer != null)
if (entityPlayer != null)
{
if(this.soundTime<=0)
{
@@ -116,83 +111,57 @@ public class MobMonolith extends EntityFlying implements IMob
this.soundTime=100;
}
this.faceEntity(entityPlayer, 1, 1);
if(shouldAttackPlayer(entityPlayer))
if (shouldAttackPlayer(entityPlayer))
{
if (aggro<470)
{
}
if(aggro<470)
{
if(rand.nextInt(11)>this.textureState||this.aggro>=300||rand.nextInt(13)>this.textureState&&this.aggroMax>this.aggro)
if (rand.nextInt(11)>this.textureState||this.aggro>=300||rand.nextInt(13)>this.textureState&&this.aggroMax>this.aggro)
{
aggro++;
}
if(this.worldObj.provider instanceof PocketProvider||this.worldObj.getClosestPlayerToEntity(this, 5)!=null)
if (this.worldObj.provider instanceof PocketProvider||this.worldObj.getClosestPlayerToEntity(this, 5)!=null)
{
aggro++;
aggro++;
if(rand.nextBoolean())
if (rand.nextBoolean())
{
aggro++;
}
}
if(aggro>430&&this.soundTime<100)
if (aggro>430&&this.soundTime<100)
{
//this.worldObj.playSoundAtEntity(entityPlayer,"mods.DimDoors.sfx.tearing",2, 1);
this.worldObj.playSoundEffect(entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ,"mods.DimDoors.sfx.tearing",2F, 1F);
this.soundTime=100;
}
if(aggro>445&&this.soundTime<200)
if (aggro>445&&this.soundTime<200)
{
//this.worldObj.playSoundAtEntity(entityPlayer,"mods.DimDoors.sfx.tearing",5, 1);
this.worldObj.playSoundEffect(entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ,"mods.DimDoors.sfx.tearing",5F, 1F);
this.soundTime=200;
}
}
else if(!this.worldObj.isRemote&&!entityPlayer.capabilities.isCreativeMode)
else if (!this.worldObj.isRemote && !entityPlayer.capabilities.isCreativeMode)
{
NewLinkData link = new NewLinkData(this.worldObj.provider.dimensionId, properties.LimboDimensionID, (int)this.posX, (int)this.posY, (int)this.posZ, (int)this.posX+rand.nextInt(500)-250, (int)this.posY+500, (int)this.posZ+rand.nextInt(500)-250, false,0);
PocketManager.instance.traverseDimDoor(worldObj, link, entityPlayer);
this.aggro=0;
Point4D destination = new Point4D(
(int) this.posX + MathHelper.getRandomIntegerInRange(rand, -250, 250),
(int) this.posY + 500,
(int) this.posZ + MathHelper.getRandomIntegerInRange(rand, -250, 250),
properties.LimboDimensionID);
DDTeleporter.teleportEntity(entityPlayer, destination);
this.aggro = 0;
entityPlayer.worldObj.playSoundAtEntity(entityPlayer,"mods.DimDoors.sfx.crack",13, 1);
}
if(!(this.worldObj.provider instanceof LimboProvider || this.worldObj.getClosestPlayerToEntity(this, 5)!=null)||this.aggro>300)
if (!(this.worldObj.provider instanceof LimboProvider || this.worldObj.getClosestPlayerToEntity(this, 5) != null) || this.aggro > 300)
{
for (int i = 0; i < -1+this.textureState/2; ++i)
{
entityPlayer.worldObj.spawnParticle("portal", entityPlayer.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, entityPlayer.posY + this.rand.nextDouble() * (double)entityPlayer.height - 0.75D, entityPlayer.posZ + (this.rand.nextDouble() - 0.5D) * (double)entityPlayer.width, (this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(), (this.rand.nextDouble() - 0.5D) * 2.0D);
}
}
}
else
{
@@ -205,12 +174,9 @@ public class MobMonolith extends EntityFlying implements IMob
}
}
}
else
{
if(aggro>0)
{
aggro--;
@@ -221,44 +187,23 @@ public class MobMonolith extends EntityFlying implements IMob
}
}
}
if(soundTime>=0)
if (soundTime>=0)
{
soundTime--;
}
{
}
this.textureState= (byte) (this.aggro/25);
if(!this.worldObj.isRemote)
if (!this.worldObj.isRemote)
{
this.dataWatcher.updateObject(16, Byte.valueOf(this.textureState));
}
}
private boolean shouldAttackPlayer(EntityPlayer par1EntityPlayer)
{
return par1EntityPlayer.canEntityBeSeen(this);
}
private boolean isCourseTraversable(double par1, double par3, double par5, double par7)
{
double d4 = (par1 - this.posX) / par7;
@@ -275,9 +220,9 @@ public class MobMonolith extends EntityFlying implements IMob
return false;
}
}
return true;
}
public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
{
if(!(par1DamageSource==DamageSource.inWall))
@@ -286,6 +231,7 @@ public class MobMonolith extends EntityFlying implements IMob
}
return false;
}
public void faceEntity(Entity par1Entity, float par2, float par3)
{
double d0 = par1Entity.posX - this.posX;
@@ -311,7 +257,6 @@ public class MobMonolith extends EntityFlying implements IMob
this.rotationYaw = f2;
this.rotationYawHead=f2;
this.renderYawOffset=this.rotationYaw;
}
private float updateRotation(float par1, float par2, float par3)
@@ -336,8 +281,6 @@ public class MobMonolith extends EntityFlying implements IMob
return 0.0F;
}
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
@@ -346,7 +289,6 @@ public class MobMonolith extends EntityFlying implements IMob
par1NBTTagCompound.setInteger("aggroMax", this.aggroMax);
par1NBTTagCompound.setByte("textureState", this.textureState);
par1NBTTagCompound.setFloat("scaleFactor", this.scaleFactor);
}
@Override
@@ -358,31 +300,27 @@ public class MobMonolith extends EntityFlying implements IMob
this.aggroMax = par1NBTTagCompound.getInteger("aggroMax");
this.textureState = par1NBTTagCompound.getByte("textureState");
this.scaleFactor = par1NBTTagCompound.getFloat("scaleFactor");
}
public boolean getCanSpawnHere()
{
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this,AxisAlignedBB.getBoundingBox( this.posX-15, posY-4, this.posZ-15, this.posX+15, this.posY+15, this.posZ+15));
if(this.worldObj.provider.dimensionId==DDProperties.instance().LimboDimensionID)
{
if(list.size()>0)
{
return false;
}
}
else if(this.worldObj.provider instanceof PocketProvider)
{
if(list.size()>5||this.worldObj.canBlockSeeTheSky((int)this.posX, (int)this.posY, (int)this.posZ))
{
return false;
}
}
return this.worldObj.checkNoEntityCollision(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox);
}
public boolean getCanSpawnHere()
{
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, AxisAlignedBB.getBoundingBox( this.posX-15, posY-4, this.posZ-15, this.posX+15, this.posY+15, this.posZ+15));
if(this.worldObj.provider.dimensionId==DDProperties.instance().LimboDimensionID)
{
if(list.size()>0)
{
return false;
}
}
else if(this.worldObj.provider instanceof PocketProvider)
{
if(list.size()>5||this.worldObj.canBlockSeeTheSky((int)this.posX, (int)this.posY, (int)this.posZ))
{
return false;
}
}
return this.worldObj.checkNoEntityCollision(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox);
}
}

View File

@@ -3,11 +3,11 @@ package StevenDimDoors.mod_pocketDim.ticking;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.TileEntityRift;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.IDimLink;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityRift;
import StevenDimDoors.mod_pocketDim.util.Point4D;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;

View File

@@ -1,4 +1,4 @@
package StevenDimDoors.mod_pocketDim;
package StevenDimDoors.mod_pocketDim.tileentities;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;

View File

@@ -1,4 +1,4 @@
package StevenDimDoors.mod_pocketDim;
package StevenDimDoors.mod_pocketDim.tileentities;
@@ -16,6 +16,7 @@ import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.IDimLink;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;

View File

@@ -0,0 +1,26 @@
package StevenDimDoors.mod_pocketDim.util;
public class Pair<P, Q>
{
//Pair is an implementation of a 2-tuple with generic parameters for strongly-typed elements.
//It's used instead of Minecraft's Tuple type because Tuple doesn't have strongly-typed elements.
private P first;
private Q second;
public Pair(P first, Q second)
{
this.first = first;
this.second = second;
}
public P getFirst()
{
return first;
}
public Q getSecond()
{
return second;
}
}

View File

@@ -0,0 +1,8 @@
package StevenDimDoors.mod_pocketDim.watcher;
import java.io.DataOutputStream;
public interface IOpaqueMessage
{
void writeToStream(DataOutputStream stream);
}

View File

@@ -0,0 +1,8 @@
package StevenDimDoors.mod_pocketDim.watcher;
import com.google.common.io.ByteArrayDataInput;
public interface IOpaqueReader
{
IOpaqueMessage read(ByteArrayDataInput source);
}

View File

@@ -0,0 +1,8 @@
package StevenDimDoors.mod_pocketDim.watcher;
public interface IUpdateWatcher
{
public void onCreated(IOpaqueMessage message);
public void onUpdated(IOpaqueMessage message);
public void onDeleted(IOpaqueMessage message);
}

View File

@@ -0,0 +1,51 @@
package StevenDimDoors.mod_pocketDim.watcher;
import java.util.ArrayList;
import java.util.List;
public class UpdateWatcherProxy implements IUpdateWatcher
{
private List<IUpdateWatcher> watchers;
public UpdateWatcherProxy()
{
watchers = new ArrayList<IUpdateWatcher>();
}
@Override
public void onCreated(IOpaqueMessage message)
{
for (IUpdateWatcher receiver : watchers)
{
receiver.onCreated(message);
}
}
@Override
public void onUpdated(IOpaqueMessage message)
{
for (IUpdateWatcher receiver : watchers)
{
receiver.onUpdated(message);
}
}
@Override
public void onDeleted(IOpaqueMessage message)
{
for (IUpdateWatcher receiver : watchers)
{
receiver.onDeleted(message);
}
}
public void registerReceiver(IUpdateWatcher receiver)
{
watchers.add(receiver);
}
public boolean unregisterReceiver(IUpdateWatcher receiver)
{
return watchers.remove(receiver);
}
}

View File

@@ -12,7 +12,7 @@ import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.IDimLink;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.items.itemDimDoor;
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
import cpw.mods.fml.common.IWorldGenerator;
public class GatewayGenerator implements IWorldGenerator
@@ -29,12 +29,12 @@ public class GatewayGenerator implements IWorldGenerator
private static final int NETHER_CHANCE_CORRECTION = 4;
private static final int OVERWORLD_DIMENSION_ID = 0;
private static final int NETHER_DIMENSION_ID = -1;
private static DDProperties properties = null;
public GatewayGenerator()
private final DDProperties properties;
public GatewayGenerator(DDProperties properties)
{
if (properties == null)
properties = DDProperties.instance();
this.properties = properties;
}
@Override
@@ -97,7 +97,7 @@ public class GatewayGenerator implements IWorldGenerator
if (link == null)
{
dimension = PocketManager.getDimensionData(world);
link = dimension.createLink(x, y + 1, z).setLinkType(IDimLink.TYPE_POCKET);
link = dimension.createLink(x, y + 1, z, IDimLink.TYPE_POCKET);
}
else
{
@@ -132,7 +132,7 @@ public class GatewayGenerator implements IWorldGenerator
{
//Create a partial link to a dungeon.
dimension = PocketManager.getDimensionData(world);
link = dimension.createLink(x, y + 1, z).setLinkType(IDimLink.TYPE_DUNGEON);
link = dimension.createLink(x, y + 1, z, IDimLink.TYPE_DUNGEON);
//If the current dimension isn't Limbo, build a Rift Gateway out of Stone Bricks
if (dimension.id() != properties.LimboDimensionID)
@@ -141,11 +141,11 @@ public class GatewayGenerator implements IWorldGenerator
}
else
{
createLimboGateway(world, x, y, z);
createLimboGateway(world, x, y, z, properties.LimboBlockID);
}
//Place the shiny transient door into a dungeon
itemDimDoor.placeDoorBlock(world, x, y + 1, z, 0, mod_pocketDim.transientDoor);
ItemDimensionalDoor.placeDoorBlock(world, x, y + 1, z, 0, mod_pocketDim.transientDoor);
}
}
}
@@ -190,11 +190,10 @@ public class GatewayGenerator implements IWorldGenerator
world.setBlock(x, y, z + 1, blockID, 0, 3);
}
private static void createLimboGateway(World world, int x, int y, int z)
private static void createLimboGateway(World world, int x, int y, int z, int blockID)
{
//Build the gateway out of Unraveled Fabric. Since nearly all the blocks in Limbo are of
//that type, there is no point replacing the ground.
final int blockID = properties.LimboBlockID;
world.setBlock(x, y + 2, z + 1, blockID, 0, 3);
world.setBlock(x, y + 2, z - 1, blockID, 0, 3);

View File

@@ -12,18 +12,12 @@ import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.ChunkProviderGenerate;
import net.minecraft.world.gen.MapGenBase;
import net.minecraft.world.gen.MapGenRavine;
import net.minecraft.world.gen.NoiseGeneratorOctaves;
import net.minecraft.world.gen.feature.MapGenScatteredFeature;
import net.minecraft.world.gen.structure.MapGenMineshaft;
import net.minecraft.world.gen.structure.MapGenStronghold;
import net.minecraft.world.gen.structure.MapGenVillage;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.terraingen.ChunkProviderEvent;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.ticking.CommonTickHandler;
import StevenDimDoors.mod_pocketDim.ticking.MonolithSpawner;
public class LimboGenerator extends ChunkProviderGenerate implements IChunkProvider
@@ -46,8 +40,6 @@ public class LimboGenerator extends ChunkProviderGenerate implements IChunkProvi
public NoiseGeneratorOctaves noiseGen5;
public World world;
private final byte[] field_82700_c = new byte[256];
private final byte[] field_82698_d = new byte[256];
/** A NoiseGeneratorOctaves used in generating terrain */
public NoiseGeneratorOctaves noiseGen6;
@@ -56,27 +48,11 @@ public class LimboGenerator extends ChunkProviderGenerate implements IChunkProvi
/** Reference to the World object. */
private World worldObj;
/** are map structures going to be generated (e.g. strongholds) */
private final boolean mapFeaturesEnabled = false;
/** Holds the overall noise array used in chunk generation */
private double[] noiseArray;
private double[] stoneNoise = new double[256];
private MapGenBase caveGenerator = new CustomCaveGen();
/** Holds Stronghold Generator */
private MapGenStronghold strongholdGenerator = new MapGenStronghold();
/** Holds Village Generator */
private MapGenVillage villageGenerator = new MapGenVillage();
/** Holds Mineshaft Generator */
private MapGenMineshaft mineshaftGenerator = new MapGenMineshaft();
private MapGenScatteredFeature scatteredFeatureGenerator = new MapGenScatteredFeature();
/** Holds ravine generator */
private MapGenBase ravineGenerator = new MapGenRavine();
/** The biomes that are used to generate the chunk */
private BiomeGenBase[] biomesForGeneration = new BiomeGenBase[1];
@@ -137,10 +113,11 @@ public class LimboGenerator extends ChunkProviderGenerate implements IChunkProvi
}
@Override
public boolean chunkExists(int var1, int var2) {
// TODO Auto-generated method stub
public boolean chunkExists(int var1, int var2)
{
return super.chunkExists(var1, var2);
}
@Override
public void replaceBlocksForBiome(int par1, int par2, byte[] par3ArrayOfByte, BiomeGenBase[] par4ArrayOfBiomeGenBase)
{

View File

@@ -1,9 +1,9 @@
package StevenDimDoors.mod_pocketDim.world;
import java.util.HashMap;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
@@ -19,6 +19,7 @@ import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPackConfig;
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
import StevenDimDoors.mod_pocketDim.util.Pair;
import StevenDimDoors.mod_pocketDim.util.Point4D;
public class PocketBuilder
@@ -35,25 +36,6 @@ public class PocketBuilder
private PocketBuilder() { }
public static boolean initializeDestination(IDimLink link, DDProperties properties)
{
if (link.hasDestination())
{
return true;
}
//Check the destination type and respond accordingly
switch (link.linkType())
{
case IDimLink.TYPE_DUNGEON:
return generateNewDungeonPocket(link, properties);
case IDimLink.TYPE_POCKET:
return generateNewPocket(link, properties);
default:
throw new IllegalArgumentException("link has an unrecognized link type.");
}
}
public static boolean generateNewDungeonPocket(IDimLink link, DDProperties properties)
{
if (link == null)
@@ -93,31 +75,35 @@ public class PocketBuilder
return false;
}
/* This code is currently wrong. It's missing the following things:
* 1. Calculate the destination point for real. That includes adding door noise if needed.
* 2. Receive the DungeonData from selectDungeon()
* 3. The function signature for DungeonSchematic.copyToWorld() has to be rewritten.
*/
//Choose a dungeon to generate
DungeonSchematic schematic = selectDungeon(dimension, random, properties);
if (schematic == null)
Pair<DungeonData, DungeonSchematic> pair = selectDungeon(dimension, random, properties);
if (pair == null)
{
System.err.println("Could not select a dungeon for generation!");
return false;
}
DungeonData dungeon = pair.getFirst();
DungeonSchematic schematic = pair.getSecond();
//Calculate the destination point
DungeonPackConfig packConfig = dungeon.dungeonType().Owner != null ? dungeon.dungeonType().Owner.getConfig() : null;
Point4D source = link.source();
int destinationY = yCoordHelper.adjustDestinationY(destination, world.getHeight(), schematic.getEntranceDoorLocation().getY(), schematic.getHeight());
int orientation = getDestinationOrientation(source);
destination.setY(destinationY);
int orientation = getDoorOrientation(source, properties);
Point3D destination;
if (packConfig != null && packConfig.doDistortDoorCoordinates())
{
destination = calculateNoisyDestination(source, dimension, orientation);
}
else
{
destination = new Point3D(source.getX(), source.getY(), source.getZ());
}
destination.setY( yCoordHelper.adjustDestinationY(destination.getY(), world.getHeight(), schematic.getEntranceDoorLocation().getY(), schematic.getHeight()) );
//Generate the dungeon
DungeonPackConfig packConfig = dungeon.dungeonType().Owner != null ? dungeon.dungeonType().Owner.getConfig() : null;
schematic.copyToWorld(world, link, packConfig.doDistortDoorCoordinates());
schematic.copyToWorld(world, destination, orientation, link, random);
//Finish up destination initialization
dimension.initializePocket(destination.getX(), destination.getY(), destination.getZ(), orientation, link);
@@ -131,7 +117,23 @@ public class PocketBuilder
}
}
private static DungeonSchematic selectDungeon(NewDimData dimension, Random random, DDProperties properties)
private static Point3D calculateNoisyDestination(Point4D source, NewDimData dimension, int orientation)
{
int depth = dimension.packDepth();
int forwardNoise = MathHelper.getRandomIntegerInRange(random, -50 * depth, 150 * depth);
int sidewaysNoise = MathHelper.getRandomIntegerInRange(random, -10 * depth, 10 * depth);
//Rotate the link destination noise to point in the same direction as the door exit
//and add it to the door's location. Use EAST as the reference orientation since linkDestination
//is constructed as if pointing East.
Point3D linkDestination = new Point3D(forwardNoise, 0, sidewaysNoise);
Point3D sourcePoint = new Point3D(source.getX(), source.getY(), source.getZ());
Point3D zeroPoint = new Point3D(0, 0, 0);
BlockRotator.transformPoint(linkDestination, zeroPoint, orientation - BlockRotator.EAST_DOOR_METADATA, sourcePoint);
return linkDestination;
}
private static Pair<DungeonData, DungeonSchematic> selectDungeon(NewDimData dimension, Random random, DDProperties properties)
{
//We assume the dimension doesn't have a dungeon assigned
if (dimension.dungeon() != null)
@@ -157,7 +159,6 @@ public class PocketBuilder
{
//TODO: In the future, remove this dungeon from the generation lists altogether.
//That will have to wait until our code is updated to support that more easily.
try
{
System.err.println("Loading the default error dungeon instead...");
@@ -170,7 +171,7 @@ public class PocketBuilder
return null;
}
}
return schematic;
return new Pair<DungeonData, DungeonSchematic>(dungeon, schematic);
}
private static DungeonSchematic loadAndValidateDungeon(DungeonData dungeon, DDProperties properties)
@@ -218,10 +219,25 @@ public class PocketBuilder
return generateNewPocket(link, DEFAULT_POCKET_SIZE, DEFAULT_POCKET_WALL_THICKNESS, properties);
}
private static int getDestinationOrientation(Point4D source)
private static int getDoorOrientation(Point4D source, DDProperties properties)
{
// TODO Auto-generated method stub
return 0;
World world = DimensionManager.getWorld(source.getDimension());
if (world == null)
{
throw new IllegalStateException("The link's source world should be loaded!");
}
//Check if the block at that point is actually a door
int blockID = world.getBlockId(source.getX(), source.getY(), source.getZ());
if (blockID != properties.DimensionalDoorID && blockID != properties.WarpDoorID &&
blockID != properties.TransientDoorID)
{
throw new IllegalStateException("The link's source is not a door block. It should be impossible to traverse a rift without a door!");
}
//Return the orientation portion of its metadata
int orientation = world.getBlockMetadata(source.getX(), source.getY(), source.getZ()) & 3;
return orientation;
}
public static boolean generateNewPocket(IDimLink link, int size, int wallThickness, DDProperties properties)
@@ -283,7 +299,7 @@ public class PocketBuilder
//Calculate the destination point
Point4D source = link.source();
int destinationY = yCoordHelper.adjustDestinationY(source.getY(), world.getHeight(), wallThickness + 1, size);
int orientation = getDestinationOrientation(source);
int orientation = getDoorOrientation(source, properties);
//Build the actual pocket area
buildPocket(world, source.getX(), destinationY, source.getZ(), orientation, size, wallThickness, properties);

View File

@@ -1,23 +1,15 @@
// This is my package declaration, do not mess with the standard (package net.minecraft.src;) like I did,
// Because I know what Im doing in this part, If you don't know what your doing keep it the normal (package net.minecraft.src;)
package StevenDimDoors.mod_pocketDimClient;
// Theses are all the imports you need
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;
// Create a class and implement IPacketHandler
// This just handles the data packets in the server
public class ClientPacketHandler implements IPacketHandler{
public class ClientPacketHandler implements IPacketHandler
{
@Override
public void onPacketData(INetworkManager manager,
Packet250CustomPayload packet, Player player) {
// TODO Auto-generated method stub
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player)
{
}
}

View File

@@ -9,11 +9,11 @@ import net.minecraft.src.ModLoader;
import net.minecraftforge.client.MinecraftForgeClient;
import StevenDimDoors.mod_pocketDim.CommonProxy;
import StevenDimDoors.mod_pocketDim.Spells;
import StevenDimDoors.mod_pocketDim.TileEntityDimDoor;
import StevenDimDoors.mod_pocketDim.TileEntityRift;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.ticking.CommonTickHandler;
import StevenDimDoors.mod_pocketDim.ticking.MobMonolith;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityRift;
public class ClientProxy extends CommonProxy

View File

@@ -12,181 +12,172 @@ import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ClosingRiftFX extends EntityFX
{
private int field_92049_a = 160;
private boolean field_92054_ax;
private boolean field_92048_ay;
private final EffectRenderer field_92047_az;
private float field_92050_aA;
private float field_92051_aB;
private float field_92052_aC;
private boolean field_92053_aD;
private int field_92049_a = 160;
private boolean field_92054_ax;
private boolean field_92048_ay;
private final EffectRenderer field_92047_az;
private float field_92050_aA;
private float field_92051_aB;
private float field_92052_aC;
private boolean field_92053_aD;
public ClosingRiftFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, EffectRenderer par14EffectRenderer)
{
public ClosingRiftFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, EffectRenderer par14EffectRenderer)
{
super(par1World, par2, par4, par6);
this.motionX = par8;
this.motionY = par10;
this.motionZ = par12;
this.field_92047_az = par14EffectRenderer;
this.particleScale *= .55F;
this.particleMaxAge = 30 + this.rand.nextInt(16);
this.noClip = false;
}
super(par1World, par2, par4, par6);
this.motionX = par8;
this.motionY = par10;
this.motionZ = par12;
this.field_92047_az = par14EffectRenderer;
this.particleScale *= .55F;
this.particleMaxAge = 30 + this.rand.nextInt(16);
this.noClip = false;
}
public void func_92045_e(boolean par1)
{
this.field_92054_ax = par1;
}
public void func_92045_e(boolean par1)
{
this.field_92054_ax = par1;
}
public void func_92043_f(boolean par1)
{
this.field_92048_ay = par1;
}
public void func_92043_f(boolean par1)
{
this.field_92048_ay = par1;
}
public void func_92044_a(int par1)
{
float var2 = (float)((par1 & 16711680) >> 16) / 255.0F;
float var3 = (float)((par1 & 65280) >> 8) / 255.0F;
float var4 = (float)((par1 & 255) >> 0) / 255.0F;
float var5 = 1.0F;
this.setRBGColorF(var2 * var5, var3 * var5, var4 * var5);
}
public void func_92044_a(int par1)
{
float var2 = (float)((par1 & 16711680) >> 16) / 255.0F;
float var3 = (float)((par1 & 65280) >> 8) / 255.0F;
float var4 = (float)((par1 & 255) >> 0) / 255.0F;
float var5 = 1.0F;
this.setRBGColorF(var2 * var5, var3 * var5, var4 * var5);
}
public void func_92046_g(int par1)
{
this.field_92050_aA = (float)((par1 & 16711680) >> 16) / 255.0F;
this.field_92051_aB = (float)((par1 & 65280) >> 8) / 255.0F;
this.field_92052_aC = (float)((par1 & 255) >> 0) / 255.0F;
this.field_92053_aD = true;
}
public void func_92046_g(int par1)
{
this.field_92050_aA = (float)((par1 & 16711680) >> 16) / 255.0F;
this.field_92051_aB = (float)((par1 & 65280) >> 8) / 255.0F;
this.field_92052_aC = (float)((par1 & 255) >> 0) / 255.0F;
this.field_92053_aD = true;
}
/**
* returns the bounding box for this entity
*/
public AxisAlignedBB getBoundingBox()
{
return null;
}
/**
* returns the bounding box for this entity
*/
public AxisAlignedBB getBoundingBox()
{
return null;
}
/**
* Returns true if this entity should push and be pushed by other entities when colliding.
*/
public boolean canBePushed()
{
return false;
}
/**
* Returns true if this entity should push and be pushed by other entities when colliding.
*/
public boolean canBePushed()
{
return false;
}
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
{
if (!this.field_92048_ay || this.particleAge < this.particleMaxAge / 3 || (this.particleAge + this.particleMaxAge) / 3 % 2 == 0)
{
this.doRenderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7);
}
}
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
{
if (!this.field_92048_ay || this.particleAge < this.particleMaxAge / 3 || (this.particleAge + this.particleMaxAge) / 3 % 2 == 0)
{
this.doRenderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7);
}
}
public void doRenderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
{
float var8 = (float)(super.particleTextureIndexX % 16) / 16.0F;
float var9 = var8 + 0.0624375F;
float var10 = (float)(this.particleTextureIndexX / 16) / 16.0F;
float var11 = var10 + 0.0624375F;
float var12 = 0.1F * this.particleScale;
float var13 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)par2 - interpPosX);
float var14 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)par2 - interpPosY);
float var15 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par2 - interpPosZ);
float var16 = .8F;
try
{
if(PocketManager.instance.getDimData(this.worldObj.provider.dimensionId).isPocket)
{
var16=.4F;
}
else
{
public void doRenderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
{
float var8 = (float)(super.particleTextureIndexX % 16) / 16.0F;
float var9 = var8 + 0.0624375F;
float var10 = (float)(this.particleTextureIndexX / 16) / 16.0F;
float var11 = var10 + 0.0624375F;
float var12 = 0.1F * this.particleScale;
float var13 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)par2 - interpPosX);
float var14 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)par2 - interpPosY);
float var15 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par2 - interpPosZ);
float var16 = 0.8F;
}
}
catch(Exception E)
{
if (PocketManager.getDimensionData(worldObj).isPocketDimension())
{
var16 = 0.4F;
}
}
par1Tessellator.setColorRGBA_F(this.particleRed * var16, this.particleGreen * var16, this.particleBlue * var16, (float) .7);
par1Tessellator.setColorRGBA_F(this.particleRed * var16, this.particleGreen * var16, this.particleBlue * var16, (float) .7);
par1Tessellator.addVertexWithUV((double)(var13 - par3 * var12 - par6 * var12), (double)(var14 - par4 * var12), (double)(var15 - par5 * var12 - par7 * var12), (double)var9, (double)var11);
par1Tessellator.addVertexWithUV((double)(var13 - par3 * var12 + par6 * var12), (double)(var14 + par4 * var12), (double)(var15 - par5 * var12 + par7 * var12), (double)var9, (double)var10);
par1Tessellator.addVertexWithUV((double)(var13 + par3 * var12 + par6 * var12), (double)(var14 + par4 * var12), (double)(var15 + par5 * var12 + par7 * var12), (double)var8, (double)var10);
par1Tessellator.addVertexWithUV((double)(var13 + par3 * var12 - par6 * var12), (double)(var14 - par4 * var12), (double)(var15 + par5 * var12 - par7 * var12), (double)var8, (double)var11);
}
par1Tessellator.addVertexWithUV((double)(var13 - par3 * var12 - par6 * var12), (double)(var14 - par4 * var12), (double)(var15 - par5 * var12 - par7 * var12), (double)var9, (double)var11);
par1Tessellator.addVertexWithUV((double)(var13 - par3 * var12 + par6 * var12), (double)(var14 + par4 * var12), (double)(var15 - par5 * var12 + par7 * var12), (double)var9, (double)var10);
par1Tessellator.addVertexWithUV((double)(var13 + par3 * var12 + par6 * var12), (double)(var14 + par4 * var12), (double)(var15 + par5 * var12 + par7 * var12), (double)var8, (double)var10);
par1Tessellator.addVertexWithUV((double)(var13 + par3 * var12 - par6 * var12), (double)(var14 - par4 * var12), (double)(var15 + par5 * var12 - par7 * var12), (double)var8, (double)var11);
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (this.particleAge++ >= this.particleMaxAge)
{
this.setDead();
}
if (this.particleAge++ >= this.particleMaxAge)
{
this.setDead();
}
if (this.particleAge > this.particleMaxAge / 2)
{
this.setAlphaF(1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / (float)this.particleMaxAge);
if (this.particleAge > this.particleMaxAge / 2)
{
this.setAlphaF(1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / (float)this.particleMaxAge);
if (this.field_92053_aD)
{
this.particleRed += (this.field_92050_aA - this.particleRed) * 0.2F;
this.particleGreen += (this.field_92051_aB - this.particleGreen) * 0.2F;
this.particleBlue += (this.field_92052_aC - this.particleBlue) * 0.2F;
}
}
if (this.field_92053_aD)
{
this.particleRed += (this.field_92050_aA - this.particleRed) * 0.2F;
this.particleGreen += (this.field_92051_aB - this.particleGreen) * 0.2F;
this.particleBlue += (this.field_92052_aC - this.particleBlue) * 0.2F;
}
}
this.setParticleTextureIndex(this.field_92049_a + (7 - this.particleAge * 8 / this.particleMaxAge));
// this.motionY -= 0.004D;
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.9100000262260437D;
this.motionY *= 0.9100000262260437D;
this.motionZ *= 0.9100000262260437D;
this.setParticleTextureIndex(this.field_92049_a + (7 - this.particleAge * 8 / this.particleMaxAge));
// this.motionY -= 0.004D;
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.9100000262260437D;
this.motionY *= 0.9100000262260437D;
this.motionZ *= 0.9100000262260437D;
if (this.onGround)
{
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;
}
if (this.onGround)
{
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;
}
if (this.field_92054_ax && this.particleAge < this.particleMaxAge / 2 && (this.particleAge + this.particleMaxAge) % 2 == 0)
{
ClosingRiftFX var1 = new ClosingRiftFX(this.worldObj, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, this.field_92047_az);
var1.setRBGColorF(this.particleRed, this.particleGreen, this.particleBlue);
var1.particleAge = var1.particleMaxAge / 2;
if (this.field_92054_ax && this.particleAge < this.particleMaxAge / 2 && (this.particleAge + this.particleMaxAge) % 2 == 0)
{
ClosingRiftFX var1 = new ClosingRiftFX(this.worldObj, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, this.field_92047_az);
var1.setRBGColorF(this.particleRed, this.particleGreen, this.particleBlue);
var1.particleAge = var1.particleMaxAge / 2;
if (this.field_92053_aD)
{
var1.field_92053_aD = true;
var1.field_92050_aA = this.field_92050_aA;
var1.field_92051_aB = this.field_92051_aB;
var1.field_92052_aC = this.field_92052_aC;
}
if (this.field_92053_aD)
{
var1.field_92053_aD = true;
var1.field_92050_aA = this.field_92050_aA;
var1.field_92051_aB = this.field_92051_aB;
var1.field_92052_aC = this.field_92052_aC;
}
var1.field_92048_ay = this.field_92048_ay;
this.field_92047_az.addEffect(var1);
}
}
var1.field_92048_ay = this.field_92048_ay;
this.field_92047_az.addEffect(var1);
}
}
public int getBrightnessForRender(float par1)
{
return 15728880;
}
public int getBrightnessForRender(float par1)
{
return 15728880;
}
/**
* Gets how bright this entity is.
*/
public float getBrightness(float par1)
{
return 1.0F;
}
/**
* Gets how bright this entity is.
*/
public float getBrightness(float par1)
{
return 1.0F;
}
}

View File

@@ -1,195 +1,185 @@
package StevenDimDoors.mod_pocketDimClient;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.particle.EntityFireworkSparkFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GoggleRiftFX extends EntityFireworkSparkFX
{
private int field_92049_a = 160;
private boolean field_92054_ax;
private boolean field_92048_ay;
private final EffectRenderer field_92047_az;
private float field_92050_aA;
private float field_92051_aB;
private float field_92052_aC;
private boolean field_92053_aD;
private int field_92049_a = 160;
private boolean field_92054_ax;
private boolean field_92048_ay;
private final EffectRenderer field_92047_az;
private float field_92050_aA;
private float field_92051_aB;
private float field_92052_aC;
private boolean field_92053_aD;
public GoggleRiftFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, EffectRenderer par14EffectRenderer)
{
public GoggleRiftFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, EffectRenderer par14EffectRenderer)
{
super(par1World, par2, par4, par6, par12, par12, par12, par14EffectRenderer);
this.motionX = par8;
this.motionY = par10;
this.motionZ = par12;
this.field_92047_az = par14EffectRenderer;
this.particleScale *= .55F;
this.particleMaxAge = 30 + this.rand.nextInt(16);
this.noClip = false;
}
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
{
if (!this.field_92048_ay || this.particleAge < this.particleMaxAge / 3 || (this.particleAge + this.particleMaxAge) / 3 % 2 == 0)
{
this.doRenderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7);
}
}
super(par1World, par2, par4, par6, par12, par12, par12, par14EffectRenderer);
this.motionX = par8;
this.motionY = par10;
this.motionZ = par12;
this.field_92047_az = par14EffectRenderer;
this.particleScale *= .55F;
this.particleMaxAge = 30 + this.rand.nextInt(16);
this.noClip = false;
}
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
{
if (!this.field_92048_ay || this.particleAge < this.particleMaxAge / 3 || (this.particleAge + this.particleMaxAge) / 3 % 2 == 0)
{
this.doRenderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7);
}
}
public void doRenderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
{
float var8 = (float)(super.particleTextureIndexX % 16) / 16.0F;
float var9 = var8 + 0.0624375F;
float var10 = (float)(this.particleTextureIndexX / 16) / 16.0F;
float var11 = var10 + 0.0624375F;
float var12 = 0.1F * this.particleScale;
float var13 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)par2 - interpPosX);
float var14 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)par2 - interpPosY);
float var15 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par2 - interpPosZ);
float var16 = .0F;
try
{
if(PocketManager.instance.getDimData(this.worldObj.provider.dimensionId).isPocket)
{
var16=.7F;
}
else
{
public void doRenderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
{
float var8 = (float)(super.particleTextureIndexX % 16) / 16.0F;
float var9 = var8 + 0.0624375F;
float var10 = (float)(this.particleTextureIndexX / 16) / 16.0F;
float var11 = var10 + 0.0624375F;
float var12 = 0.1F * this.particleScale;
float var13 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)par2 - interpPosX);
float var14 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)par2 - interpPosY);
float var15 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par2 - interpPosZ);
float var16 = .0F;
}
}
catch(Exception E)
{
if (PocketManager.getDimensionData(worldObj).isPocketDimension())
{
var16 = .7F;
}
}
par1Tessellator.setColorRGBA_F(this.particleRed * var16, this.particleGreen * var16, this.particleBlue * var16, (float) .7);
par1Tessellator.setColorRGBA_F(this.particleRed * var16, this.particleGreen * var16, this.particleBlue * var16, (float) .7);
par1Tessellator.addVertexWithUV((double)(var13 - par3 * var12 - par6 * var12), (double)(var14 - par4 * var12), (double)(var15 - par5 * var12 - par7 * var12), (double)var9, (double)var11);
par1Tessellator.addVertexWithUV((double)(var13 - par3 * var12 + par6 * var12), (double)(var14 + par4 * var12), (double)(var15 - par5 * var12 + par7 * var12), (double)var9, (double)var10);
par1Tessellator.addVertexWithUV((double)(var13 + par3 * var12 + par6 * var12), (double)(var14 + par4 * var12), (double)(var15 + par5 * var12 + par7 * var12), (double)var8, (double)var10);
par1Tessellator.addVertexWithUV((double)(var13 + par3 * var12 - par6 * var12), (double)(var14 - par4 * var12), (double)(var15 + par5 * var12 - par7 * var12), (double)var8, (double)var11);
}
par1Tessellator.addVertexWithUV((double)(var13 - par3 * var12 - par6 * var12), (double)(var14 - par4 * var12), (double)(var15 - par5 * var12 - par7 * var12), (double)var9, (double)var11);
par1Tessellator.addVertexWithUV((double)(var13 - par3 * var12 + par6 * var12), (double)(var14 + par4 * var12), (double)(var15 - par5 * var12 + par7 * var12), (double)var9, (double)var10);
par1Tessellator.addVertexWithUV((double)(var13 + par3 * var12 + par6 * var12), (double)(var14 + par4 * var12), (double)(var15 + par5 * var12 + par7 * var12), (double)var8, (double)var10);
par1Tessellator.addVertexWithUV((double)(var13 + par3 * var12 - par6 * var12), (double)(var14 - par4 * var12), (double)(var15 + par5 * var12 - par7 * var12), (double)var8, (double)var11);
}
public void func_92045_e(boolean par1)
{
this.field_92054_ax = par1;
}
public void func_92045_e(boolean par1)
{
this.field_92054_ax = par1;
}
public void func_92043_f(boolean par1)
{
this.field_92048_ay = par1;
}
public void func_92043_f(boolean par1)
{
this.field_92048_ay = par1;
}
public void func_92044_a(int par1)
{
float var2 = (float)((par1 & 16711680) >> 16) / 255.0F;
float var3 = (float)((par1 & 65280) >> 8) / 255.0F;
float var4 = (float)((par1 & 255) >> 0) / 255.0F;
float var5 = 1.0F;
this.setRBGColorF(var2 * var5, var3 * var5, var4 * var5);
}
public void func_92044_a(int par1)
{
float var2 = (float)((par1 & 16711680) >> 16) / 255.0F;
float var3 = (float)((par1 & 65280) >> 8) / 255.0F;
float var4 = (float)((par1 & 255) >> 0) / 255.0F;
float var5 = 1.0F;
this.setRBGColorF(var2 * var5, var3 * var5, var4 * var5);
}
public void func_92046_g(int par1)
{
this.field_92050_aA = (float)((par1 & 16711680) >> 16) / 255.0F;
this.field_92051_aB = (float)((par1 & 65280) >> 8) / 255.0F;
this.field_92052_aC = (float)((par1 & 255) >> 0) / 255.0F;
this.field_92053_aD = true;
}
public void func_92046_g(int par1)
{
this.field_92050_aA = (float)((par1 & 16711680) >> 16) / 255.0F;
this.field_92051_aB = (float)((par1 & 65280) >> 8) / 255.0F;
this.field_92052_aC = (float)((par1 & 255) >> 0) / 255.0F;
this.field_92053_aD = true;
}
/**
* returns the bounding box for this entity
*/
public AxisAlignedBB getBoundingBox()
{
return null;
}
/**
* returns the bounding box for this entity
*/
public AxisAlignedBB getBoundingBox()
{
return null;
}
/**
* Returns true if this entity should push and be pushed by other entities when colliding.
*/
public boolean canBePushed()
{
return false;
}
/**
* Returns true if this entity should push and be pushed by other entities when colliding.
*/
public boolean canBePushed()
{
return false;
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (this.particleAge++ >= this.particleMaxAge)
{
this.setDead();
}
if (this.particleAge++ >= this.particleMaxAge)
{
this.setDead();
}
if (this.particleAge > this.particleMaxAge / 2)
{
this.setAlphaF(1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / (float)this.particleMaxAge);
if (this.particleAge > this.particleMaxAge / 2)
{
this.setAlphaF(1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / (float)this.particleMaxAge);
if (this.field_92053_aD)
{
this.particleRed += (this.field_92050_aA - this.particleRed) * 0.2F;
this.particleGreen += (this.field_92051_aB - this.particleGreen) * 0.2F;
this.particleBlue += (this.field_92052_aC - this.particleBlue) * 0.2F;
}
}
if (this.field_92053_aD)
{
this.particleRed += (this.field_92050_aA - this.particleRed) * 0.2F;
this.particleGreen += (this.field_92051_aB - this.particleGreen) * 0.2F;
this.particleBlue += (this.field_92052_aC - this.particleBlue) * 0.2F;
}
}
this.setParticleTextureIndex(this.field_92049_a + (7 - this.particleAge * 8 / this.particleMaxAge));
// this.motionY -= 0.004D;
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.9100000262260437D;
this.motionY *= 0.9100000262260437D;
this.motionZ *= 0.9100000262260437D;
this.setParticleTextureIndex(this.field_92049_a + (7 - this.particleAge * 8 / this.particleMaxAge));
// this.motionY -= 0.004D;
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.9100000262260437D;
this.motionY *= 0.9100000262260437D;
this.motionZ *= 0.9100000262260437D;
if (this.onGround)
{
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;
}
if (this.onGround)
{
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;
}
if (this.field_92054_ax && this.particleAge < this.particleMaxAge / 2 && (this.particleAge + this.particleMaxAge) % 2 == 0)
{
GoggleRiftFX var1 = new GoggleRiftFX(this.worldObj, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, this.field_92047_az);
var1.setRBGColorF(this.particleRed, this.particleGreen, this.particleBlue);
var1.particleAge = var1.particleMaxAge / 2;
if (this.field_92054_ax && this.particleAge < this.particleMaxAge / 2 && (this.particleAge + this.particleMaxAge) % 2 == 0)
{
GoggleRiftFX var1 = new GoggleRiftFX(this.worldObj, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, this.field_92047_az);
var1.setRBGColorF(this.particleRed, this.particleGreen, this.particleBlue);
var1.particleAge = var1.particleMaxAge / 2;
if (this.field_92053_aD)
{
var1.field_92053_aD = true;
var1.field_92050_aA = this.field_92050_aA;
var1.field_92051_aB = this.field_92051_aB;
var1.field_92052_aC = this.field_92052_aC;
}
if (this.field_92053_aD)
{
var1.field_92053_aD = true;
var1.field_92050_aA = this.field_92050_aA;
var1.field_92051_aB = this.field_92051_aB;
var1.field_92052_aC = this.field_92052_aC;
}
var1.field_92048_ay = this.field_92048_ay;
this.field_92047_az.addEffect(var1);
}
}
var1.field_92048_ay = this.field_92048_ay;
this.field_92047_az.addEffect(var1);
}
}
public int getBrightnessForRender(float par1)
{
return 15728880;
}
public int getBrightnessForRender(float par1)
{
return 15728880;
}
/**
* Gets how bright this entity is.
*/
public float getBrightness(float par1)
{
return 1.0F;
}
/**
* Gets how bright this entity is.
*/
public float getBrightness(float par1)
{
return 1.0F;
}
}

View File

@@ -14,9 +14,9 @@ import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.TileEntityDimDoor;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.blocks.dimDoor;
import StevenDimDoors.mod_pocketDim.blocks.DimensionalDoor;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -40,12 +40,10 @@ public class RenderDimDoor extends TileEntitySpecialRenderer
{
try
{
dimDoor.class.cast(Block.blocksList[properties.DimensionalDoorID]).updateAttatchedTile(tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord).getFullMetadata(tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord);
mod_pocketDim.dimensionalDoor.updateAttachedTile(tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord);
}
catch(Exception e)
{
e.printStackTrace();
}

View File

@@ -1,283 +0,0 @@
package StevenDimDoors.mod_pocketDimClient;
import java.nio.FloatBuffer;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.TileEntityDimDoor;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.blocks.dimDoor;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderDimRail extends TileEntitySpecialRenderer
{
FloatBuffer field_76908_a = GLAllocation.createDirectFloatBuffer(16);
public RenderDimRail()
{
if (properties == null)
properties = DDProperties.instance();
}
private static DDProperties properties = null;
/**
* Renders the dimdoor.
*/
public void renderDimDoorTileEntity(TileEntityDimDoor tile, double x, double y, double z, float par8)
{
try
{
dimDoor.class.cast(Block.blocksList[properties.DimensionalDoorID]).updateAttatchedTile(tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord).getFullMetadata(tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord);
}
catch(Exception e)
{
e.printStackTrace();
}
float playerX = (float)this.tileEntityRenderer.playerX;
float playerY = (float)this.tileEntityRenderer.playerY;
float playerZ = (float)this.tileEntityRenderer.playerZ;
float distance = (float) tile.getDistanceFrom(playerX, playerY, playerZ);
GL11.glDisable(GL11.GL_LIGHTING);
Random rand = new Random(31100L);
float var13 = 0.75F;
for (int count = 0; count < 16; ++count)
{
GL11.glPushMatrix();
float var15 = (float)(16 - count);
float var16 = 0.2625F;
float var17 = 1.0F / (var15 + 1.0F);
if (count == 0)
{
this.bindTextureByName("/RIFT.png");
var17 = 0.1F;
var15 = 25.0F;
var16 = 0.125F;
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
if (count == 1)
{
this.bindTextureByName("/WARP.png");
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
var16 = .5F;
}
float startY = (float)(+(y + (double)var13));
float ratioY = startY + ActiveRenderInfo.objectY;
float ratioY2 = startY + var15 + ActiveRenderInfo.objectY;
float yConverted = ratioY / ratioY2;
float startZ = (float)(+(z + (double)var13));
float ratioZ = startZ + ActiveRenderInfo.objectZ;
float ratioZ2 = startZ + var15 + ActiveRenderInfo.objectZ;
float zConverted = ratioZ / ratioZ2;
float startX = (float)(+(x + (double)var13));
float ratioX = startX + ActiveRenderInfo.objectX;
float ratioX2 = startX + var15 + ActiveRenderInfo.objectX;
float xConverted = ratioX / ratioX2;
yConverted += (float)(y + (double)var13);
xConverted += (float)(x + (double)var13);
zConverted += (float)(z + (double)var13);
GL11.glTranslatef( (float)(Minecraft.getSystemTime() % 200000L) / 200000.0F,0, 0.0F);
GL11.glTranslatef(0, (float)(Minecraft.getSystemTime() % 200000L) / 200000.0F, 0.0F);
GL11.glTranslatef(0,0, (float)(Minecraft.getSystemTime() % 200000L) / 200000.0F);
GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR);
GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR);
GL11.glTexGeni(GL11.GL_R, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR);
GL11.glTexGeni(GL11.GL_Q, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR);
switch ((tile.orientation%4)+4)
{
case 4:
GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.0F));
GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GL11.glTexGen(GL11.GL_Q, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F));
break;
case 5:
GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F));
GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GL11.glTexGen(GL11.GL_Q, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.0F));
break;
case 6:
GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.0F));
GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GL11.glTexGen(GL11.GL_Q, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F));
break;
case 7:
GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(1.0F, 0.0F, 0.0F, 0.0F));
GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GL11.glTexGen(GL11.GL_Q, GL11.GL_OBJECT_PLANE, this.getFloatBuffer(0.0F, 0.0F, 1.0F, 0.0F));
break;
}
GL11.glEnable(GL11.GL_TEXTURE_GEN_S);
GL11.glEnable(GL11.GL_TEXTURE_GEN_T);
GL11.glEnable(GL11.GL_TEXTURE_GEN_R);
GL11.glEnable(GL11.GL_TEXTURE_GEN_Q);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPushMatrix();
GL11.glLoadIdentity();
GL11.glTranslatef(0.0F, (float)(Minecraft.getSystemTime() % 200000L) / 200000.0F*var15, 0.0F);
GL11.glScalef(var16, var16, var16);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
GL11.glRotatef((float)(count * count * 4321 + count * 9) * 2.0F, 0.0F, 0.0F, 1.0F);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
Tessellator var24 = Tessellator.instance;
var24.startDrawingQuads();
float var21 = rand.nextFloat() * 0.5F + 0.1F;
float var22 = rand.nextFloat() * 0.4F + 0.4F;
float var23 = rand.nextFloat() * 0.6F + 0.5F;
if (count == 0)
{
var23 = 1.0F;
var22 = 1.0F;
yConverted = 1.0F;
}
var24.setColorRGBA_F(var21 * var17, var22 * var17, var23 * var17, 1.0F);
if(tile.openOrClosed)
{
switch (tile.orientation)
{
case 0:
var24.addVertex(x+.01F, y-1 , z);
var24.addVertex(x+.01, y-1, z+1.0D);
var24.addVertex(x+.01 , y+1 , z + 1.0D);
var24.addVertex(x+.01 , y+1 , z);
break;
case 1:
var24.addVertex(x , y+1 , z+.01);
var24.addVertex(x+1 , y+1 , z+.01);
var24.addVertex(x+1, y-1, z+.01);
var24.addVertex(x, y-1, z+.01);
break;
case 2: //
var24.addVertex(x+.99 , y+1 , z);
var24.addVertex(x+.99 , y+1 , z + 1.0D);
var24.addVertex(x+.99, y-1, z+1.0D);
var24.addVertex(x+.99, y-1, z);
break;
case 3:
var24.addVertex(x, y-1, z+.99);
var24.addVertex(x+1, y-1, z+.99);
var24.addVertex(x+1 , y+1 , z+.99);
var24.addVertex(x , y+1 , z+.99);
break;
case 4://
// GL11.glTranslatef();
var24.addVertex(x+.15F, y-1 , z);
var24.addVertex(x+.15, y-1, z+1.0D);
var24.addVertex(x+.15 , y+1 , z + 1.0D);
var24.addVertex(x+.15 , y+1 , z);
break;
case 5:
var24.addVertex(x , y+1 , z+.15);
var24.addVertex(x+1 , y+1 , z+.15);
var24.addVertex(x+1, y-1, z+.15);
var24.addVertex(x, y-1, z+.15);
break;
case 6: //
var24.addVertex(x+.85 , y+1 , z);
var24.addVertex(x+.85 , y+1 , z + 1.0D);
var24.addVertex(x+.85, y-1, z+1.0D);
var24.addVertex(x+.85, y-1, z);
break;
case 7:
var24.addVertex(x, y-1, z+.85);
var24.addVertex(x+1, y-1, z+.85);
var24.addVertex(x+1 , y+1 , z+.85);
var24.addVertex(x , y+1 , z+.85);
break;
default:
break;
}
}
var24.draw();
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_TEXTURE_GEN_S);
GL11.glDisable(GL11.GL_TEXTURE_GEN_T);
GL11.glDisable(GL11.GL_TEXTURE_GEN_R);
GL11.glDisable(GL11.GL_TEXTURE_GEN_Q);
GL11.glEnable(GL11.GL_LIGHTING);
}
private FloatBuffer getFloatBuffer(float par1, float par2, float par3, float par4)
{
this.field_76908_a.clear();
this.field_76908_a.put(par1).put(par2).put(par3).put(par4);
this.field_76908_a.flip();
return this.field_76908_a;
}
public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8)
{
if (properties.DoorRenderingEnabled)
{
this.renderDimDoorTileEntity((TileEntityDimDoor)par1TileEntity, par2, par4, par6, par8);
}
}
}

View File

@@ -16,10 +16,10 @@ import org.lwjgl.opengl.GL11;
import static org.lwjgl.opengl.GL11.*;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.TileEntityDimDoor;
import StevenDimDoors.mod_pocketDim.TileEntityRift;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.blocks.dimDoor;
import StevenDimDoors.mod_pocketDim.blocks.DimensionalDoor;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityRift;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View File

@@ -1,12 +1,11 @@
package StevenDimDoors.mod_pocketDimClient;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.particle.EntityFireworkSparkFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -109,22 +108,11 @@ public class RiftFX extends EntityFX
float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par2 - interpPosZ);
float f14 = 0F;
if (PocketManager.getDimensionData(worldObj).isPocketDimension())
{
f14 = 0.7F;
}
try
{
if(PocketManager.instance.getDimData(this.worldObj.provider.dimensionId).isPocket)
{
f14=.7F;
}
else
{
}
}
catch(Exception E)
{
}
par1Tessellator.setColorRGBA_F(this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, (float) .7);
par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 - par5 * f10 - par7 * f10), (double)f7, (double)f9);
par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 - par5 * f10 + par7 * f10), (double)f7, (double)f8);