Merge remote-tracking branch 'upstream/DevBranch' into rewrite
This commit is contained in:
commit
a92cd2fba7
9 changed files with 147 additions and 21 deletions
|
@ -11,6 +11,7 @@ import net.minecraft.client.renderer.texture.IconRegister;
|
|||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemDoor;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
@ -21,6 +22,7 @@ import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
|||
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
@ -392,7 +394,7 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
|
|||
DimLink link = PocketManager.getLink(x, y, z, world.provider.dimensionId);
|
||||
if (link != null)
|
||||
{
|
||||
DDTeleporter.traverseDimDoor(world, link, entity);
|
||||
DDTeleporter.traverseDimDoor(world, link, entity, this);
|
||||
}
|
||||
// Close the door only after the entity goes through
|
||||
// so players don't have it slam in their faces.
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.block.ITileEntityProvider;
|
|||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemDoor;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
@ -16,6 +17,7 @@ import StevenDimDoors.mod_pocketDim.core.DimLink;
|
|||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
|
||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityTransTrapdoor;
|
||||
|
||||
public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntityProvider
|
||||
|
@ -50,7 +52,7 @@ public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntit
|
|||
DimLink link = PocketManager.getLink(x, y, z, world);
|
||||
if (link != null)
|
||||
{
|
||||
DDTeleporter.traverseDimDoor(world, link, entity);
|
||||
DDTeleporter.traverseDimDoor(world, link, entity,this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,6 +100,7 @@ public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntit
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int idDropped(int metadata, Random random, int fortuneLevel)
|
||||
|
@ -109,7 +112,7 @@ public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntit
|
|||
public int getDrops()
|
||||
{
|
||||
return Block.trapdoor.blockID;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isTrapdoorSetLow(int metadata)
|
||||
{
|
||||
|
|
|
@ -4,14 +4,17 @@ import net.minecraft.block.material.Material;
|
|||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.item.ItemDoor;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
|
||||
|
||||
public class TransientDoor extends BaseDimDoor
|
||||
{
|
||||
|
@ -45,7 +48,7 @@ public class TransientDoor extends BaseDimDoor
|
|||
DimLink link = PocketManager.getLink(x, y, z, world.provider.dimensionId);
|
||||
if (link != null)
|
||||
{
|
||||
DDTeleporter.traverseDimDoor(world, link, entity);
|
||||
DDTeleporter.traverseDimDoor(world, link, entity, this);
|
||||
// Turn the door into a rift AFTER teleporting the player.
|
||||
// The door's orientation may be necessary for the teleport.
|
||||
world.setBlock(x, y, z, properties.RiftBlockID);
|
||||
|
@ -96,4 +99,5 @@ public class TransientDoor extends BaseDimDoor
|
|||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
}
|
5
StevenDimDoors/mod_pocketDim/commands/IItemDimDoor.java
Normal file
5
StevenDimDoors/mod_pocketDim/commands/IItemDimDoor.java
Normal file
|
@ -0,0 +1,5 @@
|
|||
package StevenDimDoors.mod_pocketDim.commands;
|
||||
|
||||
public interface IItemDimDoor {
|
||||
|
||||
}
|
|
@ -3,11 +3,13 @@ package StevenDimDoors.mod_pocketDim.core;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.item.EntityMinecart;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemDoor;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet41EntityEffect;
|
||||
import net.minecraft.network.packet.Packet43Experience;
|
||||
|
@ -20,7 +22,9 @@ import net.minecraftforge.common.DimensionManager;
|
|||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.IDimDoor;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
@ -39,6 +43,67 @@ public class DDTeleporter
|
|||
|
||||
private DDTeleporter() { }
|
||||
|
||||
/**Checks if the destination supplied is valid, ie, filled by any non-replaceable block.
|
||||
*
|
||||
* @param entity
|
||||
* @param world
|
||||
* @param destination
|
||||
* @param properties
|
||||
* @return
|
||||
*/
|
||||
public static boolean CheckDestination(Entity entity, WorldServer world, Point4D destination,DDProperties properties)
|
||||
{
|
||||
int x = destination.getX();
|
||||
int y = destination.getY();
|
||||
int z = destination.getZ();
|
||||
int blockIDTop;
|
||||
int blockIDBottom;
|
||||
|
||||
Point3D point;
|
||||
|
||||
int orientation;
|
||||
|
||||
orientation = getDestinationOrientation(destination, properties);
|
||||
entity.rotationYaw = (orientation * 90) + 90;
|
||||
switch (orientation)
|
||||
{
|
||||
case 0:
|
||||
point= new Point3D(MathHelper.floor_double(x - 0.5), y - 1, MathHelper.floor_double(z + 0.5));
|
||||
break;
|
||||
case 1:
|
||||
point= new Point3D(MathHelper.floor_double(x + 0.5), y - 1, MathHelper.floor_double(z - 0.5));
|
||||
break;
|
||||
case 2:
|
||||
point = new Point3D(MathHelper.floor_double(x + 1.5), y - 1, MathHelper.floor_double(z + 0.5));
|
||||
break;
|
||||
case 3:
|
||||
point = new Point3D(MathHelper.floor_double(x + 0.5), y - 1, MathHelper.floor_double(z + 1.5));
|
||||
break;
|
||||
default:
|
||||
point = new Point3D(x, y - 1, z);
|
||||
break;
|
||||
}
|
||||
blockIDBottom = world.getBlockId(point.getX(), point.getY(), point.getZ());
|
||||
blockIDTop = world.getBlockId(point.getX(), point.getY()+1, point.getZ());
|
||||
|
||||
if(!(Block.blocksList[blockIDBottom]==null))
|
||||
{
|
||||
if(!Block.blocksList[blockIDBottom].isBlockReplaceable(world, point.getX(), point.getY(), point.getZ()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(!(Block.blocksList[blockIDTop]==null))
|
||||
{
|
||||
if(!Block.blocksList[blockIDTop].isBlockReplaceable(world, point.getX(), point.getY()+1, point.getZ()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
private static void placeInPortal(Entity entity, WorldServer world, Point4D destination, DDProperties properties, boolean checkOrientation)
|
||||
{
|
||||
int x = destination.getX();
|
||||
|
@ -57,6 +122,37 @@ public class DDTeleporter
|
|||
orientation = -1;
|
||||
}
|
||||
|
||||
if(!CheckDestination(entity, world, destination, properties))
|
||||
{
|
||||
|
||||
//TODO Give entity backwards acceleration
|
||||
if(entity instanceof EntityPlayerMP)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
player.rotationYaw=(orientation * 90)+90;
|
||||
switch (orientation)
|
||||
{
|
||||
case 0:
|
||||
player.setPositionAndUpdate(x + 0.5, y - 1, z + 0.5);
|
||||
break;
|
||||
case 1:
|
||||
player.setPositionAndUpdate(x + 0.5, y - 1, z + 0.5);
|
||||
break;
|
||||
case 2:
|
||||
player.setPositionAndUpdate(x + 0.5, y - 1, z + 0.5);
|
||||
break;
|
||||
case 3:
|
||||
player.setPositionAndUpdate(x + 0.5, y - 1, z + .5);
|
||||
break;
|
||||
default:
|
||||
player.setPositionAndUpdate(x, y - 1, z);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (entity instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
|
@ -210,6 +306,7 @@ public class DDTeleporter
|
|||
{
|
||||
newWorld = (WorldServer) oldWorld;
|
||||
}
|
||||
|
||||
|
||||
// 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.
|
||||
|
@ -319,7 +416,7 @@ public class DDTeleporter
|
|||
* @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, DimLink link, Entity entity)
|
||||
public static void traverseDimDoor(World world, DimLink link, Entity entity, Block door)
|
||||
{
|
||||
if (world == null)
|
||||
{
|
||||
|
@ -347,7 +444,7 @@ public class DDTeleporter
|
|||
return;
|
||||
}
|
||||
|
||||
if (!initializeDestination(link, DDProperties.instance()))
|
||||
if (!initializeDestination(link, DDProperties.instance(),door))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -368,7 +465,7 @@ public class DDTeleporter
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean initializeDestination(DimLink link, DDProperties properties)
|
||||
private static boolean initializeDestination(DimLink link, DDProperties properties, Block door)
|
||||
{
|
||||
// FIXME: Change this later to support rooms that have been wiped and must be regenerated.
|
||||
// FIXME: Add code for restoring the destination-side door.
|
||||
|
@ -385,7 +482,7 @@ public class DDTeleporter
|
|||
case LinkTypes.DUNGEON:
|
||||
return PocketBuilder.generateNewDungeonPocket(link, properties);
|
||||
case LinkTypes.POCKET:
|
||||
return PocketBuilder.generateNewPocket(link, properties);
|
||||
return PocketBuilder.generateNewPocket(link, properties,door);
|
||||
case LinkTypes.SAFE_EXIT:
|
||||
return generateSafeExit(link, properties);
|
||||
case LinkTypes.DUNGEON_EXIT:
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package StevenDimDoors.mod_pocketDim.dungeon;
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
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;
|
||||
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
|
||||
|
||||
public class ItemGoldDimDoor extends BaseItemDoor
|
||||
{
|
||||
|
@ -16,6 +16,7 @@ public class ItemGoldDimDoor extends BaseItemDoor
|
|||
super(itemID, material);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
|
@ -1,4 +1,4 @@
|
|||
package StevenDimDoors.mod_pocketDim.dungeon;
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import net.minecraft.block.Block;
|
|
@ -25,12 +25,12 @@ import StevenDimDoors.mod_pocketDim.blocks.TransientDoor;
|
|||
import StevenDimDoors.mod_pocketDim.blocks.UnstableDoor;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.WarpDoor;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.ItemGoldDimDoor;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.ItemGoldDoor;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.ChunkLoaderHelper;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemBlockDimWall;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemGoldDimDoor;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemGoldDoor;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemRiftBlade;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemRiftSignature;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemStabilizedRiftSignature;
|
||||
|
|
|
@ -3,6 +3,7 @@ package StevenDimDoors.mod_pocketDim.world;
|
|||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemDoor;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
@ -10,7 +11,8 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
|||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.DimensionalDoor;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.IDimDoor;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
|
@ -20,10 +22,11 @@ import StevenDimDoors.mod_pocketDim.dungeon.DungeonSchematic;
|
|||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPackConfig;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
||||
import StevenDimDoors.mod_pocketDim.util.Pair;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
|
||||
|
||||
public class PocketBuilder
|
||||
{
|
||||
|
@ -208,9 +211,9 @@ public class PocketBuilder
|
|||
schematic.getLength() <= DungeonHelper.MAX_DUNGEON_LENGTH);
|
||||
}
|
||||
|
||||
public static boolean generateNewPocket(DimLink link, DDProperties properties)
|
||||
public static boolean generateNewPocket(DimLink link, DDProperties properties, Block door)
|
||||
{
|
||||
return generateNewPocket(link, DEFAULT_POCKET_SIZE, DEFAULT_POCKET_WALL_THICKNESS, properties);
|
||||
return generateNewPocket(link, DEFAULT_POCKET_SIZE, DEFAULT_POCKET_WALL_THICKNESS, properties, door);
|
||||
}
|
||||
|
||||
private static int getDoorOrientation(Point4D source, DDProperties properties)
|
||||
|
@ -235,7 +238,7 @@ public class PocketBuilder
|
|||
return orientation;
|
||||
}
|
||||
|
||||
public static boolean generateNewPocket(DimLink link, int size, int wallThickness, DDProperties properties)
|
||||
public static boolean generateNewPocket(DimLink link, int size, int wallThickness, DDProperties properties, Block door)
|
||||
{
|
||||
if (link == null)
|
||||
{
|
||||
|
@ -250,6 +253,12 @@ public class PocketBuilder
|
|||
throw new IllegalArgumentException("link cannot have a destination assigned already.");
|
||||
}
|
||||
|
||||
if(door==null)
|
||||
{
|
||||
throw new IllegalArgumentException("Must have a doorItem to gen one!!");
|
||||
|
||||
}
|
||||
|
||||
if (size < MIN_POCKET_SIZE || size > MAX_POCKET_SIZE)
|
||||
{
|
||||
throw new IllegalArgumentException("size must be between " + MIN_POCKET_SIZE + " and " + MAX_POCKET_SIZE + ", inclusive.");
|
||||
|
@ -292,7 +301,7 @@ public class PocketBuilder
|
|||
parent.setDestination(reverseLink, source.getX(), source.getY(), source.getZ());
|
||||
|
||||
//Build the actual pocket area
|
||||
buildPocket(world, source.getX(), destinationY, source.getZ(), orientation, size, wallThickness, properties);
|
||||
buildPocket(world, source.getX(), destinationY, source.getZ(), orientation, size, wallThickness, properties, door);
|
||||
|
||||
//Finish up destination initialization
|
||||
dimension.initializePocket(source.getX(), destinationY, source.getZ(), orientation, link);
|
||||
|
@ -306,7 +315,7 @@ public class PocketBuilder
|
|||
}
|
||||
}
|
||||
|
||||
private static void buildPocket(World world, int x, int y, int z, int orientation, int size, int wallThickness, DDProperties properties)
|
||||
private static void buildPocket(World world, int x, int y, int z, int orientation, int size, int wallThickness, DDProperties properties, Block doorBlock)
|
||||
{
|
||||
if (properties == null)
|
||||
{
|
||||
|
@ -328,6 +337,11 @@ public class PocketBuilder
|
|||
{
|
||||
throw new IllegalArgumentException("size must be large enough to fit the specified wall thickness and some air space.");
|
||||
}
|
||||
if (!(doorBlock instanceof IDimDoor))
|
||||
{
|
||||
throw new IllegalArgumentException("Door must implement IDimDoor");
|
||||
}
|
||||
|
||||
|
||||
Point3D center = new Point3D(x - wallThickness + 1 + (size / 2), y - wallThickness - 1 + (size / 2), z);
|
||||
Point3D door = new Point3D(x, y, z);
|
||||
|
@ -345,7 +359,7 @@ public class PocketBuilder
|
|||
|
||||
//Build the door
|
||||
int doorOrientation = BlockRotator.transformMetadata(BlockRotator.EAST_DOOR_METADATA, orientation - BlockRotator.EAST_DOOR_METADATA + 2, properties.DimensionalDoorID);
|
||||
ItemDimensionalDoor.placeDoorBlock(world, x, y - 1, z, doorOrientation, mod_pocketDim.dimensionalDoor);
|
||||
ItemDimensionalDoor.placeDoorBlock(world, x, y - 1, z, doorOrientation, doorBlock);
|
||||
}
|
||||
|
||||
private static void buildBox(World world, int centerX, int centerY, int centerZ, int radius, int blockID, boolean placeTnt, int nonTntWeight)
|
||||
|
|
Loading…
Reference in a new issue