Moved file structure around a bit, and added stabilized rift sig
fixed XP bug moving through doors made items shut doors again Signed-off-by: StevenRS11 <stevenrs11@aol.com>
This commit is contained in:
102
StevenDimDoors/mod_pocketDim/blocks/BlockDimWall.java
Normal file
102
StevenDimDoors/mod_pocketDim/blocks/BlockDimWall.java
Normal file
@@ -0,0 +1,102 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
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.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockDimWall extends Block
|
||||
{
|
||||
|
||||
public BlockDimWall(int i, int j, Material par2Material)
|
||||
{
|
||||
super(i, Material.ground);
|
||||
setTickRandomly(true);
|
||||
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2());
|
||||
}
|
||||
|
||||
public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5) {}
|
||||
|
||||
protected boolean canSilkHarvest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public int quantityDropped(Random par1Random)
|
||||
{
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* replaces the block clicked with the held block, instead of placing the block on top of it. Shift click to disable.
|
||||
*/
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if(!par1World.isRemote&&entityPlayer.getCurrentEquippedItem()!=null)
|
||||
{
|
||||
Item playerEquip = entityPlayer.getCurrentEquippedItem().getItem();
|
||||
|
||||
if(!(playerEquip instanceof ItemBlock))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Block block= Block.blocksList[playerEquip.itemID];
|
||||
if(!Block.isNormalCube(playerEquip.itemID))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(block instanceof BlockContainer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemBlock)
|
||||
{
|
||||
|
||||
|
||||
if(!entityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
entityPlayer.getCurrentEquippedItem().stackSize--;
|
||||
}
|
||||
par1World.setBlock(par2, par3, par4, entityPlayer.getCurrentEquippedItem().itemID, entityPlayer.getCurrentEquippedItem().getItemDamage(),0);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
130
StevenDimDoors/mod_pocketDim/blocks/BlockDimWallPerm.java
Normal file
130
StevenDimDoors/mod_pocketDim/blocks/BlockDimWallPerm.java
Normal file
@@ -0,0 +1,130 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockDimWallPerm extends Block
|
||||
{
|
||||
|
||||
public BlockDimWallPerm(int i, int j, Material par2Material)
|
||||
{
|
||||
super(i, Material.ground);
|
||||
setTickRandomly(true);
|
||||
// this.setCreativeTab(CreativeTabs.tabBlock);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2().replace("perm", ""));
|
||||
}
|
||||
public int quantityDropped(Random par1Random)
|
||||
{
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5) {}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
if(!par1World.isRemote&&par1World.provider.dimensionId==mod_pocketDim.limboDimID)
|
||||
{
|
||||
Random rand = new Random();
|
||||
|
||||
LinkData link=dimHelper.instance.getRandomLinkData(false);
|
||||
if(link==null)
|
||||
{
|
||||
link =new LinkData(0,0,0,0);
|
||||
}
|
||||
|
||||
|
||||
if(dimHelper.getWorld(0)==null)
|
||||
{
|
||||
dimHelper.initDimension(0);
|
||||
}
|
||||
|
||||
|
||||
if(dimHelper.getWorld(0)!=null)
|
||||
{
|
||||
|
||||
|
||||
int x = (link.destXCoord + rand.nextInt(mod_pocketDim.limboExitRange)-mod_pocketDim.limboExitRange/2);
|
||||
int z = (link.destZCoord + rand.nextInt(mod_pocketDim.limboExitRange)-mod_pocketDim.limboExitRange/2);
|
||||
|
||||
x=x+(x>> 4)+1; //make sure I am in the middle of a chunk, andnot on a boundry, so it doesnt load the chunk next to me
|
||||
z=z+(z>> 4)+1;
|
||||
|
||||
dimHelper.getWorld(0).getChunkProvider().loadChunk(x >> 4, z >> 4);
|
||||
|
||||
int y = dimHelper.getWorld(0).getHeightValue(x, z);
|
||||
|
||||
//this complicated chunk teleports the player back to the overworld at some random location. Looks funky becaue it has to load the chunk
|
||||
dimHelper.instance.teleportToPocket(par1World, new LinkData(par1World.provider.dimensionId,0,x,y,z,link.locXCoord,link.locYCoord,link.locZCoord,link.isLocPocket),
|
||||
EntityPlayer.class.cast(par5Entity));
|
||||
|
||||
|
||||
EntityPlayer.class.cast(par5Entity).setPositionAndUpdate( x, y, z );
|
||||
|
||||
//makes sure they can breath when they teleport
|
||||
dimHelper.getWorld(0).setBlock(x, y, z, 0);
|
||||
int i=x;
|
||||
int j=y-1;
|
||||
int k=z;
|
||||
|
||||
|
||||
for(int xc=-3;xc<4;xc++)
|
||||
{
|
||||
for(int zc=-3;zc<4;zc++)
|
||||
{
|
||||
for(int yc=0;yc<200;yc++)
|
||||
{
|
||||
if(yc==0&&dimHelper.getWorld(0).isBlockOpaqueCube(i+xc, j-2,k +zc))
|
||||
{
|
||||
|
||||
if(Math.abs(xc)+Math.abs(zc)<rand.nextInt(3)+2)
|
||||
{
|
||||
dimHelper.getWorld(0).setBlock(i+xc, j-1+yc, k+zc, mod_pocketDim.blockLimboID);
|
||||
}
|
||||
else if(Math.abs(xc)+Math.abs(zc)<rand.nextInt(3)+3)
|
||||
|
||||
{
|
||||
dimHelper.getWorld(0).setBlock(i+xc, j-1+yc, k+zc, mod_pocketDim.blockLimboID,2,0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
75
StevenDimDoors/mod_pocketDim/blocks/BlockLimbo.java
Normal file
75
StevenDimDoors/mod_pocketDim/blocks/BlockLimbo.java
Normal file
@@ -0,0 +1,75 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||
import StevenDimDoors.mod_pocketDim.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
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.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockLimbo extends Block
|
||||
{
|
||||
|
||||
public BlockLimbo(int i, int j, Material par2Material)
|
||||
{
|
||||
super(i, Material.ground);
|
||||
setTickRandomly(false);
|
||||
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||
|
||||
|
||||
|
||||
}
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2());
|
||||
|
||||
}
|
||||
|
||||
public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5) {}
|
||||
|
||||
//part of the decay mech, if a block has fallen onto it, when it turns, it makes sure any block above it gets added too.
|
||||
@Override
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if(par1World.getBlockId(par2, par3+1, par4)==Block.gravel.blockID)
|
||||
{
|
||||
Point3D point = new Point3D(par2,par3+1,par4);
|
||||
dimHelper.blocksToDecay.add(point);
|
||||
}
|
||||
}
|
||||
public int quantityDropped(Random par1Random)
|
||||
{
|
||||
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
//if a block lands on it and its gravel, adds it to the decay list
|
||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
|
||||
if(par1World.getBlockId(par2, par3+1, par4)==Block.gravel.blockID)
|
||||
{
|
||||
Point3D point = new Point3D(par2,par3+1,par4);
|
||||
dimHelper.blocksToDecay.add(point);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//TODO set render color!!
|
||||
}
|
||||
301
StevenDimDoors/mod_pocketDim/blocks/BlockRift.java
Normal file
301
StevenDimDoors/mod_pocketDim/blocks/BlockRift.java
Normal file
@@ -0,0 +1,301 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.PacketHandler;
|
||||
import StevenDimDoors.mod_pocketDim.TileEntityRift;
|
||||
import StevenDimDoors.mod_pocketDim.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDimClient.ClosingRiftFX;
|
||||
import StevenDimDoors.mod_pocketDimClient.GoggleRiftFX;
|
||||
import StevenDimDoors.mod_pocketDimClient.RiftFX;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockRift extends BlockContainer
|
||||
{
|
||||
|
||||
public BlockRift(int i, int j, Material par2Material)
|
||||
{
|
||||
super(i, Material.air);
|
||||
setTickRandomly(true);
|
||||
// this.setCreativeTab(CreativeTabs.tabBlock);
|
||||
this.setLightOpacity(14);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2());
|
||||
}
|
||||
//sends a packet informing the client that there is a link present so it renders properly. (when placed)
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
try
|
||||
{
|
||||
PacketHandler.onLinkCreatedPacket(dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
// this.updateTick(par1World, par2, par3, par4, new Random());
|
||||
|
||||
}
|
||||
public boolean isCollidable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5) {}
|
||||
|
||||
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this block is collideable based on the arguments passed in Args: blockMetaData, unknownFlag
|
||||
*/
|
||||
public boolean canCollideCheck(int par1, boolean par2)
|
||||
{
|
||||
|
||||
return par2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Returns true if the given side of this block type should be rendered (if it's solid or not), if the
|
||||
* adjacent block is at the given coordinates. Args: blockAccess, x, y, z, side
|
||||
*/
|
||||
public boolean isBlockSolid(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//this doesnt do anything yet.
|
||||
public int getRenderType()
|
||||
{
|
||||
if(mod_pocketDim.isPlayerWearingGoogles)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 8;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
/**
|
||||
* Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
|
||||
* coordinates. Args: blockAccess, x, y, z, side
|
||||
*/
|
||||
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
//function that regulates how many blocks it eats/ how fast it eates them.
|
||||
public void updateTick(World world, int x, int y, int z, Random random)
|
||||
{
|
||||
if(!world.isRemote&&dimHelper.instance.getLinkDataFromCoords(x, y, z, world.provider.dimensionId)!=null&&mod_pocketDim.enableRiftGrief)
|
||||
{
|
||||
TileEntityRift rift = (TileEntityRift) world.getBlockTileEntity(x, y, z);
|
||||
if(rift.isNearRift)
|
||||
{
|
||||
|
||||
int range=4;
|
||||
|
||||
float distance=range+range/4;
|
||||
int i=-range;
|
||||
int j=-range;
|
||||
int k=-range;
|
||||
boolean flag=true;
|
||||
while (i<range&&flag)
|
||||
{
|
||||
while (j<range&&flag)
|
||||
{
|
||||
while (k<range&&flag)
|
||||
{
|
||||
if(!mod_pocketDim.blocksImmuneToRift.contains(world.getBlockId(x+i, y+j, z+k))&&MathHelper.abs(i)+MathHelper.abs(j)+MathHelper.abs(k)<distance&&!world.isAirBlock(x+i, y+j, z+k))
|
||||
{
|
||||
if(MathHelper.abs(i)+MathHelper.abs(j)+MathHelper.abs(k)!=0&&random.nextInt(2)==0)
|
||||
{
|
||||
world.setBlock(x+i, y+j, z+k,0);
|
||||
flag=random.nextBoolean()||random.nextBoolean();
|
||||
}
|
||||
|
||||
}
|
||||
k++;
|
||||
}
|
||||
k=-range;
|
||||
j++;
|
||||
|
||||
}
|
||||
j=-range;
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
* regulates the render effect, especially when multiple rifts start to link up. Has 3 main parts- Grows toward and away from nearest rft, bends toward it, and a randomization function
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random rand)
|
||||
{
|
||||
|
||||
int count;
|
||||
//growth in the direction towards the nearby rift
|
||||
float xGrowth=0;
|
||||
float yGrowth=0;
|
||||
float zGrowth=0;
|
||||
//growth away from the nearby rift
|
||||
float xGrowthn=0;
|
||||
float yGrowthn=0;
|
||||
float zGrowthn=0;
|
||||
//how far the particles are away from original rift. Used to decrease noise the farther they are away.
|
||||
float xChange = 0;
|
||||
float yChange = 0;
|
||||
float zChange = 0;
|
||||
|
||||
TileEntityRift tile = (TileEntityRift)par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
//the noise, ie, how far the rift particles are away from the intended location.
|
||||
float offset=0;
|
||||
float Xoffset=0;
|
||||
float Yoffset=0;
|
||||
float Zoffset=0;
|
||||
for (count = 0; count < 12 && tile!=null; ++count)
|
||||
{
|
||||
//TODO change to a switch statement for clarity
|
||||
if(tile.xOffset>0)
|
||||
{
|
||||
if(rand.nextInt(tile.xOffset)==0)
|
||||
{
|
||||
xGrowth =xGrowth+.15F*tile.xOffset;
|
||||
|
||||
}
|
||||
}
|
||||
else if(tile.xOffset<0)
|
||||
{
|
||||
if(rand.nextInt(-tile.xOffset)==0)
|
||||
{
|
||||
xGrowthn =xGrowthn-.15F*-tile.xOffset;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(tile.yOffset>0)
|
||||
{
|
||||
if(rand.nextInt(tile.yOffset)==0)
|
||||
{
|
||||
yGrowth =yGrowth+.15F*tile.yOffset;
|
||||
|
||||
}
|
||||
}
|
||||
else if(tile.yOffset<0)
|
||||
{
|
||||
if(rand.nextInt(-tile.yOffset)==0)
|
||||
{
|
||||
yGrowthn =yGrowthn-.15F*-tile.yOffset;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(tile.zOffset>0)
|
||||
{
|
||||
if(rand.nextInt(tile.zOffset)==0)
|
||||
{
|
||||
zGrowth =zGrowth+.15F*tile.zOffset;
|
||||
|
||||
}
|
||||
}
|
||||
else if(tile.zOffset<0)
|
||||
{
|
||||
if(rand.nextInt(-tile.zOffset)==0)
|
||||
{
|
||||
zGrowthn =zGrowthn-.15F*-tile.zOffset;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
xChange=(float) ((xGrowth+xGrowthn)+rand.nextGaussian()*.05F);
|
||||
yChange=(float) ((yGrowth+yGrowthn)+rand.nextGaussian()*.05F);
|
||||
zChange=(float) ((zGrowth+zGrowthn)+rand.nextGaussian()*.05F);
|
||||
|
||||
offset= (float) ((0.2F/(1+Math.abs(xChange)+Math.abs(yChange)+Math.abs(zChange))));
|
||||
Xoffset= (float) ((0.25F/(1+Math.abs(xChange))));
|
||||
|
||||
Yoffset= (float) ((0.25F/(1+Math.abs(yChange))));
|
||||
Zoffset= (float) ((0.25F/(1+Math.abs(zChange))));
|
||||
|
||||
|
||||
|
||||
|
||||
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new RiftFX(par1World,par2+.5+xChange+Xoffset*rand.nextGaussian(), par3+.5+yChange+Yoffset*rand.nextGaussian() , par4+.5+zChange+Zoffset*rand.nextGaussian(), rand.nextGaussian() * 0.001D, rand.nextGaussian() * 0.001D, rand.nextGaussian() * 0.001D, FMLClientHandler.instance().getClient().effectRenderer));
|
||||
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new RiftFX(par1World,par2+.5-xChange-Xoffset*rand.nextGaussian(), par3+.5-yChange-Yoffset*rand.nextGaussian() , par4+.5-zChange-Zoffset*rand.nextGaussian(), rand.nextGaussian() * 0.001D, rand.nextGaussian() * 0.001D, rand.nextGaussian() * 0.001D, FMLClientHandler.instance().getClient().effectRenderer));
|
||||
|
||||
|
||||
if(rand.nextBoolean())
|
||||
{
|
||||
//renders an extra little blob on top of the actual rift location so its easier to find. Eventually will only render if the player has the goggles.
|
||||
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new GoggleRiftFX(par1World,par2+.5, par3+.5, par4+.5, rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D, FMLClientHandler.instance().getClient().effectRenderer));
|
||||
}
|
||||
if(tile.shouldClose)
|
||||
{
|
||||
//renders an opposite color effect if it is being closed by the rift remover
|
||||
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ClosingRiftFX(par1World,par2+.5, par3+.5, par4+.5, rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D, FMLClientHandler.instance().getClient().effectRenderer));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1)
|
||||
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return new TileEntityRift();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
146
StevenDimDoors/mod_pocketDim/blocks/ExitDoor.java
Normal file
146
StevenDimDoors/mod_pocketDim/blocks/ExitDoor.java
Normal file
@@ -0,0 +1,146 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.dimHelper;
|
||||
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 ExitDoor extends dimDoor
|
||||
{
|
||||
|
||||
private Icon blockIconBottom;
|
||||
public ExitDoor(int par1, Material par2Material)
|
||||
{
|
||||
|
||||
super(par1, Material.wood);
|
||||
// this.blockIndexInTexture = 19;
|
||||
|
||||
|
||||
// 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.dimList.get(locDimID);
|
||||
int ExitDimID = dimData.exitDimLink.destDimID;
|
||||
|
||||
|
||||
if(dimHelper.instance.getDimDepth(locDimID)==1)
|
||||
{
|
||||
//System.out.println("exitToOverowrld from "+String.valueOf(locDimID));
|
||||
|
||||
|
||||
|
||||
|
||||
dimHelper.instance.createLink(locDimID, ExitDimID, par2, par3, par4, par2, par3, par4,par1World.getBlockMetadata(par2, par3-1, par4));
|
||||
dimHelper.instance.createLink(ExitDimID, locDimID, par2, par3, par4, par2, par3, par4,dimHelper.instance.flipDoorMetadata(par1World.getBlockMetadata(par2, par3-1, par4)));
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if(dimHelper.dimList.get(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);
|
||||
link.linkOrientation= 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);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//this.onPoweredBlockChange(par1World, par2, par3, par4, false);
|
||||
|
||||
}
|
||||
@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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
668
StevenDimDoors/mod_pocketDim/blocks/dimDoor.java
Normal file
668
StevenDimDoors/mod_pocketDim/blocks/dimDoor.java
Normal file
@@ -0,0 +1,668 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.TileEntityDimDoor;
|
||||
import StevenDimDoors.mod_pocketDim.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
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, mod_pocketDim.blockRiftID);
|
||||
|
||||
}
|
||||
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, mod_pocketDim.blockRiftID);
|
||||
|
||||
}
|
||||
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, mod_pocketDim.blockRiftID);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//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(!par1World.isRemote&&(num==5||num==4||num==6||num==7)&&(num-4)==var12)
|
||||
{
|
||||
|
||||
//int destinationID= dimHelper.instance.getDestIDFromCoords(par2, par3, par4, par1World);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
dimHelper.instance.teleportToPocket(par1World, linkData, par5Entity);
|
||||
|
||||
//if(par5Entity instanceof EntityLiving)
|
||||
{
|
||||
this.onPoweredBlockChange(par1World, par2, par3, par4, false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (!(par5Entity instanceof EntityPlayer)&&num>3)
|
||||
{
|
||||
if(par5Entity instanceof EntityLiving)
|
||||
{
|
||||
this.onPoweredBlockChange(par1World, par2, par3, par4, false);
|
||||
}
|
||||
|
||||
|
||||
dimHelper.instance.teleportToPocket(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=dimHelper.instance.flipDoorMetadata(var12);
|
||||
}
|
||||
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=dimHelper.instance.flipDoorMetadata(var12);
|
||||
}
|
||||
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);
|
||||
link.linkOrientation= 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);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@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, mod_pocketDim.dimDoorID, 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.doorSteel.itemID;
|
||||
}
|
||||
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return (par1 & 8) != 0 ? 0 : (Item.doorSteel.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;
|
||||
}
|
||||
}
|
||||
77
StevenDimDoors/mod_pocketDim/blocks/dimHatch.java
Normal file
77
StevenDimDoors/mod_pocketDim/blocks/dimHatch.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.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(CreativeTabs.tabTransport);
|
||||
// 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;
|
||||
|
||||
dimHelper.instance.teleportToPocket(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
54
StevenDimDoors/mod_pocketDim/blocks/linkDimDoor.java
Normal file
54
StevenDimDoors/mod_pocketDim/blocks/linkDimDoor.java
Normal file
@@ -0,0 +1,54 @@
|
||||
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");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
56
StevenDimDoors/mod_pocketDim/blocks/linkExitDoor.java
Normal file
56
StevenDimDoors/mod_pocketDim/blocks/linkExitDoor.java
Normal file
@@ -0,0 +1,56 @@
|
||||
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