THE UPDATE
Merging months of dev work into master. The update is playable, but untested.
This commit is contained in:
429
StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java
Normal file
429
StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java
Normal file
@@ -0,0 +1,429 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
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;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
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.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;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEntityProvider
|
||||
{
|
||||
protected final DDProperties properties;
|
||||
private Icon blockIconBottom;
|
||||
|
||||
public BaseDimDoor(int blockID, Material material, DDProperties properties)
|
||||
{
|
||||
super(blockID, material);
|
||||
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
this.enterDimDoor(world, x, y, z, entity);
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
|
||||
boolean shouldOpen=true;
|
||||
|
||||
//System.out.println(String.valueOf(par1World.getBlockMetadata(par2, par3, par4)));
|
||||
if(player.inventory.getCurrentItem()!=null)
|
||||
{
|
||||
if(player.inventory.getCurrentItem().getItem() == mod_pocketDim.itemRiftBlade)
|
||||
{
|
||||
shouldOpen = false;
|
||||
if (!world.isRemote && world.getBlockId(x, y-1, z) == this.blockID)
|
||||
{
|
||||
int var12 = (int) (MathHelper.floor_double((double)((player.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
|
||||
|
||||
if (world.getBlockMetadata(x, y-1, z) == var12)
|
||||
{
|
||||
var12 = BlockRotator.transformMetadata(var12, 1, this.blockID);
|
||||
}
|
||||
world.setBlockMetadataWithNotify(x, y-1, z, var12, 2);
|
||||
}
|
||||
if (!world.isRemote && world.getBlockId(x, y+1, z) == this.blockID)
|
||||
{
|
||||
int var12 = (int) (MathHelper.floor_double((double)((player.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
|
||||
if(world.getBlockMetadata(x, y, z)==var12)
|
||||
{
|
||||
var12 = BlockRotator.transformMetadata(var12, 1, this.blockID);
|
||||
}
|
||||
world.setBlockMetadataWithNotify(x, y, z, var12, 2);
|
||||
}
|
||||
world.playAuxSFXAtEntity(player, 1001, x, y, z, 0);
|
||||
|
||||
if (!shouldOpen && !world.isRemote)
|
||||
{
|
||||
player.inventory.getCurrentItem().damageItem(5, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(shouldOpen)
|
||||
{
|
||||
int var10 = this.getFullMetadata(world, x, y, z);
|
||||
int var11 = var10 & 7;
|
||||
var11 ^= 4;
|
||||
|
||||
if ((var10 & 8) == 0)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, var11,2);
|
||||
world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y - 1, z, var11,2);
|
||||
world.markBlockRangeForRenderUpdate(x, y - 1, z, x, y, z);
|
||||
}
|
||||
|
||||
world.playAuxSFXAtEntity(player, 1003, x, y, z, 0);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z)
|
||||
{
|
||||
//FIXME: We need to set door generation flags on the tile entities. Ignoring that for now. ~SenseiKiwi
|
||||
|
||||
this.placeLink(world, x, y, z);
|
||||
world.setBlockTileEntity(x, y, z, this.createNewTileEntity(world));
|
||||
this.updateAttachedTile(world, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
if(par1IBlockAccess.getBlockId(par2, par3-1, par4) == this.blockID)
|
||||
{
|
||||
return this.blockIcon;
|
||||
}
|
||||
else
|
||||
{
|
||||
return blockIconBottom;
|
||||
}
|
||||
}
|
||||
|
||||
//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 BaseDimDoor updateAttachedTile(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
if (tile instanceof TileEntityDimDoor)
|
||||
{
|
||||
TileEntityDimDoor dimTile = (TileEntityDimDoor) tile;
|
||||
dimTile.openOrClosed = PocketManager.getLink(x, y, z, world.provider.dimensionId) != null;
|
||||
dimTile.orientation = this.getFullMetadata(world, x, y, z) & 7;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
TileEntityDimDoor tile = (TileEntityDimDoor) par1World.getBlockTileEntity(par2, par3, par4);
|
||||
tile.openOrClosed = this.isDoorOpen( par1World, par2, par3, par4);
|
||||
tile.orientation = this.getFullMetadata(par1World, par2, par3, par4) & 7;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
this.setDoorRotation(this.getFullMetadata(par1IBlockAccess, par2, par3, par4));
|
||||
}
|
||||
|
||||
|
||||
public void setDoorRotation(int par1)
|
||||
{
|
||||
float var2 = 0.1875F;
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F);
|
||||
int var3 = par1 & 3;
|
||||
boolean var4 = (par1 & 4) != 0;
|
||||
boolean var5 = (par1 & 16) != 0;
|
||||
|
||||
if (var3 == 0)
|
||||
{
|
||||
if (var4)
|
||||
{
|
||||
if (!var5)
|
||||
{
|
||||
this.setBlockBounds(0.001F, 0.0F, 0.0F, 1.0F, 1.0F, var2);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.001F, 0.0F, 1.0F - var2, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, var2, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else if (var3 == 1)
|
||||
{
|
||||
if (var4)
|
||||
{
|
||||
if (!var5)
|
||||
{
|
||||
this.setBlockBounds(1.0F - var2, 0.0F, 0.001F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.001F, var2, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, var2);
|
||||
}
|
||||
}
|
||||
else if (var3 == 2)
|
||||
{
|
||||
if (var4)
|
||||
{
|
||||
if (!var5)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 1.0F - var2, .99F, 1.0F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, .99F, 1.0F, var2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(1.0F - var2, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else if (var3 == 3)
|
||||
{
|
||||
if (var4)
|
||||
{
|
||||
if (!var5)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, var2, 1.0F, 0.99F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(1.0F - var2, 0.0F, 0.0F, 1.0F, 1.0F, 0.99F);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 1.0F - var2, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
@Override
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if ((var6 & 8) == 0)
|
||||
{
|
||||
boolean var7 = false;
|
||||
|
||||
if (par1World.getBlockId(par2, par3 + 1, par4) != this.blockID)
|
||||
{
|
||||
par1World.setBlock(par2, par3, par4, 0);
|
||||
var7 = true;
|
||||
}
|
||||
|
||||
/**
|
||||
if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4))
|
||||
{
|
||||
par1World.setBlockWithNotify(par2, par3, par4, 0);
|
||||
var7 = true;
|
||||
|
||||
if (par1World.getBlockId(par2, par3 + 1, par4) == this.blockID)
|
||||
{
|
||||
par1World.setBlockWithNotify(par2, par3 + 1, par4, 0);
|
||||
}
|
||||
}
|
||||
**/
|
||||
|
||||
if (var7)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, properties.DimensionalDoorID, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean var8 = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4) || par1World.isBlockIndirectlyGettingPowered(par2, par3 + 1, par4);
|
||||
|
||||
if ((var8 || par5 > 0 && Block.blocksList[par5].canProvidePower()) && par5 != this.blockID)
|
||||
{
|
||||
this.onPoweredBlockChange(par1World, par2, par3, par4, var8);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (par1World.getBlockId(par2, par3 - 1, par4) != this.blockID)
|
||||
{
|
||||
par1World.setBlock(par2, par3, par4, 0);
|
||||
}
|
||||
|
||||
if (par5 > 0 && par5 != this.blockID)
|
||||
{
|
||||
this.onNeighborBlockChange(par1World, par2, par3 - 1, par4, par5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
|
||||
*/
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return this.getDrops();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return (par1 & 8) != 0 ? 0 : (getDrops());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is attempted to be harvested
|
||||
*/
|
||||
@Override
|
||||
public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer)
|
||||
{
|
||||
if (par6EntityPlayer.capabilities.isCreativeMode && (par5 & 8) != 0 && par1World.getBlockId(par2, par3 - 1, par4) == this.blockID)
|
||||
{
|
||||
par1World.setBlock(par2, par3 - 1, par4, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
return new TileEntityDimDoor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterDimDoor(World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
// FX entities dont exist on the server
|
||||
if (world.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that this is the top block of the door
|
||||
if (world.getBlockId(x, y - 1, z) == this.blockID)
|
||||
{
|
||||
int metadata = world.getBlockMetadata(x, y - 1, z);
|
||||
boolean canUse = isDoorOpen(metadata);
|
||||
if (canUse && entity instanceof EntityPlayer)
|
||||
{
|
||||
// Dont check for non-player entites
|
||||
canUse = isEntityFacingDoor(metadata, (EntityLiving) entity);
|
||||
}
|
||||
if (canUse)
|
||||
{
|
||||
// Teleport the entity through the link, if it exists
|
||||
DimLink link = PocketManager.getLink(x, y, z, world.provider.dimensionId);
|
||||
if (link != null)
|
||||
{
|
||||
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.
|
||||
this.onPoweredBlockChange(world, x, y, z, false);
|
||||
}
|
||||
}
|
||||
else if (world.getBlockId(x, y + 1, z) == this.blockID)
|
||||
{
|
||||
enterDimDoor(world, x, y + 1, z, entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDrops()
|
||||
{
|
||||
return this.blockID;
|
||||
}
|
||||
|
||||
protected static boolean isDoorOpen(int metadata)
|
||||
{
|
||||
return (metadata & 4) != 0;
|
||||
}
|
||||
|
||||
protected static boolean isEntityFacingDoor(int metadata, EntityLiving entity)
|
||||
{
|
||||
// Although any entity has the proper fields for this check,
|
||||
// we should only apply it to living entities since things
|
||||
// like Minecarts might come in backwards.
|
||||
int direction = (int) (MathHelper.floor_double((double) ((entity.rotationYaw + 90) * 4.0F / 360.0F) + 0.5D) & 3);
|
||||
return ((metadata & 3) == direction);
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,6 @@ package StevenDimDoors.mod_pocketDim.blocks;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -20,6 +15,9 @@ import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockDimWall extends Block
|
||||
{
|
||||
@@ -69,14 +67,7 @@ public class BlockDimWall extends Block
|
||||
@Override
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
if (par2 == 1)
|
||||
{
|
||||
return blockIcon[par2];
|
||||
}
|
||||
else
|
||||
{
|
||||
return blockIcon[0];
|
||||
}
|
||||
return (par2 != 1) ? blockIcon[0] : blockIcon[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,8 +110,13 @@ public class BlockDimWall extends Block
|
||||
|
||||
if (playerEquip instanceof ItemBlock)
|
||||
{
|
||||
Block block = Block.blocksList[playerEquip.itemID];
|
||||
if (!Block.isNormalCube(playerEquip.itemID) || block instanceof BlockContainer || block.blockID == this.blockID)
|
||||
// SenseiKiwi: Using getBlockID() rather than the raw itemID is critical.
|
||||
// Some mods may override that function and use item IDs outside the range
|
||||
// of the block list.
|
||||
|
||||
int blockID = ((ItemBlock) playerEquip).getBlockID();
|
||||
Block block = Block.blocksList[blockID];
|
||||
if (!Block.isNormalCube(blockID) || block instanceof BlockContainer || blockID == this.blockID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -8,18 +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.minecraft.world.WorldServer;
|
||||
import StevenDimDoors.mod_pocketDim.BlankTeleporter;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
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)
|
||||
@@ -45,97 +45,51 @@ 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 par5Entity)
|
||||
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();
|
||||
|
||||
LinkData link=dimHelper.instance.getRandomLinkData(false);
|
||||
if(link==null)
|
||||
World overworld = DimensionManager.getWorld(0);
|
||||
if (overworld != null && entity instanceof EntityPlayerMP)
|
||||
{
|
||||
link =new LinkData(0,0,0,0);
|
||||
}
|
||||
link.destDimID = 0;
|
||||
link.locDimID = par1World.provider.dimensionId;
|
||||
|
||||
|
||||
if(dimHelper.getWorld(0)==null)
|
||||
{
|
||||
dimHelper.initDimension(0);
|
||||
}
|
||||
|
||||
|
||||
if(dimHelper.getWorld(0)!=null&&par5Entity instanceof EntityPlayerMP)
|
||||
{
|
||||
par5Entity.fallDistance=0;
|
||||
int x = (link.destXCoord + rand.nextInt(properties.LimboReturnRange)-properties.LimboReturnRange/2);
|
||||
int z = (link.destZCoord + rand.nextInt(properties.LimboReturnRange)-properties.LimboReturnRange/2);
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
player.fallDistance = 0;
|
||||
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);
|
||||
|
||||
EntityPlayer.class.cast(par5Entity).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;
|
||||
dimHelper.instance.teleportEntity(par1World, par5Entity, link);
|
||||
//FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().transferPlayerToDimension((EntityPlayerMP) par5Entity, 0,new BlankTeleporter((WorldServer)par5Entity.worldObj));
|
||||
//dimHelper.instance.teleportToPocket(par1World, new LinkData(par1World.provider.dimensionId,0,x,y,z,link.locXCoord,link.locYCoord,link.locZCoord,link.isLocPocket,0),
|
||||
// EntityPlayer.class.cast(par5Entity));
|
||||
|
||||
|
||||
EntityPlayer.class.cast(par5Entity).setPositionAndUpdate( x, y, z );
|
||||
//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, false);
|
||||
|
||||
//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...
|
||||
dimHelper.getWorld(0).setBlock(x, y, z, 0);
|
||||
dimHelper.getWorld(0).setBlock(x, y+1, z, 0);
|
||||
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)
|
||||
{
|
||||
dimHelper.getWorld(0).setBlock(i+xc, j-1+yc, k+zc, properties.LimboBlockID);
|
||||
}
|
||||
else if(Math.abs(xc)+Math.abs(zc)<rand.nextInt(3)+3)
|
||||
|
||||
{
|
||||
dimHelper.getWorld(0).setBlock(i+xc, j-1+yc, k+zc, properties.LimboBlockID,2,0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
overworld.setBlock(destinationX + xc, destinationY - 1, destinationZ + zc, properties.LimboBlockID);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
{
|
||||
EntityPlayer.class.cast(par5Entity).setPositionAndUpdate( x, y, z );
|
||||
EntityPlayer.class.cast(par5Entity).fallDistance=0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//FIXME: Why do we do this repeatedly? We also set the fall distance at the start...
|
||||
player.setPositionAndUpdate( destinationX, destinationY, destinationZ );
|
||||
player.fallDistance = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
49
StevenDimDoors/mod_pocketDim/blocks/BlockDoorGold.java
Normal file
49
StevenDimDoors/mod_pocketDim/blocks/BlockDoorGold.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class BlockDoorGold extends BlockDoor
|
||||
{
|
||||
|
||||
private Icon blockIconBottom;
|
||||
private DDProperties properties;
|
||||
|
||||
public BlockDoorGold(int par1, Material par2Material,DDProperties properties)
|
||||
{
|
||||
super(par1, par2Material);
|
||||
this.properties=properties;
|
||||
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
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 blockIconBottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
50
StevenDimDoors/mod_pocketDim/blocks/BlockGoldDimDoor.java
Normal file
50
StevenDimDoors/mod_pocketDim/blocks/BlockGoldDimDoor.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
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.tileentities.TileEntityDimDoor;
|
||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoorGold;
|
||||
|
||||
public class BlockGoldDimDoor extends BaseDimDoor implements IDimDoor
|
||||
{
|
||||
|
||||
public BlockGoldDimDoor(int blockID, Material material,
|
||||
DDProperties properties) {
|
||||
super(blockID, material, properties);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeLink(World world, int x, int y, int z)
|
||||
{
|
||||
if (!world.isRemote && world.getBlockId(x, y - 1, z) == this.blockID)
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = dimension.getLink(x, y, z);
|
||||
if (link == null)
|
||||
{
|
||||
dimension.createLink(x, y, z, LinkTypes.POCKET,world.getBlockMetadata(x, y - 1, z));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public int getDrops()
|
||||
{
|
||||
return this.properties.GoldDoorItemID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
return new TileEntityDimDoorGold();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,8 +8,8 @@ import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.LimboDecay;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.LimboDecay;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
@@ -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.helpers.dimHelper;
|
||||
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;
|
||||
@@ -37,7 +37,7 @@ public class BlockRift extends BlockContainer
|
||||
private static final int BLOCK_DESTRUCTION_CHANCE = 50;
|
||||
|
||||
private final DDProperties properties;
|
||||
private static ArrayList<Integer> blocksImmuneToRift;
|
||||
private final ArrayList<Integer> blocksImmuneToRift;
|
||||
|
||||
public BlockRift(int i, int j, Material par2Material, DDProperties properties)
|
||||
{
|
||||
@@ -53,6 +53,9 @@ public class BlockRift extends BlockContainer
|
||||
this.blocksImmuneToRift.add(properties.UnstableDoorID);
|
||||
this.blocksImmuneToRift.add(properties.RiftBlockID);
|
||||
this.blocksImmuneToRift.add(properties.TransientDoorID);
|
||||
this.blocksImmuneToRift.add(properties.GoldDimDoorID);
|
||||
this.blocksImmuneToRift.add(properties.GoldDoorID);
|
||||
|
||||
this.blocksImmuneToRift.add(Block.blockIron.blockID);
|
||||
this.blocksImmuneToRift.add(Block.blockDiamond.blockID);
|
||||
this.blocksImmuneToRift.add(Block.blockEmerald.blockID);
|
||||
@@ -154,7 +157,7 @@ public class BlockRift extends BlockContainer
|
||||
public void updateTick(World world, int x, int y, int z, Random random)
|
||||
{
|
||||
if (properties.RiftGriefingEnabled && !world.isRemote &&
|
||||
dimHelper.instance.getLinkDataFromCoords(x, y, z, world.provider.dimensionId) != null)
|
||||
PocketManager.getLink(x, y, z, world.provider.dimensionId) != null)
|
||||
{
|
||||
//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.
|
||||
@@ -335,7 +338,8 @@ public class BlockRift extends BlockContainer
|
||||
}
|
||||
}
|
||||
}
|
||||
public static boolean isBlockImmune(World world, int x, int y, int z)
|
||||
|
||||
public boolean isBlockImmune(World world, int x, int y, int z)
|
||||
{
|
||||
Block block = Block.blocksList[world.getBlockId(x, y, z)];
|
||||
if (block != null)
|
||||
|
||||
@@ -1,146 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
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.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ChaosDoor extends dimDoor
|
||||
{
|
||||
private Icon blockIconBottom;
|
||||
private static DDProperties properties = null;
|
||||
|
||||
public ChaosDoor(int par1, Material material)
|
||||
{
|
||||
super(par1, Material.iron);
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if(!par1World.isRemote&&par1World.getBlockId(par2, par3-1, par4)==this.blockID)
|
||||
{
|
||||
boolean newDim=false;
|
||||
|
||||
if(dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World)==null)
|
||||
{
|
||||
newDim=true;
|
||||
}
|
||||
|
||||
if(newDim)
|
||||
{
|
||||
LinkData link = new LinkData(par1World.provider.dimensionId, properties.LimboDimensionID, par2, par3, par4, par2, par3+500, par4, false,0);
|
||||
link.linkOrientation= par1World.getBlockMetadata(par2, par3-1, par4);
|
||||
dimHelper.instance.createLink(link);
|
||||
// System.out.println(link.linkOrientation);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World)!=null)
|
||||
{
|
||||
dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World).linkOrientation=par1World.getBlockMetadata(par2, par3-1, par4);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//uses the rift rendering list to find a random destination for the player
|
||||
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
{
|
||||
|
||||
int var12 = (int) (MathHelper.floor_double((double)((par5Entity.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
|
||||
|
||||
int num = par1World.getBlockMetadata(par2, par3-1, par4);
|
||||
if(!par1World.isRemote&&(num==5||num==4||num==6||num==7)&&(num-4)==var12&&par1World.getBlockId(par2, par3-1, par4)==properties.UnstableDoorID)
|
||||
{
|
||||
this.onPoweredBlockChange(par1World, par2, par3, par4, false);
|
||||
|
||||
boolean foundRandomDest=false;
|
||||
|
||||
int i=0;
|
||||
|
||||
|
||||
Random rand= new Random();
|
||||
|
||||
while (!foundRandomDest&&i<100)
|
||||
{
|
||||
i++;
|
||||
|
||||
LinkData link = (LinkData) dimHelper.instance.getRandomLinkData(false);
|
||||
|
||||
if(link!=null)
|
||||
{
|
||||
|
||||
if(!link.isLocPocket&&link.linkOrientation!=-10&&link.destDimID!=properties.LimboDimensionID)
|
||||
{
|
||||
foundRandomDest=true;
|
||||
|
||||
dimHelper.instance.traverseDimDoor(par1World, new LinkData(link.destDimID,link.locDimID,link.destXCoord,link.destYCoord,link.destZCoord,link.locXCoord,link.locYCoord,link.locZCoord,link.isLocPocket,0), par5Entity);
|
||||
|
||||
if(dimHelper.getWorld(link.locDimID)!=null)
|
||||
{
|
||||
if(dimHelper.getWorld(link.locDimID).isAirBlock(link.locXCoord,link.locYCoord,link.locZCoord))
|
||||
{
|
||||
dimHelper.getWorld(link.locDimID).setBlock(link.locXCoord,link.locYCoord,link.locZCoord, properties.RiftBlockID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
39
StevenDimDoors/mod_pocketDim/blocks/DimensionalDoor.java
Normal file
39
StevenDimDoors/mod_pocketDim/blocks/DimensionalDoor.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class DimensionalDoor extends BaseDimDoor
|
||||
{
|
||||
|
||||
public DimensionalDoor(int blockID, Material material, DDProperties properties)
|
||||
{
|
||||
super(blockID, material, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeLink(World world, int x, int y, int z)
|
||||
{
|
||||
if (!world.isRemote && world.getBlockId(x, y - 1, z) == this.blockID)
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = dimension.getLink(x, y, z);
|
||||
if (link == null)
|
||||
{
|
||||
dimension.createLink(x, y, z, LinkTypes.POCKET,world.getBlockMetadata(x, y - 1, z));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public int getDrops()
|
||||
{
|
||||
return Item.doorIron.itemID;
|
||||
}
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
|
||||
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.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 ExitDoor extends dimDoor
|
||||
{
|
||||
|
||||
private Icon blockIconBottom;
|
||||
public ExitDoor(int par1, Material par2Material)
|
||||
{
|
||||
|
||||
super(par1, Material.wood);
|
||||
|
||||
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
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");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
|
||||
|
||||
if(!par1World.isRemote&&par1World.getBlockId(par2, par3-1, par4)==this.blockID)
|
||||
{
|
||||
|
||||
|
||||
int locDimID=par1World.provider.dimensionId;
|
||||
|
||||
if(dimHelper.instance.dimList.containsKey(locDimID)&&dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World)==null)
|
||||
{
|
||||
DimData dimData = dimHelper.instance.getDimData(locDimID);
|
||||
int ExitDimID = dimData.exitDimLink.destDimID;
|
||||
if(dimHelper.instance.getDimData(par1World.provider.dimensionId).isPocket)
|
||||
{
|
||||
int yCoord=yCoordHelper.getFirstUncovered(ExitDimID, par2, par3, par4)-1;
|
||||
|
||||
|
||||
dimHelper.instance.createLink(locDimID, ExitDimID, par2, par3, par4, par2, yCoord, par4,par1World.getBlockMetadata(par2, par3-1, par4));
|
||||
dimHelper.instance.createLink(ExitDimID, locDimID, par2, yCoord, par4, par2, par3, par4,
|
||||
BlockRotator.transformMetadata(par1World.getBlockMetadata(par2, par3 - 1, par4), 2, Block.doorWood.blockID));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
if(dimHelper.instance.getDimDepth(locDimID)==1)
|
||||
{
|
||||
//System.out.println("exitToOverowrld from "+String.valueOf(locDimID));
|
||||
|
||||
int yCoord=yCoordHelper.getFirstUncovered(ExitDimID, par2, par3, par4);
|
||||
|
||||
|
||||
dimHelper.instance.createLink(locDimID, ExitDimID, par2, par3, par4, par2, yCoord, par4,par1World.getBlockMetadata(par2, par3-1, par4));
|
||||
dimHelper.instance.createLink(ExitDimID, locDimID, par2, yCoord, par4, par2, par3, par4,dimHelper.instance.flipDoorMetadata(par1World.getBlockMetadata(par2, par3-1, par4)));
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if(dimHelper.instance.getDimData(par1World.provider.dimensionId).isPocket)
|
||||
{
|
||||
//System.out.println("Created new dim from "+String.valueOf(par1World.provider.dimensionId));
|
||||
|
||||
LinkData link = new LinkData(par1World.provider.dimensionId, 0, par2, par3, par4, par2, par3, par4, true, par1World.getBlockMetadata(par2, par3-1, par4));
|
||||
dimHelper.instance.createPocket(link,false, false);
|
||||
|
||||
|
||||
|
||||
// dimHelper.instance.generatePocket(dimHelper.getWorld(destDimID), par2, par3, par4,par1World.getBlockMetadata(par2, par3-1, par4));
|
||||
|
||||
|
||||
}
|
||||
**/
|
||||
|
||||
}
|
||||
else if (dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World)!=null)
|
||||
{
|
||||
|
||||
//System.out.println("RiftPresent at "+String.valueOf(par1World.provider.dimensionId));
|
||||
dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World).linkOrientation=par1World.getBlockMetadata(par2, par3-1, par4);
|
||||
dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World).hasGennedDoor=false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
par1World.setBlockTileEntity(par2, par3, par4, this.createNewTileEntity(par1World));
|
||||
|
||||
}
|
||||
@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 int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return Item.doorWood.itemID;
|
||||
}
|
||||
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return (par1 & 8) != 0 ? 0 : (Item.doorWood.itemID);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
13
StevenDimDoors/mod_pocketDim/blocks/IDimDoor.java
Normal file
13
StevenDimDoors/mod_pocketDim/blocks/IDimDoor.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IDimDoor
|
||||
{
|
||||
public void enterDimDoor(World world, int x, int y, int z, Entity entity);
|
||||
|
||||
public void placeLink(World world, int x, int y, int z);
|
||||
|
||||
public int getDrops();
|
||||
}
|
||||
121
StevenDimDoors/mod_pocketDim/blocks/TransTrapdoor.java
Normal file
121
StevenDimDoors/mod_pocketDim/blocks/TransTrapdoor.java
Normal file
@@ -0,0 +1,121 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockTrapDoor;
|
||||
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;
|
||||
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;
|
||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityTransTrapdoor;
|
||||
|
||||
public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntityProvider
|
||||
{
|
||||
|
||||
public TransTrapdoor(int blockID, Material material)
|
||||
{
|
||||
super(blockID, material);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2());
|
||||
}
|
||||
|
||||
//Teleports the player to the exit link of that dimension, assuming it is a pocket
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
enterDimDoor(world, x, y, z, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterDimDoor(World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if (!world.isRemote && isTrapdoorOpen(world.getBlockMetadata(x, y, z)))
|
||||
{
|
||||
this.onPoweredBlockChange(world, x, y, z, false);
|
||||
|
||||
DimLink link = PocketManager.getLink(x, y, z, world);
|
||||
if (link != null)
|
||||
{
|
||||
DDTeleporter.traverseDimDoor(world, link, entity,this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z)
|
||||
{
|
||||
this.placeLink(world, x, y, z);
|
||||
world.setBlockTileEntity(x, y, z, this.createNewTileEntity(world));
|
||||
this.updateAttachedTile(world, x, y, z);
|
||||
}
|
||||
|
||||
public void updateTick(World world, int x, int y, int z, Random random)
|
||||
{
|
||||
TileEntityTransTrapdoor tile = (TileEntityTransTrapdoor) world.getBlockTileEntity(x, y, z);
|
||||
tile.hasRift = PocketManager.getLink(x, y, z, world) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
return new TileEntityTransTrapdoor();
|
||||
}
|
||||
|
||||
public void updateAttachedTile(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
if (tile instanceof TileEntityTransTrapdoor)
|
||||
{
|
||||
TileEntityTransTrapdoor trapdoorTile = (TileEntityTransTrapdoor) tile;
|
||||
trapdoorTile.hasRift = (PocketManager.getLink(x, y, z, world) != null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeLink(World world, int x, int y, int z)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = dimension.getLink(x, y, z);
|
||||
if (link == null && dimension.isPocketDimension())
|
||||
{
|
||||
dimension.createLink(x, y, z, LinkTypes.UNSAFE_EXIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int idDropped(int metadata, Random random, int fortuneLevel)
|
||||
{
|
||||
return getDrops();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDrops()
|
||||
{
|
||||
return Block.trapdoor.blockID;
|
||||
}
|
||||
|
||||
public static boolean isTrapdoorSetLow(int metadata)
|
||||
{
|
||||
return (metadata & 8) == 0;
|
||||
}
|
||||
}
|
||||
103
StevenDimDoors/mod_pocketDim/blocks/TransientDoor.java
Normal file
103
StevenDimDoors/mod_pocketDim/blocks/TransientDoor.java
Normal file
@@ -0,0 +1,103 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
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
|
||||
{
|
||||
public TransientDoor(int blockID, Material material, DDProperties properties)
|
||||
{
|
||||
super(blockID, material, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterDimDoor(World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
// We need to ignore particle entities
|
||||
if (world.isRemote || entity instanceof EntityFX)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that this is the top block of the door
|
||||
if (world.getBlockId(x, y - 1, z) == this.blockID)
|
||||
{
|
||||
boolean canUse = true;
|
||||
int metadata = world.getBlockMetadata(x, y - 1, z);
|
||||
if (canUse && entity instanceof EntityLiving)
|
||||
{
|
||||
// Don't check for non-living entities since it might not work right
|
||||
canUse = BaseDimDoor.isEntityFacingDoor(metadata, (EntityLiving) entity);
|
||||
}
|
||||
if (canUse)
|
||||
{
|
||||
// Teleport the entity through the link, if it exists
|
||||
DimLink link = PocketManager.getLink(x, y, z, world.provider.dimensionId);
|
||||
if (link != null)
|
||||
{
|
||||
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);
|
||||
world.setBlockToAir(x, y - 1, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (world.getBlockId(x, y + 1, z) == this.blockID)
|
||||
{
|
||||
enterDimDoor(world, x, y + 1, z, entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeLink(World world, int x, int y, int z)
|
||||
{
|
||||
if (!world.isRemote && world.getBlockId(x, y - 1, z) == this.blockID)
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = dimension.getLink(x, y, z);
|
||||
if (link == null && dimension.isPocketDimension())
|
||||
{
|
||||
dimension.createLink(x, y, z, LinkTypes.SAFE_EXIT,world.getBlockMetadata(x, y - 1, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDrops()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
}
|
||||
32
StevenDimDoors/mod_pocketDim/blocks/UnstableDoor.java
Normal file
32
StevenDimDoors/mod_pocketDim/blocks/UnstableDoor.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class UnstableDoor extends BaseDimDoor
|
||||
{
|
||||
public UnstableDoor(int blockID, Material material, DDProperties properties)
|
||||
{
|
||||
super(blockID, material, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeLink(World world, int x, int y, int z)
|
||||
{
|
||||
if (!world.isRemote && world.getBlockId(x, y - 1, z) == this.blockID)
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
dimension.createLink(x, y, z, LinkTypes.RANDOM,world.getBlockMetadata(x, y - 1, z));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int getDrops()
|
||||
{
|
||||
return Item.doorIron.itemID;
|
||||
}
|
||||
}
|
||||
38
StevenDimDoors/mod_pocketDim/blocks/WarpDoor.java
Normal file
38
StevenDimDoors/mod_pocketDim/blocks/WarpDoor.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class WarpDoor extends BaseDimDoor
|
||||
{
|
||||
public WarpDoor(int blockID, Material material, DDProperties properties)
|
||||
{
|
||||
super(blockID, material, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeLink(World world, int x, int y, int z)
|
||||
{
|
||||
if (!world.isRemote && world.getBlockId(x, y - 1, z) == this.blockID)
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = dimension.getLink(x, y, z);
|
||||
if (link == null && dimension.isPocketDimension())
|
||||
{
|
||||
dimension.createLink(x, y, z, LinkTypes.SAFE_EXIT,world.getBlockMetadata(x, y - 1, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDrops()
|
||||
{
|
||||
return Item.doorWood.itemID;
|
||||
}
|
||||
}
|
||||
@@ -1,674 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.TileEntityDimDoor;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
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.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class dimDoor extends BlockContainer
|
||||
{
|
||||
private static Icon blockIconBottom;
|
||||
public dimDoor(int par1, Material material)
|
||||
{
|
||||
super(par1, Material.iron);
|
||||
// this.blockIndexInTexture = 18;
|
||||
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
}
|
||||
|
||||
private static DDProperties properties = null;
|
||||
|
||||
|
||||
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");
|
||||
|
||||
}
|
||||
|
||||
|
||||
//spawns the rift attatched to the block. Doesnt work in creative mode for some reason
|
||||
//TODO make work in creative
|
||||
public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if(!par1World.isRemote)
|
||||
{
|
||||
if(dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World)!=null)
|
||||
{
|
||||
LinkData link= dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World);
|
||||
par1World.setBlock(par2, par3, par4, properties.RiftBlockID);
|
||||
|
||||
}
|
||||
if(dimHelper.instance.getLinkDataFromCoords(par2, par3-1, par4, par1World)!=null)
|
||||
{
|
||||
LinkData link= dimHelper.instance.getLinkDataFromCoords(par2, par3-1, par4, par1World);
|
||||
par1World.setBlock(par2, par3-1, par4, properties.RiftBlockID);
|
||||
|
||||
}
|
||||
if(dimHelper.instance.getLinkDataFromCoords(par2, par3+1, par4, par1World)!=null)
|
||||
{
|
||||
LinkData link= dimHelper.instance.getLinkDataFromCoords(par2, par3+1, par4, par1World);
|
||||
par1World.setBlock(par2, par3+1, par4, properties.RiftBlockID);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//finds the rift data and teleports the player to it.
|
||||
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
{
|
||||
|
||||
if(!par1World.isRemote)
|
||||
{
|
||||
int var12 = (int) (MathHelper.floor_double((double)((par5Entity.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
|
||||
|
||||
int num=0;
|
||||
LinkData linkData=null;
|
||||
|
||||
if(par1World.getBlockId(par2, par3-1, par4)==this.blockID)
|
||||
{
|
||||
num=par1World.getBlockMetadata(par2, par3-1, par4);
|
||||
linkData= dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World);
|
||||
}
|
||||
|
||||
if(par1World.getBlockId(par2, par3+1, par4)==this.blockID)
|
||||
{
|
||||
num=par1World.getBlockMetadata(par2, par3, par4);
|
||||
linkData= dimHelper.instance.getLinkDataFromCoords(par2, par3+1, par4, par1World);
|
||||
}
|
||||
|
||||
if(!(par5Entity instanceof EntityPlayer)&&num>3)
|
||||
{
|
||||
this.onPoweredBlockChange(par1World, par2, par3, par4, false);
|
||||
dimHelper.instance.traverseDimDoor(par1World, linkData, par5Entity);
|
||||
}
|
||||
|
||||
else if(!par1World.isRemote&&(num==5||num==4||num==6||num==7)&&(num-4)==var12)
|
||||
{
|
||||
|
||||
//int destinationID= dimHelper.instance.getDestIDFromCoords(par2, par3, par4, par1World);
|
||||
|
||||
|
||||
this.onPoweredBlockChange(par1World, par2, par3, par4, false);
|
||||
|
||||
dimHelper.instance.traverseDimDoor(par1World, linkData, par5Entity);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
|
||||
boolean shouldOpen=true;
|
||||
|
||||
//System.out.println(String.valueOf(par1World.getBlockMetadata(par2, par3, par4)));
|
||||
if(par5EntityPlayer.inventory.getCurrentItem()!=null)
|
||||
{
|
||||
if(par5EntityPlayer.inventory.getCurrentItem().getItem() == mod_pocketDim.itemRiftBlade)
|
||||
{
|
||||
shouldOpen=false;
|
||||
if(!par1World.isRemote&&par1World.getBlockId(par2, par3-1, par4)==this.blockID)
|
||||
{
|
||||
int var12 = (int) (MathHelper.floor_double((double)((par5EntityPlayer.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
|
||||
|
||||
if(par1World.getBlockMetadata(par2, par3-1, par4)==var12)
|
||||
{
|
||||
var12 = BlockRotator.transformMetadata(var12, 2, Block.doorWood.blockID);
|
||||
}
|
||||
par1World.setBlockMetadataWithNotify(par2, par3-1, par4, var12,2);
|
||||
|
||||
if( dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World)!=null)
|
||||
{
|
||||
dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World).linkOrientation= par1World.getBlockMetadata(par2, par3-1, par4);
|
||||
|
||||
}
|
||||
}
|
||||
if(!par1World.isRemote&&par1World.getBlockId(par2, par3+1, par4)==this.blockID)
|
||||
{
|
||||
int var12 = (int) (MathHelper.floor_double((double)((par5EntityPlayer.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
|
||||
if(par1World.getBlockMetadata(par2, par3, par4)==var12)
|
||||
{
|
||||
var12 = BlockRotator.transformMetadata(var12, 2, Block.doorWood.blockID);
|
||||
}
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var12,2);
|
||||
|
||||
if( dimHelper.instance.getLinkDataFromCoords(par2, par3+1, par4, par1World)!=null)
|
||||
{
|
||||
dimHelper.instance.getLinkDataFromCoords(par2, par3+1, par4, par1World).linkOrientation= par1World.getBlockMetadata(par2, par3, par4);
|
||||
}
|
||||
|
||||
}
|
||||
par1World.playAuxSFXAtEntity(par5EntityPlayer, 1001, par2, par3, par4, 0);
|
||||
|
||||
if(!shouldOpen&&!par1World.isRemote)
|
||||
{
|
||||
|
||||
par5EntityPlayer.inventory.getCurrentItem().damageItem(5, par5EntityPlayer);
|
||||
|
||||
// par5EntityPlayer.sendChatToPlayer("You wedge the stick into a cranny in the door attempt to rotate the it");
|
||||
// par5EntityPlayer.sendChatToPlayer("The door rotates, but the stick breaks in half and is lost");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(shouldOpen)
|
||||
{
|
||||
|
||||
int var10 = this.getFullMetadata(par1World, par2, par3, par4);
|
||||
int var11 = var10 & 7;
|
||||
var11 ^= 4;
|
||||
|
||||
if ((var10 & 8) == 0)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var11,2);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3 - 1, par4, var11,2);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3 - 1, par4, par2, par3, par4);
|
||||
}
|
||||
|
||||
par1World.playAuxSFXAtEntity(par5EntityPlayer, 1003, par2, par3, par4, 0);
|
||||
if(dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World)!=null)
|
||||
{
|
||||
// System.out.println("Link orient is- " +dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World).linkOrientation);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A function to open a door.
|
||||
*/
|
||||
public void onPoweredBlockChange(World par1World, int par2, int par3, int par4, boolean par5)
|
||||
{
|
||||
int var6 = this.getFullMetadata(par1World, par2, par3, par4);
|
||||
boolean var7 = (var6 & 4) != 0;
|
||||
|
||||
if (var7 != par5)
|
||||
{
|
||||
int var8 = var6 & 7;
|
||||
var8 ^= 4;
|
||||
|
||||
if ((var6 & 8) == 0)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var8,2);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3 - 1, par4, var8,2);
|
||||
par1World.markBlockRangeForRenderUpdate(par2, par3 - 1, par4, par2, par3, par4);
|
||||
}
|
||||
|
||||
par1World.playAuxSFXAtEntity((EntityPlayer)null, 1003, par2, par3, par4, 0);
|
||||
}
|
||||
}
|
||||
//TODO simplify this
|
||||
@Override
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if(!par1World.isRemote&&par1World.getBlockId(par2, par3-1, par4)==this.blockID)
|
||||
{
|
||||
|
||||
|
||||
if(dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World)==null)
|
||||
{
|
||||
|
||||
|
||||
|
||||
LinkData link = new LinkData(par1World.provider.dimensionId, 0, par2, par3, par4, par2, par3, par4, true,par1World.getBlockMetadata(par2, par3-1, par4));
|
||||
dimHelper.instance.createPocket(link,true, false);
|
||||
// System.out.println(link.linkOrientation);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World)!=null)
|
||||
{
|
||||
dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World).linkOrientation=par1World.getBlockMetadata(par2, par3-1, par4);
|
||||
dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World).hasGennedDoor=false;
|
||||
|
||||
}
|
||||
}
|
||||
par1World.setBlockTileEntity(par2, par3, par4, this.createNewTileEntity(par1World));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
//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 updateAttatchedTile(IBlockAccess par1World, int par2, int par3, int par4)
|
||||
{
|
||||
TileEntity tile = (TileEntity) par1World.getBlockTileEntity(par2, par3, par4);
|
||||
if(tile instanceof TileEntityDimDoor )
|
||||
{
|
||||
TileEntityDimDoor dimTile=(TileEntityDimDoor)tile;
|
||||
|
||||
if(par1World.getBlockId( par2, par3+1, par4 )==par1World.getBlockId( par2, par3, par4 ))
|
||||
{
|
||||
//dimTile.openOrClosed=false;
|
||||
}
|
||||
if(dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, (World)par1World)==null)
|
||||
{
|
||||
dimTile.openOrClosed=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
dimTile.openOrClosed=true;
|
||||
}
|
||||
|
||||
int metaData = this.getFullMetadata(par1World, par2, par3, par4)%8;
|
||||
dimTile.orientation=metaData;
|
||||
}
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
|
||||
TileEntityDimDoor tile = (TileEntityDimDoor) par1World.getBlockTileEntity(par2, par3, par4);
|
||||
tile.openOrClosed=this.isDoorOpen( par1World, par2, par3, par4);
|
||||
int metaData = this.getFullMetadata(par1World, par2, par3, par4);
|
||||
tile.orientation=metaData%8 ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean getBlocksMovement(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = this.getFullMetadata(par1IBlockAccess, par2, par3, par4);
|
||||
return (var5 & 4) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType()
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
/**
|
||||
* Returns the bounding box of the wired rectangular prism to render.
|
||||
*/
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
this.setBlockBoundsBasedOnState(par1World, par2, par3, par4);
|
||||
return super.getSelectedBoundingBoxFromPool(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
|
||||
* cleared to be reused)
|
||||
*/
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
this.setBlockBoundsBasedOnState(par1World, par2, par3, par4);
|
||||
return super.getCollisionBoundingBoxFromPool(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the blocks bounds based on its current state. Args: world, x, y, z
|
||||
*/
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
this.setDoorRotation(this.getFullMetadata(par1IBlockAccess, par2, par3, par4));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 0, 1, 2 or 3 depending on where the hinge is.
|
||||
*/
|
||||
public int getDoorOrientation(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
return this.getFullMetadata(par1IBlockAccess, par2, par3, par4) & 3;
|
||||
}
|
||||
|
||||
public boolean isDoorOpen(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
return (this.getFullMetadata(par1IBlockAccess, par2, par3, par4) & 4) != 0;
|
||||
}
|
||||
|
||||
private void setDoorRotation(int par1)
|
||||
{
|
||||
float var2 = 0.1875F;
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F);
|
||||
int var3 = par1 & 3;
|
||||
boolean var4 = (par1 & 4) != 0;
|
||||
boolean var5 = (par1 & 16) != 0;
|
||||
|
||||
if (var3 == 0)
|
||||
{
|
||||
if (var4)
|
||||
{
|
||||
if (!var5)
|
||||
{
|
||||
this.setBlockBounds(0.001F, 0.0F, 0.0F, 1.0F, 1.0F, var2);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.001F, 0.0F, 1.0F - var2, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, var2, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else if (var3 == 1)
|
||||
{
|
||||
if (var4)
|
||||
{
|
||||
if (!var5)
|
||||
{
|
||||
this.setBlockBounds(1.0F - var2, 0.0F, 0.001F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.001F, var2, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, var2);
|
||||
}
|
||||
}
|
||||
else if (var3 == 2)
|
||||
{
|
||||
if (var4)
|
||||
{
|
||||
if (!var5)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 1.0F - var2, .99F, 1.0F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, .99F, 1.0F, var2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(1.0F - var2, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else if (var3 == 3)
|
||||
{
|
||||
if (var4)
|
||||
{
|
||||
if (!var5)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, var2, 1.0F, 0.99F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(1.0F - var2, 0.0F, 0.0F, 1.0F, 1.0F, 0.99F);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 1.0F - var2, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is clicked by a player. Args: x, y, z, entityPlayer
|
||||
*/
|
||||
public void onBlockClicked(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
|
||||
{
|
||||
// System.out.println(this.getFullMetadata(par1World, par2, par3, par4)%4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* A function to open a door.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if ((var6 & 8) == 0)
|
||||
{
|
||||
boolean var7 = false;
|
||||
|
||||
if (par1World.getBlockId(par2, par3 + 1, par4) != this.blockID)
|
||||
{
|
||||
par1World.setBlock(par2, par3, par4, 0);
|
||||
var7 = true;
|
||||
}
|
||||
|
||||
/**
|
||||
if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4))
|
||||
{
|
||||
par1World.setBlockWithNotify(par2, par3, par4, 0);
|
||||
var7 = true;
|
||||
|
||||
if (par1World.getBlockId(par2, par3 + 1, par4) == this.blockID)
|
||||
{
|
||||
par1World.setBlockWithNotify(par2, par3 + 1, par4, 0);
|
||||
}
|
||||
}
|
||||
**/
|
||||
|
||||
if (var7)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, properties.DimensionalDoorID, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean var8 = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4) || par1World.isBlockIndirectlyGettingPowered(par2, par3 + 1, par4);
|
||||
|
||||
if ((var8 || par5 > 0 && Block.blocksList[par5].canProvidePower()) && par5 != this.blockID)
|
||||
{
|
||||
this.onPoweredBlockChange(par1World, par2, par3, par4, var8);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (par1World.getBlockId(par2, par3 - 1, par4) != this.blockID)
|
||||
{
|
||||
par1World.setBlock(par2, par3, par4, 0);
|
||||
}
|
||||
|
||||
if (par5 > 0 && par5 != this.blockID)
|
||||
{
|
||||
this.onNeighborBlockChange(par1World, par2, par3 - 1, par4, par5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Ray traces through the blocks collision from start vector to end vector returning a ray trace hit. Args: world,
|
||||
* x, y, z, startVec, endVec
|
||||
*/
|
||||
public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3)
|
||||
{
|
||||
this.setBlockBoundsBasedOnState(par1World, par2, par3, par4);
|
||||
return super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
|
||||
*/
|
||||
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return par3 >= 255 ? false : par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && super.canPlaceBlockAt(par1World, par2, par3, par4) && super.canPlaceBlockAt(par1World, par2, par3 + 1, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mobility information of the block, 0 = free, 1 = can't push but can move over, 2 = total immobility
|
||||
* and stop pistons
|
||||
*/
|
||||
public int getMobilityFlag()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full metadata value created by combining the metadata of both blocks the door takes up.
|
||||
*/
|
||||
public int getFullMetadata(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
|
||||
boolean var6 = (var5 & 8) != 0;
|
||||
int var7;
|
||||
int var8;
|
||||
|
||||
if (var6)
|
||||
{
|
||||
var7 = par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4);
|
||||
var8 = var5;
|
||||
}
|
||||
else
|
||||
{
|
||||
var7 = var5;
|
||||
var8 = par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4);
|
||||
}
|
||||
|
||||
boolean var9 = (var8 & 1) != 0;
|
||||
return var7 & 7 | (var6 ? 8 : 0) | (var9 ? 16 : 0);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
/**
|
||||
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
|
||||
*/
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return Item.doorIron.itemID;
|
||||
}
|
||||
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return (par1 & 8) != 0 ? 0 : (Item.doorIron.itemID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is attempted to be harvested
|
||||
*/
|
||||
public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer)
|
||||
{
|
||||
if (par6EntityPlayer.capabilities.isCreativeMode && (par5 & 8) != 0 && par1World.getBlockId(par2, par3 - 1, par4) == this.blockID)
|
||||
{
|
||||
par1World.setBlock(par2, par3 - 1, par4, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public TileEntity createNewTileEntity(World par1World)
|
||||
{
|
||||
|
||||
TileEntity tile= new TileEntityDimDoor();
|
||||
|
||||
return tile;
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.world.PocketProvider;
|
||||
import net.minecraft.block.BlockTrapDoor;
|
||||
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.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class dimHatch extends BlockTrapDoor
|
||||
{
|
||||
|
||||
public dimHatch(int par1,int par2, Material par2Material)
|
||||
{
|
||||
super(par1, Material.iron);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
// this.setTextureFile("/PocketBlockTextures.png");
|
||||
// this.blockIndexInTexture = 16;
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2());
|
||||
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
|
||||
{
|
||||
int var10 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var10 ^ 4,2);
|
||||
par1World.playAuxSFXAtEntity(par5EntityPlayer, 1003, par2, par3, par4, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//Teleports the player to the exit link of that dimension, assuming it is a pocket
|
||||
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
{
|
||||
|
||||
int num = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if(!par1World.isRemote&&(num>3&&num<8||num>11)&&par1World.provider instanceof PocketProvider)
|
||||
{
|
||||
|
||||
this.onPoweredBlockChange(par1World, par2, par3, par4, false);
|
||||
|
||||
DimData dimData = (DimData) dimHelper.instance.dimList.get(par1World.provider.dimensionId);
|
||||
|
||||
LinkData exitLink=dimData.exitDimLink;
|
||||
exitLink.locDimID=par1World.provider.dimensionId;
|
||||
|
||||
|
||||
dimHelper.instance.traverseDimDoor(par1World, exitLink, par5Entity);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void onPoweredBlockChange(World par1World, int par2, int par3, int par4, boolean par5)
|
||||
{
|
||||
int var6 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
boolean var7 = (var6 & 4) > 0;
|
||||
|
||||
if (var7 != par5)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6 ^ 4,2);
|
||||
par1World.playAuxSFXAtEntity((EntityPlayer)null, 1003, par2, par3, par4, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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");
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user