Various Fixes #166

Merged
SenseiKiwi merged 19 commits from master into master 2014-06-26 23:17:34 +00:00
11 changed files with 127 additions and 81 deletions
Showing only changes of commit f9331e4f2d - Show all commits

View File

@@ -75,7 +75,6 @@ public class EventHookContainer
public void onSoundEffectResult(PlayBackgroundMusicEvent event) public void onSoundEffectResult(PlayBackgroundMusicEvent event)
{ {
if (FMLClientHandler.instance().getClient().thePlayer.worldObj.provider.dimensionId == mod_pocketDim.properties.LimboDimensionID) if (FMLClientHandler.instance().getClient().thePlayer.worldObj.provider.dimensionId == mod_pocketDim.properties.LimboDimensionID)
;
{ {
this.playMusicForDim(FMLClientHandler.instance().getClient().thePlayer.worldObj); this.playMusicForDim(FMLClientHandler.instance().getClient().thePlayer.worldObj);
} }
@@ -92,6 +91,8 @@ public class EventHookContainer
World world = event.entity.worldObj; World world = event.entity.worldObj;
ItemStack stack = event.entityPlayer.inventory.getCurrentItem(); ItemStack stack = event.entityPlayer.inventory.getCurrentItem();
if (stack != null && stack.getItem() instanceof ItemDoor) if (stack != null && stack.getItem() instanceof ItemDoor)
{
if(BaseItemDoor.getDoorToPlace(stack.getItem())!=null)
{ {
if (mod_pocketDim.itemDimensionalDoor.tryToPlaceDoor(stack, event.entityPlayer, world, if (mod_pocketDim.itemDimensionalDoor.tryToPlaceDoor(stack, event.entityPlayer, world,
event.x, event.y, event.z, event.face)) event.x, event.y, event.z, event.face))
@@ -101,6 +102,7 @@ public class EventHookContainer
} }
} }
} }
}
@ForgeSubscribe @ForgeSubscribe
public void onWorldLoad(WorldEvent.Load event) public void onWorldLoad(WorldEvent.Load event)

View File

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

View File

@@ -298,4 +298,9 @@ public class DungeonPack
WeightedContainer<DungeonData> resultContainer = (WeightedContainer<DungeonData>) WeightedRandom.getRandomItem(random, weights); WeightedContainer<DungeonData> resultContainer = (WeightedContainer<DungeonData>) WeightedRandom.getRandomItem(random, weights);
return (resultContainer != null) ? resultContainer.getData() : null; return (resultContainer != null) ? resultContainer.getData() : null;
} }
@Override
public String toString()
{
return this.name;
}
} }

View File

@@ -45,4 +45,9 @@ public class DungeonType implements Comparable<DungeonType>
final int prime = 2039; final int prime = 2039;
return prime * ID; return prime * ID;
} }
@Override
public String toString()
{
return this.Name+" owned by "+this.Owner;
}
} }

View File

@@ -102,6 +102,9 @@ public class mod_pocketDim
public static final String version = "1.6.4-R2.2.3"; public static final String version = "1.6.4-R2.2.3";
public static final String modid = "dimdoors"; 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 //need to clean up
@SidedProxy(clientSide = "StevenDimDoors.mod_pocketDimClient.ClientProxy", serverSide = "StevenDimDoors.mod_pocketDim.CommonProxy") @SidedProxy(clientSide = "StevenDimDoors.mod_pocketDimClient.ClientProxy", serverSide = "StevenDimDoors.mod_pocketDim.CommonProxy")
public static CommonProxy proxy; public static CommonProxy proxy;

View File

@@ -39,10 +39,39 @@ public class OldSaveImporter
return; 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()) for(DimData data : dimMap.values())
{ {
List<PackedLinkData> newPackedLinkData = new ArrayList<PackedLinkData>(); 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()) for(LinkData link : data.getLinksInDim())
{ {
@@ -55,19 +84,21 @@ public class OldSaveImporter
newPackedLinkData.add(newPackedLink); newPackedLinkData.add(newPackedLink);
allPackedLinks.add(newPackedLink); allPackedLinks.add(newPackedLink);
} }
PackedDimData dim;
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); 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); newPackedDimData.put(dim.ID,dim);
}
DDSaveHandler.unpackDimData(newPackedDimData); DDSaveHandler.unpackDimData(newPackedDimData);
DDSaveHandler.unpackLinkData(allPackedLinks); 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; package StevenDimDoors.mod_pocketDim.tileentities;
import java.util.Random;
import StevenDimDoors.mod_pocketDim.ServerPacketHandler; import StevenDimDoors.mod_pocketDim.ServerPacketHandler;
import StevenDimDoors.mod_pocketDim.mod_pocketDim; import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.blocks.IDimDoor; import StevenDimDoors.mod_pocketDim.blocks.IDimDoor;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager; import StevenDimDoors.mod_pocketDim.core.PocketManager;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@@ -11,7 +13,7 @@ import net.minecraft.network.packet.Packet130UpdateSign;
import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
public class TileEntityDimDoor extends TileEntity public class TileEntityDimDoor extends DDTileEntityBase
{ {
public boolean openOrClosed; public boolean openOrClosed;
public int orientation; public int orientation;
@@ -22,13 +24,9 @@ public class TileEntityDimDoor extends TileEntity
@Override @Override
public boolean canUpdate() public boolean canUpdate()
{ {
return true; return false;
} }
@Override
public void updateEntity()
{
}
@Override @Override
public Packet getDescriptionPacket() public Packet getDescriptionPacket()
{ {
@@ -83,5 +81,22 @@ public class TileEntityDimDoor extends TileEntity
nbt.setBoolean("hasGennedPair", hasGennedPair); 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.core.PocketManager;
import StevenDimDoors.mod_pocketDim.util.Point4D; 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 RIFT_INTERACTION_RANGE = 5;
private static final int MAX_ANCESTOR_LINKS = 2; private static final int MAX_ANCESTOR_LINKS = 2;
@@ -44,6 +44,8 @@ public class TileEntityRift extends TileEntity
private static final int MAX_RIFT_SPREAD_CHANCE = 256; private static final int MAX_RIFT_SPREAD_CHANCE = 256;
private static final int HOSTILE_ENDERMAN_CHANCE = 1; private static final int HOSTILE_ENDERMAN_CHANCE = 1;
private static final int MAX_HOSTILE_ENDERMAN_CHANCE = 3; 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 static Random random = new Random();
@@ -112,11 +114,7 @@ public class TileEntityRift extends TileEntity
updateTimer++; updateTimer++;
} }
@Override
public boolean canUpdate()
{
return true;
}
private void clearBlocksOnRift() private void clearBlocksOnRift()
{ {
@@ -387,4 +385,10 @@ public class TileEntityRift extends TileEntity
{ {
readFromNBT(pkt.data); readFromNBT(pkt.data);
} }
@Override
public float[] getRenderColor(Random rand)
{
return null;
}
} }

View File

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

View File

@@ -181,33 +181,8 @@ public class RenderDimDoor extends TileEntitySpecialRenderer
GL11.glBegin(GL11.GL_QUADS); GL11.glBegin(GL11.GL_QUADS);
// Set the portal's color depending on whether it's in the Nether float[] color = tile.getRenderColor(rand);
float var21, var22, var23; GL11.glColor4f(color[0] * var17, color[1] * var17, color[2] * var17, color[3]);
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);
switch (tile.orientation) switch (tile.orientation)
{ {