Created build.gradle
Restructured folder structure for ForgeGradle Signed-off-by: deathrat <deathrat43@gmail.com>
This commit is contained in:
@@ -0,0 +1,432 @@
|
||||
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.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
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.schematic.BlockRotator;
|
||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName()+"_top");
|
||||
this.blockIconBottom = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName()+"_bottom");
|
||||
}
|
||||
|
||||
@Override
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
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 = MathHelper.floor_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 = MathHelper.floor_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
|
||||
*/
|
||||
@Override
|
||||
@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.
|
||||
*/
|
||||
@Override
|
||||
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, (EntityLivingBase) 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, EntityLivingBase 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 = MathHelper.floor_double((entity.rotationYaw + 90) * 4.0F / 360.0F + 0.5D) & 3;
|
||||
return ((metadata & 3) == direction);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
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.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
|
||||
{
|
||||
private static final float SUPER_HIGH_HARDNESS = 10000000000000F;
|
||||
private static final float SUPER_EXPLOSION_RESISTANCE = 18000000F;
|
||||
private Icon[] blockIcon = new Icon[2];
|
||||
|
||||
public BlockDimWall(int blockID, int j, Material par2Material)
|
||||
{
|
||||
super(blockID, Material.ground);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness(World world, int x, int y, int z)
|
||||
{
|
||||
if (world.getBlockMetadata(x, y, z) == 0)
|
||||
{
|
||||
return this.blockHardness;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SUPER_HIGH_HARDNESS;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExplosionResistance(Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
|
||||
{
|
||||
if (world.getBlockMetadata(x, y, z) == 0)
|
||||
{
|
||||
return super.getExplosionResistance(entity, world, x, y, z, explosionX, explosionY, explosionZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
return SUPER_EXPLOSION_RESISTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon[0] = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
|
||||
this.blockIcon[1] = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName() + "Perm");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return (par2 != 1) ? blockIcon[0] : blockIcon[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int metadata)
|
||||
{
|
||||
//Return 0 to avoid dropping Ancient Fabric even if the player somehow manages to break it
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(int unknown, CreativeTabs tab, List subItems)
|
||||
{
|
||||
for (int ix = 0; ix < 2; ix++)
|
||||
{
|
||||
subItems.add(new ItemStack(this, 1, ix));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5) {}
|
||||
|
||||
@Override
|
||||
protected boolean canSilkHarvest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
//Check if the metadata value is 0 -- we don't want the user to replace Ancient Fabric
|
||||
if (entityPlayer.getCurrentEquippedItem() != null && world.getBlockMetadata(x, y, z) == 0)
|
||||
{
|
||||
Item playerEquip = entityPlayer.getCurrentEquippedItem().getItem();
|
||||
|
||||
if (playerEquip instanceof ItemBlock)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (!entityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
entityPlayer.getCurrentEquippedItem().stackSize--;
|
||||
}
|
||||
world.setBlock(x, y, z, entityPlayer.getCurrentEquippedItem().itemID, entityPlayer.getCurrentEquippedItem().getItemDamage(), 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
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.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
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)
|
||||
{
|
||||
super(i, Material.ground);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random par1Random)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
public void onEntityWalking(World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if (!world.isRemote && world.provider.dimensionId == properties.LimboDimensionID)
|
||||
{
|
||||
World overworld = DimensionManager.getWorld(0);
|
||||
if (overworld != null && entity instanceof EntityPlayerMP)
|
||||
{
|
||||
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
|
||||
destinationX = destinationX + (destinationX >> 4);
|
||||
destinationZ = destinationZ + (destinationZ >> 4);
|
||||
|
||||
int destinationY = yCoordHelper.getFirstUncovered(overworld, destinationX, 63, destinationZ, true);
|
||||
|
||||
//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...
|
||||
overworld.setBlockToAir(destinationX, destinationY, destinationZ);
|
||||
overworld.setBlockToAir(destinationX, destinationY + 1, destinationZ);
|
||||
|
||||
for (int xc = -3; xc < 4; xc++)
|
||||
{
|
||||
for (int zc = -3; zc < 4; zc++)
|
||||
{
|
||||
if (Math.abs(xc) + Math.abs(zc) < random.nextInt(3) + 2 ||
|
||||
Math.abs(xc) + Math.abs(zc) < random.nextInt(3) + 3)
|
||||
{
|
||||
overworld.setBlock(destinationX + xc, destinationY - 1, destinationZ + zc, properties.LimboBlockID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//FIXME: Why do we do this repeatedly? We also set the fall distance at the start...
|
||||
player.setPositionAndUpdate( destinationX, destinationY, destinationZ );
|
||||
player.fallDistance = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
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.item.Item;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class BlockDoorGold extends BlockDoor
|
||||
{
|
||||
|
||||
private Icon blockIconBottom;
|
||||
@SuppressWarnings("unused") // ??
|
||||
private DDProperties properties;
|
||||
|
||||
public BlockDoorGold(int par1, Material par2Material,DDProperties properties)
|
||||
{
|
||||
super(par1, par2Material);
|
||||
this.properties=properties;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName()+"_top");
|
||||
this.blockIconBottom = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName()+"_bottom");
|
||||
}
|
||||
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return mod_pocketDim.itemGoldDoor.itemID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
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.TileEntityDimDoorGold;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BlockGoldDimDoor extends BaseDimDoor
|
||||
{
|
||||
|
||||
public BlockGoldDimDoor(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 mod_pocketDim.itemGoldDoor.itemID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
return new TileEntityDimDoorGold();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
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.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.LimboDecay;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockLimbo extends Block
|
||||
{
|
||||
private final int limboDimensionID;
|
||||
private final LimboDecay decay;
|
||||
|
||||
public BlockLimbo(int i, int j, Material par2Material, int limboDimensionID, LimboDecay decay)
|
||||
{
|
||||
super(i, Material.ground);
|
||||
this.limboDimensionID = limboDimensionID;
|
||||
this.decay = decay;
|
||||
this.setTickRandomly(true);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public Icon getBlockTexture(IBlockAccess blockAccess, int x, int y, int z, int side)
|
||||
{
|
||||
return this.getIcon(side, blockAccess.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister iconRegister)
|
||||
{
|
||||
this.blockIcon = iconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the block is in Limbo, attempt to decay surrounding blocks upon receiving a random update tick.
|
||||
*/
|
||||
@Override
|
||||
public void updateTick(World world, int x, int y, int z, Random random)
|
||||
{
|
||||
//Make sure this block is in Limbo
|
||||
if (world.provider.dimensionId == limboDimensionID)
|
||||
{
|
||||
decay.applySpreadDecay(world, x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
370
src/main/java/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java
Normal file
370
src/main/java/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java
Normal file
@@ -0,0 +1,370 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
import java.util.Random;
|
||||
|
||||
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.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
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;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockRift extends BlockContainer
|
||||
{
|
||||
private static final float MIN_IMMUNE_HARDNESS = 200.0F;
|
||||
private static final int BLOCK_DESTRUCTION_RANGE = 4;
|
||||
private static final int BLOCK_DESTRUCTION_VOLUME = (int) Math.pow(2 * BLOCK_DESTRUCTION_RANGE + 1, 3);
|
||||
private static final int MAX_BLOCK_SEARCH_CHANCE = 100;
|
||||
private static final int BLOCK_SEARCH_CHANCE = 50;
|
||||
private static final int MAX_BLOCK_DESTRUCTION_CHANCE = 100;
|
||||
private static final int BLOCK_DESTRUCTION_CHANCE = 50;
|
||||
|
||||
private final DDProperties properties;
|
||||
private final ArrayList<Integer> blocksImmuneToRift;
|
||||
|
||||
public BlockRift(int i, int j, Material par2Material, DDProperties properties)
|
||||
{
|
||||
super(i, par2Material);
|
||||
this.setTickRandomly(true);
|
||||
this.properties = properties;
|
||||
this.blocksImmuneToRift = new ArrayList<Integer>();
|
||||
this.blocksImmuneToRift.add(properties.FabricBlockID);
|
||||
this.blocksImmuneToRift.add(properties.PermaFabricBlockID);
|
||||
this.blocksImmuneToRift.add(properties.DimensionalDoorID);
|
||||
this.blocksImmuneToRift.add(properties.WarpDoorID);
|
||||
this.blocksImmuneToRift.add(properties.TransTrapdoorID);
|
||||
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);
|
||||
this.blocksImmuneToRift.add(Block.blockGold.blockID);
|
||||
this.blocksImmuneToRift.add(Block.blockLapis.blockID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
|
||||
}
|
||||
|
||||
//sends a packet informing the client that there is a link present so it renders properly. (when placed)
|
||||
@Override
|
||||
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());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5) {}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this block is collideable based on the arguments passed in Args: blockMetaData, unknownFlag
|
||||
*/
|
||||
@Override
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
public boolean isBlockSolid(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//this doesnt do anything yet.
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
if(mod_pocketDim.isPlayerWearingGoogles)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
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)
|
||||
*/
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
//function that regulates how many blocks it eats/ how fast it eats them.
|
||||
@Override
|
||||
public void updateTick(World world, int x, int y, int z, Random random)
|
||||
{
|
||||
if (properties.RiftGriefingEnabled && !world.isRemote &&
|
||||
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.
|
||||
if (random.nextInt(MAX_BLOCK_SEARCH_CHANCE) < BLOCK_SEARCH_CHANCE &&
|
||||
((TileEntityRift) world.getBlockTileEntity(x, y, z)).isNearRift )
|
||||
{
|
||||
destroyNearbyBlocks(world, x, y, z, random);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void destroyNearbyBlocks(World world, int x, int y, int z, Random random)
|
||||
{
|
||||
HashMap<Point3D, Integer> pointDistances = new HashMap<Point3D, Integer>(BLOCK_DESTRUCTION_VOLUME);
|
||||
Queue<Point3D> points = new LinkedList<Point3D>();
|
||||
|
||||
//Perform a breadth-first search outwards from the point at which the rift is located. Record the distances
|
||||
//of the points we visit to stop the search at its maximum range.
|
||||
pointDistances.put(new Point3D(x, y, z), 0);
|
||||
addAdjacentBlocks(x, y, z, 0, pointDistances, points);
|
||||
while (!points.isEmpty())
|
||||
{
|
||||
Point3D current = points.remove();
|
||||
int distance = pointDistances.get(current);
|
||||
|
||||
//If the current block is air, continue searching. Otherwise, try destroying the block.
|
||||
if (world.isAirBlock(current.getX(), current.getY(), current.getZ()))
|
||||
{
|
||||
//Make sure we stay within the search range
|
||||
if (distance < BLOCK_DESTRUCTION_RANGE)
|
||||
{
|
||||
addAdjacentBlocks(current.getX(), current.getY(), current.getZ(), distance, pointDistances, points);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Check if the current block is immune to destruction by rifts. If not, randomly decide whether to destroy it.
|
||||
//The randomness makes it so the destroyed area appears "noisy" if the rift is exposed to a large surface.
|
||||
if (!isBlockImmune(world, current.getX(), current.getY(), current.getZ()) &&
|
||||
random.nextInt(MAX_BLOCK_DESTRUCTION_CHANCE) < BLOCK_DESTRUCTION_CHANCE)
|
||||
{
|
||||
world.setBlockToAir(current.getX(), current.getY(), current.getZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addAdjacentBlocks(int x, int y, int z, int distance, HashMap<Point3D, Integer> pointDistances, Queue<Point3D> points)
|
||||
{
|
||||
Point3D[] neighbors = new Point3D[] {
|
||||
new Point3D(x - 1, y, z),
|
||||
new Point3D(x + 1, y, z),
|
||||
new Point3D(x, y - 1, z),
|
||||
new Point3D(x, y + 1, z),
|
||||
new Point3D(x, y, z - 1),
|
||||
new Point3D(x, y, z + 1)
|
||||
};
|
||||
for (int index = 0; index < neighbors.length; index++)
|
||||
{
|
||||
if (!pointDistances.containsKey(neighbors[index]))
|
||||
{
|
||||
pointDistances.put(neighbors[index], distance + 1);
|
||||
points.add(neighbors[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@Override
|
||||
@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);
|
||||
|
||||
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);
|
||||
|
||||
Xoffset= ((0.25F/(1+Math.abs(xChange))));
|
||||
|
||||
Yoffset= ((0.25F/(1+Math.abs(yChange))));
|
||||
Zoffset= ((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 boolean isBlockImmune(World world, int x, int y, int z)
|
||||
{
|
||||
Block block = Block.blocksList[world.getBlockId(x, y, z)];
|
||||
if (block != null)
|
||||
{
|
||||
float hardness = block.getBlockHardness(world, x, y, z);
|
||||
return (hardness < 0 || hardness >= MIN_IMMUNE_HARDNESS || blocksImmuneToRift.contains(block.blockID));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1)
|
||||
{
|
||||
return new TileEntityRift();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
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;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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.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.tileentities.TileEntityTransTrapdoor;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
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.getUnlocalizedName());
|
||||
}
|
||||
|
||||
//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);
|
||||
}
|
||||
|
||||
@Override
|
||||
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,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package StevenDimDoors.mod_pocketDim.blocks;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
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 net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
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)
|
||||
{
|
||||
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 EntityPlayer)
|
||||
{
|
||||
// Don't check for non-living entities since it might not work right
|
||||
canUse = BaseDimDoor.isEntityFacingDoor(metadata, (EntityLivingBase) 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user