Fixed bug in converting old saves
Started color work
This commit is contained in:
StevenRS11 2014-05-16 21:42:59 -04:00
parent d020dd384b
commit ac9b3d73e8
8 changed files with 110 additions and 76 deletions

View file

@ -424,7 +424,8 @@ public class PocketManager
{
System.out.println("Importing old DD save data...");
OldSaveImporter.importOldSave(oldSaveData);
oldSaveData.delete();
oldSaveData.renameTo(new File(oldSaveData.getAbsolutePath()+"_IMPORTED"));
System.out.println("Import Succesful!");
}

View file

@ -101,6 +101,9 @@ public class mod_pocketDim
{
public static final String version = "1.6.4-R2.2.3";
public static final String modid = "dimdoors";
//TODO need a place to stick all these constants
public static final int NETHER_DIMENSION_ID = -1;
//need to clean up
@SidedProxy(clientSide = "StevenDimDoors.mod_pocketDimClient.ClientProxy", serverSide = "StevenDimDoors.mod_pocketDim.CommonProxy")

View file

@ -39,10 +39,39 @@ public class OldSaveImporter
return;
}
//build the child list
HashMap<Integer, ArrayList<Integer>> parentChildMapping = new HashMap<Integer, ArrayList<Integer>>();
for(DimData data : dimMap.values())
{
if(data.isPocket)
{
LinkData link = data.exitDimLink;
if(parentChildMapping.containsKey(link.destDimID))
{
parentChildMapping.get(link.destDimID).add(data.dimID);
}
else
{
parentChildMapping.put(link.destDimID, new ArrayList<Integer>());
parentChildMapping.get(link.destDimID).add(data.dimID);
}
parentChildMapping.remove(data.dimID);
}
}
for(DimData data : dimMap.values())
{
List<PackedLinkData> newPackedLinkData = new ArrayList<PackedLinkData>();
List<Integer> childDims = new ArrayList<Integer>();
List<Integer> childDims;
if(parentChildMapping.containsKey(data.dimID))
{
childDims =parentChildMapping.get(data.dimID);
}
else
{
childDims = new ArrayList<Integer>();
}
for(LinkData link : data.getLinksInDim())
{
@ -55,19 +84,21 @@ public class OldSaveImporter
newPackedLinkData.add(newPackedLink);
allPackedLinks.add(newPackedLink);
}
PackedDimData dim = new PackedDimData(data.dimID, data.depth, data.depth, data.exitDimLink.locDimID, data.exitDimLink.locDimID, 0, data.dungeonGenerator!=null, data.hasBeenFilled, null, new Point3D(0,64,0), childDims, newPackedLinkData, null);
PackedDimData dim;
if(data.isPocket)
{
dim = new PackedDimData(data.dimID, data.depth, data.depth, data.exitDimLink.locDimID, data.exitDimLink.locDimID, 0, data.dungeonGenerator!=null, data.hasBeenFilled, null, new Point3D(0,64,0), childDims, newPackedLinkData, null);
}
else
{
dim = new PackedDimData(data.dimID, data.depth, data.depth, data.dimID, data.dimID, 0, data.dungeonGenerator!=null, data.hasBeenFilled, null, new Point3D(0,64,0), childDims, newPackedLinkData, null);
}
newPackedDimData.put(dim.ID,dim);
DDSaveHandler.unpackDimData(newPackedDimData);
DDSaveHandler.unpackLinkData(allPackedLinks);
}
DDSaveHandler.unpackDimData(newPackedDimData);
DDSaveHandler.unpackLinkData(allPackedLinks);
}
}

View file

@ -0,0 +1,13 @@
package StevenDimDoors.mod_pocketDim.tileentities;
import java.util.Random;
import net.minecraft.tileentity.TileEntity;
public abstract class DDTileEntityBase extends TileEntity
{
/**
*
* @return an array of floats representing RGBA color where 1.0 = 255.
*/
public abstract float[] getRenderColor(Random rand);
}

View file

