Merge remote-tracking branch 'upstream/1.6.2-code' into mazes
This commit is contained in:
@@ -15,9 +15,9 @@ apply plugin: 'forge'
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
version = "2.1.1RC1"
|
version = "2.2.1RC1-" + System.getenv("BUILD_NUMBER")
|
||||||
group= "com.stevenrs11.dimdoors" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
group= "com.stevenrs11.dimdoors" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
archivesBaseName = "dimdoors"
|
archivesBaseName = "DimensionalDoors"
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
version = "1.6.4-9.11.1.964"
|
version = "1.6.4-9.11.1.964"
|
||||||
@@ -30,7 +30,7 @@ processResources
|
|||||||
{
|
{
|
||||||
// replace stuff in mcmod.info, nothing else
|
// replace stuff in mcmod.info, nothing else
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
include 'mcmod/info'
|
include 'mcmod.info'
|
||||||
|
|
||||||
// replace version and mcversion
|
// replace version and mcversion
|
||||||
expand 'version':project.version, 'mcversion':project.minecraft.version
|
expand 'version':project.version, 'mcversion':project.minecraft.version
|
||||||
@@ -45,6 +45,4 @@ processResources
|
|||||||
jar
|
jar
|
||||||
{
|
{
|
||||||
destinationDir = new File("build/dist/")
|
destinationDir = new File("build/dist/")
|
||||||
archiveName = "DimensionalDoors-${version}-" + System.getenv("BUILD_NUMBER") + ".jar"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,9 +27,17 @@ public class ConnectionHandler implements IConnectionHandler
|
|||||||
{
|
{
|
||||||
for(NewDimData data : PocketManager.getDimensions())
|
for(NewDimData data : PocketManager.getDimensions())
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Packet250CustomPayload[] pkt = ForgePacket.makePacketSet(new DimensionRegisterPacket(data.id(), DimensionManager.getProviderType(data.id())));
|
||||||
|
manager.addToSendQueue(pkt[0]);
|
||||||
|
}
|
||||||
|
catch(Exception E)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Packet250CustomPayload[] pkt = ForgePacket.makePacketSet(new DimensionRegisterPacket(data.id(), DimensionManager.getProviderType(data.id())));
|
|
||||||
manager.addToSendQueue(pkt[0]);
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ import net.minecraft.world.World;
|
|||||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityRift;
|
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityRift;
|
||||||
import StevenDimDoors.mod_pocketDimClient.ClosingRiftFX;
|
import StevenDimDoors.mod_pocketDimClient.ClosingRiftFX;
|
||||||
@@ -152,6 +154,8 @@ public class BlockRift extends BlockContainer
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//function that regulates how many blocks it eats/ how fast it eats them.
|
//function that regulates how many blocks it eats/ how fast it eats them.
|
||||||
@Override
|
@Override
|
||||||
public void updateTick(World world, int x, int y, int z, Random random)
|
public void updateTick(World world, int x, int y, int z, Random random)
|
||||||
@@ -162,11 +166,12 @@ public class BlockRift extends BlockContainer
|
|||||||
//Randomly decide whether to search for blocks to destroy. This reduces the frequency of search operations,
|
//Randomly decide whether to search for blocks to destroy. This reduces the frequency of search operations,
|
||||||
//moderates performance impact, and controls the apparent speed of block destruction.
|
//moderates performance impact, and controls the apparent speed of block destruction.
|
||||||
if (random.nextInt(MAX_BLOCK_SEARCH_CHANCE) < BLOCK_SEARCH_CHANCE &&
|
if (random.nextInt(MAX_BLOCK_SEARCH_CHANCE) < BLOCK_SEARCH_CHANCE &&
|
||||||
((TileEntityRift) world.getBlockTileEntity(x, y, z)).isNearRift )
|
((TileEntityRift) world.getBlockTileEntity(x, y, z)).isNearRift() )
|
||||||
{
|
{
|
||||||
destroyNearbyBlocks(world, x, y, z, random);
|
destroyNearbyBlocks(world, x, y, z, random);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void destroyNearbyBlocks(World world, int x, int y, int z, Random random)
|
private void destroyNearbyBlocks(World world, int x, int y, int z, Random random)
|
||||||
|
|||||||
@@ -61,14 +61,20 @@ public class CommandDeleteRifts extends DDCommandBase
|
|||||||
{
|
{
|
||||||
World targetWorld = PocketManager.loadDimension(targetDim);
|
World targetWorld = PocketManager.loadDimension(targetDim);
|
||||||
|
|
||||||
if(sender.worldObj.getBlockId(link.source().getX(), link.source().getY(), link.source().getZ())==mod_pocketDim.blockRift.blockID)
|
if(!mod_pocketDim.blockRift.isBlockImmune(sender.worldObj,link.source().getX(), link.source().getY(), link.source().getZ())||
|
||||||
|
(targetWorld.getBlockId(link.source().getX(), link.source().getY(), link.source().getZ())==mod_pocketDim.blockRift.blockID))
|
||||||
{
|
{
|
||||||
targetWorld.setBlock(link.source().getX(), link.source().getY(), link.source().getZ(), 0);
|
|
||||||
linksRemoved++;
|
linksRemoved++;
|
||||||
|
targetWorld.setBlock(link.source().getX(), link.source().getY(), link.source().getZ(), 0);
|
||||||
dim.deleteLink(link);
|
dim.deleteLink(link);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//TODO Probably should check what the block is, but thats annoying so Ill do it later.
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
sendChat(sender,("Removed " + linksRemoved + " rifts."));
|
sendChat(sender,("Removed " + linksRemoved + " links."));
|
||||||
|
|
||||||
}
|
}
|
||||||
return DDCommandResult.SUCCESS; //TEMPORARY HACK
|
return DDCommandResult.SUCCESS; //TEMPORARY HACK
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class CommandTeleportPlayer extends DDCommandBase
|
|||||||
|
|
||||||
private CommandTeleportPlayer()
|
private CommandTeleportPlayer()
|
||||||
{
|
{
|
||||||
super("dd-tp", new String[] {"<Player Name> <Dimension ID> <X Coord> <Y Coord> <Z Coord>"} );
|
super("dd-tp", new String[] {"<Player Name> <Dimension ID> <X Coord> <Y Coord> <Z Coord>","<Player Name> <Dimension ID>"} );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CommandTeleportPlayer instance()
|
public static CommandTeleportPlayer instance()
|
||||||
@@ -40,7 +40,6 @@ public class CommandTeleportPlayer extends DDCommandBase
|
|||||||
@Override
|
@Override
|
||||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||||
{
|
{
|
||||||
List<Integer> dimensionIDs = Arrays.asList(DimensionManager.getStaticDimensionIDs()); //Gets list of all registered dimensions, regardless if loaded or not
|
|
||||||
EntityPlayer targetPlayer = sender;
|
EntityPlayer targetPlayer = sender;
|
||||||
int dimDestinationID = sender.worldObj.provider.dimensionId;
|
int dimDestinationID = sender.worldObj.provider.dimensionId;
|
||||||
|
|
||||||
@@ -63,7 +62,7 @@ public class CommandTeleportPlayer extends DDCommandBase
|
|||||||
}
|
}
|
||||||
dimDestinationID=Integer.parseInt(command[1]);//gets the target dim ID from the command string
|
dimDestinationID=Integer.parseInt(command[1]);//gets the target dim ID from the command string
|
||||||
|
|
||||||
if(!dimensionIDs.contains(dimDestinationID))
|
if(!DimensionManager.isDimensionRegistered(dimDestinationID))
|
||||||
{
|
{
|
||||||
return DDCommandResult.INVALID_DIMENSION_ID;
|
return DDCommandResult.INVALID_DIMENSION_ID;
|
||||||
}
|
}
|
||||||
@@ -72,6 +71,55 @@ public class CommandTeleportPlayer extends DDCommandBase
|
|||||||
Point4D destination = new Point4D(Integer.parseInt(command[2]),Integer.parseInt(command[3]),Integer.parseInt(command[4]),dimDestinationID);
|
Point4D destination = new Point4D(Integer.parseInt(command[2]),Integer.parseInt(command[3]),Integer.parseInt(command[4]),dimDestinationID);
|
||||||
DDTeleporter.teleportEntity(targetPlayer, destination, false);
|
DDTeleporter.teleportEntity(targetPlayer, destination, false);
|
||||||
}
|
}
|
||||||
|
else if(command.length == 2 && isInteger(command[1]))
|
||||||
|
{
|
||||||
|
if(sender.worldObj.getPlayerEntityByName(command[0])!=null) //Gets the targeted player
|
||||||
|
{
|
||||||
|
targetPlayer = sender.worldObj.getPlayerEntityByName(command[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return DDCommandResult.INVALID_ARGUMENTS;
|
||||||
|
}
|
||||||
|
dimDestinationID=Integer.parseInt(command[1]);//gets the target dim ID from the command string
|
||||||
|
|
||||||
|
if(!DimensionManager.isDimensionRegistered(dimDestinationID))
|
||||||
|
{
|
||||||
|
return DDCommandResult.INVALID_DIMENSION_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Point4D destination = PocketManager.getDimensionData(dimDestinationID).origin();
|
||||||
|
if(!PocketManager.getDimensionData(dimDestinationID).isPocketDimension())
|
||||||
|
{
|
||||||
|
destination = new Point4D(destination.getX(),PocketManager.loadDimension(dimDestinationID).getTopSolidOrLiquidBlock(
|
||||||
|
destination.getX(), destination.getZ()),
|
||||||
|
destination.getZ(),destination.getDimension());
|
||||||
|
}
|
||||||
|
DDTeleporter.teleportEntity(targetPlayer, destination, false);
|
||||||
|
}
|
||||||
|
else if(command.length == 1 && isInteger(command[0]))
|
||||||
|
{
|
||||||
|
|
||||||
|
targetPlayer = sender;
|
||||||
|
|
||||||
|
dimDestinationID=Integer.parseInt(command[0]);//gets the target dim ID from the command string
|
||||||
|
|
||||||
|
if(!DimensionManager.isDimensionRegistered(dimDestinationID))
|
||||||
|
{
|
||||||
|
return DDCommandResult.INVALID_DIMENSION_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Point4D destination = PocketManager.getDimensionData(dimDestinationID).origin();
|
||||||
|
if(!PocketManager.getDimensionData(dimDestinationID).isPocketDimension())
|
||||||
|
{
|
||||||
|
destination = new Point4D(destination.getX(),PocketManager.loadDimension(dimDestinationID).getTopSolidOrLiquidBlock(
|
||||||
|
destination.getX(), destination.getZ()),
|
||||||
|
destination.getZ(),destination.getDimension());
|
||||||
|
}
|
||||||
|
DDTeleporter.teleportEntity(targetPlayer, destination, false);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return DDCommandResult.INVALID_ARGUMENTS;
|
return DDCommandResult.INVALID_ARGUMENTS;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
|
|||||||
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
||||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
|
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
|
||||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||||
|
import StevenDimDoors.mod_pocketDim.watcher.ClientDimData;
|
||||||
import StevenDimDoors.mod_pocketDim.world.PocketBuilder;
|
import StevenDimDoors.mod_pocketDim.world.PocketBuilder;
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
|
|
||||||
@@ -319,10 +320,10 @@ public class DDTeleporter
|
|||||||
if(player != null) // Are we working with a player?
|
if(player != null) // Are we working with a player?
|
||||||
{
|
{
|
||||||
// We need to do all this special stuff to move a player between dimensions.
|
// We need to do all this special stuff to move a player between dimensions.
|
||||||
|
//Give the client the dimensionData for the destination
|
||||||
|
PocketManager.dimWatcher.onCreated(new ClientDimData(PocketManager.getDimensionData(destination.getDimension())));
|
||||||
|
|
||||||
|
|
||||||
//Register the dim on the client when we teleport to it.
|
|
||||||
Packet250CustomPayload[] pkt = ForgePacket.makePacketSet(new DimensionRegisterPacket(newWorld.provider.dimensionId, DimensionManager.getProviderType(newWorld.provider.dimensionId)));
|
|
||||||
player.playerNetServerHandler.sendPacketToPlayer(pkt[0]);
|
|
||||||
|
|
||||||
// Set the new dimension and inform the client that it's moving to a new world.
|
// Set the new dimension and inform the client that it's moving to a new world.
|
||||||
player.dimension = destination.getDimension();
|
player.dimension = destination.getDimension();
|
||||||
|
|||||||
@@ -198,6 +198,7 @@ public abstract class NewDimData
|
|||||||
this.root = root;
|
this.root = root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DimLink findNearestRift(World world, int range, int x, int y, int z)
|
public DimLink findNearestRift(World world, int range, int x, int y, int z)
|
||||||
{
|
{
|
||||||
//TODO: Rewrite this later to use an octtree
|
//TODO: Rewrite this later to use an octtree
|
||||||
@@ -226,7 +227,7 @@ public abstract class NewDimData
|
|||||||
for (k = -range; k <= range; k++)
|
for (k = -range; k <= range; k++)
|
||||||
{
|
{
|
||||||
distance = getAbsoluteSum(i, j, k);
|
distance = getAbsoluteSum(i, j, k);
|
||||||
if (distance > 1 && distance < minDistance && world.getBlockId(x + i, y + j, z + k) == properties.RiftBlockID)
|
if (distance > 0 && distance < minDistance && world.getBlockId(x + i, y + j, z + k) == properties.RiftBlockID)
|
||||||
{
|
{
|
||||||
link = getLink(x+i, y+j, z+k);
|
link = getLink(x+i, y+j, z+k);
|
||||||
if (link != null)
|
if (link != null)
|
||||||
@@ -242,6 +243,48 @@ public abstract class NewDimData
|
|||||||
return nearest;
|
return nearest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<DimLink> findRiftsInRange(World world, int range, int x, int y, int z)
|
||||||
|
{
|
||||||
|
ArrayList<DimLink> links = new ArrayList<DimLink>();
|
||||||
|
//TODO: Rewrite this later to use an octtree
|
||||||
|
|
||||||
|
//Sanity check...
|
||||||
|
if (world.provider.dimensionId != id)
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("Attempted to search for links in a World instance for a different dimension!");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Note: Only detect rifts at a distance > 1, so we ignore the rift
|
||||||
|
//that called this function and any adjacent rifts.
|
||||||
|
|
||||||
|
DimLink link;
|
||||||
|
|
||||||
|
int distance;
|
||||||
|
int i, j, k;
|
||||||
|
DDProperties properties = DDProperties.instance();
|
||||||
|
|
||||||
|
for (i = -range; i <= range; i++)
|
||||||
|
{
|
||||||
|
for (j = -range; j <= range; j++)
|
||||||
|
{
|
||||||
|
for (k = -range; k <= range; k++)
|
||||||
|
{
|
||||||
|
distance = getAbsoluteSum(i, j, k);
|
||||||
|
if (distance > 0 && world.getBlockId(x + i, y + j, z + k) == properties.RiftBlockID)
|
||||||
|
{
|
||||||
|
link = getLink(x+i, y+j, z+k);
|
||||||
|
if (link != null)
|
||||||
|
{
|
||||||
|
links.add(link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return links;
|
||||||
|
}
|
||||||
|
|
||||||
private static int getAbsoluteSum(int i, int j, int k)
|
private static int getAbsoluteSum(int i, int j, int k)
|
||||||
{
|
{
|
||||||
return Math.abs(i) + Math.abs(j) + Math.abs(k);
|
return Math.abs(i) + Math.abs(j) + Math.abs(k);
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
@@ -213,7 +215,7 @@ public class PocketManager
|
|||||||
*/
|
*/
|
||||||
public static volatile boolean isConnected = false;
|
public static volatile boolean isConnected = false;
|
||||||
public static final UpdateWatcherProxy<ClientLinkData> linkWatcher = new UpdateWatcherProxy<ClientLinkData>();
|
public static final UpdateWatcherProxy<ClientLinkData> linkWatcher = new UpdateWatcherProxy<ClientLinkData>();
|
||||||
private static final UpdateWatcherProxy<ClientDimData> dimWatcher = new UpdateWatcherProxy<ClientDimData>();
|
static final UpdateWatcherProxy<ClientDimData> dimWatcher = new UpdateWatcherProxy<ClientDimData>();
|
||||||
private static ArrayList<NewDimData> rootDimensions = null;
|
private static ArrayList<NewDimData> rootDimensions = null;
|
||||||
|
|
||||||
//HashMap that maps all the dimension IDs registered with DimDoors to their DD data.
|
//HashMap that maps all the dimension IDs registered with DimDoors to their DD data.
|
||||||
@@ -524,6 +526,7 @@ public class PocketManager
|
|||||||
return dimension;
|
return dimension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
private static NewDimData registerClientDimension(int dimensionID, int rootID)
|
private static NewDimData registerClientDimension(int dimensionID, int rootID)
|
||||||
{
|
{
|
||||||
// No need to raise events heres since this code should only run on the client side
|
// No need to raise events heres since this code should only run on the client side
|
||||||
@@ -548,10 +551,13 @@ public class PocketManager
|
|||||||
{
|
{
|
||||||
dimension = root;
|
dimension = root;
|
||||||
}
|
}
|
||||||
if(dimension.isPocketDimension())
|
if(dimension.isPocketDimension()&&!DimensionManager.isDimensionRegistered(dimension.id()))
|
||||||
{
|
{
|
||||||
//Im registering pocket dims here. I *think* we can assume that if its a pocket and we are
|
//Im registering pocket dims here. I *think* we can assume that if its a pocket and we are
|
||||||
//registering its dim data, we also need to register it with forge.
|
//registering its dim data, we also need to register it with forge.
|
||||||
|
|
||||||
|
//New packet stuff prevents this from always being true, unfortuantly. I send the dimdata to the client when they teleport.
|
||||||
|
//Steven
|
||||||
DimensionManager.registerDimension(dimensionID, mod_pocketDim.properties.PocketProviderID);
|
DimensionManager.registerDimension(dimensionID, mod_pocketDim.properties.PocketProviderID);
|
||||||
}
|
}
|
||||||
return dimension;
|
return dimension;
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ package StevenDimDoors.mod_pocketDim.tileentities;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.DataWatcher;
|
import net.minecraft.entity.DataWatcher;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.monster.EntityEnderman;
|
import net.minecraft.entity.monster.EntityEnderman;
|
||||||
@@ -16,6 +18,9 @@ import net.minecraft.network.packet.Packet132TileEntityData;
|
|||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
import net.minecraft.world.World;
|
||||||
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.core.DimLink;
|
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||||
@@ -30,10 +35,8 @@ public class TileEntityRift extends TileEntity
|
|||||||
public int xOffset=0;
|
public int xOffset=0;
|
||||||
public int yOffset=0;
|
public int yOffset=0;
|
||||||
public int zOffset=0;
|
public int zOffset=0;
|
||||||
public int distance=0;
|
|
||||||
public boolean hasGrownRifts=false;
|
public boolean hasGrownRifts=false;
|
||||||
public boolean shouldClose=false;
|
public boolean shouldClose=false;
|
||||||
public boolean isNearRift=false;
|
|
||||||
private int count=200;
|
private int count=200;
|
||||||
private int count2 = 0;
|
private int count2 = 0;
|
||||||
public int age = 0;
|
public int age = 0;
|
||||||
@@ -87,9 +90,9 @@ public class TileEntityRift extends TileEntity
|
|||||||
{
|
{
|
||||||
this.spawnEndermen();
|
this.spawnEndermen();
|
||||||
this.calculateOldParticleOffset(); //this also calculates the distance for the particle stuff.
|
this.calculateOldParticleOffset(); //this also calculates the distance for the particle stuff.
|
||||||
if (distance > 1) //only grow if rifts are nearby
|
if (mod_pocketDim.properties.RiftSpreadEnabled&&!this.hasGrownRifts) //only grow if rifts are nearby
|
||||||
{
|
{
|
||||||
this.grow(distance);
|
this.grow();
|
||||||
}
|
}
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
@@ -165,10 +168,6 @@ public class TileEntityRift extends TileEntity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
this.isNearRift = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeRift()
|
public void closeRift()
|
||||||
@@ -176,22 +175,25 @@ public class TileEntityRift extends TileEntity
|
|||||||
NewDimData dimension = PocketManager.getDimensionData(worldObj);
|
NewDimData dimension = PocketManager.getDimensionData(worldObj);
|
||||||
if (count2 > 20 && count2 < 22)
|
if (count2 > 20 && count2 < 22)
|
||||||
{
|
{
|
||||||
nearestRiftData = dimension.findNearestRift(worldObj, 10, xCoord, yCoord, zCoord);
|
ArrayList<DimLink> rifts= dimension.findRiftsInRange(worldObj, 6, xCoord, yCoord, zCoord);
|
||||||
if (this.nearestRiftData != null)
|
if (rifts.size()>0)
|
||||||
{
|
{
|
||||||
Point4D location = nearestRiftData.source();
|
for(DimLink riftToClose : rifts)
|
||||||
TileEntityRift rift = (TileEntityRift) worldObj.getBlockTileEntity(location.getX(), location.getY(), location.getZ());
|
|
||||||
if (rift != null&&rift.shouldClose!=true)
|
|
||||||
{
|
{
|
||||||
rift.shouldClose = true;
|
Point4D location = riftToClose.source();
|
||||||
rift.onInventoryChanged();
|
TileEntityRift rift = (TileEntityRift) worldObj.getBlockTileEntity(location.getX(), location.getY(), location.getZ());
|
||||||
|
if (rift != null&&rift.shouldClose!=true)
|
||||||
|
{
|
||||||
|
rift.shouldClose = true;
|
||||||
|
rift.onInventoryChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count2 > 40)
|
if (count2 > 40)
|
||||||
{
|
{
|
||||||
this.invalidate();
|
this.invalidate();
|
||||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
|
||||||
if (dimension.getLink(xCoord, yCoord, zCoord) != null)
|
if (dimension.getLink(xCoord, yCoord, zCoord) != null)
|
||||||
{
|
{
|
||||||
if(!this.worldObj.isRemote)
|
if(!this.worldObj.isRemote)
|
||||||
@@ -199,6 +201,7 @@ public class TileEntityRift extends TileEntity
|
|||||||
dimension.deleteLink(xCoord, yCoord, zCoord);
|
dimension.deleteLink(xCoord, yCoord, zCoord);
|
||||||
}
|
}
|
||||||
worldObj.playSound(xCoord, yCoord, zCoord, "mods.DimDoors.sfx.riftClose", (float) .7, 1, true);
|
worldObj.playSound(xCoord, yCoord, zCoord, "mods.DimDoors.sfx.riftClose", (float) .7, 1, true);
|
||||||
|
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
count2++;
|
count2++;
|
||||||
@@ -214,8 +217,7 @@ public class TileEntityRift extends TileEntity
|
|||||||
this.xOffset = this.xCoord - location.getX();
|
this.xOffset = this.xCoord - location.getX();
|
||||||
this.yOffset = this.yCoord - location.getY();
|
this.yOffset = this.yCoord - location.getY();
|
||||||
this.zOffset = this.zCoord - location.getZ();
|
this.zOffset = this.zCoord - location.getZ();
|
||||||
this.distance = Math.abs(xOffset) + Math.abs(yOffset) + Math.abs(zOffset);
|
int distance = Math.abs(xOffset) + Math.abs(yOffset) + Math.abs(zOffset);
|
||||||
this.isNearRift=true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -226,44 +228,6 @@ public class TileEntityRift extends TileEntity
|
|||||||
this.onInventoryChanged();
|
this.onInventoryChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void grow(int distance)
|
|
||||||
{
|
|
||||||
if(worldObj.isRemote)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int growCount=0;
|
|
||||||
if(random.nextInt(distance*2)==0)
|
|
||||||
{
|
|
||||||
int x=0,y=0,z=0;
|
|
||||||
while(growCount<100)
|
|
||||||
{
|
|
||||||
growCount++;
|
|
||||||
x=this.xCoord+(1-(random.nextInt(2)*2)*random.nextInt(6));
|
|
||||||
y=this.yCoord+(1-(random.nextInt(2)*2)*random.nextInt(4));
|
|
||||||
z=this.zCoord+(1-(random.nextInt(2)*2)*random.nextInt(6));
|
|
||||||
if(worldObj.isAirBlock(x, y, z))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if (growCount < 100)
|
|
||||||
{
|
|
||||||
NewDimData dimension = PocketManager.getDimensionData(worldObj);
|
|
||||||
DimLink link = dimension.getLink(xCoord, yCoord, zCoord);
|
|
||||||
if (link != null)
|
|
||||||
{
|
|
||||||
if (!this.hasGrownRifts && random.nextInt(3) == 0)
|
|
||||||
{
|
|
||||||
dimension.createChildLink(x, y, z, link);
|
|
||||||
this.hasGrownRifts = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void calculateNextRenderQuad(float age, Random rand)
|
public void calculateNextRenderQuad(float age, Random rand)
|
||||||
{
|
{
|
||||||
int maxSize = MathHelper.floor_double((Math.log(Math.pow(age+1,2))));
|
int maxSize = MathHelper.floor_double((Math.log(Math.pow(age+1,2))));
|
||||||
@@ -321,6 +285,84 @@ public class TileEntityRift extends TileEntity
|
|||||||
return pass == 1;
|
return pass == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int countParents(DimLink link)
|
||||||
|
{
|
||||||
|
if(link.parent()!=null)
|
||||||
|
{
|
||||||
|
return 1 + countParents(link.parent());
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void grow()
|
||||||
|
{
|
||||||
|
if(worldObj.isRemote||this.hasGrownRifts)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NewDimData dimension = PocketManager.getDimensionData(worldObj);
|
||||||
|
if(dimension.findNearestRift(this.worldObj, 5, xCoord, yCoord, zCoord)==null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int growCount=0;
|
||||||
|
DimLink link = dimension.getLink(xCoord, yCoord, zCoord);
|
||||||
|
|
||||||
|
int x=0,y=0,z=0;
|
||||||
|
while(growCount<100)
|
||||||
|
{
|
||||||
|
growCount++;
|
||||||
|
x=xCoord+(1-(random.nextInt(2)*2)*random.nextInt(6));
|
||||||
|
y=yCoord+(1-(random.nextInt(2)*2)*random.nextInt(4));
|
||||||
|
z=zCoord+(1-(random.nextInt(2)*2)*random.nextInt(6));
|
||||||
|
if(worldObj.isAirBlock(x, y, z))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (growCount < 100)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//look to see if there is a block inbetween the rift and the spread location that should interrupt the spread. With this change,
|
||||||
|
//rifts cannot spread if there are any blocks nearby that are invularble to rift destruction
|
||||||
|
//TODO- make this look for blocks breaking line of sight with the rift
|
||||||
|
if (link != null)
|
||||||
|
{
|
||||||
|
if ((this.countParents(link)<4))
|
||||||
|
{
|
||||||
|
MovingObjectPosition hit = this.worldObj.clip(this.worldObj.getWorldVec3Pool().getVecFromPool(this.xCoord,this.yCoord,this.zCoord), this.worldObj.getWorldVec3Pool().getVecFromPool(x,y,z),false);
|
||||||
|
if(hit!=null)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(mod_pocketDim.blockRift.isBlockImmune(this.worldObj,hit.blockX,hit.blockY,hit.blockZ))
|
||||||
|
{
|
||||||
|
System.out.println(Block.blocksList[this.worldObj.getBlockId(hit.blockX,hit.blockY,hit.blockZ)].getLocalizedName()+" HIT");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
System.out.println(Block.blocksList[this.worldObj.getBlockId(hit.blockX,hit.blockY,hit.blockZ)].getLocalizedName());
|
||||||
|
hit = this.worldObj.clip(this.worldObj.getWorldVec3Pool().getVecFromPool(this.xCoord,this.yCoord,this.zCoord), this.worldObj.getWorldVec3Pool().getVecFromPool(x,y,z),false);
|
||||||
|
System.out.println(Block.blocksList[this.worldObj.getBlockId(hit.blockX,hit.blockY,hit.blockZ)].getLocalizedName());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
dimension.createChildLink(x, y, z, link);
|
||||||
|
this.hasGrownRifts=true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.out.println("allDone");
|
||||||
|
this.hasGrownRifts=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbt)
|
public void readFromNBT(NBTTagCompound nbt)
|
||||||
{
|
{
|
||||||
@@ -367,4 +409,14 @@ public class TileEntityRift extends TileEntity
|
|||||||
{
|
{
|
||||||
readFromNBT(pkt.data);
|
readFromNBT(pkt.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isNearRift()
|
||||||
|
{
|
||||||
|
if(PocketManager.getDimensionData(worldObj).findNearestRift(this.worldObj, 5, xCoord, yCoord, zCoord)==null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import StevenDimDoors.mod_pocketDim.util.Pair;
|
|||||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||||
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
|
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class PocketBuilder
|
public class PocketBuilder
|
||||||
{
|
{
|
||||||
public static final int MIN_POCKET_SIZE = 5;
|
public static final int MIN_POCKET_SIZE = 5;
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ public class PocketGenerator extends ChunkProviderGenerate
|
|||||||
public Chunk provideChunk(int chunkX, int chunkZ)
|
public Chunk provideChunk(int chunkX, int chunkZ)
|
||||||
{
|
{
|
||||||
byte[] var3 = new byte[32768];
|
byte[] var3 = new byte[32768];
|
||||||
|
|
||||||
Chunk chunk = new Chunk(worldObj, var3, chunkX, chunkZ);
|
Chunk chunk = new Chunk(worldObj, var3, chunkX, chunkZ);
|
||||||
|
|
||||||
if(!chunk.isTerrainPopulated)
|
if(!chunk.isTerrainPopulated)
|
||||||
@@ -50,14 +49,13 @@ public class PocketGenerator extends ChunkProviderGenerate
|
|||||||
chunk.isTerrainPopulated = true;
|
chunk.isTerrainPopulated = true;
|
||||||
spawner.registerChunkForPopulation(worldObj.provider.dimensionId, chunkX, chunkZ);
|
spawner.registerChunkForPopulation(worldObj.provider.dimensionId, chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Chunk loadChunk(int var1, int var2)
|
public Chunk loadChunk(int var1, int var2)
|
||||||
{
|
{
|
||||||
return super.loadChunk(var1, var2);
|
return this.provideChunk(var1, var2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user