public static void tickFlashLight(ItemStack i, World w, EntityPlayer e, boolean par5) {
if(i.getTagCompound() == null) {
i.setTagCompound(new NBTTagCompound());
}
if(!par5) {
i.getTagCompound().setBoolean("on", false);
} else {
if(i.getTagCompound().getInteger("Charge") > 0 && i.getTagCompound().getBoolean("on")) {
i.getTagCompound().setInteger("Charge", i.getTagCompound().getInteger("Charge") - 1);
}
if(i.getTagCompound().getInteger("Charge") == 0) {
i.getTagCompound().setBoolean("on", false);
}
if(!w.isRemote && i.getTagCompound().getBoolean("on")) {
Vec3 vec3 = w.getWorldVec3Pool().getVecFromPool(e.posX, e.posY + (double)e.getEyeHeight(), e.posZ);
/*
* Здесь обозначается дальность света фонаря, значения 10.0D etc.;
*/
Vec3 vec31 = w.getWorldVec3Pool().getVecFromPool(e.posX + e.getLookVec().xCoord * 10.0D, e.posY + e.getLookVec().yCoord * 10.0D + (double)e.getEyeHeight(), e.posZ + e.getLookVec().zCoord * 10.0D);
MovingObjectPosition b = w.rayTraceBlocks_do_do(vec3, vec31, true, false);
if(b != null) {
int side = b.sideHit;
int x = b.blockX;
int y = b.blockY;
int z = b.blockZ;
if(w.getBlockId(x, y, z) == 3899) {
BlockLightTile t = (BlockLightTile)w.getBlockTileEntity(x, y, z);
if(t != null) {
t.timer = 0;
}
} else {
if(side == 1) {
if(w.getBlockId(x, y + 1, z) == 31) {
if(w.getBlockId(x, y + 2, z) == 0) {
w.setBlock(x, y + 2, z, 3899);
}
return;
}
if(w.getBlockId(x, y + 1, z) == 0) {
w.setBlock(x, y + 1, z, 3899);
} else if(w.getBlockId(-((int)(e.getLookVec().xCoord * 1.5D)) + x, y + 1, -((int)(e.getLookVec().zCoord * 1.5D)) + z) == 0) {
w.setBlock(-((int)(e.getLookVec().xCoord * 1.5D)) + x, y + 1, -((int)(e.getLookVec().zCoord * 1.5D)) + z, 3899);
}
return;
}
if(side == 0) {
if(w.getBlockId(x, y - 1, z) == 0) {
w.setBlock(x, y - 1, z, 3899);
} else if(w.getBlockId(-((int)(e.getLookVec().xCoord * 1.5D)) + x, y - 1, -((int)(e.getLookVec().zCoord * 1.5D)) + z) == 0) {
w.setBlock(-((int)(e.getLookVec().xCoord * 1.5D)) + x, y - 1, -((int)(e.getLookVec().zCoord * 1.5D)) + z, 3899);
}
return;
}
if(side == 4) {
if(w.getBlockId(x - 1, y, z) == 0) {
w.setBlock(x - 1, y, z, 3899);
} else if(w.getBlockId(x, y + 1, z) == 0) {
w.setBlock(x, y + 1, z, 3899);
}
return;
}
if(side == 3) {
if(w.getBlockId(x, y, z + 1) == 0) {
w.setBlock(x, y, z + 1, 3899);
} else if(w.getBlockId(x, y + 1, z) == 0) {
w.setBlock(x, y + 1, z, 3899);
}
return;
}
if(side == 5) {
if(w.getBlockId(x + 1, y, z) == 0) {
w.setBlock(x + 1, y, z, 3899);
} else if(w.getBlockId(x, y + 1, z) == 0) {
w.setBlock(x, y + 1, z, 3899);
}
return;
}
if(side == 2) {
if(w.getBlockId(x, y, z - 1) == 0) {
w.setBlock(x, y, z - 1, 3899);
} else if(w.getBlockId(x, y + 1, z) == 0) {
w.setBlock(x, y + 1, z, 3899);
}
return;
}
}
}
}
}
}