@ -1,8 +1,10 @@
package StevenDimDoors.mod_pocketDim.tileentities;
import java.util.Random;
import StevenDimDoors.mod_pocketDim.ServerPacketHandler;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.blocks.IDimDoor;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
@ -11,7 +13,7 @@ import net.minecraft.network.packet.Packet130UpdateSign;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.tileentity.TileEntity;
public class TileEntityDimDoor extends TileEntity
public class TileEntityDimDoor extends DDTileEntityBase
{
public boolean openOrClosed;
public int orientation;
@ -22,13 +24,9 @@ public class TileEntityDimDoor extends TileEntity
@Override
public boolean canUpdate()
{
return true;
return false;
}
@Override
public void updateEntity()
{
}
@Override
public Packet getDescriptionPacket()
{
@ -83,5 +81,22 @@ public class TileEntityDimDoor extends TileEntity
nbt.setBoolean("hasGennedPair", hasGennedPair);
}
@Override
public float[] getRenderColor(Random rand)
{
float[] rgbaColor = {1,1,1,1};
if (this.worldObj.provider.dimensionId == mod_pocketDim.NETHER_DIMENSION_ID)
{
rgbaColor[0] = rand.nextFloat() * 0.5F + 0.4F;
rgbaColor[1] = rand.nextFloat() * 0.05F;
rgbaColor[2] = rand.nextFloat() * 0.05F;
}
else
{
rgbaColor[0] = rand.nextFloat() * 0.5F + 0.1F;
rgbaColor[1] = rand.nextFloat() * 0.4F + 0.4F;
rgbaColor[2] = rand.nextFloat() * 0.6F + 0.5F;
}
return rgbaColor;
}
}

View file

@ -33,7 +33,7 @@ import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.util.Point4D;
public class TileEntityRift extends TileEntity
public class TileEntityRift extends DDTileEntityBase
{
private static final int RIFT_INTERACTION_RANGE = 5;
private static final int MAX_ANCESTOR_LINKS = 2;
@ -44,7 +44,9 @@ public class TileEntityRift extends TileEntity
private static final int MAX_RIFT_SPREAD_CHANCE = 256;
private static final int HOSTILE_ENDERMAN_CHANCE = 1;
private static final int MAX_HOSTILE_ENDERMAN_CHANCE = 3;
private static final float[] POCKET_RENDER_COLOR= {1,1,1,.7F};
private static final float[] DEFAULT_RENDER_COLOR= {1,1,1,1};
private static Random random = new Random();
private int age = 0;
@ -112,11 +114,7 @@ public class TileEntityRift extends TileEntity
updateTimer++;
}
@Override
public boolean canUpdate()
{
return true;
}
private void clearBlocksOnRift()
{
@ -387,4 +385,10 @@ public class TileEntityRift extends TileEntity
{
readFromNBT(pkt.data);
}
@Override
public float[] getRenderColor(Random rand)
{
return null;
}
}

View file

@ -1,44 +1,36 @@
package StevenDimDoors.mod_pocketDim.tileentities;
import java.util.Random;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
public class TileEntityTransTrapdoor extends TileEntity
public class TileEntityTransTrapdoor extends DDTileEntityBase
{
public boolean hasRift;
@Override
public boolean canUpdate()
{
return true;
return false;
}
@Override
public void updateEntity()
public float[] getRenderColor(Random rand)
{
}
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
try
float[] rgbaColor = {1,1,1,1};
if (this.worldObj.provider.dimensionId == mod_pocketDim.NETHER_DIMENSION_ID)
{
this.hasRift = nbt.getBoolean("hasRift");
rgbaColor[0] = worldObj.rand.nextFloat() * 0.5F + 0.4F;
rgbaColor[1] = worldObj.rand.nextFloat() * 0.05F;
rgbaColor[2] = worldObj.rand.nextFloat() * 0.05F;
}
catch (Exception e)
else
{
rgbaColor[0] = worldObj.rand.nextFloat() * 0.5F + 0.1F;
rgbaColor[1] = worldObj.rand.nextFloat() * 0.4F + 0.4F;
rgbaColor[2] = worldObj.rand.nextFloat() * 0.6F + 0.5F;
}
}
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
nbt.setBoolean("hasRift", this.hasRift);
return rgbaColor;
}
}

View file

@ -181,33 +181,8 @@ public class RenderDimDoor extends TileEntitySpecialRenderer
GL11.glBegin(GL11.GL_QUADS);
// Set the portal's color depending on whether it's in the Nether
float var21, var22, var23;
NewDimData dimension = PocketManager.getDimensionData(tile.worldObj);
if (dimension.root().id() == NETHER_DIMENSION_ID)
{
var21 = rand.nextFloat() * 0.5F + 0.4F;
var22 = rand.nextFloat() * 0.05F;
var23 = rand.nextFloat() * 0.05F;
if (count == 0)
{
var21 = 1.0F;
}
}
else
{
var21 = rand.nextFloat() * 0.5F + 0.1F;
var22 = rand.nextFloat() * 0.4F + 0.4F;
var23 = rand.nextFloat() * 0.6F + 0.5F;
if (count == 0)
{
var23 = 1.0F;
var22 = 1.0F;
}
}
GL11.glColor4d(var21 * var17, var22 * var17, var23 * var17, 1.0F);
float[] color = tile.getRenderColor(rand);
GL11.glColor4f(color[0] * var17, color[1] * var17, color[2] * var17, color[3]);
switch (tile.orientation)
{